Fix broken hover/select coloring of keys in animation editor

(cherry picked from commit 172aa6c61e)
This commit is contained in:
Bernhard Liebl 2018-03-10 12:57:27 +01:00 committed by Hein-Pieter van Braam
parent 0d2a2a9300
commit 5eef26b64e
3 changed files with 32 additions and 27 deletions

View File

@ -1149,14 +1149,12 @@ void AnimationKeyEditor::_track_editor_draw() {
get_icon("KeyCall", "EditorIcons")
};
Ref<Texture> valid_icon = get_icon("KeyValid", "EditorIcons");
Ref<Texture> invalid_icon = get_icon("KeyInvalid", "EditorIcons");
Ref<Texture> invalid_icon_hover = get_icon("KeyInvalidHover", "EditorIcons");
const Color modulate_selected = Color(0x84 / 255.0, 0xc2 / 255.0, 0xff / 255.0);
Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons");
Ref<Texture> type_hover = get_icon("KeyHover", "EditorIcons");
Ref<Texture> type_selected = get_icon("KeySelected", "EditorIcons");
int right_separator_ofs = right_data_size_cache;
int h = font->get_height() + sep;
@ -1464,6 +1462,10 @@ void AnimationKeyEditor::_track_editor_draw() {
float x = key_hofs + name_limit + (time - keys_from) * zoom_scale;
Ref<Texture> tex = type_icon[tt];
Color modulate = Color(1, 1, 1);
bool is_hover = false;
bool is_selected = false;
SelectedKey sk;
sk.key = i;
@ -1472,13 +1474,33 @@ void AnimationKeyEditor::_track_editor_draw() {
if (click.click == ClickOver::CLICK_MOVE_KEYS)
continue;
tex = type_selected;
is_selected = true;
}
if (mouse_over.over == MouseOver::OVER_KEY && mouse_over.track == idx && mouse_over.over_key == i)
tex = type_hover;
is_hover = true;
Variant value = animation->track_get_key_value(idx, i);
if (prop_exists && !Variant::can_convert(value.get_type(), valid_type)) {
tex = invalid_icon;
if (is_hover)
modulate = Color(1.5, 1.5, 1.5);
else
modulate = Color(1, 1, 1);
} else if (is_selected) {
tex = valid_icon;
modulate = modulate_selected;
if (is_hover)
modulate = modulate.lightened(0.2);
} else if (is_hover) {
tex = valid_icon;
modulate = Color(1, 1, 1);
}
if (first && i > 0 && value == animation->track_get_key_value(idx, i - 1)) {
te->draw_line(ofs + Vector2(name_limit, y + h / 2), ofs + Point2(x, y + h / 2), color);
@ -1491,19 +1513,7 @@ void AnimationKeyEditor::_track_editor_draw() {
te->draw_line(ofs + Point2(x_n, y + h / 2), ofs + Point2(x, y + h / 2), color);
}
if (prop_exists && !Variant::can_convert(value.get_type(), valid_type)) {
te->draw_texture(invalid_icon, ofs + Point2(x, y + key_vofs).floor());
}
if (prop_exists && !Variant::can_convert(value.get_type(), valid_type)) {
if (tex == type_hover)
te->draw_texture(invalid_icon_hover, ofs + Point2(x, y + key_vofs).floor());
else
te->draw_texture(invalid_icon, ofs + Point2(x, y + key_vofs).floor());
} else {
te->draw_texture(tex, ofs + Point2(x, y + key_vofs).floor());
}
te->draw_texture(tex, ofs + Point2(x, y + key_vofs).floor(), modulate);
first = false;
}
@ -1539,8 +1549,8 @@ void AnimationKeyEditor::_track_editor_draw() {
continue;
int y = h + i * h + sep;
float key_vofs = Math::floor((float)(h - type_selected->get_height()) / 2);
float key_hofs = -Math::floor((float)type_selected->get_height() / 2);
float key_vofs = Math::floor((float)(h - valid_icon->get_height()) / 2);
float key_hofs = -Math::floor((float)valid_icon->get_height() / 2);
float time = animation->track_get_key_time(idx, E->key().key);
float diff = time - from_t;
@ -1554,7 +1564,7 @@ void AnimationKeyEditor::_track_editor_draw() {
x += name_limit;
te->draw_texture(type_selected, ofs + Point2(x + key_hofs, y + key_vofs).floor());
te->draw_texture(valid_icon, ofs + Point2(x + key_hofs, y + key_vofs).floor(), modulate_selected);
}
} break;
default: {};

View File

@ -1,5 +0,0 @@
<svg width="8" height="8" version="1.1" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 -1044.4)">
<rect transform="rotate(-45)" x="-741.53" y="741.08" width="6.1027" height="6.1027" ry=".76286" fill="#84c2ff"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 256 B

View File

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 253 B