ColorPicker UX improvements
- Tabs and MenuButton for mode selection and enabling/disabling colorized sliders - MenuButton for shape selection with new icon for each shape - Drag and drop functionality for presets to arrange order - A chronological list of recently selected presets which are global for the editor - Presets are now highlighted as being active or inactive - Thicker sliders for easy targeting - `grabber_offset` theme constant for Slider - Uncolorized sliders
This commit is contained in:
@ -38,6 +38,7 @@
|
||||
#include "scene/gui/grid_container.h"
|
||||
#include "scene/gui/label.h"
|
||||
#include "scene/gui/line_edit.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
#include "scene/gui/option_button.h"
|
||||
#include "scene/gui/popup.h"
|
||||
#include "scene/gui/separator.h"
|
||||
@ -63,7 +64,7 @@ public:
|
||||
void set_preset_color(const Color &p_color);
|
||||
Color get_preset_color() const;
|
||||
|
||||
ColorPresetButton(Color p_color);
|
||||
ColorPresetButton(Color p_color, int p_size);
|
||||
~ColorPresetButton();
|
||||
};
|
||||
|
||||
@ -96,8 +97,10 @@ private:
|
||||
static Ref<Shader> circle_shader;
|
||||
static Ref<Shader> circle_ok_color_shader;
|
||||
static List<Color> preset_cache;
|
||||
static List<Color> recent_preset_cache;
|
||||
|
||||
int current_slider_count = SLIDER_COUNT;
|
||||
static const int MODE_BUTTON_COUNT = 3;
|
||||
|
||||
bool slider_theme_modified = true;
|
||||
|
||||
@ -114,9 +117,20 @@ private:
|
||||
Control *wheel_uv = nullptr;
|
||||
TextureRect *sample = nullptr;
|
||||
GridContainer *preset_container = nullptr;
|
||||
HSeparator *preset_separator = nullptr;
|
||||
HBoxContainer *recent_preset_hbc = nullptr;
|
||||
Button *btn_add_preset = nullptr;
|
||||
Button *btn_pick = nullptr;
|
||||
Button *btn_preset = nullptr;
|
||||
Button *btn_recent_preset = nullptr;
|
||||
PopupMenu *shape_popup = nullptr;
|
||||
PopupMenu *mode_popup = nullptr;
|
||||
MenuButton *btn_shape = nullptr;
|
||||
MenuButton *btn_mode = nullptr;
|
||||
Button *mode_btns[MODE_BUTTON_COUNT];
|
||||
Ref<ButtonGroup> mode_group = nullptr;
|
||||
ColorPresetButton *selected_recent_preset = nullptr;
|
||||
Ref<ButtonGroup> preset_group;
|
||||
Ref<ButtonGroup> recent_preset_group;
|
||||
|
||||
OptionButton *mode_option_button = nullptr;
|
||||
|
||||
@ -135,10 +149,13 @@ private:
|
||||
bool text_is_constructor = false;
|
||||
PickerShapeType current_shape = SHAPE_HSV_RECTANGLE;
|
||||
ColorModeType current_mode = MODE_RGB;
|
||||
bool colorize_sliders = true;
|
||||
|
||||
const int preset_column_count = 9;
|
||||
const int PRESET_COLUMN_COUNT = 9;
|
||||
int prev_preset_size = 0;
|
||||
int prev_rencet_preset_size = 0;
|
||||
List<Color> presets;
|
||||
List<Color> recent_presets;
|
||||
|
||||
Color color;
|
||||
Color old_color;
|
||||
@ -150,6 +167,8 @@ private:
|
||||
bool spinning = false;
|
||||
bool presets_enabled = true;
|
||||
bool presets_visible = true;
|
||||
bool line_edit_mouse_release = false;
|
||||
bool text_changed = false;
|
||||
|
||||
float h = 0.0;
|
||||
float s = 0.0;
|
||||
@ -175,8 +194,12 @@ private:
|
||||
|
||||
void _uv_input(const Ref<InputEvent> &p_event, Control *c);
|
||||
void _w_input(const Ref<InputEvent> &p_event);
|
||||
void _slider_or_spin_input(const Ref<InputEvent> &p_event);
|
||||
void _line_edit_input(const Ref<InputEvent> &p_event);
|
||||
void _preset_input(const Ref<InputEvent> &p_event, const Color &p_color);
|
||||
void _recent_preset_pressed(const bool pressed, ColorPresetButton *p_preset);
|
||||
void _screen_input(const Ref<InputEvent> &p_event);
|
||||
void _text_changed(const String &p_new_text);
|
||||
void _add_preset_pressed();
|
||||
void _screen_pick_pressed();
|
||||
void _focus_enter();
|
||||
@ -185,8 +208,16 @@ private:
|
||||
|
||||
inline int _get_preset_size();
|
||||
void _add_preset_button(int p_size, const Color &p_color);
|
||||
void _add_recent_preset_button(int p_size, const Color &p_color);
|
||||
|
||||
void _set_color_mode(ColorModeType p_mode);
|
||||
void _show_hide_preset(const bool &p_is_btn_pressed, Button *p_btn_preset, Container *p_preset_container);
|
||||
void _update_drop_down_arrow(const bool &p_is_btn_pressed, Button *p_btn_preset);
|
||||
|
||||
void _set_mode_popup_value(ColorModeType p_mode);
|
||||
|
||||
Variant _get_drag_data_fw(const Point2 &p_point, Control *p_from_control);
|
||||
bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control) const;
|
||||
void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from_control);
|
||||
|
||||
protected:
|
||||
void _notification(int);
|
||||
@ -218,13 +249,23 @@ public:
|
||||
PickerShapeType get_picker_shape() const;
|
||||
|
||||
void add_preset(const Color &p_color);
|
||||
void add_recent_preset(const Color &p_color);
|
||||
void erase_preset(const Color &p_color);
|
||||
void erase_recent_preset(const Color &p_color);
|
||||
PackedColorArray get_presets() const;
|
||||
PackedColorArray get_recent_presets() const;
|
||||
void _update_presets();
|
||||
void _update_recent_presets();
|
||||
|
||||
void _select_from_preset_container(const Color &p_color);
|
||||
bool _select_from_recent_preset_hbc(const Color &p_color);
|
||||
|
||||
void set_color_mode(ColorModeType p_mode);
|
||||
ColorModeType get_color_mode() const;
|
||||
|
||||
void set_colorize_sliders(bool p_colorize_sliders);
|
||||
bool is_colorizing_sliders() const;
|
||||
|
||||
void set_deferred_mode(bool p_enabled);
|
||||
bool is_deferred_mode() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user