summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2023-04-25 14:24:38 +0200
committerGitHub <noreply@github.com>2023-04-25 14:24:38 +0200
commitd78691d44fe6e4f38dce3a89164cdae688772031 (patch)
tree26b6162338b2be9844691916f60a9b0878b79c1c /scene
parent90b4ca2e506c6a0d432770d59f62ae7eea565ad0 (diff)
parentb5bd99d9e6062f5820e7e51cdaee8d799c85f701 (diff)
Merge pull request #76405 from YuriSizov/4.0-cherrypicks
Cherry-picks for the 4.0 branch (future 4.0.3) - 2nd batch
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/cpu_particles_2d.cpp4
-rw-r--r--scene/3d/cpu_particles_3d.cpp4
-rw-r--r--scene/gui/code_edit.cpp2
-rw-r--r--scene/gui/color_picker.cpp12
-rw-r--r--scene/gui/control.cpp16
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp15
-rw-r--r--scene/gui/rich_text_label.h2
-rw-r--r--scene/gui/text_edit.cpp2
-rw-r--r--scene/gui/tree.cpp4
-rw-r--r--scene/main/canvas_item.cpp6
-rw-r--r--scene/resources/default_theme/default_theme.cpp24
-rw-r--r--scene/resources/particle_process_material.cpp4
-rw-r--r--scene/resources/style_box.cpp72
-rw-r--r--scene/resources/style_box.h2
-rw-r--r--scene/resources/visual_shader.cpp12
16 files changed, 106 insertions, 77 deletions
diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp
index 04c7555306..b86635b82b 100644
--- a/scene/2d/cpu_particles_2d.cpp
+++ b/scene/2d/cpu_particles_2d.cpp
@@ -722,12 +722,12 @@ void CPUParticles2D::_particles_process(double p_delta) {
tex_linear_velocity = curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY]->sample(0);
}*/
- real_t tex_angle = 0.0;
+ real_t tex_angle = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_angle = curve_parameters[PARAM_ANGLE]->sample(tv);
}
- real_t tex_anim_offset = 0.0;
+ real_t tex_anim_offset = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_anim_offset = curve_parameters[PARAM_ANGLE]->sample(tv);
}
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp
index 23855b2d8e..2ee62920ed 100644
--- a/scene/3d/cpu_particles_3d.cpp
+++ b/scene/3d/cpu_particles_3d.cpp
@@ -742,12 +742,12 @@ void CPUParticles3D::_particles_process(double p_delta) {
tex_linear_velocity = curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY]->sample(0);
}*/
- real_t tex_angle = 0.0;
+ real_t tex_angle = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_angle = curve_parameters[PARAM_ANGLE]->sample(tv);
}
- real_t tex_anim_offset = 0.0;
+ real_t tex_anim_offset = 1.0;
if (curve_parameters[PARAM_ANGLE].is_valid()) {
tex_anim_offset = curve_parameters[PARAM_ANGLE]->sample(tv);
}
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 91c4fa3761..ca5e9b401c 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -1968,7 +1968,7 @@ void CodeEdit::confirm_code_completion(bool p_replace) {
return;
}
- char32_t caret_last_completion_char;
+ char32_t caret_last_completion_char = 0;
begin_complex_operation();
Vector<int> caret_edit_order = get_caret_index_edit_order();
for (const int &i : caret_edit_order) {
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 48e3759981..cea60f375a 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -500,8 +500,9 @@ void ColorPicker::_html_submitted(const String &p_html) {
return;
}
- Color previous_color = color;
- color = Color::html(p_html);
+ const Color previous_color = color;
+ color = Color::from_string(p_html, previous_color);
+
if (!is_editing_alpha()) {
color.a = previous_color.a;
}
@@ -601,13 +602,13 @@ void ColorPicker::_text_type_toggled() {
text_type->set_icon(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")));
c_text->set_editable(false);
- c_text->set_h_size_flags(SIZE_EXPAND_FILL);
+ c_text->set_tooltip_text(RTR("Copy this constructor in a script."));
} else {
text_type->set_text("#");
text_type->set_icon(nullptr);
c_text->set_editable(true);
- c_text->set_h_size_flags(SIZE_FILL);
+ c_text->set_tooltip_text(RTR("Enter a hex code (\"#ff0000\") or named color (\"red\")."));
}
_update_color();
}
@@ -1754,7 +1755,10 @@ ColorPicker::ColorPicker() {
c_text = memnew(LineEdit);
hex_hbc->add_child(c_text);
+ c_text->set_h_size_flags(SIZE_EXPAND_FILL);
c_text->set_select_all_on_focus(true);
+ c_text->set_tooltip_text(RTR("Enter a hex code (\"#ff0000\") or named color (\"red\")."));
+ c_text->set_placeholder(RTR("Hex code or named color"));
c_text->connect("text_submitted", callable_mp(this, &ColorPicker::_html_submitted));
c_text->connect("text_changed", callable_mp(this, &ColorPicker::_text_changed));
c_text->connect("focus_exited", callable_mp(this, &ColorPicker::_html_focus_exit));
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 3ecb9c47c0..8aee6144fc 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -765,7 +765,7 @@ void Control::set_anchor_and_offset(Side p_side, real_t p_anchor, real_t p_pos,
set_offset(p_side, p_pos);
}
-void Control::set_begin(const Size2 &p_point) {
+void Control::set_begin(const Point2 &p_point) {
ERR_FAIL_COND(!isfinite(p_point.x) || !isfinite(p_point.y));
if (data.offset[0] == p_point.x && data.offset[1] == p_point.y) {
return;
@@ -776,11 +776,11 @@ void Control::set_begin(const Size2 &p_point) {
_size_changed();
}
-Size2 Control::get_begin() const {
- return Size2(data.offset[0], data.offset[1]);
+Point2 Control::get_begin() const {
+ return Point2(data.offset[0], data.offset[1]);
}
-void Control::set_end(const Size2 &p_point) {
+void Control::set_end(const Point2 &p_point) {
if (data.offset[2] == p_point.x && data.offset[3] == p_point.y) {
return;
}
@@ -790,8 +790,8 @@ void Control::set_end(const Size2 &p_point) {
_size_changed();
}
-Size2 Control::get_end() const {
- return Size2(data.offset[2], data.offset[3]);
+Point2 Control::get_end() const {
+ return Point2(data.offset[2], data.offset[3]);
}
void Control::set_h_grow_direction(GrowDirection p_direction) {
@@ -1358,11 +1358,11 @@ void Control::set_grow_direction_preset(LayoutPreset p_preset) {
/// Manual positioning.
-void Control::_set_position(const Size2 &p_point) {
+void Control::_set_position(const Point2 &p_point) {
set_position(p_point);
}
-void Control::set_position(const Size2 &p_point, bool p_keep_offsets) {
+void Control::set_position(const Point2 &p_point, bool p_keep_offsets) {
if (p_keep_offsets) {
_compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor);
} else {
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 6b2faf1a40..17cc81c8d3 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -952,7 +952,7 @@ void LineEdit::_notification(int p_what) {
if (ceil(ofs.x) >= x_ofs && (ofs.x + glyphs[i].advance) <= ofs_max) {
if (glyphs[i].font_rid != RID()) {
TS->font_draw_glyph(glyphs[i].font_rid, ci, glyphs[i].font_size, ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, selected ? font_selected_color : font_color);
- } else if ((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
+ } else if (((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) && ((glyphs[i].flags & TextServer::GRAPHEME_IS_EMBEDDED_OBJECT) != TextServer::GRAPHEME_IS_EMBEDDED_OBJECT)) {
TS->draw_hex_code_box(ci, glyphs[i].font_size, ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, selected ? font_selected_color : font_color);
}
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 68e12b9bb5..cf7b6cf608 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1323,7 +1323,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
if (!skip) {
if (frid != RID()) {
TS->font_draw_glyph(frid, ci, glyphs[i].font_size, p_ofs + fx_offset + off, gl, font_color);
- } else if ((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
+ } else if (((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) && ((glyphs[i].flags & TextServer::GRAPHEME_IS_EMBEDDED_OBJECT) != TextServer::GRAPHEME_IS_EMBEDDED_OBJECT)) {
TS->draw_hex_code_box(ci, glyphs[i].font_size, p_ofs + fx_offset + off, gl, font_color);
}
}
@@ -1510,7 +1510,7 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V
}
if (crect.has_point(p_click)) {
for (int j = 0; j < (int)frame->lines.size(); j++) {
- _find_click_in_line(frame, j, rect.position + Vector2(0, frame->lines[j].offset.y), rect.size.x, p_click, &table_click_frame, &table_click_line, &table_click_item, &table_click_char, true, p_meta);
+ _find_click_in_line(frame, j, rect.position + Vector2(frame->padding.position.x, frame->lines[j].offset.y), rect.size.x, p_click, &table_click_frame, &table_click_line, &table_click_item, &table_click_char, true, p_meta);
if (table_click_frame && table_click_item) {
// Save cell detected cell hit data.
table_range = Vector2i(INT32_MAX, 0);
@@ -2697,6 +2697,10 @@ bool RichTextLabel::is_ready() const {
return (main->first_invalid_line.load() == (int)main->lines.size() && main->first_resized_line.load() == (int)main->lines.size() && main->first_invalid_font_line.load() == (int)main->lines.size());
}
+bool RichTextLabel::is_updating() const {
+ return updating.load() || validating.load();
+}
+
void RichTextLabel::set_threaded(bool p_threaded) {
if (threaded != p_threaded) {
_stop_thread();
@@ -2721,6 +2725,7 @@ bool RichTextLabel::_validate_line_caches() {
if (updating.load()) {
return false;
}
+ validating.store(true);
if (main->first_invalid_line.load() == (int)main->lines.size()) {
MutexLock data_lock(data_mutex);
Rect2 text_rect = _get_text_rect();
@@ -2739,6 +2744,7 @@ bool RichTextLabel::_validate_line_caches() {
if (main->first_resized_line.load() == (int)main->lines.size()) {
vscroll->set_value(old_scroll);
+ validating.store(false);
return true;
}
@@ -2790,8 +2796,10 @@ bool RichTextLabel::_validate_line_caches() {
if (fit_content) {
update_minimum_size();
}
+ validating.store(false);
return true;
}
+ validating.store(false);
stop_thread.store(false);
if (threaded) {
updating.store(true);
@@ -2801,7 +2809,9 @@ bool RichTextLabel::_validate_line_caches() {
loading_started = OS::get_singleton()->get_ticks_msec();
return false;
} else {
+ updating.store(true);
_process_line_caches();
+ updating.store(false);
queue_redraw();
return true;
}
@@ -5882,6 +5892,7 @@ RichTextLabel::RichTextLabel(const String &p_text) {
set_text(p_text);
updating.store(false);
+ validating.store(false);
stop_thread.store(false);
set_clip_contents(true);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 1dae8b75ca..5a9a8478b7 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -376,6 +376,7 @@ private:
bool threaded = false;
std::atomic<bool> stop_thread;
std::atomic<bool> updating;
+ std::atomic<bool> validating;
std::atomic<double> loaded;
uint64_t loading_started = 0;
@@ -679,6 +680,7 @@ public:
void deselect();
bool is_ready() const;
+ bool is_updating() const;
void set_threaded(bool p_threaded);
bool is_threaded() const;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 0560b9f2e4..814af12d60 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1276,7 +1276,7 @@ void TextEdit::_notification(int p_what) {
if (glyphs[j].font_rid != RID()) {
TS->font_draw_glyph(glyphs[j].font_rid, ci, glyphs[j].font_size, Vector2(char_margin + char_ofs + ofs_x + glyphs[j].x_off, ofs_y + glyphs[j].y_off), glyphs[j].index, gl_color);
had_glyphs_drawn = true;
- } else if ((glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
+ } else if (((glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) && ((glyphs[j].flags & TextServer::GRAPHEME_IS_EMBEDDED_OBJECT) != TextServer::GRAPHEME_IS_EMBEDDED_OBJECT)) {
TS->draw_hex_code_box(ci, glyphs[j].font_size, Vector2(char_margin + char_ofs + ofs_x + glyphs[j].x_off, ofs_y + glyphs[j].y_off), glyphs[j].index, gl_color);
had_glyphs_drawn = true;
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index f8c2e9f4ad..bae2c8a9cb 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -4523,8 +4523,8 @@ int Tree::get_item_offset(TreeItem *p_item) const {
return ofs;
}
- ofs += compute_item_height(it);
- if (it != root || !hide_root) {
+ if ((it != root || !hide_root) && it->is_visible()) {
+ ofs += compute_item_height(it);
ofs += theme_cache.v_separation;
}
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 72fb838732..de76d3610d 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -219,7 +219,7 @@ void CanvasItem::_enter_canvas() {
RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
RenderingServer::get_singleton()->canvas_item_set_visibility_layer(canvas_item, visibility_layer);
- canvas_group = "root_canvas" + itos(canvas.get_id());
+ canvas_group = "_root_canvas" + itos(canvas.get_id());
add_to_group(canvas_group);
if (canvas_layer) {
@@ -341,9 +341,7 @@ void CanvasItem::_notification(int p_what) {
}
void CanvasItem::_window_visibility_changed() {
- if (visible) {
- _propagate_visibility_changed(window->is_visible());
- }
+ _propagate_visibility_changed(window->is_visible());
}
void CanvasItem::queue_redraw() {
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 2e1ba96d11..35c81ea91b 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -162,7 +162,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_font("font", "Button", Ref<Font>());
theme->set_font_size("font_size", "Button", -1);
- theme->set_constant("outline_size", "Button", 0 * scale);
+ theme->set_constant("outline_size", "Button", 0);
theme->set_color("font_color", "Button", control_font_color);
theme->set_color("font_pressed_color", "Button", control_font_pressed_color);
@@ -190,7 +190,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_font("font", "MenuBar", Ref<Font>());
theme->set_font_size("font_size", "MenuBar", -1);
- theme->set_constant("outline_size", "MenuBar", 0 * scale);
+ theme->set_constant("outline_size", "MenuBar", 0);
theme->set_color("font_color", "MenuBar", control_font_color);
theme->set_color("font_pressed_color", "MenuBar", control_font_pressed_color);
@@ -315,7 +315,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("font_outline_color", "CheckBox", Color(1, 1, 1));
theme->set_constant("h_separation", "CheckBox", 4 * scale);
- theme->set_constant("check_v_offset", "CheckBox", 0 * scale);
+ theme->set_constant("check_v_offset", "CheckBox", 0);
theme->set_constant("outline_size", "CheckBox", 0);
// CheckButton
@@ -352,7 +352,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_color("font_outline_color", "CheckButton", Color(1, 1, 1));
theme->set_constant("h_separation", "CheckButton", 4 * scale);
- theme->set_constant("check_v_offset", "CheckButton", 0 * scale);
+ theme->set_constant("check_v_offset", "CheckButton", 0);
theme->set_constant("outline_size", "CheckButton", 0);
// Label
@@ -1034,7 +1034,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * scale);
theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * scale);
- theme->set_constant("line_separation", "RichTextLabel", 0 * scale);
+ theme->set_constant("line_separation", "RichTextLabel", 0);
theme->set_constant("table_h_separation", "RichTextLabel", 3 * scale);
theme->set_constant("table_v_separation", "RichTextLabel", 3 * scale);
@@ -1057,10 +1057,10 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("separation", "BoxContainer", 4 * scale);
theme->set_constant("separation", "HBoxContainer", 4 * scale);
theme->set_constant("separation", "VBoxContainer", 4 * scale);
- theme->set_constant("margin_left", "MarginContainer", 0 * scale);
- theme->set_constant("margin_top", "MarginContainer", 0 * scale);
- theme->set_constant("margin_right", "MarginContainer", 0 * scale);
- theme->set_constant("margin_bottom", "MarginContainer", 0 * scale);
+ theme->set_constant("margin_left", "MarginContainer", 0);
+ theme->set_constant("margin_top", "MarginContainer", 0);
+ theme->set_constant("margin_right", "MarginContainer", 0);
+ theme->set_constant("margin_bottom", "MarginContainer", 0);
theme->set_constant("h_separation", "GridContainer", 4 * scale);
theme->set_constant("v_separation", "GridContainer", 4 * scale);
theme->set_constant("separation", "SplitContainer", 12 * scale);
@@ -1069,9 +1069,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("minimum_grab_thickness", "SplitContainer", 6 * scale);
theme->set_constant("minimum_grab_thickness", "HSplitContainer", 6 * scale);
theme->set_constant("minimum_grab_thickness", "VSplitContainer", 6 * scale);
- theme->set_constant("autohide", "SplitContainer", 1 * scale);
- theme->set_constant("autohide", "HSplitContainer", 1 * scale);
- theme->set_constant("autohide", "VSplitContainer", 1 * scale);
+ theme->set_constant("autohide", "SplitContainer", 1);
+ theme->set_constant("autohide", "HSplitContainer", 1);
+ theme->set_constant("autohide", "VSplitContainer", 1);
theme->set_constant("h_separation", "FlowContainer", 4 * scale);
theme->set_constant("v_separation", "FlowContainer", 4 * scale);
theme->set_constant("h_separation", "HFlowContainer", 4 * scale);
diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp
index 7ae154ea1d..41edbcb726 100644
--- a/scene/resources/particle_process_material.cpp
+++ b/scene/resources/particle_process_material.cpp
@@ -419,7 +419,7 @@ void ParticleProcessMaterial::_update_shader() {
if (tex_parameters[PARAM_ANGLE].is_valid()) {
code += " float tex_angle = textureLod(angle_texture, vec2(0.0, 0.0), 0.0).r;\n";
} else {
- code += " float tex_angle = 0.0;\n";
+ code += " float tex_angle = 1.0;\n";
}
if (tex_parameters[PARAM_ANIM_OFFSET].is_valid()) {
@@ -737,7 +737,7 @@ void ParticleProcessMaterial::_update_shader() {
code += " VELOCITY = normalize(VELOCITY) * v;\n";
code += " }\n";
code += " }\n";
- code += " float base_angle = (tex_angle) * mix(initial_angle_min, initial_angle_max, rand_from_seed(alt_seed));\n";
+ code += " float base_angle = (tex_angle) * mix(initial_angle_min, initial_angle_max, angle_rand);\n";
code += " base_angle += CUSTOM.y * LIFETIME * (tex_angular_velocity) * mix(angular_velocity_min,angular_velocity_max, rand_from_seed(alt_seed));\n";
code += " CUSTOM.x = base_angle * degree_to_rad;\n"; // angle
code += " CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, rand_from_seed(alt_seed)) + tv * tex_anim_speed * mix(anim_speed_min, anim_speed_max, rand_from_seed(alt_seed));\n"; // angle
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 9e0b856ecd..27ae83908e 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -757,76 +757,84 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
// Create infill (no AA).
- if (draw_center && (!aa_on || blend_on || !draw_border)) {
+ if (draw_center && (!aa_on || blend_on)) {
draw_ring(verts, indices, colors, border_style_rect, adapted_corner,
infill_rect, infill_rect, bg_color, bg_color, corner_detail, skew, true);
}
if (aa_on) {
real_t aa_border_width[4];
+ real_t aa_border_width_half[4];
real_t aa_fill_width[4];
+ real_t aa_fill_width_half[4];
if (draw_border) {
for (int i = 0; i < 4; i++) {
if (border_width[i] > 0) {
aa_border_width[i] = aa_size;
+ aa_border_width_half[i] = aa_size / 2;
aa_fill_width[i] = 0;
+ aa_fill_width_half[i] = 0;
} else {
aa_border_width[i] = 0;
+ aa_border_width_half[i] = 0;
aa_fill_width[i] = aa_size;
+ aa_fill_width_half[i] = aa_size / 2;
}
}
} else {
for (int i = 0; i < 4; i++) {
aa_border_width[i] = 0;
+ aa_border_width_half[i] = 0;
aa_fill_width[i] = aa_size;
+ aa_fill_width_half[i] = aa_size / 2;
}
}
- 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) {
- Rect2 infill_inner_rect_aa = infill_inner_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP],
- aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]);
- // Create infill within AA border.
+ // Infill rect, transparent side of antialiasing gradient (base infill rect enlarged by AA size)
+ Rect2 infill_rect_aa_transparent = infill_rect.grow_individual(aa_fill_width_half[SIDE_LEFT], aa_fill_width_half[SIDE_TOP],
+ aa_fill_width_half[SIDE_RIGHT], aa_fill_width_half[SIDE_BOTTOM]);
+ // Infill rect, colored side of antialiasing gradient (base infill rect shrunk by AA size)
+ Rect2 infill_rect_aa_colored = infill_rect_aa_transparent.grow_individual(-aa_fill_width[SIDE_LEFT], -aa_fill_width[SIDE_TOP],
+ -aa_fill_width[SIDE_RIGHT], -aa_fill_width[SIDE_BOTTOM]);
+ if (!blend_on) {
+ // Create center fill, not antialiased yet
draw_ring(verts, indices, colors, border_style_rect, adapted_corner,
- infill_inner_rect_aa, infill_inner_rect_aa, bg_color, bg_color, corner_detail, skew, true);
+ infill_rect_aa_colored, infill_rect_aa_colored, bg_color, bg_color, corner_detail, skew, true);
}
-
if (!blend_on || !draw_border) {
- Rect2 infill_rect_aa = 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);
-
- // Create infill fake AA gradient.
- draw_ring(verts, indices, colors, style_rect, adapted_corner,
- infill_rect_aa, infill_rect, bg_color, alpha_bg, corner_detail, skew);
+ // Add antialiasing on the center fill
+ draw_ring(verts, indices, colors, border_style_rect, adapted_corner,
+ infill_rect_aa_transparent, infill_rect_aa_colored, bg_color, alpha_bg, corner_detail, skew);
}
}
if (draw_border) {
- Rect2 infill_rect_aa = infill_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP],
- aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]);
- Rect2 style_rect_aa = style_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP],
- aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]);
- Rect2 border_style_rect_aa = border_style_rect.grow_individual(aa_border_width[SIDE_LEFT], aa_border_width[SIDE_TOP],
- aa_border_width[SIDE_RIGHT], aa_border_width[SIDE_BOTTOM]);
-
- // Create border.
+ // Inner border recct, fully colored side of antialiasing gradient (base inner rect enlarged by AA size)
+ Rect2 inner_rect_aa_colored = infill_rect.grow_individual(aa_border_width_half[SIDE_LEFT], aa_border_width_half[SIDE_TOP],
+ aa_border_width_half[SIDE_RIGHT], aa_border_width_half[SIDE_BOTTOM]);
+ // Inner border rect, transparent side of antialiasing gradient (base inner rect shrunk by AA size)
+ Rect2 inner_rect_aa_transparent = inner_rect_aa_colored.grow_individual(-aa_border_width[SIDE_LEFT], -aa_border_width[SIDE_TOP],
+ -aa_border_width[SIDE_RIGHT], -aa_border_width[SIDE_BOTTOM]);
+ // Outer border rect, transparent side of antialiasing gradient (base outer rect enlarged by AA size)
+ Rect2 outer_rect_aa_transparent = style_rect.grow_individual(aa_border_width_half[SIDE_LEFT], aa_border_width_half[SIDE_TOP],
+ aa_border_width_half[SIDE_RIGHT], aa_border_width_half[SIDE_BOTTOM]);
+ // Outer border rect, colored side of antialiasing gradient (base outer rect shrunk by AA size)
+ Rect2 outer_rect_aa_colored = border_style_rect.grow_individual(aa_border_width_half[SIDE_LEFT], aa_border_width_half[SIDE_TOP],
+ aa_border_width_half[SIDE_RIGHT], aa_border_width_half[SIDE_BOTTOM]);
+
+ // Create border ring, not antialiased yet
draw_ring(verts, indices, colors, border_style_rect, adapted_corner,
- border_style_rect_aa, ((blend_on) ? infill_rect : infill_rect_aa), border_color_inner, border_color, corner_detail, skew);
-
+ outer_rect_aa_colored, ((blend_on) ? infill_rect : inner_rect_aa_colored), border_color_inner, border_color, corner_detail, skew);
if (!blend_on) {
- // Create inner border fake AA gradient.
+ // Add antialiasing on the ring inner border
draw_ring(verts, indices, colors, border_style_rect, adapted_corner,
- infill_rect_aa, infill_rect, border_color_blend, border_color, corner_detail, skew);
+ inner_rect_aa_colored, inner_rect_aa_transparent, border_color_blend, border_color, corner_detail, skew);
}
-
- // Create outer border fake AA gradient.
+ // Add antialiasing on the ring outer border
draw_ring(verts, indices, colors, border_style_rect, adapted_corner,
- style_rect_aa, border_style_rect_aa, border_color, border_color_alpha, corner_detail, skew);
+ outer_rect_aa_transparent, outer_rect_aa_colored, border_color, border_color_alpha, corner_detail, skew);
}
}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index 17acfd773e..9d96e9a3b7 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -163,7 +163,7 @@ class StyleBoxFlat : public StyleBox {
int corner_detail = 8;
int shadow_size = 0;
Point2 shadow_offset;
- real_t aa_size = 0.625;
+ real_t aa_size = 1;
protected:
virtual float get_style_margin(Side p_side) const override;
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 3a6d40d22c..e46b643cd1 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -2183,11 +2183,17 @@ void VisualShader::_update_shader() const {
const String temp = String(info.name);
if (!info.options.is_empty()) {
+ if (!render_mode.is_empty()) {
+ render_mode += ", ";
+ }
+ // Always write out a render_mode for the enumerated modes as having no render mode is not always
+ // the same as the default. i.e. for depth_draw_opaque, the render mode has to be declared for it
+ // to work properly, no render mode is an invalid option.
if (modes.has(temp) && modes[temp] < info.options.size()) {
- if (!render_mode.is_empty()) {
- render_mode += ", ";
- }
render_mode += temp + "_" + info.options[modes[temp]];
+ } else {
+ // Use the default.
+ render_mode += temp + "_" + info.options[0];
}
} else if (flags.has(temp)) {
flag_names.push_back(temp);