Improvements to GUI performance
This commit is contained in:
parent
1960ea827e
commit
80097dc41e
8 changed files with 31 additions and 21 deletions
|
|
@ -220,10 +220,13 @@ void TextBoxEditTool::edit_gui(Toolbar& t) {
|
|||
.onChange = [&] {
|
||||
currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);
|
||||
commit_update_and_layout_func_and_android_update();
|
||||
commit_update_func_and_android_update();
|
||||
},
|
||||
.onSelect = [&] { hold_undo_data("Highlight Color", a); },
|
||||
.onDeselect = [&] { release_undo_data("Highlight Color"); }
|
||||
.onDeselect = [&] {
|
||||
release_undo_data("Highlight Color");
|
||||
gui.set_to_layout();
|
||||
}
|
||||
});
|
||||
if(newHighlightColor.w() != 0.0f) {
|
||||
svg_icon_button(gui, "Remove Highlight Color", "data/icons/close.svg", {
|
||||
|
|
@ -374,10 +377,13 @@ void TextBoxEditTool::phone_bottom_toolbar_gui(PhoneDrawingProgramScreen& t) {
|
|||
.onChange = [&] {
|
||||
currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);
|
||||
commit_update_and_layout_func_and_android_update();
|
||||
commit_update_func_and_android_update();
|
||||
},
|
||||
.onSelect = [&] { hold_undo_data("Highlight Color", a); },
|
||||
.onDeselect = [&] { release_undo_data("Highlight Color"); }
|
||||
.onDeselect = [&] {
|
||||
release_undo_data("Highlight Color");
|
||||
gui.set_to_layout();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ struct ColorPickerItemsOptions {
|
|||
|
||||
template <typename T> void color_picker_items(GUIManager& gui, const char* id, T* val, const ColorPickerItemsOptions& options = {}) {
|
||||
gui.new_id(id, [&] {
|
||||
auto fullOnEdit = [&gui, oE = options.onEdit]() {
|
||||
if(oE) oE();
|
||||
auto fullOnDeselect = [&gui, oD = options.onDeselect]() {
|
||||
if(oD) oD();
|
||||
gui.set_to_layout();
|
||||
};
|
||||
CLAY_AUTO_ID({
|
||||
|
|
@ -44,24 +44,24 @@ template <typename T> void color_picker_items(GUIManager& gui, const char* id, T
|
|||
},
|
||||
.aspectRatio = {options.forceAspectRatioOnColorPicker ? 1.0f : 0.0f}
|
||||
}) {
|
||||
gui.element<ColorPicker<T>>("c", val, options.hasAlpha, ColorPickerData{ .onChange = fullOnEdit, .onHold = options.onSelect, .onRelease = options.onDeselect });
|
||||
gui.element<ColorPicker<T>>("c", val, options.hasAlpha, ColorPickerData{ .onChange = options.onEdit, .onHold = options.onSelect, .onRelease = fullOnDeselect });
|
||||
}
|
||||
if(!gui.io.isTouchDevice) {
|
||||
left_to_right_line_layout(gui, [&]() {
|
||||
text_label(gui, "R");
|
||||
input_color_component_255(gui, "r", &(*val)[0], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
input_color_component_255(gui, "r", &(*val)[0], { .onEdit = options.onEdit, .onSelect = options.onSelect, .onDeselect = fullOnDeselect });
|
||||
text_label(gui, "G");
|
||||
input_color_component_255(gui, "g", &(*val)[1], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
input_color_component_255(gui, "g", &(*val)[1], { .onEdit = options.onEdit, .onSelect = options.onSelect, .onDeselect = fullOnDeselect });
|
||||
text_label(gui, "B");
|
||||
input_color_component_255(gui, "b", &(*val)[2], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
input_color_component_255(gui, "b", &(*val)[2], { .onEdit = options.onEdit, .onSelect = options.onSelect, .onDeselect = fullOnDeselect });
|
||||
if(options.hasAlpha) {
|
||||
text_label(gui, "A");
|
||||
input_color_component_255(gui, "a", &(*val)[3], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
input_color_component_255(gui, "a", &(*val)[3], { .onEdit = options.onEdit, .onSelect = options.onSelect, .onDeselect = fullOnDeselect });
|
||||
}
|
||||
});
|
||||
left_to_right_line_layout(gui, [&]() {
|
||||
text_label(gui, "Hex");
|
||||
input_color_hex(gui, "h", val, { .hasAlpha = options.hasAlpha, .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
input_color_hex(gui, "h", val, { .hasAlpha = options.hasAlpha, .onEdit = options.onEdit, .onSelect = options.onSelect, .onDeselect = fullOnDeselect });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,10 +24,6 @@
|
|||
namespace GUIStuff { namespace ElementHelpers {
|
||||
template <typename T> void slider_scalar_field(GUIManager& gui, const char* id, std::string_view name, T* val, T min, T max, TextBoxScalarOptions options = {}) {
|
||||
gui.new_id(id, [&] {
|
||||
options.onEdit = [&, oE = options.onEdit] {
|
||||
if(oE) oE();
|
||||
gui.set_to_layout();
|
||||
};
|
||||
left_to_right_line_layout(gui, [&]() {
|
||||
text_label(gui, name);
|
||||
input_scalar(gui, "textbox", val, min, max, options);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,10 @@ void PaintCircleMenu::input_mouse_button_callback(const InputManager::MouseButto
|
|||
if(d.mouseButton) d.mouseButton(button, mouseHovering);
|
||||
dd.isHeld = mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||
update_paint_circle_menu_mouse_hover(button.pos);
|
||||
bool isRotateBarHeldOld = dd.isRotateBarHeld;
|
||||
dd.isRotateBarHeld = dd.isRotateBarHovered && dd.isHeld;
|
||||
if(isRotateBarHeldOld && !dd.isRotateBarHeld && d.onRotateDone)
|
||||
d.onRotateDone();
|
||||
update_paint_circle_menu_mouse(button.pos, button.button == InputManager::MouseButton::LEFT && button.down);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class PaintCircleMenu : public Element {
|
|||
Vector4f* selectedColor = nullptr;
|
||||
std::vector<Vector3f> palette;
|
||||
std::function<void()> onRotate;
|
||||
std::function<void()> onRotateDone;
|
||||
std::function<void()> onPaletteClick;
|
||||
std::function<void(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ template <typename T> void TextBox<T>::layout(const Clay_ElementId& id, const Te
|
|||
}
|
||||
|
||||
template <typename T> void TextBox<T>::update() {
|
||||
if(!is_selected())
|
||||
reset_textbox_text();
|
||||
std::string newTextboxStr = textbox->get_string();
|
||||
if(oldDD.isSelected != is_selected() || oldDD.textboxStr != newTextboxStr || oldDD.cur != *cur) {
|
||||
oldDD.isSelected = is_selected();
|
||||
|
|
|
|||
|
|
@ -1002,12 +1002,12 @@ void PhoneDrawingProgramScreen::color_settings_popup(Vector4f* color, const Colo
|
|||
.aspectRatio = {1.0f}
|
||||
}) {
|
||||
gui.element<ColorPicker<Vector4f>>("color picker element", color, true, ColorPickerData{
|
||||
.onChange = [&, d] {
|
||||
if(d.onChange) d.onChange();
|
||||
gui.set_to_layout();
|
||||
},
|
||||
.onChange = d.onChange,
|
||||
.onHold = d.onSelect,
|
||||
.onRelease = d.onDeselect
|
||||
.onRelease = [&, d] {
|
||||
if(d.onDeselect) d.onDeselect();
|
||||
main.g.gui.set_to_layout();
|
||||
}
|
||||
});
|
||||
}
|
||||
CLAY_AUTO_ID({
|
||||
|
|
|
|||
|
|
@ -392,6 +392,8 @@ void Toolbar::paint_popup(Vector2f popupPos) {
|
|||
.onRotate = [&, newRotationAngle] {
|
||||
main.world->drawData.cam.c.rotate_about(main.world->drawData.cam.c.from_space(main.window.size.cast<float>() * 0.5f), *newRotationAngle - main.world->drawData.cam.c.rotation);
|
||||
*newRotationAngle = main.world->drawData.cam.c.rotation;
|
||||
},
|
||||
.onRotateDone = [&] {
|
||||
gui.set_to_layout();
|
||||
},
|
||||
.onPaletteClick = [&] {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue