diff options
Diffstat (limited to 'editor/animation_track_editor.cpp')
-rw-r--r-- | editor/animation_track_editor.cpp | 92 |
1 files changed, 49 insertions, 43 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 53f585d06b..11995e8cb4 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -606,8 +606,7 @@ public: } break; case Animation::TYPE_METHOD: { p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name")); - static_assert(VARIANT_ARG_MAX == 8, "PROPERTY_HINT_RANGE needs to be updated if VARIANT_ARG_MAX != 8"); - p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,8,1")); + p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,32,1,or_greater")); Dictionary d = animation->track_get_key_value(track, key); ERR_FAIL_COND(!d.has("args")); @@ -1287,8 +1286,8 @@ public: } break; case Animation::TYPE_METHOD: { p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name")); - static_assert(VARIANT_ARG_MAX == 8, "PROPERTY_HINT_RANGE needs to be updated if VARIANT_ARG_MAX != 8"); - p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,8,1")); + + p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,32,1,or_greater")); Dictionary d = animation->track_get_key_value(first_track, first_key); ERR_FAIL_COND(!d.has("args")); @@ -1459,7 +1458,8 @@ int AnimationTimelineEdit::get_name_limit() const { void AnimationTimelineEdit::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { panner->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/animation_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning"))); add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); @@ -1946,6 +1946,16 @@ AnimationTimelineEdit::AnimationTimelineEdit() { void AnimationTrackEdit::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_THEME_CHANGED: { + if (animation.is_null()) { + return; + } + ERR_FAIL_INDEX(track, animation->get_track_count()); + + type_icon = _get_key_type_icon(); + selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); + } break; + case NOTIFICATION_DRAW: { if (animation.is_null()) { return; @@ -1964,17 +1974,6 @@ void AnimationTrackEdit::_notification(int p_what) { Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); - Ref<Texture2D> type_icons[9] = { - get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackScale"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyTrackBlendShape"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) - }; int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); Color linecolor = color; linecolor.a = 0.2; @@ -1990,7 +1989,7 @@ void AnimationTrackEdit::_notification(int p_what) { draw_texture(check, check_rect.position); ofs += check->get_width() + hsep; - Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)]; + Ref<Texture2D> type_icon = _get_key_type_icon(); draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); ofs += type_icon->get_width() + hsep; @@ -2426,22 +2425,10 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati track = p_track; update(); - Ref<Texture2D> type_icons[9] = { - get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyXPosition"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyXRotation"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyXScale"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyBlendShape"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), - get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) - }; - ERR_FAIL_INDEX(track, animation->get_track_count()); node_path = animation->track_get_path(p_track); - type_icon = type_icons[animation->track_get_type(track)]; + type_icon = _get_key_type_icon(); selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); } @@ -2542,6 +2529,21 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant return (!prop_exists || Variant::can_convert(p_key_value.get_type(), r_valid_type)); } +Ref<Texture2D> AnimationTrackEdit::_get_key_type_icon() const { + Ref<Texture2D> type_icons[9] = { + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackPosition"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackRotation"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackScale"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyTrackBlendShape"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) + }; + return type_icons[animation->track_get_type(track)]; +} + String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (check_rect.has_point(p_pos)) { return TTR("Toggle this track on/off."); @@ -2748,7 +2750,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); - menu->set_as_minsize(); + menu->reset_size(); Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); menu->set_position(popup_pos); @@ -2766,7 +2768,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); - menu->set_as_minsize(); + menu->reset_size(); Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); menu->set_position(popup_pos); @@ -2783,7 +2785,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->clear(); menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); - menu->set_as_minsize(); + menu->reset_size(); Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height); menu->set_position(popup_pos); @@ -2885,7 +2887,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->add_separator(); menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); } - menu->set_as_minsize(); + menu->reset_size(); menu->set_position(get_screen_position() + get_local_mouse_position()); menu->popup(); @@ -3189,7 +3191,7 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_value_track_edit(Object *p_ }; Callable::CallError ce; - return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_value_track_edit", (const Variant **)&argptrs, 6, ce).operator Object *()); + return Object::cast_to<AnimationTrackEdit>(get_script_instance()->callp("create_value_track_edit", (const Variant **)&argptrs, 6, ce).operator Object *()); } return nullptr; } @@ -3588,7 +3590,7 @@ void AnimationTrackEditor::commit_insert_queue() { } } - if (bool(EDITOR_DEF("editors/animation/confirm_insert_track", true)) && num_tracks > 0) { + if (bool(EDITOR_GET("editors/animation/confirm_insert_track")) && num_tracks > 0) { // Potentially a new key, does not exist. if (num_tracks == 1) { // TRANSLATORS: %s will be replaced by a phrase describing the target of track. @@ -5554,31 +5556,35 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } } + String track_type; switch (animation->track_get_type(i)) { case Animation::TYPE_POSITION_3D: - text += " (Position)"; + track_type = TTR("Position"); break; case Animation::TYPE_ROTATION_3D: - text += " (Rotation)"; + track_type = TTR("Rotation"); break; case Animation::TYPE_SCALE_3D: - text += " (Scale)"; + track_type = TTR("Scale"); break; case Animation::TYPE_BLEND_SHAPE: - text += " (BlendShape)"; + track_type = TTR("BlendShape"); break; case Animation::TYPE_METHOD: - text += " (Methods)"; + track_type = TTR("Methods"); break; case Animation::TYPE_BEZIER: - text += " (Bezier)"; + track_type = TTR("Bezier"); break; case Animation::TYPE_AUDIO: - text += " (Audio)"; + track_type = TTR("Audio"); break; default: { }; } + if (!track_type.is_empty()) { + text += vformat(" (%s)", track_type); + } TreeItem *it = track_copy_select->create_item(troot); it->set_editable(0, true); |