summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_properties.cpp53
-rw-r--r--editor/editor_properties.h1
2 files changed, 39 insertions, 15 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 30fb561fbe..f456cf7233 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -922,16 +922,29 @@ EditorPropertyFloat::EditorPropertyFloat() {
void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
- Ref<InputEventMouseButton> mb = p_ev;
- if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
- preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
- preset->popup();
- }
- if (mb.is_valid() && mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) {
- _setup_spin();
+ const Ref<InputEventMouseButton> mb = p_ev;
+ if (mb.is_valid()) {
+ if (mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) {
+ _setup_spin();
+ }
+
+ if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
+ preset->popup();
+
+ // Ensure the easing doesn't appear as being dragged
+ dragging = false;
+ easing_draw->update();
+ }
+
+ if (mb->get_button_index() == BUTTON_LEFT) {
+ dragging = mb->is_pressed();
+ // Update to display the correct dragging color
+ easing_draw->update();
+ }
}
- Ref<InputEventMouseMotion> mm = p_ev;
+ const Ref<InputEventMouseMotion> mm = p_ev;
if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) {
@@ -969,13 +982,19 @@ void EditorPropertyEasing::_draw_easing() {
Rect2 r(Point2(), s);
r = r.grow(3);
- int points = 48;
+ const int points = 48;
float prev = 1.0;
- float exp = get_edited_object()->get(get_edited_property());
+ const float exp = get_edited_object()->get(get_edited_property());
- Ref<Font> f = get_font("font", "Label");
- Color color = get_color("font_color", "Label");
+ const Ref<Font> f = get_font("font", "Label");
+ const Color font_color = get_color("font_color", "Label");
+ Color line_color;
+ if (dragging) {
+ line_color = get_color("accent_color", "Editor");
+ } else {
+ line_color = get_color("font_color", "Label") * Color(1, 1, 1, 0.9);
+ }
Vector<Point2> lines;
for (int i = 1; i <= points; i++) {
@@ -983,7 +1002,7 @@ void EditorPropertyEasing::_draw_easing() {
float ifl = i / float(points);
float iflp = (i - 1) / float(points);
- float h = 1.0 - Math::ease(ifl, exp);
+ const float h = 1.0 - Math::ease(ifl, exp);
if (flip) {
ifl = 1.0 - ifl;
@@ -995,8 +1014,8 @@ void EditorPropertyEasing::_draw_easing() {
prev = h;
}
- easing_draw->draw_multiline(lines, color, 1.0, true);
- f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), color);
+ easing_draw->draw_multiline(lines, line_color, 1.0, true);
+ f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), font_color);
}
void EditorPropertyEasing::update_property() {
@@ -1033,6 +1052,9 @@ void EditorPropertyEasing::_spin_value_changed(double p_value) {
void EditorPropertyEasing::_spin_focus_exited() {
spin->hide();
+ // Ensure the easing doesn't appear as being dragged
+ dragging = false;
+ easing_draw->update();
}
void EditorPropertyEasing::setup(bool p_full, bool p_flip) {
@@ -1095,6 +1117,7 @@ EditorPropertyEasing::EditorPropertyEasing() {
spin->hide();
add_child(spin);
+ dragging = false;
flip = false;
full = false;
}
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index adf7779dc4..b8d6aa00c2 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -311,6 +311,7 @@ class EditorPropertyEasing : public EditorProperty {
EditorSpinSlider *spin;
bool setting;
+ bool dragging;
bool full;
bool flip;