summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorBernhard Liebl <Bernhard.Liebl@gmx.org>2018-03-10 12:57:27 +0100
committerBernhard Liebl <Bernhard.Liebl@gmx.org>2018-03-10 12:57:27 +0100
commit172aa6c61e27f6506f265983fc18e1f5e248efeb (patch)
tree137fafe98864e54ff5706f384b0b0e2057ccc5cd /editor
parent47addcf9d03da717e54158e455d1fc558b4bd66f (diff)
Fix broken hover/select coloring of keys in animation editor
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_editor.cpp54
-rw-r--r--editor/icons/icon_key_selected.svg5
-rw-r--r--editor/icons/icon_key_valid.svg (renamed from editor/icons/icon_key_hover.svg)0
3 files changed, 32 insertions, 27 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp
index 1b97a24968..b40ec2cff7 100644
--- a/editor/animation_editor.cpp
+++ b/editor/animation_editor.cpp
@@ -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: {};
diff --git a/editor/icons/icon_key_selected.svg b/editor/icons/icon_key_selected.svg
deleted file mode 100644
index c73d31981d..0000000000
--- a/editor/icons/icon_key_selected.svg
+++ /dev/null
@@ -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>
diff --git a/editor/icons/icon_key_hover.svg b/editor/icons/icon_key_valid.svg
index 4a3fab4754..4a3fab4754 100644
--- a/editor/icons/icon_key_hover.svg
+++ b/editor/icons/icon_key_valid.svg