Added options in file selector screen main menu
This commit is contained in:
parent
06dd550067
commit
1fb8aa4409
7 changed files with 240 additions and 46 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "ButtonHelpers.hpp"
|
||||
#include "../Elements/SVGIcon.hpp"
|
||||
#include "../Elements/LayoutElement.hpp"
|
||||
#include "TextLabelHelpers.hpp"
|
||||
|
||||
namespace GUIStuff { namespace ElementHelpers {
|
||||
|
|
@ -26,6 +27,51 @@ void text_button(GUIManager& gui, const char* id, std::string_view text, const T
|
|||
}
|
||||
}
|
||||
|
||||
void text_button_with_icon(GUIManager& gui, const char* id, const std::string& svgPath, std::string_view text, const TextButtonOptions& options) {
|
||||
gui.new_id(id, [&] {
|
||||
SelectableButton::Data d = selectable_button_options_to_data(options);
|
||||
d.innerContent = [&gui, svgPath, text, centered = options.centered] (const SelectableButton::InnerContentCallbackParameters&) {
|
||||
gui.element<LayoutElement>("layoutelem", [&] (LayoutElement* l, const Clay_ElementId& lId) {
|
||||
CLAY(lId, {
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) },
|
||||
.childGap = gui.io.theme->childGap1,
|
||||
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER}
|
||||
}
|
||||
}) {
|
||||
if(l->get_bb().has_value()) {
|
||||
float iconSize = l->get_bb().value().height();
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIXED(iconSize), .height = CLAY_SIZING_FIXED(iconSize)},
|
||||
},
|
||||
.aspectRatio = {.aspectRatio = 1.0f}
|
||||
}) {
|
||||
gui.element<SVGIcon>("icon", svgPath, false);
|
||||
}
|
||||
}
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) },
|
||||
.childAlignment = {.x = centered ? CLAY_ALIGN_X_CENTER : CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER}
|
||||
}
|
||||
}) {
|
||||
text_label(gui, text);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = options.wide ? CLAY_SIZING_GROW(0) : CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0) },
|
||||
.childAlignment = {.x = options.centered ? CLAY_ALIGN_X_CENTER : CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER}
|
||||
}
|
||||
}) {
|
||||
gui.element<SelectableButton>("button", d);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void text_button_sized(GUIManager& gui, const char* id, std::string_view text, Clay_SizingAxis x, Clay_SizingAxis y, const TextButtonOptions& options) {
|
||||
SelectableButton::Data d = selectable_button_options_to_data(options);
|
||||
d.innerContent = [&gui, text] (const SelectableButton::InnerContentCallbackParameters&) {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ struct FixedSizeColorButtonOptions {
|
|||
};
|
||||
|
||||
void text_button(GUIManager& gui, const char* id, std::string_view text, const TextButtonOptions& options = {});
|
||||
void text_button_with_icon(GUIManager& gui, const char* id, const std::string& svgPath, std::string_view text, const TextButtonOptions& options = {});
|
||||
void text_button_sized(GUIManager& gui, const char* id, std::string_view text, Clay_SizingAxis x, Clay_SizingAxis y, const TextButtonOptions& options = {});
|
||||
SelectableButton* svg_icon_button(GUIManager& gui, const char* id, const std::string& svgPath, const SVGButtonOptions& options = {});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ void GridScrollArea::layout(const Clay_ElementId& id, const Options& o) {
|
|||
|
||||
options = o;
|
||||
|
||||
if(boundingBox.has_value())
|
||||
rowWidth = boundingBox.value().width(); // Use grid element bounding box instead of inner content width because row width will decide whether a scroll bar appears or not, which will change the inner content width (circular dependency)
|
||||
|
||||
ScrollBarManyEntriesOptions opts;
|
||||
opts.clipHorizontal = true;
|
||||
opts.entryHeight = options.entryHeight;
|
||||
opts.innerContentExtraCallback = [&, extraCallback = options.innerContentExtraCallback] (const ScrollArea::InnerContentParameters& contParams) {
|
||||
rowWidth = std::fabs(contParams.containerDimensions.x());
|
||||
if(extraCallback) extraCallback(contParams);
|
||||
};
|
||||
size_t entriesPerRow = std::max<size_t>(rowWidth / options.entryWidth, 1);
|
||||
|
|
|
|||
|
|
@ -258,9 +258,11 @@ void GUIManager::draw(SkCanvas* c, bool skiaAA) {
|
|||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_SCISSOR_END: {
|
||||
canvas->restore();
|
||||
clipRectStack.pop_back();
|
||||
clip_rect_transform(canvas, clipRectStack, clipRect, clipNoDraw);
|
||||
if(!clipRectStack.empty()) {
|
||||
canvas->restore();
|
||||
clipRectStack.pop_back();
|
||||
clip_rect_transform(canvas, clipRectStack, clipRect, clipNoDraw);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CLAY_RENDER_COMMAND_TYPE_CUSTOM: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue