Made color buttons smaller
This commit is contained in:
parent
0e08b9576d
commit
99983daa65
5 changed files with 37 additions and 31 deletions
|
|
@ -22,20 +22,16 @@ bool EllipseDrawEditTool::edit_gui(const std::shared_ptr<DrawComponent>& comp) {
|
|||
if(t.gui.radio_button_field("filloutline", "Fill and Outline", a->d.fillStrokeMode == 2)) a->d.fillStrokeMode = 2;
|
||||
if(a->d.fillStrokeMode == 0 || a->d.fillStrokeMode == 2) {
|
||||
t.gui.left_to_right_line_layout([&]() {
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Fill Color", &a->d.fillColor, &a->d.fillColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.fillColor == t.colorRight ? nullptr : &a->d.fillColor);
|
||||
}
|
||||
if(t.gui.color_button_big("Fill Color", &a->d.fillColor, &a->d.fillColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.fillColor == t.colorRight ? nullptr : &a->d.fillColor);
|
||||
t.gui.text_label("Fill Color");
|
||||
});
|
||||
}
|
||||
if(a->d.fillStrokeMode == 1 || a->d.fillStrokeMode == 2) {
|
||||
t.gui.slider_scalar_field("relstrokewidth", "Outline Size", &a->d.strokeWidth, 3.0f, 40.0f);
|
||||
t.gui.left_to_right_line_layout([&]() {
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Outline Color", &a->d.strokeColor, &a->d.strokeColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.strokeColor == t.colorRight ? nullptr : &a->d.strokeColor);
|
||||
}
|
||||
if(t.gui.color_button_big("Outline Color", &a->d.strokeColor, &a->d.strokeColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.strokeColor == t.colorRight ? nullptr : &a->d.strokeColor);
|
||||
t.gui.text_label("Outline Color");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,10 +56,8 @@ void GridModifyTool::gui_toolbox() {
|
|||
t.gui.checkbox_field("Subdivide outwards", "Subdivide when zooming out", &divOut);
|
||||
g.set_remove_divisions_outwards(divOut);
|
||||
t.gui.left_to_right_line_layout([&]() {
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Grid Color", &g.color, &g.color == t.colorRight))
|
||||
t.color_selector_right(&g.color == t.colorRight ? nullptr : &g.color);
|
||||
}
|
||||
if(t.gui.color_button_big("Grid Color", &g.color, &g.color == t.colorRight))
|
||||
t.color_selector_right(&g.color == t.colorRight ? nullptr : &g.color);
|
||||
t.gui.text_label("Grid Color");
|
||||
});
|
||||
bool bounded = g.bounds.has_value();
|
||||
|
|
|
|||
|
|
@ -20,20 +20,16 @@ bool RectDrawEditTool::edit_gui(const std::shared_ptr<DrawComponent>& comp) {
|
|||
if(t.gui.radio_button_field("filloutline", "Fill and Outline", a->d.fillStrokeMode == 2)) a->d.fillStrokeMode = 2;
|
||||
if(a->d.fillStrokeMode == 0 || a->d.fillStrokeMode == 2) {
|
||||
t.gui.left_to_right_line_layout([&]() {
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Fill Color", &a->d.fillColor, &a->d.fillColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.fillColor == t.colorRight ? nullptr : &a->d.fillColor);
|
||||
}
|
||||
if(t.gui.color_button_big("Fill Color", &a->d.fillColor, &a->d.fillColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.fillColor == t.colorRight ? nullptr : &a->d.fillColor);
|
||||
t.gui.text_label("Fill Color");
|
||||
});
|
||||
}
|
||||
if(a->d.fillStrokeMode == 1 || a->d.fillStrokeMode == 2) {
|
||||
t.gui.slider_scalar_field("relstrokewidth", "Outline Size", &a->d.strokeWidth, 3.0f, 40.0f);
|
||||
t.gui.left_to_right_line_layout([&]() {
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Outline Color", &a->d.strokeColor, &a->d.strokeColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.strokeColor == t.colorRight ? nullptr : &a->d.strokeColor);
|
||||
}
|
||||
if(t.gui.color_button_big("Outline Color", &a->d.strokeColor, &a->d.strokeColor == t.colorRight))
|
||||
t.color_selector_right(&a->d.strokeColor == t.colorRight ? nullptr : &a->d.strokeColor);
|
||||
t.gui.text_label("Outline Color");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,10 +92,8 @@ bool TextBoxEditTool::edit_gui(const std::shared_ptr<DrawComponent>& comp) {
|
|||
|
||||
// Text color
|
||||
t.gui.left_to_right_line_layout([&]() {
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Text Color", &newTextColor, &newTextColor == t.colorRight))
|
||||
t.color_selector_right(&newTextColor == t.colorRight ? nullptr : &newTextColor);
|
||||
}
|
||||
if(t.gui.color_button_big("Text Color", &newTextColor, &newTextColor == t.colorRight))
|
||||
t.color_selector_right(&newTextColor == t.colorRight ? nullptr : &newTextColor);
|
||||
t.gui.text_label("Text Color");
|
||||
});
|
||||
|
||||
|
|
@ -113,21 +111,22 @@ bool TextBoxEditTool::edit_gui(const std::shared_ptr<DrawComponent>& comp) {
|
|||
|
||||
// Highlight color
|
||||
t.gui.left_to_right_line_layout([&]() {
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(40), .height = CLAY_SIZING_FIXED(40)}}}) {
|
||||
if(t.gui.color_button("Highlight Color", &newHighlightColor, &newHighlightColor == t.colorRight)) {
|
||||
if(newHighlightColor.w() == 0.0f) // Make highlight appear when the button is pressed
|
||||
newHighlightColor.w() = 1.0f;
|
||||
t.color_selector_right(&newHighlightColor == t.colorRight ? nullptr : &newHighlightColor);
|
||||
if(t.gui.color_button_big("Highlight Color", &newHighlightColor, &newHighlightColor == t.colorRight)) {
|
||||
if(newHighlightColor.w() == 0.0f) { // Make highlight appear when the button is pressed
|
||||
newHighlightColor.w() = 1.0f;
|
||||
currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
add_undo_if_selecting_area(a, [&]() {a->textBox->set_text_style_modifier_between(a->cursor->selectionBeginPos, a->cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);});
|
||||
}
|
||||
t.color_selector_right(&newHighlightColor == t.colorRight ? nullptr : &newHighlightColor);
|
||||
}
|
||||
t.gui.text_label("Highlight Color");
|
||||
if(newHighlightColor.w() != 0.0f) {
|
||||
if(t.gui.svg_icon_button("Remove Highlight Color", "data/icons/close.svg")) {
|
||||
newHighlightColor = Vector4f{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
newHighlightColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
add_undo_if_selecting_area(a, [&]() {a->textBox->set_text_style_modifier_between(a->cursor->selectionBeginPos, a->cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);});
|
||||
}
|
||||
}
|
||||
t.gui.text_label("Highlight Color");
|
||||
});
|
||||
|
||||
if(&newHighlightColor == t.colorRight)
|
||||
|
|
|
|||
|
|
@ -267,6 +267,23 @@ class GUIManager {
|
|||
}, GUIStuff::SelectableButton::DrawType::TRANSPARENT_BORDER, isSelected);
|
||||
}
|
||||
|
||||
template <typename T> bool color_button_big(const std::string& id, T* val, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr) {
|
||||
bool toRet = false;
|
||||
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_FIXED(BIG_BUTTON_SIZE), .height = CLAY_SIZING_FIXED(BIG_BUTTON_SIZE)}}}) {
|
||||
toRet = selectable_button(id, [&](SelectionHelper& s, bool iS) {
|
||||
CLAY({.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||
},
|
||||
.backgroundColor = convert_vec4<Clay_Color>(*val),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(5),
|
||||
}) {}
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}, GUIStuff::SelectableButton::DrawType::TRANSPARENT_BORDER, isSelected);
|
||||
}
|
||||
return toRet;
|
||||
}
|
||||
|
||||
template <typename T> bool color_picker_button(const std::string& id, T* val, bool selectAlpha, const std::function<void()>& elemUpdate = nullptr) {
|
||||
bool isUpdating = false;
|
||||
push_id(id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue