diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | doc/classes/TabContainer.xml | 3 | ||||
-rw-r--r-- | editor/editor_node.cpp | 7 | ||||
-rw-r--r-- | editor/editor_node.h | 1 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 62 | ||||
-rw-r--r-- | misc/hooks/README.md | 5 | ||||
-rwxr-xr-x | misc/hooks/pre-commit | 2 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs | 26 | ||||
-rw-r--r-- | scene/2d/gpu_particles_2d.cpp | 2 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 13 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 4 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 1 |
12 files changed, 81 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore index 0ef640bd2f..539003ca6b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ ########################### /custom.py +misc/hooks/pre-commit-custom-* ############################# ### Godot generated files ### diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 74f258072c..302f9b329b 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -258,5 +258,8 @@ <theme_item name="tab_unselected" data_type="style" type="StyleBox"> The style of the other, unselected tabs. </theme_item> + <theme_item name="tabbar_background" data_type="style" type="StyleBox"> + The style for the background fill of the [TabBar] area. + </theme_item> </theme_items> </class> diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6b68c4127f..0f2e0c8fcb 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -753,6 +753,8 @@ void EditorNode::_notification(int p_what) { gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + + tabbar_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("tabbar_background"), SNAME("TabContainer"))); scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); @@ -6490,8 +6492,11 @@ EditorNode::EditorNode() { tab_preview->set_position(Point2(2, 2) * EDSCALE); tab_preview_panel->add_child(tab_preview); + tabbar_panel = memnew(PanelContainer); + tabbar_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("tabbar_background"), SNAME("TabContainer"))); + srt->add_child(tabbar_panel); tabbar_container = memnew(HBoxContainer); - srt->add_child(tabbar_container); + tabbar_panel->add_child(tabbar_container); scene_tabs = memnew(TabBar); scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); diff --git a/editor/editor_node.h b/editor/editor_node.h index 792d2fc879..7e66e14ce0 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -426,6 +426,7 @@ private: int dock_popup_selected_idx = -1; int dock_select_rect_over_idx = -1; + PanelContainer *tabbar_panel = nullptr; HBoxContainer *tabbar_container = nullptr; Button *distraction_free = nullptr; Button *scene_tab_add = nullptr; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index d20caef51c..088239c2d9 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -656,45 +656,46 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // TabBar - Ref<StyleBoxFlat> style_tab_selected = style_widget->duplicate(); + Ref<StyleBoxFlat> style_tab_base = style_widget->duplicate(); - // Add a highlight line at the top of the selected tab. - style_tab_selected->set_border_width_all(0); - style_tab_selected->set_default_margin(SIDE_LEFT, widget_default_margin.x - border_width); - style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE)); - // Make the highlight line prominent, but not too prominent as to not be distracting. - Color tab_highlight = dark_color_2.lerp(accent_color, 0.75); - style_tab_selected->set_border_color(tab_highlight); + style_tab_base->set_border_width_all(0); // Don't round the top corners to avoid creating a small blank space between the tabs and the main panel. // This also makes the top highlight look better. - style_tab_selected->set_corner_radius_all(0); + style_tab_base->set_corner_detail(corner_width); + style_tab_base->set_corner_radius_all(0); + style_tab_base->set_corner_radius(CORNER_TOP_LEFT, corner_radius * EDSCALE); + style_tab_base->set_corner_radius(CORNER_TOP_RIGHT, corner_radius * EDSCALE); // Prevent visible artifacts and cover the top-left rounded corner of the panel below the tab if selected // We can't prevent them with both rounded corners and non-zero border width, though - style_tab_selected->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); - + style_tab_base->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); // When using a border width greater than 0, visually line up the left of the selected tab with the underlying panel. - style_tab_selected->set_expand_margin_size(SIDE_LEFT, -border_width); + style_tab_base->set_expand_margin_size(SIDE_LEFT, -border_width); + + style_tab_base->set_default_margin(SIDE_LEFT, widget_default_margin.x + 5 * EDSCALE); + style_tab_base->set_default_margin(SIDE_RIGHT, widget_default_margin.x + 5 * EDSCALE); + style_tab_base->set_default_margin(SIDE_BOTTOM, widget_default_margin.y); + style_tab_base->set_default_margin(SIDE_TOP, widget_default_margin.y); + + Ref<StyleBoxFlat> style_tab_selected = style_tab_base->duplicate(); - style_tab_selected->set_default_margin(SIDE_LEFT, widget_default_margin.x + 2 * EDSCALE); - style_tab_selected->set_default_margin(SIDE_RIGHT, widget_default_margin.x + 2 * EDSCALE); - style_tab_selected->set_default_margin(SIDE_BOTTOM, widget_default_margin.y); - style_tab_selected->set_default_margin(SIDE_TOP, widget_default_margin.y); style_tab_selected->set_bg_color(base_color); + // Add a highlight line at the top of the selected tab. + style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE)); + // Make the highlight line prominent, but not too prominent as to not be distracting. + Color tab_highlight = dark_color_2.lerp(accent_color, 0.75); + style_tab_selected->set_border_color(tab_highlight); + style_tab_selected->set_corner_radius_all(0); - Ref<StyleBoxFlat> style_tab_unselected = style_tab_selected->duplicate(); - style_tab_unselected->set_bg_color(dark_color_1); + Ref<StyleBoxFlat> style_tab_unselected = style_tab_base->duplicate(); style_tab_unselected->set_expand_margin_size(SIDE_BOTTOM, 0); + style_tab_unselected->set_bg_color(dark_color_1); // Add some spacing between unselected tabs to make them easier to distinguish from each other style_tab_unselected->set_border_color(Color(0, 0, 0, 0)); - style_tab_unselected->set_border_width(SIDE_LEFT, Math::round(1 * EDSCALE)); - style_tab_unselected->set_border_width(SIDE_RIGHT, Math::round(1 * EDSCALE)); - style_tab_unselected->set_default_margin(SIDE_LEFT, widget_default_margin.x + 2 * EDSCALE); - style_tab_unselected->set_default_margin(SIDE_RIGHT, widget_default_margin.x + 2 * EDSCALE); - Ref<StyleBoxFlat> style_tab_disabled = style_tab_selected->duplicate(); - style_tab_disabled->set_bg_color(disabled_bg_color); + Ref<StyleBoxFlat> style_tab_disabled = style_tab_base->duplicate(); style_tab_disabled->set_expand_margin_size(SIDE_BOTTOM, 0); + style_tab_disabled->set_bg_color(disabled_bg_color); style_tab_disabled->set_border_color(disabled_bg_color); // Editor background @@ -1199,6 +1200,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("line_separation", "ItemList", 3 * EDSCALE); // TabBar & TabContainer + Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(dark_color_1, 0, 0, 0, 0); + style_tabbar_background->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); + style_tabbar_background->set_corner_detail(corner_width); + style_tabbar_background->set_corner_radius(CORNER_TOP_LEFT, corner_radius * EDSCALE); + style_tabbar_background->set_corner_radius(CORNER_TOP_RIGHT, corner_radius * EDSCALE); + theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background); + theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected); theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected); theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled); @@ -1234,14 +1242,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_content_panel = style_default->duplicate(); style_content_panel->set_border_color(dark_color_3); style_content_panel->set_border_width_all(border_width); + style_content_panel->set_border_width(Side::SIDE_TOP, 0); + style_content_panel->set_corner_radius(CORNER_TOP_LEFT, 0); + style_content_panel->set_corner_radius(CORNER_TOP_RIGHT, 0); // compensate the border style_content_panel->set_default_margin(SIDE_TOP, (2 + margin_size_extra) * EDSCALE); style_content_panel->set_default_margin(SIDE_RIGHT, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_BOTTOM, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_LEFT, margin_size_extra * EDSCALE); - // Display border to visually split the body of the container from its possible backgrounds. - style_content_panel->set_border_width(Side::SIDE_TOP, Math::round(2 * EDSCALE)); - style_content_panel->set_border_color(dark_color_2); theme->set_stylebox("panel", "TabContainer", style_content_panel); // TabContainerOdd can be used on tabs against the base color background (e.g. nested tabs). diff --git a/misc/hooks/README.md b/misc/hooks/README.md index 8732237244..ea94b3f5f3 100644 --- a/misc/hooks/README.md +++ b/misc/hooks/README.md @@ -35,3 +35,8 @@ so they should work out of the box on Linux/macOS. ##### black - Python installation: make sure Python is added to the `PATH` - Install `black` - in any console: `pip3 install black` + +## Custom hooks + +The pre-commit hook will run any other script in `.git/hooks` whose filename +matches `pre-commit-custom-*`, after the Godot ones. diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit index ab0fc8176f..6359161260 100755 --- a/misc/hooks/pre-commit +++ b/misc/hooks/pre-commit @@ -13,8 +13,8 @@ # pre-commit hooks to be executed. They should be in the same .git/hooks/ folder # as this script. Hooks should return 0 if successful and nonzero to cancel the # commit. They are executed in the order in which they are listed. -#HOOKS="pre-commit-compile pre-commit-uncrustify" HOOKS="pre-commit-clang-format pre-commit-black pre-commit-make-rst" +HOOKS="$HOOKS $(find $(dirname -- "$0") -type f -name 'pre-commit-custom-*' -exec basename {} \;)" ########################################################### # There should be no need to change anything below this line. diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs index 2ea3c18d26..26fffc079c 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs @@ -11,31 +11,31 @@ namespace Godot.NativeInterop case Variant.Type.Nil: return default; case Variant.Type.Bool: - return new godot_variant() { Bool = src.Bool }; + return new godot_variant() { Bool = src.Bool, Type = Variant.Type.Bool }; case Variant.Type.Int: - return new godot_variant() { Int = src.Int }; + return new godot_variant() { Int = src.Int, Type = Variant.Type.Int }; case Variant.Type.Float: - return new godot_variant() { Float = src.Float }; + return new godot_variant() { Float = src.Float, Type = Variant.Type.Float }; case Variant.Type.Vector2: - return new godot_variant() { Vector2 = src.Vector2 }; + return new godot_variant() { Vector2 = src.Vector2, Type = Variant.Type.Vector2 }; case Variant.Type.Vector2i: - return new godot_variant() { Vector2i = src.Vector2i }; + return new godot_variant() { Vector2i = src.Vector2i, Type = Variant.Type.Vector2i }; case Variant.Type.Rect2: - return new godot_variant() { Rect2 = src.Rect2 }; + return new godot_variant() { Rect2 = src.Rect2, Type = Variant.Type.Rect2 }; case Variant.Type.Rect2i: - return new godot_variant() { Rect2i = src.Rect2i }; + return new godot_variant() { Rect2i = src.Rect2i, Type = Variant.Type.Rect2i }; case Variant.Type.Vector3: - return new godot_variant() { Vector3 = src.Vector3 }; + return new godot_variant() { Vector3 = src.Vector3, Type = Variant.Type.Vector3 }; case Variant.Type.Vector3i: - return new godot_variant() { Vector3i = src.Vector3i }; + return new godot_variant() { Vector3i = src.Vector3i, Type = Variant.Type.Vector3i }; case Variant.Type.Plane: - return new godot_variant() { Plane = src.Plane }; + return new godot_variant() { Plane = src.Plane, Type = Variant.Type.Plane }; case Variant.Type.Quaternion: - return new godot_variant() { Quaternion = src.Quaternion }; + return new godot_variant() { Quaternion = src.Quaternion, Type = Variant.Type.Quaternion }; case Variant.Type.Color: - return new godot_variant() { Color = src.Color }; + return new godot_variant() { Color = src.Color, Type = Variant.Type.Color }; case Variant.Type.Rid: - return new godot_variant() { RID = src.RID }; + return new godot_variant() { RID = src.RID, Type = Variant.Type.Rid }; } godotsharp_variant_new_copy(out godot_variant ret, src); diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index cb0349fefd..bed68b4ee0 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -376,7 +376,7 @@ void GPUParticles2D::_texture_changed() { // Changes to the texture need to trigger an update to make // the editor redraw the sprite with the updated texture. if (texture.is_valid()) { - update(); + queue_redraw(); } } diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 7d9f83b7a2..5b18d4e457 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -75,10 +75,17 @@ Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree."); ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); -#ifdef DEBUG_ENABLED Variant::Type property_type = p_target->get_indexed(p_property.get_as_property_path().get_subnames()).get_type(); - ERR_FAIL_COND_V_MSG(property_type != p_to.get_type(), Ref<PropertyTweener>(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); -#endif + if (property_type != p_to.get_type()) { + // Cast p_to between floats and ints to avoid minor annoyances. + if (property_type == Variant::FLOAT && p_to.get_type() == Variant::INT) { + p_to = float(p_to); + } else if (property_type == Variant::INT && p_to.get_type() == Variant::FLOAT) { + p_to = int(p_to); + } else { + ERR_FAIL_V_MSG(Ref<PropertyTweener>(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); + } + } Ref<PropertyTweener> tweener = memnew(PropertyTweener(p_target, p_property, p_to, p_duration)); append(tweener); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 861a3050cb..3e04ebee6a 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -163,6 +163,10 @@ void TabContainer::_notification(int p_what) { int header_height = _get_top_margin(); + // Draw background for the tabbar. + Ref<StyleBox> tabbar_background = get_theme_stylebox(SNAME("tabbar_background")); + tabbar_background->draw(canvas, Rect2(0, 0, size.width, header_height)); + // Draw the background for the tab's content. panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height)); // Draw the popup menu. diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 410f35e597..73ad1ceff7 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -831,6 +831,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected); theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled); theme->set_stylebox("panel", "TabContainer", make_flat_stylebox(style_normal_color, 0, 0, 0, 0)); + theme->set_stylebox("tabbar_background", "TabContainer", make_empty_stylebox(0, 0, 0, 0)); theme->set_icon("increment", "TabContainer", icons["scroll_button_right"]); theme->set_icon("increment_highlight", "TabContainer", icons["scroll_button_right_hl"]); |