|
@@ -253,6 +253,24 @@ void ColorPicker::add_preset(const Color &p_color) {
|
|
|
bt_add_preset->hide();
|
|
|
}
|
|
|
|
|
|
+void ColorPicker::erase_preset(const Color &p_color) {
|
|
|
+
|
|
|
+ if (presets.find(p_color)) {
|
|
|
+ presets.erase(presets.find(p_color));
|
|
|
+ preset->update();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+PoolColorArray ColorPicker::get_presets() const {
|
|
|
+
|
|
|
+ PoolColorArray arr;
|
|
|
+ arr.resize(presets.size());
|
|
|
+ for (int i = 0; i < presets.size(); i++) {
|
|
|
+ arr.set(i, presets[i]);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+}
|
|
|
+
|
|
|
void ColorPicker::set_raw_mode(bool p_enabled) {
|
|
|
|
|
|
if (raw_mode_enabled == p_enabled)
|
|
@@ -446,7 +464,9 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &p_event) {
|
|
|
set_pick_color(presets[index]);
|
|
|
} else if (bev->is_pressed() && bev->get_button_index() == BUTTON_RIGHT) {
|
|
|
int index = bev->get_position().x / (preset->get_size().x / presets.size());
|
|
|
- presets.erase(presets[index]);
|
|
|
+ Color clicked_preset = presets[index];
|
|
|
+ presets.erase(clicked_preset);
|
|
|
+ emit_signal("preset_removed", clicked_preset);
|
|
|
preset->update();
|
|
|
bt_add_preset->show();
|
|
|
}
|
|
@@ -501,6 +521,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
void ColorPicker::_add_preset_pressed() {
|
|
|
add_preset(color);
|
|
|
+ emit_signal("preset_added", color);
|
|
|
}
|
|
|
|
|
|
void ColorPicker::_screen_pick_pressed() {
|
|
@@ -553,6 +574,8 @@ void ColorPicker::_bind_methods() {
|
|
|
ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPicker::set_edit_alpha);
|
|
|
ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPicker::is_editing_alpha);
|
|
|
ClassDB::bind_method(D_METHOD("add_preset", "color"), &ColorPicker::add_preset);
|
|
|
+ ClassDB::bind_method(D_METHOD("erase_preset", "color"), &ColorPicker::erase_preset);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_presets"), &ColorPicker::get_presets);
|
|
|
ClassDB::bind_method(D_METHOD("_value_changed"), &ColorPicker::_value_changed);
|
|
|
ClassDB::bind_method(D_METHOD("_html_entered"), &ColorPicker::_html_entered);
|
|
|
ClassDB::bind_method(D_METHOD("_text_type_toggled"), &ColorPicker::_text_type_toggled);
|
|
@@ -575,6 +598,8 @@ void ColorPicker::_bind_methods() {
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deferred_mode"), "set_deferred_mode", "is_deferred_mode");
|
|
|
|
|
|
ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
|
|
|
+ ADD_SIGNAL(MethodInfo("preset_added", PropertyInfo(Variant::COLOR, "color")));
|
|
|
+ ADD_SIGNAL(MethodInfo("preset_removed", PropertyInfo(Variant::COLOR, "color")));
|
|
|
}
|
|
|
|
|
|
ColorPicker::ColorPicker() :
|