Make editor inspector easing lines use the accent color when dragged

This makes their visual feedback more consistent with other controls.

This also makes easing lines slightly more subtle by decreasing
their opacity by 10%.
This commit is contained in:
Hugo Locurcio 2019-09-06 16:04:07 +02:00
parent 4ee8ecd3ef
commit 21222fb478
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
2 changed files with 39 additions and 15 deletions

View file

@ -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;
}

View file

@ -311,6 +311,7 @@ class EditorPropertyEasing : public EditorProperty {
EditorSpinSlider *spin;
bool setting;
bool dragging;
bool full;
bool flip;