summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-12-13 10:22:40 +0100
committerGitHub <noreply@github.com>2018-12-13 10:22:40 +0100
commitd119428ff93359c5d03cf1dc81957663b84c0cd7 (patch)
tree61730517ac19562c806aea4b94e2544b743bed29
parentc7cef29b00430e01faceed396dbd9def1b7cb235 (diff)
parent61ceb59f1dbc39a3d2789a9e8bb808240a5a44b6 (diff)
Merge pull request #24310 from merumelu/color-picker-fixes
ColorPicker fixes
-rw-r--r--scene/gui/color_picker.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 19c6cde111..523e07087b 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -204,22 +204,9 @@ void ColorPicker::_update_presets() {
preset->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), Rect2(Point2(), preset_size), true);
-#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
- PoolColorArray arr_to_save = PoolColorArray();
-
- for (int i = 0; i < presets.size(); i++) {
- preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]);
- arr_to_save.insert(i, presets[i]);
- }
-
- EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
- }
-#else
for (int i = 0; i < presets.size(); i++) {
preset->draw_rect(Rect2(Point2(size.width * i, 0), size), presets[i]);
}
-#endif
}
void ColorPicker::_text_type_toggled() {
@@ -251,6 +238,13 @@ void ColorPicker::add_preset(const Color &p_color) {
preset->update();
if (presets.size() == 10)
bt_add_preset->hide();
+
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ PoolColorArray arr_to_save = get_presets();
+ EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
+ }
+#endif
}
void ColorPicker::erase_preset(const Color &p_color) {
@@ -258,6 +252,13 @@ void ColorPicker::erase_preset(const Color &p_color) {
if (presets.find(p_color)) {
presets.erase(presets.find(p_color));
preset->update();
+
+#ifdef TOOLS_ENABLED
+ if (Engine::get_singleton()->is_editor_hint()) {
+ PoolColorArray arr_to_save = get_presets();
+ EditorSettings::get_singleton()->set_project_metadata("color_picker", "presets", arr_to_save);
+ }
+#endif
}
}
@@ -462,16 +463,15 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) {
int index = bev->get_position().x / (preset->get_size().x / presets.size());
set_pick_color(presets[index]);
+ _update_color();
+ emit_signal("color_changed", color);
} else if (bev->is_pressed() && bev->get_button_index() == BUTTON_RIGHT) {
int index = bev->get_position().x / (preset->get_size().x / presets.size());
Color clicked_preset = presets[index];
- presets.erase(clicked_preset);
+ erase_preset(clicked_preset);
emit_signal("preset_removed", clicked_preset);
- preset->update();
bt_add_preset->show();
}
- _update_color();
- emit_signal("color_changed", color);
}
Ref<InputEventMouseMotion> mev = p_event;