diff --git a/src/GUIStuff/GUIManager.cpp b/src/GUIStuff/GUIManager.cpp index ae5f323..6b6991a 100644 --- a/src/GUIStuff/GUIManager.cpp +++ b/src/GUIStuff/GUIManager.cpp @@ -562,7 +562,7 @@ bool GUIManager::font_picker(const std::string& id, std::string* fontName) { return toRet; } -void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::vector& selections, float width, const std::function& hoverboxElemUpdate) { +void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::vector& selections, float width, float maxHeight, const std::function& hoverboxElemUpdate) { push_id(id); bool& dropDownOpen = insert_any_with_id(0, false); left_to_right_layout(CLAY_SIZING_FIXED(width), CLAY_SIZING_FIT(0), [&]() { @@ -590,7 +590,8 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std:: if(dropDownOpen) { CLAY({ .layout = { - .sizing = {.width = CLAY_SIZING_FIXED(width), .height = CLAY_SIZING_FIT(0)}, + .sizing = {.width = CLAY_SIZING_FIXED(width), .height = CLAY_SIZING_FIT(0, maxHeight)}, + .childGap = 0 }, .backgroundColor = convert_vec4(io->theme->backColor1), .cornerRadius = CLAY_CORNER_RADIUS(4), @@ -610,44 +611,42 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std:: } }) { obstructing_window(); - CLAY({ - .layout = { - .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)}, - .childGap = 1, - .childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP}, - .layoutDirection = CLAY_TOP_TO_BOTTOM - } - }) { - for(size_t i = 0; i < selections.size(); i++) { - bool selectedEntry = *val == i; + scroll_bar_many_entries_area("dropdown scroll area", 18.0f, selections.size(), [&](size_t i, bool) { + bool selectedEntry = *val == i; + + CLAY({ + .layout = { + .sizing = {.width = CLAY_SIZING_FIXED(250), .height = CLAY_SIZING_FIXED(18)}, + .padding = CLAY_PADDING_ALL(0), + .childGap = 0, + .childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER}, + .layoutDirection = CLAY_TOP_TO_BOTTOM + } + }) { + SkColor4f entryColor; + if(selectedEntry) + entryColor = io->theme->backColor2; + else if(Clay_Hovered()) + entryColor = io->theme->backColor2; + else + entryColor = io->theme->backColor1; CLAY({ .layout = { - .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)} + .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}, + .padding = {.left = 2, .right = 2, .top = 0, .bottom = 0}, + .childGap = 0, + .childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER} }, + .backgroundColor = convert_vec4(entryColor) }) { - SkColor4f entryColor; - if(selectedEntry) - entryColor = io->theme->backColor2; - else if(Clay_Hovered()) - entryColor = io->theme->backColor2; - else - entryColor = io->theme->backColor1; - CLAY({ - .layout = { - .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)}, - .padding = {.left = 2, .right = 2}, - }, - .backgroundColor = convert_vec4(entryColor) - }) { - text_label(selections[i]); - if(io->mouse.leftClick && Clay_Hovered()) { - *val = i; - dropDownOpen = false; - } + text_label(selections[i]); + if(io->mouse.leftClick && Clay_Hovered()) { + *val = i; + dropDownOpen = false; } } } - } + }); if(hoverboxElemUpdate) hoverboxElemUpdate(); } diff --git a/src/GUIStuff/GUIManager.hpp b/src/GUIStuff/GUIManager.hpp index b3384a2..d874522 100644 --- a/src/GUIStuff/GUIManager.hpp +++ b/src/GUIStuff/GUIManager.hpp @@ -97,7 +97,7 @@ class GUIManager { void input_path(const std::string& id, std::filesystem::path* val, std::filesystem::file_type fileTypeRestriction, const std::function& elemUpdate = nullptr); void input_path_field(const std::string& id, const std::string& name, std::filesystem::path* val, std::filesystem::file_type fileTypeRestriction, const std::function& elemUpdate = nullptr); - void dropdown_select(const std::string& id, size_t* val, const std::vector& selections, float width = 200.0f, const std::function& hoverboxElemUpdate = nullptr); + void dropdown_select(const std::string& id, size_t* val, const std::vector& selections, float width = 200.0f, float maxHeight = 0.0f, const std::function& hoverboxElemUpdate = nullptr); void paint_circle_popup_menu(const std::string& id, const Vector2f& centerPos, const PaintCircleMenu::Data& val, const std::function& elemUpdate = nullptr); diff --git a/src/RichTextBox/TextStyleModifier.cpp b/src/RichTextBox/TextStyleModifier.cpp index c273845..ec1bf3c 100644 --- a/src/RichTextBox/TextStyleModifier.cpp +++ b/src/RichTextBox/TextStyleModifier.cpp @@ -181,7 +181,9 @@ void FontFamiliesTextStyleModifier::load(cereal::PortableBinaryInputArchive& a) } void FontFamiliesTextStyleModifier::modify_text_style(skia::textlayout::TextStyle& style) const { - style.setFontFamilies(families); + auto familiesToPush = families; + familiesToPush.emplace_back("Roboto"); + style.setFontFamilies(familiesToPush); } bool FontFamiliesTextStyleModifier::equivalent_data(TextStyleModifier& modifier) const { diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index 500c4ed..97db627 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -1136,7 +1136,7 @@ bool Toolbar::color_palette(const std::string& id, Vector4f* color, bool& hoveri std::vector paletteNames; for(auto& p : paletteData.palettes) paletteNames.emplace_back(p.name); - gui.dropdown_select("paletteselector", &paletteData.selectedPalette, paletteNames, 200.0f, [&]() { + gui.dropdown_select("paletteselector", &paletteData.selectedPalette, paletteNames, 200.0f, 90.0f, [&]() { hoveringOnDropdown = Clay_Hovered(); }); if(gui.svg_icon_button("paletteadd", "data/icons/plus.svg", paletteData.addingPalette, 25.0f)) paletteData.addingPalette = !paletteData.addingPalette;