diff options
Diffstat (limited to 'editor/animation_editor.cpp')
-rw-r--r-- | editor/animation_editor.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index b832b993bb..54eb695178 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -64,6 +64,8 @@ private: float transition; Mode mode; + LineEdit *value_edit; + void _notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { @@ -144,14 +146,11 @@ private: } } - String txt = String::num(exp, 2); if (mode == MODE_DISABLED) { - txt = TTR("Disabled"); + f->draw(ci, Point2(5, 5 + f->get_ascent()), TTR("Disabled"), color); } else if (mode == MODE_MULTIPLE) { - txt += " - " + TTR("All Selection"); + f->draw(ci, Point2(5, 5 + f->get_ascent() + value_edit->get_size().height), TTR("All Selection"), color); } - - f->draw(ci, Point2(10, 10 + f->get_ascent()), txt, color); } } @@ -163,6 +162,8 @@ private: if (mode == MODE_DISABLED) return; + value_edit->release_focus(); + float rel = mm->get_relative().x; if (rel == 0) return; @@ -187,24 +188,28 @@ private: if (sg) val = -val; - transition = val; - update(); - //emit_signal("variant_changed"); - emit_signal("transition_changed", transition); + force_transition(val); } } + void _edit_value_changed(const String &p_value_str) { + + force_transition(p_value_str.to_float()); + } + public: static void _bind_methods() { //ClassDB::bind_method("_update_obj",&AnimationKeyEdit::_update_obj); ClassDB::bind_method("_gui_input", &AnimationCurveEdit::_gui_input); + ClassDB::bind_method("_edit_value_changed", &AnimationCurveEdit::_edit_value_changed); ADD_SIGNAL(MethodInfo("transition_changed")); } void set_mode(Mode p_mode) { mode = p_mode; + value_edit->set_visible(mode != MODE_DISABLED); update(); } @@ -218,7 +223,8 @@ public: } void set_transition(float p_transition) { - transition = p_transition; + transition = Math::stepify(p_transition, 0.01); + value_edit->set_text(String::num(transition)); update(); } @@ -229,9 +235,8 @@ public: void force_transition(float p_value) { if (mode == MODE_DISABLED) return; - transition = p_value; + set_transition(p_value); emit_signal("transition_changed", p_value); - update(); } AnimationCurveEdit() { @@ -239,6 +244,11 @@ public: transition = 1.0; set_default_cursor_shape(CURSOR_HSPLIT); mode = MODE_DISABLED; + + value_edit = memnew(LineEdit); + value_edit->hide(); + value_edit->connect("text_entered", this, "_edit_value_changed"); + add_child(value_edit); } }; @@ -1101,7 +1111,7 @@ void AnimationKeyEditor::_track_editor_draw() { Color select_color = color; select_color.a = 0.1; Color invalid_path_color = get_color("error_color", "Editor"); - Color track_select_color = get_color("accent", "Editor"); + Color track_select_color = get_color("highlighted_font_color", "Editor"); Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons"); Ref<Texture> move_up_icon = get_icon("MoveUp", "EditorIcons"); |