Make all dropdowns scrollable at a specified maxHeight
This commit is contained in:
parent
d4492807fe
commit
c956ab7230
4 changed files with 37 additions and 36 deletions
|
|
@ -562,7 +562,7 @@ bool GUIManager::font_picker(const std::string& id, std::string* fontName) {
|
||||||
return toRet;
|
return toRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::vector<std::string>& selections, float width, const std::function<void()>& hoverboxElemUpdate) {
|
void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::vector<std::string>& selections, float width, float maxHeight, const std::function<void()>& hoverboxElemUpdate) {
|
||||||
push_id(id);
|
push_id(id);
|
||||||
bool& dropDownOpen = insert_any_with_id(0, false);
|
bool& dropDownOpen = insert_any_with_id(0, false);
|
||||||
left_to_right_layout(CLAY_SIZING_FIXED(width), CLAY_SIZING_FIT(0), [&]() {
|
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) {
|
if(dropDownOpen) {
|
||||||
CLAY({
|
CLAY({
|
||||||
.layout = {
|
.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<Clay_Color>(io->theme->backColor1),
|
.backgroundColor = convert_vec4<Clay_Color>(io->theme->backColor1),
|
||||||
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
.cornerRadius = CLAY_CORNER_RADIUS(4),
|
||||||
|
|
@ -610,20 +611,17 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
obstructing_window();
|
obstructing_window();
|
||||||
|
scroll_bar_many_entries_area("dropdown scroll area", 18.0f, selections.size(), [&](size_t i, bool) {
|
||||||
|
bool selectedEntry = *val == i;
|
||||||
|
|
||||||
CLAY({
|
CLAY({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)},
|
.sizing = {.width = CLAY_SIZING_FIXED(250), .height = CLAY_SIZING_FIXED(18)},
|
||||||
.childGap = 1,
|
.padding = CLAY_PADDING_ALL(0),
|
||||||
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_TOP},
|
.childGap = 0,
|
||||||
|
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||||
}
|
}
|
||||||
}) {
|
|
||||||
for(size_t i = 0; i < selections.size(); i++) {
|
|
||||||
bool selectedEntry = *val == i;
|
|
||||||
CLAY({
|
|
||||||
.layout = {
|
|
||||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)}
|
|
||||||
},
|
|
||||||
}) {
|
}) {
|
||||||
SkColor4f entryColor;
|
SkColor4f entryColor;
|
||||||
if(selectedEntry)
|
if(selectedEntry)
|
||||||
|
|
@ -634,8 +632,10 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::
|
||||||
entryColor = io->theme->backColor1;
|
entryColor = io->theme->backColor1;
|
||||||
CLAY({
|
CLAY({
|
||||||
.layout = {
|
.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},
|
.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<Clay_Color>(entryColor)
|
.backgroundColor = convert_vec4<Clay_Color>(entryColor)
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -646,8 +646,7 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
if(hoverboxElemUpdate)
|
if(hoverboxElemUpdate)
|
||||||
hoverboxElemUpdate();
|
hoverboxElemUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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<void(SelectionHelper&)>& elemUpdate = nullptr);
|
void input_path(const std::string& id, std::filesystem::path* val, std::filesystem::file_type fileTypeRestriction, const std::function<void(SelectionHelper&)>& 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<void(SelectionHelper&)>& 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<void(SelectionHelper&)>& elemUpdate = nullptr);
|
||||||
|
|
||||||
void dropdown_select(const std::string& id, size_t* val, const std::vector<std::string>& selections, float width = 200.0f, const std::function<void()>& hoverboxElemUpdate = nullptr);
|
void dropdown_select(const std::string& id, size_t* val, const std::vector<std::string>& selections, float width = 200.0f, float maxHeight = 0.0f, const std::function<void()>& hoverboxElemUpdate = nullptr);
|
||||||
|
|
||||||
void paint_circle_popup_menu(const std::string& id, const Vector2f& centerPos, const PaintCircleMenu::Data& val, const std::function<void()>& elemUpdate = nullptr);
|
void paint_circle_popup_menu(const std::string& id, const Vector2f& centerPos, const PaintCircleMenu::Data& val, const std::function<void()>& elemUpdate = nullptr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,9 @@ void FontFamiliesTextStyleModifier::load(cereal::PortableBinaryInputArchive& a)
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontFamiliesTextStyleModifier::modify_text_style(skia::textlayout::TextStyle& style) const {
|
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 {
|
bool FontFamiliesTextStyleModifier::equivalent_data(TextStyleModifier& modifier) const {
|
||||||
|
|
|
||||||
|
|
@ -1136,7 +1136,7 @@ bool Toolbar::color_palette(const std::string& id, Vector4f* color, bool& hoveri
|
||||||
std::vector<std::string> paletteNames;
|
std::vector<std::string> paletteNames;
|
||||||
for(auto& p : paletteData.palettes)
|
for(auto& p : paletteData.palettes)
|
||||||
paletteNames.emplace_back(p.name);
|
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();
|
hoveringOnDropdown = Clay_Hovered();
|
||||||
});
|
});
|
||||||
if(gui.svg_icon_button("paletteadd", "data/icons/plus.svg", paletteData.addingPalette, 25.0f)) paletteData.addingPalette = !paletteData.addingPalette;
|
if(gui.svg_icon_button("paletteadd", "data/icons/plus.svg", paletteData.addingPalette, 25.0f)) paletteData.addingPalette = !paletteData.addingPalette;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue