Dreikblack Posted August 11 Share Posted August 11 #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> menuWold; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> panel; shared_ptr<Icon> icon; bool isFirst = true; void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(menuWold, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); panel = CreatePanel(10, 50, 64, 64, ui->root, PANEL_DEFAULT); icon = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/help.svg"); icon->SetColor(0.5, 0.5, 1.0); panel->SetIcon(icon); panel->Redraw(); } int main(int argc, const char* argv[]) { auto displays = GetDisplays(); window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_DEFAULT); menuWold = CreateWorld(); menuWold->RecordStats(); framebuffer = CreateFramebuffer(window); auto light = CreateBoxLight(menuWold); auto camera = CreateCamera(menuWold); camera->SetClearColor(0.125); initGui(); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { isFirst = !isFirst; if (isFirst) { panel->icon->SetColor(0.5, 0.5, 0.5); panel->SetIcon(panel->icon); panel->Redraw(); } else { panel->icon->SetColor(1.0, 1.0, 0.5); panel->SetIcon(panel->icon); panel->Redraw(); } } menuWold->Update(); menuWold->Render(framebuffer); } return 0; } Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted August 11 Author Share Posted August 11 Found work around with panel->SetIcon(nullptr); Quote Link to comment Share on other sites More sharing options...
Josh Posted August 15 Share Posted August 15 The way setIcon works is it rasterizes a pixmap with the required scale and applies that to the widget. Setting an icon color will clear all cached pixmaps the icon stores, but the icon does not store a list of widget it has been applied to. I could add this using weak pointers, but I am leaning towards leaving the current behavior alone, since it is a pretty rare use case. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dreikblack Posted August 15 Author Share Posted August 15 Can't say it's rare since color often shows current state of buttons or status of icons in games 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted October 14 Share Posted October 14 I considered it but there are two things that made me decide against it. An icon may be in use across many widgets, so using it to indicate state isn't a great idea. Rasterization is of an icon into a pixmap (which must be done to make it visible) is a relatively slow step and should be avoided in real-time. If anything, it would probably be better to have the widget foreground color affect the widget pixmap. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted October 28 Solution Share Posted October 28 I am going to mark this as solved and icons, for the time being, will be considered a vector image from which pixmaps are rasterized. I need to focus on the more basic functionality and make sure that works before adding more complexity. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.