From 4b8b8039316493ee3fa77c6bb93f95e109fa68a6 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 22 Dec 2020 16:24:29 +0000 Subject: [PATCH] Rename Control margin to offset --- core/core_constants.cpp | 8 +- core/math/math_defs.h | 10 +- core/math/rect2.h | 28 +- core/variant/binder_common.h | 2 +- core/variant/variant.cpp | 4 +- core/variant/variant.h | 2 +- core/variant/variant_internal.h | 2 +- doc/classes/@GlobalScope.xml | 16 +- doc/classes/Camera2D.xml | 16 +- doc/classes/Control.xml | 102 +++--- doc/classes/GraphNode.xml | 10 +- doc/classes/NinePatchRect.xml | 8 +- doc/classes/Rect2.xml | 4 +- doc/classes/Rect2i.xml | 4 +- doc/classes/StyleBox.xml | 12 +- doc/classes/StyleBoxFlat.xml | 18 +- doc/classes/StyleBoxTexture.xml | 16 +- doc/classes/TextureProgressBar.xml | 4 +- editor/animation_bezier_editor.cpp | 2 +- editor/animation_track_editor.cpp | 8 +- editor/code_editor.cpp | 8 +- editor/debugger/editor_debugger_node.cpp | 8 +- .../debugger/editor_performance_profiler.cpp | 2 +- editor/editor_audio_buses.cpp | 2 +- editor/editor_feature_profile.cpp | 2 +- editor/editor_help.cpp | 4 +- editor/editor_inspector.cpp | 2 +- editor/editor_layouts_dialog.cpp | 16 +- editor/editor_node.cpp | 16 +- editor/editor_properties.cpp | 10 +- editor/editor_properties_array_dict.cpp | 2 +- editor/editor_spin_slider.cpp | 6 +- editor/editor_themes.cpp | 128 ++++---- editor/find_in_files.cpp | 16 +- editor/groups_editor.cpp | 4 +- editor/input_map_editor.cpp | 14 +- .../animation_blend_tree_editor_plugin.cpp | 2 +- .../animation_state_machine_editor.cpp | 10 +- .../plugins/asset_library_editor_plugin.cpp | 18 +- editor/plugins/audio_stream_editor_plugin.cpp | 4 +- editor/plugins/camera_3d_editor_plugin.cpp | 24 +- editor/plugins/canvas_item_editor_plugin.cpp | 274 ++++++++-------- editor/plugins/canvas_item_editor_plugin.h | 78 ++--- editor/plugins/material_editor_plugin.cpp | 4 +- editor/plugins/mesh_editor_plugin.cpp | 2 +- editor/plugins/mesh_library_editor_plugin.cpp | 2 +- editor/plugins/multimesh_editor_plugin.cpp | 2 +- editor/plugins/node_3d_editor_plugin.cpp | 38 +-- editor/plugins/polygon_2d_editor_plugin.cpp | 8 +- editor/plugins/script_text_editor.cpp | 12 +- editor/plugins/shader_editor_plugin.cpp | 2 +- editor/plugins/text_editor.cpp | 2 +- editor/plugins/texture_3d_editor_plugin.cpp | 12 +- .../plugins/texture_layered_editor_plugin.cpp | 12 +- .../plugins/texture_region_editor_plugin.cpp | 62 ++-- editor/plugins/tile_map_editor_plugin.cpp | 2 +- .../plugins/visual_shader_editor_plugin.cpp | 16 +- editor/progress_dialog.cpp | 12 +- editor/project_manager.cpp | 14 +- editor/property_editor.cpp | 40 +-- editor/scene_tree_dock.cpp | 4 +- editor/scene_tree_editor.cpp | 4 +- editor/settings_config_dialog.cpp | 6 +- modules/gdnative/gdnative/rect2.cpp | 8 +- .../gdnative_library_editor_plugin.cpp | 4 +- modules/gridmap/grid_map_editor_plugin.cpp | 2 +- .../visual_script/visual_script_editor.cpp | 14 +- scene/2d/camera_2d.cpp | 128 ++++---- scene/2d/camera_2d.h | 8 +- scene/gui/button.cpp | 50 +-- scene/gui/button.h | 2 +- scene/gui/check_box.cpp | 18 +- scene/gui/check_button.cpp | 18 +- scene/gui/color_picker.cpp | 6 +- scene/gui/control.cpp | 302 +++++++++--------- scene/gui/control.h | 38 +-- scene/gui/dialogs.cpp | 4 +- scene/gui/graph_edit.cpp | 56 ++-- scene/gui/graph_node.cpp | 34 +- scene/gui/graph_node.h | 6 +- scene/gui/item_list.cpp | 10 +- scene/gui/label.cpp | 4 +- scene/gui/line_edit.cpp | 48 +-- scene/gui/nine_patch_rect.cpp | 42 +-- scene/gui/nine_patch_rect.h | 4 +- scene/gui/option_button.cpp | 12 +- scene/gui/popup_menu.cpp | 20 +- scene/gui/rich_text_label.cpp | 8 +- scene/gui/scroll_bar.cpp | 8 +- scene/gui/scroll_container.cpp | 20 +- scene/gui/spin_box.cpp | 6 +- scene/gui/tab_container.cpp | 32 +- scene/gui/tabs.cpp | 26 +- scene/gui/text_edit.cpp | 26 +- scene/gui/texture_progress_bar.cpp | 34 +- scene/gui/texture_progress_bar.h | 4 +- scene/gui/tree.cpp | 18 +- scene/main/viewport.cpp | 10 +- .../resources/default_theme/default_theme.cpp | 78 ++--- scene/resources/style_box.cpp | 188 +++++------ scene/resources/style_box.h | 32 +- servers/rendering/renderer_canvas_cull.cpp | 8 +- .../renderer_rd/renderer_canvas_render_rd.cpp | 8 +- .../rendering/rendering_server_default.cpp | 16 +- tests/test_gui.cpp | 6 +- tests/test_rect2.h | 8 +- 106 files changed, 1278 insertions(+), 1278 deletions(-) diff --git a/core/core_constants.cpp b/core/core_constants.cpp index 8585078722..555908ea79 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -112,10 +112,10 @@ VARIANT_ENUM_CAST(JoyAxisList); VARIANT_ENUM_CAST(MidiMessageList); void register_global_constants() { - BIND_CORE_ENUM_CONSTANT(MARGIN_LEFT); - BIND_CORE_ENUM_CONSTANT(MARGIN_TOP); - BIND_CORE_ENUM_CONSTANT(MARGIN_RIGHT); - BIND_CORE_ENUM_CONSTANT(MARGIN_BOTTOM); + BIND_CORE_ENUM_CONSTANT(SIDE_LEFT); + BIND_CORE_ENUM_CONSTANT(SIDE_TOP); + BIND_CORE_ENUM_CONSTANT(SIDE_RIGHT); + BIND_CORE_ENUM_CONSTANT(SIDE_BOTTOM); BIND_CORE_ENUM_CONSTANT(CORNER_TOP_LEFT); BIND_CORE_ENUM_CONSTANT(CORNER_TOP_RIGHT); diff --git a/core/math/math_defs.h b/core/math/math_defs.h index 4d97f72ebf..0478de732a 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -83,11 +83,11 @@ enum VAlign { VALIGN_BOTTOM }; -enum Margin { - MARGIN_LEFT, - MARGIN_TOP, - MARGIN_RIGHT, - MARGIN_BOTTOM +enum Side { + SIDE_LEFT, + SIDE_TOP, + SIDE_RIGHT, + SIDE_BOTTOM }; enum Corner { diff --git a/core/math/rect2.h b/core/math/rect2.h index f36084ec74..aecba9e88c 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -189,17 +189,17 @@ struct Rect2 { return g; } - inline Rect2 grow_margin(Margin p_margin, real_t p_amount) const { + inline Rect2 grow_margin(Side p_side, real_t p_amount) const { Rect2 g = *this; - g = g.grow_individual((MARGIN_LEFT == p_margin) ? p_amount : 0, - (MARGIN_TOP == p_margin) ? p_amount : 0, - (MARGIN_RIGHT == p_margin) ? p_amount : 0, - (MARGIN_BOTTOM == p_margin) ? p_amount : 0); + g = g.grow_individual((SIDE_LEFT == p_side) ? p_amount : 0, + (SIDE_TOP == p_side) ? p_amount : 0, + (SIDE_RIGHT == p_side) ? p_amount : 0, + (SIDE_BOTTOM == p_side) ? p_amount : 0); return g; } - inline Rect2 grow_margin_bind(uint32_t p_margin, real_t p_amount) const { - return grow_margin(Margin(p_margin), p_amount); + inline Rect2 grow_margin_bind(uint32_t p_side, real_t p_amount) const { + return grow_margin(Side(p_side), p_amount); } inline Rect2 grow_individual(real_t p_left, real_t p_top, real_t p_right, real_t p_bottom) const { @@ -431,17 +431,17 @@ struct Rect2i { return g; } - inline Rect2i grow_margin(Margin p_margin, int p_amount) const { + inline Rect2i grow_margin(Side p_side, int p_amount) const { Rect2i g = *this; - g = g.grow_individual((MARGIN_LEFT == p_margin) ? p_amount : 0, - (MARGIN_TOP == p_margin) ? p_amount : 0, - (MARGIN_RIGHT == p_margin) ? p_amount : 0, - (MARGIN_BOTTOM == p_margin) ? p_amount : 0); + g = g.grow_individual((SIDE_LEFT == p_side) ? p_amount : 0, + (SIDE_TOP == p_side) ? p_amount : 0, + (SIDE_RIGHT == p_side) ? p_amount : 0, + (SIDE_BOTTOM == p_side) ? p_amount : 0); return g; } - inline Rect2i grow_margin_bind(uint32_t p_margin, int p_amount) const { - return grow_margin(Margin(p_margin), p_amount); + inline Rect2i grow_margin_bind(uint32_t p_side, int p_amount) const { + return grow_margin(Side(p_side), p_amount); } inline Rect2i grow_individual(int p_left, int p_top, int p_right, int p_bottom) const { diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h index e950709526..95113c89ba 100644 --- a/core/variant/binder_common.h +++ b/core/variant/binder_common.h @@ -87,7 +87,7 @@ VARIANT_ENUM_CAST(Object::ConnectFlags); VARIANT_ENUM_CAST(Vector3::Axis); VARIANT_ENUM_CAST(Error); -VARIANT_ENUM_CAST(Margin); +VARIANT_ENUM_CAST(Side); VARIANT_ENUM_CAST(Corner); VARIANT_ENUM_CAST(Orientation); VARIANT_ENUM_CAST(HAlign); diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 741d05c139..9eb512f71d 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -2338,8 +2338,8 @@ Variant::operator Vector() const { return to; } -Variant::operator Margin() const { - return (Margin) operator int(); +Variant::operator Side() const { + return (Side) operator int(); } Variant::operator Orientation() const { diff --git a/core/variant/variant.h b/core/variant/variant.h index 76c936a7bd..b22488a877 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -356,7 +356,7 @@ public: operator Vector() const; // some core type enums to convert to - operator Margin() const; + operator Side() const; operator Orientation() const; operator IP_Address() const; diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index 804abf8fbc..57e8f8813f 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -743,7 +743,7 @@ VARIANT_ACCESSOR_NUMBER(int64_t) VARIANT_ACCESSOR_NUMBER(uint64_t) VARIANT_ACCESSOR_NUMBER(char32_t) VARIANT_ACCESSOR_NUMBER(Error) -VARIANT_ACCESSOR_NUMBER(Margin) +VARIANT_ACCESSOR_NUMBER(Side) template <> struct VariantInternalAccessor { diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 3f0a7b7c25..f128de52ea 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1250,17 +1250,17 @@ - - Left margin, usually used for [Control] or [StyleBox]-derived classes. + + Left side, usually used for [Control] or [StyleBox]-derived classes. - - Top margin, usually used for [Control] or [StyleBox]-derived classes. + + Top side, usually used for [Control] or [StyleBox]-derived classes. - - Right margin, usually used for [Control] or [StyleBox]-derived classes. + + Right side, usually used for [Control] or [StyleBox]-derived classes. - - Bottom margin, usually used for [Control] or [StyleBox]-derived classes. + + Bottom side, usually used for [Control] or [StyleBox]-derived classes. Top-left corner. diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml index c7ee915109..957195d73b 100644 --- a/doc/classes/Camera2D.xml +++ b/doc/classes/Camera2D.xml @@ -52,19 +52,19 @@ - + - Returns the specified margin. See also [member drag_margin_bottom], [member drag_margin_top], [member drag_margin_left], and [member drag_margin_right]. + Returns the drag margin for the specified [enum Side]. See also [member drag_margin_bottom], [member drag_margin_top], [member drag_margin_left], and [member drag_margin_right]. - + - Returns the specified camera limit. See also [member limit_bottom], [member limit_top], [member limit_left], and [member limit_right]. + Returns the camera limit for the specified [enum Side]. See also [member limit_bottom], [member limit_top], [member limit_left], and [member limit_right]. @@ -85,23 +85,23 @@ - + - Sets the specified margin. See also [member drag_margin_bottom], [member drag_margin_top], [member drag_margin_left], and [member drag_margin_right]. + Sets the drag margin for the specified [enum Side]. See also [member drag_margin_bottom], [member drag_margin_top], [member drag_margin_left], and [member drag_margin_right]. - + - Sets the specified camera limit. See also [member limit_bottom], [member limit_top], [member limit_left], and [member limit_right]. + Sets the camera limit for the specified [enum Side]. See also [member limit_bottom], [member limit_top], [member limit_left], and [member limit_right]. diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 14d44a2fbe..811d0d6369 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -1,11 +1,11 @@ - All user interface nodes inherit from Control. A control's anchors and margins adapt its position and size relative to its parent. + All user interface nodes inherit from Control. A control's anchors and offsets adapt its position and size relative to its parent. - Base class for all UI-related nodes. [Control] features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change. - For more information on Godot's UI system, anchors, margins, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from [Control] and [Container] nodes. + Base class for all UI-related nodes. [Control] features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and offsets relative to the anchor. The offsets update automatically when the node, any of its parents, or the screen size change. + For more information on Godot's UI system, anchors, offsets, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from [Control] and [Container] nodes. [b]User Interface nodes and input[/b] Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [code]MainLoop._input_event[/code]. [b]FIXME:[/b] No longer valid after DisplayServer split and Input refactoring. @@ -332,17 +332,17 @@ - + - Returns the anchor identified by [code]margin[/code] constant from [enum Margin] enum. A getter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top]. + Returns the anchor for the specified [enum Side]. A getter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top]. - Returns [member margin_left] and [member margin_top]. See also [member rect_position]. + Returns [member offset_left] and [member offset_top]. See also [member rect_position]. @@ -391,16 +391,16 @@ - Returns [member margin_right] and [member margin_bottom]. + Returns [member offset_right] and [member offset_bottom]. - + - Returns the focus neighbor identified by [code]margin[/code] constant from [enum Margin] enum. A getter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top]. + Returns the focus neighbor for the specified [enum Side]. A getter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top]. @@ -417,13 +417,13 @@ Returns the position and size of the control relative to the top-left corner of the screen. See [member rect_position] and [member rect_size]. - + - + - Returns the anchor identified by [code]margin[/code] constant from [enum Margin] enum. A getter method for [member margin_bottom], [member margin_left], [member margin_right] and [member margin_top]. + Returns the anchor for the specified [enum Side]. A getter method for [member offset_bottom], [member offset_left], [member offset_right] and [member offset_top]. @@ -745,24 +745,24 @@ - + - + - Sets the anchor identified by [code]margin[/code] constant from [enum Margin] enum to value [code]anchor[/code]. A setter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top]. - If [code]keep_margin[/code] is [code]true[/code], margins aren't updated after this operation. + Sets the anchor for the specified [enum Side] to [code]anchor[/code]. A setter method for [member anchor_bottom], [member anchor_left], [member anchor_right] and [member anchor_top]. + If [code]keep_offset[/code] is [code]true[/code], offsets aren't updated after this operation. If [code]push_opposite_anchor[/code] is [code]true[/code] and the opposite anchor overlaps this anchor, the opposite one will have its value overridden. For example, when setting left anchor to 1 and the right anchor has value of 0.5, the right anchor will also get value of 1. If [code]push_opposite_anchor[/code] was [code]false[/code], the left anchor would get value 0.5. - + - + @@ -771,10 +771,10 @@ - Works the same as [method set_anchor], but instead of [code]keep_margin[/code] argument and automatic update of margin, it allows to set the margin offset yourself (see [method set_margin]). + Works the same as [method set_anchor], but instead of [code]keep_offset[/code] argument and automatic update of offset, it allows to set the offset yourself (see [method set_offset]). - + @@ -784,7 +784,7 @@ - Sets both anchor preset and margin preset. See [method set_anchors_preset] and [method set_margins_preset]. + Sets both anchor preset and offset preset. See [method set_anchors_preset] and [method set_offsets_preset]. @@ -792,11 +792,11 @@ - + Sets the anchors to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is code equivalent of using the Layout menu in 2D editor. - If [code]keep_margins[/code] is [code]true[/code], control's position will also be updated. + If [code]keep_offsets[/code] is [code]true[/code], control's position will also be updated. @@ -805,7 +805,7 @@ - Sets [member margin_left] and [member margin_top] at the same time. Equivalent of changing [member rect_position]. + Sets [member offset_left] and [member offset_top] at the same time. Equivalent of changing [member rect_position]. @@ -917,18 +917,18 @@ - Sets [member margin_right] and [member margin_bottom] at the same time. + Sets [member offset_right] and [member offset_bottom] at the same time. - + - Sets the anchor identified by [code]margin[/code] constant from [enum Margin] enum to [Control] at [code]neighbor[/code] node path. A setter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top]. + Sets the anchor for the specified [enum Side] to the [Control] at [code]neighbor[/code] node path. A setter method for [member focus_neighbor_bottom], [member focus_neighbor_left], [member focus_neighbor_right] and [member focus_neighbor_top]. @@ -936,25 +936,25 @@ - + Sets the [member rect_global_position] to given [code]position[/code]. - If [code]keep_margins[/code] is [code]true[/code], control's anchors will be updated instead of margins. + If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets. - + - + - Sets the margin identified by [code]margin[/code] constant from [enum Margin] enum to given [code]offset[/code]. A setter method for [member margin_bottom], [member margin_left], [member margin_right] and [member margin_top]. + Sets the offset for the specified [enum Side] to [code]offset[/code]. A setter method for [member offset_bottom], [member offset_left], [member offset_right] and [member offset_top]. - + @@ -964,7 +964,7 @@ - Sets the margins to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is code equivalent of using the Layout menu in 2D editor. + Sets the offsets to a [code]preset[/code] from [enum Control.LayoutPreset] enum. This is code equivalent of using the Layout menu in 2D editor. Use parameter [code]resize_mode[/code] with constants from [enum Control.LayoutPresetMode] to better determine the resulting size of the [Control]. Constant size will be ignored if used with presets that change size, e.g. [code]PRESET_LEFT_WIDE[/code]. Use parameter [code]margin[/code] to determine the gap between the [Control] and the edges. @@ -974,11 +974,11 @@ - + Sets the [member rect_position] to given [code]position[/code]. - If [code]keep_margins[/code] is [code]true[/code], control's anchors will be updated instead of margins. + If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets. @@ -995,11 +995,11 @@ - + Sets the size (see [member rect_size]). - If [code]keep_margins[/code] is [code]true[/code], control's anchors will be updated instead of margins. + If [code]keep_offsets[/code] is [code]true[/code], control's anchors will be updated instead of offsets. @@ -1014,16 +1014,16 @@ - Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom margin updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. + Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. - Anchors the left edge of the node to the origin, the center or the end of its parent control. It changes how the left margin updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. + Anchors the left edge of the node to the origin, the center or the end of its parent control. It changes how the left offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. - Anchors the right edge of the node to the origin, the center or the end of its parent control. It changes how the right margin updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. + Anchors the right edge of the node to the origin, the center or the end of its parent control. It changes how the right offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. - Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top margin updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. + Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top offset updates when the node moves or changes size. You can use one of the [enum Anchor] constants for convenience. The focus access mode for the control (None, Click or All). Only one Control can be focused at the same time, and it will receive keyboard signals. @@ -1079,19 +1079,19 @@ Controls layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew). - + Distance between the node's bottom edge and its parent control, based on [member anchor_bottom]. Margins are often controlled by one or multiple parent [Container] nodes, so you should not modify them manually if your node is a direct child of a [Container]. Margins update automatically when you move or resize the node. - + Distance between the node's left edge and its parent control, based on [member anchor_left]. Margins are often controlled by one or multiple parent [Container] nodes, so you should not modify them manually if your node is a direct child of a [Container]. Margins update automatically when you move or resize the node. - + Distance between the node's right edge and its parent control, based on [member anchor_right]. Margins are often controlled by one or multiple parent [Container] nodes, so you should not modify them manually if your node is a direct child of a [Container]. Margins update automatically when you move or resize the node. - + Distance between the node's top edge and its parent control, based on [member anchor_top]. Margins are often controlled by one or multiple parent [Container] nodes, so you should not modify them manually if your node is a direct child of a [Container]. Margins update automatically when you move or resize the node. @@ -1305,16 +1305,16 @@ Snap all 4 anchors to the center of the parent control's bounds. Use with [method set_anchors_preset]. - Snap all 4 anchors to the left edge of the parent control. The left margin becomes relative to the left edge and the top margin relative to the top left corner of the node's parent. Use with [method set_anchors_preset]. + Snap all 4 anchors to the left edge of the parent control. The left offset becomes relative to the left edge and the top offset relative to the top left corner of the node's parent. Use with [method set_anchors_preset]. - Snap all 4 anchors to the top edge of the parent control. The left margin becomes relative to the top left corner, the top margin relative to the top edge, and the right margin relative to the top right corner of the node's parent. Use with [method set_anchors_preset]. + Snap all 4 anchors to the top edge of the parent control. The left offset becomes relative to the top left corner, the top offset relative to the top edge, and the right offset relative to the top right corner of the node's parent. Use with [method set_anchors_preset]. - Snap all 4 anchors to the right edge of the parent control. The right margin becomes relative to the right edge and the top margin relative to the top right corner of the node's parent. Use with [method set_anchors_preset]. + Snap all 4 anchors to the right edge of the parent control. The right offset becomes relative to the right edge and the top offset relative to the top right corner of the node's parent. Use with [method set_anchors_preset]. - Snap all 4 anchors to the bottom edge of the parent control. The left margin becomes relative to the bottom left corner, the bottom margin relative to the bottom edge, and the right margin relative to the bottom right corner of the node's parent. Use with [method set_anchors_preset]. + Snap all 4 anchors to the bottom edge of the parent control. The left offset becomes relative to the bottom left corner, the bottom offset relative to the bottom edge, and the right offset relative to the bottom right corner of the node's parent. Use with [method set_anchors_preset]. Snap all 4 anchors to a vertical line that cuts the parent control in half. Use with [method set_anchors_preset]. @@ -1323,7 +1323,7 @@ Snap all 4 anchors to a horizontal line that cuts the parent control in half. Use with [method set_anchors_preset]. - Snap all 4 anchors to the respective corners of the parent control. Set all 4 margins to 0 after you applied this preset and the [Control] will fit its parent control. This is equivalent to the "Full Rect" layout option in the editor. Use with [method set_anchors_preset]. + Snap all 4 anchors to the respective corners of the parent control. Set all 4 offsets to 0 after you applied this preset and the [Control] will fit its parent control. This is equivalent to the "Full Rect" layout option in the editor. Use with [method set_anchors_preset]. The control will be resized to its minimum size. diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index 632d138932..4b0ea4dcb1 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -215,13 +215,13 @@ Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead. - - The offset of the GraphNode, relative to the scroll offset of the [GraphEdit]. - [b]Note:[/b] You cannot use position directly, as [GraphEdit] is a [Container]. - Sets the overlay shown above the GraphNode. See [enum Overlay]. + + The offset of the GraphNode, relative to the scroll offset of the [GraphEdit]. + [b]Note:[/b] You cannot use position offset directly, as [GraphEdit] is a [Container]. + If [code]true[/code], the user can resize the GraphNode. [b]Note:[/b] Dragging the handle will only emit the [signal resize_request] signal, the GraphNode needs to be resized manually. @@ -255,7 +255,7 @@ Emitted when the GraphNode is dragged. - + Emitted when the GraphNode is moved. diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml index b2e0442be8..f4b9d75e91 100644 --- a/doc/classes/NinePatchRect.xml +++ b/doc/classes/NinePatchRect.xml @@ -12,21 +12,21 @@ - + - Returns the size of the margin identified by the given [enum Margin] constant. + Returns the size of the margin on the specified [enum Side]. - + - Sets the size of the margin identified by the given [enum Margin] constant to [code]value[/code] in pixels. + Sets the size of the margin on the specified [enum Side] to [code]value[/code] pixels. diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index 5682e12b63..8feeb91b97 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -133,12 +133,12 @@ - + - Returns a copy of the [Rect2] grown a given amount of units towards the [enum Margin] direction. + Returns a copy of the [Rect2] grown a given amount of units on the specified [enum Side]. diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml index ef12c8de1e..80f2a87f31 100644 --- a/doc/classes/Rect2i.xml +++ b/doc/classes/Rect2i.xml @@ -131,12 +131,12 @@ - + - Returns a copy of the [Rect2i] grown a given amount of units towards the [enum Margin] direction. + Returns a copy of the [Rect2i] grown a given amount of units on the specified [enum Side]. diff --git a/doc/classes/StyleBox.xml b/doc/classes/StyleBox.xml index 04f8eb9d13..525dba0549 100644 --- a/doc/classes/StyleBox.xml +++ b/doc/classes/StyleBox.xml @@ -39,19 +39,19 @@ - + - Returns the default value of the specified [enum Margin]. + Returns the default margin of the specified [enum Side]. - + - Returns the content margin offset for the specified [enum Margin]. + Returns the content margin offset for the specified [enum Side]. Positive values reduce size inwards, unlike [Control]'s margin values. @@ -72,12 +72,12 @@ - + - Sets the default value of the specified [enum Margin] to given [code]offset[/code] in pixels. + Sets the default value of the specified [enum Side] to [code]offset[/code] pixels. diff --git a/doc/classes/StyleBoxFlat.xml b/doc/classes/StyleBoxFlat.xml index d6e737b076..71f227dfb0 100644 --- a/doc/classes/StyleBoxFlat.xml +++ b/doc/classes/StyleBoxFlat.xml @@ -27,10 +27,10 @@ - + - Returns the given [code]margin[/code]'s border width. See [enum Margin] for possible values. + Returns the specified [enum Side]'s border width. @@ -52,21 +52,21 @@ - + - Returns the size of the given [code]margin[/code]'s expand margin. See [enum Margin] for possible values. + Returns the size of the specified [enum Side]'s expand margin. - + - Sets the border width to [code]width[/code] pixels for the given [code]margin[/code]. See [enum Margin] for possible values. + Sets the specified [enum Side]'s border width to [code]width[/code] pixels. @@ -75,7 +75,7 @@ - Sets the border width to [code]width[/code] pixels for all margins. + Sets the border width to [code]width[/code] pixels for all sides. @@ -116,12 +116,12 @@ - + - Sets the expand margin to [code]size[/code] pixels for the given [code]margin[/code]. See [enum Margin] for possible values. + Sets the expand margin to [code]size[/code] pixels for the specified [enum Side]. diff --git a/doc/classes/StyleBoxTexture.xml b/doc/classes/StyleBoxTexture.xml index 6f5577b61b..5b17f25978 100644 --- a/doc/classes/StyleBoxTexture.xml +++ b/doc/classes/StyleBoxTexture.xml @@ -12,19 +12,19 @@ - + - Returns the size of the given [code]margin[/code]'s expand margin. See [enum Margin] for possible values. + Returns the expand margin size of the specified [enum Side]. - + - Returns the size of the given [code]margin[/code]. See [enum Margin] for possible values. + Returns the margin size of the specified [enum Side]. @@ -54,23 +54,23 @@ - + - Sets the expand margin to [code]size[/code] pixels for the given [code]margin[/code]. See [enum Margin] for possible values. + Sets the expand margin to [code]size[/code] pixels for the specified [enum Side]. - + - Sets the margin to [code]size[/code] pixels for the given [code]margin[/code]. See [enum Margin] for possible values. + Sets the margin to [code]size[/code] pixels for the specified [enum Side]. diff --git a/doc/classes/TextureProgressBar.xml b/doc/classes/TextureProgressBar.xml index 56a7365855..cfc8f16648 100644 --- a/doc/classes/TextureProgressBar.xml +++ b/doc/classes/TextureProgressBar.xml @@ -12,7 +12,7 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 25ff7f884a..6530e27dcd 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -1164,7 +1164,7 @@ AnimationBezierTrackEdit::AnimationBezierTrackEdit() { play_position = memnew(Control); play_position->set_mouse_filter(MOUSE_FILTER_PASS); add_child(play_position); - play_position->set_anchors_and_margins_preset(PRESET_WIDE); + play_position->set_anchors_and_offsets_preset(PRESET_WIDE); play_position->connect("draw", callable_mp(this, &AnimationBezierTrackEdit::_play_position_draw)); set_focus_mode(FOCUS_CLICK); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index ec411c6415..9b2cc686e3 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1745,7 +1745,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() { play_position = memnew(Control); play_position->set_mouse_filter(MOUSE_FILTER_PASS); add_child(play_position); - play_position->set_anchors_and_margins_preset(PRESET_WIDE); + play_position->set_anchors_and_offsets_preset(PRESET_WIDE); play_position->connect("draw", callable_mp(this, &AnimationTimelineEdit::_play_position_draw)); add_track = memnew(MenuButton); @@ -2720,7 +2720,7 @@ void AnimationTrackEdit::_gui_input(const Ref &p_event) { add_child(path_popup); path = memnew(LineEdit); path_popup->add_child(path); - path->set_anchors_and_margins_preset(PRESET_WIDE); + path->set_anchors_and_offsets_preset(PRESET_WIDE); path->connect("text_entered", callable_mp(this, &AnimationTrackEdit::_path_entered)); } @@ -2973,7 +2973,7 @@ AnimationTrackEdit::AnimationTrackEdit() { play_position = memnew(Control); play_position->set_mouse_filter(MOUSE_FILTER_PASS); add_child(play_position); - play_position->set_anchors_and_margins_preset(PRESET_WIDE); + play_position->set_anchors_and_offsets_preset(PRESET_WIDE); play_position->connect("draw", callable_mp(this, &AnimationTrackEdit::_play_position_draw)); set_focus_mode(FOCUS_CLICK); set_mouse_filter(MOUSE_FILTER_PASS); //scroll has to work too for selection @@ -5661,7 +5661,7 @@ AnimationTrackEditor::AnimationTrackEditor() { info_message->set_align(Label::ALIGN_CENTER); info_message->set_autowrap(true); info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); - info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + info_message->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); main_panel->add_child(info_message); timeline = memnew(AnimationTimelineEdit); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 3dd0977478..bca2979e72 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -66,10 +66,10 @@ GotoLineDialog::GotoLineDialog() { set_title(TTR("Go to Line")); VBoxContainer *vbc = memnew(VBoxContainer); - vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE); add_child(vbc); Label *l = memnew(Label); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 276df45972..118b8f9f2e 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -55,8 +55,8 @@ EditorDebuggerNode::EditorDebuggerNode() { singleton = this; } - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_RIGHT)); tabs = memnew(TabContainer); tabs->set_tab_align(TabContainer::ALIGN_LEFT); @@ -226,8 +226,8 @@ void EditorDebuggerNode::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->get_tab_count() > 1) { - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_RIGHT)); tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); } diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 44c5f83e9a..2068d42eb7 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -382,7 +382,7 @@ EditorPerformanceProfiler::EditorPerformanceProfiler() { info_message->set_align(Label::ALIGN_CENTER); info_message->set_autowrap(true); info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); - info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + info_message->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); monitor_draw->add_child(info_message); for (int i = 0; i < Performance::MONITOR_MAX; i++) { diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index d81dc05a75..d768f00c3b 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -922,7 +922,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { bus_options = memnew(MenuButton); bus_options->set_shortcut_context(this); bus_options->set_h_size_flags(SIZE_SHRINK_END); - bus_options->set_anchor(MARGIN_RIGHT, 0.0); + bus_options->set_anchor(SIDE_RIGHT, 0.0); bus_options->set_tooltip(TTR("Bus options")); hbc->add_child(bus_options); diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 05bc2edefb..ecb659e7d3 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -876,7 +876,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { no_profile_selected_help = memnew(Label(TTR("Create or import a profile to edit available classes and properties."))); // Add some spacing above the help label. Ref sb = memnew(StyleBoxEmpty); - sb->set_default_margin(MARGIN_TOP, 20 * EDSCALE); + sb->set_default_margin(SIDE_TOP, 20 * EDSCALE); no_profile_selected_help->add_theme_style_override("normal", sb); no_profile_selected_help->set_align(Label::ALIGN_CENTER); no_profile_selected_help->set_v_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 41010b6a86..1592549e0c 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -160,8 +160,8 @@ void EditorHelp::_class_desc_resized() { const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5; Ref class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "RichTextLabel")->duplicate(); - class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin); - class_desc_stylebox->set_default_margin(MARGIN_RIGHT, display_margin); + class_desc_stylebox->set_default_margin(SIDE_LEFT, display_margin); + class_desc_stylebox->set_default_margin(SIDE_RIGHT, display_margin); class_desc->add_theme_style_override("normal", class_desc_stylebox); } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index dd136c046f..a36b5f5a6a 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -220,7 +220,7 @@ void EditorProperty::_notification(int p_what) { Size2 size = get_size(); if (bottom_editor) { - size.height = bottom_editor->get_margin(MARGIN_TOP); + size.height = bottom_editor->get_offset(SIDE_TOP); } else if (label_reference) { size.height = label_reference->get_size().height; } diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index c50fe81217..74f45fa628 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -100,24 +100,24 @@ void EditorLayoutsDialog::_post_popup() { EditorLayoutsDialog::EditorLayoutsDialog() { makevb = memnew(VBoxContainer); add_child(makevb); - makevb->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5); - makevb->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5); + makevb->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5); + makevb->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5); layout_names = memnew(ItemList); makevb->add_child(layout_names); layout_names->set_visible(true); - layout_names->set_margin(MARGIN_TOP, 5); - layout_names->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5); - layout_names->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5); + layout_names->set_offset(SIDE_TOP, 5); + layout_names->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5); + layout_names->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5); layout_names->set_v_size_flags(Control::SIZE_EXPAND_FILL); layout_names->set_select_mode(ItemList::SELECT_MULTI); layout_names->set_allow_rmb_select(true); name = memnew(LineEdit); makevb->add_child(name); - name->set_margin(MARGIN_TOP, 5); - name->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5); - name->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5); + name->set_offset(SIDE_TOP, 5); + name->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5); + name->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5); name->connect("gui_input", callable_mp(this, &EditorLayoutsDialog::_line_gui_input)); name->connect("focus_entered", callable_mp(layout_names, &ItemList::unselect_all)); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 970b61af0c..52cf54350f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4018,16 +4018,16 @@ void EditorNode::_dock_make_float() { window->set_title(dock->get_name()); Panel *p = memnew(Panel); p->set_mode(Panel::MODE_FOREGROUND); - p->set_anchors_and_margins_preset(Control::PRESET_WIDE); + p->set_anchors_and_offsets_preset(Control::PRESET_WIDE); window->add_child(p); MarginContainer *margin = memnew(MarginContainer); - margin->set_anchors_and_margins_preset(Control::PRESET_WIDE); + margin->set_anchors_and_offsets_preset(Control::PRESET_WIDE); margin->add_theme_constant_override("margin_right", borders.width); margin->add_theme_constant_override("margin_top", borders.height); margin->add_theme_constant_override("margin_left", borders.width); margin->add_theme_constant_override("margin_bottom", borders.height); window->add_child(margin); - dock->set_anchors_and_margins_preset(Control::PRESET_WIDE); + dock->set_anchors_and_offsets_preset(Control::PRESET_WIDE); margin->add_child(dock); window->set_wrap_controls(true); window->set_size(dock_size); @@ -5795,11 +5795,11 @@ EditorNode::EditorNode() { theme_base = memnew(Control); add_child(theme_base); - theme_base->set_anchors_and_margins_preset(Control::PRESET_WIDE); + theme_base->set_anchors_and_offsets_preset(Control::PRESET_WIDE); gui_base = memnew(Panel); theme_base->add_child(gui_base); - gui_base->set_anchors_and_margins_preset(Control::PRESET_WIDE); + gui_base->set_anchors_and_offsets_preset(Control::PRESET_WIDE); theme_base->set_theme(theme); gui_base->set_theme(theme); @@ -5811,13 +5811,13 @@ EditorNode::EditorNode() { gui_base->add_child(progress_dialog); // take up all screen - gui_base->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END); - gui_base->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END); + gui_base->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); + gui_base->set_anchor(SIDE_BOTTOM, Control::ANCHOR_END); gui_base->set_end(Point2(0, 0)); main_vbox = memnew(VBoxContainer); gui_base->add_child(main_vbox); - main_vbox->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 8); + main_vbox->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 8); main_vbox->add_theme_constant_override("separation", 8 * EDSCALE); menu_hb = memnew(HBoxContainer); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 523e65babe..f432d52bf6 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2590,7 +2590,7 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Refset_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_theme_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_theme_constant("hseparation", "Button")); + preview->set_offset(SIDE_LEFT, assign->get_icon()->get_width() + assign->get_theme_stylebox("normal")->get_default_margin(SIDE_LEFT) + get_theme_constant("hseparation", "Button")); if (type == "GradientTexture") { preview->set_stretch_mode(TextureRect::STRETCH_SCALE); assign->set_custom_minimum_size(Size2(1, 1)); @@ -3167,10 +3167,10 @@ EditorPropertyResource::EditorPropertyResource() { preview = memnew(TextureRect); preview->set_expand(true); - preview->set_anchors_and_margins_preset(PRESET_WIDE); - preview->set_margin(MARGIN_TOP, 1); - preview->set_margin(MARGIN_BOTTOM, -1); - preview->set_margin(MARGIN_RIGHT, -1); + preview->set_anchors_and_offsets_preset(PRESET_WIDE); + preview->set_offset(SIDE_TOP, 1); + preview->set_offset(SIDE_BOTTOM, -1); + preview->set_offset(SIDE_RIGHT, -1); assign->add_child(preview); assign->connect("gui_input", callable_mp(this, &EditorPropertyResource::_button_input)); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 56fbfbd0c2..c2c309fc32 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -975,7 +975,7 @@ void EditorPropertyDictionary::update_property() { Ref flat; flat.instance(); for (int j = 0; j < 4; j++) { - flat->set_default_margin(Margin(j), 2 * EDSCALE); + flat->set_default_margin(Side(j), 2 * EDSCALE); } flat->set_bg_color(get_theme_color("prop_subsection", "Editor")); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index d72510d40d..4a37d26a26 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -202,7 +202,7 @@ void EditorSpinSlider::_notification(int p_what) { // EditorSpinSliders with a label have more space on the left, so add an // higher margin to match the location where the text begins. // The margin values below were determined by empirical testing. - stylebox->set_default_margin(MARGIN_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE); + stylebox->set_default_margin(SIDE_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE); value_input->add_theme_style_override("normal", stylebox); } @@ -256,7 +256,7 @@ void EditorSpinSlider::_notification(int p_what) { if (get_step() == 1) { Ref updown2 = get_theme_icon("updown", "SpinBox"); int updown_vofs = (get_size().height - updown2->get_height()) / 2; - updown_offset = get_size().width - sb->get_margin(MARGIN_RIGHT) - updown2->get_width(); + updown_offset = get_size().width - sb->get_margin(SIDE_RIGHT) - updown2->get_width(); Color c(1, 1, 1); if (hover_updown) { c *= Color(1.2, 1.2, 1.2); @@ -500,7 +500,7 @@ EditorSpinSlider::EditorSpinSlider() { value_input = memnew(LineEdit); value_input_popup->add_child(value_input); value_input_popup->set_wrap_controls(true); - value_input->set_anchors_and_margins_preset(PRESET_WIDE); + value_input->set_anchors_and_offsets_preset(PRESET_WIDE); value_input_popup->connect("popup_hide", callable_mp(this, &EditorSpinSlider::_value_input_closed)); value_input->connect("text_entered", callable_mp(this, &EditorSpinSlider::_value_input_entered)); value_input->connect("focus_exited", callable_mp(this, &EditorSpinSlider::_value_focus_exited)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 35de38fad2..7582c2073f 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -44,34 +44,34 @@ static Ref make_stylebox(Ref p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) { Ref style(memnew(StyleBoxTexture)); style->set_texture(p_texture); - style->set_margin_size(MARGIN_LEFT, p_left * EDSCALE); - style->set_margin_size(MARGIN_RIGHT, p_right * EDSCALE); - style->set_margin_size(MARGIN_BOTTOM, p_botton * EDSCALE); - style->set_margin_size(MARGIN_TOP, p_top * EDSCALE); - style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE); - style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE); - style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * EDSCALE); - style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE); + style->set_margin_size(SIDE_LEFT, p_left * EDSCALE); + style->set_margin_size(SIDE_RIGHT, p_right * EDSCALE); + style->set_margin_size(SIDE_BOTTOM, p_botton * EDSCALE); + style->set_margin_size(SIDE_TOP, p_top * EDSCALE); + style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); + style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); + style->set_default_margin(SIDE_BOTTOM, p_margin_botton * EDSCALE); + style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE); style->set_draw_center(p_draw_center); return style; } static Ref make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) { Ref style(memnew(StyleBoxEmpty)); - style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE); - style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE); - style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE); - style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE); + style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); + style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); + style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE); + style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE); return style; } static Ref make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) { Ref style(memnew(StyleBoxFlat)); style->set_bg_color(p_color); - style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE); - style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE); - style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE); - style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE); + style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); + style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); + style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE); + style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE); return style; } @@ -477,10 +477,10 @@ Ref create_editor_theme(const Ref p_theme) { const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing"); Ref style_widget = style_default->duplicate(); - style_widget->set_default_margin(MARGIN_LEFT, (extra_spacing + 6) * EDSCALE); - style_widget->set_default_margin(MARGIN_TOP, (extra_spacing + default_margin_size) * EDSCALE); - style_widget->set_default_margin(MARGIN_RIGHT, (extra_spacing + 6) * EDSCALE); - style_widget->set_default_margin(MARGIN_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE); + style_widget->set_default_margin(SIDE_LEFT, (extra_spacing + 6) * EDSCALE); + style_widget->set_default_margin(SIDE_TOP, (extra_spacing + default_margin_size) * EDSCALE); + style_widget->set_default_margin(SIDE_RIGHT, (extra_spacing + 6) * EDSCALE); + style_widget->set_default_margin(SIDE_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE); style_widget->set_bg_color(dark_color_1); style_widget->set_border_color(dark_color_2); @@ -500,10 +500,10 @@ Ref create_editor_theme(const Ref p_theme) { // style for windows, popups, etc.. Ref style_popup = style_default->duplicate(); const int popup_margin_size = default_margin_size * EDSCALE * 2; - style_popup->set_default_margin(MARGIN_LEFT, popup_margin_size); - style_popup->set_default_margin(MARGIN_TOP, popup_margin_size); - style_popup->set_default_margin(MARGIN_RIGHT, popup_margin_size); - style_popup->set_default_margin(MARGIN_BOTTOM, popup_margin_size); + style_popup->set_default_margin(SIDE_LEFT, popup_margin_size); + style_popup->set_default_margin(SIDE_TOP, popup_margin_size); + style_popup->set_default_margin(SIDE_RIGHT, popup_margin_size); + style_popup->set_default_margin(SIDE_BOTTOM, popup_margin_size); style_popup->set_border_color(contrast_color_1); style_popup->set_border_width_all(MAX(EDSCALE, border_width)); const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1); @@ -536,13 +536,13 @@ Ref create_editor_theme(const Ref p_theme) { Ref style_tab_selected = style_widget->duplicate(); style_tab_selected->set_border_width_all(border_width); - style_tab_selected->set_border_width(MARGIN_BOTTOM, 0); + style_tab_selected->set_border_width(SIDE_BOTTOM, 0); style_tab_selected->set_border_color(dark_color_3); - style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width); - style_tab_selected->set_default_margin(MARGIN_LEFT, tab_default_margin_side); - style_tab_selected->set_default_margin(MARGIN_RIGHT, tab_default_margin_side); - style_tab_selected->set_default_margin(MARGIN_BOTTOM, tab_default_margin_vertical); - style_tab_selected->set_default_margin(MARGIN_TOP, tab_default_margin_vertical); + style_tab_selected->set_expand_margin_size(SIDE_BOTTOM, border_width); + style_tab_selected->set_default_margin(SIDE_LEFT, tab_default_margin_side); + style_tab_selected->set_default_margin(SIDE_RIGHT, tab_default_margin_side); + style_tab_selected->set_default_margin(SIDE_BOTTOM, tab_default_margin_vertical); + style_tab_selected->set_default_margin(SIDE_TOP, tab_default_margin_vertical); style_tab_selected->set_bg_color(tab_color); Ref style_tab_unselected = style_tab_selected->duplicate(); @@ -580,7 +580,7 @@ Ref create_editor_theme(const Ref p_theme) { Ref style_menu_hover_border = style_widget->duplicate(); style_menu_hover_border->set_draw_center(false); style_menu_hover_border->set_border_width_all(0); - style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width); + style_menu_hover_border->set_border_width(SIDE_BOTTOM, border_width); style_menu_hover_border->set_border_color(accent_color); Ref style_menu_hover_bg = style_widget->duplicate(); @@ -668,10 +668,10 @@ Ref create_editor_theme(const Ref p_theme) { // Checkbox Ref sb_checkbox = style_menu->duplicate(); - sb_checkbox->set_default_margin(MARGIN_LEFT, default_margin_size * EDSCALE); - sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE); - sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE); - sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(SIDE_LEFT, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(SIDE_RIGHT, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE); theme->set_stylebox("normal", "CheckBox", sb_checkbox); theme->set_stylebox("pressed", "CheckBox", sb_checkbox); @@ -697,10 +697,10 @@ Ref create_editor_theme(const Ref p_theme) { // PopupMenu const int popup_menu_margin_size = default_margin_size * 1.5 * EDSCALE; Ref style_popup_menu = style_popup->duplicate(); - style_popup_menu->set_default_margin(MARGIN_LEFT, popup_menu_margin_size); - style_popup_menu->set_default_margin(MARGIN_TOP, popup_menu_margin_size); - style_popup_menu->set_default_margin(MARGIN_RIGHT, popup_menu_margin_size); - style_popup_menu->set_default_margin(MARGIN_BOTTOM, popup_menu_margin_size); + style_popup_menu->set_default_margin(SIDE_LEFT, popup_menu_margin_size); + style_popup_menu->set_default_margin(SIDE_TOP, popup_menu_margin_size); + style_popup_menu->set_default_margin(SIDE_RIGHT, popup_menu_margin_size); + style_popup_menu->set_default_margin(SIDE_BOTTOM, popup_menu_margin_size); theme->set_stylebox("panel", "PopupMenu", style_popup_menu); theme->set_stylebox("separator", "PopupMenu", style_popup_separator); @@ -724,9 +724,9 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE); Ref sub_inspector_bg = make_flat_stylebox(dark_color_1.lerp(accent_color, 0.08), 2, 0, 2, 2); - sub_inspector_bg->set_border_width(MARGIN_LEFT, 2); - sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2); - sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2); + sub_inspector_bg->set_border_width(SIDE_LEFT, 2); + sub_inspector_bg->set_border_width(SIDE_RIGHT, 2); + sub_inspector_bg->set_border_width(SIDE_BOTTOM, 2); sub_inspector_bg->set_border_color(accent_color * Color(1, 1, 1, 0.3)); sub_inspector_bg->set_draw_center(true); @@ -866,17 +866,17 @@ Ref create_editor_theme(const Ref p_theme) { style_content_panel->set_border_color(dark_color_3); style_content_panel->set_border_width_all(border_width); // compensate the border - style_content_panel->set_default_margin(MARGIN_TOP, margin_size_extra * EDSCALE); - style_content_panel->set_default_margin(MARGIN_RIGHT, margin_size_extra * EDSCALE); - style_content_panel->set_default_margin(MARGIN_BOTTOM, margin_size_extra * EDSCALE); - style_content_panel->set_default_margin(MARGIN_LEFT, margin_size_extra * EDSCALE); + style_content_panel->set_default_margin(SIDE_TOP, 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); // this is the stylebox used in 3d and 2d viewports (no borders) Ref style_content_panel_vp = style_content_panel->duplicate(); - style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width * 2); - style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE); - style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width * 2); - style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width * 2); + style_content_panel_vp->set_default_margin(SIDE_LEFT, border_width * 2); + style_content_panel_vp->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE); + style_content_panel_vp->set_default_margin(SIDE_RIGHT, border_width * 2); + style_content_panel_vp->set_default_margin(SIDE_BOTTOM, border_width * 2); theme->set_stylebox("panel", "TabContainer", style_content_panel); theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); @@ -887,13 +887,13 @@ Ref create_editor_theme(const Ref p_theme) { // Debugger Ref style_panel_debugger = style_content_panel->duplicate(); - style_panel_debugger->set_border_width(MARGIN_BOTTOM, 0); + style_panel_debugger->set_border_width(SIDE_BOTTOM, 0); theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger); Ref style_panel_invisible_top = style_content_panel->duplicate(); - int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height(theme->get_font_size("tab_fg", "TabContainer")) + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(MARGIN_TOP); - style_panel_invisible_top->set_expand_margin_size(MARGIN_TOP, -stylebox_offset); - style_panel_invisible_top->set_default_margin(MARGIN_TOP, 0); + int stylebox_offset = theme->get_font("tab_fg", "TabContainer")->get_height(theme->get_font_size("tab_fg", "TabContainer")) + theme->get_stylebox("tab_fg", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(SIDE_TOP); + style_panel_invisible_top->set_expand_margin_size(SIDE_TOP, -stylebox_offset); + style_panel_invisible_top->set_default_margin(SIDE_TOP, 0); theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top); // LineEdit @@ -958,8 +958,8 @@ Ref create_editor_theme(const Ref p_theme) { // WindowDialog Ref style_window = style_popup->duplicate(); style_window->set_border_color(tab_color); - style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE); - style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE); + style_window->set_border_width(SIDE_TOP, 24 * EDSCALE); + style_window->set_expand_margin_size(SIDE_TOP, 24 * EDSCALE); theme->set_stylebox("panel", "Window", style_default); theme->set_stylebox("panel_window", "Window", style_window); @@ -1055,10 +1055,10 @@ Ref create_editor_theme(const Ref p_theme) { // TooltipPanel Ref style_tooltip = style_popup->duplicate(); float v = MAX(border_size * EDSCALE, 1.0); - style_tooltip->set_default_margin(MARGIN_LEFT, v); - style_tooltip->set_default_margin(MARGIN_TOP, v); - style_tooltip->set_default_margin(MARGIN_RIGHT, v); - style_tooltip->set_default_margin(MARGIN_BOTTOM, v); + style_tooltip->set_default_margin(SIDE_LEFT, v); + style_tooltip->set_default_margin(SIDE_TOP, v); + style_tooltip->set_default_margin(SIDE_RIGHT, v); + style_tooltip->set_default_margin(SIDE_BOTTOM, v); style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9)); style_tooltip->set_border_width_all(border_width); style_tooltip->set_border_color(mono_color); @@ -1155,10 +1155,10 @@ Ref create_editor_theme(const Ref p_theme) { smgraphsbselected->set_shadow_color(shadow_color); if (use_gn_headers) { - graphsb->set_border_width(MARGIN_TOP, 24 * EDSCALE); - graphsbselected->set_border_width(MARGIN_TOP, 24 * EDSCALE); - graphsbcomment->set_border_width(MARGIN_TOP, 24 * EDSCALE); - graphsbcommentselected->set_border_width(MARGIN_TOP, 24 * EDSCALE); + graphsb->set_border_width(SIDE_TOP, 24 * EDSCALE); + graphsbselected->set_border_width(SIDE_TOP, 24 * EDSCALE); + graphsbcomment->set_border_width(SIDE_TOP, 24 * EDSCALE); + graphsbcommentselected->set_border_width(SIDE_TOP, 24 * EDSCALE); } theme->set_stylebox("frame", "GraphNode", graphsb); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 076b873eac..e8588bbed5 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -294,10 +294,10 @@ FindInFilesDialog::FindInFilesDialog() { set_title(TTR("Find in Files")); VBoxContainer *vbc = memnew(VBoxContainer); - vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE); add_child(vbc); GridContainer *gc = memnew(GridContainer); @@ -551,10 +551,10 @@ FindInFilesPanel::FindInFilesPanel() { add_child(_finder); VBoxContainer *vbc = memnew(VBoxContainer); - vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0); - vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0); - vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); - vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); + vbc->set_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, 0); + vbc->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 0); + vbc->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); + vbc->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); add_child(vbc); { diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 32c50321d7..1eaf7d70b7 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -413,7 +413,7 @@ GroupDialog::GroupDialog() { VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); - vbc->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + vbc->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); HBoxContainer *hbc = memnew(HBoxContainer); vbc->add_child(hbc); @@ -534,7 +534,7 @@ GroupDialog::GroupDialog() { group_empty->set_autowrap(true); group_empty->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); nodes_to_remove->add_child(group_empty); - group_empty->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + group_empty->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); set_title(TTR("Group Editor")); diff --git a/editor/input_map_editor.cpp b/editor/input_map_editor.cpp index 83adccb752..249b9770b1 100644 --- a/editor/input_map_editor.cpp +++ b/editor/input_map_editor.cpp @@ -921,10 +921,10 @@ InputMapEditor::InputMapEditor() { inputmap_changed = "inputmap_changed"; VBoxContainer *vbc = memnew(VBoxContainer); - vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 0); - vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, 0); - vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 0); - vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, 0); + vbc->set_anchor_and_offset(SIDE_TOP, Control::ANCHOR_BEGIN, 0); + vbc->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_END, 0); + vbc->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 0); + vbc->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, 0); add_child(vbc); HBoxContainer *hbc = memnew(HBoxContainer); @@ -986,10 +986,10 @@ InputMapEditor::InputMapEditor() { l = memnew(Label); l->set_text(TTR("Press a Key...")); - l->set_anchors_and_margins_preset(Control::PRESET_WIDE); + l->set_anchors_and_offsets_preset(Control::PRESET_WIDE); l->set_align(Label::ALIGN_CENTER); - l->set_margin(MARGIN_TOP, 20); - l->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 30); + l->set_offset(SIDE_TOP, 20); + l->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_BEGIN, 30); press_a_key->add_child(l); press_a_key_label = l; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 38648b5f0a..a20bbd2b62 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -127,7 +127,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { Ref agnode = blend_tree->get_node(E->get()); - node->set_offset(blend_tree->get_node_position(E->get()) * EDSCALE); + node->set_position_offset(blend_tree->get_node_position(E->get()) * EDSCALE); node->set_title(agnode->get_caption()); node->set_name(E->get()); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index c59e056f4f..6fa1792c67 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -1291,18 +1291,18 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { state_machine_play_pos = memnew(Control); state_machine_draw->add_child(state_machine_play_pos); state_machine_play_pos->set_mouse_filter(MOUSE_FILTER_PASS); //pass all to parent - state_machine_play_pos->set_anchors_and_margins_preset(PRESET_WIDE); + state_machine_play_pos->set_anchors_and_offsets_preset(PRESET_WIDE); state_machine_play_pos->connect("draw", callable_mp(this, &AnimationNodeStateMachineEditor::_state_machine_pos_draw)); v_scroll = memnew(VScrollBar); state_machine_draw->add_child(v_scroll); - v_scroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE); + v_scroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); v_scroll->connect("value_changed", callable_mp(this, &AnimationNodeStateMachineEditor::_scroll_changed)); h_scroll = memnew(HScrollBar); state_machine_draw->add_child(h_scroll); - h_scroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); - h_scroll->set_margin(MARGIN_RIGHT, -v_scroll->get_size().x * EDSCALE); + h_scroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); + h_scroll->set_offset(SIDE_RIGHT, -v_scroll->get_size().x * EDSCALE); h_scroll->connect("value_changed", callable_mp(this, &AnimationNodeStateMachineEditor::_scroll_changed)); error_panel = memnew(PanelContainer); @@ -1328,7 +1328,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { add_child(name_edit_popup); name_edit = memnew(LineEdit); name_edit_popup->add_child(name_edit); - name_edit->set_anchors_and_margins_preset(PRESET_WIDE); + name_edit->set_anchors_and_offsets_preset(PRESET_WIDE); name_edit->connect("text_entered", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited)); name_edit->connect("focus_exited", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited_focus_out)); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index ba798a7826..bd70e649e6 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -87,10 +87,10 @@ void EditorAssetLibraryItem::_bind_methods() { EditorAssetLibraryItem::EditorAssetLibraryItem() { Ref border; border.instance(); - border->set_default_margin(MARGIN_LEFT, 5 * EDSCALE); - border->set_default_margin(MARGIN_RIGHT, 5 * EDSCALE); - border->set_default_margin(MARGIN_BOTTOM, 5 * EDSCALE); - border->set_default_margin(MARGIN_TOP, 5 * EDSCALE); + border->set_default_margin(SIDE_LEFT, 5 * EDSCALE); + border->set_default_margin(SIDE_RIGHT, 5 * EDSCALE); + border->set_default_margin(SIDE_BOTTOM, 5 * EDSCALE); + border->set_default_margin(SIDE_TOP, 5 * EDSCALE); add_theme_style_override("panel", border); HBoxContainer *hb = memnew(HBoxContainer); @@ -1400,10 +1400,10 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { Ref border2; border2.instance(); - border2->set_default_margin(MARGIN_LEFT, 15 * EDSCALE); - border2->set_default_margin(MARGIN_RIGHT, 35 * EDSCALE); - border2->set_default_margin(MARGIN_BOTTOM, 15 * EDSCALE); - border2->set_default_margin(MARGIN_TOP, 15 * EDSCALE); + border2->set_default_margin(SIDE_LEFT, 15 * EDSCALE); + border2->set_default_margin(SIDE_RIGHT, 35 * EDSCALE); + border2->set_default_margin(SIDE_BOTTOM, 15 * EDSCALE); + border2->set_default_margin(SIDE_TOP, 15 * EDSCALE); PanelContainer *library_vb_border = memnew(PanelContainer); library_scroll->add_child(library_vb_border); @@ -1493,7 +1493,7 @@ AssetLibraryEditorPlugin::AssetLibraryEditorPlugin(EditorNode *p_node) { addon_library = memnew(EditorAssetLibrary); addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL); editor->get_viewport()->add_child(addon_library); - addon_library->set_anchors_and_margins_preset(Control::PRESET_WIDE); + addon_library->set_anchors_and_offsets_preset(Control::PRESET_WIDE); addon_library->hide(); } diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 998916349c..5041cf9f32 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -202,7 +202,7 @@ AudioStreamEditor::AudioStreamEditor() { add_child(_player); VBoxContainer *vbox = memnew(VBoxContainer); - vbox->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_MINSIZE, 0); + vbox->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_MINSIZE, 0); add_child(vbox); _preview = memnew(ColorRect); @@ -211,7 +211,7 @@ AudioStreamEditor::AudioStreamEditor() { vbox->add_child(_preview); _indicator = memnew(Control); - _indicator->set_anchors_and_margins_preset(PRESET_WIDE); + _indicator->set_anchors_and_offsets_preset(PRESET_WIDE); _indicator->connect("draw", callable_mp(this, &AudioStreamEditor::_draw_indicator)); _indicator->connect("gui_input", callable_mp(this, &AudioStreamEditor::_on_input_indicator)); _preview->add_child(_indicator); diff --git a/editor/plugins/camera_3d_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp index 48f9f208a5..9a5cfd35cd 100644 --- a/editor/plugins/camera_3d_editor_plugin.cpp +++ b/editor/plugins/camera_3d_editor_plugin.cpp @@ -69,12 +69,12 @@ Camera3DEditor::Camera3DEditor() { preview->set_text(TTR("Preview")); preview->set_toggle_mode(true); - preview->set_anchor(MARGIN_LEFT, Control::ANCHOR_END); - preview->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END); - preview->set_margin(MARGIN_LEFT, -60); - preview->set_margin(MARGIN_RIGHT, 0); - preview->set_margin(MARGIN_TOP, 0); - preview->set_margin(MARGIN_BOTTOM, 10); + preview->set_anchor(SIDE_LEFT, Control::ANCHOR_END); + preview->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); + preview->set_offset(SIDE_LEFT, -60); + preview->set_offset(SIDE_RIGHT, 0); + preview->set_offset(SIDE_TOP, 0); + preview->set_offset(SIDE_BOTTOM, 10); preview->connect("pressed", callable_mp(this, &Camera3DEditor::_pressed)); } @@ -100,12 +100,12 @@ Camera3DEditorPlugin::Camera3DEditorPlugin(EditorNode *p_node) { /* camera_editor = memnew( CameraEditor ); editor->get_viewport()->add_child(camera_editor); - camera_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); - camera_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); - camera_editor->set_margin(MARGIN_LEFT,60); - camera_editor->set_margin(MARGIN_RIGHT,0); - camera_editor->set_margin(MARGIN_TOP,0); - camera_editor->set_margin(MARGIN_BOTTOM,10); + camera_editor->set_anchor(SIDE_LEFT,Control::ANCHOR_END); + camera_editor->set_anchor(SIDE_RIGHT,Control::ANCHOR_END); + camera_editor->set_offset(SIDE_LEFT,60); + camera_editor->set_offset(SIDE_RIGHT,0); + camera_editor->set_offset(SIDE_TOP,0); + camera_editor->set_offset(SIDE_BOTTOM,10); camera_editor->hide(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 2a4cc691c3..4aac18f05f 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -366,8 +366,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig // Self anchors if ((is_snap_active && snap_node_anchors && (p_modes & SNAP_NODE_ANCHORS)) || (p_forced_modes & SNAP_NODE_ANCHORS)) { if (const Control *c = Object::cast_to(p_self_canvas_item)) { - Point2 begin = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(MARGIN_LEFT), c->get_anchor(MARGIN_TOP)))); - Point2 end = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(MARGIN_RIGHT), c->get_anchor(MARGIN_BOTTOM)))); + Point2 begin = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(SIDE_LEFT), c->get_anchor(SIDE_TOP)))); + Point2 end = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(SIDE_RIGHT), c->get_anchor(SIDE_BOTTOM)))); _snap_if_closer_point(p_target, output, snap_target, begin, SNAP_TARGET_SELF_ANCHORS, rotation); _snap_if_closer_point(p_target, output, snap_target, end, SNAP_TARGET_SELF_ANCHORS, rotation); } @@ -1628,10 +1628,10 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref &p_event) { Control *control = Object::cast_to(selection[0]); if (control && _is_node_movable(control)) { Vector2 anchor_pos[4]; - anchor_pos[0] = Vector2(control->get_anchor(MARGIN_LEFT), control->get_anchor(MARGIN_TOP)); - anchor_pos[1] = Vector2(control->get_anchor(MARGIN_RIGHT), control->get_anchor(MARGIN_TOP)); - anchor_pos[2] = Vector2(control->get_anchor(MARGIN_RIGHT), control->get_anchor(MARGIN_BOTTOM)); - anchor_pos[3] = Vector2(control->get_anchor(MARGIN_LEFT), control->get_anchor(MARGIN_BOTTOM)); + anchor_pos[0] = Vector2(control->get_anchor(SIDE_LEFT), control->get_anchor(SIDE_TOP)); + anchor_pos[1] = Vector2(control->get_anchor(SIDE_RIGHT), control->get_anchor(SIDE_TOP)); + anchor_pos[2] = Vector2(control->get_anchor(SIDE_RIGHT), control->get_anchor(SIDE_BOTTOM)); + anchor_pos[3] = Vector2(control->get_anchor(SIDE_LEFT), control->get_anchor(SIDE_BOTTOM)); Rect2 anchor_rects[4]; for (int i = 0; i < 4; i++) { @@ -1681,8 +1681,8 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref &p_event) { Transform2D xform = control->get_global_transform_with_canvas().affine_inverse(); Point2 previous_anchor; - previous_anchor.x = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_BOTTOM_LEFT) ? control->get_anchor(MARGIN_LEFT) : control->get_anchor(MARGIN_RIGHT); - previous_anchor.y = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_TOP_RIGHT) ? control->get_anchor(MARGIN_TOP) : control->get_anchor(MARGIN_BOTTOM); + previous_anchor.x = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_BOTTOM_LEFT) ? control->get_anchor(SIDE_LEFT) : control->get_anchor(SIDE_RIGHT); + previous_anchor.y = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_TOP_RIGHT) ? control->get_anchor(SIDE_TOP) : control->get_anchor(SIDE_BOTTOM); previous_anchor = xform.affine_inverse().xform(_anchor_to_position(control, previous_anchor)); Vector2 new_anchor = xform.xform(snap_point(previous_anchor + (drag_to - drag_from), SNAP_GRID | SNAP_OTHER_NODES, SNAP_NODE_PARENT | SNAP_NODE_SIDES | SNAP_NODE_CENTER, control)); @@ -1695,44 +1695,44 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref &p_event) { switch (drag_type) { case DRAG_ANCHOR_TOP_LEFT: if (!use_single_axis || !use_y) { - control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false); + control->set_anchor(SIDE_LEFT, new_anchor.x, false, false); } if (!use_single_axis || use_y) { - control->set_anchor(MARGIN_TOP, new_anchor.y, false, false); + control->set_anchor(SIDE_TOP, new_anchor.y, false, false); } break; case DRAG_ANCHOR_TOP_RIGHT: if (!use_single_axis || !use_y) { - control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false); + control->set_anchor(SIDE_RIGHT, new_anchor.x, false, false); } if (!use_single_axis || use_y) { - control->set_anchor(MARGIN_TOP, new_anchor.y, false, false); + control->set_anchor(SIDE_TOP, new_anchor.y, false, false); } break; case DRAG_ANCHOR_BOTTOM_RIGHT: if (!use_single_axis || !use_y) { - control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false); + control->set_anchor(SIDE_RIGHT, new_anchor.x, false, false); } if (!use_single_axis || use_y) { - control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false); + control->set_anchor(SIDE_BOTTOM, new_anchor.y, false, false); } break; case DRAG_ANCHOR_BOTTOM_LEFT: if (!use_single_axis || !use_y) { - control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false); + control->set_anchor(SIDE_LEFT, new_anchor.x, false, false); } if (!use_single_axis || use_y) { - control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false); + control->set_anchor(SIDE_BOTTOM, new_anchor.y, false, false); } break; case DRAG_ANCHOR_ALL: if (!use_single_axis || !use_y) { - control->set_anchor(MARGIN_LEFT, new_anchor.x, false, true); - control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, true); + control->set_anchor(SIDE_LEFT, new_anchor.x, false, true); + control->set_anchor(SIDE_RIGHT, new_anchor.x, false, true); } if (!use_single_axis || use_y) { - control->set_anchor(MARGIN_TOP, new_anchor.y, false, true); - control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, true); + control->set_anchor(SIDE_TOP, new_anchor.y, false, true); + control->set_anchor(SIDE_BOTTOM, new_anchor.y, false, true); } break; default: @@ -2780,37 +2780,37 @@ void CanvasItemEditor::_update_cursor() { viewport->set_default_cursor_shape(c); } -void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Margin p_side) { +void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) { Color color = get_theme_color("font_color", "Editor"); color.a = 0.8; Ref font = get_theme_font("font", "Label"); int font_size = get_theme_font_size("font_size", "Label"); Size2 text_size = font->get_string_size(p_string, font_size); switch (p_side) { - case MARGIN_LEFT: + case SIDE_LEFT: p_position += Vector2(-text_size.x - 5, text_size.y / 2); break; - case MARGIN_TOP: + case SIDE_TOP: p_position += Vector2(-text_size.x / 2, -5); break; - case MARGIN_RIGHT: + case SIDE_RIGHT: p_position += Vector2(5, text_size.y / 2); break; - case MARGIN_BOTTOM: + case SIDE_BOTTOM: p_position += Vector2(-text_size.x / 2, text_size.y + 5); break; } viewport->draw_string(font, p_position, p_string, HALIGN_LEFT, -1, font_size, color); } -void CanvasItemEditor::_draw_margin_at_position(int p_value, Point2 p_position, Margin p_side) { +void CanvasItemEditor::_draw_margin_at_position(int p_value, Point2 p_position, Side p_side) { String str = TS->format_number(vformat("%d " + TTR("px"), p_value)); if (p_value != 0) { _draw_text_at_position(p_position, str, p_side); } } -void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_position, Margin p_side) { +void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_position, Side p_side) { String str = TS->format_number(vformat("%.1f ", p_value * 100.0)) + TS->percent_sign(); if (p_value != 0) { _draw_text_at_position(p_position, str, p_side); @@ -3185,10 +3185,10 @@ void CanvasItemEditor::_draw_control_anchors(Control *control) { if (tool == TOOL_SELECT && !Object::cast_to(control->get_parent())) { // Compute the anchors float anchors_values[4]; - anchors_values[0] = control->get_anchor(MARGIN_LEFT); - anchors_values[1] = control->get_anchor(MARGIN_TOP); - anchors_values[2] = control->get_anchor(MARGIN_RIGHT); - anchors_values[3] = control->get_anchor(MARGIN_BOTTOM); + anchors_values[0] = control->get_anchor(SIDE_LEFT); + anchors_values[1] = control->get_anchor(SIDE_TOP); + anchors_values[2] = control->get_anchor(SIDE_RIGHT); + anchors_values[3] = control->get_anchor(SIDE_BOTTOM); Vector2 anchors_pos[4]; for (int i = 0; i < 4; i++) { @@ -3224,10 +3224,10 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { // Compute the anchors float anchors_values[4]; - anchors_values[0] = control->get_anchor(MARGIN_LEFT); - anchors_values[1] = control->get_anchor(MARGIN_TOP); - anchors_values[2] = control->get_anchor(MARGIN_RIGHT); - anchors_values[3] = control->get_anchor(MARGIN_BOTTOM); + anchors_values[0] = control->get_anchor(SIDE_LEFT); + anchors_values[1] = control->get_anchor(SIDE_TOP); + anchors_values[2] = control->get_anchor(SIDE_RIGHT); + anchors_values[3] = control->get_anchor(SIDE_BOTTOM); Vector2 anchors[4]; Vector2 anchors_pos[4]; @@ -3280,19 +3280,19 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { float percent_val; percent_val = anchors_values[(dragged_anchor + 2) % 4] - anchors_values[dragged_anchor]; percent_val = (dragged_anchor >= 2) ? -percent_val : percent_val; - _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 1) % 4]) / 2, (Margin)((dragged_anchor + 1) % 4)); + _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 1) % 4]) / 2, (Side)((dragged_anchor + 1) % 4)); percent_val = anchors_values[(dragged_anchor + 3) % 4] - anchors_values[(dragged_anchor + 1) % 4]; percent_val = ((dragged_anchor + 1) % 4 >= 2) ? -percent_val : percent_val; - _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 3) % 4]) / 2, (Margin)(dragged_anchor)); + _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 3) % 4]) / 2, (Side)(dragged_anchor)); percent_val = anchors_values[(dragged_anchor + 1) % 4]; percent_val = ((dragged_anchor + 1) % 4 >= 2) ? ANCHOR_END - percent_val : percent_val; - _draw_percentage_at_position(percent_val, (line_starts[dragged_anchor] + anchors_pos[dragged_anchor]) / 2, (Margin)(dragged_anchor)); + _draw_percentage_at_position(percent_val, (line_starts[dragged_anchor] + anchors_pos[dragged_anchor]) / 2, (Side)(dragged_anchor)); percent_val = anchors_values[dragged_anchor]; percent_val = (dragged_anchor >= 2) ? ANCHOR_END - percent_val : percent_val; - _draw_percentage_at_position(percent_val, (line_ends[(dragged_anchor + 1) % 4] + anchors_pos[dragged_anchor]) / 2, (Margin)((dragged_anchor + 1) % 4)); + _draw_percentage_at_position(percent_val, (line_ends[(dragged_anchor + 1) % 4] + anchors_pos[dragged_anchor]) / 2, (Side)((dragged_anchor + 1) % 4)); } // Draw the margin values and the node width/height when dragging control side @@ -3302,22 +3302,22 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { Rect2 parent_rect = control->get_parent_anchorable_rect(); - node_pos_in_parent[0] = control->get_anchor(MARGIN_LEFT) * parent_rect.size.width + control->get_margin(MARGIN_LEFT) + parent_rect.position.x; - node_pos_in_parent[1] = control->get_anchor(MARGIN_TOP) * parent_rect.size.height + control->get_margin(MARGIN_TOP) + parent_rect.position.y; - node_pos_in_parent[2] = control->get_anchor(MARGIN_RIGHT) * parent_rect.size.width + control->get_margin(MARGIN_RIGHT) + parent_rect.position.x; - node_pos_in_parent[3] = control->get_anchor(MARGIN_BOTTOM) * parent_rect.size.height + control->get_margin(MARGIN_BOTTOM) + parent_rect.position.y; + node_pos_in_parent[0] = control->get_anchor(SIDE_LEFT) * parent_rect.size.width + control->get_offset(SIDE_LEFT) + parent_rect.position.x; + node_pos_in_parent[1] = control->get_anchor(SIDE_TOP) * parent_rect.size.height + control->get_offset(SIDE_TOP) + parent_rect.position.y; + node_pos_in_parent[2] = control->get_anchor(SIDE_RIGHT) * parent_rect.size.width + control->get_offset(SIDE_RIGHT) + parent_rect.position.x; + node_pos_in_parent[3] = control->get_anchor(SIDE_BOTTOM) * parent_rect.size.height + control->get_offset(SIDE_BOTTOM) + parent_rect.position.y; Point2 start, end; switch (drag_type) { case DRAG_LEFT: case DRAG_TOP_LEFT: case DRAG_BOTTOM_LEFT: - _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM); + _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), SIDE_BOTTOM); [[fallthrough]]; case DRAG_MOVE: start = Vector2(node_pos_in_parent[0], Math::lerp(node_pos_in_parent[1], node_pos_in_parent[3], ratio)); - end = start - Vector2(control->get_margin(MARGIN_LEFT), 0); - _draw_margin_at_position(control->get_margin(MARGIN_LEFT), parent_transform.xform((start + end) / 2), MARGIN_TOP); + end = start - Vector2(control->get_offset(SIDE_LEFT), 0); + _draw_margin_at_position(control->get_offset(SIDE_LEFT), parent_transform.xform((start + end) / 2), SIDE_TOP); viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE)); break; default: @@ -3327,12 +3327,12 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { case DRAG_RIGHT: case DRAG_TOP_RIGHT: case DRAG_BOTTOM_RIGHT: - _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM); + _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), SIDE_BOTTOM); [[fallthrough]]; case DRAG_MOVE: start = Vector2(node_pos_in_parent[2], Math::lerp(node_pos_in_parent[3], node_pos_in_parent[1], ratio)); - end = start - Vector2(control->get_margin(MARGIN_RIGHT), 0); - _draw_margin_at_position(control->get_margin(MARGIN_RIGHT), parent_transform.xform((start + end) / 2), MARGIN_BOTTOM); + end = start - Vector2(control->get_offset(SIDE_RIGHT), 0); + _draw_margin_at_position(control->get_offset(SIDE_RIGHT), parent_transform.xform((start + end) / 2), SIDE_BOTTOM); viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE)); break; default: @@ -3342,12 +3342,12 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { case DRAG_TOP: case DRAG_TOP_LEFT: case DRAG_TOP_RIGHT: - _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), MARGIN_RIGHT); + _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), SIDE_RIGHT); [[fallthrough]]; case DRAG_MOVE: start = Vector2(Math::lerp(node_pos_in_parent[0], node_pos_in_parent[2], ratio), node_pos_in_parent[1]); - end = start - Vector2(0, control->get_margin(MARGIN_TOP)); - _draw_margin_at_position(control->get_margin(MARGIN_TOP), parent_transform.xform((start + end) / 2), MARGIN_LEFT); + end = start - Vector2(0, control->get_offset(SIDE_TOP)); + _draw_margin_at_position(control->get_offset(SIDE_TOP), parent_transform.xform((start + end) / 2), SIDE_LEFT); viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE)); break; default: @@ -3357,12 +3357,12 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { case DRAG_BOTTOM: case DRAG_BOTTOM_LEFT: case DRAG_BOTTOM_RIGHT: - _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), MARGIN_RIGHT); + _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), SIDE_RIGHT); [[fallthrough]]; case DRAG_MOVE: start = Vector2(Math::lerp(node_pos_in_parent[2], node_pos_in_parent[0], ratio), node_pos_in_parent[3]); - end = start - Vector2(0, control->get_margin(MARGIN_BOTTOM)); - _draw_margin_at_position(control->get_margin(MARGIN_BOTTOM), parent_transform.xform((start + end) / 2), MARGIN_RIGHT); + end = start - Vector2(0, control->get_offset(SIDE_BOTTOM)); + _draw_margin_at_position(control->get_offset(SIDE_BOTTOM), parent_transform.xform((start + end) / 2), SIDE_RIGHT); viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE)); break; default: @@ -3941,7 +3941,7 @@ void CanvasItemEditor::_draw_viewport() { group_button->set_disabled(selection.empty()); ungroup_button->set_visible(all_group); - info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); + info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); _draw_grid(); _draw_ruler_tool(); @@ -4019,17 +4019,17 @@ void CanvasItemEditor::_notification(int p_what) { Vector2 pivot; pivot = control->get_pivot_offset(); - anchors[MARGIN_LEFT] = control->get_anchor(MARGIN_LEFT); - anchors[MARGIN_RIGHT] = control->get_anchor(MARGIN_RIGHT); - anchors[MARGIN_TOP] = control->get_anchor(MARGIN_TOP); - anchors[MARGIN_BOTTOM] = control->get_anchor(MARGIN_BOTTOM); + anchors[SIDE_LEFT] = control->get_anchor(SIDE_LEFT); + anchors[SIDE_RIGHT] = control->get_anchor(SIDE_RIGHT); + anchors[SIDE_TOP] = control->get_anchor(SIDE_TOP); + anchors[SIDE_BOTTOM] = control->get_anchor(SIDE_BOTTOM); - if (pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) { + if (pivot != se->prev_pivot || anchors[SIDE_LEFT] != se->prev_anchors[SIDE_LEFT] || anchors[SIDE_RIGHT] != se->prev_anchors[SIDE_RIGHT] || anchors[SIDE_TOP] != se->prev_anchors[SIDE_TOP] || anchors[SIDE_BOTTOM] != se->prev_anchors[SIDE_BOTTOM]) { se->prev_pivot = pivot; - se->prev_anchors[MARGIN_LEFT] = anchors[MARGIN_LEFT]; - se->prev_anchors[MARGIN_RIGHT] = anchors[MARGIN_RIGHT]; - se->prev_anchors[MARGIN_TOP] = anchors[MARGIN_TOP]; - se->prev_anchors[MARGIN_BOTTOM] = anchors[MARGIN_BOTTOM]; + se->prev_anchors[SIDE_LEFT] = anchors[SIDE_LEFT]; + se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT]; + se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP]; + se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM]; viewport->update(); } nb_control++; @@ -4100,8 +4100,8 @@ void CanvasItemEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); for (int i = 0; i < 4; i++) { - select_sb->set_margin_size(Margin(i), 4); - select_sb->set_default_margin(Margin(i), 4); + select_sb->set_margin_size(Side(i), 4); + select_sb->set_default_margin(Side(i), 4); } AnimationPlayerEditor::singleton->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed)); @@ -4158,26 +4158,26 @@ void CanvasItemEditor::_notification(int p_what) { PopupMenu *p = presets_menu->get_popup(); p->clear(); - p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_MARGINS_PRESET_TOP_LEFT); - p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT); + p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT); + p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT); + p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT); + p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT); - p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_MARGINS_PRESET_CENTER_TOP); - p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM); - p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_MARGINS_PRESET_CENTER); + p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT); + p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP); + p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT); + p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM); + p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_OFFSETS_PRESET_CENTER); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_MARGINS_PRESET_TOP_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE); - p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE); - p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE); + p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE); + p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_MARGINS_PRESET_WIDE); - p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO); + p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_OFFSETS_PRESET_WIDE); + p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO); p->add_separator(); p->add_submenu_item(TTR("Anchors only"), "Anchors"); p->set_item_icon(21, get_theme_icon("Anchor", "EditorIcons")); @@ -4396,7 +4396,7 @@ void CanvasItemEditor::_popup_warning_depop(Control *p_control) { timer->queue_delete(); p_control->hide(); popup_temporarily_timers.erase(p_control); - info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); + info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); } void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const float p_duration) { @@ -4414,7 +4414,7 @@ void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const floa timer->start(p_duration); p_control->show(); - info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); + info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); } void CanvasItemEditor::_update_scroll(float) { @@ -4427,10 +4427,10 @@ void CanvasItemEditor::_update_scroll(float) { viewport->update(); } -void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_preset) { +void CanvasItemEditor::_set_anchors_and_offsets_preset(Control::LayoutPreset p_preset) { List selection = editor_selection->get_selected_node_list(); - undo_redo->create_action(TTR("Change Anchors and Margins")); + undo_redo->create_action(TTR("Change Anchors and Offsets")); for (List::Element *E = selection.front(); E; E = E->next()) { Control *control = Object::cast_to(E->get()); @@ -4468,20 +4468,20 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p anchor_mode_button->set_pressed(anchors_mode); } -void CanvasItemEditor::_set_anchors_and_margins_to_keep_ratio() { +void CanvasItemEditor::_set_anchors_and_offsets_to_keep_ratio() { List selection = editor_selection->get_selected_node_list(); - undo_redo->create_action(TTR("Change Anchors and Margins")); + undo_redo->create_action(TTR("Change Anchors and Offsets")); for (List::Element *E = selection.front(); E; E = E->next()) { Control *control = Object::cast_to(E->get()); if (control) { Point2 top_left_anchor = _position_to_anchor(control, Point2()); Point2 bottom_right_anchor = _position_to_anchor(control, control->get_size()); - undo_redo->add_do_method(control, "set_anchor", MARGIN_LEFT, top_left_anchor.x, false, true); - undo_redo->add_do_method(control, "set_anchor", MARGIN_RIGHT, bottom_right_anchor.x, false, true); - undo_redo->add_do_method(control, "set_anchor", MARGIN_TOP, top_left_anchor.y, false, true); - undo_redo->add_do_method(control, "set_anchor", MARGIN_BOTTOM, bottom_right_anchor.y, false, true); + undo_redo->add_do_method(control, "set_anchor", SIDE_LEFT, top_left_anchor.x, false, true); + undo_redo->add_do_method(control, "set_anchor", SIDE_RIGHT, bottom_right_anchor.x, false, true); + undo_redo->add_do_method(control, "set_anchor", SIDE_TOP, top_left_anchor.y, false, true); + undo_redo->add_do_method(control, "set_anchor", SIDE_BOTTOM, bottom_right_anchor.y, false, true); undo_redo->add_do_method(control, "set_meta", "_edit_use_anchors_", true); bool use_anchors = control->has_meta("_edit_use_anchors_") && control->get_meta("_edit_use_anchors_"); @@ -4934,56 +4934,56 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->add_undo_method(viewport, "update", Variant()); undo_redo->commit_action(); } break; - case ANCHORS_AND_MARGINS_PRESET_TOP_LEFT: { - _set_anchors_and_margins_preset(PRESET_TOP_LEFT); + case ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT: { + _set_anchors_and_offsets_preset(PRESET_TOP_LEFT); } break; - case ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT: { - _set_anchors_and_margins_preset(PRESET_TOP_RIGHT); + case ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT: { + _set_anchors_and_offsets_preset(PRESET_TOP_RIGHT); } break; - case ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT: { - _set_anchors_and_margins_preset(PRESET_BOTTOM_LEFT); + case ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT: { + _set_anchors_and_offsets_preset(PRESET_BOTTOM_LEFT); } break; - case ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT: { - _set_anchors_and_margins_preset(PRESET_BOTTOM_RIGHT); + case ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT: { + _set_anchors_and_offsets_preset(PRESET_BOTTOM_RIGHT); } break; - case ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT: { - _set_anchors_and_margins_preset(PRESET_CENTER_LEFT); + case ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT: { + _set_anchors_and_offsets_preset(PRESET_CENTER_LEFT); } break; - case ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT: { - _set_anchors_and_margins_preset(PRESET_CENTER_RIGHT); + case ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT: { + _set_anchors_and_offsets_preset(PRESET_CENTER_RIGHT); } break; - case ANCHORS_AND_MARGINS_PRESET_CENTER_TOP: { - _set_anchors_and_margins_preset(PRESET_CENTER_TOP); + case ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP: { + _set_anchors_and_offsets_preset(PRESET_CENTER_TOP); } break; - case ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM: { - _set_anchors_and_margins_preset(PRESET_CENTER_BOTTOM); + case ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM: { + _set_anchors_and_offsets_preset(PRESET_CENTER_BOTTOM); } break; - case ANCHORS_AND_MARGINS_PRESET_CENTER: { - _set_anchors_and_margins_preset(PRESET_CENTER); + case ANCHORS_AND_OFFSETS_PRESET_CENTER: { + _set_anchors_and_offsets_preset(PRESET_CENTER); } break; - case ANCHORS_AND_MARGINS_PRESET_TOP_WIDE: { - _set_anchors_and_margins_preset(PRESET_TOP_WIDE); + case ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE: { + _set_anchors_and_offsets_preset(PRESET_TOP_WIDE); } break; - case ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE: { - _set_anchors_and_margins_preset(PRESET_LEFT_WIDE); + case ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE: { + _set_anchors_and_offsets_preset(PRESET_LEFT_WIDE); } break; - case ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE: { - _set_anchors_and_margins_preset(PRESET_RIGHT_WIDE); + case ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE: { + _set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); } break; - case ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE: { - _set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); + case ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE: { + _set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); } break; - case ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE: { - _set_anchors_and_margins_preset(PRESET_VCENTER_WIDE); + case ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE: { + _set_anchors_and_offsets_preset(PRESET_VCENTER_WIDE); } break; - case ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE: { - _set_anchors_and_margins_preset(PRESET_HCENTER_WIDE); + case ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE: { + _set_anchors_and_offsets_preset(PRESET_HCENTER_WIDE); } break; - case ANCHORS_AND_MARGINS_PRESET_WIDE: { - _set_anchors_and_margins_preset(Control::PRESET_WIDE); + case ANCHORS_AND_OFFSETS_PRESET_WIDE: { + _set_anchors_and_offsets_preset(Control::PRESET_WIDE); } break; - case ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO: { - _set_anchors_and_margins_to_keep_ratio(); + case ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO: { + _set_anchors_and_offsets_to_keep_ratio(); } break; case ANCHORS_PRESET_TOP_LEFT: { @@ -5572,12 +5572,12 @@ void CanvasItemEditor::add_control_to_info_overlay(Control *p_control) { p_control->set_h_size_flags(p_control->get_h_size_flags() & ~Control::SIZE_EXPAND_FILL); info_overlay->add_child(p_control); - info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); + info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); } void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) { info_overlay->remove_child(p_control); - info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); + info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); } void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { @@ -5674,7 +5674,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb = memnew(HBoxContainer); add_child(hb); - hb->set_anchors_and_margins_preset(Control::PRESET_WIDE); + hb->set_anchors_and_offsets_preset(Control::PRESET_WIDE); bottom_split = memnew(VSplitContainer); add_child(bottom_split); @@ -5695,7 +5695,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { SubViewportContainer *scene_tree = memnew(SubViewportContainer); viewport_scrollable->add_child(scene_tree); scene_tree->set_stretch(true); - scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE); + scene_tree->set_anchors_and_offsets_preset(Control::PRESET_WIDE); scene_tree->add_child(p_editor->get_scene_root()); controls_vb = memnew(VBoxContainer); @@ -5709,16 +5709,16 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { viewport = memnew(CanvasItemEditorViewport(p_editor, this)); viewport_scrollable->add_child(viewport); viewport->set_mouse_filter(MOUSE_FILTER_PASS); - viewport->set_anchors_and_margins_preset(Control::PRESET_WIDE); + viewport->set_anchors_and_offsets_preset(Control::PRESET_WIDE); viewport->set_clip_contents(true); viewport->set_focus_mode(FOCUS_ALL); viewport->connect("draw", callable_mp(this, &CanvasItemEditor::_draw_viewport)); viewport->connect("gui_input", callable_mp(this, &CanvasItemEditor::_gui_input_viewport)); info_overlay = memnew(VBoxContainer); - info_overlay->set_anchors_and_margins_preset(Control::PRESET_BOTTOM_LEFT); - info_overlay->set_margin(MARGIN_LEFT, 10); - info_overlay->set_margin(MARGIN_BOTTOM, -15); + info_overlay->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_LEFT); + info_overlay->set_offset(SIDE_LEFT, 10); + info_overlay->set_offset(SIDE_BOTTOM, -15); info_overlay->set_v_grow_direction(Control::GROW_DIRECTION_BEGIN); info_overlay->add_theme_constant_override("separation", 10); viewport_scrollable->add_child(info_overlay); @@ -6140,7 +6140,7 @@ CanvasItemEditorPlugin::CanvasItemEditorPlugin(EditorNode *p_node) { canvas_item_editor = memnew(CanvasItemEditor(editor)); canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); editor->get_viewport()->add_child(canvas_item_editor); - canvas_item_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); + canvas_item_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE); canvas_item_editor->hide(); } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index c4a1dca593..f5da953810 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -119,23 +119,23 @@ private: UNLOCK_SELECTED, GROUP_SELECTED, UNGROUP_SELECTED, - ANCHORS_AND_MARGINS_PRESET_TOP_LEFT, - ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT, - ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT, - ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT, - ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT, - ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT, - ANCHORS_AND_MARGINS_PRESET_CENTER_TOP, - ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM, - ANCHORS_AND_MARGINS_PRESET_CENTER, - ANCHORS_AND_MARGINS_PRESET_TOP_WIDE, - ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE, - ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE, - ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE, - ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE, - ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE, - ANCHORS_AND_MARGINS_PRESET_WIDE, - ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO, + ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT, + ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT, + ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT, + ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT, + ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT, + ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT, + ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP, + ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM, + ANCHORS_AND_OFFSETS_PRESET_CENTER, + ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE, + ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE, + ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE, + ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE, + ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE, + ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE, + ANCHORS_AND_OFFSETS_PRESET_WIDE, + ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO, ANCHORS_PRESET_TOP_LEFT, ANCHORS_PRESET_TOP_RIGHT, ANCHORS_PRESET_BOTTOM_LEFT, @@ -152,22 +152,22 @@ private: ANCHORS_PRESET_VCENTER_WIDE, ANCHORS_PRESET_HCENTER_WIDE, ANCHORS_PRESET_WIDE, - MARGINS_PRESET_TOP_LEFT, - MARGINS_PRESET_TOP_RIGHT, - MARGINS_PRESET_BOTTOM_LEFT, - MARGINS_PRESET_BOTTOM_RIGHT, - MARGINS_PRESET_CENTER_LEFT, - MARGINS_PRESET_CENTER_RIGHT, - MARGINS_PRESET_CENTER_TOP, - MARGINS_PRESET_CENTER_BOTTOM, - MARGINS_PRESET_CENTER, - MARGINS_PRESET_TOP_WIDE, - MARGINS_PRESET_LEFT_WIDE, - MARGINS_PRESET_RIGHT_WIDE, - MARGINS_PRESET_BOTTOM_WIDE, - MARGINS_PRESET_VCENTER_WIDE, - MARGINS_PRESET_HCENTER_WIDE, - MARGINS_PRESET_WIDE, + OFFSETS_PRESET_TOP_LEFT, + OFFSETS_PRESET_TOP_RIGHT, + OFFSETS_PRESET_BOTTOM_LEFT, + OFFSETS_PRESET_BOTTOM_RIGHT, + OFFSETS_PRESET_CENTER_LEFT, + OFFSETS_PRESET_CENTER_RIGHT, + OFFSETS_PRESET_CENTER_TOP, + OFFSETS_PRESET_CENTER_BOTTOM, + OFFSETS_PRESET_CENTER, + OFFSETS_PRESET_TOP_WIDE, + OFFSETS_PRESET_LEFT_WIDE, + OFFSETS_PRESET_RIGHT_WIDE, + OFFSETS_PRESET_BOTTOM_WIDE, + OFFSETS_PRESET_VCENTER_WIDE, + OFFSETS_PRESET_HCENTER_WIDE, + OFFSETS_PRESET_WIDE, ANIM_INSERT_KEY, ANIM_INSERT_KEY_EXISTING, ANIM_INSERT_POS, @@ -454,9 +454,9 @@ private: void _unhandled_key_input(const Ref &p_ev); - void _draw_text_at_position(Point2 p_position, String p_string, Margin p_side); - void _draw_margin_at_position(int p_value, Point2 p_position, Margin p_side); - void _draw_percentage_at_position(float p_value, Point2 p_position, Margin p_side); + void _draw_text_at_position(Point2 p_position, String p_string, Side p_side); + void _draw_margin_at_position(int p_value, Point2 p_position, Side p_side); + void _draw_percentage_at_position(float p_value, Point2 p_position, Side p_side); void _draw_straight_line(Point2 p_from, Point2 p_to, Color p_color); void _draw_smart_snapping(); @@ -519,9 +519,9 @@ private: const Node *p_current); void _set_anchors_preset(Control::LayoutPreset p_preset); - void _set_margins_preset(Control::LayoutPreset p_preset); - void _set_anchors_and_margins_preset(Control::LayoutPreset p_preset); - void _set_anchors_and_margins_to_keep_ratio(); + void _set_offsets_preset(Control::LayoutPreset p_preset); + void _set_anchors_and_offsets_preset(Control::LayoutPreset p_preset); + void _set_anchors_and_offsets_to_keep_ratio(); void _button_toggle_anchor_mode(bool p_status); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index e49cfd51f7..e45344b427 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -108,7 +108,7 @@ MaterialEditor::MaterialEditor() { vc = memnew(SubViewportContainer); vc->set_stretch(true); add_child(vc); - vc->set_anchors_and_margins_preset(PRESET_WIDE); + vc->set_anchors_and_offsets_preset(PRESET_WIDE); viewport = memnew(SubViewport); Ref world_3d; world_3d.instance(); @@ -155,7 +155,7 @@ MaterialEditor::MaterialEditor() { HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); - hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2); + hb->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2); VBoxContainer *vb_shape = memnew(VBoxContainer); hb->add_child(vb_shape); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 9d396467c3..79dbf7d522 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -137,7 +137,7 @@ MeshEditor::MeshEditor() { HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); - hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2); + hb->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2); hb->add_spacer(); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index b11a07365c..fb34f4064a 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -298,7 +298,7 @@ MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) { mesh_library_editor = memnew(MeshLibraryEditor(p_node)); p_node->get_viewport()->add_child(mesh_library_editor); - mesh_library_editor->set_anchors_and_margins_preset(Control::PRESET_TOP_WIDE); + mesh_library_editor->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE); mesh_library_editor->set_end(Point2(0, 22)); mesh_library_editor->hide(); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index b8a4f7bc5a..59ab622994 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -337,7 +337,7 @@ MultiMeshEditor::MultiMeshEditor() { vbc->add_margin_child(TTR("Scale:"), populate_scale); populate_amount = memnew(SpinBox); - populate_amount->set_anchor(MARGIN_RIGHT, ANCHOR_END); + populate_amount->set_anchor(SIDE_RIGHT, ANCHOR_END); populate_amount->set_begin(Point2(20, 232)); populate_amount->set_end(Point2(-5, 237)); populate_amount->set_min(1); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 4d7be66180..610645eb9e 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2543,12 +2543,12 @@ void Node3DEditorViewport::_notification(int p_what) { cinema_label->set_visible(show_cinema); if (show_cinema) { float cinema_half_width = cinema_label->get_size().width / 2.0f; - cinema_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -cinema_half_width); + cinema_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -cinema_half_width); } if (lock_rotation) { float locked_half_width = locked_label->get_size().width / 2.0f; - locked_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -locked_half_width); + locked_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -locked_half_width); } } @@ -3890,7 +3890,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito subviewport_container = c; c->set_stretch(true); add_child(c); - c->set_anchors_and_margins_preset(Control::PRESET_WIDE); + c->set_anchors_and_offsets_preset(Control::PRESET_WIDE); viewport = memnew(SubViewport); viewport->set_disable_input(true); @@ -3898,7 +3898,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito surface = memnew(Control); surface->set_drag_forwarding(this); add_child(surface); - surface->set_anchors_and_margins_preset(Control::PRESET_WIDE); + surface->set_anchors_and_offsets_preset(Control::PRESET_WIDE); surface->set_clip_contents(true); camera = memnew(Camera3D); camera->set_disable_gizmo(true); @@ -4033,19 +4033,19 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito preview_node = nullptr; info_label = memnew(Label); - info_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); - info_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -90 * EDSCALE); - info_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE); - info_label->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -10 * EDSCALE); + info_label->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -90 * EDSCALE); + info_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -90 * EDSCALE); + info_label->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -10 * EDSCALE); + info_label->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -10 * EDSCALE); info_label->set_h_grow_direction(GROW_DIRECTION_BEGIN); info_label->set_v_grow_direction(GROW_DIRECTION_BEGIN); surface->add_child(info_label); info_label->hide(); fps_label = memnew(Label); - fps_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); - fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); - fps_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE); + fps_label->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -90 * EDSCALE); + fps_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 10 * EDSCALE); + fps_label->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -10 * EDSCALE); fps_label->set_h_grow_direction(GROW_DIRECTION_BEGIN); fps_label->set_tooltip(TTR("Note: The FPS is estimated on a 60hz refresh rate.")); fps_label->set_mouse_filter(MOUSE_FILTER_PASS); // Otherwise tooltip doesn't show. @@ -4053,7 +4053,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito fps_label->hide(); cinema_label = memnew(Label); - cinema_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); + cinema_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 10 * EDSCALE); cinema_label->set_h_grow_direction(GROW_DIRECTION_END); cinema_label->set_align(Label::ALIGN_CENTER); surface->add_child(cinema_label); @@ -4062,8 +4062,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito previewing_cinema = false; locked_label = memnew(Label); - locked_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -20 * EDSCALE); - locked_label->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -10 * EDSCALE); + locked_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -20 * EDSCALE); + locked_label->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -10 * EDSCALE); locked_label->set_h_grow_direction(GROW_DIRECTION_END); locked_label->set_v_grow_direction(GROW_DIRECTION_BEGIN); locked_label->set_align(Label::ALIGN_CENTER); @@ -4072,7 +4072,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito locked_label->hide(); top_right_vbox = memnew(VBoxContainer); - top_right_vbox->set_anchors_and_margins_preset(PRESET_TOP_RIGHT, PRESET_MODE_MINSIZE, 2.0 * EDSCALE); + top_right_vbox->set_anchors_and_offsets_preset(PRESET_TOP_RIGHT, PRESET_MODE_MINSIZE, 2.0 * EDSCALE); top_right_vbox->set_h_grow_direction(GROW_DIRECTION_BEGIN); rotation_control = memnew(ViewportRotationControl); @@ -4082,9 +4082,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito top_right_vbox->add_child(rotation_control); fps_label = memnew(Label); - fps_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); - fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); - fps_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE); + fps_label->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -90 * EDSCALE); + fps_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 10 * EDSCALE); + fps_label->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -10 * EDSCALE); fps_label->set_h_grow_direction(GROW_DIRECTION_BEGIN); fps_label->set_tooltip(TTR("Note: The FPS value displayed is the editor's framerate.\nIt cannot be used as a reliable indication of in-game performance.")); fps_label->set_mouse_filter(MOUSE_FILTER_PASS); // Otherwise tooltip doesn't show. @@ -6109,7 +6109,7 @@ void Node3DEditor::_toggle_maximize_view(Object *p_viewport) { if (!maximized) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { if (i == (uint32_t)index) { - viewports[i]->set_anchors_and_margins_preset(Control::PRESET_WIDE); + viewports[i]->set_anchors_and_offsets_preset(Control::PRESET_WIDE); } else { viewports[i]->hide(); } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 0ccca7e06c..0584ee894b 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -86,8 +86,8 @@ void Polygon2DEditor::_notification(int p_what) { b_snap_enable->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); uv_icon_zoom->set_texture(get_theme_icon("Zoom", "EditorIcons")); - uv_vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE); - uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); + uv_vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); + uv_hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); } break; case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { @@ -1189,8 +1189,8 @@ void Polygon2DEditor::_uv_draw() { Size2 vmin = uv_vscroll->get_combined_minimum_size(); // Avoid scrollbar overlapping. - uv_hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, uv_vscroll->is_visible() ? -vmin.width : 0); - uv_vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, uv_hscroll->is_visible() ? -hmin.height : 0); + uv_hscroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, uv_vscroll->is_visible() ? -vmin.width : 0); + uv_vscroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, uv_hscroll->is_visible() ? -hmin.height : 0); updating_uv_scroll = false; } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index e854ed4fb3..ed2c0c9f26 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -84,10 +84,10 @@ ConnectionInfoDialog::ConnectionInfoDialog() { set_title(TTR("Connections to method:")); VBoxContainer *vbc = memnew(VBoxContainer); - vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE); add_child(vbc); method = memnew(Label); @@ -1679,7 +1679,7 @@ void ScriptTextEditor::_enable_code_editor() { VSplitContainer *editor_box = memnew(VSplitContainer); add_child(editor_box); - editor_box->set_anchors_and_margins_preset(Control::PRESET_WIDE); + editor_box->set_anchors_and_offsets_preset(Control::PRESET_WIDE); editor_box->set_v_size_flags(SIZE_EXPAND_FILL); editor_box->add_child(code_editor); @@ -1809,7 +1809,7 @@ void ScriptTextEditor::_enable_code_editor() { ScriptTextEditor::ScriptTextEditor() { code_editor = memnew(CodeTextEditor); code_editor->add_theme_constant_override("separation", 2); - code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); + code_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE); code_editor->set_code_complete_func(_code_complete_scripts, this); code_editor->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index d24dcdef83..9bb34f4489 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -558,7 +558,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { shader_editor = memnew(ShaderTextEditor); shader_editor->set_v_size_flags(SIZE_EXPAND_FILL); shader_editor->add_theme_constant_override("separation", 0); - shader_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); + shader_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE); shader_editor->connect("script_changed", callable_mp(this, &ShaderEditor::apply_shaders)); EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ShaderEditor::_editor_settings_changed)); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 9894d0e1b0..b95abe8994 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -548,7 +548,7 @@ TextEditor::TextEditor() { code_editor->add_theme_constant_override("separation", 0); code_editor->connect("load_theme_settings", callable_mp(this, &TextEditor::_load_theme_settings)); code_editor->connect("validate_script", callable_mp(this, &TextEditor::_validate_script)); - code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); + code_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE); code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); update_settings(); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 8447a2346f..d13a865534 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -160,16 +160,16 @@ Texture3DEditor::Texture3DEditor() { layer->set_step(1); layer->set_max(100); add_child(layer); - layer->set_anchor(MARGIN_RIGHT, 1); - layer->set_anchor(MARGIN_LEFT, 1); + layer->set_anchor(SIDE_RIGHT, 1); + layer->set_anchor(SIDE_LEFT, 1); layer->set_h_grow_direction(GROW_DIRECTION_BEGIN); layer->set_modulate(Color(1, 1, 1, 0.8)); info = memnew(Label); add_child(info); - info->set_anchor(MARGIN_RIGHT, 1); - info->set_anchor(MARGIN_LEFT, 1); - info->set_anchor(MARGIN_BOTTOM, 1); - info->set_anchor(MARGIN_TOP, 1); + info->set_anchor(SIDE_RIGHT, 1); + info->set_anchor(SIDE_LEFT, 1); + info->set_anchor(SIDE_BOTTOM, 1); + info->set_anchor(SIDE_TOP, 1); info->set_h_grow_direction(GROW_DIRECTION_BEGIN); info->set_v_grow_direction(GROW_DIRECTION_BEGIN); info->add_theme_color_override("font_color", Color(1, 1, 1, 1)); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index eafe4d546b..a807e8e99b 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -225,16 +225,16 @@ TextureLayeredEditor::TextureLayeredEditor() { layer->set_step(1); layer->set_max(100); add_child(layer); - layer->set_anchor(MARGIN_RIGHT, 1); - layer->set_anchor(MARGIN_LEFT, 1); + layer->set_anchor(SIDE_RIGHT, 1); + layer->set_anchor(SIDE_LEFT, 1); layer->set_h_grow_direction(GROW_DIRECTION_BEGIN); layer->set_modulate(Color(1, 1, 1, 0.8)); info = memnew(Label); add_child(info); - info->set_anchor(MARGIN_RIGHT, 1); - info->set_anchor(MARGIN_LEFT, 1); - info->set_anchor(MARGIN_BOTTOM, 1); - info->set_anchor(MARGIN_TOP, 1); + info->set_anchor(SIDE_RIGHT, 1); + info->set_anchor(SIDE_LEFT, 1); + info->set_anchor(SIDE_BOTTOM, 1); + info->set_anchor(SIDE_TOP, 1); info->set_h_grow_direction(GROW_DIRECTION_BEGIN); info->set_v_grow_direction(GROW_DIRECTION_BEGIN); info->add_theme_color_override("font_color", Color(1, 1, 1, 1)); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index f599b94428..15d5c615bd 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -217,23 +217,23 @@ void TextureRegionEditor::_region_draw() { Size2 vmin = vscroll->get_combined_minimum_size(); // Avoid scrollbar overlapping. - hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, vscroll->is_visible() ? -vmin.width : 0); - vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, hscroll->is_visible() ? -hmin.height : 0); + hscroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, vscroll->is_visible() ? -vmin.width : 0); + vscroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, hscroll->is_visible() ? -hmin.height : 0); updating_scroll = false; if (node_ninepatch || obj_styleBox.is_valid()) { float margins[4] = { 0 }; if (node_ninepatch) { - margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP); - margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM); - margins[2] = node_ninepatch->get_patch_margin(MARGIN_LEFT); - margins[3] = node_ninepatch->get_patch_margin(MARGIN_RIGHT); + margins[0] = node_ninepatch->get_patch_margin(SIDE_TOP); + margins[1] = node_ninepatch->get_patch_margin(SIDE_BOTTOM); + margins[2] = node_ninepatch->get_patch_margin(SIDE_LEFT); + margins[3] = node_ninepatch->get_patch_margin(SIDE_RIGHT); } else if (obj_styleBox.is_valid()) { - margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP); - margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM); - margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT); - margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT); + margins[0] = obj_styleBox->get_margin_size(SIDE_TOP); + margins[1] = obj_styleBox->get_margin_size(SIDE_BOTTOM); + margins[2] = obj_styleBox->get_margin_size(SIDE_LEFT); + margins[3] = obj_styleBox->get_margin_size(SIDE_RIGHT); } Vector2 pos[4] = { @@ -278,15 +278,15 @@ void TextureRegionEditor::_region_input(const Ref &p_input) { edited_margin = -1; float margins[4] = { 0 }; if (node_ninepatch) { - margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP); - margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM); - margins[2] = node_ninepatch->get_patch_margin(MARGIN_LEFT); - margins[3] = node_ninepatch->get_patch_margin(MARGIN_RIGHT); + margins[0] = node_ninepatch->get_patch_margin(SIDE_TOP); + margins[1] = node_ninepatch->get_patch_margin(SIDE_BOTTOM); + margins[2] = node_ninepatch->get_patch_margin(SIDE_LEFT); + margins[3] = node_ninepatch->get_patch_margin(SIDE_RIGHT); } else if (obj_styleBox.is_valid()) { - margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP); - margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM); - margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT); - margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT); + margins[0] = obj_styleBox->get_margin_size(SIDE_TOP); + margins[1] = obj_styleBox->get_margin_size(SIDE_BOTTOM); + margins[2] = obj_styleBox->get_margin_size(SIDE_LEFT); + margins[3] = obj_styleBox->get_margin_size(SIDE_RIGHT); } Vector2 pos[4] = { @@ -395,13 +395,13 @@ void TextureRegionEditor::_region_input(const Ref &p_input) { } else if (drag) { if (edited_margin >= 0) { undo_redo->create_action(TTR("Set Margin")); - static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT }; + static Side side[4] = { SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT }; if (node_ninepatch) { - undo_redo->add_do_method(node_ninepatch, "set_patch_margin", m[edited_margin], node_ninepatch->get_patch_margin(m[edited_margin])); - undo_redo->add_undo_method(node_ninepatch, "set_patch_margin", m[edited_margin], prev_margin); + undo_redo->add_do_method(node_ninepatch, "set_patch_margin", side[edited_margin], node_ninepatch->get_patch_margin(side[edited_margin])); + undo_redo->add_undo_method(node_ninepatch, "set_patch_margin", side[edited_margin], prev_margin); } else if (obj_styleBox.is_valid()) { - undo_redo->add_do_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], obj_styleBox->get_margin_size(m[edited_margin])); - undo_redo->add_undo_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], prev_margin); + undo_redo->add_do_method(obj_styleBox.ptr(), "set_margin_size", side[edited_margin], obj_styleBox->get_margin_size(side[edited_margin])); + undo_redo->add_undo_method(obj_styleBox.ptr(), "set_margin_size", side[edited_margin], prev_margin); obj_styleBox->emit_signal(CoreStringNames::get_singleton()->changed); } edited_margin = -1; @@ -438,12 +438,12 @@ void TextureRegionEditor::_region_input(const Ref &p_input) { if (drag) { drag = false; if (edited_margin >= 0) { - static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT }; + static Side side[4] = { SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT }; if (node_ninepatch) { - node_ninepatch->set_patch_margin(m[edited_margin], prev_margin); + node_ninepatch->set_patch_margin(side[edited_margin], prev_margin); } if (obj_styleBox.is_valid()) { - obj_styleBox->set_margin_size(m[edited_margin], prev_margin); + obj_styleBox->set_margin_size(side[edited_margin], prev_margin); } edited_margin = -1; } else { @@ -486,12 +486,12 @@ void TextureRegionEditor::_region_input(const Ref &p_input) { if (new_margin < 0) { new_margin = 0; } - static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT }; + static Side side[4] = { SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT }; if (node_ninepatch) { - node_ninepatch->set_patch_margin(m[edited_margin], new_margin); + node_ninepatch->set_patch_margin(side[edited_margin], new_margin); } if (obj_styleBox.is_valid()) { - obj_styleBox->set_margin_size(m[edited_margin], new_margin); + obj_styleBox->set_margin_size(side[edited_margin], new_margin); } } else { Vector2 new_pos = mtx.affine_inverse().xform(mm->get_position()); @@ -772,8 +772,8 @@ void TextureRegionEditor::_notification(int p_what) { zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); - vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE); - hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); + vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); + hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); } break; case NOTIFICATION_VISIBILITY_CHANGED: { if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) { diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 189e5ec442..49eb68c93a 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -2085,7 +2085,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { info_message->set_align(Label::ALIGN_CENTER); info_message->set_autowrap(true); info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); - info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + info_message->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); palette->add_child(info_message); // Add autotile override palette. diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index da664109dc..3820416c76 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -83,10 +83,10 @@ void VisualShaderNodePlugin::_bind_methods() { static Ref make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) { Ref style(memnew(StyleBoxEmpty)); - style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE); - style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE); - style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE); - style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE); + style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); + style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); + style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE); + style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE); return style; } @@ -283,7 +283,7 @@ VisualShader::Type VisualShaderGraphPlugin::get_shader_type() const { void VisualShaderGraphPlugin::set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position) { if (visual_shader->get_shader_type() == p_type && links.has(p_id)) { - links[p_id].graph_node->set_offset(p_position); + links[p_id].graph_node->set_position_offset(p_position); } } @@ -365,7 +365,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression = expression_node->get_expression(); } - node->set_offset(visual_shader->get_node_position(p_type, p_id)); + node->set_position_offset(visual_shader->get_node_position(p_type, p_id)); node->set_title(vsnode->get_caption()); node->set_name(itos(p_id)); @@ -1580,9 +1580,9 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p box_size.x = gn->get_size().x; } } - box_size.x -= text_box->get_margin(MARGIN_LEFT); + box_size.x -= text_box->get_offset(SIDE_LEFT); box_size.x -= 28 * EDSCALE; - box_size.y -= text_box->get_margin(MARGIN_TOP); + box_size.y -= text_box->get_offset(SIDE_TOP); box_size.y -= 28 * EDSCALE; text_box->set_custom_minimum_size(Size2(box_size.x, box_size.y)); text_box->set_size(Size2(1, 1)); diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 46a656e0af..a37f4776ac 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -50,7 +50,7 @@ void BackgroundProgress::_add_task(const String &p_task, const String &p_label, Control *ec = memnew(Control); ec->set_h_size_flags(SIZE_EXPAND_FILL); ec->set_v_size_flags(SIZE_EXPAND_FILL); - t.progress->set_anchors_and_margins_preset(Control::PRESET_WIDE); + t.progress->set_anchors_and_offsets_preset(Control::PRESET_WIDE); ec->add_child(t.progress); ec->set_custom_minimum_size(Size2(80, 5) * EDSCALE); t.hb->add_child(ec); @@ -141,10 +141,10 @@ void ProgressDialog::_popup() { Ref style = main->get_theme_stylebox("panel", "PopupMenu"); ms += style->get_minimum_size(); - main->set_margin(MARGIN_LEFT, style->get_margin(MARGIN_LEFT)); - main->set_margin(MARGIN_RIGHT, -style->get_margin(MARGIN_RIGHT)); - main->set_margin(MARGIN_TOP, style->get_margin(MARGIN_TOP)); - main->set_margin(MARGIN_BOTTOM, -style->get_margin(MARGIN_BOTTOM)); + main->set_offset(SIDE_LEFT, style->get_margin(SIDE_LEFT)); + main->set_offset(SIDE_RIGHT, -style->get_margin(SIDE_RIGHT)); + main->set_offset(SIDE_TOP, style->get_margin(SIDE_TOP)); + main->set_offset(SIDE_BOTTOM, -style->get_margin(SIDE_BOTTOM)); //raise(); popup_centered(ms); @@ -235,7 +235,7 @@ void ProgressDialog::_bind_methods() { ProgressDialog::ProgressDialog() { main = memnew(VBoxContainer); add_child(main); - main->set_anchors_and_margins_preset(Control::PRESET_WIDE); + main->set_anchors_and_offsets_preset(Control::PRESET_WIDE); set_exclusive(true); last_progress_tick = 0; singleton = this; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index ad0c9532d8..3068bdd672 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1824,7 +1824,7 @@ void ProjectManager::_notification(int p_what) { switch (p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { - settings_hb->set_anchors_and_margins_preset(Control::PRESET_TOP_RIGHT); + settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT); update(); } break; case NOTIFICATION_ENTER_TREE: { @@ -2440,19 +2440,19 @@ ProjectManager::ProjectManager() { FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files")); - set_anchors_and_margins_preset(Control::PRESET_WIDE); + set_anchors_and_offsets_preset(Control::PRESET_WIDE); set_theme(create_custom_theme()); - set_anchors_and_margins_preset(Control::PRESET_WIDE); + set_anchors_and_offsets_preset(Control::PRESET_WIDE); Panel *panel = memnew(Panel); add_child(panel); - panel->set_anchors_and_margins_preset(Control::PRESET_WIDE); + panel->set_anchors_and_offsets_preset(Control::PRESET_WIDE); panel->add_theme_style_override("panel", get_theme_stylebox("Background", "EditorStyles")); VBoxContainer *vb = memnew(VBoxContainer); panel->add_child(vb); - vb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 8 * EDSCALE); + vb->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 8 * EDSCALE); Control *center_box = memnew(Control); center_box->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -2460,7 +2460,7 @@ ProjectManager::ProjectManager() { tabs = memnew(TabContainer); center_box->add_child(tabs); - tabs->set_anchors_and_margins_preset(Control::PRESET_WIDE); + tabs->set_anchors_and_offsets_preset(Control::PRESET_WIDE); tabs->set_tab_align(TabContainer::ALIGN_LEFT); HBoxContainer *projects_hb = memnew(HBoxContainer); @@ -2571,7 +2571,7 @@ ProjectManager::ProjectManager() { settings_hb = memnew(HBoxContainer); settings_hb->set_alignment(BoxContainer::ALIGN_END); settings_hb->set_h_grow_direction(Control::GROW_DIRECTION_BEGIN); - settings_hb->set_anchors_and_margins_preset(Control::PRESET_TOP_RIGHT); + settings_hb->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT); Label *version_label = memnew(Label); String hash = String(VERSION_HASH); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 847af0f2c2..d45ee1eae1 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -456,14 +456,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: set_size(Vector2(4, 4) * EDSCALE + checks20gc->get_position() + checks20gc->get_size()); } else if (hint == PROPERTY_HINT_EXP_EASING) { - easing_draw->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5 * EDSCALE); - easing_draw->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5 * EDSCALE); - easing_draw->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 5 * EDSCALE); - easing_draw->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -30 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 3 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -3 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_END, -25 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -7 * EDSCALE); + easing_draw->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 5 * EDSCALE); + easing_draw->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -5 * EDSCALE); + easing_draw->set_anchor_and_offset(SIDE_TOP, Control::ANCHOR_BEGIN, 5 * EDSCALE); + easing_draw->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_END, -30 * EDSCALE); + type_button->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 3 * EDSCALE); + type_button->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -3 * EDSCALE); + type_button->set_anchor_and_offset(SIDE_TOP, Control::ANCHOR_END, -25 * EDSCALE); + type_button->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_END, -7 * EDSCALE); type_button->set_text(TTR("Preset...")); type_button->get_popup()->clear(); type_button->get_popup()->add_item(TTR("Linear"), EASING_LINEAR); @@ -536,10 +536,10 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: int button_margin = text_edit->get_theme_constant("button_margin", "Dialogs"); int margin = text_edit->get_theme_constant("margin", "Dialogs"); - action_buttons[0]->set_anchor(MARGIN_LEFT, Control::ANCHOR_END); - action_buttons[0]->set_anchor(MARGIN_TOP, Control::ANCHOR_END); - action_buttons[0]->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END); - action_buttons[0]->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END); + action_buttons[0]->set_anchor(SIDE_LEFT, Control::ANCHOR_END); + action_buttons[0]->set_anchor(SIDE_TOP, Control::ANCHOR_END); + action_buttons[0]->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); + action_buttons[0]->set_anchor(SIDE_BOTTOM, Control::ANCHOR_END); action_buttons[0]->set_begin(Point2(-70 * EDSCALE, -button_margin + 5 * EDSCALE)); action_buttons[0]->set_end(Point2(-margin, -margin)); action_buttons[0]->set_text(TTR("Close")); @@ -1661,10 +1661,10 @@ void CustomPropertyEditor::_focus_exit() { void CustomPropertyEditor::config_action_buttons(const List &p_strings) { Ref sb = action_buttons[0]->get_theme_stylebox("panel"); - int margin_top = sb->get_margin(MARGIN_TOP); - int margin_left = sb->get_margin(MARGIN_LEFT); - int margin_bottom = sb->get_margin(MARGIN_BOTTOM); - int margin_right = sb->get_margin(MARGIN_RIGHT); + int margin_top = sb->get_margin(SIDE_TOP); + int margin_left = sb->get_margin(SIDE_LEFT); + int margin_bottom = sb->get_margin(SIDE_BOTTOM); + int margin_right = sb->get_margin(SIDE_RIGHT); int max_width = 0; int height = 0; @@ -1794,8 +1794,8 @@ CustomPropertyEditor::CustomPropertyEditor() { text_edit = memnew(TextEdit); add_child(text_edit); - text_edit->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); - text_edit->set_margin(MARGIN_BOTTOM, -30); + text_edit->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); + text_edit->set_offset(SIDE_BOTTOM, -30); text_edit->hide(); text_edit->connect("text_changed", callable_mp(this, &CustomPropertyEditor::_text_edit_changed)); @@ -1853,12 +1853,12 @@ CustomPropertyEditor::CustomPropertyEditor() { spinbox = memnew(SpinBox); add_child(spinbox); - spinbox->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); + spinbox->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); spinbox->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); slider = memnew(HSlider); add_child(slider); - slider->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); + slider->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); slider->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); create_dialog = nullptr; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 72703623ab..91ae81dea2 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1015,7 +1015,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; case TOOL_CREATE_USER_INTERFACE: { Control *node = memnew(Control); - node->set_anchors_and_margins_preset(PRESET_WIDE); //more useful for resizable UIs. + node->set_anchors_and_offsets_preset(PRESET_WIDE); //more useful for resizable UIs. new_node = node; } break; @@ -1107,7 +1107,7 @@ void SceneTreeDock::_notification(int p_what) { node_shortcuts_toggle->set_toggle_mode(true); node_shortcuts_toggle->set_tooltip(TTR("Switch to Favorite Nodes")); node_shortcuts_toggle->set_pressed(EDITOR_GET("_use_favorites_root_selection")); - node_shortcuts_toggle->set_anchors_and_margins_preset(Control::PRESET_CENTER_RIGHT); + node_shortcuts_toggle->set_anchors_and_offsets_preset(Control::PRESET_CENTER_RIGHT); node_shortcuts_toggle->connect("pressed", callable_mp(this, &SceneTreeDock::_update_create_root_dialog)); top_row->add_child(node_shortcuts_toggle); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 685833da55..40fc5c02fc 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -1150,8 +1150,8 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope } tree = memnew(Tree); - tree->set_anchor(MARGIN_RIGHT, ANCHOR_END); - tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END); + tree->set_anchor(SIDE_RIGHT, ANCHOR_END); + tree->set_anchor(SIDE_BOTTOM, ANCHOR_END); tree->set_begin(Point2(0, p_label ? 18 : 0)); tree->set_end(Point2(0, 0)); tree->add_theme_constant_override("button_margin", 0); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index a29b6aded7..c152c2625f 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -471,10 +471,10 @@ EditorSettingsDialog::EditorSettingsDialog() { Label *l = memnew(Label); l->set_text(TTR("Press a Key...")); - l->set_anchors_and_margins_preset(Control::PRESET_WIDE); + l->set_anchors_and_offsets_preset(Control::PRESET_WIDE); l->set_align(Label::ALIGN_CENTER); - l->set_margin(MARGIN_TOP, 20); - l->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 30); + l->set_offset(SIDE_TOP, 20); + l->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_BEGIN, 30); press_a_key_label = l; press_a_key->add_child(l); press_a_key->connect("window_input", callable_mp(this, &EditorSettingsDialog::_wait_for_key)); diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp index 0576fb569f..9897b96c09 100644 --- a/modules/gdnative/gdnative/rect2.cpp +++ b/modules/gdnative/gdnative/rect2.cpp @@ -127,10 +127,10 @@ godot_rect2 GDAPI godot_rect2_grow_individual(const godot_rect2 *p_self, const g return dest; } -godot_rect2 GDAPI godot_rect2_grow_margin(const godot_rect2 *p_self, const godot_int p_margin, const godot_real p_by) { +godot_rect2 GDAPI godot_rect2_grow_margin(const godot_rect2 *p_self, const godot_int p_side, const godot_real p_by) { godot_rect2 dest; const Rect2 *self = (const Rect2 *)p_self; - *((Rect2 *)&dest) = self->grow_margin((Margin)p_margin, p_by); + *((Rect2 *)&dest) = self->grow_margin((Side)p_side, p_by); return dest; } @@ -270,10 +270,10 @@ godot_rect2i GDAPI godot_rect2i_grow_individual(const godot_rect2i *p_self, cons return dest; } -godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_margin, const godot_int p_by) { +godot_rect2i GDAPI godot_rect2i_grow_margin(const godot_rect2i *p_self, const godot_int p_side, const godot_int p_by) { godot_rect2i dest; const Rect2i *self = (const Rect2i *)p_self; - *((Rect2i *)&dest) = self->grow_margin((Margin)p_margin, p_by); + *((Rect2i *)&dest) = self->grow_margin((Side)p_side, p_by); return dest; } diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index 52f8c837c4..5ea5c8ee8d 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -327,7 +327,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { VBoxContainer *container = memnew(VBoxContainer); add_child(container); - container->set_anchors_and_margins_preset(PRESET_WIDE); + container->set_anchors_and_offsets_preset(PRESET_WIDE); HBoxContainer *hbox = memnew(HBoxContainer); container->add_child(hbox); @@ -381,7 +381,7 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() { new_architecture_input = memnew(LineEdit); new_architecture_dialog->add_child(new_architecture_input); // new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE); - new_architecture_input->set_anchors_and_margins_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE); + new_architecture_input->set_anchors_and_offsets_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE); new_architecture_dialog->get_ok_button()->connect("pressed", callable_mp(this, &GDNativeLibraryEditor::_on_create_new_entry)); } diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index cda217acf0..d4fbecd60f 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1288,7 +1288,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { info_message->set_align(Label::ALIGN_CENTER); info_message->set_autowrap(true); info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); - info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + info_message->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); mesh_library_palette->add_child(info_message); edit_axis = Vector3::AXIS_Y; diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 1bd88a2a19..19de5d4adc 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -672,7 +672,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { GraphNode *gnode = memnew(GraphNode); gnode->set_title(node->get_caption()); - gnode->set_offset(pos * EDSCALE); + gnode->set_position_offset(pos * EDSCALE); if (error_line == E->get()) { gnode->set_overlay(GraphNode::OVERLAY_POSITION); } else if (node->is_breakpoint()) { @@ -2639,7 +2639,7 @@ void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) { if (gn) { gn->set_selected(true); - Vector2 new_scroll = gn->get_offset() - graph->get_size() * 0.5 + gn->get_size() * 0.5; + Vector2 new_scroll = gn->get_position_offset() - graph->get_size() * 0.5 + gn->get_size() * 0.5; graph->set_scroll_ofs(new_scroll); script->set_function_scroll(p_func, new_scroll / EDSCALE); script->set_edited(true); @@ -2852,7 +2852,7 @@ void VisualScriptEditor::_move_node(const StringName &p_func, int p_id, const Ve Node *node = graph->get_node(itos(p_id)); if (Object::cast_to(node)) { - Object::cast_to(node)->set_offset(p_to); + Object::cast_to(node)->set_position_offset(p_to); } script->set_node_position(p_func, p_id, p_to / EDSCALE); @@ -4786,7 +4786,7 @@ VisualScriptEditor::VisualScriptEditor() { graph = memnew(GraphEdit); add_child(graph); graph->set_v_size_flags(Control::SIZE_EXPAND_FILL); - graph->set_anchors_and_margins_preset(Control::PRESET_WIDE); + graph->set_anchors_and_offsets_preset(Control::PRESET_WIDE); graph->connect("node_selected", callable_mp(this, &VisualScriptEditor::_node_selected)); graph->connect("begin_node_move", callable_mp(this, &VisualScriptEditor::_begin_node_move)); graph->connect("end_node_move", callable_mp(this, &VisualScriptEditor::_end_node_move)); @@ -4870,9 +4870,9 @@ VisualScriptEditor::VisualScriptEditor() { add_child(select_func_text); hint_text = memnew(Label); - hint_text->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -100); - hint_text->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); - hint_text->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); + hint_text->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -100); + hint_text->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); + hint_text->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); hint_text->set_align(Label::ALIGN_CENTER); hint_text->set_valign(Label::VALIGN_CENTER); graph->add_child(hint_text); diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 0d09d21a71..2ba9de9e87 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -105,27 +105,27 @@ Transform2D Camera2D::get_camera_transform() { if (!first) { if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) { if (h_drag_enabled && !Engine::get_singleton()->is_editor_hint() && !h_offset_changed) { - camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * zoom.x * drag_margin[MARGIN_LEFT])); - camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * zoom.x * drag_margin[MARGIN_RIGHT])); + camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * zoom.x * drag_margin[SIDE_LEFT])); + camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * zoom.x * drag_margin[SIDE_RIGHT])); } else { if (h_ofs < 0) { - camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT] * h_ofs; + camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[SIDE_RIGHT] * h_ofs; } else { - camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_LEFT] * h_ofs; + camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[SIDE_LEFT] * h_ofs; } h_offset_changed = false; } if (v_drag_enabled && !Engine::get_singleton()->is_editor_hint() && !v_offset_changed) { - camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * zoom.y * drag_margin[MARGIN_TOP])); - camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * zoom.y * drag_margin[MARGIN_BOTTOM])); + camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * zoom.y * drag_margin[SIDE_TOP])); + camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * zoom.y * drag_margin[SIDE_BOTTOM])); } else { if (v_ofs < 0) { - camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs; + camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[SIDE_BOTTOM] * v_ofs; } else { - camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_TOP] * v_ofs; + camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[SIDE_TOP] * v_ofs; } v_offset_changed = false; @@ -139,20 +139,20 @@ Transform2D Camera2D::get_camera_transform() { Rect2 screen_rect(-screen_offset + camera_pos, screen_size * zoom); if (limit_smoothing_enabled) { - if (screen_rect.position.x < limit[MARGIN_LEFT]) { - camera_pos.x -= screen_rect.position.x - limit[MARGIN_LEFT]; + if (screen_rect.position.x < limit[SIDE_LEFT]) { + camera_pos.x -= screen_rect.position.x - limit[SIDE_LEFT]; } - if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT]) { - camera_pos.x -= screen_rect.position.x + screen_rect.size.x - limit[MARGIN_RIGHT]; + if (screen_rect.position.x + screen_rect.size.x > limit[SIDE_RIGHT]) { + camera_pos.x -= screen_rect.position.x + screen_rect.size.x - limit[SIDE_RIGHT]; } - if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM]) { - camera_pos.y -= screen_rect.position.y + screen_rect.size.y - limit[MARGIN_BOTTOM]; + if (screen_rect.position.y + screen_rect.size.y > limit[SIDE_BOTTOM]) { + camera_pos.y -= screen_rect.position.y + screen_rect.size.y - limit[SIDE_BOTTOM]; } - if (screen_rect.position.y < limit[MARGIN_TOP]) { - camera_pos.y -= screen_rect.position.y - limit[MARGIN_TOP]; + if (screen_rect.position.y < limit[SIDE_TOP]) { + camera_pos.y -= screen_rect.position.y - limit[SIDE_TOP]; } } @@ -178,20 +178,20 @@ Transform2D Camera2D::get_camera_transform() { } Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom); - if (screen_rect.position.x < limit[MARGIN_LEFT]) { - screen_rect.position.x = limit[MARGIN_LEFT]; + if (screen_rect.position.x < limit[SIDE_LEFT]) { + screen_rect.position.x = limit[SIDE_LEFT]; } - if (screen_rect.position.x + screen_rect.size.x > limit[MARGIN_RIGHT]) { - screen_rect.position.x = limit[MARGIN_RIGHT] - screen_rect.size.x; + if (screen_rect.position.x + screen_rect.size.x > limit[SIDE_RIGHT]) { + screen_rect.position.x = limit[SIDE_RIGHT] - screen_rect.size.x; } - if (screen_rect.position.y + screen_rect.size.y > limit[MARGIN_BOTTOM]) { - screen_rect.position.y = limit[MARGIN_BOTTOM] - screen_rect.size.y; + if (screen_rect.position.y + screen_rect.size.y > limit[SIDE_BOTTOM]) { + screen_rect.position.y = limit[SIDE_BOTTOM] - screen_rect.size.y; } - if (screen_rect.position.y < limit[MARGIN_TOP]) { - screen_rect.position.y = limit[MARGIN_TOP]; + if (screen_rect.position.y < limit[SIDE_TOP]) { + screen_rect.position.y = limit[SIDE_TOP]; } if (offset != Vector2()) { @@ -304,10 +304,10 @@ void Camera2D::_notification(int p_what) { Vector2 camera_origin = get_global_transform().get_origin(); Vector2 camera_scale = get_global_transform().get_scale().abs(); Vector2 limit_points[4] = { - (Vector2(limit[MARGIN_LEFT], limit[MARGIN_TOP]) - camera_origin) / camera_scale, - (Vector2(limit[MARGIN_RIGHT], limit[MARGIN_TOP]) - camera_origin) / camera_scale, - (Vector2(limit[MARGIN_RIGHT], limit[MARGIN_BOTTOM]) - camera_origin) / camera_scale, - (Vector2(limit[MARGIN_LEFT], limit[MARGIN_BOTTOM]) - camera_origin) / camera_scale + (Vector2(limit[SIDE_LEFT], limit[SIDE_TOP]) - camera_origin) / camera_scale, + (Vector2(limit[SIDE_RIGHT], limit[SIDE_TOP]) - camera_origin) / camera_scale, + (Vector2(limit[SIDE_RIGHT], limit[SIDE_BOTTOM]) - camera_origin) / camera_scale, + (Vector2(limit[SIDE_LEFT], limit[SIDE_BOTTOM]) - camera_origin) / camera_scale }; for (int i = 0; i < 4; i++) { @@ -327,10 +327,10 @@ void Camera2D::_notification(int p_what) { Size2 screen_size = _get_camera_screen_size(); Vector2 margin_endpoints[4] = { - inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[MARGIN_LEFT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[MARGIN_TOP]))), - inv_camera_transform.xform(Vector2((screen_size.width / 2) + ((screen_size.width / 2) * drag_margin[MARGIN_RIGHT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[MARGIN_TOP]))), - inv_camera_transform.xform(Vector2((screen_size.width / 2) + ((screen_size.width / 2) * drag_margin[MARGIN_RIGHT]), (screen_size.height / 2) + ((screen_size.height / 2) * drag_margin[MARGIN_BOTTOM]))), - inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[MARGIN_LEFT]), (screen_size.height / 2) + ((screen_size.height / 2) * drag_margin[MARGIN_BOTTOM]))) + inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[SIDE_LEFT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[SIDE_TOP]))), + inv_camera_transform.xform(Vector2((screen_size.width / 2) + ((screen_size.width / 2) * drag_margin[SIDE_RIGHT]), (screen_size.height / 2) - ((screen_size.height / 2) * drag_margin[SIDE_TOP]))), + inv_camera_transform.xform(Vector2((screen_size.width / 2) + ((screen_size.width / 2) * drag_margin[SIDE_RIGHT]), (screen_size.height / 2) + ((screen_size.height / 2) * drag_margin[SIDE_BOTTOM]))), + inv_camera_transform.xform(Vector2((screen_size.width / 2) - ((screen_size.width / 2) * drag_margin[SIDE_LEFT]), (screen_size.height / 2) + ((screen_size.height / 2) * drag_margin[SIDE_BOTTOM]))) }; Transform2D inv_transform = get_global_transform().affine_inverse(); // undo global space @@ -425,15 +425,15 @@ void Camera2D::clear_current() { } } -void Camera2D::set_limit(Margin p_margin, int p_limit) { - ERR_FAIL_INDEX((int)p_margin, 4); - limit[p_margin] = p_limit; +void Camera2D::set_limit(Side p_side, int p_limit) { + ERR_FAIL_INDEX((int)p_side, 4); + limit[p_side] = p_limit; update(); } -int Camera2D::get_limit(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); - return limit[p_margin]; +int Camera2D::get_limit(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0); + return limit[p_side]; } void Camera2D::set_limit_smoothing_enabled(bool enable) { @@ -445,15 +445,15 @@ bool Camera2D::is_limit_smoothing_enabled() const { return limit_smoothing_enabled; } -void Camera2D::set_drag_margin(Margin p_margin, float p_drag_margin) { - ERR_FAIL_INDEX((int)p_margin, 4); - drag_margin[p_margin] = p_drag_margin; +void Camera2D::set_drag_margin(Side p_side, float p_drag_margin) { + ERR_FAIL_INDEX((int)p_side, 4); + drag_margin[p_side] = p_drag_margin; update(); } -float Camera2D::get_drag_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); - return drag_margin[p_margin]; +float Camera2D::get_drag_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0); + return drag_margin[p_side]; } Vector2 Camera2D::get_camera_position() const { @@ -477,14 +477,14 @@ void Camera2D::align() { Point2 current_camera_pos = get_global_transform().get_origin(); if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) { if (h_ofs < 0) { - camera_pos.x = current_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT] * h_ofs; + camera_pos.x = current_camera_pos.x + screen_size.x * 0.5 * drag_margin[SIDE_RIGHT] * h_ofs; } else { - camera_pos.x = current_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_LEFT] * h_ofs; + camera_pos.x = current_camera_pos.x + screen_size.x * 0.5 * drag_margin[SIDE_LEFT] * h_ofs; } if (v_ofs < 0) { - camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_TOP] * v_ofs; + camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[SIDE_TOP] * v_ofs; } else { - camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs; + camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[SIDE_BOTTOM] * v_ofs; } } else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) { camera_pos = current_camera_pos; @@ -717,10 +717,10 @@ void Camera2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_mode", "get_process_mode"); ADD_GROUP("Limit", "limit_"); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_left"), "set_limit", "get_limit", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_top"), "set_limit", "get_limit", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_right"), "set_limit", "get_limit", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_bottom"), "set_limit", "get_limit", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_left"), "set_limit", "get_limit", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_top"), "set_limit", "get_limit", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_right"), "set_limit", "get_limit", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit_bottom"), "set_limit", "get_limit", SIDE_BOTTOM); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "limit_smoothed"), "set_limit_smoothing_enabled", "is_limit_smoothing_enabled"); ADD_GROUP("Draw Margin", "draw_margin_"); @@ -736,10 +736,10 @@ void Camera2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "offset_v", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_v_offset", "get_v_offset"); ADD_GROUP("Drag Margin", "drag_margin_"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_left", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_top", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_right", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_bottom", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_left", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_top", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_right", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "drag_margin_bottom", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_margin", "get_drag_margin", SIDE_BOTTOM); ADD_GROUP("Editor", "editor_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_draw_screen"), "set_screen_drawing_enabled", "is_screen_drawing_enabled"); @@ -756,15 +756,15 @@ Camera2D::Camera2D() { anchor_mode = ANCHOR_MODE_DRAG_CENTER; rotating = false; current = false; - limit[MARGIN_LEFT] = -10000000; - limit[MARGIN_TOP] = -10000000; - limit[MARGIN_RIGHT] = 10000000; - limit[MARGIN_BOTTOM] = 10000000; + limit[SIDE_LEFT] = -10000000; + limit[SIDE_TOP] = -10000000; + limit[SIDE_RIGHT] = 10000000; + limit[SIDE_BOTTOM] = 10000000; - drag_margin[MARGIN_LEFT] = 0.2; - drag_margin[MARGIN_TOP] = 0.2; - drag_margin[MARGIN_RIGHT] = 0.2; - drag_margin[MARGIN_BOTTOM] = 0.2; + drag_margin[SIDE_LEFT] = 0.2; + drag_margin[SIDE_TOP] = 0.2; + drag_margin[SIDE_RIGHT] = 0.2; + drag_margin[SIDE_BOTTOM] = 0.2; camera_pos = Vector2(); first = true; smoothing_enabled = false; diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 867a5562b2..ebfcf97861 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -111,8 +111,8 @@ public: void set_rotating(bool p_rotating); bool is_rotating() const; - void set_limit(Margin p_margin, int p_limit); - int get_limit(Margin p_margin) const; + void set_limit(Side p_side, int p_limit); + int get_limit(Side p_side) const; void set_limit_smoothing_enabled(bool enable); bool is_limit_smoothing_enabled() const; @@ -123,8 +123,8 @@ public: void set_v_drag_enabled(bool p_enabled); bool is_v_drag_enabled() const; - void set_drag_margin(Margin p_margin, float p_drag_margin); - float get_drag_margin(Margin p_margin) const; + void set_drag_margin(Side p_side, float p_drag_margin); + float get_drag_margin(Side p_side) const; void set_v_offset(float p_offset); float get_v_offset() const; diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 711e5f9262..0cdfa9457e 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -59,8 +59,8 @@ Size2 Button::get_minimum_size() const { return get_theme_stylebox("normal")->get_minimum_size() + minsize; } -void Button::_set_internal_margin(Margin p_margin, float p_value) { - _internal_margin[p_margin] = p_value; +void Button::_set_internal_margin(Side p_side, float p_value) { + _internal_margin[p_side] = p_value; } void Button::_notification(int p_what) { @@ -205,12 +205,12 @@ void Button::_notification(int p_what) { float icon_ofs_region = 0; if (rtl) { - if (_internal_margin[MARGIN_RIGHT] > 0) { - icon_ofs_region = _internal_margin[MARGIN_RIGHT] + get_theme_constant("hseparation"); + if (_internal_margin[SIDE_RIGHT] > 0) { + icon_ofs_region = _internal_margin[SIDE_RIGHT] + get_theme_constant("hseparation"); } } else { - if (_internal_margin[MARGIN_LEFT] > 0) { - icon_ofs_region = _internal_margin[MARGIN_LEFT] + get_theme_constant("hseparation"); + if (_internal_margin[SIDE_LEFT] > 0) { + icon_ofs_region = _internal_margin[SIDE_LEFT] + get_theme_constant("hseparation"); } } @@ -229,13 +229,13 @@ void Button::_notification(int p_what) { } if (rtl) { - icon_region = Rect2(Point2(size.width - (icon_ofs_region + icon_width + style->get_margin(MARGIN_RIGHT)), style->get_margin(MARGIN_TOP) + (_size.height - icon_height) / 2), Size2(icon_width, icon_height)); + icon_region = Rect2(Point2(size.width - (icon_ofs_region + icon_width + style->get_margin(SIDE_RIGHT)), style->get_margin(SIDE_TOP) + (_size.height - icon_height) / 2), Size2(icon_width, icon_height)); } else { icon_region = Rect2(style->get_offset() + Point2(icon_ofs_region, (_size.height - icon_height) / 2), Size2(icon_width, icon_height)); } } else { if (rtl) { - icon_region = Rect2(Point2(size.width - (icon_ofs_region + _icon->get_size().width + style->get_margin(MARGIN_RIGHT)), style->get_margin(MARGIN_TOP) + Math::floor((valign - _icon->get_height()) / 2.0)), _icon->get_size()); + icon_region = Rect2(Point2(size.width - (icon_ofs_region + _icon->get_size().width + style->get_margin(SIDE_RIGHT)), style->get_margin(SIDE_TOP) + Math::floor((valign - _icon->get_height()) / 2.0)), _icon->get_size()); } else { icon_region = Rect2(style->get_offset() + Point2(icon_ofs_region, Math::floor((valign - _icon->get_height()) / 2.0)), _icon->get_size()); } @@ -248,28 +248,28 @@ void Button::_notification(int p_what) { int text_width = clip_text ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x; - if (_internal_margin[MARGIN_LEFT] > 0) { - text_clip -= _internal_margin[MARGIN_LEFT] + get_theme_constant("hseparation"); + if (_internal_margin[SIDE_LEFT] > 0) { + text_clip -= _internal_margin[SIDE_LEFT] + get_theme_constant("hseparation"); } - if (_internal_margin[MARGIN_RIGHT] > 0) { - text_clip -= _internal_margin[MARGIN_RIGHT] + get_theme_constant("hseparation"); + if (_internal_margin[SIDE_RIGHT] > 0) { + text_clip -= _internal_margin[SIDE_RIGHT] + get_theme_constant("hseparation"); } - Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[MARGIN_RIGHT] - _internal_margin[MARGIN_LEFT], 0)) / 2.0; + Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[SIDE_RIGHT] - _internal_margin[SIDE_LEFT], 0)) / 2.0; switch (align) { case ALIGN_LEFT: { if (rtl) { - if (_internal_margin[MARGIN_RIGHT] > 0) { - text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - text_width - _internal_margin[MARGIN_RIGHT] - get_theme_constant("hseparation"); + if (_internal_margin[SIDE_RIGHT] > 0) { + text_ofs.x = size.x - style->get_margin(SIDE_RIGHT) - text_width - _internal_margin[SIDE_RIGHT] - get_theme_constant("hseparation"); } else { - text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - text_width; + text_ofs.x = size.x - style->get_margin(SIDE_RIGHT) - text_width; } } else { - if (_internal_margin[MARGIN_LEFT] > 0) { - text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x + _internal_margin[MARGIN_LEFT] + get_theme_constant("hseparation"); + if (_internal_margin[SIDE_LEFT] > 0) { + text_ofs.x = style->get_margin(SIDE_LEFT) + icon_ofs.x + _internal_margin[SIDE_LEFT] + get_theme_constant("hseparation"); } else { - text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x; + text_ofs.x = style->get_margin(SIDE_LEFT) + icon_ofs.x; } } text_ofs.y += style->get_offset().y; @@ -283,16 +283,16 @@ void Button::_notification(int p_what) { } break; case ALIGN_RIGHT: { if (rtl) { - if (_internal_margin[MARGIN_LEFT] > 0) { - text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x + _internal_margin[MARGIN_LEFT] + get_theme_constant("hseparation"); + if (_internal_margin[SIDE_LEFT] > 0) { + text_ofs.x = style->get_margin(SIDE_LEFT) + icon_ofs.x + _internal_margin[SIDE_LEFT] + get_theme_constant("hseparation"); } else { - text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x; + text_ofs.x = style->get_margin(SIDE_LEFT) + icon_ofs.x; } } else { - if (_internal_margin[MARGIN_RIGHT] > 0) { - text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - text_width - _internal_margin[MARGIN_RIGHT] - get_theme_constant("hseparation"); + if (_internal_margin[SIDE_RIGHT] > 0) { + text_ofs.x = size.x - style->get_margin(SIDE_RIGHT) - text_width - _internal_margin[SIDE_RIGHT] - get_theme_constant("hseparation"); } else { - text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - text_width; + text_ofs.x = size.x - style->get_margin(SIDE_RIGHT) - text_width; } } text_ofs.y += style->get_offset().y; diff --git a/scene/gui/button.h b/scene/gui/button.h index da89e5e6c4..f367448b86 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -63,7 +63,7 @@ private: void _shape(); protected: - void _set_internal_margin(Margin p_margin, float p_value); + void _set_internal_margin(Side p_side, float p_value); void _notification(int p_what); static void _bind_methods(); diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 0c78369688..bb274195f4 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -62,7 +62,7 @@ Size2 CheckBox::get_minimum_size() const { minsize.width += get_theme_constant("hseparation"); } Ref sb = get_theme_stylebox("normal"); - minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM)); + minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(SIDE_TOP) + sb->get_margin(SIDE_BOTTOM)); return minsize; } @@ -70,11 +70,11 @@ Size2 CheckBox::get_minimum_size() const { void CheckBox::_notification(int p_what) { if ((p_what == NOTIFICATION_THEME_CHANGED) || (p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || (p_what == NOTIFICATION_TRANSLATION_CHANGED))) { if (is_layout_rtl()) { - _set_internal_margin(MARGIN_LEFT, 0.f); - _set_internal_margin(MARGIN_RIGHT, get_icon_size().width); + _set_internal_margin(SIDE_LEFT, 0.f); + _set_internal_margin(SIDE_RIGHT, get_icon_size().width); } else { - _set_internal_margin(MARGIN_LEFT, get_icon_size().width); - _set_internal_margin(MARGIN_RIGHT, 0.f); + _set_internal_margin(SIDE_LEFT, get_icon_size().width); + _set_internal_margin(SIDE_RIGHT, 0.f); } } else if (p_what == NOTIFICATION_DRAW) { RID ci = get_canvas_item(); @@ -85,9 +85,9 @@ void CheckBox::_notification(int p_what) { Vector2 ofs; if (is_layout_rtl()) { - ofs.x = get_size().x - sb->get_margin(MARGIN_RIGHT) - get_icon_size().width; + ofs.x = get_size().x - sb->get_margin(SIDE_RIGHT) - get_icon_size().width; } else { - ofs.x = sb->get_margin(MARGIN_LEFT); + ofs.x = sb->get_margin(SIDE_LEFT); } ofs.y = int((get_size().height - get_icon_size().height) / 2) + get_theme_constant("check_vadjust"); @@ -110,9 +110,9 @@ CheckBox::CheckBox(const String &p_text) : set_text_align(ALIGN_LEFT); if (is_layout_rtl()) { - _set_internal_margin(MARGIN_RIGHT, get_icon_size().width); + _set_internal_margin(SIDE_RIGHT, get_icon_size().width); } else { - _set_internal_margin(MARGIN_LEFT, get_icon_size().width); + _set_internal_margin(SIDE_LEFT, get_icon_size().width); } } diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index e58f56a99b..2dd6cd1cb2 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -55,7 +55,7 @@ Size2 CheckButton::get_minimum_size() const { minsize.width += get_theme_constant("hseparation"); } Ref sb = get_theme_stylebox("normal"); - minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM)); + minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(SIDE_TOP) + sb->get_margin(SIDE_BOTTOM)); return minsize; } @@ -63,11 +63,11 @@ Size2 CheckButton::get_minimum_size() const { void CheckButton::_notification(int p_what) { if ((p_what == NOTIFICATION_THEME_CHANGED) || (p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED) || (p_what == NOTIFICATION_TRANSLATION_CHANGED)) { if (is_layout_rtl()) { - _set_internal_margin(MARGIN_LEFT, get_icon_size().width); - _set_internal_margin(MARGIN_RIGHT, 0.f); + _set_internal_margin(SIDE_LEFT, get_icon_size().width); + _set_internal_margin(SIDE_RIGHT, 0.f); } else { - _set_internal_margin(MARGIN_LEFT, 0.f); - _set_internal_margin(MARGIN_RIGHT, get_icon_size().width); + _set_internal_margin(SIDE_LEFT, 0.f); + _set_internal_margin(SIDE_RIGHT, get_icon_size().width); } } else if (p_what == NOTIFICATION_DRAW) { RID ci = get_canvas_item(); @@ -91,9 +91,9 @@ void CheckButton::_notification(int p_what) { Size2 tex_size = get_icon_size(); if (rtl) { - ofs.x = sb->get_margin(MARGIN_LEFT); + ofs.x = sb->get_margin(SIDE_LEFT); } else { - ofs.x = get_size().width - (tex_size.width + sb->get_margin(MARGIN_RIGHT)); + ofs.x = get_size().width - (tex_size.width + sb->get_margin(SIDE_RIGHT)); } ofs.y = (get_size().height - tex_size.height) / 2 + get_theme_constant("check_vadjust"); @@ -109,9 +109,9 @@ CheckButton::CheckButton() { set_toggle_mode(true); set_text_align(ALIGN_LEFT); if (is_layout_rtl()) { - _set_internal_margin(MARGIN_LEFT, get_icon_size().width); + _set_internal_margin(SIDE_LEFT, get_icon_size().width); } else { - _set_internal_margin(MARGIN_RIGHT, get_icon_size().width); + _set_internal_margin(SIDE_RIGHT, get_icon_size().width); } } diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 6ebd1011e9..8b02567d88 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -66,7 +66,7 @@ void ColorPicker::_notification(int p_what) { } break; case NOTIFICATION_PARENTED: { for (int i = 0; i < 4; i++) { - set_margin((Margin)i, get_margin((Margin)i) + get_theme_constant("margin")); + set_offset((Side)i, get_offset((Side)i) + get_theme_constant("margin")); } } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -611,7 +611,7 @@ void ColorPicker::_screen_pick_pressed() { screen = memnew(Control); r->add_child(screen); screen->set_as_top_level(true); - screen->set_anchors_and_margins_preset(Control::PRESET_WIDE); + screen->set_anchors_and_offsets_preset(Control::PRESET_WIDE); screen->set_default_cursor_shape(CURSOR_POINTING_HAND); screen->connect("gui_input", callable_mp(this, &ColorPicker::_screen_input)); // It immediately toggles off in the first press otherwise. @@ -973,7 +973,7 @@ void ColorPickerButton::_update_picker() { popup = memnew(PopupPanel); popup->set_wrap_controls(true); picker = memnew(ColorPicker); - picker->set_anchors_and_margins_preset(PRESET_WIDE); + picker->set_anchors_and_offsets_preset(PRESET_WIDE); popup->add_child(picker); add_child(popup); picker->connect("color_changed", callable_mp(this, &ColorPickerButton::_color_changed)); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index bc37045386..62cbec4ae5 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -58,17 +58,17 @@ Dictionary Control::_edit_get_state() const { s["scale"] = get_scale(); s["pivot"] = get_pivot_offset(); Array anchors; - anchors.push_back(get_anchor(MARGIN_LEFT)); - anchors.push_back(get_anchor(MARGIN_TOP)); - anchors.push_back(get_anchor(MARGIN_RIGHT)); - anchors.push_back(get_anchor(MARGIN_BOTTOM)); + anchors.push_back(get_anchor(SIDE_LEFT)); + anchors.push_back(get_anchor(SIDE_TOP)); + anchors.push_back(get_anchor(SIDE_RIGHT)); + anchors.push_back(get_anchor(SIDE_BOTTOM)); s["anchors"] = anchors; - Array margins; - margins.push_back(get_margin(MARGIN_LEFT)); - margins.push_back(get_margin(MARGIN_TOP)); - margins.push_back(get_margin(MARGIN_RIGHT)); - margins.push_back(get_margin(MARGIN_BOTTOM)); - s["margins"] = margins; + Array offsets; + offsets.push_back(get_offset(SIDE_LEFT)); + offsets.push_back(get_offset(SIDE_TOP)); + offsets.push_back(get_offset(SIDE_RIGHT)); + offsets.push_back(get_offset(SIDE_BOTTOM)); + s["offsets"] = offsets; return s; } @@ -79,15 +79,15 @@ void Control::_edit_set_state(const Dictionary &p_state) { set_scale(state["scale"]); set_pivot_offset(state["pivot"]); Array anchors = state["anchors"]; - data.anchor[MARGIN_LEFT] = anchors[0]; - data.anchor[MARGIN_TOP] = anchors[1]; - data.anchor[MARGIN_RIGHT] = anchors[2]; - data.anchor[MARGIN_BOTTOM] = anchors[3]; - Array margins = state["margins"]; - data.margin[MARGIN_LEFT] = margins[0]; - data.margin[MARGIN_TOP] = margins[1]; - data.margin[MARGIN_RIGHT] = margins[2]; - data.margin[MARGIN_BOTTOM] = margins[3]; + data.anchor[SIDE_LEFT] = anchors[0]; + data.anchor[SIDE_TOP] = anchors[1]; + data.anchor[SIDE_RIGHT] = anchors[2]; + data.anchor[SIDE_BOTTOM] = anchors[3]; + Array offsets = state["offsets"]; + data.offset[SIDE_LEFT] = offsets[0]; + data.offset[SIDE_TOP] = offsets[1]; + data.offset[SIDE_RIGHT] = offsets[2]; + data.offset[SIDE_BOTTOM] = offsets[3]; _size_changed(); } @@ -1227,15 +1227,15 @@ Size2 Control::get_parent_area_size() const { void Control::_size_changed() { Rect2 parent_rect = get_parent_anchorable_rect(); - float margin_pos[4]; + float edge_pos[4]; for (int i = 0; i < 4; i++) { float area = parent_rect.size[i & 1]; - margin_pos[i] = data.margin[i] + (data.anchor[i] * area); + edge_pos[i] = data.offset[i] + (data.anchor[i] * area); } - Point2 new_pos_cache = Point2(margin_pos[0], margin_pos[1]); - Size2 new_size_cache = Point2(margin_pos[2], margin_pos[3]) - new_pos_cache; + Point2 new_pos_cache = Point2(edge_pos[0], edge_pos[1]); + Size2 new_size_cache = Point2(edge_pos[2], edge_pos[3]) - new_pos_cache; Size2 minimum_size = get_combined_minimum_size(); @@ -1275,7 +1275,7 @@ void Control::_size_changed() { } if (pos_changed || size_changed) { item_rect_changed(size_changed); - _change_notify_margins(); + _change_notify_offsets(); _notify_transform(); } @@ -1285,29 +1285,29 @@ void Control::_size_changed() { } } -void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bool p_push_opposite_anchor) { - ERR_FAIL_INDEX((int)p_margin, 4); +void Control::set_anchor(Side p_side, float p_anchor, bool p_keep_offset, bool p_push_opposite_anchor) { + ERR_FAIL_INDEX((int)p_side, 4); Rect2 parent_rect = get_parent_anchorable_rect(); - float parent_range = (p_margin == MARGIN_LEFT || p_margin == MARGIN_RIGHT) ? parent_rect.size.x : parent_rect.size.y; - float previous_margin_pos = data.margin[p_margin] + data.anchor[p_margin] * parent_range; - float previous_opposite_margin_pos = data.margin[(p_margin + 2) % 4] + data.anchor[(p_margin + 2) % 4] * parent_range; + float parent_range = (p_side == SIDE_LEFT || p_side == SIDE_RIGHT) ? parent_rect.size.x : parent_rect.size.y; + float previous_pos = data.offset[p_side] + data.anchor[p_side] * parent_range; + float previous_opposite_pos = data.offset[(p_side + 2) % 4] + data.anchor[(p_side + 2) % 4] * parent_range; - data.anchor[p_margin] = p_anchor; + data.anchor[p_side] = p_anchor; - if (((p_margin == MARGIN_LEFT || p_margin == MARGIN_TOP) && data.anchor[p_margin] > data.anchor[(p_margin + 2) % 4]) || - ((p_margin == MARGIN_RIGHT || p_margin == MARGIN_BOTTOM) && data.anchor[p_margin] < data.anchor[(p_margin + 2) % 4])) { + if (((p_side == SIDE_LEFT || p_side == SIDE_TOP) && data.anchor[p_side] > data.anchor[(p_side + 2) % 4]) || + ((p_side == SIDE_RIGHT || p_side == SIDE_BOTTOM) && data.anchor[p_side] < data.anchor[(p_side + 2) % 4])) { if (p_push_opposite_anchor) { - data.anchor[(p_margin + 2) % 4] = data.anchor[p_margin]; + data.anchor[(p_side + 2) % 4] = data.anchor[p_side]; } else { - data.anchor[p_margin] = data.anchor[(p_margin + 2) % 4]; + data.anchor[p_side] = data.anchor[(p_side + 2) % 4]; } } - if (!p_keep_margin) { - data.margin[p_margin] = previous_margin_pos - data.anchor[p_margin] * parent_range; + if (!p_keep_offset) { + data.offset[p_side] = previous_pos - data.anchor[p_side] * parent_range; if (p_push_opposite_anchor) { - data.margin[(p_margin + 2) % 4] = previous_opposite_margin_pos - data.anchor[(p_margin + 2) % 4] * parent_range; + data.offset[(p_side + 2) % 4] = previous_opposite_pos - data.anchor[(p_side + 2) % 4] * parent_range; } } if (is_inside_tree()) { @@ -1321,16 +1321,16 @@ void Control::set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin, bo _change_notify("anchor_bottom"); } -void Control::_set_anchor(Margin p_margin, float p_anchor) { - set_anchor(p_margin, p_anchor); +void Control::_set_anchor(Side p_side, float p_anchor) { + set_anchor(p_side, p_anchor); } -void Control::set_anchor_and_margin(Margin p_margin, float p_anchor, float p_pos, bool p_push_opposite_anchor) { - set_anchor(p_margin, p_anchor, false, p_push_opposite_anchor); - set_margin(p_margin, p_pos); +void Control::set_anchor_and_offset(Side p_side, float p_anchor, float p_pos, bool p_push_opposite_anchor) { + set_anchor(p_side, p_anchor, false, p_push_opposite_anchor); + set_offset(p_side, p_pos); } -void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { +void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets) { ERR_FAIL_INDEX((int)p_preset, 16); //Left @@ -1343,21 +1343,21 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { case PRESET_LEFT_WIDE: case PRESET_HCENTER_WIDE: case PRESET_WIDE: - set_anchor(MARGIN_LEFT, ANCHOR_BEGIN, p_keep_margins); + set_anchor(SIDE_LEFT, ANCHOR_BEGIN, p_keep_offsets); break; case PRESET_CENTER_TOP: case PRESET_CENTER_BOTTOM: case PRESET_CENTER: case PRESET_VCENTER_WIDE: - set_anchor(MARGIN_LEFT, 0.5, p_keep_margins); + set_anchor(SIDE_LEFT, 0.5, p_keep_offsets); break; case PRESET_TOP_RIGHT: case PRESET_BOTTOM_RIGHT: case PRESET_CENTER_RIGHT: case PRESET_RIGHT_WIDE: - set_anchor(MARGIN_LEFT, ANCHOR_END, p_keep_margins); + set_anchor(SIDE_LEFT, ANCHOR_END, p_keep_offsets); break; } @@ -1371,21 +1371,21 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { case PRESET_TOP_WIDE: case PRESET_VCENTER_WIDE: case PRESET_WIDE: - set_anchor(MARGIN_TOP, ANCHOR_BEGIN, p_keep_margins); + set_anchor(SIDE_TOP, ANCHOR_BEGIN, p_keep_offsets); break; case PRESET_CENTER_LEFT: case PRESET_CENTER_RIGHT: case PRESET_CENTER: case PRESET_HCENTER_WIDE: - set_anchor(MARGIN_TOP, 0.5, p_keep_margins); + set_anchor(SIDE_TOP, 0.5, p_keep_offsets); break; case PRESET_BOTTOM_LEFT: case PRESET_BOTTOM_RIGHT: case PRESET_CENTER_BOTTOM: case PRESET_BOTTOM_WIDE: - set_anchor(MARGIN_TOP, ANCHOR_END, p_keep_margins); + set_anchor(SIDE_TOP, ANCHOR_END, p_keep_offsets); break; } @@ -1395,14 +1395,14 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { case PRESET_BOTTOM_LEFT: case PRESET_CENTER_LEFT: case PRESET_LEFT_WIDE: - set_anchor(MARGIN_RIGHT, ANCHOR_BEGIN, p_keep_margins); + set_anchor(SIDE_RIGHT, ANCHOR_BEGIN, p_keep_offsets); break; case PRESET_CENTER_TOP: case PRESET_CENTER_BOTTOM: case PRESET_CENTER: case PRESET_VCENTER_WIDE: - set_anchor(MARGIN_RIGHT, 0.5, p_keep_margins); + set_anchor(SIDE_RIGHT, 0.5, p_keep_offsets); break; case PRESET_TOP_RIGHT: @@ -1413,7 +1413,7 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { case PRESET_BOTTOM_WIDE: case PRESET_HCENTER_WIDE: case PRESET_WIDE: - set_anchor(MARGIN_RIGHT, ANCHOR_END, p_keep_margins); + set_anchor(SIDE_RIGHT, ANCHOR_END, p_keep_offsets); break; } @@ -1423,14 +1423,14 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { case PRESET_TOP_RIGHT: case PRESET_CENTER_TOP: case PRESET_TOP_WIDE: - set_anchor(MARGIN_BOTTOM, ANCHOR_BEGIN, p_keep_margins); + set_anchor(SIDE_BOTTOM, ANCHOR_BEGIN, p_keep_offsets); break; case PRESET_CENTER_LEFT: case PRESET_CENTER_RIGHT: case PRESET_CENTER: case PRESET_HCENTER_WIDE: - set_anchor(MARGIN_BOTTOM, 0.5, p_keep_margins); + set_anchor(SIDE_BOTTOM, 0.5, p_keep_offsets); break; case PRESET_BOTTOM_LEFT: @@ -1441,12 +1441,12 @@ void Control::set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins) { case PRESET_BOTTOM_WIDE: case PRESET_VCENTER_WIDE: case PRESET_WIDE: - set_anchor(MARGIN_BOTTOM, ANCHOR_END, p_keep_margins); + set_anchor(SIDE_BOTTOM, ANCHOR_END, p_keep_offsets); break; } } -void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) { +void Control::set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) { ERR_FAIL_INDEX((int)p_preset, 16); ERR_FAIL_INDEX((int)p_resize_mode, 4); @@ -1476,21 +1476,21 @@ void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz case PRESET_LEFT_WIDE: case PRESET_HCENTER_WIDE: case PRESET_WIDE: - data.margin[0] = x * (0.0 - data.anchor[0]) + p_margin + parent_rect.position.x; + data.offset[0] = x * (0.0 - data.anchor[0]) + p_margin + parent_rect.position.x; break; case PRESET_CENTER_TOP: case PRESET_CENTER_BOTTOM: case PRESET_CENTER: case PRESET_VCENTER_WIDE: - data.margin[0] = x * (0.5 - data.anchor[0]) - new_size.x / 2 + parent_rect.position.x; + data.offset[0] = x * (0.5 - data.anchor[0]) - new_size.x / 2 + parent_rect.position.x; break; case PRESET_TOP_RIGHT: case PRESET_BOTTOM_RIGHT: case PRESET_CENTER_RIGHT: case PRESET_RIGHT_WIDE: - data.margin[0] = x * (1.0 - data.anchor[0]) - new_size.x - p_margin + parent_rect.position.x; + data.offset[0] = x * (1.0 - data.anchor[0]) - new_size.x - p_margin + parent_rect.position.x; break; } @@ -1504,21 +1504,21 @@ void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz case PRESET_TOP_WIDE: case PRESET_VCENTER_WIDE: case PRESET_WIDE: - data.margin[1] = parent_rect.size.y * (0.0 - data.anchor[1]) + p_margin + parent_rect.position.y; + data.offset[1] = parent_rect.size.y * (0.0 - data.anchor[1]) + p_margin + parent_rect.position.y; break; case PRESET_CENTER_LEFT: case PRESET_CENTER_RIGHT: case PRESET_CENTER: case PRESET_HCENTER_WIDE: - data.margin[1] = parent_rect.size.y * (0.5 - data.anchor[1]) - new_size.y / 2 + parent_rect.position.y; + data.offset[1] = parent_rect.size.y * (0.5 - data.anchor[1]) - new_size.y / 2 + parent_rect.position.y; break; case PRESET_BOTTOM_LEFT: case PRESET_BOTTOM_RIGHT: case PRESET_CENTER_BOTTOM: case PRESET_BOTTOM_WIDE: - data.margin[1] = parent_rect.size.y * (1.0 - data.anchor[1]) - new_size.y - p_margin + parent_rect.position.y; + data.offset[1] = parent_rect.size.y * (1.0 - data.anchor[1]) - new_size.y - p_margin + parent_rect.position.y; break; } @@ -1528,14 +1528,14 @@ void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz case PRESET_BOTTOM_LEFT: case PRESET_CENTER_LEFT: case PRESET_LEFT_WIDE: - data.margin[2] = x * (0.0 - data.anchor[2]) + new_size.x + p_margin + parent_rect.position.x; + data.offset[2] = x * (0.0 - data.anchor[2]) + new_size.x + p_margin + parent_rect.position.x; break; case PRESET_CENTER_TOP: case PRESET_CENTER_BOTTOM: case PRESET_CENTER: case PRESET_VCENTER_WIDE: - data.margin[2] = x * (0.5 - data.anchor[2]) + new_size.x / 2 + parent_rect.position.x; + data.offset[2] = x * (0.5 - data.anchor[2]) + new_size.x / 2 + parent_rect.position.x; break; case PRESET_TOP_RIGHT: @@ -1546,7 +1546,7 @@ void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz case PRESET_BOTTOM_WIDE: case PRESET_HCENTER_WIDE: case PRESET_WIDE: - data.margin[2] = x * (1.0 - data.anchor[2]) - p_margin + parent_rect.position.x; + data.offset[2] = x * (1.0 - data.anchor[2]) - p_margin + parent_rect.position.x; break; } @@ -1556,14 +1556,14 @@ void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz case PRESET_TOP_RIGHT: case PRESET_CENTER_TOP: case PRESET_TOP_WIDE: - data.margin[3] = parent_rect.size.y * (0.0 - data.anchor[3]) + new_size.y + p_margin + parent_rect.position.y; + data.offset[3] = parent_rect.size.y * (0.0 - data.anchor[3]) + new_size.y + p_margin + parent_rect.position.y; break; case PRESET_CENTER_LEFT: case PRESET_CENTER_RIGHT: case PRESET_CENTER: case PRESET_HCENTER_WIDE: - data.margin[3] = parent_rect.size.y * (0.5 - data.anchor[3]) + new_size.y / 2 + parent_rect.position.y; + data.offset[3] = parent_rect.size.y * (0.5 - data.anchor[3]) + new_size.y / 2 + parent_rect.position.y; break; case PRESET_BOTTOM_LEFT: @@ -1574,65 +1574,65 @@ void Control::set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resiz case PRESET_BOTTOM_WIDE: case PRESET_VCENTER_WIDE: case PRESET_WIDE: - data.margin[3] = parent_rect.size.y * (1.0 - data.anchor[3]) - p_margin + parent_rect.position.y; + data.offset[3] = parent_rect.size.y * (1.0 - data.anchor[3]) - p_margin + parent_rect.position.y; break; } _size_changed(); } -void Control::set_anchors_and_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) { +void Control::set_anchors_and_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode, int p_margin) { set_anchors_preset(p_preset); - set_margins_preset(p_preset, p_resize_mode, p_margin); + set_offsets_preset(p_preset, p_resize_mode, p_margin); } -float Control::get_anchor(Margin p_margin) const { - ERR_FAIL_INDEX_V(int(p_margin), 4, 0.0); +float Control::get_anchor(Side p_side) const { + ERR_FAIL_INDEX_V(int(p_side), 4, 0.0); - return data.anchor[p_margin]; + return data.anchor[p_side]; } -void Control::_change_notify_margins() { +void Control::_change_notify_offsets() { // this avoids sending the whole object data again on a change - _change_notify("margin_left"); - _change_notify("margin_top"); - _change_notify("margin_right"); - _change_notify("margin_bottom"); + _change_notify("offset_left"); + _change_notify("offset_top"); + _change_notify("offset_right"); + _change_notify("offset_bottom"); _change_notify("rect_position"); _change_notify("rect_size"); } -void Control::set_margin(Margin p_margin, float p_value) { - ERR_FAIL_INDEX((int)p_margin, 4); +void Control::set_offset(Side p_side, float p_value) { + ERR_FAIL_INDEX((int)p_side, 4); - data.margin[p_margin] = p_value; + data.offset[p_side] = p_value; _size_changed(); } void Control::set_begin(const Size2 &p_point) { - data.margin[0] = p_point.x; - data.margin[1] = p_point.y; + data.offset[0] = p_point.x; + data.offset[1] = p_point.y; _size_changed(); } void Control::set_end(const Size2 &p_point) { - data.margin[2] = p_point.x; - data.margin[3] = p_point.y; + data.offset[2] = p_point.x; + data.offset[3] = p_point.y; _size_changed(); } -float Control::get_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); +float Control::get_offset(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0); - return data.margin[p_margin]; + return data.offset[p_side]; } Size2 Control::get_begin() const { - return Size2(data.margin[0], data.margin[1]); + return Size2(data.offset[0], data.offset[1]); } Size2 Control::get_end() const { - return Size2(data.margin[2], data.margin[3]); + return Size2(data.offset[2], data.offset[3]); } Point2 Control::get_global_position() const { @@ -1654,17 +1654,17 @@ void Control::_set_global_position(const Point2 &p_point) { set_global_position(p_point); } -void Control::set_global_position(const Point2 &p_point, bool p_keep_margins) { +void Control::set_global_position(const Point2 &p_point, bool p_keep_offsets) { Transform2D inv; if (data.parent_canvas_item) { inv = data.parent_canvas_item->get_global_transform().affine_inverse(); } - set_position(inv.xform(p_point), p_keep_margins); + set_position(inv.xform(p_point), p_keep_offsets); } -void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r_anchors)[4]) { +void Control::_compute_anchors(Rect2 p_rect, const float p_offsets[4], float (&r_anchors)[4]) { Size2 parent_rect_size = get_parent_anchorable_rect().size; ERR_FAIL_COND(parent_rect_size.x == 0.0); ERR_FAIL_COND(parent_rect_size.y == 0.0); @@ -1673,38 +1673,38 @@ void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r if (is_layout_rtl()) { x = parent_rect_size.x - x - p_rect.size.x; } - r_anchors[0] = (x - p_margins[0]) / parent_rect_size.x; - r_anchors[1] = (p_rect.position.y - p_margins[1]) / parent_rect_size.y; - r_anchors[2] = (x + p_rect.size.x - p_margins[2]) / parent_rect_size.x; - r_anchors[3] = (p_rect.position.y + p_rect.size.y - p_margins[3]) / parent_rect_size.y; + r_anchors[0] = (x - p_offsets[0]) / parent_rect_size.x; + r_anchors[1] = (p_rect.position.y - p_offsets[1]) / parent_rect_size.y; + r_anchors[2] = (x + p_rect.size.x - p_offsets[2]) / parent_rect_size.x; + r_anchors[3] = (p_rect.position.y + p_rect.size.y - p_offsets[3]) / parent_rect_size.y; } -void Control::_compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]) { +void Control::_compute_offsets(Rect2 p_rect, const float p_anchors[4], float (&r_offsets)[4]) { Size2 parent_rect_size = get_parent_anchorable_rect().size; float x = p_rect.position.x; if (is_layout_rtl()) { x = parent_rect_size.x - x - p_rect.size.x; } - r_margins[0] = x - (p_anchors[0] * parent_rect_size.x); - r_margins[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y); - r_margins[2] = x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x); - r_margins[3] = p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y); + r_offsets[0] = x - (p_anchors[0] * parent_rect_size.x); + r_offsets[1] = p_rect.position.y - (p_anchors[1] * parent_rect_size.y); + r_offsets[2] = x + p_rect.size.x - (p_anchors[2] * parent_rect_size.x); + r_offsets[3] = p_rect.position.y + p_rect.size.y - (p_anchors[3] * parent_rect_size.y); } void Control::_set_position(const Size2 &p_point) { set_position(p_point); } -void Control::set_position(const Size2 &p_point, bool p_keep_margins) { - if (p_keep_margins) { - _compute_anchors(Rect2(p_point, data.size_cache), data.margin, data.anchor); +void Control::set_position(const Size2 &p_point, bool p_keep_offsets) { + if (p_keep_offsets) { + _compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor); _change_notify("anchor_left"); _change_notify("anchor_right"); _change_notify("anchor_top"); _change_notify("anchor_bottom"); } else { - _compute_margins(Rect2(p_point, data.size_cache), data.anchor, data.margin); + _compute_offsets(Rect2(p_point, data.size_cache), data.anchor, data.offset); } _size_changed(); } @@ -1714,7 +1714,7 @@ void Control::set_rect(const Rect2 &p_rect) { data.anchor[i] = ANCHOR_BEGIN; } - _compute_margins(p_rect, data.anchor, data.margin); + _compute_offsets(p_rect, data.anchor, data.offset); if (is_inside_tree()) { _size_changed(); } @@ -1724,7 +1724,7 @@ void Control::_set_size(const Size2 &p_size) { set_size(p_size); } -void Control::set_size(const Size2 &p_size, bool p_keep_margins) { +void Control::set_size(const Size2 &p_size, bool p_keep_offsets) { Size2 new_size = p_size; Size2 min = get_combined_minimum_size(); if (new_size.x < min.x) { @@ -1734,14 +1734,14 @@ void Control::set_size(const Size2 &p_size, bool p_keep_margins) { new_size.y = min.y; } - if (p_keep_margins) { - _compute_anchors(Rect2(data.pos_cache, new_size), data.margin, data.anchor); + if (p_keep_offsets) { + _compute_anchors(Rect2(data.pos_cache, new_size), data.offset, data.anchor); _change_notify("anchor_left"); _change_notify("anchor_right"); _change_notify("anchor_top"); _change_notify("anchor_bottom"); } else { - _compute_margins(Rect2(data.pos_cache, new_size), data.anchor, data.margin); + _compute_offsets(Rect2(data.pos_cache, new_size), data.anchor, data.offset); } _size_changed(); } @@ -2206,14 +2206,14 @@ String Control::_get_tooltip() const { return data.tooltip; } -void Control::set_focus_neighbor(Margin p_margin, const NodePath &p_neighbor) { - ERR_FAIL_INDEX((int)p_margin, 4); - data.focus_neighbor[p_margin] = p_neighbor; +void Control::set_focus_neighbor(Side p_side, const NodePath &p_neighbor) { + ERR_FAIL_INDEX((int)p_side, 4); + data.focus_neighbor[p_side] = p_neighbor; } -NodePath Control::get_focus_neighbor(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, NodePath()); - return data.focus_neighbor[p_margin]; +NodePath Control::get_focus_neighbor(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, NodePath()); + return data.focus_neighbor[p_side]; } void Control::set_focus_next(const NodePath &p_next) { @@ -2234,15 +2234,15 @@ NodePath Control::get_focus_previous() const { #define MAX_NEIGHBOR_SEARCH_COUNT 512 -Control *Control::_get_focus_neighbor(Margin p_margin, int p_count) { - ERR_FAIL_INDEX_V((int)p_margin, 4, nullptr); +Control *Control::_get_focus_neighbor(Side p_side, int p_count) { + ERR_FAIL_INDEX_V((int)p_side, 4, nullptr); if (p_count >= MAX_NEIGHBOR_SEARCH_COUNT) { return nullptr; } - if (!data.focus_neighbor[p_margin].is_empty()) { + if (!data.focus_neighbor[p_side].is_empty()) { Control *c = nullptr; - Node *n = get_node(data.focus_neighbor[p_margin]); + Node *n = get_node(data.focus_neighbor[p_side]); if (n) { c = Object::cast_to(n); ERR_FAIL_COND_V_MSG(!c, nullptr, "Neighbor focus node is not a control: " + n->get_name() + "."); @@ -2260,7 +2260,7 @@ Control *Control::_get_focus_neighbor(Margin p_margin, int p_count) { return c; } - c = c->_get_focus_neighbor(p_margin, p_count + 1); + c = c->_get_focus_neighbor(p_side, p_count + 1); return c; } @@ -2283,7 +2283,7 @@ Control *Control::_get_focus_neighbor(Margin p_margin, int p_count) { Vector2(0, 1) }; - Vector2 vdir = dir[p_margin]; + Vector2 vdir = dir[p_side]; float maxd = -1e7; @@ -2745,28 +2745,28 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("accept_event"), &Control::accept_event); ClassDB::bind_method(D_METHOD("get_minimum_size"), &Control::get_minimum_size); ClassDB::bind_method(D_METHOD("get_combined_minimum_size"), &Control::get_combined_minimum_size); - ClassDB::bind_method(D_METHOD("set_anchors_preset", "preset", "keep_margins"), &Control::set_anchors_preset, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("set_margins_preset", "preset", "resize_mode", "margin"), &Control::set_margins_preset, DEFVAL(PRESET_MODE_MINSIZE), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("set_anchors_and_margins_preset", "preset", "resize_mode", "margin"), &Control::set_anchors_and_margins_preset, DEFVAL(PRESET_MODE_MINSIZE), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("_set_anchor", "margin", "anchor"), &Control::_set_anchor); - ClassDB::bind_method(D_METHOD("set_anchor", "margin", "anchor", "keep_margin", "push_opposite_anchor"), &Control::set_anchor, DEFVAL(false), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_anchor", "margin"), &Control::get_anchor); - ClassDB::bind_method(D_METHOD("set_margin", "margin", "offset"), &Control::set_margin); - ClassDB::bind_method(D_METHOD("set_anchor_and_margin", "margin", "anchor", "offset", "push_opposite_anchor"), &Control::set_anchor_and_margin, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("set_anchors_preset", "preset", "keep_offsets"), &Control::set_anchors_preset, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("set_offsets_preset", "preset", "resize_mode", "margin"), &Control::set_offsets_preset, DEFVAL(PRESET_MODE_MINSIZE), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_anchors_and_offsets_preset", "preset", "resize_mode", "margin"), &Control::set_anchors_and_offsets_preset, DEFVAL(PRESET_MODE_MINSIZE), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("_set_anchor", "side", "anchor"), &Control::_set_anchor); + ClassDB::bind_method(D_METHOD("set_anchor", "side", "anchor", "keep_offset", "push_opposite_anchor"), &Control::set_anchor, DEFVAL(false), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("get_anchor", "side"), &Control::get_anchor); + ClassDB::bind_method(D_METHOD("set_offset", "side", "offset"), &Control::set_offset); + ClassDB::bind_method(D_METHOD("set_anchor_and_offset", "side", "anchor", "offset", "push_opposite_anchor"), &Control::set_anchor_and_offset, DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_begin", "position"), &Control::set_begin); ClassDB::bind_method(D_METHOD("set_end", "position"), &Control::set_end); - ClassDB::bind_method(D_METHOD("set_position", "position", "keep_margins"), &Control::set_position, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("_set_position", "margin"), &Control::_set_position); - ClassDB::bind_method(D_METHOD("set_size", "size", "keep_margins"), &Control::set_size, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("set_position", "position", "keep_offsets"), &Control::set_position, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("_set_position", "position"), &Control::_set_position); + ClassDB::bind_method(D_METHOD("set_size", "size", "keep_offsets"), &Control::set_size, DEFVAL(false)); ClassDB::bind_method(D_METHOD("_set_size", "size"), &Control::_set_size); ClassDB::bind_method(D_METHOD("set_custom_minimum_size", "size"), &Control::set_custom_minimum_size); - ClassDB::bind_method(D_METHOD("set_global_position", "position", "keep_margins"), &Control::set_global_position, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("set_global_position", "position", "keep_offsets"), &Control::set_global_position, DEFVAL(false)); ClassDB::bind_method(D_METHOD("_set_global_position", "position"), &Control::_set_global_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation); ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Control::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale); ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset); - ClassDB::bind_method(D_METHOD("get_margin", "margin"), &Control::get_margin); + ClassDB::bind_method(D_METHOD("get_offset", "offset"), &Control::get_offset); ClassDB::bind_method(D_METHOD("get_begin"), &Control::get_begin); ClassDB::bind_method(D_METHOD("get_end"), &Control::get_end); ClassDB::bind_method(D_METHOD("get_position"), &Control::get_position); @@ -2843,8 +2843,8 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_default_cursor_shape"), &Control::get_default_cursor_shape); ClassDB::bind_method(D_METHOD("get_cursor_shape", "position"), &Control::get_cursor_shape, DEFVAL(Point2())); - ClassDB::bind_method(D_METHOD("set_focus_neighbor", "margin", "neighbor"), &Control::set_focus_neighbor); - ClassDB::bind_method(D_METHOD("get_focus_neighbor", "margin"), &Control::get_focus_neighbor); + ClassDB::bind_method(D_METHOD("set_focus_neighbor", "side", "neighbor"), &Control::set_focus_neighbor); + ClassDB::bind_method(D_METHOD("get_focus_neighbor", "side"), &Control::get_focus_neighbor); ClassDB::bind_method(D_METHOD("set_focus_next", "next"), &Control::set_focus_next); ClassDB::bind_method(D_METHOD("get_focus_next"), &Control::get_focus_next); @@ -2890,16 +2890,16 @@ void Control::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::BOOL, "_clips_input")); ADD_GROUP("Anchor", "anchor_"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_left", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_top", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_right", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_bottom", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_left", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_top", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_right", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "anchor_bottom", PROPERTY_HINT_RANGE, "0,1,0.001,or_lesser,or_greater"), "_set_anchor", "get_anchor", SIDE_BOTTOM); - ADD_GROUP("Margin", "margin_"); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "margin_left", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin", "get_margin", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "margin_top", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin", "get_margin", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "margin_right", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin", "get_margin", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "margin_bottom", PROPERTY_HINT_RANGE, "-4096,4096"), "set_margin", "get_margin", MARGIN_BOTTOM); + ADD_GROUP("Offset", "offset_"); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "offset_left", PROPERTY_HINT_RANGE, "-4096,4096"), "set_offset", "get_offset", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "offset_top", PROPERTY_HINT_RANGE, "-4096,4096"), "set_offset", "get_offset", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "offset_right", PROPERTY_HINT_RANGE, "-4096,4096"), "set_offset", "get_offset", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "offset_bottom", PROPERTY_HINT_RANGE, "-4096,4096"), "set_offset", "get_offset", SIDE_BOTTOM); ADD_GROUP("Grow Direction", "grow_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "grow_horizontal", PROPERTY_HINT_ENUM, "Begin,End,Both"), "set_h_grow_direction", "get_h_grow_direction"); @@ -2922,10 +2922,10 @@ void Control::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), "set_tooltip", "_get_tooltip"); ADD_GROUP("Focus", "focus_"); - ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_left", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_top", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_right", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_bottom", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_left", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_top", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_right", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::NODE_PATH, "focus_neighbor_bottom", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_neighbor", "get_focus_neighbor", SIDE_BOTTOM); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "focus_next", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_next", "get_focus_next"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "focus_previous", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Control"), "set_focus_previous", "get_focus_previous"); ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_focus_mode", "get_focus_mode"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 2241c242bb..ea336e3c59 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -171,7 +171,7 @@ private: Size2 last_minimum_size; bool updating_last_minimum_size = false; - float margin[4] = { 0.0, 0.0, 0.0, 0.0 }; + float offset[4] = { 0.0, 0.0, 0.0, 0.0 }; float anchor[4] = { ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN, ANCHOR_BEGIN }; FocusMode focus_mode = FOCUS_NONE; GrowDirection h_grow = GROW_DIRECTION_END; @@ -224,22 +224,22 @@ private: Control *_find_control_at_pos(CanvasItem *p_node, const Point2 &p_pos, const Transform2D &p_xform, Transform2D &r_inv_xform); void _window_find_focus_neighbor(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest); - Control *_get_focus_neighbor(Margin p_margin, int p_count = 0); + Control *_get_focus_neighbor(Side p_side, int p_count = 0); - void _set_anchor(Margin p_margin, float p_anchor); + void _set_anchor(Side p_side, float p_anchor); void _set_position(const Point2 &p_point); void _set_global_position(const Point2 &p_point); void _set_size(const Size2 &p_size); void _theme_changed(); - void _change_notify_margins(); + void _change_notify_offsets(); void _update_minimum_size(); void _update_scroll(); - void _compute_margins(Rect2 p_rect, const float p_anchors[4], float (&r_margins)[4]); - void _compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r_anchors)[4]); + void _compute_offsets(Rect2 p_rect, const float p_anchors[4], float (&r_offsets)[4]); + void _compute_anchors(Rect2 p_rect, const float p_offsets[4], float (&r_anchors)[4]); void _size_changed(); String _get_tooltip() const; @@ -359,17 +359,17 @@ public: /* POSITIONING */ - void set_anchors_preset(LayoutPreset p_preset, bool p_keep_margins = true); - void set_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0); - void set_anchors_and_margins_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0); + void set_anchors_preset(LayoutPreset p_preset, bool p_keep_offsets = true); + void set_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0); + void set_anchors_and_offsets_preset(LayoutPreset p_preset, LayoutPresetMode p_resize_mode = PRESET_MODE_MINSIZE, int p_margin = 0); - void set_anchor(Margin p_margin, float p_anchor, bool p_keep_margin = true, bool p_push_opposite_anchor = true); - float get_anchor(Margin p_margin) const; + void set_anchor(Side p_side, float p_anchor, bool p_keep_offset = true, bool p_push_opposite_anchor = true); + float get_anchor(Side p_side) const; - void set_margin(Margin p_margin, float p_value); - float get_margin(Margin p_margin) const; + void set_offset(Side p_side, float p_value); + float get_offset(Side p_side) const; - void set_anchor_and_margin(Margin p_margin, float p_anchor, float p_pos, bool p_push_opposite_anchor = true); + void set_anchor_and_offset(Side p_side, float p_anchor, float p_pos, bool p_push_opposite_anchor = true); void set_begin(const Point2 &p_point); // helper void set_end(const Point2 &p_point); // helper @@ -377,13 +377,13 @@ public: Point2 get_begin() const; Point2 get_end() const; - void set_position(const Point2 &p_point, bool p_keep_margins = false); - void set_global_position(const Point2 &p_point, bool p_keep_margins = false); + void set_position(const Point2 &p_point, bool p_keep_offsets = false); + void set_global_position(const Point2 &p_point, bool p_keep_offsets = false); Point2 get_position() const; Point2 get_global_position() const; Point2 get_screen_position() const; - void set_size(const Size2 &p_size, bool p_keep_margins = false); + void set_size(const Size2 &p_size, bool p_keep_offsets = false); Size2 get_size() const; Rect2 get_rect() const; @@ -436,8 +436,8 @@ public: Control *find_next_valid_focus() const; Control *find_prev_valid_focus() const; - void set_focus_neighbor(Margin p_margin, const NodePath &p_neighbor); - NodePath get_focus_neighbor(Margin p_margin) const; + void set_focus_neighbor(Side p_side, const NodePath &p_neighbor); + NodePath get_focus_neighbor(Side p_side) const; void set_focus_next(const NodePath &p_next); NodePath get_focus_next() const; diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 4e80498108..9f5f6c21c8 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -309,8 +309,8 @@ AcceptDialog::AcceptDialog() { int button_margin = hbc->get_theme_constant("button_margin", "Dialogs"); label = memnew(Label); - label->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END); - label->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END); + label->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); + label->set_anchor(SIDE_BOTTOM, Control::ANCHOR_END); label->set_begin(Point2(margin, margin)); label->set_end(Point2(-margin, -button_margin - 10)); add_child(label); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 2bcc1890fe..6c2d414ea9 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -276,7 +276,7 @@ void GraphEdit::_update_scroll_offset() { continue; } - Point2 pos = gn->get_offset() * zoom; + Point2 pos = gn->get_position_offset() * zoom; pos -= Point2(h_scroll->get_value(), v_scroll->get_value()); gn->set_position(pos); if (gn->get_scale() != Vector2(zoom, zoom)) { @@ -306,7 +306,7 @@ void GraphEdit::_update_scroll() { } Rect2 r; - r.position = gn->get_offset() * zoom; + r.position = gn->get_position_offset() * zoom; r.size = gn->get_size() * zoom; screen = screen.merge(r); } @@ -337,8 +337,8 @@ void GraphEdit::_update_scroll() { Size2 vmin = v_scroll->get_combined_minimum_size(); // Avoid scrollbar overlapping. - h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, v_scroll->is_visible() ? -vmin.width : 0); - v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, h_scroll->is_visible() ? -hmin.height : 0); + h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, v_scroll->is_visible() ? -vmin.width : 0); + v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, h_scroll->is_visible() ? -hmin.height : 0); set_block_minimum_size_adjust(false); @@ -429,15 +429,15 @@ void GraphEdit::_notification(int p_what) { Size2 hmin = h_scroll->get_combined_minimum_size(); Size2 vmin = v_scroll->get_combined_minimum_size(); - h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0); - h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); - h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height); - h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); + h_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, 0); + h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); + h_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -hmin.height); + h_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); - v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -vmin.width); - v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); - v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0); - v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); + v_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -vmin.width); + v_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); + v_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 0); + v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); } if (p_what == NOTIFICATION_DRAW) { draw_style_box(get_theme_stylebox("bg"), Rect2(Point2(), get_size())); @@ -851,9 +851,9 @@ void GraphEdit::_connections_layer_draw() { continue; } - Vector2 frompos = gfrom->get_connection_output_position(E->get().from_port) + gfrom->get_offset() * zoom; + Vector2 frompos = gfrom->get_connection_output_position(E->get().from_port) + gfrom->get_position_offset() * zoom; Color color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 topos = gto->get_connection_input_position(E->get().to_port) + gto->get_offset() * zoom; + Vector2 topos = gto->get_connection_input_position(E->get().to_port) + gto->get_position_offset() * zoom; Color tocolor = gto->get_connection_input_color(E->get().to_port); if (E->get().activity > 0) { @@ -929,7 +929,7 @@ void GraphEdit::_minimap_draw() { continue; } - Vector2 node_position = minimap->_convert_from_graph_position(gn->get_offset() * zoom - graph_offset) + minimap_offset; + Vector2 node_position = minimap->_convert_from_graph_position(gn->get_position_offset() * zoom - graph_offset) + minimap_offset; Vector2 node_size = minimap->_convert_from_graph_position(gn->get_size() * zoom); Rect2 node_rect = Rect2(node_position, node_size); @@ -952,7 +952,7 @@ void GraphEdit::_minimap_draw() { continue; } - Vector2 node_position = minimap->_convert_from_graph_position(gn->get_offset() * zoom - graph_offset) + minimap_offset; + Vector2 node_position = minimap->_convert_from_graph_position(gn->get_position_offset() * zoom - graph_offset) + minimap_offset; Vector2 node_size = minimap->_convert_from_graph_position(gn->get_size() * zoom); Rect2 node_rect = Rect2(node_position, node_size); @@ -992,10 +992,10 @@ void GraphEdit::_minimap_draw() { continue; } - Vector2 from_slot_position = gfrom->get_offset() * zoom + gfrom->get_connection_output_position(E->get().from_port); + Vector2 from_slot_position = gfrom->get_position_offset() * zoom + gfrom->get_connection_output_position(E->get().from_port); Vector2 from_position = minimap->_convert_from_graph_position(from_slot_position - graph_offset) + minimap_offset; Color from_color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 to_slot_position = gto->get_offset() * zoom + gto->get_connection_input_position(E->get().to_port); + Vector2 to_slot_position = gto->get_position_offset() * zoom + gto->get_connection_input_position(E->get().to_port); Vector2 to_position = minimap->_convert_from_graph_position(to_slot_position - graph_offset) + minimap_offset; Color to_color = gto->get_connection_input_color(E->get().to_port); @@ -1054,7 +1054,7 @@ void GraphEdit::_gui_input(const Ref &p_ev) { pos = pos.snapped(Vector2(snap, snap)); } - gn->set_offset(pos); + gn->set_position_offset(pos); } } } @@ -1502,10 +1502,10 @@ void GraphEdit::set_minimap_size(Vector2 p_size) { Vector2 minimap_size = minimap->get_size(); // The size might've been adjusted by the minimum size. minimap->set_anchors_preset(Control::PRESET_BOTTOM_RIGHT); - minimap->set_margin(Margin::MARGIN_LEFT, -minimap_size.x - MINIMAP_OFFSET); - minimap->set_margin(Margin::MARGIN_TOP, -minimap_size.y - MINIMAP_OFFSET); - minimap->set_margin(Margin::MARGIN_RIGHT, -MINIMAP_OFFSET); - minimap->set_margin(Margin::MARGIN_BOTTOM, -MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_LEFT, -minimap_size.x - MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_TOP, -minimap_size.y - MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_RIGHT, -MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_BOTTOM, -MINIMAP_OFFSET); minimap->update(); } @@ -1645,7 +1645,7 @@ GraphEdit::GraphEdit() { top_layer = memnew(GraphEditFilter(this)); add_child(top_layer); top_layer->set_mouse_filter(MOUSE_FILTER_PASS); - top_layer->set_anchors_and_margins_preset(Control::PRESET_WIDE); + top_layer->set_anchors_and_offsets_preset(Control::PRESET_WIDE); top_layer->connect("draw", callable_mp(this, &GraphEdit::_top_layer_draw)); top_layer->connect("gui_input", callable_mp(this, &GraphEdit::_top_layer_input)); @@ -1745,10 +1745,10 @@ GraphEdit::GraphEdit() { minimap->set_custom_minimum_size(Vector2(50, 50)); minimap->set_size(minimap_size); minimap->set_anchors_preset(Control::PRESET_BOTTOM_RIGHT); - minimap->set_margin(Margin::MARGIN_LEFT, -minimap_size.x - MINIMAP_OFFSET); - minimap->set_margin(Margin::MARGIN_TOP, -minimap_size.y - MINIMAP_OFFSET); - minimap->set_margin(Margin::MARGIN_RIGHT, -MINIMAP_OFFSET); - minimap->set_margin(Margin::MARGIN_BOTTOM, -MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_LEFT, -minimap_size.x - MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_TOP, -minimap_size.y - MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_RIGHT, -MINIMAP_OFFSET); + minimap->set_offset(Side::SIDE_BOTTOM, -MINIMAP_OFFSET); minimap->connect("draw", callable_mp(this, &GraphEdit::_minimap_draw)); setting_scroll_ofs = false; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 4ce33ec8f2..eaee086b81 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -203,7 +203,7 @@ void GraphNode::_resort() { Size2i size = c->get_combined_minimum_size(); - Rect2 r(sb->get_margin(MARGIN_LEFT), sb->get_margin(MARGIN_TOP) + vofs, w, size.y); + Rect2 r(sb->get_margin(SIDE_LEFT), sb->get_margin(SIDE_TOP) + vofs, w, size.y); fit_child_in_rect(c, r); cache_y.push_back(vofs + size.y * 0.5); @@ -224,7 +224,7 @@ bool GraphNode::has_point(const Point2 &p_point) const { return true; } - if (Rect2(0, 0, get_size().width, comment->get_margin(MARGIN_TOP)).has_point(p_point)) { + if (Rect2(0, 0, get_size().width, comment->get_margin(SIDE_TOP)).has_point(p_point)) { return true; } @@ -261,7 +261,7 @@ void GraphNode::_notification(int p_what) { Color title_color = get_theme_color("title_color"); Point2i icofs = -port->get_size() * 0.5; int edgeofs = get_theme_constant("port_offset"); - icofs.y += sb->get_margin(MARGIN_TOP); + icofs.y += sb->get_margin(SIDE_TOP); draw_style_box(sb, Rect2(Point2(), get_size())); @@ -284,9 +284,9 @@ void GraphNode::_notification(int p_what) { } title_buf->set_width(w); - title_buf->draw(get_canvas_item(), Point2(sb->get_margin(MARGIN_LEFT) + title_h_offset, -title_buf->get_size().y + title_offset), title_color); + title_buf->draw(get_canvas_item(), Point2(sb->get_margin(SIDE_LEFT) + title_h_offset, -title_buf->get_size().y + title_offset), title_color); if (show_close) { - Vector2 cpos = Point2(w + sb->get_margin(MARGIN_LEFT) + close_h_offset, -close->get_height() + close_offset); + Vector2 cpos = Point2(w + sb->get_margin(SIDE_LEFT) + close_h_offset, -close->get_height() + close_offset); draw_texture(close, cpos, close_color); close_rect.position = cpos; close_rect.size = close->get_size(); @@ -528,14 +528,14 @@ String GraphNode::get_language() const { return language; } -void GraphNode::set_offset(const Vector2 &p_offset) { - offset = p_offset; - emit_signal("offset_changed"); +void GraphNode::set_position_offset(const Vector2 &p_offset) { + position_offset = p_offset; + emit_signal("position_offset_changed"); update(); } -Vector2 GraphNode::get_offset() const { - return offset; +Vector2 GraphNode::get_position_offset() const { + return position_offset; } void GraphNode::set_selected(bool p_selected) { @@ -549,9 +549,9 @@ bool GraphNode::is_selected() { void GraphNode::set_drag(bool p_drag) { if (p_drag) { - drag_from = get_offset(); + drag_from = get_position_offset(); } else { - emit_signal("dragged", drag_from, get_offset()); //useful for undo/redo + emit_signal("dragged", drag_from, get_position_offset()); //useful for undo/redo } } @@ -590,7 +590,7 @@ void GraphNode::_connpos_update() { Size2i size = c->get_combined_minimum_size(); - int y = sb->get_margin(MARGIN_TOP) + vofs; + int y = sb->get_margin(SIDE_TOP) + vofs; int h = size.y; if (slot_info.has(idx)) { @@ -787,8 +787,8 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("get_slot_type_right", "idx"), &GraphNode::get_slot_type_right); ClassDB::bind_method(D_METHOD("get_slot_color_right", "idx"), &GraphNode::get_slot_color_right); - ClassDB::bind_method(D_METHOD("set_offset", "offset"), &GraphNode::set_offset); - ClassDB::bind_method(D_METHOD("get_offset"), &GraphNode::get_offset); + ClassDB::bind_method(D_METHOD("set_position_offset", "offset"), &GraphNode::set_position_offset); + ClassDB::bind_method(D_METHOD("get_position_offset"), &GraphNode::get_position_offset); ClassDB::bind_method(D_METHOD("set_comment", "comment"), &GraphNode::set_comment); ClassDB::bind_method(D_METHOD("is_comment"), &GraphNode::is_comment); @@ -818,14 +818,14 @@ void GraphNode::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title"); ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,LTR,RTL,Inherited"), "set_text_direction", "get_text_direction"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "language"), "set_language", "get_language"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position_offset"), "set_position_offset", "get_position_offset"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_close"), "set_show_close_button", "is_close_button_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable"), "set_resizable", "is_resizable"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selected"), "set_selected", "is_selected"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "comment"), "set_comment", "is_comment"); ADD_PROPERTY(PropertyInfo(Variant::INT, "overlay", PROPERTY_HINT_ENUM, "Disabled,Breakpoint,Position"), "set_overlay", "get_overlay"); - ADD_SIGNAL(MethodInfo("offset_changed")); + ADD_SIGNAL(MethodInfo("position_offset_changed")); ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "from"), PropertyInfo(Variant::VECTOR2, "to"))); ADD_SIGNAL(MethodInfo("raise_request")); ADD_SIGNAL(MethodInfo("close_request")); diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index 3cd7ae6e24..08ae0d465d 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -73,7 +73,7 @@ private: TextDirection text_direction = TEXT_DIRECTION_AUTO; bool show_close; - Vector2 offset; + Vector2 position_offset; bool comment; bool resizable; @@ -142,8 +142,8 @@ public: void set_language(const String &p_language); String get_language() const; - void set_offset(const Vector2 &p_offset); - Vector2 get_offset() const; + void set_position_offset(const Vector2 &p_offset); + Vector2 get_position_offset() const; void set_selected(bool p_selected); bool is_selected(); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 5be7804ac1..e0aef32e15 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -861,10 +861,10 @@ void ItemList::_notification(int p_what) { Ref bg = get_theme_stylebox("bg"); int mw = scroll_bar->get_minimum_size().x; - scroll_bar->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -mw); - scroll_bar->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); - scroll_bar->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, bg->get_margin(MARGIN_TOP)); - scroll_bar->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -bg->get_margin(MARGIN_BOTTOM)); + scroll_bar->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -mw); + scroll_bar->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); + scroll_bar->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, bg->get_margin(SIDE_TOP)); + scroll_bar->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -bg->get_margin(SIDE_BOTTOM)); Size2 size = get_size(); @@ -1270,7 +1270,7 @@ void ItemList::_notification(int p_what) { } const int y = base_ofs.y + separators[i]; - draw_line(Vector2(bg->get_margin(MARGIN_LEFT), y), Vector2(width, y), guide_color); + draw_line(Vector2(bg->get_margin(SIDE_LEFT), y), Vector2(width, y), guide_color); } } } diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 566d77e3fd..d70f07c0a8 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -272,7 +272,7 @@ void Label::_notification(int p_what) { case ALIGN_FILL: case ALIGN_LEFT: { if (rtl) { - ofs.x = int(size.width - style->get_margin(MARGIN_RIGHT) - TS->shaped_text_get_size(lines_rid[i]).x); + ofs.x = int(size.width - style->get_margin(SIDE_RIGHT) - TS->shaped_text_get_size(lines_rid[i]).x); } else { ofs.x = style->get_offset().x; } @@ -284,7 +284,7 @@ void Label::_notification(int p_what) { if (rtl) { ofs.x = style->get_offset().x; } else { - ofs.x = int(size.width - style->get_margin(MARGIN_RIGHT) - TS->shaped_text_get_size(lines_rid[i]).x); + ofs.x = int(size.width - style->get_margin(SIDE_RIGHT) - TS->shaped_text_get_size(lines_rid[i]).x); } } break; } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 9f8b944f4c..e623ba987f 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -743,7 +743,7 @@ void LineEdit::_notification(int p_what) { case ALIGN_FILL: case ALIGN_LEFT: { if (rtl) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(size.width - style->get_margin(SIDE_RIGHT) - (text_width))); } else { x_ofs = style->get_offset().x; } @@ -752,19 +752,19 @@ void LineEdit::_notification(int p_what) { if (scroll_offset != 0) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - (text_width)) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(size.width - (text_width)) / 2); } } break; case ALIGN_RIGHT: { if (rtl) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(size.width - style->get_margin(SIDE_RIGHT) - (text_width))); } } break; } - int ofs_max = width - style->get_margin(MARGIN_RIGHT); + int ofs_max = width - style->get_margin(SIDE_RIGHT); int y_area = height - style->get_minimum_size().height; int y_ofs = style->get_offset().y + (y_area - text_height) / 2; @@ -791,14 +791,14 @@ void LineEdit::_notification(int p_what) { } } - r_icon->draw(ci, Point2(width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT), height / 2 - r_icon->get_height() / 2), color_icon); + r_icon->draw(ci, Point2(width - r_icon->get_width() - style->get_margin(SIDE_RIGHT), height / 2 - r_icon->get_height() / 2), color_icon); if (align == ALIGN_CENTER) { if (scroll_offset == 0) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - text_width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT) * 2) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(size.width - text_width - r_icon->get_width() - style->get_margin(SIDE_RIGHT) * 2) / 2); } } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - r_icon->get_width() - style->get_margin(MARGIN_RIGHT)); + x_ofs = MAX(style->get_margin(SIDE_LEFT), x_ofs - r_icon->get_width() - style->get_margin(SIDE_RIGHT)); } ofs_max -= r_icon->get_width(); @@ -1088,7 +1088,7 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { case ALIGN_FILL: case ALIGN_LEFT: { if (rtl) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - style->get_margin(SIDE_RIGHT) - (text_width))); } else { x_ofs = style->get_offset().x; } @@ -1097,14 +1097,14 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { if (scroll_offset != 0) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - (text_width)) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - (text_width)) / 2); } } break; case ALIGN_RIGHT: { if (rtl) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - style->get_margin(SIDE_RIGHT) - (text_width))); } } break; } @@ -1115,10 +1115,10 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { Ref r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; if (align == ALIGN_CENTER) { if (scroll_offset == 0) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT) * 2) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(SIDE_RIGHT) * 2) / 2); } } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - r_icon->get_width() - style->get_margin(MARGIN_RIGHT)); + x_ofs = MAX(style->get_margin(SIDE_LEFT), x_ofs - r_icon->get_width() - style->get_margin(SIDE_RIGHT)); } } @@ -1136,7 +1136,7 @@ Vector2i LineEdit::get_cursor_pixel_pos() { case ALIGN_FILL: case ALIGN_LEFT: { if (rtl) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - style->get_margin(SIDE_RIGHT) - (text_width))); } else { x_ofs = style->get_offset().x; } @@ -1145,14 +1145,14 @@ Vector2i LineEdit::get_cursor_pixel_pos() { if (scroll_offset != 0) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - (text_width)) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - (text_width)) / 2); } } break; case ALIGN_RIGHT: { if (rtl) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - style->get_margin(SIDE_RIGHT) - (text_width))); } } break; } @@ -1163,10 +1163,10 @@ Vector2i LineEdit::get_cursor_pixel_pos() { Ref r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; if (align == ALIGN_CENTER) { if (scroll_offset == 0) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT) * 2) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(SIDE_RIGHT) * 2) / 2); } } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - r_icon->get_width() - style->get_margin(MARGIN_RIGHT)); + x_ofs = MAX(style->get_margin(SIDE_LEFT), x_ofs - r_icon->get_width() - style->get_margin(SIDE_RIGHT)); } } @@ -1460,7 +1460,7 @@ void LineEdit::set_cursor_position(int p_pos) { case ALIGN_FILL: case ALIGN_LEFT: { if (rtl) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - style->get_margin(SIDE_RIGHT) - (text_width))); } else { x_ofs = style->get_offset().x; } @@ -1469,29 +1469,29 @@ void LineEdit::set_cursor_position(int p_pos) { if (scroll_offset != 0) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - (text_width)) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - (text_width)) / 2); } } break; case ALIGN_RIGHT: { if (rtl) { x_ofs = style->get_offset().x; } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - style->get_margin(MARGIN_RIGHT) - (text_width))); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - style->get_margin(SIDE_RIGHT) - (text_width))); } } break; } - int ofs_max = get_size().width - style->get_margin(MARGIN_RIGHT); + int ofs_max = get_size().width - style->get_margin(SIDE_RIGHT); bool using_placeholder = text.empty() && ime_text.empty(); bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { Ref r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon; if (align == ALIGN_CENTER) { if (scroll_offset == 0) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT) * 2) / 2); + x_ofs = MAX(style->get_margin(SIDE_LEFT), int(get_size().width - text_width - r_icon->get_width() - style->get_margin(SIDE_RIGHT) * 2) / 2); } } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - r_icon->get_width() - style->get_margin(MARGIN_RIGHT)); + x_ofs = MAX(style->get_margin(SIDE_LEFT), x_ofs - r_icon->get_width() - style->get_margin(SIDE_RIGHT)); } ofs_max -= r_icon->get_width(); } @@ -1994,7 +1994,7 @@ void LineEdit::_shape() { void LineEdit::_fit_to_width() { if (align == ALIGN_FILL) { Ref style = get_theme_stylebox("normal"); - int t_width = get_size().width - style->get_margin(MARGIN_RIGHT) - style->get_margin(MARGIN_LEFT); + int t_width = get_size().width - style->get_margin(SIDE_RIGHT) - style->get_margin(SIDE_LEFT); bool using_placeholder = text.empty() && ime_text.empty(); bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index bc71ae94f5..72754f375a 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -44,12 +44,12 @@ void NinePatchRect::_notification(int p_what) { texture->get_rect_region(rect, src_rect, rect, src_rect); RID ci = get_canvas_item(); - RS::get_singleton()->canvas_item_add_nine_patch(ci, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center); + RS::get_singleton()->canvas_item_add_nine_patch(ci, rect, src_rect, texture->get_rid(), Vector2(margin[SIDE_LEFT], margin[SIDE_TOP]), Vector2(margin[SIDE_RIGHT], margin[SIDE_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center); } } Size2 NinePatchRect::get_minimum_size() const { - return Size2(margin[MARGIN_LEFT] + margin[MARGIN_RIGHT], margin[MARGIN_TOP] + margin[MARGIN_BOTTOM]); + return Size2(margin[SIDE_LEFT] + margin[SIDE_RIGHT], margin[SIDE_TOP] + margin[SIDE_BOTTOM]); } void NinePatchRect::_bind_methods() { @@ -73,10 +73,10 @@ void NinePatchRect::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); ADD_GROUP("Patch Margin", "patch_margin_"); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "patch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_patch_margin", "get_patch_margin", SIDE_BOTTOM); ADD_GROUP("Axis Stretch", "axis_stretch_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "axis_stretch_horizontal", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_h_axis_stretch_mode", "get_h_axis_stretch_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "axis_stretch_vertical", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_v_axis_stretch_mode", "get_v_axis_stretch_mode"); @@ -105,30 +105,30 @@ Ref NinePatchRect::get_texture() const { return texture; } -void NinePatchRect::set_patch_margin(Margin p_margin, int p_size) { - ERR_FAIL_INDEX((int)p_margin, 4); - margin[p_margin] = p_size; +void NinePatchRect::set_patch_margin(Side p_side, int p_size) { + ERR_FAIL_INDEX((int)p_side, 4); + margin[p_side] = p_size; update(); minimum_size_changed(); - switch (p_margin) { - case MARGIN_LEFT: + switch (p_side) { + case SIDE_LEFT: _change_notify("patch_margin_left"); break; - case MARGIN_TOP: + case SIDE_TOP: _change_notify("patch_margin_top"); break; - case MARGIN_RIGHT: + case SIDE_RIGHT: _change_notify("patch_margin_right"); break; - case MARGIN_BOTTOM: + case SIDE_BOTTOM: _change_notify("patch_margin_bottom"); break; } } -int NinePatchRect::get_patch_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); - return margin[p_margin]; +int NinePatchRect::get_patch_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0); + return margin[p_side]; } void NinePatchRect::set_region_rect(const Rect2 &p_region_rect) { @@ -174,10 +174,10 @@ NinePatchRect::AxisStretchMode NinePatchRect::get_v_axis_stretch_mode() const { } NinePatchRect::NinePatchRect() { - margin[MARGIN_LEFT] = 0; - margin[MARGIN_RIGHT] = 0; - margin[MARGIN_BOTTOM] = 0; - margin[MARGIN_TOP] = 0; + margin[SIDE_LEFT] = 0; + margin[SIDE_RIGHT] = 0; + margin[SIDE_BOTTOM] = 0; + margin[SIDE_TOP] = 0; set_mouse_filter(MOUSE_FILTER_IGNORE); draw_center = true; diff --git a/scene/gui/nine_patch_rect.h b/scene/gui/nine_patch_rect.h index a539ad43c0..91d24ada8f 100644 --- a/scene/gui/nine_patch_rect.h +++ b/scene/gui/nine_patch_rect.h @@ -59,8 +59,8 @@ public: void set_texture(const Ref &p_tex); Ref get_texture() const; - void set_patch_margin(Margin p_margin, int p_size); - int get_patch_margin(Margin p_margin) const; + void set_patch_margin(Side p_side, int p_size); + int get_patch_margin(Side p_side) const; void set_region_rect(const Rect2 &p_region_rect); Rect2 get_region_rect() const; diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 902d2715d4..8fdd3db4e7 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -90,11 +90,11 @@ void OptionButton::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { if (has_theme_icon("arrow")) { if (is_layout_rtl()) { - _set_internal_margin(MARGIN_LEFT, Control::get_theme_icon("arrow")->get_width()); - _set_internal_margin(MARGIN_RIGHT, 0.f); + _set_internal_margin(SIDE_LEFT, Control::get_theme_icon("arrow")->get_width()); + _set_internal_margin(SIDE_RIGHT, 0.f); } else { - _set_internal_margin(MARGIN_LEFT, 0.f); - _set_internal_margin(MARGIN_RIGHT, Control::get_theme_icon("arrow")->get_width()); + _set_internal_margin(SIDE_LEFT, 0.f); + _set_internal_margin(SIDE_RIGHT, Control::get_theme_icon("arrow")->get_width()); } } } break; @@ -341,11 +341,11 @@ OptionButton::OptionButton() { set_text_align(ALIGN_LEFT); if (is_layout_rtl()) { if (has_theme_icon("arrow")) { - _set_internal_margin(MARGIN_LEFT, Control::get_theme_icon("arrow")->get_width()); + _set_internal_margin(SIDE_LEFT, Control::get_theme_icon("arrow")->get_width()); } } else { if (has_theme_icon("arrow")) { - _set_internal_margin(MARGIN_RIGHT, Control::get_theme_icon("arrow")->get_width()); + _set_internal_margin(SIDE_RIGHT, Control::get_theme_icon("arrow")->get_width()); } } set_action_mode(ACTION_MODE_BUTTON_PRESS); diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 07f03ad40e..e1a324efb3 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -571,9 +571,9 @@ void PopupMenu::_draw_items() { // Submenu arrow on right hand side if (items[i].submenu != "") { if (rtl) { - submenu->draw(ci, Point2(scroll_width + style->get_margin(MARGIN_LEFT), item_ofs.y + Math::floor(h - submenu->get_height()) / 2), icon_color); + submenu->draw(ci, Point2(scroll_width + style->get_margin(SIDE_LEFT), item_ofs.y + Math::floor(h - submenu->get_height()) / 2), icon_color); } else { - submenu->draw(ci, Point2(display_width - style->get_margin(MARGIN_RIGHT) - submenu->get_width(), item_ofs.y + Math::floor(h - submenu->get_height()) / 2), icon_color); + submenu->draw(ci, Point2(display_width - style->get_margin(SIDE_RIGHT) - submenu->get_width(), item_ofs.y + Math::floor(h - submenu->get_height()) / 2), icon_color); } } @@ -595,9 +595,9 @@ void PopupMenu::_draw_items() { // Accelerator / Shortcut if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) { if (rtl) { - item_ofs.x = scroll_width + style->get_margin(MARGIN_LEFT); + item_ofs.x = scroll_width + style->get_margin(SIDE_LEFT); } else { - item_ofs.x = display_width - style->get_margin(MARGIN_RIGHT) - items[i].accel_text_buf->get_size().x; + item_ofs.x = display_width - style->get_margin(SIDE_RIGHT) - items[i].accel_text_buf->get_size().x; } items[i].accel_text_buf->draw(ci, item_ofs + Point2(0, Math::floor((h - items[i].text_buf->get_size().y) / 2.0)), i == mouse_over ? font_color_hover : font_color_accel); } @@ -745,10 +745,10 @@ void PopupMenu::_notification(int p_what) { // Set margin on the margin container Ref panel_style = get_theme_stylebox("panel"); - margin_container->add_theme_constant_override("margin_top", panel_style->get_margin(Margin::MARGIN_TOP)); - margin_container->add_theme_constant_override("margin_bottom", panel_style->get_margin(Margin::MARGIN_BOTTOM)); - margin_container->add_theme_constant_override("margin_left", panel_style->get_margin(Margin::MARGIN_LEFT)); - margin_container->add_theme_constant_override("margin_right", panel_style->get_margin(Margin::MARGIN_RIGHT)); + margin_container->add_theme_constant_override("margin_top", panel_style->get_margin(Side::SIDE_TOP)); + margin_container->add_theme_constant_override("margin_bottom", panel_style->get_margin(Side::SIDE_BOTTOM)); + margin_container->add_theme_constant_override("margin_left", panel_style->get_margin(Side::SIDE_LEFT)); + margin_container->add_theme_constant_override("margin_right", panel_style->get_margin(Side::SIDE_RIGHT)); } } break; } @@ -1643,7 +1643,7 @@ void PopupMenu::popup(const Rect2 &p_bounds) { PopupMenu::PopupMenu() { // Margin Container margin_container = memnew(MarginContainer); - margin_container->set_anchors_and_margins_preset(Control::PRESET_WIDE); + margin_container->set_anchors_and_offsets_preset(Control::PRESET_WIDE); add_child(margin_container); margin_container->connect("draw", callable_mp(this, &PopupMenu::_draw_background)); @@ -1655,7 +1655,7 @@ PopupMenu::PopupMenu() { // The control which will display the items control = memnew(Control); control->set_clip_contents(false); - control->set_anchors_and_margins_preset(Control::PRESET_WIDE); + control->set_anchors_and_offsets_preset(Control::PRESET_WIDE); control->set_h_size_flags(Control::SIZE_EXPAND_FILL); control->set_v_size_flags(Control::SIZE_EXPAND_FILL); scroll_container->add_child(control); diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 244d90ca6b..40138e458b 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1250,7 +1250,7 @@ void RichTextLabel::_update_scroll() { scroll_visible = true; scroll_w = vscroll->get_combined_minimum_size().width; vscroll->show(); - vscroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -scroll_w); + vscroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -scroll_w); } else { scroll_visible = false; scroll_w = 0; @@ -3956,9 +3956,9 @@ RichTextLabel::RichTextLabel() { add_child(vscroll); vscroll->set_drag_node(String("..")); vscroll->set_step(1); - vscroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0); - vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); - vscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); + vscroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 0); + vscroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); + vscroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); vscroll->connect("value_changed", callable_mp(this, &RichTextLabel::_scroll_changed)); vscroll->set_step(1); vscroll->hide(); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 70de63fd40..1a4d19eab3 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -259,11 +259,11 @@ void ScrollBar::_notification(int p_what) { grabber_rect.size.width = get_grabber_size(); grabber_rect.size.height = get_size().height; grabber_rect.position.y = 0; - grabber_rect.position.x = get_grabber_offset() + decr->get_width() + bg->get_margin(MARGIN_LEFT); + grabber_rect.position.x = get_grabber_offset() + decr->get_width() + bg->get_margin(SIDE_LEFT); } else { grabber_rect.size.width = get_size().width; grabber_rect.size.height = get_grabber_size(); - grabber_rect.position.y = get_grabber_offset() + decr->get_height() + bg->get_margin(MARGIN_TOP); + grabber_rect.position.y = get_grabber_offset() + decr->get_height() + bg->get_margin(SIDE_TOP); grabber_rect.position.x = 0; } @@ -437,12 +437,12 @@ double ScrollBar::get_area_offset() const { double ofs = 0; if (orientation == VERTICAL) { - ofs += get_theme_stylebox("hscroll")->get_margin(MARGIN_TOP); + ofs += get_theme_stylebox("hscroll")->get_margin(SIDE_TOP); ofs += get_theme_icon("decrement")->get_height(); } if (orientation == HORIZONTAL) { - ofs += get_theme_stylebox("hscroll")->get_margin(MARGIN_LEFT); + ofs += get_theme_stylebox("hscroll")->get_margin(SIDE_LEFT); ofs += get_theme_icon("decrement")->get_width(); } diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 3a54ac7443..65f1084dc2 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -220,15 +220,15 @@ void ScrollContainer::_update_scrollbar_position() { Size2 hmin = h_scroll->get_combined_minimum_size(); Size2 vmin = v_scroll->get_combined_minimum_size(); - h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0); - h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); - h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height); - h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); + h_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_BEGIN, 0); + h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); + h_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -hmin.height); + h_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); - v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -vmin.width); - v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); - v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0); - v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); + v_scroll->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -vmin.width); + v_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, 0); + v_scroll->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 0); + v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, 0); h_scroll->raise(); v_scroll->raise(); @@ -462,8 +462,8 @@ void ScrollContainer::update_scrollbars() { } // Avoid scrollbar overlapping. - h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, hide_scroll_v ? 0 : -vmin.width); - v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, hide_scroll_h ? 0 : -hmin.height); + h_scroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, hide_scroll_v ? 0 : -vmin.width); + v_scroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, hide_scroll_h ? 0 : -hmin.height); } void ScrollContainer::_scroll_moved(float) { diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 46b24efed5..a4de4a0408 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -173,8 +173,8 @@ void SpinBox::_line_edit_focus_exit() { inline void SpinBox::_adjust_width_for_icon(const Ref &icon) { int w = icon->get_width(); if ((w != last_w)) { - line_edit->set_margin(MARGIN_LEFT, 0); - line_edit->set_margin(MARGIN_RIGHT, -w); + line_edit->set_offset(SIDE_LEFT, 0); + line_edit->set_offset(SIDE_RIGHT, -w); last_w = w; } } @@ -272,7 +272,7 @@ SpinBox::SpinBox() { line_edit = memnew(LineEdit); add_child(line_edit); - line_edit->set_anchors_and_margins_preset(Control::PRESET_WIDE); + line_edit->set_anchors_and_offsets_preset(Control::PRESET_WIDE); line_edit->set_mouse_filter(MOUSE_FILTER_PASS); line_edit->set_align(LineEdit::ALIGN_LEFT); diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 809b4ffd64..ddb2b1fe47 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -547,8 +547,8 @@ void TabContainer::_draw_tab(Ref &p_tab_style, Color &p_font_color, in Control *control = Object::cast_to(tabs[p_index]); String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name())); - int x_content = tab_rect.position.x + p_tab_style->get_margin(MARGIN_LEFT); - int top_margin = p_tab_style->get_margin(MARGIN_TOP); + int x_content = tab_rect.position.x + p_tab_style->get_margin(SIDE_LEFT); + int top_margin = p_tab_style->get_margin(SIDE_TOP); int y_center = top_margin + (tab_rect.size.y - p_tab_style->get_minimum_size().y) / 2; // Draw the tab icon. @@ -607,14 +607,14 @@ void TabContainer::_repaint() { Control *c = tabs[i]; if (i == current) { c->show(); - c->set_anchors_and_margins_preset(Control::PRESET_WIDE); + c->set_anchors_and_offsets_preset(Control::PRESET_WIDE); if (tabs_visible) { - c->set_margin(MARGIN_TOP, _get_top_margin()); + c->set_offset(SIDE_TOP, _get_top_margin()); } - c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP))); - c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT))); - c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT))); - c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM))); + c->set_offset(Side(SIDE_TOP), c->get_offset(Side(SIDE_TOP)) + sb->get_margin(Side(SIDE_TOP))); + c->set_offset(Side(SIDE_LEFT), c->get_offset(Side(SIDE_LEFT)) + sb->get_margin(Side(SIDE_LEFT))); + c->set_offset(Side(SIDE_RIGHT), c->get_offset(Side(SIDE_RIGHT)) - sb->get_margin(Side(SIDE_RIGHT))); + c->set_offset(Side(SIDE_BOTTOM), c->get_offset(Side(SIDE_BOTTOM)) - sb->get_margin(Side(SIDE_BOTTOM))); } else { c->hide(); @@ -712,15 +712,15 @@ void TabContainer::add_child_notify(Node *p_child) { current = 0; previous = 0; } - c->set_anchors_and_margins_preset(Control::PRESET_WIDE); + c->set_anchors_and_offsets_preset(Control::PRESET_WIDE); if (tabs_visible) { - c->set_margin(MARGIN_TOP, _get_top_margin()); + c->set_offset(SIDE_TOP, _get_top_margin()); } Ref sb = get_theme_stylebox("panel"); - c->set_margin(Margin(MARGIN_TOP), c->get_margin(Margin(MARGIN_TOP)) + sb->get_margin(Margin(MARGIN_TOP))); - c->set_margin(Margin(MARGIN_LEFT), c->get_margin(Margin(MARGIN_LEFT)) + sb->get_margin(Margin(MARGIN_LEFT))); - c->set_margin(Margin(MARGIN_RIGHT), c->get_margin(Margin(MARGIN_RIGHT)) - sb->get_margin(Margin(MARGIN_RIGHT))); - c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM))); + c->set_offset(Side(SIDE_TOP), c->get_offset(Side(SIDE_TOP)) + sb->get_margin(Side(SIDE_TOP))); + c->set_offset(Side(SIDE_LEFT), c->get_offset(Side(SIDE_LEFT)) + sb->get_margin(Side(SIDE_LEFT))); + c->set_offset(Side(SIDE_RIGHT), c->get_offset(Side(SIDE_RIGHT)) - sb->get_margin(Side(SIDE_RIGHT))); + c->set_offset(Side(SIDE_BOTTOM), c->get_offset(Side(SIDE_BOTTOM)) - sb->get_margin(Side(SIDE_BOTTOM))); update(); p_child->connect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback)); if (first && is_inside_tree()) { @@ -982,9 +982,9 @@ void TabContainer::set_tabs_visible(bool p_visible) { for (int i = 0; i < tabs.size(); i++) { Control *c = tabs[i]; if (p_visible) { - c->set_margin(MARGIN_TOP, _get_top_margin()); + c->set_offset(SIDE_TOP, _get_top_margin()); } else { - c->set_margin(MARGIN_TOP, 0); + c->set_offset(SIDE_TOP, 0); } } diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 5b26428e45..d332a5cbc6 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -341,15 +341,15 @@ void Tabs::_notification(int p_what) { } sb->draw(ci, sb_rect); - w += sb->get_margin(MARGIN_LEFT); + w += sb->get_margin(SIDE_LEFT); Size2i sb_ms = sb->get_minimum_size(); Ref icon = tabs[i].icon; if (icon.is_valid()) { if (rtl) { - icon->draw(ci, Point2i(size.width - w - icon->get_width(), sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2)); + icon->draw(ci, Point2i(size.width - w - icon->get_width(), sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2)); } else { - icon->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2)); + icon->draw(ci, Point2i(w, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2)); } if (tabs[i].text != "") { w += icon->get_width() + get_theme_constant("hseparation"); @@ -357,9 +357,9 @@ void Tabs::_notification(int p_what) { } if (rtl) { - tabs[i].text_buf->draw(ci, Point2i(size.width - w - tabs[i].text_buf->get_size().x, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2), col); + tabs[i].text_buf->draw(ci, Point2i(size.width - w - tabs[i].text_buf->get_size().x, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2), col); } else { - tabs[i].text_buf->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2), col); + tabs[i].text_buf->draw(ci, Point2i(w, sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - tabs[i].text_buf->get_size().y) / 2), col); } w += tabs[i].size_text; @@ -377,7 +377,7 @@ void Tabs::_notification(int p_what) { } else { rb_rect.position.x = w; } - rb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (rb_rect.size.y)) / 2; + rb_rect.position.y = sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - (rb_rect.size.y)) / 2; if (rb_hover == i) { if (rb_pressing) { @@ -388,9 +388,9 @@ void Tabs::_notification(int p_what) { } if (rtl) { - rb->draw(ci, Point2i(size.width - w - rb_rect.size.x + style->get_margin(MARGIN_LEFT), rb_rect.position.y + style->get_margin(MARGIN_TOP))); + rb->draw(ci, Point2i(size.width - w - rb_rect.size.x + style->get_margin(SIDE_LEFT), rb_rect.position.y + style->get_margin(SIDE_TOP))); } else { - rb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), rb_rect.position.y + style->get_margin(MARGIN_TOP))); + rb->draw(ci, Point2i(w + style->get_margin(SIDE_LEFT), rb_rect.position.y + style->get_margin(SIDE_TOP))); } w += rb->get_width(); tabs.write[i].rb_rect = rb_rect; @@ -409,7 +409,7 @@ void Tabs::_notification(int p_what) { } else { cb_rect.position.x = w; } - cb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (cb_rect.size.y)) / 2; + cb_rect.position.y = sb->get_margin(SIDE_TOP) + ((sb_rect.size.y - sb_ms.y) - (cb_rect.size.y)) / 2; if (!tabs[i].disabled && cb_hover == i) { if (cb_pressing) { @@ -420,15 +420,15 @@ void Tabs::_notification(int p_what) { } if (rtl) { - cb->draw(ci, Point2i(size.width - w - cb_rect.size.x + style->get_margin(MARGIN_LEFT), cb_rect.position.y + style->get_margin(MARGIN_TOP))); + cb->draw(ci, Point2i(size.width - w - cb_rect.size.x + style->get_margin(SIDE_LEFT), cb_rect.position.y + style->get_margin(SIDE_TOP))); } else { - cb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), cb_rect.position.y + style->get_margin(MARGIN_TOP))); + cb->draw(ci, Point2i(w + style->get_margin(SIDE_LEFT), cb_rect.position.y + style->get_margin(SIDE_TOP))); } w += cb->get_width(); tabs.write[i].cb_rect = cb_rect; } - w += sb->get_margin(MARGIN_RIGHT); + w += sb->get_margin(SIDE_RIGHT); } if (offset > 0 || missing_right) { @@ -691,7 +691,7 @@ void Tabs::_update_cache() { int slen = tabs[i].size_text; if (min_width > 0 && mw > limit && i != current) { if (lsize > m_width) { - slen = m_width - (sb->get_margin(MARGIN_LEFT) + sb->get_margin(MARGIN_RIGHT)); + slen = m_width - (sb->get_margin(SIDE_LEFT) + sb->get_margin(SIDE_RIGHT)); if (tabs[i].icon.is_valid()) { slen -= tabs[i].icon->get_width(); slen -= get_theme_constant("hseparation"); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index f3569f9ce3..971d374667 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -296,8 +296,8 @@ void TextEdit::_update_scrollbars() { Size2 hmin = h_scroll->get_combined_minimum_size(); Size2 vmin = v_scroll->get_combined_minimum_size(); - v_scroll->set_begin(Point2(size.width - vmin.width, cache.style_normal->get_margin(MARGIN_TOP))); - v_scroll->set_end(Point2(size.width, size.height - cache.style_normal->get_margin(MARGIN_TOP) - cache.style_normal->get_margin(MARGIN_BOTTOM))); + v_scroll->set_begin(Point2(size.width - vmin.width, cache.style_normal->get_margin(SIDE_TOP))); + v_scroll->set_end(Point2(size.width, size.height - cache.style_normal->get_margin(SIDE_TOP) - cache.style_normal->get_margin(SIDE_BOTTOM))); h_scroll->set_begin(Point2(0, size.height - hmin.height)); h_scroll->set_end(Point2(size.width - vmin.width, size.height)); @@ -489,7 +489,7 @@ void TextEdit::_update_selection_mode_line() { void TextEdit::_update_minimap_click() { Point2 mp = _get_local_mouse_pos(); - int xmargin_end = get_size().width - cache.style_normal->get_margin(MARGIN_RIGHT); + int xmargin_end = get_size().width - cache.style_normal->get_margin(SIDE_RIGHT); if (!dragging_minimap && (mp.x < xmargin_end - minimap_width || mp.y > xmargin_end)) { minimap_clicked = false; return; @@ -622,9 +622,9 @@ void TextEdit::_notification(int p_what) { RID ci = get_canvas_item(); RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true); - int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding; + int xmargin_beg = cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding; - int xmargin_end = size.width - cache.style_normal->get_margin(MARGIN_RIGHT) - cache.minimap_width; + int xmargin_end = size.width - cache.style_normal->get_margin(SIDE_RIGHT) - cache.minimap_width; // Let's do it easy for now. cache.style_normal->draw(ci, Rect2(Point2(), size)); if (readonly) { @@ -1071,7 +1071,7 @@ void TextEdit::_notification(int p_what) { if (line_wrap_index == 0) { // Only do these if we are on the first wrapped part of a line. - int gutter_offset = cache.style_normal->get_margin(MARGIN_LEFT); + int gutter_offset = cache.style_normal->get_margin(SIDE_LEFT); for (int g = 0; g < gutters.size(); g++) { const GutterInfo gutter = gutters[g]; @@ -2035,7 +2035,7 @@ int TextEdit::_calculate_spaces_till_next_right_indent(int column) { void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const { float rows = p_mouse.y; - rows -= cache.style_normal->get_margin(MARGIN_TOP); + rows -= cache.style_normal->get_margin(SIDE_TOP); rows /= get_row_height(); rows += get_v_scroll_offset(); int first_vis_line = get_first_visible_line(); @@ -2061,7 +2061,7 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co row = text.size() - 1; col = text[row].size(); } else { - int colx = p_mouse.x - (cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding); + int colx = p_mouse.x - (cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding); colx += cursor.x_ofs; RID text_rid = text.get_line_data(row)->get_line_rid(wrap_index); @@ -2089,7 +2089,7 @@ Vector2i TextEdit::_get_cursor_pixel_pos(bool p_adjust_viewport) { // Calculate final pixel position int y = (row - get_v_scroll_offset()) * get_row_height(); - int x = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding - cursor.x_ofs; + int x = cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding - cursor.x_ofs; Rect2 l_caret, t_caret; TextServer::Direction l_dir, t_dir; @@ -2106,7 +2106,7 @@ Vector2i TextEdit::_get_cursor_pixel_pos(bool p_adjust_viewport) { void TextEdit::_get_minimap_mouse_row(const Point2i &p_mouse, int &r_row) const { float rows = p_mouse.y; - rows -= cache.style_normal->get_margin(MARGIN_TOP); + rows -= cache.style_normal->get_margin(SIDE_TOP); rows /= (minimap_char_size.y + minimap_line_spacing); rows += get_v_scroll_offset(); @@ -2234,7 +2234,7 @@ void TextEdit::_gui_input(const Ref &p_gui_input) { int row, col; _get_mouse_pos(Point2i(mpos.x, mpos.y), row, col); - int left_margin = cache.style_normal->get_margin(MARGIN_LEFT); + int left_margin = cache.style_normal->get_margin(SIDE_LEFT); for (int i = 0; i < gutters.size(); i++) { if (!gutters[i].draw || gutters[i].width <= 0) { continue; @@ -4575,7 +4575,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const { int row, col; _get_mouse_pos(p_pos, row, col); - int left_margin = cache.style_normal->get_margin(MARGIN_LEFT); + int left_margin = cache.style_normal->get_margin(SIDE_LEFT); int gutter = left_margin + gutters_width; if (p_pos.x < gutter) { for (int i = 0; i < gutters.size(); i++) { @@ -4593,7 +4593,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const { return CURSOR_ARROW; } - int xmargin_end = get_size().width - cache.style_normal->get_margin(MARGIN_RIGHT); + int xmargin_end = get_size().width - cache.style_normal->get_margin(SIDE_RIGHT); if (draw_minimap && p_pos.x > xmargin_end - minimap_width && p_pos.x <= xmargin_end) { return CURSOR_ARROW; } diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp index b5115690ac..8278bd3689 100644 --- a/scene/gui/texture_progress_bar.cpp +++ b/scene/gui/texture_progress_bar.cpp @@ -54,16 +54,16 @@ Ref TextureProgressBar::get_over_texture() const { return over; } -void TextureProgressBar::set_stretch_margin(Margin p_margin, int p_size) { - ERR_FAIL_INDEX((int)p_margin, 4); - stretch_margin[p_margin] = p_size; +void TextureProgressBar::set_stretch_margin(Side p_side, int p_size) { + ERR_FAIL_INDEX((int)p_side, 4); + stretch_margin[p_side] = p_size; update(); minimum_size_changed(); } -int TextureProgressBar::get_stretch_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); - return stretch_margin[p_margin]; +int TextureProgressBar::get_stretch_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0); + return stretch_margin[p_side]; } void TextureProgressBar::set_nine_patch_stretch(bool p_stretch) { @@ -78,7 +78,7 @@ bool TextureProgressBar::get_nine_patch_stretch() const { Size2 TextureProgressBar::get_minimum_size() const { if (nine_patch_stretch) { - return Size2(stretch_margin[MARGIN_LEFT] + stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_TOP] + stretch_margin[MARGIN_BOTTOM]); + return Size2(stretch_margin[SIDE_LEFT] + stretch_margin[SIDE_RIGHT], stretch_margin[SIDE_TOP] + stretch_margin[SIDE_BOTTOM]); } else if (under.is_valid()) { return under->get_size(); } else if (over.is_valid()) { @@ -206,8 +206,8 @@ Point2 TextureProgressBar::get_relative_center() { void TextureProgressBar::draw_nine_patch_stretched(const Ref &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) { Vector2 texture_size = p_texture->get_size(); - Vector2 topleft = Vector2(stretch_margin[MARGIN_LEFT], stretch_margin[MARGIN_TOP]); - Vector2 bottomright = Vector2(stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_BOTTOM]); + Vector2 topleft = Vector2(stretch_margin[SIDE_LEFT], stretch_margin[SIDE_TOP]); + Vector2 bottomright = Vector2(stretch_margin[SIDE_RIGHT], stretch_margin[SIDE_BOTTOM]); Rect2 src_rect = Rect2(Point2(), texture_size); Rect2 dst_rect = Rect2(Point2(), get_size()); @@ -523,10 +523,10 @@ void TextureProgressBar::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "radial_center_offset"), "set_radial_center_offset", "get_radial_center_offset"); ADD_GROUP("Stretch", "stretch_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "nine_patch_stretch"), "set_nine_patch_stretch", "get_nine_patch_stretch"); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", SIDE_BOTTOM); BIND_ENUM_CONSTANT(FILL_LEFT_TO_RIGHT); BIND_ENUM_CONSTANT(FILL_RIGHT_TO_LEFT); @@ -547,10 +547,10 @@ TextureProgressBar::TextureProgressBar() { set_mouse_filter(MOUSE_FILTER_PASS); nine_patch_stretch = false; - stretch_margin[MARGIN_LEFT] = 0; - stretch_margin[MARGIN_RIGHT] = 0; - stretch_margin[MARGIN_BOTTOM] = 0; - stretch_margin[MARGIN_TOP] = 0; + stretch_margin[SIDE_LEFT] = 0; + stretch_margin[SIDE_RIGHT] = 0; + stretch_margin[SIDE_BOTTOM] = 0; + stretch_margin[SIDE_TOP] = 0; tint_under = tint_progress = tint_over = Color(1, 1, 1); } diff --git a/scene/gui/texture_progress_bar.h b/scene/gui/texture_progress_bar.h index 342e719a59..4fab8076fd 100644 --- a/scene/gui/texture_progress_bar.h +++ b/scene/gui/texture_progress_bar.h @@ -78,8 +78,8 @@ public: void set_over_texture(const Ref &p_texture); Ref get_over_texture() const; - void set_stretch_margin(Margin p_margin, int p_size); - int get_stretch_margin(Margin p_margin) const; + void set_stretch_margin(Side p_side, int p_size); + int get_stretch_margin(Side p_side) const; void set_nine_patch_stretch(bool p_stretch); bool get_nine_patch_stretch() const; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 063a5e7ac1..ad4545cf6c 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1358,9 +1358,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (i == 0) { if (p_item->cells[0].selected && select_mode == SELECT_ROW) { - Rect2i row_rect = Rect2i(Point2i(cache.bg->get_margin(MARGIN_LEFT), item_rect.position.y), Size2i(get_size().width - cache.bg->get_minimum_size().width, item_rect.size.y)); + Rect2i row_rect = Rect2i(Point2i(cache.bg->get_margin(SIDE_LEFT), item_rect.position.y), Size2i(get_size().width - cache.bg->get_minimum_size().width, item_rect.size.y)); //Rect2 r = Rect2i(row_rect.pos,row_rect.size); - //r.grow(cache.selected->get_margin(MARGIN_LEFT)); + //r.grow(cache.selected->get_margin(SIDE_LEFT)); if (rtl) { row_rect.position.x = get_size().width - row_rect.position.x - row_rect.size.x; } @@ -1887,7 +1887,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool return -1; } else if (col == 0) { int margin = x_ofs + cache.item_margin; //-cache.hseparation; - //int lm = cache.bg->get_margin(MARGIN_LEFT); + //int lm = cache.bg->get_margin(SIDE_LEFT); col_width -= margin; col_ofs += margin; x -= margin; @@ -3005,8 +3005,8 @@ void Tree::update_scrollbars() { Size2 hmin = h_scroll->get_combined_minimum_size(); Size2 vmin = v_scroll->get_combined_minimum_size(); - v_scroll->set_begin(Point2(size.width - vmin.width, cache.bg->get_margin(MARGIN_TOP))); - v_scroll->set_end(Point2(size.width, size.height - cache.bg->get_margin(MARGIN_TOP) - cache.bg->get_margin(MARGIN_BOTTOM))); + v_scroll->set_begin(Point2(size.width - vmin.width, cache.bg->get_margin(SIDE_TOP))); + v_scroll->set_end(Point2(size.width, size.height - cache.bg->get_margin(SIDE_TOP) - cache.bg->get_margin(SIDE_BOTTOM))); h_scroll->set_begin(Point2(0, size.height - hmin.height)); h_scroll->set_end(Point2(size.width - vmin.width, size.height)); @@ -3166,11 +3166,11 @@ void Tree::_notification(int p_what) { if (show_column_titles) { //title buttons - int ofs2 = cache.bg->get_margin(MARGIN_LEFT); + int ofs2 = cache.bg->get_margin(SIDE_LEFT); for (int i = 0; i < columns.size(); i++) { Ref sb = (cache.click_type == Cache::CLICK_TITLE && cache.click_index == i) ? cache.title_button_pressed : ((cache.hover_type == Cache::CLICK_TITLE && cache.hover_index == i) ? cache.title_button_hover : cache.title_button); Ref f = cache.tb_font; - Rect2 tbrect = Rect2(ofs2 - cache.offset.x, bg->get_margin(MARGIN_TOP), get_column_width(i), tbh); + Rect2 tbrect = Rect2(ofs2 - cache.offset.x, bg->get_margin(SIDE_TOP), get_column_width(i), tbh); if (is_layout_rtl()) { tbrect.position.x = get_size().width - tbrect.size.x - tbrect.position.x; } @@ -3470,7 +3470,7 @@ int Tree::get_column_width(int p_column) const { Ref bg = cache.bg; - int expand_area = get_size().width - (bg->get_margin(MARGIN_LEFT) + bg->get_margin(MARGIN_RIGHT)); + int expand_area = get_size().width - (bg->get_margin(SIDE_LEFT) + bg->get_margin(SIDE_RIGHT)); if (v_scroll->is_visible_in_tree()) { expand_area -= v_scroll->get_combined_minimum_size().width; @@ -4249,7 +4249,7 @@ Tree::Tree() { popup_editor_vb = memnew(VBoxContainer); popup_editor->add_child(popup_editor_vb); popup_editor_vb->add_theme_constant_override("separation", 0); - popup_editor_vb->set_anchors_and_margins_preset(PRESET_WIDE); + popup_editor_vb->set_anchors_and_offsets_preset(PRESET_WIDE); text_editor = memnew(LineEdit); popup_editor_vb->add_child(text_editor); text_editor->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index c96dd4ad35..54cd3a0054 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1565,7 +1565,7 @@ void Viewport::_gui_show_tooltip() { base_tooltip = gui.tooltip_label; } - base_tooltip->set_anchors_and_margins_preset(Control::PRESET_WIDE); + base_tooltip->set_anchors_and_offsets_preset(Control::PRESET_WIDE); TooltipPanel *panel = memnew(TooltipPanel); panel->set_transient(false); @@ -2392,19 +2392,19 @@ void Viewport::_gui_input_event(Ref p_event) { } if (!mods && p_event->is_action_pressed("ui_up") && input->is_action_just_pressed("ui_up")) { - next = from->_get_focus_neighbor(MARGIN_TOP); + next = from->_get_focus_neighbor(SIDE_TOP); } if (!mods && p_event->is_action_pressed("ui_left") && input->is_action_just_pressed("ui_left")) { - next = from->_get_focus_neighbor(MARGIN_LEFT); + next = from->_get_focus_neighbor(SIDE_LEFT); } if (!mods && p_event->is_action_pressed("ui_right") && input->is_action_just_pressed("ui_right")) { - next = from->_get_focus_neighbor(MARGIN_RIGHT); + next = from->_get_focus_neighbor(SIDE_RIGHT); } if (!mods && p_event->is_action_pressed("ui_down") && input->is_action_just_pressed("ui_down")) { - next = from->_get_focus_neighbor(MARGIN_BOTTOM); + next = from->_get_focus_neighbor(SIDE_BOTTOM); } if (next) { diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 2de28b5e5c..7dbf53a43c 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -64,14 +64,14 @@ static Ref make_stylebox(T p_src, float p_left, float p_top, fl Ref style(memnew(StyleBoxTexture)); style->set_texture(texture); - style->set_margin_size(MARGIN_LEFT, p_left * scale); - style->set_margin_size(MARGIN_RIGHT, p_right * scale); - style->set_margin_size(MARGIN_BOTTOM, p_botton * scale); - style->set_margin_size(MARGIN_TOP, p_top * scale); - style->set_default_margin(MARGIN_LEFT, p_margin_left * scale); - style->set_default_margin(MARGIN_RIGHT, p_margin_right * scale); - style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * scale); - style->set_default_margin(MARGIN_TOP, p_margin_top * scale); + style->set_margin_size(SIDE_LEFT, p_left * scale); + style->set_margin_size(SIDE_RIGHT, p_right * scale); + style->set_margin_size(SIDE_BOTTOM, p_botton * scale); + style->set_margin_size(SIDE_TOP, p_top * scale); + style->set_default_margin(SIDE_LEFT, p_margin_left * scale); + style->set_default_margin(SIDE_RIGHT, p_margin_right * scale); + style->set_default_margin(SIDE_BOTTOM, p_margin_botton * scale); + style->set_default_margin(SIDE_TOP, p_margin_top * scale); style->set_draw_center(p_draw_center); return style; @@ -80,19 +80,19 @@ static Ref make_stylebox(T p_src, float p_left, float p_top, fl static Ref make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) { Ref style(memnew(StyleBoxFlat)); style->set_bg_color(p_color); - style->set_default_margin(MARGIN_LEFT, p_margin_left * scale); - style->set_default_margin(MARGIN_RIGHT, p_margin_right * scale); - style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * scale); - style->set_default_margin(MARGIN_TOP, p_margin_top * scale); + style->set_default_margin(SIDE_LEFT, p_margin_left * scale); + style->set_default_margin(SIDE_RIGHT, p_margin_right * scale); + style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * scale); + style->set_default_margin(SIDE_TOP, p_margin_top * scale); return style; } static Ref sb_expand(Ref p_sbox, float p_left, float p_top, float p_right, float p_botton) { - p_sbox->set_expand_margin_size(MARGIN_LEFT, p_left * scale); - p_sbox->set_expand_margin_size(MARGIN_TOP, p_top * scale); - p_sbox->set_expand_margin_size(MARGIN_RIGHT, p_right * scale); - p_sbox->set_expand_margin_size(MARGIN_BOTTOM, p_botton * scale); + p_sbox->set_expand_margin_size(SIDE_LEFT, p_left * scale); + p_sbox->set_expand_margin_size(SIDE_TOP, p_top * scale); + p_sbox->set_expand_margin_size(SIDE_RIGHT, p_right * scale); + p_sbox->set_expand_margin_size(SIDE_BOTTOM, p_botton * scale); return p_sbox; } @@ -130,10 +130,10 @@ static Ref flip_icon(Ref p_texture, bool p_flip_y = false, static Ref make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1) { Ref style(memnew(StyleBoxEmpty)); - style->set_default_margin(MARGIN_LEFT, p_margin_left * scale); - style->set_default_margin(MARGIN_RIGHT, p_margin_right * scale); - style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * scale); - style->set_default_margin(MARGIN_TOP, p_margin_top * scale); + style->set_default_margin(SIDE_LEFT, p_margin_left * scale); + style->set_default_margin(SIDE_RIGHT, p_margin_right * scale); + style->set_default_margin(SIDE_BOTTOM, p_margin_botton * scale); + style->set_default_margin(SIDE_TOP, p_margin_top * scale); return style; } @@ -162,7 +162,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const Ref focus = make_stylebox(focus_png, 5, 5, 5, 5); for (int i = 0; i < 4; i++) { - focus->set_expand_margin_size(Margin(i), 1 * scale); + focus->set_expand_margin_size(Side(i), 1 * scale); } // Button @@ -281,15 +281,15 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const // CheckBox Ref cbx_empty = memnew(StyleBoxEmpty); - cbx_empty->set_default_margin(MARGIN_LEFT, 4 * scale); - cbx_empty->set_default_margin(MARGIN_RIGHT, 4 * scale); - cbx_empty->set_default_margin(MARGIN_TOP, 4 * scale); - cbx_empty->set_default_margin(MARGIN_BOTTOM, 4 * scale); + cbx_empty->set_default_margin(SIDE_LEFT, 4 * scale); + cbx_empty->set_default_margin(SIDE_RIGHT, 4 * scale); + cbx_empty->set_default_margin(SIDE_TOP, 4 * scale); + cbx_empty->set_default_margin(SIDE_BOTTOM, 4 * scale); Ref cbx_focus = focus; - cbx_focus->set_default_margin(MARGIN_LEFT, 4 * scale); - cbx_focus->set_default_margin(MARGIN_RIGHT, 4 * scale); - cbx_focus->set_default_margin(MARGIN_TOP, 4 * scale); - cbx_focus->set_default_margin(MARGIN_BOTTOM, 4 * scale); + cbx_focus->set_default_margin(SIDE_LEFT, 4 * scale); + cbx_focus->set_default_margin(SIDE_RIGHT, 4 * scale); + cbx_focus->set_default_margin(SIDE_TOP, 4 * scale); + cbx_focus->set_default_margin(SIDE_BOTTOM, 4 * scale); theme->set_stylebox("normal", "CheckBox", cbx_empty); theme->set_stylebox("pressed", "CheckBox", cbx_empty); @@ -318,10 +318,10 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const // CheckButton Ref cb_empty = memnew(StyleBoxEmpty); - cb_empty->set_default_margin(MARGIN_LEFT, 6 * scale); - cb_empty->set_default_margin(MARGIN_RIGHT, 6 * scale); - cb_empty->set_default_margin(MARGIN_TOP, 4 * scale); - cb_empty->set_default_margin(MARGIN_BOTTOM, 4 * scale); + cb_empty->set_default_margin(SIDE_LEFT, 6 * scale); + cb_empty->set_default_margin(SIDE_RIGHT, 6 * scale); + cb_empty->set_default_margin(SIDE_TOP, 4 * scale); + cb_empty->set_default_margin(SIDE_BOTTOM, 4 * scale); theme->set_stylebox("normal", "CheckButton", cb_empty); theme->set_stylebox("pressed", "CheckButton", cb_empty); @@ -568,7 +568,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const Ref selected = make_stylebox(selection_png, 6, 6, 6, 6); for (int i = 0; i < 4; i++) { - selected->set_expand_margin_size(Margin(i), 2 * scale); + selected->set_expand_margin_size(Side(i), 2 * scale); } theme->set_stylebox("panel", "PopupPanel", style_pp); @@ -617,8 +617,8 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const Ref graph_bpoint = make_stylebox(graph_node_breakpoint_png, 6, 24, 6, 5, 16, 24, 16, 6); Ref graph_position = make_stylebox(graph_node_position_png, 6, 24, 6, 5, 16, 24, 16, 6); - //graphsb->set_expand_margin_size(MARGIN_LEFT,10); - //graphsb->set_expand_margin_size(MARGIN_RIGHT,10); + //graphsb->set_expand_margin_size(SIDE_LEFT,10); + //graphsb->set_expand_margin_size(SIDE_RIGHT,10); theme->set_stylebox("frame", "GraphNode", graphsb); theme->set_stylebox("selectedframe", "GraphNode", graphsbselected); theme->set_stylebox("defaultframe", "GraphNode", graphsbdefault); @@ -713,8 +713,8 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const Ref tc_sb = sb_expand(make_stylebox(tab_container_bg_png, 4, 4, 4, 4, 4, 4, 4, 4), 3, 3, 3, 3); - tc_sb->set_expand_margin_size(MARGIN_TOP, 2 * scale); - tc_sb->set_default_margin(MARGIN_TOP, 8 * scale); + tc_sb->set_expand_margin_size(SIDE_TOP, 2 * scale); + tc_sb->set_default_margin(SIDE_TOP, 8 * scale); theme->set_stylebox("tab_fg", "TabContainer", sb_expand(make_stylebox(tab_current_png, 4, 4, 4, 1, 16, 4, 16, 4), 2, 2, 2, 2)); theme->set_stylebox("tab_bg", "TabContainer", sb_expand(make_stylebox(tab_behind_png, 5, 5, 5, 1, 16, 6, 16, 4), 3, 0, 3, 3)); @@ -808,7 +808,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const Ref style_tt = make_stylebox(tooltip_bg_png, 4, 4, 4, 4); for (int i = 0; i < 4; i++) { - style_tt->set_expand_margin_size((Margin)i, 4 * scale); + style_tt->set_expand_margin_size((Side)i, 4 * scale); } theme->set_stylebox("panel", "TooltipPanel", style_tt); diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 14197c6c68..0271edaff0 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -38,26 +38,26 @@ bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const { return true; } -void StyleBox::set_default_margin(Margin p_margin, float p_value) { - ERR_FAIL_INDEX((int)p_margin, 4); +void StyleBox::set_default_margin(Side p_side, float p_value) { + ERR_FAIL_INDEX((int)p_side, 4); - margin[p_margin] = p_value; + margin[p_side] = p_value; emit_changed(); } -float StyleBox::get_default_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0); +float StyleBox::get_default_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0.0); - return margin[p_margin]; + return margin[p_side]; } -float StyleBox::get_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0); +float StyleBox::get_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0.0); - if (margin[p_margin] < 0) { - return get_style_margin(p_margin); + if (margin[p_side] < 0) { + return get_style_margin(p_side); } else { - return margin[p_margin]; + return margin[p_side]; } } @@ -66,11 +66,11 @@ CanvasItem *StyleBox::get_current_item_drawn() const { } Size2 StyleBox::get_minimum_size() const { - return Size2(get_margin(MARGIN_LEFT) + get_margin(MARGIN_RIGHT), get_margin(MARGIN_TOP) + get_margin(MARGIN_BOTTOM)); + return Size2(get_margin(SIDE_LEFT) + get_margin(SIDE_RIGHT), get_margin(SIDE_TOP) + get_margin(SIDE_BOTTOM)); } Point2 StyleBox::get_offset() const { - return Point2(get_margin(MARGIN_LEFT), get_margin(MARGIN_TOP)); + return Point2(get_margin(SIDE_LEFT), get_margin(SIDE_TOP)); } Size2 StyleBox::get_center_size() const { @@ -99,10 +99,10 @@ void StyleBox::_bind_methods() { ClassDB::bind_method(D_METHOD("draw", "canvas_item", "rect"), &StyleBox::draw); ADD_GROUP("Content Margin", "content_margin_"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_left", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_right", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_top", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_bottom", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_left", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_right", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_top", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_bottom", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", SIDE_BOTTOM); } StyleBox::StyleBox() { @@ -130,10 +130,10 @@ Ref StyleBoxTexture::get_texture() const { return texture; } -void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) { - ERR_FAIL_INDEX((int)p_margin, 4); +void StyleBoxTexture::set_margin_size(Side p_side, float p_size) { + ERR_FAIL_INDEX((int)p_side, 4); - margin[p_margin] = p_size; + margin[p_side] = p_size; emit_changed(); static const char *margin_prop[4] = { "content_margin_left", @@ -141,23 +141,23 @@ void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) { "content_margin_right", "content_margin_bottom", }; - _change_notify(margin_prop[p_margin]); + _change_notify(margin_prop[p_side]); } -float StyleBoxTexture::get_margin_size(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0); +float StyleBoxTexture::get_margin_size(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0.0); - return margin[p_margin]; + return margin[p_side]; } -float StyleBoxTexture::get_style_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0); +float StyleBoxTexture::get_style_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0.0); - return margin[p_margin]; + return margin[p_side]; } Rect2 StyleBoxTexture::get_draw_rect(const Rect2 &p_rect) const { - return p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]); + return p_rect.grow_individual(expand_margin[SIDE_LEFT], expand_margin[SIDE_TOP], expand_margin[SIDE_RIGHT], expand_margin[SIDE_BOTTOM]); } void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const { @@ -170,12 +170,12 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const { texture->get_rect_region(rect, src_rect, rect, src_rect); - rect.position.x -= expand_margin[MARGIN_LEFT]; - rect.position.y -= expand_margin[MARGIN_TOP]; - rect.size.x += expand_margin[MARGIN_LEFT] + expand_margin[MARGIN_RIGHT]; - rect.size.y += expand_margin[MARGIN_TOP] + expand_margin[MARGIN_BOTTOM]; + rect.position.x -= expand_margin[SIDE_LEFT]; + rect.position.y -= expand_margin[SIDE_TOP]; + rect.size.x += expand_margin[SIDE_LEFT] + expand_margin[SIDE_RIGHT]; + rect.size.y += expand_margin[SIDE_TOP] + expand_margin[SIDE_BOTTOM]; - RenderingServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center, modulate); + RenderingServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[SIDE_LEFT], margin[SIDE_TOP]), Vector2(margin[SIDE_RIGHT], margin[SIDE_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center, modulate); } void StyleBoxTexture::set_draw_center(bool p_enabled) { @@ -195,17 +195,17 @@ Size2 StyleBoxTexture::get_center_size() const { return region_rect.size - get_minimum_size(); } -void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin, float p_size) { - ERR_FAIL_INDEX((int)p_expand_margin, 4); - expand_margin[p_expand_margin] = p_size; +void StyleBoxTexture::set_expand_margin_size(Side p_side, float p_size) { + ERR_FAIL_INDEX((int)p_side, 4); + expand_margin[p_side] = p_size; emit_changed(); } void StyleBoxTexture::set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom) { - expand_margin[MARGIN_LEFT] = p_left; - expand_margin[MARGIN_TOP] = p_top; - expand_margin[MARGIN_RIGHT] = p_right; - expand_margin[MARGIN_BOTTOM] = p_bottom; + expand_margin[SIDE_LEFT] = p_left; + expand_margin[SIDE_TOP] = p_top; + expand_margin[SIDE_RIGHT] = p_right; + expand_margin[SIDE_BOTTOM] = p_bottom; emit_changed(); } @@ -216,9 +216,9 @@ void StyleBoxTexture::set_expand_margin_size_all(float p_expand_margin_size) { emit_changed(); } -float StyleBoxTexture::get_expand_margin_size(Margin p_expand_margin) const { - ERR_FAIL_INDEX_V((int)p_expand_margin, 4, 0); - return expand_margin[p_expand_margin]; +float StyleBoxTexture::get_expand_margin_size(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0); + return expand_margin[p_side]; } void StyleBoxTexture::set_region_rect(const Rect2 &p_region_rect) { @@ -299,15 +299,15 @@ void StyleBoxTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); ADD_GROUP("Margin", "margin_"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", SIDE_BOTTOM); ADD_GROUP("Expand Margin", "expand_margin_"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", SIDE_BOTTOM); ADD_GROUP("Axis Stretch", "axis_stretch_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "axis_stretch_horizontal", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_h_axis_stretch_mode", "get_h_axis_stretch_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "axis_stretch_vertical", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_v_axis_stretch_mode", "get_v_axis_stretch_mode"); @@ -367,15 +367,15 @@ int StyleBoxFlat::get_border_width_min() const { return MIN(MIN(border_width[0], border_width[1]), MIN(border_width[2], border_width[3])); } -void StyleBoxFlat::set_border_width(Margin p_margin, int p_width) { - ERR_FAIL_INDEX((int)p_margin, 4); - border_width[p_margin] = p_width; +void StyleBoxFlat::set_border_width(Side p_side, int p_width) { + ERR_FAIL_INDEX((int)p_side, 4); + border_width[p_side] = p_width; emit_changed(); } -int StyleBoxFlat::get_border_width(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0); - return border_width[p_margin]; +int StyleBoxFlat::get_border_width(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0); + return border_width[p_side]; } void StyleBoxFlat::set_border_blend(bool p_blend) { @@ -415,17 +415,17 @@ int StyleBoxFlat::get_corner_radius(const Corner p_corner) const { return corner_radius[p_corner]; } -void StyleBoxFlat::set_expand_margin_size(Margin p_expand_margin, float p_size) { - ERR_FAIL_INDEX((int)p_expand_margin, 4); - expand_margin[p_expand_margin] = p_size; +void StyleBoxFlat::set_expand_margin_size(Side p_side, float p_size) { + ERR_FAIL_INDEX((int)p_side, 4); + expand_margin[p_side] = p_size; emit_changed(); } void StyleBoxFlat::set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom) { - expand_margin[MARGIN_LEFT] = p_left; - expand_margin[MARGIN_TOP] = p_top; - expand_margin[MARGIN_RIGHT] = p_right; - expand_margin[MARGIN_BOTTOM] = p_bottom; + expand_margin[SIDE_LEFT] = p_left; + expand_margin[SIDE_TOP] = p_top; + expand_margin[SIDE_RIGHT] = p_right; + expand_margin[SIDE_BOTTOM] = p_bottom; emit_changed(); } @@ -436,9 +436,9 @@ void StyleBoxFlat::set_expand_margin_size_all(float p_expand_margin_size) { emit_changed(); } -float StyleBoxFlat::get_expand_margin_size(Margin p_expand_margin) const { - ERR_FAIL_INDEX_V((int)p_expand_margin, 4, 0.0); - return expand_margin[p_expand_margin]; +float StyleBoxFlat::get_expand_margin_size(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0.0); + return expand_margin[p_side]; } void StyleBoxFlat::set_draw_center(bool p_enabled) { @@ -633,7 +633,7 @@ inline void adapt_values(int p_index_a, int p_index_b, int *adapted_values, cons } Rect2 StyleBoxFlat::get_draw_rect(const Rect2 &p_rect) const { - Rect2 draw_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]); + Rect2 draw_rect = p_rect.grow_individual(expand_margin[SIDE_LEFT], expand_margin[SIDE_TOP], expand_margin[SIDE_RIGHT], expand_margin[SIDE_BOTTOM]); if (shadow_size > 0) { Rect2 shadow_rect = draw_rect.grow(shadow_size); @@ -652,7 +652,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { return; } - Rect2 style_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]); + Rect2 style_rect = p_rect.grow_individual(expand_margin[SIDE_LEFT], expand_margin[SIDE_TOP], expand_margin[SIDE_RIGHT], expand_margin[SIDE_BOTTOM]); if (Math::is_zero_approx(style_rect.size.width) || Math::is_zero_approx(style_rect.size.height)) { return; } @@ -671,23 +671,23 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { int width = MAX(style_rect.size.width, 0); int height = MAX(style_rect.size.height, 0); int adapted_border[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX }; - adapt_values(MARGIN_TOP, MARGIN_BOTTOM, adapted_border, border_width, height, height, height); - adapt_values(MARGIN_LEFT, MARGIN_RIGHT, adapted_border, border_width, width, width, width); + adapt_values(SIDE_TOP, SIDE_BOTTOM, adapted_border, border_width, height, height, height); + adapt_values(SIDE_LEFT, SIDE_RIGHT, adapted_border, border_width, width, width, width); //adapt corners (prevent weird overlapping/glitchy drawings) int adapted_corner[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX }; - adapt_values(CORNER_TOP_RIGHT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, height, height - adapted_border[MARGIN_BOTTOM], height - adapted_border[MARGIN_TOP]); - adapt_values(CORNER_TOP_LEFT, CORNER_BOTTOM_LEFT, adapted_corner, corner_radius, height, height - adapted_border[MARGIN_BOTTOM], height - adapted_border[MARGIN_TOP]); - adapt_values(CORNER_TOP_LEFT, CORNER_TOP_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[MARGIN_RIGHT], width - adapted_border[MARGIN_LEFT]); - adapt_values(CORNER_BOTTOM_LEFT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[MARGIN_RIGHT], width - adapted_border[MARGIN_LEFT]); + adapt_values(CORNER_TOP_RIGHT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, height, height - adapted_border[SIDE_BOTTOM], height - adapted_border[SIDE_TOP]); + adapt_values(CORNER_TOP_LEFT, CORNER_BOTTOM_LEFT, adapted_corner, corner_radius, height, height - adapted_border[SIDE_BOTTOM], height - adapted_border[SIDE_TOP]); + adapt_values(CORNER_TOP_LEFT, CORNER_TOP_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[SIDE_RIGHT], width - adapted_border[SIDE_LEFT]); + adapt_values(CORNER_BOTTOM_LEFT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[SIDE_RIGHT], width - adapted_border[SIDE_LEFT]); - Rect2 infill_rect = style_rect.grow_individual(-adapted_border[MARGIN_LEFT], -adapted_border[MARGIN_TOP], -adapted_border[MARGIN_RIGHT], -adapted_border[MARGIN_BOTTOM]); + Rect2 infill_rect = style_rect.grow_individual(-adapted_border[SIDE_LEFT], -adapted_border[SIDE_TOP], -adapted_border[SIDE_RIGHT], -adapted_border[SIDE_BOTTOM]); Rect2 border_style_rect = style_rect; if (aa_on) { for (int i = 0; i < 4; i++) { if (border_width[i] > 0) { - border_style_rect = border_style_rect.grow_margin((Margin)i, -aa_size_grow); + border_style_rect = border_style_rect.grow_margin((Side)i, -aa_size_grow); } } } @@ -748,8 +748,8 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { } } - Rect2 infill_inner_rect = infill_rect.grow_individual(-aa_border_width[MARGIN_LEFT], -aa_border_width[MARGIN_TOP], - -aa_border_width[MARGIN_RIGHT], -aa_border_width[MARGIN_BOTTOM]); + Rect2 infill_inner_rect = infill_rect.grow_individual(-aa_border_width[SIDE_LEFT], -aa_border_width[SIDE_TOP], + -aa_border_width[SIDE_RIGHT], -aa_border_width[SIDE_BOTTOM]); if (draw_center) { if (!blend_on && draw_border) { @@ -759,8 +759,8 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { } if (!blend_on || !draw_border) { - Rect2 infill_aa_rect = infill_rect.grow_individual(aa_fill_width[MARGIN_LEFT], aa_fill_width[MARGIN_TOP], - aa_fill_width[MARGIN_RIGHT], aa_fill_width[MARGIN_BOTTOM]); + Rect2 infill_aa_rect = infill_rect.grow_individual(aa_fill_width[SIDE_LEFT], aa_fill_width[SIDE_TOP], + aa_fill_width[SIDE_RIGHT], aa_fill_width[SIDE_BOTTOM]); Color alpha_bg = Color(bg_color.r, bg_color.g, bg_color.b, 0); @@ -796,9 +796,9 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { vs->canvas_item_add_triangle_array(p_canvas_item, indices, verts, colors, uvs); } -float StyleBoxFlat::get_style_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, 0.0); - return border_width[p_margin]; +float StyleBoxFlat::get_style_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, 0.0); + return border_width[p_side]; } void StyleBoxFlat::_bind_methods() { @@ -854,10 +854,10 @@ void StyleBoxFlat::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_center"), "set_draw_center", "is_draw_center_enabled"); ADD_GROUP("Border Width", "border_width_"); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_top", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_bottom", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_top", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_bottom", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", SIDE_BOTTOM); ADD_GROUP("Border", "border_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "border_color"), "set_border_color", "get_border_color"); @@ -873,10 +873,10 @@ void StyleBoxFlat::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,20,1"), "set_corner_detail", "get_corner_detail"); ADD_GROUP("Expand Margin", "expand_margin_"); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_LEFT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_RIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", SIDE_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", SIDE_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "expand_margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", SIDE_BOTTOM); ADD_GROUP("Shadow", "shadow_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color"), "set_shadow_color", "get_shadow_color"); @@ -985,8 +985,8 @@ void StyleBoxLine::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vertical"), "set_vertical", "is_vertical"); } -float StyleBoxLine::get_style_margin(Margin p_margin) const { - ERR_FAIL_INDEX_V((int)p_margin, 4, thickness); +float StyleBoxLine::get_style_margin(Side p_side) const { + ERR_FAIL_INDEX_V((int)p_side, 4, thickness); return thickness; } diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 7dd806e840..52d3160d36 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -44,15 +44,15 @@ class StyleBox : public Resource { float margin[4]; protected: - virtual float get_style_margin(Margin p_margin) const = 0; + virtual float get_style_margin(Side p_side) const = 0; static void _bind_methods(); public: virtual bool test_mask(const Point2 &p_point, const Rect2 &p_rect) const; - void set_default_margin(Margin p_margin, float p_value); - float get_default_margin(Margin p_margin) const; - float get_margin(Margin p_margin) const; + void set_default_margin(Side p_side, float p_value); + float get_default_margin(Side p_side) const; + float get_margin(Side p_side) const; virtual Size2 get_center_size() const; virtual Rect2 get_draw_rect(const Rect2 &p_rect) const; @@ -68,7 +68,7 @@ public: class StyleBoxEmpty : public StyleBox { GDCLASS(StyleBoxEmpty, StyleBox); - virtual float get_style_margin(Margin p_margin) const override { return 0; } + virtual float get_style_margin(Side p_side) const override { return 0; } public: virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const override {} @@ -96,17 +96,17 @@ private: AxisStretchMode axis_v; protected: - virtual float get_style_margin(Margin p_margin) const override; + virtual float get_style_margin(Side p_side) const override; static void _bind_methods(); public: - void set_expand_margin_size(Margin p_expand_margin, float p_size); + void set_expand_margin_size(Side p_expand_side, float p_size); void set_expand_margin_size_all(float p_expand_margin_size); void set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom); - float get_expand_margin_size(Margin p_expand_margin) const; + float get_expand_margin_size(Side p_expand_side) const; - void set_margin_size(Margin p_margin, float p_size); - float get_margin_size(Margin p_margin) const; + void set_margin_size(Side p_side, float p_size); + float get_margin_size(Side p_side) const; void set_region_rect(const Rect2 &p_region_rect); Rect2 get_region_rect() const; @@ -157,7 +157,7 @@ class StyleBoxFlat : public StyleBox { int aa_size; protected: - virtual float get_style_margin(Margin p_margin) const override; + virtual float get_style_margin(Side p_side) const override; static void _bind_methods(); public: @@ -174,8 +174,8 @@ public: void set_border_width_all(int p_size); int get_border_width_min() const; - void set_border_width(Margin p_margin, int p_width); - int get_border_width(Margin p_margin) const; + void set_border_width(Side p_side, int p_width); + int get_border_width(Side p_side) const; //blend void set_border_blend(bool p_blend); @@ -192,10 +192,10 @@ public: int get_corner_detail() const; //EXPANDS - void set_expand_margin_size(Margin p_expand_margin, float p_size); + void set_expand_margin_size(Side p_expand_side, float p_size); void set_expand_margin_size_all(float p_expand_margin_size); void set_expand_margin_size_individual(float p_left, float p_top, float p_right, float p_bottom); - float get_expand_margin_size(Margin p_expand_margin) const; + float get_expand_margin_size(Side p_expand_side) const; //DRAW CENTER void set_draw_center(bool p_enabled); @@ -237,7 +237,7 @@ class StyleBoxLine : public StyleBox { float grow_end; protected: - virtual float get_style_margin(Margin p_margin) const override; + virtual float get_style_margin(Side p_side) const override; static void _bind_methods(); public: diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index 53deba512e..ea6ed2b532 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -825,10 +825,10 @@ void RendererCanvasCull::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_r style->source = p_source; style->draw_center = p_draw_center; style->color = p_modulate; - style->margin[MARGIN_LEFT] = p_topleft.x; - style->margin[MARGIN_TOP] = p_topleft.y; - style->margin[MARGIN_RIGHT] = p_bottomright.x; - style->margin[MARGIN_BOTTOM] = p_bottomright.y; + style->margin[SIDE_LEFT] = p_topleft.x; + style->margin[SIDE_TOP] = p_topleft.y; + style->margin[SIDE_RIGHT] = p_bottomright.x; + style->margin[SIDE_BOTTOM] = p_bottomright.y; style->axis_x = p_x_axis_mode; style->axis_y = p_y_axis_mode; } diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 8fa56b182c..591018346a 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -601,10 +601,10 @@ void RendererCanvasRenderRD::_render_item(RD::DrawListID p_draw_list, const Item push_constant.flags |= FLAGS_NINEPACH_DRAW_CENTER; } - push_constant.ninepatch_margins[0] = np->margin[MARGIN_LEFT]; - push_constant.ninepatch_margins[1] = np->margin[MARGIN_TOP]; - push_constant.ninepatch_margins[2] = np->margin[MARGIN_RIGHT]; - push_constant.ninepatch_margins[3] = np->margin[MARGIN_BOTTOM]; + push_constant.ninepatch_margins[0] = np->margin[SIDE_LEFT]; + push_constant.ninepatch_margins[1] = np->margin[SIDE_TOP]; + push_constant.ninepatch_margins[2] = np->margin[SIDE_RIGHT]; + push_constant.ninepatch_margins[3] = np->margin[SIDE_BOTTOM]; RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant)); RD::get_singleton()->draw_list_bind_index_array(p_draw_list, shader.quad_index_array); diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index 47f7fa07d5..8c7c25c19b 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -45,17 +45,17 @@ int RenderingServerDefault::changes = 0; /* BLACK BARS */ void RenderingServerDefault::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) { - black_margin[MARGIN_LEFT] = p_left; - black_margin[MARGIN_TOP] = p_top; - black_margin[MARGIN_RIGHT] = p_right; - black_margin[MARGIN_BOTTOM] = p_bottom; + black_margin[SIDE_LEFT] = p_left; + black_margin[SIDE_TOP] = p_top; + black_margin[SIDE_RIGHT] = p_right; + black_margin[SIDE_BOTTOM] = p_bottom; } void RenderingServerDefault::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) { - black_image[MARGIN_LEFT] = p_left; - black_image[MARGIN_TOP] = p_top; - black_image[MARGIN_RIGHT] = p_right; - black_image[MARGIN_BOTTOM] = p_bottom; + black_image[SIDE_LEFT] = p_left; + black_image[SIDE_TOP] = p_top; + black_image[SIDE_RIGHT] = p_right; + black_image[SIDE_BOTTOM] = p_bottom; } void RenderingServerDefault::_draw_margins() { diff --git a/tests/test_gui.cpp b/tests/test_gui.cpp index c2d81bda69..a4559687c8 100644 --- a/tests/test_gui.cpp +++ b/tests/test_gui.cpp @@ -67,8 +67,8 @@ public: SceneTree::init(); Panel *frame = memnew(Panel); - frame->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END); - frame->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END); + frame->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); + frame->set_anchor(SIDE_BOTTOM, Control::ANCHOR_END); frame->set_end(Point2(0, 0)); Ref t = memnew(Theme); @@ -199,7 +199,7 @@ public: richtext->set_position(Point2(600, 210)); richtext->set_size(Point2(180, 250)); - richtext->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -20); + richtext->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -20); frame->add_child(richtext); diff --git a/tests/test_rect2.h b/tests/test_rect2.h index b1c588fda1..b6edc9ce81 100644 --- a/tests/test_rect2.h +++ b/tests/test_rect2.h @@ -197,10 +197,10 @@ TEST_CASE("[Rect2] Growing") { "grow_individual() with positive and negative values should return the expected Rect2."); CHECK_MESSAGE( - Rect2(0, 100, 1280, 720).grow_margin(MARGIN_TOP, 500).is_equal_approx(Rect2(0, -400, 1280, 1220)), + Rect2(0, 100, 1280, 720).grow_margin(SIDE_TOP, 500).is_equal_approx(Rect2(0, -400, 1280, 1220)), "grow_margin() with positive value should return the expected Rect2."); CHECK_MESSAGE( - Rect2(0, 100, 1280, 720).grow_margin(MARGIN_TOP, -500).is_equal_approx(Rect2(0, 600, 1280, 220)), + Rect2(0, 100, 1280, 720).grow_margin(SIDE_TOP, -500).is_equal_approx(Rect2(0, 600, 1280, 220)), "grow_margin() with negative value should return the expected Rect2."); } @@ -409,10 +409,10 @@ TEST_CASE("[Rect2i] Growing") { "grow_individual() with positive and negative values should return the expected Rect2i."); CHECK_MESSAGE( - Rect2i(0, 100, 1280, 720).grow_margin(MARGIN_TOP, 500) == Rect2i(0, -400, 1280, 1220), + Rect2i(0, 100, 1280, 720).grow_margin(SIDE_TOP, 500) == Rect2i(0, -400, 1280, 1220), "grow_margin() with positive value should return the expected Rect2i."); CHECK_MESSAGE( - Rect2i(0, 100, 1280, 720).grow_margin(MARGIN_TOP, -500) == Rect2i(0, 600, 1280, 220), + Rect2i(0, 100, 1280, 720).grow_margin(SIDE_TOP, -500) == Rect2i(0, 600, 1280, 220), "grow_margin() with negative value should return the expected Rect2i."); }