mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 20:23:53 +00:00
Add ability to type easing value for key transition
This commit is contained in:
parent
ba9486a4d3
commit
f0a58c5fd1
@ -64,6 +64,8 @@ private:
|
|||||||
float transition;
|
float transition;
|
||||||
Mode mode;
|
Mode mode;
|
||||||
|
|
||||||
|
LineEdit *value_edit;
|
||||||
|
|
||||||
void _notification(int p_what) {
|
void _notification(int p_what) {
|
||||||
|
|
||||||
if (p_what == NOTIFICATION_DRAW) {
|
if (p_what == NOTIFICATION_DRAW) {
|
||||||
@ -144,14 +146,11 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String txt = String::num(exp, 2);
|
|
||||||
if (mode == MODE_DISABLED) {
|
if (mode == MODE_DISABLED) {
|
||||||
txt = TTR("Disabled");
|
f->draw(ci, Point2(5, 5 + f->get_ascent()), TTR("Disabled"), color);
|
||||||
} else if (mode == MODE_MULTIPLE) {
|
} 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)
|
if (mode == MODE_DISABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
value_edit->release_focus();
|
||||||
|
|
||||||
float rel = mm->get_relative().x;
|
float rel = mm->get_relative().x;
|
||||||
if (rel == 0)
|
if (rel == 0)
|
||||||
return;
|
return;
|
||||||
@ -187,24 +188,28 @@ private:
|
|||||||
if (sg)
|
if (sg)
|
||||||
val = -val;
|
val = -val;
|
||||||
|
|
||||||
transition = val;
|
force_transition(val);
|
||||||
update();
|
|
||||||
//emit_signal("variant_changed");
|
|
||||||
emit_signal("transition_changed", transition);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _edit_value_changed(const String &p_value_str) {
|
||||||
|
|
||||||
|
force_transition(p_value_str.to_float());
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void _bind_methods() {
|
static void _bind_methods() {
|
||||||
|
|
||||||
//ClassDB::bind_method("_update_obj",&AnimationKeyEdit::_update_obj);
|
//ClassDB::bind_method("_update_obj",&AnimationKeyEdit::_update_obj);
|
||||||
ClassDB::bind_method("_gui_input", &AnimationCurveEdit::_gui_input);
|
ClassDB::bind_method("_gui_input", &AnimationCurveEdit::_gui_input);
|
||||||
|
ClassDB::bind_method("_edit_value_changed", &AnimationCurveEdit::_edit_value_changed);
|
||||||
ADD_SIGNAL(MethodInfo("transition_changed"));
|
ADD_SIGNAL(MethodInfo("transition_changed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_mode(Mode p_mode) {
|
void set_mode(Mode p_mode) {
|
||||||
|
|
||||||
mode = p_mode;
|
mode = p_mode;
|
||||||
|
value_edit->set_visible(mode != MODE_DISABLED);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +223,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void set_transition(float p_transition) {
|
void set_transition(float p_transition) {
|
||||||
transition = p_transition;
|
transition = Math::stepify(p_transition, 0.01);
|
||||||
|
value_edit->set_text(String::num(transition));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,9 +235,8 @@ public:
|
|||||||
void force_transition(float p_value) {
|
void force_transition(float p_value) {
|
||||||
if (mode == MODE_DISABLED)
|
if (mode == MODE_DISABLED)
|
||||||
return;
|
return;
|
||||||
transition = p_value;
|
set_transition(p_value);
|
||||||
emit_signal("transition_changed", p_value);
|
emit_signal("transition_changed", p_value);
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationCurveEdit() {
|
AnimationCurveEdit() {
|
||||||
@ -239,6 +244,11 @@ public:
|
|||||||
transition = 1.0;
|
transition = 1.0;
|
||||||
set_default_cursor_shape(CURSOR_HSPLIT);
|
set_default_cursor_shape(CURSOR_HSPLIT);
|
||||||
mode = MODE_DISABLED;
|
mode = MODE_DISABLED;
|
||||||
|
|
||||||
|
value_edit = memnew(LineEdit);
|
||||||
|
value_edit->hide();
|
||||||
|
value_edit->connect("text_entered", this, "_edit_value_changed");
|
||||||
|
add_child(value_edit);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user