Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix bottom border in the animation track

Michael Alexsanderbf7045a8f4b8
diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp
index 7f355230b65..f7ea50d147d 100644
--- a/editor/animation/animation_track_editor.cpp
+++ b/editor/animation/animation_track_editor.cpp
@@ -5604,10 +5604,6 @@ void AnimationTrackEditor::_notification(int p_what) {
dummy_player_warning->set_button_icon(get_editor_theme_icon(SNAME("NodeWarning")));
inactive_player_warning->set_button_icon(get_editor_theme_icon(SNAME("NodeWarning")));
- Ref<StyleBox> panel_style = get_theme_stylebox(SceneStringName(panel), SNAME("Tree"))->duplicate();
- panel_style->set_content_margin(SIDE_TOP, get_theme_constant("base_margin", EditorStringName(Editor)) * EDSCALE);
- main_panel->add_theme_style_override(SceneStringName(panel), panel_style);
-
edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_ADD_RESET_KEY), get_editor_theme_icon(SNAME("MoveUp")));
edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_editor_theme_icon(SNAME("Reload")));
auto_fit->set_button_icon(get_editor_theme_icon(SNAME("AnimationAutoFit")));
@@ -8119,9 +8115,11 @@ AnimationTrackEditor::AnimationTrackEditor() {
mc->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(mc);
- main_panel = memnew(PanelContainer);
+ PanelContainer *main_panel = memnew(PanelContainer);
main_panel->set_focus_mode(FOCUS_ALL); // Allow panel to have focus so that shortcuts work as expected.
+ main_panel->set_theme_type_variation("AnimationTrackPanel");
mc->add_child(main_panel);
+
HBoxContainer *timeline_scroll = memnew(HBoxContainer);
main_panel->add_child(timeline_scroll);
timeline_scroll->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/animation/animation_track_editor.h b/editor/animation/animation_track_editor.h
index 5ee3cdbf67b..9318a7e4d06 100644
--- a/editor/animation/animation_track_editor.h
+++ b/editor/animation/animation_track_editor.h
@@ -617,7 +617,6 @@ class AnimationTrackEditor : public VBoxContainer {
MenuButton *edit = nullptr;
- PanelContainer *main_panel = nullptr;
HScrollBar *hscroll = nullptr;
ScrollContainer *scroll = nullptr;
VBoxContainer *track_vbox = nullptr;
diff --git a/editor/themes/theme_modern.cpp b/editor/themes/theme_modern.cpp
index e74ff61bb7c..786a5ca200d 100644
--- a/editor/themes/theme_modern.cpp
+++ b/editor/themes/theme_modern.cpp
@@ -2041,75 +2041,6 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
p_theme->set_stylebox(SceneStringName(panel), "EditorAbout", p_config.window_complex_style);
p_theme->set_stylebox(SceneStringName(panel), "ThemeItemEditorDialog", p_config.window_complex_style);
- // MarginContainers with negative margins, to negate borders. Used with scroll hints.
- {
- int panel_margin = p_theme->get_stylebox(SceneStringName(panel), SNAME("PanelContainer"))->get_content_margin(SIDE_LEFT);
- int margin = -panel_margin;
-
- p_theme->set_type_variation("NoBorderHorizontal", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderHorizontal", margin);
- p_theme->set_constant("margin_right", "NoBorderHorizontal", margin);
-
- p_theme->set_type_variation("NoBorderHorizontalBottom", "NoBorderHorizontal");
- p_theme->set_constant("margin_bottom", "NoBorderHorizontalBottom", margin);
-
- // Used in the asset library. Specifically, the ("bg", "AssetLib") stylebox.
-
- margin = -p_config.base_margin * EDSCALE;
-
- p_theme->set_type_variation("NoBorderAssetLib", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderAssetLib", margin);
- p_theme->set_constant("margin_right", "NoBorderAssetLib", margin);
- p_theme->set_constant("margin_bottom", "NoBorderAssetLib", margin);
-
- p_theme->set_type_variation("NoBorderAssetLibHorizontal", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderAssetLibHorizontal", margin);
- p_theme->set_constant("margin_right", "NoBorderAssetLibHorizontal", margin);
-
- margin -= panel_margin;
-
- // Same as above, but with the margins adapted for the project manager.
-
- p_theme->set_type_variation("NoBorderAssetLibProjectManager", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderAssetLibProjectManager", margin);
- p_theme->set_constant("margin_right", "NoBorderAssetLibProjectManager", margin);
- p_theme->set_constant("margin_bottom", "NoBorderAssetLibProjectManager", margin);
-
- p_theme->set_type_variation("NoBorderAssetLibProjectManagerHorizontal", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderAssetLibProjectManagerHorizontal", margin);
- p_theme->set_constant("margin_right", "NoBorderAssetLibProjectManagerHorizontal", margin);
-
- int bottom_panel_margin = p_theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))->get_content_margin(SIDE_LEFT);
-
- p_theme->set_type_variation("NoBorderPanel", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderPanel", -bottom_panel_margin);
- p_theme->set_constant("margin_right", "NoBorderPanel", -bottom_panel_margin);
-
- p_theme->set_type_variation("NoBorderBottomPanel", "NoBorderPanel");
- p_theme->set_constant("margin_bottom", "NoBorderBottomPanel", -bottom_panel_margin);
-
- margin = -p_theme->get_stylebox(SceneStringName(panel), SNAME("AcceptDialog"))->get_content_margin(SIDE_LEFT);
-
- p_theme->set_type_variation("NoBorderHorizontalWindow", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderHorizontalWindow", margin);
- p_theme->set_constant("margin_right", "NoBorderHorizontalWindow", margin);
-
- margin = 2 * -bottom_panel_margin;
-
- // Same as above, including the bottom.
- p_theme->set_type_variation("NoBorderBottomWideWindow", "NoBorderHorizontalWindow");
- p_theme->set_constant("margin_bottom", "NoBorderBottomWideWindow", margin);
-
- // Used in the animation track editor.
- p_theme->set_type_variation("NoBorderAnimation", "MarginContainer");
- p_theme->set_constant("margin_left", "NoBorderAnimation", margin);
- p_theme->set_constant("margin_right", "NoBorderAnimation", margin);
-
- // Used in the OpenXR action map editor.
- p_theme->set_type_variation("NoBorderOpenXR", "NoBorderAnimation");
- p_theme->set_constant("margin_bottom", "NoBorderOpenXR", -panel_margin);
- }
-
// Buttons in material previews.
{
const Color dim_light_color = p_config.icon_normal_color.darkened(0.24);
@@ -2614,6 +2545,11 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
int margin = p_theme->get_stylebox(SceneStringName(panel), SNAME("PanelContainer"))->get_content_margin(SIDE_LEFT);
+ p_theme->set_type_variation("AnimationTrackPanel", "PanelContainer");
+ Ref<StyleBox> panel_sb = p_theme->get_stylebox(SceneStringName(panel), SNAME("Tree"))->duplicate();
+ panel_sb->set_content_margin(SIDE_TOP, p_config.base_margin * EDSCALE);
+ p_theme->set_stylebox(SceneStringName(panel), "AnimationTrackPanel", panel_sb);
+
p_theme->set_type_variation("AnimationTrackMargins", "MarginContainer");
p_theme->set_constant("margin_left", "AnimationTrackMargins", margin);
p_theme->set_constant("margin_right", "AnimationTrackMargins", margin);
@@ -2934,4 +2870,74 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
Ref<StyleBoxFlat> tile_expand_style = p_config.base_style->duplicate();
tile_expand_style->set_corner_radius_all(0);
p_theme->set_stylebox("expand_panel", "TileSetEditor", tile_expand_style);
+
+ // MarginContainers with negative margins, to negate borders. Used with scroll hints.
+ {
+ int panel_margin = p_theme->get_stylebox(SceneStringName(panel), SNAME("PanelContainer"))->get_content_margin(SIDE_LEFT);
+ int margin = -panel_margin;
+
+ p_theme->set_type_variation("NoBorderHorizontal", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderHorizontal", margin);
+ p_theme->set_constant("margin_right", "NoBorderHorizontal", margin);
+
+ p_theme->set_type_variation("NoBorderHorizontalBottom", "NoBorderHorizontal");
+ p_theme->set_constant("margin_bottom", "NoBorderHorizontalBottom", margin);
+
+ // Used in the asset library. Specifically, the ("bg", "AssetLib") stylebox.
+
+ margin = -p_config.base_margin * EDSCALE;
+
+ p_theme->set_type_variation("NoBorderAssetLib", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderAssetLib", margin);
+ p_theme->set_constant("margin_right", "NoBorderAssetLib", margin);
+ p_theme->set_constant("margin_bottom", "NoBorderAssetLib", margin);
+
+ p_theme->set_type_variation("NoBorderAssetLibHorizontal", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderAssetLibHorizontal", margin);
+ p_theme->set_constant("margin_right", "NoBorderAssetLibHorizontal", margin);
+
+ margin -= panel_margin;
+
+ // Same as above, but with the margins adapted for the project manager.
+
+ p_theme->set_type_variation("NoBorderAssetLibProjectManager", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderAssetLibProjectManager", margin);
+ p_theme->set_constant("margin_right", "NoBorderAssetLibProjectManager", margin);
+ p_theme->set_constant("margin_bottom", "NoBorderAssetLibProjectManager", margin);
+
+ p_theme->set_type_variation("NoBorderAssetLibProjectManagerHorizontal", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderAssetLibProjectManagerHorizontal", margin);
+ p_theme->set_constant("margin_right", "NoBorderAssetLibProjectManagerHorizontal", margin);
+
+ int bottom_panel_margin = p_theme->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))->get_content_margin(SIDE_LEFT);
+
+ p_theme->set_type_variation("NoBorderPanel", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderPanel", -bottom_panel_margin);
+ p_theme->set_constant("margin_right", "NoBorderPanel", -bottom_panel_margin);
+
+ p_theme->set_type_variation("NoBorderBottomPanel", "NoBorderPanel");
+ p_theme->set_constant("margin_bottom", "NoBorderBottomPanel", -bottom_panel_margin);
+
+ margin = -p_theme->get_stylebox(SceneStringName(panel), SNAME("AcceptDialog"))->get_content_margin(SIDE_LEFT);
+
+ p_theme->set_type_variation("NoBorderHorizontalWindow", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderHorizontalWindow", margin);
+ p_theme->set_constant("margin_right", "NoBorderHorizontalWindow", margin);
+
+ margin = 2 * -bottom_panel_margin;
+
+ // Same as above, including the bottom.
+ p_theme->set_type_variation("NoBorderBottomWideWindow", "NoBorderHorizontalWindow");
+ p_theme->set_constant("margin_bottom", "NoBorderBottomWideWindow", margin);
+
+ // Used in the animation track editor.
+ p_theme->set_type_variation("NoBorderAnimation", "MarginContainer");
+ p_theme->set_constant("margin_left", "NoBorderAnimation", margin);
+ p_theme->set_constant("margin_right", "NoBorderAnimation", margin);
+ p_theme->set_constant("margin_bottom", "NoBorderAnimation", -p_theme->get_stylebox(SceneStringName(panel), SNAME("AnimationTrackPanel"))->get_content_margin(SIDE_BOTTOM));
+
+ // Used in the OpenXR action map editor.
+ p_theme->set_type_variation("NoBorderOpenXR", "NoBorderAnimation");
+ p_theme->set_constant("margin_bottom", "NoBorderOpenXR", -panel_margin);
+ }
}