Josh Posted May 29, 2021 Share Posted May 29, 2021 The menu system uses multiple windows, one for each menu or submenu. This also demonstrates dialogs and the requester. The behavior here is fairly complex, one of the most difficult parts of this project. I think a little more work on the spacing would make it look better, but it looks the same as the Windows version. Menu.zip 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...
Josh Posted May 30, 2021 Author Share Posted May 30, 2021 #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR | WINDOW_CENTER | WINDOW_RESIZABLE); //window->Activate(); //Create User Interface auto ui = CreateInterface(window); //Create widget auto sz = ui->root->ClientSize(); auto menu = CreateMenu("", ui->root); //Create menu items auto menu_file = CreateMenu("File", menu); const auto menu_new = CreateMenu("New", menu_file); auto menu_open = CreateMenu("Open", menu_file); auto menu_save = CreateMenu("Save", menu_file); CreateMenu("", menu_file); auto menu_recentfiles = CreateMenu("Recent Files", menu_file); std::array<shared_ptr<Widget>, 10> menu_recentfile; for (int n = 0; n < menu_recentfile.size(); ++n) { menu_recentfile[n] = CreateMenu("Recent file " + String(n+1), menu_recentfiles); } CreateMenu("", menu_file); auto menu_exit = CreateMenu("Exit", menu_file); auto menu_tools = CreateMenu("Tools", menu); const auto menu_option = CreateMenu("Option", menu_tools); auto menu_help = CreateMenu("Help", menu); const auto menu_helpcontents = CreateMenu("Help Contents", menu_help); auto panel = CreatePanel(0, menu->size.y, sz.x, sz.y - menu->size.y, ui->root); panel->SetColor(0.15, 0.15, 0.15); panel->SetLayout(1,1,1,1); while (true) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WIDGETACTION: if (ev.source == menu_new) { Confirm("Create New?"); } else if (ev.source == menu_open) { RequestFile(); } else if (ev.source == menu_option) { if (menu_option->GetState() == WIDGETSTATE_SELECTED) { menu_option->SetState(WIDGETSTATE_UNSELECTED); } else { menu_option->SetState(WIDGETSTATE_SELECTED); } } else if (ev.source == menu_save) { RequestFile("Save File", "", "All Files:*", 0, true); } else if (ev.source == menu_exit) { if (Confirm("Quit Program?")) return 0; } else if (ev.source == menu_helpcontents) { RunFile("https://www.ultraengine.com/learn"); } else { Notify(ev.source->As<Widget>()->text); } break; case EVENT_WINDOWCLOSE: if (ev.source == window) return 0; break; } } return 0; } 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...
aiaf Posted May 31, 2021 Share Posted May 31, 2021 When i hover Tools or Help and click for the first time, the text in the menu is not shown. Then it appears after i move the mouse or something. The file menu doesn't have the above issue. The File -> Recent Files and Help -> Help contents texts in gui are cut , onyl half of the last s is shown. Using 150% Scale UI. 1 Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station 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.