summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/animated_sprite_2d.cpp2
-rw-r--r--scene/2d/camera_2d.cpp130
-rw-r--r--scene/2d/camera_2d.h8
-rw-r--r--scene/2d/canvas_modulate.cpp2
-rw-r--r--scene/2d/collision_object_2d.cpp4
-rw-r--r--scene/2d/collision_polygon_2d.cpp6
-rw-r--r--scene/2d/joints_2d.cpp12
-rw-r--r--scene/2d/light_2d.cpp2
-rw-r--r--scene/2d/light_occluder_2d.cpp4
-rw-r--r--scene/2d/navigation_agent_2d.cpp2
-rw-r--r--scene/2d/navigation_obstacle_2d.cpp2
-rw-r--r--scene/2d/navigation_region_2d.cpp4
-rw-r--r--scene/2d/node_2d.cpp9
-rw-r--r--scene/2d/node_2d.h14
-rw-r--r--scene/2d/parallax_layer.cpp2
-rw-r--r--scene/2d/path_2d.cpp13
-rw-r--r--scene/2d/path_2d.h18
-rw-r--r--scene/2d/physics_body_2d.cpp4
-rw-r--r--scene/2d/remote_transform_2d.cpp2
-rw-r--r--scene/2d/skeleton_2d.cpp4
-rw-r--r--scene/2d/tile_map.cpp2
-rw-r--r--scene/2d/visibility_notifier_2d.cpp2
-rw-r--r--scene/3d/baked_lightmap.cpp2
-rw-r--r--scene/3d/collision_object_3d.cpp4
-rw-r--r--scene/3d/collision_polygon_3d.cpp6
-rw-r--r--scene/3d/collision_shape_3d.cpp8
-rw-r--r--scene/3d/gi_probe.cpp2
-rw-r--r--scene/3d/light_3d.cpp6
-rw-r--r--scene/3d/navigation_agent_3d.cpp2
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp2
-rw-r--r--scene/3d/navigation_region_3d.cpp4
-rw-r--r--scene/3d/node_3d.cpp26
-rw-r--r--scene/3d/node_3d.h33
-rw-r--r--scene/3d/path_3d.cpp15
-rw-r--r--scene/3d/path_3d.h18
-rw-r--r--scene/3d/physics_body_3d.cpp6
-rw-r--r--scene/3d/physics_body_3d.h12
-rw-r--r--scene/3d/physics_joint_3d.cpp4
-rw-r--r--scene/3d/remote_transform_3d.cpp2
-rw-r--r--scene/3d/skeleton_ik_3d.cpp6
-rw-r--r--scene/3d/soft_body_3d.cpp4
-rw-r--r--scene/3d/sprite_3d.cpp2
-rw-r--r--scene/3d/vehicle_body_3d.cpp2
-rw-r--r--scene/3d/velocity_tracker_3d.cpp6
-rw-r--r--scene/3d/voxelizer.cpp2
-rw-r--r--scene/3d/world_environment.cpp4
-rw-r--r--scene/3d/xr_nodes.cpp18
-rw-r--r--scene/3d/xr_nodes.h2
-rw-r--r--scene/animation/animation_player.cpp84
-rw-r--r--scene/animation/animation_player.h19
-rw-r--r--scene/animation/animation_tree.cpp10
-rw-r--r--scene/gui/button.cpp50
-rw-r--r--scene/gui/button.h2
-rw-r--r--scene/gui/check_box.cpp18
-rw-r--r--scene/gui/check_button.cpp18
-rw-r--r--scene/gui/color_picker.cpp8
-rw-r--r--scene/gui/container.cpp2
-rw-r--r--scene/gui/control.cpp342
-rw-r--r--scene/gui/control.h85
-rw-r--r--scene/gui/dialogs.cpp6
-rw-r--r--scene/gui/file_dialog.cpp16
-rw-r--r--scene/gui/file_dialog.h2
-rw-r--r--scene/gui/graph_edit.cpp74
-rw-r--r--scene/gui/graph_node.cpp34
-rw-r--r--scene/gui/graph_node.h6
-rw-r--r--scene/gui/item_list.cpp24
-rw-r--r--scene/gui/item_list.h4
-rw-r--r--scene/gui/label.cpp4
-rw-r--r--scene/gui/line_edit.cpp68
-rw-r--r--scene/gui/nine_patch_rect.cpp42
-rw-r--r--scene/gui/nine_patch_rect.h4
-rw-r--r--scene/gui/option_button.cpp12
-rw-r--r--scene/gui/panel.cpp3
-rw-r--r--scene/gui/panel.h1
-rw-r--r--scene/gui/popup_menu.cpp20
-rw-r--r--scene/gui/progress_bar.cpp2
-rw-r--r--scene/gui/range.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp39
-rw-r--r--scene/gui/rich_text_label.h2
-rw-r--r--scene/gui/scroll_bar.cpp8
-rw-r--r--scene/gui/scroll_container.cpp23
-rw-r--r--scene/gui/spin_box.cpp6
-rw-r--r--scene/gui/tab_container.cpp100
-rw-r--r--scene/gui/tab_container.h2
-rw-r--r--scene/gui/tabs.cpp26
-rw-r--r--scene/gui/text_edit.cpp40
-rw-r--r--scene/gui/texture_progress_bar.cpp34
-rw-r--r--scene/gui/texture_progress_bar.h4
-rw-r--r--scene/gui/tree.cpp26
-rw-r--r--scene/main/canvas_item.cpp28
-rw-r--r--scene/main/canvas_item.h60
-rw-r--r--scene/main/node.cpp75
-rw-r--r--scene/main/node.h66
-rw-r--r--scene/main/scene_tree.cpp87
-rw-r--r--scene/main/scene_tree.h59
-rw-r--r--scene/main/shader_globals_override.cpp2
-rw-r--r--scene/main/viewport.cpp16
-rw-r--r--scene/resources/animation.cpp2
-rw-r--r--scene/resources/animation.h2
-rw-r--r--scene/resources/bit_map.cpp2
-rw-r--r--scene/resources/curve.cpp4
-rw-r--r--scene/resources/default_theme/default_theme.cpp78
-rw-r--r--scene/resources/environment.cpp88
-rw-r--r--scene/resources/environment.h31
-rw-r--r--scene/resources/font.cpp4
-rw-r--r--scene/resources/gradient.h2
-rw-r--r--scene/resources/mesh.cpp6
-rw-r--r--scene/resources/mesh_data_tool.cpp2
-rw-r--r--scene/resources/packed_scene.cpp6
-rw-r--r--scene/resources/shape_3d.cpp2
-rw-r--r--scene/resources/style_box.cpp188
-rw-r--r--scene/resources/style_box.h32
-rw-r--r--scene/resources/syntax_highlighter.cpp2
-rw-r--r--scene/resources/text_line.cpp2
-rw-r--r--scene/resources/text_paragraph.cpp4
-rw-r--r--scene/resources/texture.cpp12
-rw-r--r--scene/resources/visual_shader.cpp4
-rw-r--r--scene/resources/world_2d.cpp10
-rw-r--r--scene/resources/world_3d.cpp8
119 files changed, 1234 insertions, 1368 deletions
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp
index 0f98fad824..6a9d1883ea 100644
--- a/scene/2d/animated_sprite_2d.cpp
+++ b/scene/2d/animated_sprite_2d.cpp
@@ -654,7 +654,7 @@ String AnimatedSprite2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (frames.is_null()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite to display frames.");
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;
-
- drag_margin[MARGIN_LEFT] = 0.2;
- drag_margin[MARGIN_TOP] = 0.2;
- drag_margin[MARGIN_RIGHT] = 0.2;
- drag_margin[MARGIN_BOTTOM] = 0.2;
+ limit[SIDE_LEFT] = -10000000;
+ limit[SIDE_TOP] = -10000000;
+ limit[SIDE_RIGHT] = 10000000;
+ limit[SIDE_BOTTOM] = 10000000;
+
+ 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/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 8fb16534e8..2411e31b83 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -84,7 +84,7 @@ String CanvasModulate::get_configuration_warning() const {
get_tree()->get_nodes_in_group("_canvas_modulate_" + itos(get_canvas().get_id()), &nodes);
if (nodes.size() > 1) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Only one visible CanvasModulate is allowed per scene (or set of instanced scenes). The first created one will work, while the rest will be ignored.");
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index fe16d4089a..f15939b05f 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -366,8 +366,8 @@ void CollisionObject2D::_update_pickable() {
String CollisionObject2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
- if (shapes.empty()) {
- if (!warning.empty()) {
+ if (shapes.is_empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape2D or CollisionPolygon2D as a child to define its shape.");
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 64d82d715c..faf8931d21 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -233,14 +233,14 @@ String CollisionPolygon2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!Object::cast_to<CollisionObject2D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
}
- if (polygon.empty()) {
- if (!warning.empty()) {
+ if (polygon.is_empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("An empty CollisionPolygon2D has no effect on collision.");
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index f5d13fd641..6e5b02776d 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -90,6 +90,14 @@ void Joint2D::_update_joint(bool p_only_free) {
warning = String();
update_configuration_warning();
+ if (body_a) {
+ body_a->force_update_transform();
+ }
+
+ if (body_b) {
+ body_b->force_update_transform();
+ }
+
joint = _configure_joint(body_a, body_b);
ERR_FAIL_COND_MSG(!joint.is_valid(), "Failed to configure the joint.");
@@ -168,8 +176,8 @@ bool Joint2D::get_exclude_nodes_from_collision() const {
String Joint2D::get_configuration_warning() const {
String node_warning = Node2D::get_configuration_warning();
- if (!warning.empty()) {
- if (!node_warning.empty()) {
+ if (!warning.is_empty()) {
+ if (!node_warning.is_empty()) {
node_warning += "\n\n";
}
node_warning += warning;
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index 2b373a669b..bb08bc95ea 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -404,7 +404,7 @@ String PointLight2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!texture.is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("A texture with the shape of the light must be supplied to the \"Texture\" property.");
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index b5b39ccc8f..8c31c99b46 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -249,14 +249,14 @@ String LightOccluder2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!occluder_polygon.is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("An occluder polygon must be set (or drawn) for this occluder to take effect.");
}
if (occluder_polygon.is_valid() && occluder_polygon->get_polygon().size() == 0) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The occluder polygon for this occluder is empty. Please draw a polygon.");
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index 1c7063d0d3..334cd4f4a8 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -274,7 +274,7 @@ String NavigationAgent2D::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!Object::cast_to<Node2D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The NavigationAgent2D can be used only under a Node2D node");
diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp
index 252d7cbb96..c436221718 100644
--- a/scene/2d/navigation_obstacle_2d.cpp
+++ b/scene/2d/navigation_obstacle_2d.cpp
@@ -109,7 +109,7 @@ String NavigationObstacle2D::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!Object::cast_to<Node2D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The NavigationObstacle2D only serves to provide collision avoidance to a Node2D object.");
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index 98817ec03e..41e8edc3b3 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -503,7 +503,7 @@ String NavigationRegion2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!navpoly.is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("A NavigationPolygon resource must be set or created for this node to work. Please set a property or draw a polygon.");
@@ -516,7 +516,7 @@ String NavigationRegion2D::get_configuration_warning() const {
c = Object::cast_to<Node2D>(c->get_parent());
}
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
return warning + TTR("NavigationRegion2D must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 42c2585487..a2f687cd96 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -475,12 +475,3 @@ void Node2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_index", "get_z_index");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "z_as_relative"), "set_z_as_relative", "is_z_relative");
}
-
-Node2D::Node2D() {
- angle = 0;
- _scale = Vector2(1, 1);
- skew = 0;
- _xform_dirty = false;
- z_index = 0;
- z_relative = true;
-}
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index e20f746447..a66e7f625d 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -37,15 +37,15 @@ class Node2D : public CanvasItem {
GDCLASS(Node2D, CanvasItem);
Point2 pos;
- float angle;
- Size2 _scale;
- float skew;
- int z_index;
- bool z_relative;
+ float angle = 0;
+ Size2 _scale = Vector2(1, 1);
+ float skew = 0;
+ int z_index = 0;
+ bool z_relative = true;
Transform2D _mat;
- bool _xform_dirty;
+ bool _xform_dirty = false;
void _update_transform();
@@ -121,7 +121,7 @@ public:
Transform2D get_transform() const override;
- Node2D();
+ Node2D() {}
};
#endif // NODE2D_H
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 01aa5838b4..ce2632d9c1 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -139,7 +139,7 @@ String ParallaxLayer::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!Object::cast_to<ParallaxBackground>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("ParallaxLayer node only works when set as child of a ParallaxBackground node.");
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index f40a993423..199373f459 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -257,7 +257,7 @@ String PathFollow2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!Object::cast_to<Path2D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("PathFollow2D only works when set as a child of a Path2D node.");
@@ -387,14 +387,3 @@ void PathFollow2D::set_loop(bool p_loop) {
bool PathFollow2D::has_loop() const {
return loop;
}
-
-PathFollow2D::PathFollow2D() {
- offset = 0;
- h_offset = 0;
- v_offset = 0;
- path = nullptr;
- rotates = true;
- cubic = true;
- loop = true;
- lookahead = 4;
-}
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index fcb8b40125..40042a04ef 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -63,14 +63,14 @@ class PathFollow2D : public Node2D {
public:
private:
- Path2D *path;
- real_t offset;
- real_t h_offset;
- real_t v_offset;
- real_t lookahead;
- bool cubic;
- bool loop;
- bool rotates;
+ Path2D *path = nullptr;
+ real_t offset = 0;
+ real_t h_offset = 0;
+ real_t v_offset = 0;
+ real_t lookahead = 4;
+ bool cubic = true;
+ bool loop = true;
+ bool rotates = true;
void _update_transform();
@@ -107,7 +107,7 @@ public:
String get_configuration_warning() const override;
- PathFollow2D();
+ PathFollow2D() {}
};
#endif // PATH_2D_H
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index e314669fb0..3a60de0694 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -301,7 +301,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
bool in_scene = E->get().in_scene;
- if (E->get().shapes.empty()) {
+ if (E->get().shapes.is_empty()) {
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody2D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody2D::_body_exit_tree));
@@ -724,7 +724,7 @@ String RigidBody2D::get_configuration_warning() const {
String warning = CollisionObject2D::get_configuration_warning();
if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05)) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Size changes to RigidBody2D (in character or rigid modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.");
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index 7655416ce2..96dbf1e4ec 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -189,7 +189,7 @@ String RemoteTransform2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!has_node(remote_node) || !Object::cast_to<Node2D>(get_node(remote_node))) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Path property must point to a valid Node2D node to work.");
diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp
index ea1d9f5930..7262840b62 100644
--- a/scene/2d/skeleton_2d.cpp
+++ b/scene/2d/skeleton_2d.cpp
@@ -136,7 +136,7 @@ int Bone2D::get_index_in_skeleton() const {
String Bone2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (!skeleton) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
if (parent_bone) {
@@ -147,7 +147,7 @@ String Bone2D::get_configuration_warning() const {
}
if (rest == Transform2D(0, 0, 0, 0, 0, 0)) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("This bone lacks a proper REST pose. Go to the Skeleton2D node and set one.");
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index bff191a2bf..928a839cc1 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -1714,7 +1714,7 @@ String TileMap::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (use_parent && !collision_parent) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
return TTR("TileMap with Use Parent on needs a parent CollisionObject2D to give shapes to. Please use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index e217f2a394..d183995d65 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -317,7 +317,7 @@ String VisibilityEnabler2D::get_configuration_warning() const {
#ifdef TOOLS_ENABLED
if (is_inside_tree() && get_parent() && (get_parent()->get_filename() == String() && get_parent() != get_tree()->get_edited_scene_root())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("VisibilityEnabler2D works best when used with the edited scene root directly as parent.");
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 38c9e96fbc..09a7d62bb6 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -678,7 +678,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d
}
TypedArray<Image> images = RS::get_singleton()->bake_render_uv2(mf.mesh->get_rid(), overrides, lightmap_size);
- ERR_FAIL_COND_V(images.empty(), BAKE_ERROR_CANT_CREATE_IMAGE);
+ ERR_FAIL_COND_V(images.is_empty(), BAKE_ERROR_CANT_CREATE_IMAGE);
Ref<Image> albedo = images[RS::BAKE_CHANNEL_ALBEDO_ALPHA];
Ref<Image> orm = images[RS::BAKE_CHANNEL_ORM];
diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp
index 356992e922..8dcf52662b 100644
--- a/scene/3d/collision_object_3d.cpp
+++ b/scene/3d/collision_object_3d.cpp
@@ -349,8 +349,8 @@ bool CollisionObject3D::get_capture_input_on_drag() const {
String CollisionObject3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
- if (shapes.empty()) {
- if (!warning.empty()) {
+ if (shapes.is_empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape3D or CollisionPolygon3D as a child to define its shape.");
diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp
index b8a4ab74ee..6caf021e8c 100644
--- a/scene/3d/collision_polygon_3d.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -159,14 +159,14 @@ String CollisionPolygon3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
if (!Object::cast_to<CollisionObject3D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("CollisionPolygon3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape.");
}
- if (polygon.empty()) {
- if (!warning.empty()) {
+ if (polygon.is_empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("An empty CollisionPolygon3D has no effect on collision.");
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp
index e1c691b89a..4d9537f420 100644
--- a/scene/3d/collision_shape_3d.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -60,7 +60,7 @@ void CollisionShape3D::make_convex_from_siblings() {
if (m.is_valid()) {
for (int j = 0; j < m->get_surface_count(); j++) {
Array a = m->surface_get_arrays(j);
- if (!a.empty()) {
+ if (!a.is_empty()) {
Vector<Vector3> v = a[RenderingServer::ARRAY_VERTEX];
for (int k = 0; k < v.size(); k++) {
vertices.append(mi->get_transform().xform(v[k]));
@@ -127,14 +127,14 @@ String CollisionShape3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
if (!Object::cast_to<CollisionObject3D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("CollisionShape3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape.");
}
if (!shape.is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("A shape must be provided for CollisionShape3D to function. Please create a shape resource for it.");
@@ -144,7 +144,7 @@ String CollisionShape3D::get_configuration_warning() const {
Object::cast_to<RigidBody3D>(get_parent()) &&
Object::cast_to<ConcavePolygonShape3D>(*shape) &&
Object::cast_to<RigidBody3D>(get_parent())->get_mode() != RigidBody3D::MODE_STATIC) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("ConcavePolygonShape3D doesn't support RigidBody3D in another mode than static.");
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index fd592012f8..b3b85989f5 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -516,7 +516,7 @@ String GIProbe::get_configuration_warning() const {
String warning = VisualInstance3D::get_configuration_warning();
if (RenderingServer::get_singleton()->is_low_end()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("GIProbes are not supported by the GLES2 video driver.\nUse a BakedLightmap instead.");
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index 3f816535f5..56f8e56858 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -462,7 +462,7 @@ String OmniLight3D::get_configuration_warning() const {
String warning = Light3D::get_configuration_warning();
if (!has_shadow() && get_projector().is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Projector texture only works with shadows active.");
@@ -496,14 +496,14 @@ String SpotLight3D::get_configuration_warning() const {
String warning = Light3D::get_configuration_warning();
if (has_shadow() && get_param(PARAM_SPOT_ANGLE) >= 90.0) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("A SpotLight3D with an angle wider than 90 degrees cannot cast shadows.");
}
if (!has_shadow() && get_projector().is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Projector texture only works with shadows active.");
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index f9f8f276a3..fb60f99f28 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -290,7 +290,7 @@ String NavigationAgent3D::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!Object::cast_to<Node3D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The NavigationAgent3D can be used only under a spatial node.");
diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp
index adbff06ed6..da0467e4a4 100644
--- a/scene/3d/navigation_obstacle_3d.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -116,7 +116,7 @@ String NavigationObstacle3D::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!Object::cast_to<Node3D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The NavigationObstacle3D only serves to provide collision avoidance to a spatial object.");
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp
index 2ae01c7ab8..30d6a54e21 100644
--- a/scene/3d/navigation_region_3d.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -193,7 +193,7 @@ String NavigationRegion3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
if (!navmesh.is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("A NavigationMesh resource must be set or created for this node to work.");
@@ -208,7 +208,7 @@ String NavigationRegion3D::get_configuration_warning() const {
c = Object::cast_to<Node3D>(c->get_parent());
}
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
return warning + TTR("NavigationRegion3D must be a child or grandchild to a Navigation3D node. It only provides navigation data.");
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index e8005f38ed..deb04f0978 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -784,28 +784,4 @@ void Node3D::_bind_methods() {
}
Node3D::Node3D() :
- xform_change(this) {
- data.dirty = DIRTY_NONE;
- data.children_lock = 0;
-
- data.ignore_notification = false;
- data.top_level = false;
- data.top_level_active = false;
- data.scale = Vector3(1, 1, 1);
- data.viewport = nullptr;
- data.inside_world = false;
- data.visible = true;
- data.disable_scale = false;
-
-#ifdef TOOLS_ENABLED
- data.gizmo_disabled = false;
- data.gizmo_dirty = false;
-#endif
- data.notify_local_transform = false;
- data.notify_transform = false;
- data.parent = nullptr;
- data.C = nullptr;
-}
-
-Node3D::~Node3D() {
-}
+ xform_change(this) {}
diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h
index 5fb421c930..180c441a2a 100644
--- a/scene/3d/node_3d.h
+++ b/scene/3d/node_3d.h
@@ -65,32 +65,32 @@ class Node3D : public Node {
mutable Transform global_transform;
mutable Transform local_transform;
mutable Vector3 rotation;
- mutable Vector3 scale;
+ mutable Vector3 scale = Vector3(1, 1, 1);
- mutable int dirty;
+ mutable int dirty = DIRTY_NONE;
- Viewport *viewport;
+ Viewport *viewport = nullptr;
- bool top_level_active;
- bool top_level;
- bool inside_world;
+ bool top_level_active = false;
+ bool top_level = false;
+ bool inside_world = false;
- int children_lock;
- Node3D *parent;
+ int children_lock = 0;
+ Node3D *parent = nullptr;
List<Node3D *> children;
- List<Node3D *>::Element *C;
+ List<Node3D *>::Element *C = nullptr;
- bool ignore_notification;
- bool notify_local_transform;
- bool notify_transform;
+ bool ignore_notification = false;
+ bool notify_local_transform = false;
+ bool notify_transform = false;
- bool visible;
- bool disable_scale;
+ bool visible = true;
+ bool disable_scale = false;
#ifdef TOOLS_ENABLED
Ref<Node3DGizmo> gizmo;
- bool gizmo_disabled;
- bool gizmo_dirty;
+ bool gizmo_disabled = false;
+ bool gizmo_dirty = false;
#endif
} data;
@@ -197,7 +197,6 @@ public:
void force_update_transform();
Node3D();
- ~Node3D();
};
#endif // NODE_3D_H
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index ae6bbad8bf..018f6a5bcb 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -249,14 +249,14 @@ String PathFollow3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
if (!Object::cast_to<Path3D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("PathFollow3D only works when set as a child of a Path3D node.");
} else {
Path3D *path = Object::cast_to<Path3D>(get_parent());
if (path->get_curve().is_valid() && !path->get_curve()->is_up_vector_enabled() && rotation_mode == ROTATION_ORIENTED) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("PathFollow3D's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its parent Path3D's Curve resource.");
@@ -385,14 +385,3 @@ void PathFollow3D::set_loop(bool p_loop) {
bool PathFollow3D::has_loop() const {
return loop;
}
-
-PathFollow3D::PathFollow3D() {
- offset = 0;
- delta_offset = 0;
- h_offset = 0;
- v_offset = 0;
- path = nullptr;
- rotation_mode = ROTATION_XYZ;
- cubic = true;
- loop = true;
-}
diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h
index 1b0f5fa4e0..39f04f1556 100644
--- a/scene/3d/path_3d.h
+++ b/scene/3d/path_3d.h
@@ -65,14 +65,14 @@ public:
};
private:
- Path3D *path;
- real_t delta_offset; // change in offset since last _update_transform
- real_t offset;
- real_t h_offset;
- real_t v_offset;
- bool cubic;
- bool loop;
- RotationMode rotation_mode;
+ Path3D *path = nullptr;
+ real_t delta_offset = 0; // Change in offset since last _update_transform.
+ real_t offset = 0;
+ real_t h_offset = 0;
+ real_t v_offset = 0;
+ bool cubic = true;
+ bool loop = true;
+ RotationMode rotation_mode = ROTATION_XYZ;
void _update_transform(bool p_update_xyz_rot = true);
@@ -106,7 +106,7 @@ public:
String get_configuration_warning() const override;
- PathFollow3D();
+ PathFollow3D() {}
};
VARIANT_ENUM_CAST(PathFollow3D::RotationMode);
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 15cd2238e1..47c7627ad1 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -311,7 +311,7 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
bool in_tree = E->get().in_tree;
- if (E->get().shapes.empty()) {
+ if (E->get().shapes.is_empty()) {
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree));
@@ -714,7 +714,7 @@ String RigidBody3D::get_configuration_warning() const {
String warning = CollisionObject3D::get_configuration_warning();
if ((get_mode() == MODE_RIGID || get_mode() == MODE_CHARACTER) && (ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(2).length() - 1.0) > 0.05)) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Size changes to RigidBody3D (in character or rigid modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.");
@@ -1971,7 +1971,7 @@ bool PhysicalBone3D::_set(const StringName &p_name, const Variant &p_value) {
}
if (joint_data) {
- if (joint_data->_set(p_name, p_value)) {
+ if (joint_data->_set(p_name, p_value, joint)) {
#ifdef TOOLS_ENABLED
if (get_gizmo().is_valid()) {
get_gizmo()->redraw();
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index 58eebc90ce..cbf16863fb 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -370,7 +370,7 @@ public:
virtual JointType get_joint_type() { return JOINT_TYPE_NONE; }
/// "j" is used to set the parameter inside the PhysicsServer3D
- virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID());
+ virtual bool _set(const StringName &p_name, const Variant &p_value, RID j);
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
@@ -380,7 +380,7 @@ public:
struct PinJointData : public JointData {
virtual JointType get_joint_type() { return JOINT_TYPE_PIN; }
- virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID());
+ virtual bool _set(const StringName &p_name, const Variant &p_value, RID j);
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
@@ -394,7 +394,7 @@ public:
struct ConeJointData : public JointData {
virtual JointType get_joint_type() { return JOINT_TYPE_CONE; }
- virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID());
+ virtual bool _set(const StringName &p_name, const Variant &p_value, RID j);
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
@@ -411,7 +411,7 @@ public:
struct HingeJointData : public JointData {
virtual JointType get_joint_type() { return JOINT_TYPE_HINGE; }
- virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID());
+ virtual bool _set(const StringName &p_name, const Variant &p_value, RID j);
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
@@ -431,7 +431,7 @@ public:
struct SliderJointData : public JointData {
virtual JointType get_joint_type() { return JOINT_TYPE_SLIDER; }
- virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID());
+ virtual bool _set(const StringName &p_name, const Variant &p_value, RID j);
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
@@ -478,7 +478,7 @@ public:
virtual JointType get_joint_type() { return JOINT_TYPE_6DOF; }
- virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID());
+ virtual bool _set(const StringName &p_name, const Variant &p_value, RID j);
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp
index 06de5ad0ae..b43ec78e2e 100644
--- a/scene/3d/physics_joint_3d.cpp
+++ b/scene/3d/physics_joint_3d.cpp
@@ -168,8 +168,8 @@ bool Joint3D::get_exclude_nodes_from_collision() const {
String Joint3D::get_configuration_warning() const {
String node_warning = Node3D::get_configuration_warning();
- if (!warning.empty()) {
- if (!node_warning.empty()) {
+ if (!warning.is_empty()) {
+ if (!node_warning.is_empty()) {
node_warning += "\n\n";
}
node_warning += warning;
diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp
index 358f9346f8..9c7b935090 100644
--- a/scene/3d/remote_transform_3d.cpp
+++ b/scene/3d/remote_transform_3d.cpp
@@ -183,7 +183,7 @@ String RemoteTransform3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
if (!has_node(remote_node) || !Object::cast_to<Node3D>(get_node(remote_node))) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The \"Remote Path\" property must point to a valid Node3D or Node3D-derived node to work.");
diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp
index 32d7afd5df..14af6b066a 100644
--- a/scene/3d/skeleton_ik_3d.cpp
+++ b/scene/3d/skeleton_ik_3d.cpp
@@ -204,7 +204,7 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_
while (sub_chain_root) { // Reach the tip
sub_chain_root->current_pos = origin;
- if (!sub_chain_root->children.empty()) {
+ if (!sub_chain_root->children.is_empty()) {
ChainItem &child(sub_chain_root->children.write[0]);
// Is not tip
@@ -301,7 +301,7 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
Transform new_bone_pose(ci->initial_transform);
new_bone_pose.origin = ci->current_pos;
- if (!ci->children.empty()) {
+ if (!ci->children.is_empty()) {
/// Rotate basis
const Vector3 initial_ori((ci->children[0].initial_transform.origin - ci->initial_transform.origin).normalized());
const Vector3 rot_axis(initial_ori.cross(ci->current_ori).normalized());
@@ -321,7 +321,7 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
p_task->skeleton->set_bone_global_pose_override(ci->bone, new_bone_pose, 1.0, true);
- if (!ci->children.empty()) {
+ if (!ci->children.is_empty()) {
ci = &ci->children.write[0];
} else {
ci = nullptr;
diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp
index d811b2e852..51ade358b7 100644
--- a/scene/3d/soft_body_3d.cpp
+++ b/scene/3d/soft_body_3d.cpp
@@ -380,7 +380,7 @@ String SoftBody3D::get_configuration_warning() const {
String warning = MeshInstance3D::get_configuration_warning();
if (get_mesh().is_null()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
@@ -389,7 +389,7 @@ String SoftBody3D::get_configuration_warning() const {
Transform t = get_transform();
if ((ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(2).length() - 1.0) > 0.05)) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 1d20a9cd3b..27a932e660 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -1074,7 +1074,7 @@ String AnimatedSprite3D::get_configuration_warning() const {
String warning = SpriteBase3D::get_configuration_warning();
if (frames.is_null()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("A SpriteFrames resource must be created or set in the \"Frames\" property in order for AnimatedSprite3D to display frames.");
diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp
index e27307e75f..63e791a556 100644
--- a/scene/3d/vehicle_body_3d.cpp
+++ b/scene/3d/vehicle_body_3d.cpp
@@ -106,7 +106,7 @@ String VehicleWheel3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
if (!Object::cast_to<VehicleBody3D>(get_parent())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("VehicleWheel3D serves to provide a wheel system to a VehicleBody3D. Please use it as a child of a VehicleBody3D.");
diff --git a/scene/3d/velocity_tracker_3d.cpp b/scene/3d/velocity_tracker_3d.cpp
index eba7d44c16..4ffa335775 100644
--- a/scene/3d/velocity_tracker_3d.cpp
+++ b/scene/3d/velocity_tracker_3d.cpp
@@ -45,7 +45,7 @@ void VelocityTracker3D::update_position(const Vector3 &p_position) {
if (physics_step) {
ph.frame = Engine::get_singleton()->get_physics_frames();
} else {
- ph.frame = Engine::get_singleton()->get_idle_frame_ticks();
+ ph.frame = Engine::get_singleton()->get_frame_ticks();
}
if (position_history_len == 0 || position_history[0].frame != ph.frame) { //in same frame, use latest
@@ -72,7 +72,7 @@ Vector3 VelocityTracker3D::get_tracked_linear_velocity() const {
uint64_t base = Engine::get_singleton()->get_physics_frames();
base_time = float(base - position_history[0].frame) / Engine::get_singleton()->get_iterations_per_second();
} else {
- uint64_t base = Engine::get_singleton()->get_idle_frame_ticks();
+ uint64_t base = Engine::get_singleton()->get_frame_ticks();
base_time = double(base - position_history[0].frame) / 1000000.0;
}
}
@@ -109,7 +109,7 @@ void VelocityTracker3D::reset(const Vector3 &p_new_pos) {
if (physics_step) {
ph.frame = Engine::get_singleton()->get_physics_frames();
} else {
- ph.frame = Engine::get_singleton()->get_idle_frame_ticks();
+ ph.frame = Engine::get_singleton()->get_frame_ticks();
}
position_history.write[0] = ph;
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index c570fc7b7c..4ae91ae876 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -294,7 +294,7 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector<Color> Voxelizer::_get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add) {
Vector<Color> ret;
- if (p_image.is_null() || p_image->empty()) {
+ if (p_image.is_null() || p_image->is_empty()) {
ret.resize(bake_texture_size * bake_texture_size);
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
ret.write[i] = p_color_add;
diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp
index 3c12d4991e..05fd45e6b6 100644
--- a/scene/3d/world_environment.cpp
+++ b/scene/3d/world_environment.cpp
@@ -113,7 +113,7 @@ String WorldEnvironment::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!environment.is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("WorldEnvironment requires its \"Environment\" property to contain an Environment to have a visible effect.");
@@ -127,7 +127,7 @@ String WorldEnvironment::get_configuration_warning() const {
get_tree()->get_nodes_in_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id()), &nodes);
if (nodes.size() > 1) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Only one WorldEnvironment is allowed per scene (or set of instanced scenes).");
diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp
index a7b3a830e0..47b0536843 100644
--- a/scene/3d/xr_nodes.cpp
+++ b/scene/3d/xr_nodes.cpp
@@ -65,7 +65,7 @@ String XRCamera3D::get_configuration_warning() const {
// must be child node of XROrigin3D!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
if (origin == nullptr) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("XRCamera3D must have an XROrigin3D node as its parent.");
@@ -247,7 +247,7 @@ void XRController3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &XRController3D::get_joystick_axis);
ClassDB::bind_method(D_METHOD("get_is_active"), &XRController3D::get_is_active);
- ClassDB::bind_method(D_METHOD("get_hand"), &XRController3D::get_hand);
+ ClassDB::bind_method(D_METHOD("get_tracker_hand"), &XRController3D::get_tracker_hand);
ClassDB::bind_method(D_METHOD("get_rumble"), &XRController3D::get_rumble);
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &XRController3D::set_rumble);
@@ -349,7 +349,7 @@ bool XRController3D::get_is_active() const {
return is_active;
};
-XRPositionalTracker::TrackerHand XRController3D::get_hand() const {
+XRPositionalTracker::TrackerHand XRController3D::get_tracker_hand() const {
// get our XRServer
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL_V(xr_server, XRPositionalTracker::TRACKER_HAND_UNKNOWN);
@@ -359,7 +359,7 @@ XRPositionalTracker::TrackerHand XRController3D::get_hand() const {
return XRPositionalTracker::TRACKER_HAND_UNKNOWN;
};
- return tracker->get_hand();
+ return tracker->get_tracker_hand();
};
String XRController3D::get_configuration_warning() const {
@@ -372,14 +372,14 @@ String XRController3D::get_configuration_warning() const {
// must be child node of XROrigin!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
if (origin == nullptr) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("XRController3D must have an XROrigin3D node as its parent.");
};
if (controller_id == 0) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The controller ID must not be 0 or this controller won't be bound to an actual controller.");
@@ -497,14 +497,14 @@ String XRAnchor3D::get_configuration_warning() const {
// must be child node of XROrigin3D!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
if (origin == nullptr) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("XRAnchor3D must have an XROrigin3D node as its parent.");
};
if (anchor_id == 0) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The anchor ID must not be 0 or this anchor won't be bound to an actual anchor.");
@@ -536,7 +536,7 @@ String XROrigin3D::get_configuration_warning() const {
String warning = Node3D::get_configuration_warning();
if (tracked_camera == nullptr) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("XROrigin3D requires an XRCamera3D child node.");
diff --git a/scene/3d/xr_nodes.h b/scene/3d/xr_nodes.h
index 751b2b68cb..6aa7709485 100644
--- a/scene/3d/xr_nodes.h
+++ b/scene/3d/xr_nodes.h
@@ -93,7 +93,7 @@ public:
void set_rumble(real_t p_rumble);
bool get_is_active() const;
- XRPositionalTracker::TrackerHand get_hand() const;
+ XRPositionalTracker::TrackerHand get_tracker_hand() const;
Ref<Mesh> get_mesh() const;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index e9e17148d6..159ccae130 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -36,6 +36,7 @@
#include "servers/audio/audio_stream.h"
#ifdef TOOLS_ENABLED
+#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "scene/2d/skeleton_2d.h"
@@ -53,6 +54,21 @@ void AnimatedValuesBackup::update_skeletons() {
}
}
}
+
+void AnimatedValuesBackup::restore() const {
+ for (int i = 0; i < entries.size(); i++) {
+ const AnimatedValuesBackup::Entry *entry = &entries[i];
+ if (entry->bone_idx == -1) {
+ entry->object->set_indexed(entry->subpath, entry->value);
+ } else {
+ Object::cast_to<Skeleton3D>(entry->object)->set_bone_pose(entry->bone_idx, entry->value);
+ }
+ }
+}
+
+void AnimatedValuesBackup::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("restore"), &AnimatedValuesBackup::restore);
+}
#endif
bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) {
@@ -1379,6 +1395,14 @@ String AnimationPlayer::get_autoplay() const {
return autoplay;
}
+void AnimationPlayer::set_reset_on_save_enabled(bool p_enabled) {
+ reset_on_save = p_enabled;
+}
+
+bool AnimationPlayer::is_reset_on_save_enabled() const {
+ return reset_on_save;
+}
+
void AnimationPlayer::set_animation_process_mode(AnimationProcessMode p_mode) {
if (animation_process_mode == p_mode) {
return;
@@ -1473,15 +1497,15 @@ void AnimationPlayer::get_argument_options(const StringName &p_function, int p_i
}
#ifdef TOOLS_ENABLED
-AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
+Ref<AnimatedValuesBackup> AnimationPlayer::backup_animated_values() {
+ Ref<AnimatedValuesBackup> backup;
if (!playback.current.from) {
- return AnimatedValuesBackup();
+ return backup;
}
_ensure_node_caches(playback.current.from);
- AnimatedValuesBackup backup;
-
+ backup.instance();
for (int i = 0; i < playback.current.from->node_cache.size(); i++) {
TrackNodeCache *nc = playback.current.from->node_cache[i];
if (!nc) {
@@ -1497,7 +1521,7 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
entry.object = nc->skeleton;
entry.bone_idx = nc->bone_idx;
entry.value = nc->skeleton->get_bone_pose(nc->bone_idx);
- backup.entries.push_back(entry);
+ backup->entries.push_back(entry);
} else {
if (nc->spatial) {
AnimatedValuesBackup::Entry entry;
@@ -1505,7 +1529,7 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
entry.subpath.push_back("transform");
entry.value = nc->spatial->get_transform();
entry.bone_idx = -1;
- backup.entries.push_back(entry);
+ backup->entries.push_back(entry);
} else {
for (Map<StringName, TrackNodeCache::PropertyAnim>::Element *E = nc->property_anim.front(); E; E = E->next()) {
AnimatedValuesBackup::Entry entry;
@@ -1515,7 +1539,7 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
entry.value = E->value().object->get_indexed(E->value().subpath, &valid);
entry.bone_idx = -1;
if (valid) {
- backup.entries.push_back(entry);
+ backup->entries.push_back(entry);
}
}
}
@@ -1525,15 +1549,40 @@ AnimatedValuesBackup AnimationPlayer::backup_animated_values() {
return backup;
}
-void AnimationPlayer::restore_animated_values(const AnimatedValuesBackup &p_backup) {
- for (int i = 0; i < p_backup.entries.size(); i++) {
- const AnimatedValuesBackup::Entry *entry = &p_backup.entries[i];
- if (entry->bone_idx == -1) {
- entry->object->set_indexed(entry->subpath, entry->value);
- } else {
- Object::cast_to<Skeleton3D>(entry->object)->set_bone_pose(entry->bone_idx, entry->value);
- }
+Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) {
+ ERR_FAIL_COND_V(!can_apply_reset(), Ref<AnimatedValuesBackup>());
+
+ Ref<Animation> reset_anim = animation_set["RESET"].animation;
+ ERR_FAIL_COND_V(reset_anim.is_null(), Ref<AnimatedValuesBackup>());
+
+ Node *root_node = get_node_or_null(root);
+ ERR_FAIL_COND_V(!root_node, Ref<AnimatedValuesBackup>());
+
+ AnimationPlayer *aux_player = memnew(AnimationPlayer);
+ EditorNode::get_singleton()->add_child(aux_player);
+ aux_player->set_root(aux_player->get_path_to(root_node));
+ aux_player->add_animation("RESET", reset_anim);
+ aux_player->set_assigned_animation("RESET");
+ Ref<AnimatedValuesBackup> old_values = aux_player->backup_animated_values();
+ aux_player->seek(0.0f, true);
+ aux_player->queue_delete();
+
+ if (p_user_initiated) {
+ Ref<AnimatedValuesBackup> new_values = aux_player->backup_animated_values();
+ old_values->restore();
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Anim Apply Reset"));
+ ur->add_do_method(new_values.ptr(), "restore");
+ ur->add_undo_method(old_values.ptr(), "restore");
+ ur->commit_action();
}
+
+ return old_values;
+}
+
+bool AnimationPlayer::can_apply_reset() const {
+ return has_animation("RESET") && playback.assigned != StringName("RESET");
}
#endif
@@ -1577,6 +1626,9 @@ void AnimationPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_autoplay", "name"), &AnimationPlayer::set_autoplay);
ClassDB::bind_method(D_METHOD("get_autoplay"), &AnimationPlayer::get_autoplay);
+ ClassDB::bind_method(D_METHOD("set_reset_on_save_enabled", "enabled"), &AnimationPlayer::set_reset_on_save_enabled);
+ ClassDB::bind_method(D_METHOD("is_reset_on_save_enabled"), &AnimationPlayer::is_reset_on_save_enabled);
+
ClassDB::bind_method(D_METHOD("set_root", "path"), &AnimationPlayer::set_root);
ClassDB::bind_method(D_METHOD("get_root"), &AnimationPlayer::get_root);
@@ -1600,6 +1652,7 @@ void AnimationPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER), "set_current_animation", "get_current_animation");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", 0), "set_assigned_animation", "get_assigned_animation");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_autoplay", "get_autoplay");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reset_on_save", PROPERTY_HINT_NONE, ""), "set_reset_on_save_enabled", "is_reset_on_save_enabled");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_length", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_length");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_position", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_position");
@@ -1631,6 +1684,7 @@ AnimationPlayer::AnimationPlayer() {
speed_scale = 1;
end_reached = false;
end_notify = false;
+ reset_on_save = true;
animation_process_mode = ANIMATION_PROCESS_IDLE;
method_call_mode = ANIMATION_METHOD_CALL_DEFERRED;
processing = false;
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index dbce5643c7..7f0d5630e1 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -37,8 +37,9 @@
#include "scene/resources/animation.h"
#ifdef TOOLS_ENABLED
-// To save/restore animated values
-class AnimatedValuesBackup {
+class AnimatedValuesBackup : public Reference {
+ GDCLASS(AnimatedValuesBackup, Reference);
+
struct Entry {
Object *object;
Vector<StringName> subpath; // Unused if bone
@@ -49,8 +50,12 @@ class AnimatedValuesBackup {
friend class AnimationPlayer;
+protected:
+ static void _bind_methods();
+
public:
void update_skeletons();
+ void restore() const;
};
#endif
@@ -215,6 +220,7 @@ private:
bool end_notify;
String autoplay;
+ bool reset_on_save;
AnimationProcessMode animation_process_mode;
AnimationMethodCallMode method_call_mode;
bool processing;
@@ -304,6 +310,9 @@ public:
void set_autoplay(const String &p_name);
String get_autoplay() const;
+ void set_reset_on_save_enabled(bool p_enabled);
+ bool is_reset_on_save_enabled() const;
+
void set_animation_process_mode(AnimationProcessMode p_mode);
AnimationProcessMode get_animation_process_mode() const;
@@ -325,9 +334,9 @@ public:
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#ifdef TOOLS_ENABLED
- // These may be interesting for games, but are too dangerous for general use
- AnimatedValuesBackup backup_animated_values();
- void restore_animated_values(const AnimatedValuesBackup &p_backup);
+ Ref<AnimatedValuesBackup> backup_animated_values();
+ Ref<AnimatedValuesBackup> apply_reset(bool p_user_initiated = false);
+ bool can_apply_reset() const;
#endif
AnimationPlayer();
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 2ef3ba87b2..8b5cc8eda3 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -40,7 +40,7 @@ void AnimationNode::get_parameter_list(List<PropertyInfo> *r_list) const {
Array parameters = get_script_instance()->call("get_parameter_list");
for (int i = 0; i < parameters.size(); i++) {
Dictionary d = parameters[i];
- ERR_CONTINUE(d.empty());
+ ERR_CONTINUE(d.is_empty());
r_list->push_back(PropertyInfo::from_dict(d));
}
}
@@ -1287,14 +1287,14 @@ String AnimationTree::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!root.is_valid()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("No root AnimationNode for the graph is set.");
}
if (!has_node(animation_player)) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Path to an AnimationPlayer node containing animations is not set.");
@@ -1302,12 +1302,12 @@ String AnimationTree::get_configuration_warning() const {
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(get_node(animation_player));
if (!player) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Path set for AnimationPlayer does not lead to an AnimationPlayer node.");
} else if (!player->has_node(player->get_root())) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The AnimationPlayer root node is not a valid node.");
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<StyleBox> 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<StyleBox> 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..a80506029c 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: {
@@ -591,7 +591,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
}
Ref<Image> img = r->get_texture()->get_data();
- if (img.is_valid() && !img->empty()) {
+ if (img.is_valid() && !img->is_empty()) {
Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position();
Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y);
@@ -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/container.cpp b/scene/gui/container.cpp
index f01da703c1..38e938ebea 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -163,7 +163,7 @@ String Container::get_configuration_warning() const {
String warning = Control::get_configuration_warning();
if (get_class() == "Container" && get_script().is_null()) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Container by itself serves no purpose unless a script configures its children placement behavior.\nIf you don't intend to add a script, use a plain Control node instead.");
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index bdbb0d4684..78abacea42 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<Control>(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;
@@ -2698,7 +2698,7 @@ String Control::get_configuration_warning() const {
String warning = CanvasItem::get_configuration_warning();
if (data.mouse_filter == MOUSE_FILTER_IGNORE && data.tooltip != "") {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("The Hint Tooltip won't be displayed as the control's Mouse Filter is set to \"Ignore\". To solve this, set the Mouse Filter to \"Stop\" or \"Pass\".");
@@ -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");
@@ -2913,7 +2913,8 @@ void Control::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_global_position", PROPERTY_HINT_NONE, "", 0), "_set_global_position", "get_global_position");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rect_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_rotation_degrees", "get_rotation_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rect_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rect_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_rotation_degrees", "get_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_scale"), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_pivot_offset"), "set_pivot_offset", "get_pivot_offset");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rect_clip_content"), "set_clip_contents", "is_clipping_contents");
@@ -2922,10 +2923,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");
@@ -3043,38 +3044,3 @@ void Control::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_point", PropertyInfo(Variant::VECTOR2, "point")));
}
-
-Control::Control() {
- data.parent = nullptr;
-
- data.mouse_filter = MOUSE_FILTER_STOP;
-
- data.RI = nullptr;
- data.theme_owner = nullptr;
- data.theme_owner_window = nullptr;
- data.default_cursor = CURSOR_ARROW;
- data.layout_dir = LAYOUT_DIRECTION_INHERITED;
- data.h_size_flags = SIZE_FILL;
- data.v_size_flags = SIZE_FILL;
- data.expand = 1;
- data.rotation = 0;
- data.parent_canvas_item = nullptr;
- data.scale = Vector2(1, 1);
-
- data.block_minimum_size_adjust = false;
- data.disable_visibility_clip = false;
- data.h_grow = GROW_DIRECTION_END;
- data.v_grow = GROW_DIRECTION_END;
- data.minimum_size_valid = false;
- data.updating_last_minimum_size = false;
-
- data.clip_contents = false;
- for (int i = 0; i < 4; i++) {
- data.anchor[i] = ANCHOR_BEGIN;
- data.margin[i] = 0;
- }
- data.focus_mode = FOCUS_NONE;
-}
-
-Control::~Control() {
-}
diff --git a/scene/gui/control.h b/scene/gui/control.h
index d314c7357b..ea336e3c59 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -166,46 +166,46 @@ private:
Point2 pos_cache;
Size2 size_cache;
Size2 minimum_size_cache;
- bool minimum_size_valid;
+ bool minimum_size_valid = false;
Size2 last_minimum_size;
- bool updating_last_minimum_size;
+ bool updating_last_minimum_size = false;
- float margin[4];
- float anchor[4];
- FocusMode focus_mode;
- GrowDirection h_grow;
- GrowDirection v_grow;
+ 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;
+ GrowDirection v_grow = GROW_DIRECTION_END;
- LayoutDirection layout_dir;
+ LayoutDirection layout_dir = LAYOUT_DIRECTION_INHERITED;
- float rotation;
- Vector2 scale;
+ float rotation = 0;
+ Vector2 scale = Vector2(1, 1);
Vector2 pivot_offset;
- int h_size_flags;
- int v_size_flags;
- float expand;
+ int h_size_flags = SIZE_FILL;
+ int v_size_flags = SIZE_FILL;
+ float expand = 1;
Point2 custom_minimum_size;
- MouseFilter mouse_filter;
+ MouseFilter mouse_filter = MOUSE_FILTER_STOP;
- bool clip_contents;
+ bool clip_contents = false;
- bool block_minimum_size_adjust;
- bool disable_visibility_clip;
+ bool block_minimum_size_adjust = false;
+ bool disable_visibility_clip = false;
- Control *parent;
+ Control *parent = nullptr;
ObjectID drag_owner;
Ref<Theme> theme;
- Control *theme_owner;
- Window *theme_owner_window;
+ Control *theme_owner = nullptr;
+ Window *theme_owner_window = nullptr;
String tooltip;
- CursorShape default_cursor;
+ CursorShape default_cursor = CURSOR_ARROW;
- List<Control *>::Element *RI;
+ List<Control *>::Element *RI = nullptr;
- CanvasItem *parent_canvas_item;
+ CanvasItem *parent_canvas_item = nullptr;
NodePath focus_neighbor[4];
NodePath focus_next;
@@ -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;
@@ -518,8 +518,7 @@ public:
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
virtual String get_configuration_warning() const override;
- Control();
- ~Control();
+ Control() {}
};
VARIANT_ENUM_CAST(Control::FocusMode);
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 4e80498108..199af936a6 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -165,7 +165,7 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) {
void AcceptDialog::_update_child_rects() {
Size2 label_size = label->get_minimum_size();
- if (label->get_text().empty()) {
+ if (label->get_text().is_empty()) {
label_size.height = 0;
}
int margin = hbc->get_theme_constant("margin", "Dialogs");
@@ -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/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 041b8ef174..fa29bedd62 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -136,7 +136,7 @@ void FileDialog::update_dir() {
}
// Deselect any item, to make "Select Current Folder" button text by default.
- deselect_items();
+ deselect_all();
}
void FileDialog::_dir_entered(String p_dir) {
@@ -172,7 +172,7 @@ void FileDialog::_post_popup() {
// For open dir mode, deselect all items on file dialog open.
if (mode == FILE_MODE_OPEN_DIR) {
- deselect_items();
+ deselect_all();
file_box->set_visible(false);
} else {
file_box->set_visible(true);
@@ -318,7 +318,7 @@ void FileDialog::_go_up() {
update_dir();
}
-void FileDialog::deselect_items() {
+void FileDialog::deselect_all() {
// Clear currently selected items in file manager.
tree->deselect_all();
@@ -434,7 +434,7 @@ void FileDialog::update_file_list() {
dirs.sort_custom<NaturalNoCaseComparator>();
files.sort_custom<NaturalNoCaseComparator>();
- while (!dirs.empty()) {
+ while (!dirs.is_empty()) {
String &dir_name = dirs.front()->get();
TreeItem *ti = tree->create_item(root);
ti->set_text(0, dir_name);
@@ -478,8 +478,8 @@ void FileDialog::update_file_list() {
String base_dir = dir_access->get_current_dir();
- while (!files.empty()) {
- bool match = patterns.empty();
+ while (!files.is_empty()) {
+ bool match = patterns.is_empty();
String match_str;
for (List<String>::Element *E = patterns.front(); E; E = E->next()) {
@@ -808,7 +808,7 @@ void FileDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_file_name"), &FileDialog::update_file_name);
ClassDB::bind_method(D_METHOD("_update_dir"), &FileDialog::update_dir);
ClassDB::bind_method(D_METHOD("_update_file_list"), &FileDialog::update_file_list);
- ClassDB::bind_method(D_METHOD("deselect_items"), &FileDialog::deselect_items);
+ ClassDB::bind_method(D_METHOD("deselect_all"), &FileDialog::deselect_all);
ClassDB::bind_method(D_METHOD("invalidate"), &FileDialog::invalidate);
@@ -932,7 +932,7 @@ FileDialog::FileDialog() {
tree->connect("multi_selected", callable_mp(this, &FileDialog::_tree_multi_selected), varray(), CONNECT_DEFERRED);
tree->connect("cell_selected", callable_mp(this, &FileDialog::_tree_selected), varray(), CONNECT_DEFERRED);
tree->connect("item_activated", callable_mp(this, &FileDialog::_tree_item_activated), varray());
- tree->connect("nothing_selected", callable_mp(this, &FileDialog::deselect_items));
+ tree->connect("nothing_selected", callable_mp(this, &FileDialog::deselect_all));
dir->connect("text_entered", callable_mp(this, &FileDialog::_dir_entered));
file->connect("text_entered", callable_mp(this, &FileDialog::_file_entered));
filter->connect("item_selected", callable_mp(this, &FileDialog::_filter_selected));
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 8003650668..3649a30756 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -170,7 +170,7 @@ public:
void invalidate();
- void deselect_items();
+ void deselect_all();
FileDialog();
~FileDialog();
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 2bcc1890fe..ce68aeeeed 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);
@@ -389,7 +389,7 @@ void GraphEdit::add_child_notify(Node *p_child) {
GraphNode *gn = Object::cast_to<GraphNode>(p_child);
if (gn) {
gn->set_scale(Vector2(zoom, zoom));
- gn->connect("offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved), varray(gn));
+ gn->connect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved), varray(gn));
gn->connect("raise_request", callable_mp(this, &GraphEdit::_graph_node_raised), varray(gn));
gn->connect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::update));
gn->connect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::update));
@@ -407,7 +407,7 @@ void GraphEdit::remove_child_notify(Node *p_child) {
GraphNode *gn = Object::cast_to<GraphNode>(p_child);
if (gn) {
- gn->disconnect("offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved));
+ gn->disconnect("position_offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved));
gn->disconnect("raise_request", callable_mp(this, &GraphEdit::_graph_node_raised));
gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::update));
gn->disconnect("item_rect_changed", callable_mp((CanvasItem *)minimap, &GraphEditMinimap::update));
@@ -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<InputEvent> &p_ev) {
pos = pos.snapped(Vector2(snap, snap));
}
- gn->set_offset(pos);
+ gn->set_position_offset(pos);
}
}
}
@@ -1081,13 +1081,13 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (!gn->is_selected() && box_selection_mode_additive) {
emit_signal("node_selected", gn);
} else if (gn->is_selected() && !box_selection_mode_additive) {
- emit_signal("node_unselected", gn);
+ emit_signal("node_deselected", gn);
}
gn->set_selected(box_selection_mode_additive);
} else {
bool select = (previus_selected.find(gn) != nullptr);
if (gn->is_selected() && !select) {
- emit_signal("node_unselected", gn);
+ emit_signal("node_deselected", gn);
} else if (!gn->is_selected() && select) {
emit_signal("node_selected", gn);
}
@@ -1112,7 +1112,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
bool select = (previus_selected.find(gn) != nullptr);
if (gn->is_selected() && !select) {
- emit_signal("node_unselected", gn);
+ emit_signal("node_deselected", gn);
} else if (!gn->is_selected() && select) {
emit_signal("node_selected", gn);
}
@@ -1141,7 +1141,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
Rect2 r = gn->get_rect();
r.size *= zoom;
if (r.has_point(b->get_position())) {
- emit_signal("node_unselected", gn);
+ emit_signal("node_deselected", gn);
gn->set_selected(false);
}
}
@@ -1204,7 +1204,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
o_gn->set_selected(true);
} else {
if (o_gn->is_selected()) {
- emit_signal("node_unselected", o_gn);
+ emit_signal("node_deselected", o_gn);
}
o_gn->set_selected(false);
}
@@ -1264,7 +1264,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
continue;
}
if (gn2->is_selected()) {
- emit_signal("node_unselected", gn2);
+ emit_signal("node_deselected", gn2);
}
gn2->set_selected(false);
}
@@ -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();
}
@@ -1628,7 +1628,7 @@ void GraphEdit::_bind_methods() {
ADD_SIGNAL(MethodInfo("copy_nodes_request"));
ADD_SIGNAL(MethodInfo("paste_nodes_request"));
ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
- ADD_SIGNAL(MethodInfo("node_unselected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
+ ADD_SIGNAL(MethodInfo("node_deselected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING_NAME, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING_NAME, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
ADD_SIGNAL(MethodInfo("delete_nodes_request"));
@@ -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..30610c63b5 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -333,7 +333,7 @@ void ItemList::select(int p_idx, bool p_single) {
update();
}
-void ItemList::unselect(int p_idx) {
+void ItemList::deselect(int p_idx) {
ERR_FAIL_INDEX(p_idx, items.size());
if (select_mode != SELECT_MULTI) {
@@ -345,7 +345,7 @@ void ItemList::unselect(int p_idx) {
update();
}
-void ItemList::unselect_all() {
+void ItemList::deselect_all() {
if (items.size() < 1) {
return;
}
@@ -573,7 +573,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
int i = closest;
if (select_mode == SELECT_MULTI && items[i].selected && mb->get_command()) {
- unselect(i);
+ deselect(i);
emit_signal("multi_selected", i, false);
} else if (select_mode == SELECT_MULTI && mb->get_shift() && current >= 0 && current < items.size() && current != i) {
@@ -759,7 +759,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
select(current, false);
emit_signal("multi_selected", current, true);
} else if (items[current].selected) {
- unselect(current);
+ deselect(current);
emit_signal("multi_selected", current, false);
}
}
@@ -861,10 +861,10 @@ void ItemList::_notification(int p_what) {
Ref<StyleBox> 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);
}
}
}
@@ -1314,7 +1314,7 @@ int ItemList::get_item_at_position(const Point2 &p_pos, bool p_exact) const {
}
bool ItemList::is_pos_at_end_of_items(const Point2 &p_pos) const {
- if (items.empty()) {
+ if (items.is_empty()) {
return true;
}
@@ -1519,8 +1519,8 @@ void ItemList::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_tooltip", "idx"), &ItemList::get_item_tooltip);
ClassDB::bind_method(D_METHOD("select", "idx", "single"), &ItemList::select, DEFVAL(true));
- ClassDB::bind_method(D_METHOD("unselect", "idx"), &ItemList::unselect);
- ClassDB::bind_method(D_METHOD("unselect_all"), &ItemList::unselect_all);
+ ClassDB::bind_method(D_METHOD("deselect", "idx"), &ItemList::deselect);
+ ClassDB::bind_method(D_METHOD("deselect_all"), &ItemList::deselect_all);
ClassDB::bind_method(D_METHOD("is_selected", "idx"), &ItemList::is_selected);
ClassDB::bind_method(D_METHOD("get_selected_items"), &ItemList::get_selected_items);
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 9684ce0a32..281814e178 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -183,8 +183,8 @@ public:
Color get_item_custom_fg_color(int p_idx) const;
void select(int p_idx, bool p_single = true);
- void unselect(int p_idx);
- void unselect_all();
+ void deselect(int p_idx);
+ void deselect_all();
bool is_selected(int p_idx) const;
Vector<int> get_selected_items();
bool is_anything_selected();
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..921c9875b3 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -69,7 +69,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
_reset_caret_blink_timer();
if (b->is_pressed()) {
accept_event(); //don't pass event further when clicked on text field
- if (!text.empty() && is_editable() && _is_over_clear_button(b->get_position())) {
+ if (!text.is_empty() && is_editable() && _is_over_clear_button(b->get_position())) {
clear_button_status.press_attempt = true;
clear_button_status.pressing_inside = true;
update();
@@ -106,7 +106,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
update();
} else {
- if (!text.empty() && is_editable() && clear_button_enabled) {
+ if (!text.is_empty() && is_editable() && clear_button_enabled) {
bool press_attempt = clear_button_status.press_attempt;
clear_button_status.press_attempt = false;
if (press_attempt && clear_button_status.pressing_inside && _is_over_clear_button(b->get_position())) {
@@ -136,7 +136,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventMouseMotion> m = p_event;
if (m.is_valid()) {
- if (!text.empty() && is_editable() && clear_button_enabled) {
+ if (!text.is_empty() && is_editable() && clear_button_enabled) {
bool last_press_inside = clear_button_status.pressing_inside;
clear_button_status.pressing_inside = clear_button_status.press_attempt && _is_over_clear_button(m->get_position());
if (last_press_inside != clear_button_status.pressing_inside) {
@@ -653,7 +653,7 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
}
Control::CursorShape LineEdit::get_cursor_shape(const Point2 &p_pos) const {
- if (!text.empty() && is_editable() && _is_over_clear_button(p_pos)) {
+ if (!text.is_empty() && is_editable() && _is_over_clear_button(p_pos)) {
return CURSOR_ARROW;
}
return Control::get_cursor_shape(p_pos);
@@ -735,7 +735,7 @@ void LineEdit::_notification(int p_what) {
}
int x_ofs = 0;
- bool using_placeholder = text.empty() && ime_text.empty();
+ bool using_placeholder = text.is_empty() && ime_text.is_empty();
float text_width = TS->shaped_text_get_size(text_rid).x;
float text_height = TS->shaped_text_get_size(text_rid).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM);
@@ -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,28 +1097,28 @@ 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;
}
- bool using_placeholder = text.empty() && ime_text.empty();
+ bool using_placeholder = text.is_empty() && ime_text.is_empty();
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
Ref<Texture2D> 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,28 +1145,28 @@ 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;
}
- bool using_placeholder = text.empty() && ime_text.empty();
+ bool using_placeholder = text.is_empty() && ime_text.is_empty();
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
Ref<Texture2D> 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);
- bool using_placeholder = text.empty() && ime_text.empty();
+ int ofs_max = get_size().width - style->get_margin(SIDE_RIGHT);
+ bool using_placeholder = text.is_empty() && ime_text.is_empty();
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
Ref<Texture2D> 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();
}
@@ -1570,7 +1570,7 @@ Size2 LineEdit::get_minimum_size() const {
min_size.height = MAX(TS->shaped_text_get_size(text_rid).y + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM), font->get_height(font_size));
// Take icons into account.
- bool using_placeholder = text.empty() && ime_text.empty();
+ bool using_placeholder = text.is_empty() && ime_text.is_empty();
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_icon;
@@ -1994,8 +1994,8 @@ void LineEdit::_shape() {
void LineEdit::_fit_to_width() {
if (align == ALIGN_FILL) {
Ref<StyleBox> style = get_theme_stylebox("normal");
- int t_width = get_size().width - style->get_margin(MARGIN_RIGHT) - style->get_margin(MARGIN_LEFT);
- bool using_placeholder = text.empty() && ime_text.empty();
+ int t_width = get_size().width - style->get_margin(SIDE_RIGHT) - style->get_margin(SIDE_LEFT);
+ bool using_placeholder = text.is_empty() && ime_text.is_empty();
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
if (right_icon.is_valid() || display_clear_icon) {
Ref<Texture2D> r_icon = display_clear_icon ? Control::get_theme_icon("clear") : right_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<Texture2D> 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<Texture2D> &p_tex);
Ref<Texture2D> 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/panel.cpp b/scene/gui/panel.cpp
index acbb6d7ab5..28cc056d6e 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -63,6 +63,3 @@ Panel::Panel() {
// Has visible stylebox, so stop by default.
set_mouse_filter(MOUSE_FILTER_STOP);
}
-
-Panel::~Panel() {
-}
diff --git a/scene/gui/panel.h b/scene/gui/panel.h
index a68c3d3f0c..e2c1ddc91d 100644
--- a/scene/gui/panel.h
+++ b/scene/gui/panel.h
@@ -54,7 +54,6 @@ public:
Mode get_mode() const;
Panel();
- ~Panel();
};
VARIANT_ENUM_CAST(Panel::Mode)
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<StyleBox> 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/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 1344d010ae..c111ddff58 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -74,7 +74,7 @@ void ProgressBar::_notification(int p_what) {
if (percent_visible) {
String txt = TS->format_number(itos(int(get_as_ratio() * 100))) + TS->percent_sign();
TextLine tl = TextLine(txt, font, font_size);
- tl.draw(get_canvas_item(), Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2, font_color);
+ tl.draw(get_canvas_item(), (Point2(get_size().width - tl.get_size().x, get_size().height - tl.get_size().y) / 2).round(), font_color);
}
}
}
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index bdb9f408f0..6342109660 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -34,7 +34,7 @@ String Range::get_configuration_warning() const {
String warning = Control::get_configuration_warning();
if (shared->exp_ratio && shared->min <= 0) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0.");
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 244d90ca6b..5258aae80c 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -606,11 +606,11 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
}
}
-float RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &p_shadow_ofs) {
+void RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &p_shadow_ofs) {
Vector2 off;
- ERR_FAIL_COND_V(p_frame == nullptr, off.y);
- ERR_FAIL_COND_V(p_line < 0 || p_line >= p_frame->lines.size(), off.y);
+ ERR_FAIL_COND(p_frame == nullptr);
+ ERR_FAIL_COND(p_line < 0 || p_line >= p_frame->lines.size());
Line &l = p_frame->lines.write[p_line];
@@ -619,7 +619,7 @@ float RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p
Variant meta;
if (it_from == nullptr) {
- return off.y;
+ return;
}
RID ci = get_canvas_item();
@@ -1040,8 +1040,6 @@ float RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p
}
off.y += TS->shaped_text_get_descent(rid);
}
-
- return off.y;
}
void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, ItemFrame **r_click_frame, int *r_click_line, Item **r_click_item, int *r_click_char, bool *r_outside) {
@@ -1065,7 +1063,7 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
//TODO, change to binary search ?
while (from_line < main->lines.size()) {
- if (main->lines[from_line].offset.y + main->lines[from_line].text_buf->get_size().y + _get_text_rect().get_position().y >= vofs) {
+ if (main->lines[from_line].offset.y + main->lines[from_line].text_buf->get_size().y >= vofs) {
break;
}
from_line++;
@@ -1250,7 +1248,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;
@@ -1349,7 +1347,7 @@ void RichTextLabel::_notification(int p_what) {
//TODO, change to binary search ?
while (from_line < main->lines.size()) {
- if (main->lines[from_line].offset.y + main->lines[from_line].text_buf->get_size().y + _get_text_rect().get_position().y >= vofs) {
+ if (main->lines[from_line].offset.y + main->lines[from_line].text_buf->get_size().y >= vofs) {
break;
}
from_line++;
@@ -1372,7 +1370,8 @@ void RichTextLabel::_notification(int p_what) {
Point2 ofs = text_rect.get_position() + Vector2(0, main->lines[from_line].offset.y - vofs);
while (ofs.y < size.height && from_line < main->lines.size()) {
visible_line_count++;
- ofs.y += _draw_line(main, from_line, ofs, text_rect.size.x, base_color, outline_size, outline_color, font_color_shadow, use_outline, shadow_ofs);
+ _draw_line(main, from_line, ofs, text_rect.size.x, base_color, outline_size, outline_color, font_color_shadow, use_outline, shadow_ofs);
+ ofs.y += main->lines[from_line].text_buf->get_size().y;
from_line++;
}
} break;
@@ -2062,14 +2061,14 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
int total_height = 0;
if (p_frame->lines.size()) {
- total_height = p_frame->lines[p_frame->lines.size() - 1].offset.y + p_frame->lines[p_frame->lines.size() - 1].text_buf->get_size().y + get_theme_stylebox("normal")->get_minimum_size().height;
+ total_height = p_frame->lines[p_frame->lines.size() - 1].offset.y + p_frame->lines[p_frame->lines.size() - 1].text_buf->get_size().y;
}
p_frame->first_resized_line = p_frame->lines.size();
updating_scroll = true;
vscroll->set_max(total_height);
- vscroll->set_page(size.height);
+ vscroll->set_page(text_rect.size.height);
if (scroll_follow && scroll_following) {
vscroll->set_value(total_height - size.height);
}
@@ -2098,7 +2097,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
int total_height = 0;
if (p_frame->lines.size()) {
- total_height = p_frame->lines[p_frame->lines.size() - 1].offset.y + p_frame->lines[p_frame->lines.size() - 1].text_buf->get_size().y + get_theme_stylebox("normal")->get_minimum_size().height;
+ total_height = p_frame->lines[p_frame->lines.size() - 1].offset.y + p_frame->lines[p_frame->lines.size() - 1].text_buf->get_size().y;
}
p_frame->first_invalid_line = p_frame->lines.size();
@@ -2106,7 +2105,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
updating_scroll = true;
vscroll->set_max(total_height);
- vscroll->set_page(size.height);
+ vscroll->set_page(text_rect.size.height);
if (scroll_follow && scroll_following) {
vscroll->set_value(total_height - size.height);
}
@@ -2724,7 +2723,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
String bbcode_name;
typedef Map<String, String> OptionMap;
OptionMap bbcode_options;
- if (!split_tag_block.empty()) {
+ if (!split_tag_block.is_empty()) {
bbcode_name = split_tag_block[0];
for (int i = 1; i < split_tag_block.size(); i++) {
const String &expr = split_tag_block[i];
@@ -3072,7 +3071,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
int width = 0;
int height = 0;
- if (!bbcode_value.empty()) {
+ if (!bbcode_value.is_empty()) {
int sep = bbcode_value.find("x");
if (sep == -1) {
width = bbcode_value.to_int();
@@ -3649,7 +3648,7 @@ void RichTextLabel::install_effect(const Variant effect) {
int RichTextLabel::get_content_height() const {
int total_height = 0;
if (main->lines.size()) {
- total_height = main->lines[main->lines.size() - 1].offset.y + main->lines[main->lines.size() - 1].text_buf->get_size().y + get_theme_stylebox("normal")->get_minimum_size().height;
+ total_height = main->lines[main->lines.size() - 1].offset.y + main->lines[main->lines.size() - 1].text_buf->get_size().y;
}
return total_height;
}
@@ -3956,9 +3955,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/rich_text_label.h b/scene/gui/rich_text_label.h
index 93e48dd449..f1dac69dce 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -378,7 +378,7 @@ private:
void _shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, int *r_char_offset);
void _resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width);
- float _draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs);
+ void _draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs);
float _find_click_in_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, const Point2i &p_click, ItemFrame **r_click_frame = nullptr, int *r_click_line = nullptr, Item **r_click_item = nullptr, int *r_click_char = nullptr);
String _roman(int p_num, bool p_capitalize) const;
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..35f504812d 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();
@@ -328,6 +328,7 @@ void ScrollContainer::_notification(int p_what) {
if (rtl && v_scroll->is_visible_in_tree() && v_scroll->get_parent() == this) {
r.position.x += v_scroll->get_minimum_size().x;
}
+ r.position = r.position.floor();
fit_child_in_rect(c, r);
}
@@ -462,8 +463,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) {
@@ -557,7 +558,7 @@ String ScrollContainer::get_configuration_warning() const {
}
if (found != 1) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("ScrollContainer is intended to work with a single child control.\nUse a container as child (VBox, HBox, etc.), or a Control and set the custom minimum size manually.");
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<Texture2D> &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 01c1a15b79..ddb2b1fe47 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -547,8 +547,8 @@ void TabContainer::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, in
Control *control = Object::cast_to<Control>(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.
@@ -568,16 +568,12 @@ void TabContainer::_draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, in
text_buf[p_index]->draw(canvas, text_pos, p_font_color);
}
-void TabContainer::_on_theme_changed() {
- if (!_theme_changing) {
- return;
- }
-
+void TabContainer::_refresh_texts() {
text_buf.clear();
+ Vector<Control *> tabs = _get_tabs();
bool rtl = is_layout_rtl();
Ref<Font> font = get_theme_font("font");
int font_size = get_theme_font_size("font_size");
- Vector<Control *> tabs = _get_tabs();
for (int i = 0; i < tabs.size(); i++) {
Control *control = Object::cast_to<Control>(tabs[i]);
String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name()));
@@ -587,6 +583,14 @@ void TabContainer::_on_theme_changed() {
name->add_string(text, font, font_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
text_buf.push_back(name);
}
+}
+
+void TabContainer::_on_theme_changed() {
+ if (!_theme_changing) {
+ return;
+ }
+
+ _refresh_texts();
minimum_size_changed();
if (get_tab_count() > 0) {
@@ -603,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();
@@ -679,21 +683,7 @@ Vector<Control *> TabContainer::_get_tabs() const {
}
void TabContainer::_child_renamed_callback() {
- text_buf.clear();
- Vector<Control *> tabs = _get_tabs();
- bool rtl = is_layout_rtl();
- Ref<Font> font = get_theme_font("font");
- int font_size = get_theme_font_size("font_size");
- for (int i = 0; i < tabs.size(); i++) {
- Control *control = Object::cast_to<Control>(tabs[i]);
- String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name()));
- Ref<TextLine> name;
- name.instance();
- name->set_direction(rtl ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
- name->add_string(text, font, font_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
- text_buf.push_back(name);
- }
-
+ _refresh_texts();
update();
}
@@ -708,20 +698,8 @@ void TabContainer::add_child_notify(Node *p_child) {
return;
}
- text_buf.clear();
Vector<Control *> tabs = _get_tabs();
- bool rtl = is_layout_rtl();
- Ref<Font> font = get_theme_font("font");
- int font_size = get_theme_font_size("font_size");
- for (int i = 0; i < tabs.size(); i++) {
- Control *control = Object::cast_to<Control>(tabs[i]);
- String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name()));
- Ref<TextLine> name;
- name.instance();
- name->set_direction(rtl ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
- name->add_string(text, font, font_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
- text_buf.push_back(name);
- }
+ _refresh_texts();
bool first = false;
@@ -734,16 +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<StyleBox> 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()) {
@@ -751,6 +728,13 @@ void TabContainer::add_child_notify(Node *p_child) {
}
}
+void TabContainer::move_child_notify(Node *p_child) {
+ Container::move_child_notify(p_child);
+ call_deferred("_update_current_tab");
+ _refresh_texts();
+ update();
+}
+
int TabContainer::get_tab_count() const {
return _get_tabs().size();
}
@@ -813,20 +797,8 @@ void TabContainer::remove_child_notify(Node *p_child) {
}
void TabContainer::_update_current_tab() {
- text_buf.clear();
Vector<Control *> tabs = _get_tabs();
- bool rtl = is_layout_rtl();
- Ref<Font> font = get_theme_font("font");
- int font_size = get_theme_font_size("font_size");
- for (int i = 0; i < tabs.size(); i++) {
- Control *control = Object::cast_to<Control>(tabs[i]);
- String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name()));
- Ref<TextLine> name;
- name.instance();
- name->set_direction(rtl ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
- name->add_string(text, font, font_size, Dictionary(), TranslationServer::get_singleton()->get_tool_locale());
- text_buf.push_back(name);
- }
+ _refresh_texts();
int tc = tabs.size();
if (current >= tc) {
@@ -1010,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/tab_container.h b/scene/gui/tab_container.h
index 91153e5fc3..9ff56afe6e 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -73,12 +73,14 @@ private:
void _on_mouse_exited();
void _update_current_tab();
void _draw_tab(Ref<StyleBox> &p_tab_style, Color &p_font_color, int p_index, float p_x);
+ void _refresh_texts();
protected:
void _child_renamed_callback();
void _gui_input(const Ref<InputEvent> &p_event);
void _notification(int p_what);
virtual void add_child_notify(Node *p_child) override;
+ virtual void move_child_notify(Node *p_child) override;
virtual void remove_child_notify(Node *p_child) override;
Variant get_drag_data(const Point2 &p_point) override;
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<Texture2D> 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..d044d2421b 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -189,12 +189,12 @@ void TextEdit::Text::invalidate_cache(int p_line, int p_column, const String &p_
text.write[p_line].data_buf->set_preserve_control(draw_control_chars);
if (p_ime_text.length() > 0) {
text.write[p_line].data_buf->add_string(p_ime_text, font, font_size, opentype_features, language);
- if (!p_bidi_override.empty()) {
+ if (!p_bidi_override.is_empty()) {
TS->shaped_text_set_bidi_override(text.write[p_line].data_buf->get_rid(), p_bidi_override);
}
} else {
text.write[p_line].data_buf->add_string(text[p_line].data, font, font_size, opentype_features, language);
- if (!text[p_line].bidi_override.empty()) {
+ if (!text[p_line].bidi_override.is_empty()) {
TS->shaped_text_set_bidi_override(text.write[p_line].data_buf->get_rid(), text[p_line].bidi_override);
}
}
@@ -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];
@@ -1167,7 +1167,7 @@ void TextEdit::_notification(int p_what) {
}
int start = TS->shaped_text_get_range(rid).x;
- if (!search_text.empty()) { // Search highhlight
+ if (!search_text.is_empty()) { // Search highhlight
int search_text_col = _get_column_pos_of_word(search_text, str, search_flags, 0);
while (search_text_col != -1) {
Vector<Vector2> sel = TS->shaped_text_get_selection(rid, search_text_col + start, search_text_col + search_text.length() + start);
@@ -1190,7 +1190,7 @@ void TextEdit::_notification(int p_what) {
}
}
- if (highlight_all_occurrences && !only_whitespaces_highlighted && !highlighted_text.empty()) { // Highlight
+ if (highlight_all_occurrences && !only_whitespaces_highlighted && !highlighted_text.is_empty()) { // Highlight
int highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, 0);
while (highlighted_text_col != -1) {
Vector<Vector2> sel = TS->shaped_text_get_selection(rid, highlighted_text_col + start, highlighted_text_col + highlighted_text.length() + start);
@@ -1245,7 +1245,7 @@ void TextEdit::_notification(int p_what) {
int gl_size = visual.size();
ofs_y += ldata->get_line_ascent(line_wrap_index);
- float char_ofs = 0.f;
+ int char_ofs = 0;
for (int j = 0; j < gl_size; j++) {
if (color_map.has(glyphs[j].start)) {
current_color = color_map[glyphs[j].start].get("color");
@@ -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<InputEvent> &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;
}
@@ -5197,7 +5197,7 @@ void TextEdit::paste() {
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
- } else if (!cut_copy_line.empty() && cut_copy_line == clipboard) {
+ } else if (!cut_copy_line.is_empty() && cut_copy_line == clipboard) {
cursor_set_column(0);
String ins = "\n";
clipboard += ins;
@@ -6469,7 +6469,7 @@ void TextEdit::query_code_comple() {
c--;
}
- bool ignored = completion_active && !completion_options.empty();
+ bool ignored = completion_active && !completion_options.is_empty();
if (ignored) {
ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_PLAIN_TEXT;
const ScriptCodeCompletionOption *previous_option = nullptr;
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<Texture2D> 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<Texture2D> &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<Texture2D> &p_texture);
Ref<Texture2D> 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..cb9729a5e8 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -163,7 +163,7 @@ void TreeItem::set_text(int p_column, String p_text) {
cells.write[p_column].max = INT_MIN;
for (int i = 0; i < strings.size(); i++) {
int value = i;
- if (!strings[i].get_slicec(':', 1).empty()) {
+ if (!strings[i].get_slicec(':', 1).is_empty()) {
value = strings[i].get_slicec(':', 1).to_int();
}
cells.write[p_column].min = MIN(cells[p_column].min, value);
@@ -1212,7 +1212,7 @@ void Tree::update_item_cell(TreeItem *p_item, int p_col) {
Vector<String> strings = p_item->cells[p_col].text.split(",");
for (int j = 0; j < strings.size(); j++) {
int value = j;
- if (!strings[j].get_slicec(':', 1).empty()) {
+ if (!strings[j].get_slicec(':', 1).is_empty()) {
value = strings[j].get_slicec(':', 1).to_int();
}
if (option == value) {
@@ -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;
@@ -2031,7 +2031,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
popup_menu->clear();
for (int i = 0; i < c.text.get_slice_count(","); i++) {
String s = c.text.get_slicec(',', i);
- popup_menu->add_item(s.get_slicec(':', 0), s.get_slicec(':', 1).empty() ? i : s.get_slicec(':', 1).to_int());
+ popup_menu->add_item(s.get_slicec(':', 0), s.get_slicec(':', 1).is_empty() ? i : s.get_slicec(':', 1).to_int());
}
popup_menu->set_size(Size2(col_width, 0));
@@ -2930,7 +2930,7 @@ bool Tree::edit_selected() {
popup_menu->clear();
for (int i = 0; i < c.text.get_slice_count(","); i++) {
String s2 = c.text.get_slicec(',', i);
- popup_menu->add_item(s2.get_slicec(':', 0), s2.get_slicec(':', 1).empty() ? i : s2.get_slicec(':', 1).to_int());
+ popup_menu->add_item(s2.get_slicec(':', 0), s2.get_slicec(':', 1).is_empty() ? i : s2.get_slicec(':', 1).to_int());
}
popup_menu->set_size(Size2(rect.size.width, 0));
@@ -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<StyleBox> 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<Font> 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<StyleBox> 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/canvas_item.cpp b/scene/main/canvas_item.cpp
index 43350fae37..8babb1460f 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -292,15 +292,10 @@ void CanvasItemMaterial::_bind_methods() {
CanvasItemMaterial::CanvasItemMaterial() :
element(this) {
- blend_mode = BLEND_MODE_MIX;
- light_mode = LIGHT_MODE_NORMAL;
- particles_animation = false;
-
set_particles_anim_h_frames(1);
set_particles_anim_v_frames(1);
set_particles_anim_loop(false);
- current_key.key = 0;
current_key.invalid_key = 1;
_queue_shader_change();
}
@@ -1411,30 +1406,7 @@ CanvasItem::TextureRepeat CanvasItem::get_texture_repeat() const {
CanvasItem::CanvasItem() :
xform_change(this) {
- window = nullptr;
canvas_item = RenderingServer::get_singleton()->canvas_item_create();
- visible = true;
- pending_update = false;
- modulate = Color(1, 1, 1, 1);
- self_modulate = Color(1, 1, 1, 1);
- top_level = false;
- first_draw = false;
- drawing = false;
- behind = false;
- clip_children = false;
- block_transform_notify = false;
- canvas_layer = nullptr;
- use_parent_material = false;
- global_invalid = true;
- notify_local_transform = false;
- notify_transform = false;
- light_mask = 1;
- texture_repeat = TEXTURE_REPEAT_PARENT_NODE;
- texture_filter = TEXTURE_FILTER_PARENT_NODE;
- texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
- texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
-
- C = nullptr;
}
CanvasItem::~CanvasItem() {
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index 3cde6b69c1..34268c1a78 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -73,7 +73,7 @@ private:
uint32_t invalid_key : 1;
};
- uint32_t key;
+ uint32_t key = 0;
bool operator<(const MaterialKey &p_key) const {
return key < p_key.key;
@@ -114,10 +114,11 @@ private:
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;
- BlendMode blend_mode;
- LightMode light_mode;
- bool particles_animation;
+ BlendMode blend_mode = BLEND_MODE_MIX;
+ LightMode light_mode = LIGHT_MODE_NORMAL;
+ bool particles_animation = false;
+ // Initialized in the constructor.
int particles_anim_h_frames;
int particles_anim_v_frames;
bool particles_anim_loop;
@@ -188,39 +189,38 @@ private:
RID canvas_item;
String group;
- CanvasLayer *canvas_layer;
+ CanvasLayer *canvas_layer = nullptr;
- Color modulate;
- Color self_modulate;
+ Color modulate = Color(1, 1, 1, 1);
+ Color self_modulate = Color(1, 1, 1, 1);
List<CanvasItem *> children_items;
- List<CanvasItem *>::Element *C;
-
- int light_mask;
-
- Window *window;
- bool first_draw;
- bool visible;
- bool clip_children;
- bool pending_update;
- bool top_level;
- bool drawing;
- bool block_transform_notify;
- bool behind;
- bool use_parent_material;
- bool notify_local_transform;
- bool notify_transform;
-
- RS::CanvasItemTextureFilter texture_filter_cache;
- RS::CanvasItemTextureRepeat texture_repeat_cache;
-
- TextureFilter texture_filter;
- TextureRepeat texture_repeat;
+ List<CanvasItem *>::Element *C = nullptr;
+
+ int light_mask = 1;
+
+ Window *window = nullptr;
+ bool first_draw = false;
+ bool visible = true;
+ bool clip_children = false;
+ bool pending_update = false;
+ bool top_level = false;
+ bool drawing = false;
+ bool block_transform_notify = false;
+ bool behind = false;
+ bool use_parent_material = false;
+ bool notify_local_transform = false;
+ bool notify_transform = false;
+
+ RS::CanvasItemTextureFilter texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
+ RS::CanvasItemTextureRepeat texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
+ TextureFilter texture_filter = TEXTURE_FILTER_PARENT_NODE;
+ TextureRepeat texture_repeat = TEXTURE_REPEAT_PARENT_NODE;
Ref<Material> material;
mutable Transform2D global_transform;
- mutable bool global_invalid;
+ mutable bool global_invalid = true;
void _top_level_raise_self();
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 47440f8c60..402d047ccd 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -797,9 +797,9 @@ bool Node::can_process_notification(int p_what) const {
case NOTIFICATION_PHYSICS_PROCESS:
return data.physics_process;
case NOTIFICATION_PROCESS:
- return data.idle_process;
+ return data.process;
case NOTIFICATION_INTERNAL_PROCESS:
- return data.idle_process_internal;
+ return data.process_internal;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS:
return data.physics_process_internal;
}
@@ -845,50 +845,50 @@ float Node::get_physics_process_delta_time() const {
float Node::get_process_delta_time() const {
if (data.tree) {
- return data.tree->get_idle_process_time();
+ return data.tree->get_process_time();
} else {
return 0;
}
}
-void Node::set_process(bool p_idle_process) {
- if (data.idle_process == p_idle_process) {
+void Node::set_process(bool p_process) {
+ if (data.process == p_process) {
return;
}
- data.idle_process = p_idle_process;
+ data.process = p_process;
- if (data.idle_process) {
- add_to_group("idle_process", false);
+ if (data.process) {
+ add_to_group("process", false);
} else {
- remove_from_group("idle_process");
+ remove_from_group("process");
}
- _change_notify("idle_process");
+ _change_notify("process");
}
bool Node::is_processing() const {
- return data.idle_process;
+ return data.process;
}
-void Node::set_process_internal(bool p_idle_process_internal) {
- if (data.idle_process_internal == p_idle_process_internal) {
+void Node::set_process_internal(bool p_process_internal) {
+ if (data.process_internal == p_process_internal) {
return;
}
- data.idle_process_internal = p_idle_process_internal;
+ data.process_internal = p_process_internal;
- if (data.idle_process_internal) {
- add_to_group("idle_process_internal", false);
+ if (data.process_internal) {
+ add_to_group("process_internal", false);
} else {
- remove_from_group("idle_process_internal");
+ remove_from_group("process_internal");
}
- _change_notify("idle_process_internal");
+ _change_notify("process_internal");
}
bool Node::is_processing_internal() const {
- return data.idle_process_internal;
+ return data.process_internal;
}
void Node::set_process_priority(int p_priority) {
@@ -900,11 +900,11 @@ void Node::set_process_priority(int p_priority) {
}
if (is_processing()) {
- data.tree->make_group_changed("idle_process");
+ data.tree->make_group_changed("process");
}
if (is_processing_internal()) {
- data.tree->make_group_changed("idle_process_internal");
+ data.tree->make_group_changed("process_internal");
}
if (is_physics_processing()) {
@@ -1887,7 +1887,7 @@ void Node::remove_and_skip() {
}
}
- while (!children.empty()) {
+ while (!children.is_empty()) {
Node *c_node = children.front()->get();
data.parent->add_child(c_node);
c_node->_propagate_replace_owner(nullptr, new_owner);
@@ -2245,7 +2245,7 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
List<const Node *> process_list;
process_list.push_back(this);
- while (!process_list.empty()) {
+ while (!process_list.is_empty()) {
const Node *n = process_list.front()->get();
process_list.pop_front();
@@ -2925,35 +2925,6 @@ String Node::_get_name_num_separator() {
}
Node::Node() {
- data.pos = -1;
- data.depth = -1;
- data.blocked = 0;
- data.parent = nullptr;
- data.tree = nullptr;
- data.physics_process = false;
- data.idle_process = false;
- data.process_priority = 0;
- data.physics_process_internal = false;
- data.idle_process_internal = false;
- data.inside_tree = false;
- data.ready_notified = false;
-
- data.owner = nullptr;
- data.OW = nullptr;
- data.input = false;
- data.unhandled_input = false;
- data.unhandled_key_input = false;
- data.pause_mode = PAUSE_MODE_INHERIT;
- data.pause_owner = nullptr;
- data.network_master = 1; //server by default
- data.path_cache = nullptr;
- data.parent_owned = false;
- data.in_constructor = true;
- data.viewport = nullptr;
- data.use_placeholder = false;
- data.display_folded = false;
- data.ready_first = true;
-
orphan_node_count++;
}
diff --git a/scene/main/node.h b/scene/main/node.h
index 024d036fd3..9df89fb51d 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -90,54 +90,54 @@ private:
HashMap<NodePath, int> editable_instances;
- Node *parent;
- Node *owner;
- Vector<Node *> children; // list of children
- int pos;
- int depth;
- int blocked; // safeguard that throws an error when attempting to modify the tree in a harmful way while being traversed.
+ Node *parent = nullptr;
+ Node *owner = nullptr;
+ Vector<Node *> children;
+ int pos = -1;
+ int depth = -1;
+ int blocked = 0; // Safeguard that throws an error when attempting to modify the tree in a harmful way while being traversed.
StringName name;
- SceneTree *tree;
- bool inside_tree;
- bool ready_notified; //this is a small hack, so if a node is added during _ready() to the tree, it correctly gets the _ready() notification
- bool ready_first;
+ SceneTree *tree = nullptr;
+ bool inside_tree = false;
+ bool ready_notified = false; // This is a small hack, so if a node is added during _ready() to the tree, it correctly gets the _ready() notification.
+ bool ready_first = true;
#ifdef TOOLS_ENABLED
- NodePath import_path; //path used when imported, used by scene editors to keep tracking
+ NodePath import_path; // Path used when imported, used by scene editors to keep tracking.
#endif
- Viewport *viewport;
+ Viewport *viewport = nullptr;
Map<StringName, GroupData> grouped;
- List<Node *>::Element *OW; // owned element
+ List<Node *>::Element *OW = nullptr; // Owned element.
List<Node *> owned;
- PauseMode pause_mode;
- Node *pause_owner;
+ PauseMode pause_mode = PAUSE_MODE_INHERIT;
+ Node *pause_owner = nullptr;
- int network_master;
+ int network_master = 1; // Server by default.
Vector<NetData> rpc_methods;
Vector<NetData> rpc_properties;
- // variables used to properly sort the node when processing, ignored otherwise
- //should move all the stuff below to bits
- bool physics_process;
- bool idle_process;
- int process_priority;
+ // Variables used to properly sort the node when processing, ignored otherwise.
+ // TODO: Should move all the stuff below to bits.
+ bool physics_process = false;
+ bool process = false;
+ int process_priority = 0;
- bool physics_process_internal;
- bool idle_process_internal;
+ bool physics_process_internal = false;
+ bool process_internal = false;
- bool input;
- bool unhandled_input;
- bool unhandled_key_input;
+ bool input = false;
+ bool unhandled_input = false;
+ bool unhandled_key_input = false;
- bool parent_owned;
- bool in_constructor;
- bool use_placeholder;
+ bool parent_owned = false;
+ bool in_constructor = true;
+ bool use_placeholder = false;
- bool display_folded;
+ bool display_folded = false;
- mutable NodePath *path_cache;
+ mutable NodePath *path_cache = nullptr;
} data;
@@ -339,14 +339,14 @@ public:
float get_physics_process_delta_time() const;
bool is_physics_processing() const;
- void set_process(bool p_idle_process);
+ void set_process(bool p_process);
float get_process_delta_time() const;
bool is_processing() const;
void set_physics_process_internal(bool p_process_internal);
bool is_physics_processing_internal() const;
- void set_process_internal(bool p_idle_process_internal);
+ void set_process_internal(bool p_process_internal);
bool is_processing_internal() const;
void set_process_priority(int p_priority);
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 1df61daa2c..58bc6099f6 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -136,7 +136,7 @@ void SceneTree::remove_from_group(const StringName &p_group, Node *p_node) {
ERR_FAIL_COND(!E);
E->get().nodes.erase(p_node);
- if (E->get().nodes.empty()) {
+ if (E->get().nodes.is_empty()) {
group_map.erase(E);
}
}
@@ -183,7 +183,7 @@ void SceneTree::_update_group_order(Group &g, bool p_use_priority) {
if (!g.changed) {
return;
}
- if (g.nodes.empty()) {
+ if (g.nodes.is_empty()) {
return;
}
@@ -206,7 +206,7 @@ void SceneTree::call_group_flags(uint32_t p_call_flags, const StringName &p_grou
return;
}
Group &g = E->get();
- if (g.nodes.empty()) {
+ if (g.nodes.is_empty()) {
return;
}
@@ -282,7 +282,7 @@ void SceneTree::notify_group_flags(uint32_t p_call_flags, const StringName &p_gr
return;
}
Group &g = E->get();
- if (g.nodes.empty()) {
+ if (g.nodes.is_empty()) {
return;
}
@@ -333,7 +333,7 @@ void SceneTree::set_group_flags(uint32_t p_call_flags, const StringName &p_group
return;
}
Group &g = E->get();
- if (g.nodes.empty()) {
+ if (g.nodes.is_empty()) {
return;
}
@@ -390,20 +390,20 @@ void SceneTree::set_group(const StringName &p_group, const String &p_name, const
set_group_flags(0, p_group, p_name, p_value);
}
-void SceneTree::init() {
+void SceneTree::initialize() {
initialized = true;
root->_set_tree(this);
- MainLoop::init();
+ MainLoop::initialize();
}
-bool SceneTree::iteration(float p_time) {
+bool SceneTree::physics_process(float p_time) {
root_lock++;
current_frame++;
flush_transform_notifications();
- MainLoop::iteration(p_time);
+ MainLoop::physics_process(p_time);
physics_process_time = p_time;
emit_signal("physics_frame");
@@ -422,29 +422,25 @@ bool SceneTree::iteration(float p_time) {
return _quit;
}
-bool SceneTree::idle(float p_time) {
- //print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
- //print_line("node count: "+itos(get_node_count()));
- //print_line("TEXTURE RAM: "+itos(RS::get_singleton()->get_render_info(RS::INFO_TEXTURE_MEM_USED)));
-
+bool SceneTree::process(float p_time) {
root_lock++;
- MainLoop::idle(p_time);
+ MainLoop::process(p_time);
- idle_process_time = p_time;
+ process_time = p_time;
if (multiplayer_poll) {
multiplayer->poll();
}
- emit_signal("idle_frame");
+ emit_signal("process_frame");
MessageQueue::get_singleton()->flush(); //small little hack
flush_transform_notifications();
- _notify_group_pause("idle_process_internal", Node::NOTIFICATION_INTERNAL_PROCESS);
- _notify_group_pause("idle_process", Node::NOTIFICATION_PROCESS);
+ _notify_group_pause("process_internal", Node::NOTIFICATION_INTERNAL_PROCESS);
+ _notify_group_pause("process", Node::NOTIFICATION_PROCESS);
_flush_ugc();
MessageQueue::get_singleton()->flush(); //small little hack
@@ -516,14 +512,14 @@ bool SceneTree::idle(float p_time) {
return _quit;
}
-void SceneTree::finish() {
+void SceneTree::finalize() {
_flush_delete_queue();
_flush_ugc();
initialized = false;
- MainLoop::finish();
+ MainLoop::finalize();
if (root) {
root->_set_tree(nullptr);
@@ -787,7 +783,7 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio
return;
}
Group &g = E->get();
- if (g.nodes.empty()) {
+ if (g.nodes.is_empty()) {
return;
}
@@ -840,7 +836,7 @@ void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p
return;
}
Group &g = E->get();
- if (g.nodes.empty()) {
+ if (g.nodes.is_empty()) {
return;
}
@@ -1265,7 +1261,7 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL(MethodInfo("node_renamed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
- ADD_SIGNAL(MethodInfo("idle_frame"));
+ ADD_SIGNAL(MethodInfo("process_frame"));
ADD_SIGNAL(MethodInfo("physics_frame"));
ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
@@ -1303,7 +1299,7 @@ void SceneTree::get_argument_options(const StringName &p_function, int p_idx, Li
List<String> directories;
directories.push_back(dir_access->get_current_dir());
- while (!directories.empty()) {
+ while (!directories.is_empty()) {
dir_access->change_dir(directories.back()->get());
directories.pop_back();
@@ -1332,14 +1328,6 @@ SceneTree::SceneTree() {
if (singleton == nullptr) {
singleton = this;
}
- _quit = false;
- accept_quit = true;
- quit_on_go_back = true;
- initialized = false;
-#ifdef DEBUG_ENABLED
- debug_collisions_hint = false;
- debug_navigation_hint = false;
-#endif
debug_collisions_color = GLOBAL_DEF("debug/shapes/collision/shape_color", Color(0.0, 0.6, 0.7, 0.5));
debug_collision_contact_color = GLOBAL_DEF("debug/shapes/collision/contact_color", Color(1.0, 0.2, 0.1, 0.8));
debug_navigation_color = GLOBAL_DEF("debug/shapes/navigation/geometry_color", Color(0.1, 1.0, 0.7, 0.4));
@@ -1347,23 +1335,7 @@ SceneTree::SceneTree() {
collision_debug_contacts = GLOBAL_DEF("debug/shapes/collision/max_contacts_displayed", 10000);
ProjectSettings::get_singleton()->set_custom_property_info("debug/shapes/collision/max_contacts_displayed", PropertyInfo(Variant::INT, "debug/shapes/collision/max_contacts_displayed", PROPERTY_HINT_RANGE, "0,20000,1")); // No negative
- tree_version = 1;
- physics_process_time = 1;
- idle_process_time = 1;
-
- root = nullptr;
- pause = false;
- current_frame = 0;
- tree_changed_name = "tree_changed";
- node_added_name = "node_added";
- node_removed_name = "node_removed";
- node_renamed_name = "node_renamed";
- ugc_locked = false;
- call_lock = 0;
- root_lock = 0;
- node_count = 0;
-
- //create with mainloop
+ // Create with mainloop.
root = memnew(Window);
root->set_name("root");
@@ -1371,8 +1343,7 @@ SceneTree::SceneTree() {
root->set_world_3d(Ref<World3D>(memnew(World3D)));
}
- // Initialize network state
- multiplayer_poll = true;
+ // Initialize network state.
set_multiplayer(Ref<MultiplayerAPI>(memnew(MultiplayerAPI)));
//root->set_world_2d( Ref<World2D>( memnew( World2D )));
@@ -1409,8 +1380,8 @@ SceneTree::SceneTree() {
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/2d_sdf/oversize", PropertyInfo(Variant::INT, "rendering/quality/2d_sdf/oversize", PROPERTY_HINT_ENUM, "100%,120%,150%,200%"));
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/2d_sdf/scale", PropertyInfo(Variant::INT, "rendering/quality/2d_sdf/scale", PROPERTY_HINT_ENUM, "100%,50%,25%"));
- { //load default fallback environment
- //get possible extensions
+ { // Load default fallback environment.
+ // Get possible extensions.
List<String> exts;
ResourceLoader::get_recognized_extensions_for_type("Environment", &exts);
String ext_hint;
@@ -1420,9 +1391,9 @@ SceneTree::SceneTree() {
}
ext_hint += "*." + E->get();
}
- //get path
+ // Get path.
String env_path = GLOBAL_DEF("rendering/environment/default_environment", "");
- //setup property
+ // Setup property.
ProjectSettings::get_singleton()->set_custom_property_info("rendering/environment/default_environment", PropertyInfo(Variant::STRING, "rendering/viewport/default_environment", PROPERTY_HINT_FILE, ext_hint));
env_path = env_path.strip_edges();
if (env_path != String()) {
@@ -1431,10 +1402,10 @@ SceneTree::SceneTree() {
root->get_world_3d()->set_fallback_environment(env);
} else {
if (Engine::get_singleton()->is_editor_hint()) {
- //file was erased, clear the field.
+ // File was erased, clear the field.
ProjectSettings::get_singleton()->set("rendering/environment/default_environment", "");
} else {
- //file was erased, notify user.
+ // File was erased, notify user.
ERR_PRINT(RTR("Default Environment as specified in Project Settings (Rendering -> Environment -> Default Environment) could not be loaded."));
}
}
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 3e5802ce2e..00d4b25e76 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -80,37 +80,36 @@ public:
private:
struct Group {
Vector<Node *> nodes;
- //uint64_t last_tree_version;
bool changed;
Group() { changed = false; };
};
- Window *root;
+ Window *root = nullptr;
- uint64_t tree_version;
- float physics_process_time;
- float idle_process_time;
- bool accept_quit;
- bool quit_on_go_back;
+ uint64_t tree_version = 1;
+ float physics_process_time = 1.0;
+ float process_time = 1.0;
+ bool accept_quit = true;
+ bool quit_on_go_back = true;
#ifdef DEBUG_ENABLED
- bool debug_collisions_hint;
- bool debug_navigation_hint;
+ bool debug_collisions_hint = false;
+ bool debug_navigation_hint = false;
#endif
- bool pause;
- int root_lock;
+ bool pause = false;
+ int root_lock = 0;
Map<StringName, Group> group_map;
- bool _quit;
- bool initialized;
+ bool _quit = false;
+ bool initialized = false;
- StringName tree_changed_name;
- StringName node_added_name;
- StringName node_removed_name;
- StringName node_renamed_name;
+ StringName tree_changed_name = "tree_changed";
+ StringName node_added_name = "node_added";
+ StringName node_removed_name = "node_removed";
+ StringName node_renamed_name = "node_renamed";
- int64_t current_frame;
- int node_count;
+ int64_t current_frame = 0;
+ int node_count = 0;
#ifdef TOOLS_ENABLED
Node *edited_scene_root;
@@ -122,14 +121,14 @@ private:
bool operator<(const UGCall &p_with) const { return group == p_with.group ? call < p_with.call : group < p_with.group; }
};
- //safety for when a node is deleted while a group is being called
- int call_lock;
- Set<Node *> call_skip; //skip erased nodes
+ // Safety for when a node is deleted while a group is being called.
+ int call_lock = 0;
+ Set<Node *> call_skip; // Skip erased nodes.
List<ObjectID> delete_queue;
Map<UGCall, Vector<Variant>> unique_group_calls;
- bool ugc_locked;
+ bool ugc_locked = false;
void _flush_ugc();
_FORCE_INLINE_ void _update_group_order(Group &g, bool p_use_priority = false);
@@ -157,7 +156,7 @@ private:
///network///
Ref<MultiplayerAPI> multiplayer;
- bool multiplayer_poll;
+ bool multiplayer_poll = true;
void _network_peer_connected(int p_id);
void _network_peer_disconnected(int p_id);
@@ -183,7 +182,7 @@ private:
Variant _call_group(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
void _flush_delete_queue();
- //optimization
+ // Optimization.
friend class CanvasItem;
friend class Node3D;
friend class Viewport;
@@ -237,12 +236,12 @@ public:
void flush_transform_notifications();
- virtual void init() override;
+ virtual void initialize() override;
- virtual bool iteration(float p_time) override;
- virtual bool idle(float p_time) override;
+ virtual bool physics_process(float p_time) override;
+ virtual bool process(float p_time) override;
- virtual void finish() override;
+ virtual void finalize() override;
void set_auto_accept_quit(bool p_enable);
void set_quit_on_go_back(bool p_enable);
@@ -250,7 +249,7 @@ public:
void quit(int p_exit_code = -1);
_FORCE_INLINE_ float get_physics_process_time() const { return physics_process_time; }
- _FORCE_INLINE_ float get_idle_process_time() const { return idle_process_time; }
+ _FORCE_INLINE_ float get_process_time() const { return process_time; }
#ifdef TOOLS_ENABLED
bool is_node_being_edited(const Node *p_node) const;
diff --git a/scene/main/shader_globals_override.cpp b/scene/main/shader_globals_override.cpp
index 432fb5b4fb..d072abe546 100644
--- a/scene/main/shader_globals_override.cpp
+++ b/scene/main/shader_globals_override.cpp
@@ -264,7 +264,7 @@ String ShaderGlobalsOverride::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!active) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("ShaderGlobalsOverride is not active because another node of the same type is in the scene.");
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index c96dd4ad35..0185a5f865 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1505,7 +1505,7 @@ String Viewport::_gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Cont
}
// If we found a tooltip, we stop here.
- if (!tooltip.empty()) {
+ if (!tooltip.is_empty()) {
break;
}
@@ -1539,7 +1539,7 @@ void Viewport::_gui_show_tooltip() {
gui.tooltip_control->get_global_transform().xform_inv(gui.last_mouse_pos),
&tooltip_owner);
tooltip_text.strip_edges();
- if (tooltip_text.empty()) {
+ if (tooltip_text.is_empty()) {
return; // Nothing to show.
}
@@ -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<InputEvent> 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) {
@@ -3139,7 +3139,7 @@ String Viewport::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (size.x == 0 || size.y == 0) {
- if (!warning.empty()) {
+ if (!warning.is_empty()) {
warning += "\n\n";
}
warning += TTR("Viewport size must be greater than 0 to render anything.");
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index a7a02361a9..f4670ca850 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -33,8 +33,6 @@
#include "core/math/geometry_3d.h"
-#define ANIM_MIN_LENGTH 0.001
-
bool Animation::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index 060d1fe2d9..650a54ebfc 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -33,6 +33,8 @@
#include "core/io/resource.h"
+#define ANIM_MIN_LENGTH 0.001
+
class Animation : public Resource {
GDCLASS(Animation, Resource);
RES_BASE_EXTENSION("anim");
diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp
index d07447179d..f4764bef2d 100644
--- a/scene/resources/bit_map.cpp
+++ b/scene/resources/bit_map.cpp
@@ -43,7 +43,7 @@ void BitMap::create(const Size2 &p_size) {
}
void BitMap::create_from_image_alpha(const Ref<Image> &p_image, float p_threshold) {
- ERR_FAIL_COND(p_image.is_null() || p_image->empty());
+ ERR_FAIL_COND(p_image.is_null() || p_image->is_empty());
Ref<Image> img = p_image->duplicate();
img->convert(Image::FORMAT_LA8);
ERR_FAIL_COND(img->get_format() != Image::FORMAT_LA8);
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index de076670cf..e97f3f8825 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -602,7 +602,7 @@ void Curve2D::remove_point(int p_index) {
}
void Curve2D::clear_points() {
- if (!points.empty()) {
+ if (!points.is_empty()) {
points.clear();
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
@@ -1087,7 +1087,7 @@ void Curve3D::remove_point(int p_index) {
}
void Curve3D::clear_points() {
- if (!points.empty()) {
+ if (!points.is_empty()) {
points.clear();
baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
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<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, fl
Ref<StyleBoxTexture> 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<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, fl
static Ref<StyleBoxFlat> 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<StyleBoxFlat> 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<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> 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<Texture2D> flip_icon(Ref<Texture2D> p_texture, bool p_flip_y = false,
static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1) {
Ref<StyleBox> 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> &theme, const Ref<Font> &default_font, const
Ref<StyleBoxTexture> 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> &theme, const Ref<Font> &default_font, const
// CheckBox
Ref<StyleBox> 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<StyleBox> 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> &theme, const Ref<Font> &default_font, const
// CheckButton
Ref<StyleBox> 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> &theme, const Ref<Font> &default_font, const
Ref<StyleBoxTexture> 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> &theme, const Ref<Font> &default_font, const
Ref<StyleBoxTexture> graph_bpoint = make_stylebox(graph_node_breakpoint_png, 6, 24, 6, 5, 16, 24, 16, 6);
Ref<StyleBoxTexture> 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> &theme, const Ref<Font> &default_font, const
Ref<StyleBoxTexture> 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> &theme, const Ref<Font> &default_font, const
Ref<StyleBoxTexture> 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/environment.cpp b/scene/resources/environment.cpp
index 1eb78a3679..32840dd373 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -368,49 +368,58 @@ float Environment::get_ssao_intensity() const {
return ssao_intensity;
}
-void Environment::set_ssao_bias(float p_bias) {
- ssao_bias = p_bias;
+void Environment::set_ssao_power(float p_power) {
+ ssao_power = p_power;
_update_ssao();
}
-float Environment::get_ssao_bias() const {
- return ssao_bias;
+float Environment::get_ssao_power() const {
+ return ssao_power;
}
-void Environment::set_ssao_direct_light_affect(float p_direct_light_affect) {
- ssao_direct_light_affect = p_direct_light_affect;
+void Environment::set_ssao_detail(float p_detail) {
+ ssao_detail = p_detail;
_update_ssao();
}
-float Environment::get_ssao_direct_light_affect() const {
- return ssao_direct_light_affect;
+float Environment::get_ssao_detail() const {
+ return ssao_detail;
}
-void Environment::set_ssao_ao_channel_affect(float p_ao_channel_affect) {
- ssao_ao_channel_affect = p_ao_channel_affect;
+void Environment::set_ssao_horizon(float p_horizon) {
+ ssao_horizon = p_horizon;
_update_ssao();
}
-float Environment::get_ssao_ao_channel_affect() const {
- return ssao_ao_channel_affect;
+float Environment::get_ssao_horizon() const {
+ return ssao_horizon;
+}
+
+void Environment::set_ssao_sharpness(float p_sharpness) {
+ ssao_sharpness = p_sharpness;
+ _update_ssao();
}
-void Environment::set_ssao_blur(SSAOBlur p_blur) {
- ssao_blur = p_blur;
+float Environment::get_ssao_sharpness() const {
+ return ssao_sharpness;
+}
+
+void Environment::set_ssao_direct_light_affect(float p_direct_light_affect) {
+ ssao_direct_light_affect = p_direct_light_affect;
_update_ssao();
}
-Environment::SSAOBlur Environment::get_ssao_blur() const {
- return ssao_blur;
+float Environment::get_ssao_direct_light_affect() const {
+ return ssao_direct_light_affect;
}
-void Environment::set_ssao_edge_sharpness(float p_edge_sharpness) {
- ssao_edge_sharpness = p_edge_sharpness;
+void Environment::set_ssao_ao_channel_affect(float p_ao_channel_affect) {
+ ssao_ao_channel_affect = p_ao_channel_affect;
_update_ssao();
}
-float Environment::get_ssao_edge_sharpness() const {
- return ssao_edge_sharpness;
+float Environment::get_ssao_ao_channel_affect() const {
+ return ssao_ao_channel_affect;
}
void Environment::_update_ssao() {
@@ -419,11 +428,12 @@ void Environment::_update_ssao() {
ssao_enabled,
ssao_radius,
ssao_intensity,
- ssao_bias,
+ ssao_power,
+ ssao_detail,
+ ssao_horizon,
+ ssao_sharpness,
ssao_direct_light_affect,
- ssao_ao_channel_affect,
- RS::EnvironmentSSAOBlur(ssao_blur),
- ssao_edge_sharpness);
+ ssao_ao_channel_affect);
}
// SDFGI
@@ -1150,26 +1160,29 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ssao_radius"), &Environment::get_ssao_radius);
ClassDB::bind_method(D_METHOD("set_ssao_intensity", "intensity"), &Environment::set_ssao_intensity);
ClassDB::bind_method(D_METHOD("get_ssao_intensity"), &Environment::get_ssao_intensity);
- ClassDB::bind_method(D_METHOD("set_ssao_bias", "bias"), &Environment::set_ssao_bias);
- ClassDB::bind_method(D_METHOD("get_ssao_bias"), &Environment::get_ssao_bias);
+ ClassDB::bind_method(D_METHOD("set_ssao_power", "power"), &Environment::set_ssao_power);
+ ClassDB::bind_method(D_METHOD("get_ssao_power"), &Environment::get_ssao_power);
+ ClassDB::bind_method(D_METHOD("set_ssao_detail", "detail"), &Environment::set_ssao_detail);
+ ClassDB::bind_method(D_METHOD("get_ssao_detail"), &Environment::get_ssao_detail);
+ ClassDB::bind_method(D_METHOD("set_ssao_horizon", "horizon"), &Environment::set_ssao_horizon);
+ ClassDB::bind_method(D_METHOD("get_ssao_horizon"), &Environment::get_ssao_horizon);
+ ClassDB::bind_method(D_METHOD("set_ssao_sharpness", "sharpness"), &Environment::set_ssao_sharpness);
+ ClassDB::bind_method(D_METHOD("get_ssao_sharpness"), &Environment::get_ssao_sharpness);
ClassDB::bind_method(D_METHOD("set_ssao_direct_light_affect", "amount"), &Environment::set_ssao_direct_light_affect);
ClassDB::bind_method(D_METHOD("get_ssao_direct_light_affect"), &Environment::get_ssao_direct_light_affect);
ClassDB::bind_method(D_METHOD("set_ssao_ao_channel_affect", "amount"), &Environment::set_ssao_ao_channel_affect);
ClassDB::bind_method(D_METHOD("get_ssao_ao_channel_affect"), &Environment::get_ssao_ao_channel_affect);
- ClassDB::bind_method(D_METHOD("set_ssao_blur", "mode"), &Environment::set_ssao_blur);
- ClassDB::bind_method(D_METHOD("get_ssao_blur"), &Environment::get_ssao_blur);
- ClassDB::bind_method(D_METHOD("set_ssao_edge_sharpness", "edge_sharpness"), &Environment::set_ssao_edge_sharpness);
- ClassDB::bind_method(D_METHOD("get_ssao_edge_sharpness"), &Environment::get_ssao_edge_sharpness);
ADD_GROUP("SSAO", "ssao_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ssao_enabled"), "set_ssao_enabled", "is_ssao_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_radius", PROPERTY_HINT_RANGE, "0.1,128,0.01"), "set_ssao_radius", "get_ssao_radius");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_intensity", PROPERTY_HINT_RANGE, "0.0,128,0.01"), "set_ssao_intensity", "get_ssao_intensity");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_bias", PROPERTY_HINT_RANGE, "0.001,8,0.001"), "set_ssao_bias", "get_ssao_bias");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_radius", PROPERTY_HINT_RANGE, "0.01,16,0.01,or_greater"), "set_ssao_radius", "get_ssao_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_intensity", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_ssao_intensity", "get_ssao_intensity");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_power", PROPERTY_HINT_EXP_EASING), "set_ssao_power", "get_ssao_power");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_detail", PROPERTY_HINT_RANGE, "0,5,0.01"), "set_ssao_detail", "get_ssao_detail");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_horizon", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ssao_horizon", "get_ssao_horizon");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_sharpness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ssao_sharpness", "get_ssao_sharpness");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_light_affect", PROPERTY_HINT_RANGE, "0.00,1,0.01"), "set_ssao_direct_light_affect", "get_ssao_direct_light_affect");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_ao_channel_affect", PROPERTY_HINT_RANGE, "0.00,1,0.01"), "set_ssao_ao_channel_affect", "get_ssao_ao_channel_affect");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "ssao_blur", PROPERTY_HINT_ENUM, "Disabled,1x1,2x2,3x3"), "set_ssao_blur", "get_ssao_blur");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_edge_sharpness", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_ssao_edge_sharpness", "get_ssao_edge_sharpness");
// SDFGI
@@ -1367,11 +1380,6 @@ void Environment::_bind_methods() {
BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_REPLACE);
BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_MIX);
- BIND_ENUM_CONSTANT(SSAO_BLUR_DISABLED);
- BIND_ENUM_CONSTANT(SSAO_BLUR_1x1);
- BIND_ENUM_CONSTANT(SSAO_BLUR_2x2);
- BIND_ENUM_CONSTANT(SSAO_BLUR_3x3);
-
BIND_ENUM_CONSTANT(SDFGI_CASCADES_4);
BIND_ENUM_CONSTANT(SDFGI_CASCADES_6);
BIND_ENUM_CONSTANT(SDFGI_CASCADES_8);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index 106ba92bfe..a720f2cc47 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -70,13 +70,6 @@ public:
TONE_MAPPER_ACES,
};
- enum SSAOBlur {
- SSAO_BLUR_DISABLED,
- SSAO_BLUR_1x1,
- SSAO_BLUR_2x2,
- SSAO_BLUR_3x3,
- };
-
enum SDFGICascades {
SDFGI_CASCADES_4,
SDFGI_CASCADES_6,
@@ -148,12 +141,13 @@ private:
// SSAO
bool ssao_enabled = false;
float ssao_radius = 1.0;
- float ssao_intensity = 1.0;
- float ssao_bias = 0.01;
+ float ssao_intensity = 2.0;
+ float ssao_power = 1.5;
+ float ssao_detail = 0.5;
+ float ssao_horizon = 0.06;
+ float ssao_sharpness = 0.98;
float ssao_direct_light_affect = 0.0;
float ssao_ao_channel_affect = 0.0;
- SSAOBlur ssao_blur = SSAO_BLUR_3x3;
- float ssao_edge_sharpness = 4.0;
void _update_ssao();
// SDFGI
@@ -295,16 +289,18 @@ public:
float get_ssao_radius() const;
void set_ssao_intensity(float p_intensity);
float get_ssao_intensity() const;
- void set_ssao_bias(float p_bias);
- float get_ssao_bias() const;
+ void set_ssao_power(float p_power);
+ float get_ssao_power() const;
+ void set_ssao_detail(float p_detail);
+ float get_ssao_detail() const;
+ void set_ssao_horizon(float p_horizon);
+ float get_ssao_horizon() const;
+ void set_ssao_sharpness(float p_sharpness);
+ float get_ssao_sharpness() const;
void set_ssao_direct_light_affect(float p_direct_light_affect);
float get_ssao_direct_light_affect() const;
void set_ssao_ao_channel_affect(float p_ao_channel_affect);
float get_ssao_ao_channel_affect() const;
- void set_ssao_blur(SSAOBlur p_blur);
- SSAOBlur get_ssao_blur() const;
- void set_ssao_edge_sharpness(float p_edge_sharpness);
- float get_ssao_edge_sharpness() const;
// SDFGI
void set_sdfgi_enabled(bool p_enabled);
@@ -414,7 +410,6 @@ VARIANT_ENUM_CAST(Environment::BGMode)
VARIANT_ENUM_CAST(Environment::AmbientSource)
VARIANT_ENUM_CAST(Environment::ReflectionSource)
VARIANT_ENUM_CAST(Environment::ToneMapper)
-VARIANT_ENUM_CAST(Environment::SSAOBlur)
VARIANT_ENUM_CAST(Environment::SDFGICascades)
VARIANT_ENUM_CAST(Environment::SDFGIYScale)
VARIANT_ENUM_CAST(Environment::GlowBlendMode)
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 791f260c0e..667d4af76d 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -724,7 +724,7 @@ void Font::set_spacing(int p_type, int p_value) {
// Drawing string and string sizes, cached.
Size2 Font::get_string_size(const String &p_text, int p_size) const {
- ERR_FAIL_COND_V(data.empty(), Size2());
+ ERR_FAIL_COND_V(data.is_empty(), Size2());
uint64_t hash = p_text.hash64();
hash = hash_djb2_one_64(p_size, hash);
@@ -746,7 +746,7 @@ Size2 Font::get_string_size(const String &p_text, int p_size) const {
}
Size2 Font::get_multiline_string_size(const String &p_text, float p_width, int p_size, uint8_t p_flags) const {
- ERR_FAIL_COND_V(data.empty(), Size2());
+ ERR_FAIL_COND_V(data.is_empty(), Size2());
uint64_t hash = p_text.hash64();
hash = hash_djb2_one_64(p_size, hash);
diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h
index e839909770..0e8f114383 100644
--- a/scene/resources/gradient.h
+++ b/scene/resources/gradient.h
@@ -82,7 +82,7 @@ public:
Vector<Color> get_colors() const;
_FORCE_INLINE_ Color get_color_at_offset(float p_offset) {
- if (points.empty()) {
+ if (points.is_empty()) {
return Color(0, 0, 0, 1);
}
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index f1c05b8014..8d101aa8d3 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -74,7 +74,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
}
Array a = surface_get_arrays(i);
- ERR_FAIL_COND_V(a.empty(), Ref<TriangleMesh>());
+ ERR_FAIL_COND_V(a.is_empty(), Ref<TriangleMesh>());
int vc = surface_get_array_len(i);
Vector<Vector3> vertices = a[ARRAY_VERTEX];
@@ -226,7 +226,7 @@ Ref<Shape3D> Mesh::create_convex_shape() const {
for (int i = 0; i < get_surface_count(); i++) {
Array a = surface_get_arrays(i);
- ERR_FAIL_COND_V(a.empty(), Ref<ConvexPolygonShape3D>());
+ ERR_FAIL_COND_V(a.is_empty(), Ref<ConvexPolygonShape3D>());
Vector<Vector3> v = a[ARRAY_VERTEX];
vertices.append_array(v);
}
@@ -266,7 +266,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
}
Array a = surface_get_arrays(i);
- ERR_FAIL_COND_V(a.empty(), Ref<ArrayMesh>());
+ ERR_FAIL_COND_V(a.is_empty(), Ref<ArrayMesh>());
if (i == 0) {
arrays = a;
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index a5c360f123..a24cc800df 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -43,7 +43,7 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf
ERR_FAIL_COND_V(p_mesh->surface_get_primitive_type(p_surface) != Mesh::PRIMITIVE_TRIANGLES, ERR_INVALID_PARAMETER);
Array arrays = p_mesh->surface_get_arrays(p_surface);
- ERR_FAIL_COND_V(arrays.empty(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(arrays.is_empty(), ERR_INVALID_PARAMETER);
Vector<Vector3> varray = arrays[Mesh::ARRAY_VERTEX];
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 09674f3465..a89858f02a 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -80,7 +80,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
Node **ret_nodes = (Node **)alloca(sizeof(Node *) * nc);
- bool gen_node_path_cache = p_edit_state != GEN_EDIT_STATE_DISABLED && node_path_cache.empty();
+ bool gen_node_path_cache = p_edit_state != GEN_EDIT_STATE_DISABLED && node_path_cache.is_empty();
Map<Ref<Resource>, Ref<Resource>> resources_local_to_scene;
@@ -603,7 +603,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map
// Save the right type. If this node was created by an instance
// then flag that the node should not be created but reused
- if (pack_state_stack.empty()) {
+ if (pack_state_stack.is_empty()) {
//this node is not part of an instancing process, so save the type
nd.type = _nm_get_string(p_node->get_class(), name_map);
} else {
@@ -1349,7 +1349,7 @@ NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const {
sub_path.insert(0, base_path.get_name(i));
}
- if (sub_path.empty()) {
+ if (sub_path.is_empty()) {
return NodePath(".");
}
diff --git a/scene/resources/shape_3d.cpp b/scene/resources/shape_3d.cpp
index 59766f4f1f..115d7f74cc 100644
--- a/scene/resources/shape_3d.cpp
+++ b/scene/resources/shape_3d.cpp
@@ -66,7 +66,7 @@ Ref<ArrayMesh> Shape3D::get_debug_mesh() {
debug_mesh_cache = Ref<ArrayMesh>(memnew(ArrayMesh));
- if (!lines.empty()) {
+ if (!lines.is_empty()) {
//make mesh
Vector<Vector3> array;
array.resize(lines.size());
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<Texture2D> 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/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp
index e3e4373fa9..96c7f23981 100644
--- a/scene/resources/syntax_highlighter.cpp
+++ b/scene/resources/syntax_highlighter.cpp
@@ -552,7 +552,7 @@ Dictionary CodeHighlighter::get_color_regions() const {
Dictionary r_color_regions;
for (int i = 0; i < color_regions.size(); i++) {
ColorRegion region = color_regions[i];
- r_color_regions[region.start_key + (region.end_key.empty() ? "" : " " + region.end_key)] = region.color;
+ r_color_regions[region.start_key + (region.end_key.is_empty() ? "" : " " + region.end_key)] = region.color;
}
return r_color_regions;
}
diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp
index cc9b6758b6..a32d443c6a 100644
--- a/scene/resources/text_line.cpp
+++ b/scene/resources/text_line.cpp
@@ -97,7 +97,7 @@ void TextLine::_bind_methods() {
void TextLine::_shape() {
if (dirty) {
- if (!tab_stops.empty()) {
+ if (!tab_stops.is_empty()) {
TS->shaped_text_tab_align(rid, tab_stops);
}
if (align == HALIGN_FILL) {
diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp
index fd6dd071eb..2624cc8b0b 100644
--- a/scene/resources/text_paragraph.cpp
+++ b/scene/resources/text_paragraph.cpp
@@ -110,14 +110,14 @@ void TextParagraph::_shape_lines() {
}
lines.clear();
- if (!tab_stops.empty()) {
+ if (!tab_stops.is_empty()) {
TS->shaped_text_tab_align(rid, tab_stops);
}
Vector<Vector2i> line_breaks = TS->shaped_text_get_line_breaks(rid, width, 0, flags);
for (int i = 0; i < line_breaks.size(); i++) {
RID line = TS->shaped_text_substr(rid, line_breaks[i].x, line_breaks[i].y - line_breaks[i].x);
- if (!tab_stops.empty()) {
+ if (!tab_stops.is_empty()) {
TS->shaped_text_tab_align(line, tab_stops);
}
if (align == HALIGN_FILL && (line_breaks.size() == 1 || i < line_breaks.size() - 1)) {
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 706b18d2b5..730b53b29c 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -371,8 +371,8 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit
img = Image::lossy_unpacker(pv);
}
- if (img.is_null() || img->empty()) {
- ERR_FAIL_COND_V(img.is_null() || img->empty(), Ref<Image>());
+ if (img.is_null() || img->is_empty()) {
+ ERR_FAIL_COND_V(img.is_null() || img->is_empty(), Ref<Image>());
}
if (first) {
@@ -548,7 +548,7 @@ Error StreamTexture2D::_load_data(const String &p_path, int &tw, int &th, int &t
memdelete(f);
- if (image.is_null() || image->empty()) {
+ if (image.is_null() || image->is_empty()) {
return ERR_CANT_OPEN;
}
@@ -924,7 +924,7 @@ Error StreamTexture3D::_load_data(const String &p_path, Vector<Ref<Image>> &r_da
for (int i = 0; i < (r_depth + mipmaps); i++) {
Ref<Image> image = StreamTexture2D::load_image_from_file(f, 0);
- ERR_FAIL_COND_V(image.is_null() || image->empty(), ERR_CANT_OPEN);
+ ERR_FAIL_COND_V(image.is_null() || image->is_empty(), ERR_CANT_OPEN);
if (i == 0) {
r_format = image->get_format();
r_width = image->get_width();
@@ -2223,7 +2223,7 @@ Error ImageTextureLayered::create_from_images(Vector<Ref<Image>> p_images) {
"Cubemap array layers must be a multiple of 6");
}
- ERR_FAIL_COND_V(p_images[0].is_null() || p_images[0]->empty(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_images[0].is_null() || p_images[0]->is_empty(), ERR_INVALID_PARAMETER);
Image::Format new_format = p_images[0]->get_format();
int new_width = p_images[0]->get_width();
@@ -2361,7 +2361,7 @@ Error StreamTextureLayered::_load_data(const String &p_path, Vector<Ref<Image>>
for (uint32_t i = 0; i < layer_count; i++) {
Ref<Image> image = StreamTexture2D::load_image_from_file(f, p_size_limit);
- ERR_FAIL_COND_V(image.is_null() || image->empty(), ERR_CANT_OPEN);
+ ERR_FAIL_COND_V(image.is_null() || image->is_empty(), ERR_CANT_OPEN);
images.write[i] = image;
}
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 34129e35da..50f456bc59 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -3124,7 +3124,7 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad
_expression = _expression.replace("\n", "\n\t\t");
static Vector<String> pre_symbols;
- if (pre_symbols.empty()) {
+ if (pre_symbols.is_empty()) {
pre_symbols.push_back("\t");
pre_symbols.push_back(",");
pre_symbols.push_back(";");
@@ -3144,7 +3144,7 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad
}
static Vector<String> post_symbols;
- if (post_symbols.empty()) {
+ if (post_symbols.is_empty()) {
post_symbols.push_back("\t");
post_symbols.push_back("\n");
post_symbols.push_back(",");
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 41d3fe20be..7aad3a2e05 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -111,7 +111,7 @@ struct SpatialIndexer2D {
ERR_CONTINUE(!E);
if (E->get().notifiers[p_notifier].dec() == 0) {
E->get().notifiers.erase(p_notifier);
- if (E->get().notifiers.empty()) {
+ if (E->get().notifiers.is_empty()) {
cells.erase(E);
}
}
@@ -156,7 +156,7 @@ struct SpatialIndexer2D {
}
}
- while (!removed.empty()) {
+ while (!removed.is_empty()) {
p_notifier->_exit_viewport(removed.front()->get());
removed.pop_front();
}
@@ -189,7 +189,7 @@ struct SpatialIndexer2D {
removed.push_back(E->key());
}
- while (!removed.empty()) {
+ while (!removed.is_empty()) {
removed.front()->get()->_exit_viewport(p_viewport);
removed.pop_front();
}
@@ -271,12 +271,12 @@ struct SpatialIndexer2D {
}
}
- while (!added.empty()) {
+ while (!added.is_empty()) {
added.front()->get()->_enter_viewport(E->key());
added.pop_front();
}
- while (!removed.empty()) {
+ while (!removed.is_empty()) {
E->get().notifiers.erase(removed.front()->get());
removed.front()->get()->_exit_viewport(E->key());
removed.pop_front();
diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp
index b8fb3825ce..1503152b5e 100644
--- a/scene/resources/world_3d.cpp
+++ b/scene/resources/world_3d.cpp
@@ -97,7 +97,7 @@ struct SpatialIndexer {
}
}
- while (!removed.empty()) {
+ while (!removed.is_empty()) {
p_notifier->_exit_camera(removed.front()->get());
removed.pop_front();
}
@@ -125,7 +125,7 @@ struct SpatialIndexer {
removed.push_back(E->key());
}
- while (!removed.empty()) {
+ while (!removed.is_empty()) {
removed.front()->get()->_exit_camera(p_camera);
removed.pop_front();
}
@@ -175,12 +175,12 @@ struct SpatialIndexer {
}
}
- while (!added.empty()) {
+ while (!added.is_empty()) {
added.front()->get()->_enter_camera(E->key());
added.pop_front();
}
- while (!removed.empty()) {
+ while (!removed.is_empty()) {
E->get().notifiers.erase(removed.front()->get());
removed.front()->get()->_exit_camera(E->key());
removed.pop_front();