Added text/highlight colors to text edit tool
This commit is contained in:
parent
0087048a02
commit
c85fdbb61f
11 changed files with 136 additions and 100 deletions
|
|
@ -8,6 +8,8 @@ namespace GUIStuff { namespace ElementHelpers {
|
|||
struct ColorPickerItemsOptions {
|
||||
bool hasAlpha = true;
|
||||
std::function<void()> onEdit;
|
||||
std::function<void()> onSelect;
|
||||
std::function<void()> onDeselect;
|
||||
};
|
||||
|
||||
template <typename T> void color_picker_items(GUIManager& gui, const char* id, T* val, const ColorPickerItemsOptions& options = {}) {
|
||||
|
|
@ -16,22 +18,22 @@ template <typename T> void color_picker_items(GUIManager& gui, const char* id, T
|
|||
if(oE) oE();
|
||||
gui.set_to_layout();
|
||||
};
|
||||
gui.element<ColorPicker<T>>("c", val, options.hasAlpha, fullOnEdit);
|
||||
gui.element<ColorPicker<T>>("c", val, options.hasAlpha, ColorPickerData{ .onChange = fullOnEdit, .onHold = options.onSelect, .onRelease = options.onDeselect });
|
||||
left_to_right_line_layout(gui, [&]() {
|
||||
text_label(gui, "R");
|
||||
input_color_component_255(gui, "r", &(*val)[0], { .onEdit = fullOnEdit });
|
||||
input_color_component_255(gui, "r", &(*val)[0], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
text_label(gui, "G");
|
||||
input_color_component_255(gui, "g", &(*val)[1], { .onEdit = fullOnEdit });
|
||||
input_color_component_255(gui, "g", &(*val)[1], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
text_label(gui, "B");
|
||||
input_color_component_255(gui, "b", &(*val)[2], { .onEdit = fullOnEdit });
|
||||
input_color_component_255(gui, "b", &(*val)[2], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
if(options.hasAlpha) {
|
||||
text_label(gui, "A");
|
||||
input_color_component_255(gui, "a", &(*val)[3], { .onEdit = fullOnEdit });
|
||||
input_color_component_255(gui, "a", &(*val)[3], { .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
}
|
||||
});
|
||||
left_to_right_line_layout(gui, [&]() {
|
||||
text_label(gui, "Hex");
|
||||
input_color_hex(gui, "h", val, { .hasAlpha = options.hasAlpha, .onEdit = fullOnEdit });
|
||||
input_color_hex(gui, "h", val, { .hasAlpha = options.hasAlpha, .onEdit = fullOnEdit, .onSelect = options.onSelect, .onDeselect = options.onDeselect });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue