Jump to content

[SOLVED] Rendering something ABOVE the console?


photo

Recommended Posts

Hi, I'm trying to have a sprite render over the console. The doc says Widget::setOrder() can be used, with a value from -127 for the profiler and 127 for the console.

I tried 127, but the console is still above. I tried 255, but nope, still it displays below the console. Is it possible to force something above the console?

Rationale: we are displaying binary data encoded into the image, which is video recorded, and then later decoded. But sometimes we need to open the console and this will corrupt the encoded data, of course.

Link to comment

Hello,

For widgets 127 is the maximum order value. Set this value for the widget and also use the flags ALIGN_OVERLAP and ALIGN_FIXED when adding to the window. Here is a small example:

int AppSystemLogic::init()
{
	ImagePtr img = Image::create();
	img->create2D(256, 256, Image::FORMAT_RGBA8);
	for (int i = 0; i < 256; i++)
	{
		for (int j = 0; j < 256; j++)
			img->set2D(i, j, Image::Pixel(0, 255, 0, 255));
	}

	WidgetSpritePtr overlap_sprite = WidgetSprite::create();
	overlap_sprite->setImage(img);
	overlap_sprite->setOrder(127);

	EngineWindowPtr main_window = WindowManager::getMainWindow();
	main_window->addChild(overlap_sprite, Gui::ALIGN_OVERLAP | Gui::ALIGN_FIXED);

	return 1;
}

image.png

Link to comment

Each window contains a WidgetVBox which is responsible for the widgets in the client area. The idea was to add the sprite after adding the console and not let it reorder. For a test you can try adding this widget last among all the widgets in the window. For example:

int AppSystemLogic::update()
{
	EngineWindowPtr main_window = WindowManager::getMainWindow();
	int num = main_window->getNumChildren();
	if (num != 0 && main_window->getChild(num - 1) != overlap_sprite)
	{
		overlap_sprite->setParent(nullptr);
		overlap_sprite->setOrder(127);
		main_window->addChild(overlap_sprite, Gui::ALIGN_OVERLAP);
		overlap_sprite->setFlags(Gui::ALIGN_OVERLAP | Gui::ALIGN_FIXED);
	}

	return 1;
}

 

  • Like 1
Link to comment
  • silent changed the title to [SOLVED] Rendering something ABOVE the console?
×
×
  • Create New...