Josh Posted January 7, 2023 Author Share Posted January 7, 2023 On 1/3/2023 at 7:49 AM, Dreikblack said: If i understand correctly your case and how mouse/keys events works a callbacks triggers only for upper UI element under mouse cursor. In UAK i solved it for my custom widgets by calling parent event methods void InnerContainer::MouseEnter(const int x, const int y) { GetParent()->MouseEnter(x, y); } I want to note that MouseEnter() etc. are now protected methods. They can be accessed from a subclass of Widget, but not from outside the class. However, you can duplicate this behavior by feeding an event into Interface::ProcessEvent. 1 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...
SpiderPig Posted January 8, 2023 Share Posted January 8, 2023 Have just noticed while the clipping of widgets is off by 1 pixel, a child of clipped widget is not clipped at all. Here the blue panel is a child of the red, which is very large and extends well beyond the region of the green panel. Perhaps the two clipping issues are related. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto w1 = CreatePanel(20, 20, 128, 128, ui->root); w1->SetColor(0, 1, 0); auto w2 = CreatePanel(-10, 10, 1024, 64, w1); w2->SetColor(1, 0, 0); auto w3 = CreatePanel(512, 10, 32, 32, w2); w3->SetColor(0, 0, 1); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); ui->ProcessEvent(ev); } world->Update(); world->Render(framebuffer); } return 0; } 1 Link to comment Share on other sites More sharing options...
reepblue Posted January 8, 2023 Share Posted January 8, 2023 Can we get a Quote String/WString function? I made one in my core static library similar how Leadwerks would have it. I have a terrible time remembering how to format the string to show quotes and this makes it easier. std::string String::Quote(const std::string& s) { return "\"" + s + "\""; } The usage could be something like this: UltraEngine::String str = "Hello World!"; UltraEngine::Print(str.Quote()); Output: "Hello World!" 1 Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted January 9, 2023 Author Share Posted January 9, 2023 10 hours ago, reepblue said: Can we get a Quote String/WString function? I made one in my core static library similar how Leadwerks would have it. I have a terrible time remembering how to format the string to show quotes and this makes it easier. I don't feel like the usage of this is common enough to warrant a method. Update Fixed widget clipping 1 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...
klepto2 Posted January 9, 2023 Share Posted January 9, 2023 Updated my Repo here: https://github.com/klepto2/UltraEngineUtilities Added a ShaderWatcher: It establishes a FilesystemWatch and keeps track of all used shaders in Shaderfamilies. - Runtime compilation of shaders - Automatically reloading shader assets after compilation - Error-Reports for each shader Missing: Handling Renaming and Deletion of json files Known issues: Notepadd++ uses a way to save files which will trigger the FILECHANGED - EVENT multiple times. I guess i need some way to store some hashvalues for the files. #include "UltraEngine.h" #include "ComponentSystem.h" #include "include\Utilities.h" using namespace UltraEngine; using namespace UltraEngine::Utilities::Shader; int main(int argc, const char* argv[]) { auto watcher = CreateShaderWatcher(); watcher->Start(); ... } 2 Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
SpiderPig Posted January 9, 2023 Share Posted January 9, 2023 4 hours ago, Josh said: Update Fixed widget clipping After updating I'm getting a consistent exception thrown with the example I posted above for this issue. Same with my other project too. It's not giving me anymore details. Link to comment Share on other sites More sharing options...
Josh Posted January 9, 2023 Author Share Posted January 9, 2023 Cleaned and rebuilt the library. 1 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...
SpiderPig Posted January 9, 2023 Share Posted January 9, 2023 Thankyou, it all compiles now and that example works fine. But my UI has cracked it. 😧 It's probably because some of the child widgets are the exact same size as their parents but I will have to look into this tomorrow as right now I require slumber. 😴 1 Link to comment Share on other sites More sharing options...
klepto2 Posted January 9, 2023 Share Posted January 9, 2023 Ingame realtime Shaderediting: 4 1 Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted January 9, 2023 Author Share Posted January 9, 2023 That's crazy! How is the IDE text being drawn? 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...
klepto2 Posted January 9, 2023 Share Posted January 9, 2023 It is a slightly modified and updated to the latest version of ultraengine of this: It is not rendered in Vulkan directly, so it will not work when rendered to a texture, but for general purpose ingame editors it will work as well as if it is directly attached to a window. I just needed to modify some syntax changes and change some scrolling and draw behavior. 2 Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
SpiderPig Posted January 9, 2023 Share Posted January 9, 2023 The escape isn't quitting the application anymore either... #include "Engine.h" #include "DynamicUI.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; } 1 Link to comment Share on other sites More sharing options...
SpiderPig Posted January 9, 2023 Share Posted January 9, 2023 I'm trying to find the source of my UI issue, what does widget->clipregion represent? In one case it is 0,0,1,1. Does this mean it is only drawing one pixel of that widget and it is the top left corner? I read it wrong. It's 0,0,1,0. Link to comment Share on other sites More sharing options...
SpiderPig Posted January 10, 2023 Share Posted January 10, 2023 I've found part (hopefully all) of the problem. Setting the shape of the widget is not triggering a refresh of the clipping data. I also couldn't get any key input to work. I only tried a few keys but they're not working since the last update. #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto w1 = CreatePanel(20, 20, 128, 128, ui->root); w1->SetColor(0, 1, 0); auto w2 = CreatePanel(0, 0, 1, 1, w1); w2->SetColor(1, 0, 0); auto w3 = CreatePanel(-10, -10, 32, 32, w2); w3->SetColor(0, 0, 1); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); ui->ProcessEvent(ev); } if (window->MouseHit(MOUSE_RIGHT)) { w2->SetShape(0, 0, 256, 256); } world->Update(); world->Render(framebuffer); } return 0; } Link to comment Share on other sites More sharing options...
Josh Posted January 10, 2023 Author Share Posted January 10, 2023 3 hours ago, SpiderPig said: I've found part (hopefully all) of the problem. Setting the shape of the widget is not triggering a refresh of the clipping data. When I right-click the mouse the red panel appears. Maybe your installation is not up to date? 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...
SpiderPig Posted January 10, 2023 Share Posted January 10, 2023 10 minutes ago, Josh said: When I right-click the mouse the red panel appears. Maybe your installation is not up to date? That's correct but the blue panel remains at 1x1 pixels. It is 32x32 panel and is offset by -10,-10. So you should see a 22x22 blue square in the top left corner but it remains as a 1x1 pixel. Link to comment Share on other sites More sharing options...
Josh Posted January 10, 2023 Author Share Posted January 10, 2023 Update Fixed keydown state not working Fixed widget clipping bug 1 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...
SpiderPig Posted January 10, 2023 Share Posted January 10, 2023 Thankyou those issues are fixed. But now there is another - when a child moves out of bounds and should be hidden completely it seems to pile up. Here's a shot in my game of what's happening when I scroll some items on the left, and a smaller example is below. Just move the red panel around with the arrow keys. #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto w1 = CreatePanel(20, 20, 128, 128, ui->root); w1->SetColor(0, 1, 0); auto w2 = CreatePanel(0, 0, 1, 1, w1); w2->SetColor(1, 0, 0); auto w3 = CreatePanel(0, 0, 32, 32, w2); w3->SetColor(0, 0, 1); auto p = iVec2(); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); ui->ProcessEvent(ev); } if (window->KeyDown(KEY_UP)) { w2->SetShape(p.x, p.y -= 1, 256, 256); } else if (window->KeyDown(KEY_DOWN)) { w2->SetShape(p.x, p.y += 1, 256, 256); } if (window->KeyDown(KEY_LEFT)) { w2->SetShape(p.x -= 1, p.y, 256, 256); } else if (window->KeyDown(KEY_RIGHT)) { w2->SetShape(p.x += 1, p.y, 256, 256); } world->Update(); world->Render(framebuffer); } return 0; } Link to comment Share on other sites More sharing options...
Josh Posted January 10, 2023 Author Share Posted January 10, 2023 Fixed! 1 1 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...
klepto2 Posted January 10, 2023 Share Posted January 10, 2023 This is how the ShaderEditor looks like when styled the UltraEngine way and with proper glsl highlighting: 3 Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
SpiderPig Posted January 10, 2023 Share Posted January 10, 2023 Working pretty good now. There is a noticeable delay (less so in release) when scrolling a lot of widgets. I'm using SetShape() to position them as I move the wheel. I tried a smaller example but it looked fine as it wasn't scrolling many widgets. It looks like when the clipping region encompasses the whole widget they are then hidden? Either way you might consider this a minor cosmetic issue but I'll mention it none the less. If you want I can put together a larger example tonight. Link to comment Share on other sites More sharing options...
Josh Posted January 10, 2023 Author Share Posted January 10, 2023 8 minutes ago, SpiderPig said: Working pretty good now. There is a noticeable delay (less so in release) when scrolling a lot of widgets. I'm using SetShape() to position them as I move the wheel. I tried a smaller example but it looked fine as it wasn't scrolling many widgets. It looks like when the clipping region encompasses the whole widget they are then hidden? Either way you might consider this a minor cosmetic issue but I'll mention it none the less. If you want I can put together a larger example tonight. I've been waiting for someone to mention this.... What you are seeing is happening because the culling is asynchronous. When you quickly scroll some items pop into view, but since a new visibility list has not been received from the culling thread, it does not draw the new objects that are in view yet. You can get the same effect with a listbox with many items or a treeview. There are some different possible solutions for this. I could make the camera culling frustum bigger, or disable frustum culling on a per-object basis. It is probably best to get the engine in people's hands first, see how it gets used, and then decide on a solution. 1 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...
klepto2 Posted January 10, 2023 Share Posted January 10, 2023 You can try to implement some kind of virtualization. If all elements in you list are of the same size, you can just create as much as is visible. If you scroll you can recycle the ones which are out of view and put them in a cache. Then you calculate which items are in view and you pop the items from the cache and update there position. If the size changes and more items are visible than are in the cache, just create new items. 1 1 Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
SpiderPig Posted January 10, 2023 Share Posted January 10, 2023 I thought it might have something to do with that. I agree, get it out there and then see. Could disable culling on scrollable items? Or some sort of prediction method as you've mentioned before? Link to comment Share on other sites More sharing options...
SpiderPig Posted January 11, 2023 Share Posted January 11, 2023 Does the label widget support text with shadows? Or is this a job for a custom widget? Link to comment Share on other sites More sharing options...
Recommended Posts