Amerio.Stephane Posted March 27, 2023 Share Posted March 27, 2023 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
karpych11 Posted March 28, 2023 Share Posted March 28, 2023 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; } Link to comment
Amerio.Stephane Posted March 28, 2023 Author Share Posted March 28, 2023 Hum nope, doesn't work for me :( Same code, same location. Maybe there is something else that could interfere? Link to comment
silent Posted March 28, 2023 Share Posted March 28, 2023 Are you using 2.16.1 SDK? How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
karpych11 Posted March 28, 2023 Share Posted March 28, 2023 Is the console used only in one window or in several? Link to comment
karpych11 Posted March 28, 2023 Share Posted March 28, 2023 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; } 1 Link to comment
Amerio.Stephane Posted March 28, 2023 Author Share Posted March 28, 2023 It works with this code! Thanks! Link to comment
Recommended Posts