diff --git a/modules/paint/nodes/paint_project.cpp b/modules/paint/nodes/paint_project.cpp index f9883fab3..cf0062de0 100644 --- a/modules/paint/nodes/paint_project.cpp +++ b/modules/paint/nodes/paint_project.cpp @@ -11,6 +11,34 @@ void PaintProject::set_current_color(const Color &color) { emit_signal("current_color_changed", _current_color); } +void PaintProject::add_preset_color(const Color &color) { + _color_presets.push_back(color); + + emit_signal("color_presets_changed"); +} +void PaintProject::remove_preset_color(const int index) { + ERR_FAIL_INDEX(index, _color_presets.size()); + + _color_presets.remove(index); + + emit_signal("color_presets_changed"); +} +Color PaintProject::get_preset_color(const int index) { + ERR_FAIL_INDEX_V(index, _color_presets.size(), Color()); + + return _color_presets.get(index); +} +void PaintProject::set_preset_color(const int index, const Color &color) { + ERR_FAIL_INDEX(index, _color_presets.size()); + + _color_presets.set(index, color); + + emit_signal("color_presets_changed"); +} +int PaintProject::get_preset_color_count() { + return _color_presets.size(); +} + PoolColorArray PaintProject::get_color_presets() { return _color_presets; } @@ -51,6 +79,12 @@ void PaintProject::_bind_methods() { ClassDB::bind_method(D_METHOD("set_current_color", "size"), &PaintProject::set_current_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "current_color"), "set_current_color", "get_current_color"); + ClassDB::bind_method(D_METHOD("add_preset_color", "color"), &PaintProject::add_preset_color); + ClassDB::bind_method(D_METHOD("remove_preset_color", "index"), &PaintProject::remove_preset_color); + ClassDB::bind_method(D_METHOD("get_preset_color", "index"), &PaintProject::get_preset_color); + ClassDB::bind_method(D_METHOD("set_preset_color", "index", "color"), &PaintProject::set_preset_color); + ClassDB::bind_method(D_METHOD("get_preset_color_count"), &PaintProject::get_preset_color_count); + ClassDB::bind_method(D_METHOD("get_color_presets"), &PaintProject::get_color_presets); ClassDB::bind_method(D_METHOD("set_color_presets", "colors"), &PaintProject::set_color_presets); ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "color_presets"), "set_color_presets", "get_color_presets"); diff --git a/modules/paint/nodes/paint_project.h b/modules/paint/nodes/paint_project.h index 02ebd6627..eca9dbec5 100644 --- a/modules/paint/nodes/paint_project.h +++ b/modules/paint/nodes/paint_project.h @@ -12,6 +12,12 @@ public: Color get_current_color(); void set_current_color(const Color &color); + void add_preset_color(const Color &color); + void remove_preset_color(const int index); + Color get_preset_color(const int index); + void set_preset_color(const int index, const Color &color); + int get_preset_color_count(); + PoolColorArray get_color_presets(); void set_color_presets(const PoolColorArray &colors);