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 = [&] {
|
.onChange = [&] {
|
||||||
currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
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]);
|
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); },
|
.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) {
|
if(newHighlightColor.w() != 0.0f) {
|
||||||
svg_icon_button(gui, "Remove Highlight Color", "data/icons/close.svg", {
|
svg_icon_button(gui, "Remove Highlight Color", "data/icons/close.svg", {
|
||||||
|
|
@ -374,10 +377,13 @@ void TextBoxEditTool::phone_bottom_toolbar_gui(PhoneDrawingProgramScreen& t) {
|
||||||
.onChange = [&] {
|
.onChange = [&] {
|
||||||
currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
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]);
|
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); },
|
.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 = {}) {
|
template <typename T> void color_picker_items(GUIManager& gui, const char* id, T* val, const ColorPickerItemsOptions& options = {}) {
|
||||||
gui.new_id(id, [&] {
|
gui.new_id(id, [&] {
|
||||||
auto fullOnEdit = [&gui, oE = options.onEdit]() {
|
auto fullOnDeselect = [&gui, oD = options.onDeselect]() {
|
||||||
if(oE) oE();
|
if(oD) oD();
|
||||||
gui.set_to_layout();
|
gui.set_to_layout();
|
||||||
};
|
};
|
||||||
CLAY_AUTO_ID({
|
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}
|
.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) {
|
if(!gui.io.isTouchDevice) {
|
||||||
left_to_right_line_layout(gui, [&]() {
|
left_to_right_line_layout(gui, [&]() {
|
||||||
text_label(gui, "R");
|
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");
|
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");
|
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) {
|
if(options.hasAlpha) {
|
||||||
text_label(gui, "A");
|
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, [&]() {
|
left_to_right_line_layout(gui, [&]() {
|
||||||
text_label(gui, "Hex");
|
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 {
|
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 = {}) {
|
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, [&] {
|
gui.new_id(id, [&] {
|
||||||
options.onEdit = [&, oE = options.onEdit] {
|
|
||||||
if(oE) oE();
|
|
||||||
gui.set_to_layout();
|
|
||||||
};
|
|
||||||
left_to_right_line_layout(gui, [&]() {
|
left_to_right_line_layout(gui, [&]() {
|
||||||
text_label(gui, name);
|
text_label(gui, name);
|
||||||
input_scalar(gui, "textbox", val, min, max, options);
|
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);
|
if(d.mouseButton) d.mouseButton(button, mouseHovering);
|
||||||
dd.isHeld = mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
dd.isHeld = mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||||
update_paint_circle_menu_mouse_hover(button.pos);
|
update_paint_circle_menu_mouse_hover(button.pos);
|
||||||
|
bool isRotateBarHeldOld = dd.isRotateBarHeld;
|
||||||
dd.isRotateBarHeld = dd.isRotateBarHovered && dd.isHeld;
|
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);
|
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;
|
Vector4f* selectedColor = nullptr;
|
||||||
std::vector<Vector3f> palette;
|
std::vector<Vector3f> palette;
|
||||||
std::function<void()> onRotate;
|
std::function<void()> onRotate;
|
||||||
|
std::function<void()> onRotateDone;
|
||||||
std::function<void()> onPaletteClick;
|
std::function<void()> onPaletteClick;
|
||||||
std::function<void(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
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() {
|
template <typename T> void TextBox<T>::update() {
|
||||||
|
if(!is_selected())
|
||||||
|
reset_textbox_text();
|
||||||
std::string newTextboxStr = textbox->get_string();
|
std::string newTextboxStr = textbox->get_string();
|
||||||
if(oldDD.isSelected != is_selected() || oldDD.textboxStr != newTextboxStr || oldDD.cur != *cur) {
|
if(oldDD.isSelected != is_selected() || oldDD.textboxStr != newTextboxStr || oldDD.cur != *cur) {
|
||||||
oldDD.isSelected = is_selected();
|
oldDD.isSelected = is_selected();
|
||||||
|
|
|
||||||
|
|
@ -1002,12 +1002,12 @@ void PhoneDrawingProgramScreen::color_settings_popup(Vector4f* color, const Colo
|
||||||
.aspectRatio = {1.0f}
|
.aspectRatio = {1.0f}
|
||||||
}) {
|
}) {
|
||||||
gui.element<ColorPicker<Vector4f>>("color picker element", color, true, ColorPickerData{
|
gui.element<ColorPicker<Vector4f>>("color picker element", color, true, ColorPickerData{
|
||||||
.onChange = [&, d] {
|
.onChange = d.onChange,
|
||||||
if(d.onChange) d.onChange();
|
|
||||||
gui.set_to_layout();
|
|
||||||
},
|
|
||||||
.onHold = d.onSelect,
|
.onHold = d.onSelect,
|
||||||
.onRelease = d.onDeselect
|
.onRelease = [&, d] {
|
||||||
|
if(d.onDeselect) d.onDeselect();
|
||||||
|
main.g.gui.set_to_layout();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
CLAY_AUTO_ID({
|
CLAY_AUTO_ID({
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,8 @@ void Toolbar::paint_popup(Vector2f popupPos) {
|
||||||
.onRotate = [&, newRotationAngle] {
|
.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);
|
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;
|
*newRotationAngle = main.world->drawData.cam.c.rotation;
|
||||||
|
},
|
||||||
|
.onRotateDone = [&] {
|
||||||
gui.set_to_layout();
|
gui.set_to_layout();
|
||||||
},
|
},
|
||||||
.onPaletteClick = [&] {
|
.onPaletteClick = [&] {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue