From ba75f394e89fe3e3de0692f4f86c9e5f4c89f8d9 Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Sat, 22 Nov 2025 13:00:52 +0300 Subject: [PATCH] About menu and settings menu text can now wrap again --- src/GUIStuff/Elements/FontPicker.cpp | 2 +- src/GUIStuff/GUIManager.cpp | 10 +++++----- src/GUIStuff/GUIManager.hpp | 4 ++-- src/Toolbar.cpp | 20 ++++++++------------ 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/GUIStuff/Elements/FontPicker.cpp b/src/GUIStuff/Elements/FontPicker.cpp index b55c0d1..b341fae 100644 --- a/src/GUIStuff/Elements/FontPicker.cpp +++ b/src/GUIStuff/Elements/FontPicker.cpp @@ -103,7 +103,7 @@ bool GUIStuff::FontPicker::update(UpdateInputData& io, std::string* fontName, GU gui->obstructing_window(); if(Clay_Hovered()) clickedOut = false; - gui->scroll_bar_many_entries_area("Font Selector", ENTRY_HEIGHT, sortedFontList.size(), [fontName, gui, &fontChangedFromSelection, &sortedFontList = sortedFontList, val, &io = io](size_t i, bool listHovered) { + gui->scroll_bar_many_entries_area("Font Selector", ENTRY_HEIGHT, sortedFontList.size(), true, [fontName, gui, &fontChangedFromSelection, &sortedFontList = sortedFontList, val, &io = io](size_t i, bool listHovered) { bool selectedEntry = val == i; skia::textlayout::ParagraphStyle pStyle; diff --git a/src/GUIStuff/GUIManager.cpp b/src/GUIStuff/GUIManager.cpp index 77e5cea..b5db3db 100644 --- a/src/GUIStuff/GUIManager.cpp +++ b/src/GUIStuff/GUIManager.cpp @@ -613,7 +613,7 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std:: } }) { obstructing_window(); - scroll_bar_many_entries_area("dropdown scroll area", 18.0f, selections.size(), [&](size_t i, bool) { + scroll_bar_many_entries_area("dropdown scroll area", 18.0f, selections.size(), true, [&](size_t i, bool) { bool selectedEntry = *val == i; CLAY({ @@ -659,7 +659,7 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std:: pop_id(); } -void GUIManager::scroll_bar_area(const std::string& id, const std::function& elemUpdate) { +void GUIManager::scroll_bar_area(const std::string& id, bool clipHorizontal, const std::function& elemUpdate) { CLAY({ .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}, @@ -694,7 +694,7 @@ void GUIManager::scroll_bar_area(const std::string& id, const std::function& entryUpdate, const std::function& elemUpdate) { +void GUIManager::scroll_bar_many_entries_area(const std::string& id, float entryHeight, size_t entryCount, bool clipHorizontal, const std::function& entryUpdate, const std::function& elemUpdate) { push_id(id); - scroll_bar_area(id, [&](float scrollContentHeight, float containerHeight, float& scrollAmount) { + scroll_bar_area(id, clipHorizontal, [&](float scrollContentHeight, float containerHeight, float& scrollAmount) { if(elemUpdate) elemUpdate(scrollContentHeight, containerHeight, scrollAmount); diff --git a/src/GUIStuff/GUIManager.hpp b/src/GUIStuff/GUIManager.hpp index 34730e2..d7ab5e6 100644 --- a/src/GUIStuff/GUIManager.hpp +++ b/src/GUIStuff/GUIManager.hpp @@ -79,8 +79,8 @@ class GUIManager { void push_id(const std::string& id); void pop_id(); - void scroll_bar_area(const std::string& id, const std::function& elemUpdate); - void scroll_bar_many_entries_area(const std::string& id, float entryHeight, size_t entryCount, const std::function& entryUpdate, const std::function& elemUpdate = nullptr); + void scroll_bar_area(const std::string& id, bool clipHorizontal, const std::function& elemUpdate); + void scroll_bar_many_entries_area(const std::string& id, float entryHeight, size_t entryCount, bool clipHorizontal, const std::function& entryUpdate, const std::function& elemUpdate = nullptr); bool input_color_component_255(const std::string& id, float* val, const std::function& elemUpdate = nullptr); bool input_text(const std::string& id, std::string* val, bool updateEveryEdit = true, const std::function& elemUpdate = nullptr); diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index f777b81..52b45d6 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -704,7 +704,7 @@ void Toolbar::grid_menu(bool justOpened) { if(main.world->gridMan.sorted_grid_ids().empty()) gui.text_label_centered("No grids yet..."); ServerClientID toDelete{0, 0}; - gui.scroll_bar_many_entries_area("grid menu entries", entryHeight, main.world->gridMan.sorted_grid_ids().size(), [&](size_t i, bool isListHovered) { + gui.scroll_bar_many_entries_area("grid menu entries", entryHeight, main.world->gridMan.sorted_grid_ids().size(), true, [&](size_t i, bool isListHovered) { ServerClientID gridID = main.world->gridMan.sorted_grid_ids()[i]; WorldGrid& grid = main.world->gridMan.grids[gridID]; bool selectedEntry = gridID == gridMenu.gridSelected; @@ -798,7 +798,7 @@ void Toolbar::bookmark_menu(bool justOpened) { if(main.world->bMan.sorted_names().empty()) gui.text_label_centered("No bookmarks yet..."); std::string toDelete; - gui.scroll_bar_many_entries_area("bookmark menu entries", entryHeight, main.world->bMan.sorted_names().size(), [&](size_t i, bool isListHovered) { + gui.scroll_bar_many_entries_area("bookmark menu entries", entryHeight, main.world->bMan.sorted_names().size(), true, [&](size_t i, bool isListHovered) { const std::string& bookmark = main.world->bMan.sorted_names()[i]; bool selectedEntry = bookmark == bookMenu.newName; CLAY({ @@ -1423,7 +1423,7 @@ void Toolbar::options_menu() { .layoutDirection = CLAY_TOP_TO_BOTTOM } }) { - gui.scroll_bar_area("general settings scroll area", [&](float, float, float) { + gui.scroll_bar_area("general settings scroll area", false, [&](float, float, float) { CLAY({ .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) }, @@ -1724,17 +1724,14 @@ void Toolbar::about_menu_gui() { .layout = { .sizing = {.width = CLAY_SIZING_FIT(200), .height = CLAY_SIZING_FIT(0) }, .padding = CLAY_PADDING_ALL(io->theme->padding1), - .childGap = 1, .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP}, .layoutDirection = CLAY_TOP_TO_BOTTOM } }) { - gui.scroll_bar_area("About Menu Selector Scroll Area", [&](float, float, float) { + gui.scroll_bar_area("About Menu Selector Scroll Area", true, [&](float, float, float) { CLAY({ .layout = { - .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) }, - .padding = CLAY_PADDING_ALL(0), - .childGap = 1, + .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)} } }) { if(gui.text_button_left_transparent("infinipaintnoticebutton", "InfiniPaint", selectedLicense == -1)) selectedLicense = -1; @@ -1744,8 +1741,7 @@ void Toolbar::about_menu_gui() { CLAY({ .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) }, - .padding = CLAY_PADDING_ALL(0), - .childGap = 1, + .padding = CLAY_PADDING_ALL(1) } }) { gui.push_id(i); @@ -1756,7 +1752,7 @@ void Toolbar::about_menu_gui() { }); } gui.pop_id(); - gui.scroll_bar_area("About Menu Text Scroll Area", [&](float, float, float) { + gui.scroll_bar_area("About Menu Text Scroll Area", false, [&](float, float, float) { gui.text_label_size((selectedLicense == -1) ? ownLicenseText : thirdPartyLicenses[selectedLicense].second, 0.8f); }); }); @@ -1872,7 +1868,7 @@ void Toolbar::file_picker_gui() { filePicker.refreshEntries = false; } float entryHeight = 25.0f; - gui.scroll_bar_many_entries_area("file picker entries", entryHeight, filePicker.entries.size(), [&](size_t i, bool isListHovered) { + gui.scroll_bar_many_entries_area("file picker entries", entryHeight, filePicker.entries.size(), true, [&](size_t i, bool isListHovered) { const std::filesystem::path& entry = filePicker.entries[i]; bool selectedEntry = filePicker.currentSelectedPath == entry; CLAY({