summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-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/style_box.cpp188
-rw-r--r--scene/resources/style_box.h32
5 files changed, 210 insertions, 207 deletions
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/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: