Getting color selectors working

This commit is contained in:
Yousef Khadadeh 2026-04-02 18:23:36 +03:00
parent 60c12ce150
commit 2c76741c9b
8 changed files with 242 additions and 189 deletions

View file

@ -331,6 +331,7 @@ void DrawingProgram::toolbar_gui() {
GUIManager& gui = world.main.g.gui;
auto& io = gui.io;
auto& t = world.main.toolbar;
gui.new_id("Drawing Program Toolbar GUI", [&] {
gui.element<LayoutElement>("Drawing Program Toolbar GUI", [&] (const Clay_ElementId& lId) {
@ -374,6 +375,9 @@ void DrawingProgram::toolbar_gui() {
world.drawData.cam.c.rotate_about(world.drawData.cam.c.from_space(world.main.window.size.cast<float>() * 0.5f), *newRotationAngle - world.drawData.cam.c.rotation);
*newRotationAngle = world.drawData.cam.c.rotation;
});
t.color_button_left("Foreground color", &world.main.toolConfig.globalConf.foregroundColor);
t.color_button_left("Background color", &world.main.toolConfig.globalConf.backgroundColor);
}
});
});
@ -445,6 +449,11 @@ void DrawingProgram::selection_action_menu(Vector2f popupPos) {
selection.push_selection_to_back();
});
}
}, LayoutElement::Callbacks{
.mouseButton = [&](const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
if(button.down && button.button != InputManager::MouseButton::RIGHT)
clear_right_click_popup();
}
});
});
}

View file

@ -22,13 +22,13 @@ void EllipseDrawEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
auto& a = static_cast<EllipseCanvasComponent&>(comp->obj->get_comp());
auto& gui = drawP.world.main.g.gui;
Toolbar& t = drawP.world.main.toolbar;
auto commit_update_func = [&, comp] { comp->obj->commit_update(drawP); };
auto commit_update_and_layout_func = [&, comp] {
comp->obj->commit_update(drawP);
drawP.world.main.g.gui.set_to_layout();
};
Toolbar& t = drawP.world.main.toolbar;
gui.new_id("edit tool ellipse", [&] {
text_label_centered(gui, "Edit Ellipse");
radio_button_selector(gui, "Fill selector", &a.d.fillStrokeMode, {
@ -38,16 +38,14 @@ void EllipseDrawEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
}, commit_update_and_layout_func);
if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) {
left_to_right_line_layout(gui, [&] {
//if(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.color_button_right("Fill color button", &a.d.fillColor, commit_update_func);
text_label(gui, "Fill Color");
});
}
if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) {
slider_scalar_field(gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f, {.onEdit = commit_update_func});
left_to_right_line_layout(gui, [&] {
//if(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.color_button_right("Outline color button", &a.d.strokeColor, commit_update_func);
text_label(gui, "Outline Color");
});
}

View file

@ -36,16 +36,14 @@ void RectDrawEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
}, commit_update_and_layout_func);
if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) {
left_to_right_line_layout(gui, [&] {
//if(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.color_button_right("Fill color button", &a.d.fillColor, commit_update_func);
text_label(gui, "Fill Color");
});
}
if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) {
slider_scalar_field(gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f, { .onEdit = commit_update_func });
left_to_right_line_layout(gui, [&] {
//if(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.color_button_right("Outline color button", &a.d.strokeColor, commit_update_func);
text_label(gui, "Outline Color");
});
}