mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-15 07:01:11 +01:00
Also handle udpating the GradientEditor when the edited resource changes.
This commit is contained in:
parent
91b87ce9ef
commit
29919540db
@ -1,5 +1,6 @@
|
|||||||
#include "gradient_cursor.h"
|
#include "gradient_cursor.h"
|
||||||
|
|
||||||
|
#include "core/print_string.h"
|
||||||
#include "gradient_editor.h"
|
#include "gradient_editor.h"
|
||||||
#include "scene/gui/label.h"
|
#include "scene/gui/label.h"
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ void GradientCursor::_gui_input(const Ref<InputEvent> &ev) {
|
|||||||
//ged->save_color_state();
|
//ged->save_color_state();
|
||||||
sliding = true;
|
sliding = true;
|
||||||
label->set_visible(true);
|
label->set_visible(true);
|
||||||
|
|
||||||
label->set_text(String::num(get_cursor_position(), 3));
|
label->set_text(String::num(get_cursor_position(), 3));
|
||||||
} else {
|
} else {
|
||||||
if (sliding) {
|
if (sliding) {
|
||||||
|
@ -33,8 +33,20 @@ Ref<GradientBase> MMGradientEditor::get_value() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MMGradientEditor::set_value(const Ref<GradientBase> &val) {
|
void MMGradientEditor::set_value(const Ref<GradientBase> &val) {
|
||||||
|
if (value == val) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.is_valid()) {
|
||||||
|
value->disconnect("changed", this, "on_value_changed");
|
||||||
|
}
|
||||||
|
|
||||||
value = val;
|
value = val;
|
||||||
|
|
||||||
|
if (value.is_valid()) {
|
||||||
|
value->connect("changed", this, "on_value_changed");
|
||||||
|
}
|
||||||
|
|
||||||
_update_preview_queued = true;
|
_update_preview_queued = true;
|
||||||
_update_cursors_queued = true;
|
_update_cursors_queued = true;
|
||||||
|
|
||||||
@ -308,6 +320,13 @@ void MMGradientEditor::on_color_selector_closed() {
|
|||||||
_selecting_color = false;
|
_selecting_color = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMGradientEditor::on_value_changed() {
|
||||||
|
if (!graph_node->get_ignore_change_event()) {
|
||||||
|
_color_selection_done = true;
|
||||||
|
_selecting_color = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MMGradientEditor::MMGradientEditor() {
|
MMGradientEditor::MMGradientEditor() {
|
||||||
graph_node = nullptr;
|
graph_node = nullptr;
|
||||||
embedded = false;
|
embedded = false;
|
||||||
@ -535,4 +554,5 @@ void MMGradientEditor::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("_on_Interpolation_item_selected", "ID"), &MMGradientEditor::_on_Interpolation_item_selected);
|
ClassDB::bind_method(D_METHOD("_on_Interpolation_item_selected", "ID"), &MMGradientEditor::_on_Interpolation_item_selected);
|
||||||
ClassDB::bind_method(D_METHOD("on_resized"), &MMGradientEditor::on_resized);
|
ClassDB::bind_method(D_METHOD("on_resized"), &MMGradientEditor::on_resized);
|
||||||
ClassDB::bind_method(D_METHOD("on_color_selector_closed"), &MMGradientEditor::on_color_selector_closed);
|
ClassDB::bind_method(D_METHOD("on_color_selector_closed"), &MMGradientEditor::on_color_selector_closed);
|
||||||
|
ClassDB::bind_method(D_METHOD("on_value_changed"), &MMGradientEditor::on_value_changed);
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ class MMMaterial;
|
|||||||
class MMGradientEditor : public Control {
|
class MMGradientEditor : public Control {
|
||||||
GDCLASS(MMGradientEditor, Control);
|
GDCLASS(MMGradientEditor, Control);
|
||||||
|
|
||||||
//todo mmnode changed event sub + handle
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MMGraphNode *get_graph_node();
|
MMGraphNode *get_graph_node();
|
||||||
void set_graph_node(MMGraphNode *val);
|
void set_graph_node(MMGraphNode *val);
|
||||||
@ -68,6 +66,7 @@ public:
|
|||||||
void apply_new_interpolation();
|
void apply_new_interpolation();
|
||||||
void on_resized();
|
void on_resized();
|
||||||
void on_color_selector_closed();
|
void on_color_selector_closed();
|
||||||
|
void on_value_changed();
|
||||||
|
|
||||||
MMGradientEditor();
|
MMGradientEditor();
|
||||||
~MMGradientEditor();
|
~MMGradientEditor();
|
||||||
|
Loading…
Reference in New Issue
Block a user