summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/parallax_layer.cpp6
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/scroll_bar.cpp9
-rw-r--r--scene/gui/text_edit.cpp16
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/gui/texture_progress.cpp257
-rw-r--r--scene/gui/texture_progress.h9
-rw-r--r--scene/main/scene_tree.cpp2
-rw-r--r--scene/resources/style_box.cpp38
-rw-r--r--scene/resources/style_box.h4
10 files changed, 271 insertions, 73 deletions
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index a5a59252a9..debdc22b65 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -36,6 +36,9 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
motion_scale = p_scale;
+ if (!get_parent())
+ return;
+
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
if (is_inside_tree() && pb) {
Vector2 ofs = pb->get_final_offset();
@@ -53,6 +56,9 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
motion_offset = p_offset;
+ if (!get_parent())
+ return;
+
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
if (is_inside_tree() && pb) {
Vector2 ofs = pb->get_final_offset();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 6a3ef66e0a..36fc9a6b3a 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1839,8 +1839,6 @@ Control *Control::find_prev_valid_focus() const {
}
return NULL;
-
- return NULL;
}
Control::FocusMode Control::get_focus_mode() const {
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 6519cde6d3..4242ee4523 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -40,6 +40,11 @@ void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
+ Ref<InputEventMouseMotion> m = p_event;
+ if (!m.is_valid() || drag.active) {
+ emit_signal("scrolling");
+ }
+
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {
@@ -143,8 +148,6 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
}
}
- Ref<InputEventMouseMotion> m = p_event;
-
if (m.is_valid()) {
accept_event();
@@ -823,6 +826,8 @@ void ScrollBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("_drag_slave_input"), &ScrollBar::_drag_slave_input);
ClassDB::bind_method(D_METHOD("_drag_slave_exit"), &ScrollBar::_drag_slave_exit);
+ ADD_SIGNAL(MethodInfo("scrolling"));
+
ADD_PROPERTY(PropertyInfo(Variant::REAL, "custom_step", PROPERTY_HINT_RANGE, "-1,4096"), "set_custom_step", "get_custom_step");
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index f15fb71f87..245e7e04be 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2880,6 +2880,8 @@ void TextEdit::_post_shift_selection() {
}
void TextEdit::_scroll_lines_up() {
+ scrolling = false;
+
// adjust the vertical scroll
if (get_v_scroll() > 0) {
set_v_scroll(get_v_scroll() - 1);
@@ -2892,6 +2894,8 @@ void TextEdit::_scroll_lines_up() {
}
void TextEdit::_scroll_lines_down() {
+ scrolling = false;
+
// calculate the maximum vertical scroll position
int max_v_scroll = get_line_count() - 1;
if (!scroll_past_end_of_file_enabled) {
@@ -3156,6 +3160,7 @@ int TextEdit::get_visible_rows() const {
return total;
}
void TextEdit::adjust_viewport_to_cursor() {
+ scrolling = false;
if (cursor.line_ofs > cursor.line)
cursor.line_ofs = cursor.line;
@@ -3195,6 +3200,7 @@ void TextEdit::adjust_viewport_to_cursor() {
}
void TextEdit::center_viewport_to_cursor() {
+ scrolling = false;
if (cursor.line_ofs > cursor.line)
cursor.line_ofs = cursor.line;
@@ -3313,6 +3319,10 @@ bool TextEdit::cursor_is_block_mode() const {
return block_caret;
}
+void TextEdit::_v_scroll_input() {
+ scrolling = false;
+}
+
void TextEdit::_scroll_moved(double p_to_val) {
if (updating_scrolls)
@@ -3656,9 +3666,6 @@ void TextEdit::cut() {
void TextEdit::copy() {
- if (!selection.active)
- return;
-
if (!selection.active) {
String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
OS::get_singleton()->set_clipboard(clipboard);
@@ -4709,6 +4716,7 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("_push_current_op"), &TextEdit::_push_current_op);
ClassDB::bind_method(D_METHOD("_click_selection_held"), &TextEdit::_click_selection_held);
ClassDB::bind_method(D_METHOD("_toggle_draw_caret"), &TextEdit::_toggle_draw_caret);
+ ClassDB::bind_method(D_METHOD("_v_scroll_input"), &TextEdit::_v_scroll_input);
BIND_ENUM_CONSTANT(SEARCH_MATCH_CASE);
BIND_ENUM_CONSTANT(SEARCH_WHOLE_WORDS);
@@ -4846,6 +4854,8 @@ TextEdit::TextEdit() {
h_scroll->connect("value_changed", this, "_scroll_moved");
v_scroll->connect("value_changed", this, "_scroll_moved");
+ v_scroll->connect("scrolling", this, "_v_scroll_input");
+
cursor_changed_dirty = false;
text_changed_dirty = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 1abfe368dd..6321cad2da 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -299,6 +299,7 @@ class TextEdit : public Control {
void adjust_viewport_to_cursor();
void _scroll_moved(double);
void _update_scrollbars();
+ void _v_scroll_input();
void _click_selection_held();
void _pre_shift_selection();
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index 08025452d8..59cff84719 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -57,9 +57,33 @@ Ref<Texture> TextureProgress::get_over_texture() const {
return over;
}
+void TextureProgress::set_stretch_margin(Margin p_margin, int p_size) {
+ ERR_FAIL_INDEX(p_margin, 4);
+ stretch_margin[p_margin] = p_size;
+ update();
+ minimum_size_changed();
+}
+
+int TextureProgress::get_stretch_margin(Margin p_margin) const {
+ ERR_FAIL_INDEX_V(p_margin, 4, 0);
+ return stretch_margin[p_margin];
+}
+
+void TextureProgress::set_nine_patch_stretch(bool p_stretch) {
+ nine_patch_stretch = p_stretch;
+ update();
+ minimum_size_changed();
+}
+
+bool TextureProgress::get_nine_patch_stretch() const {
+ return nine_patch_stretch;
+}
+
Size2 TextureProgress::get_minimum_size() const {
- if (under.is_valid())
+ if (nine_patch_stretch)
+ return Size2(stretch_margin[MARGIN_LEFT] + stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_TOP] + stretch_margin[MARGIN_BOTTOM]);
+ else if (under.is_valid())
return under->get_size();
else if (over.is_valid())
return over->get_size();
@@ -122,80 +146,165 @@ Point2 TextureProgress::get_relative_center() {
return p;
}
+void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio) {
+ 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]);
+
+ Rect2 src_rect = Rect2(Point2(), texture_size);
+ Rect2 dst_rect = Rect2(Point2(), get_size());
+
+ if (p_ratio < 1.0) {
+ // Drawing a partially-filled 9-patch is a little tricky -
+ // texture is divided by 3 sections toward fill direction,
+ // then middle section is streching while the other two aren't.
+
+ double width_total = 0.0;
+ double width_texture = 0.0;
+ double first_section_size = 0.0;
+ double last_section_size = 0.0;
+ switch (mode) {
+ case FILL_LEFT_TO_RIGHT:
+ case FILL_RIGHT_TO_LEFT: {
+ width_total = dst_rect.size.x;
+ width_texture = texture_size.x;
+ first_section_size = topleft.x;
+ last_section_size = bottomright.x;
+ } break;
+ case FILL_TOP_TO_BOTTOM:
+ case FILL_BOTTOM_TO_TOP: {
+ width_total = dst_rect.size.y;
+ width_texture = texture_size.y;
+ first_section_size = topleft.y;
+ last_section_size = bottomright.y;
+ } break;
+ }
+
+ double width_filled = width_total * p_ratio;
+ double middle_section_size = MAX(0.0, width_texture - first_section_size - last_section_size);
+
+ middle_section_size *= MIN(1.0, (MAX(0.0, width_filled - first_section_size) / MAX(1.0, width_total - first_section_size - last_section_size)));
+ last_section_size = MAX(0.0, last_section_size - (width_total - width_filled));
+ width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
+
+ switch (mode) {
+ case FILL_LEFT_TO_RIGHT: {
+ src_rect.size.x = width_texture;
+ dst_rect.size.x = width_filled;
+ bottomright.x = last_section_size;
+ } break;
+ case FILL_RIGHT_TO_LEFT: {
+ src_rect.position.x += src_rect.size.x - width_texture;
+ src_rect.size.x = width_texture;
+ dst_rect.position.x += width_total - width_filled;
+ dst_rect.size.x = width_filled;
+ topleft.x = last_section_size;
+ } break;
+ case FILL_TOP_TO_BOTTOM: {
+ src_rect.size.y = width_texture;
+ dst_rect.size.y = width_filled;
+ bottomright.y = last_section_size;
+ } break;
+ case FILL_BOTTOM_TO_TOP: {
+ src_rect.position.y += src_rect.size.y - width_texture;
+ src_rect.size.y = width_texture;
+ dst_rect.position.y += width_total - width_filled;
+ dst_rect.size.y = width_filled;
+ topleft.y = last_section_size;
+ } break;
+ }
+ }
+
+ RID ci = get_canvas_item();
+ VS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright);
+}
+
void TextureProgress::_notification(int p_what) {
const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 };
switch (p_what) {
case NOTIFICATION_DRAW: {
- if (under.is_valid())
- draw_texture(under, Point2());
- if (progress.is_valid()) {
- Size2 s = progress->get_size();
- switch (mode) {
- case FILL_LEFT_TO_RIGHT: {
- Rect2 region = Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y));
- draw_texture_rect_region(progress, region, region);
- } break;
- case FILL_RIGHT_TO_LEFT: {
- Rect2 region = Rect2(Point2(s.x - s.x * get_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y));
- draw_texture_rect_region(progress, region, region);
- } break;
- case FILL_TOP_TO_BOTTOM: {
- Rect2 region = Rect2(Point2(), Size2(s.x, s.y * get_as_ratio()));
- draw_texture_rect_region(progress, region, region);
- } break;
- case FILL_BOTTOM_TO_TOP: {
- Rect2 region = Rect2(Point2(0, s.y - s.y * get_as_ratio()), Size2(s.x, s.y * get_as_ratio()));
- draw_texture_rect_region(progress, region, region);
- } break;
- case FILL_CLOCKWISE:
- case FILL_COUNTER_CLOCKWISE: {
- float val = get_as_ratio() * rad_max_degrees / 360;
- if (val == 1) {
- Rect2 region = Rect2(Point2(), s);
+ if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP)) {
+ if (under.is_valid()) {
+ draw_nine_patch_stretched(under, FILL_LEFT_TO_RIGHT, 1.0);
+ }
+ if (progress.is_valid()) {
+ draw_nine_patch_stretched(progress, mode, get_as_ratio());
+ }
+ if (over.is_valid()) {
+ draw_nine_patch_stretched(over, FILL_LEFT_TO_RIGHT, 1.0);
+ }
+ } else {
+ if (under.is_valid())
+ draw_texture(under, Point2());
+ if (progress.is_valid()) {
+ Size2 s = progress->get_size();
+ switch (mode) {
+ case FILL_LEFT_TO_RIGHT: {
+ Rect2 region = Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y));
+ draw_texture_rect_region(progress, region, region);
+ } break;
+ case FILL_RIGHT_TO_LEFT: {
+ Rect2 region = Rect2(Point2(s.x - s.x * get_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y));
draw_texture_rect_region(progress, region, region);
- } else if (val != 0) {
- Array pts;
- float direction = mode == FILL_CLOCKWISE ? 1 : -1;
- float start = rad_init_angle / 360;
- float end = start + direction * val;
- pts.append(start);
- pts.append(end);
- float from = MIN(start, end);
- float to = MAX(start, end);
- for (int i = 0; i < 12; i++)
- if (corners[i] > from && corners[i] < to)
- pts.append(corners[i]);
- pts.sort();
- Vector<Point2> uvs;
- Vector<Point2> points;
- uvs.push_back(get_relative_center());
- points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
- for (int i = 0; i < pts.size(); i++) {
- Point2 uv = unit_val_to_uv(pts[i]);
- if (uvs.find(uv) >= 0)
- continue;
- uvs.push_back(uv);
- points.push_back(Point2(uv.x * s.x, uv.y * s.y));
+ } break;
+ case FILL_TOP_TO_BOTTOM: {
+ Rect2 region = Rect2(Point2(), Size2(s.x, s.y * get_as_ratio()));
+ draw_texture_rect_region(progress, region, region);
+ } break;
+ case FILL_BOTTOM_TO_TOP: {
+ Rect2 region = Rect2(Point2(0, s.y - s.y * get_as_ratio()), Size2(s.x, s.y * get_as_ratio()));
+ draw_texture_rect_region(progress, region, region);
+ } break;
+ case FILL_CLOCKWISE:
+ case FILL_COUNTER_CLOCKWISE: {
+ float val = get_as_ratio() * rad_max_degrees / 360;
+ if (val == 1) {
+ Rect2 region = Rect2(Point2(), s);
+ draw_texture_rect_region(progress, region, region);
+ } else if (val != 0) {
+ Array pts;
+ float direction = mode == FILL_CLOCKWISE ? 1 : -1;
+ float start = rad_init_angle / 360;
+ float end = start + direction * val;
+ pts.append(start);
+ pts.append(end);
+ float from = MIN(start, end);
+ float to = MAX(start, end);
+ for (int i = 0; i < 12; i++)
+ if (corners[i] > from && corners[i] < to)
+ pts.append(corners[i]);
+ pts.sort();
+ Vector<Point2> uvs;
+ Vector<Point2> points;
+ uvs.push_back(get_relative_center());
+ points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
+ for (int i = 0; i < pts.size(); i++) {
+ Point2 uv = unit_val_to_uv(pts[i]);
+ if (uvs.find(uv) >= 0)
+ continue;
+ uvs.push_back(uv);
+ points.push_back(Point2(uv.x * s.x, uv.y * s.y));
+ }
+ draw_polygon(points, Vector<Color>(), uvs, progress);
+ }
+ if (Engine::get_singleton()->is_editor_hint()) {
+ Point2 p = progress->get_size();
+ p.x *= get_relative_center().x;
+ p.y *= get_relative_center().y;
+ p = p.floor();
+ draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
+ draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
}
- draw_polygon(points, Vector<Color>(), uvs, progress);
- }
- if (Engine::get_singleton()->is_editor_hint()) {
- Point2 p = progress->get_size();
- p.x *= get_relative_center().x;
- p.y *= get_relative_center().y;
- p = p.floor();
- draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
- draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
- }
- } break;
- default:
- draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)));
+ } break;
+ default:
+ draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)));
+ }
}
+ if (over.is_valid())
+ draw_texture(over, Point2());
}
- if (over.is_valid())
- draw_texture(over, Point2());
} break;
}
@@ -265,6 +374,12 @@ void TextureProgress::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_fill_degrees", "mode"), &TextureProgress::set_fill_degrees);
ClassDB::bind_method(D_METHOD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
+ ClassDB::bind_method(D_METHOD("set_stretch_margin", "margin", "value"), &TextureProgress::set_stretch_margin);
+ ClassDB::bind_method(D_METHOD("get_stretch_margin", "margin"), &TextureProgress::get_stretch_margin);
+
+ ClassDB::bind_method(D_METHOD("set_nine_patch_stretch", "stretch"), &TextureProgress::set_nine_patch_stretch);
+ ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgress::get_nine_patch_stretch);
+
ADD_GROUP("Textures", "texture_");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_under_texture", "get_under_texture");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_over_texture", "get_over_texture");
@@ -274,6 +389,12 @@ void TextureProgress::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_initial_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_radial_initial_angle", "get_radial_initial_angle");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_fill_degrees", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), "set_fill_degrees", "get_fill_degrees");
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_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_LEFT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_RIGHT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "stretch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1"), "set_stretch_margin", "get_stretch_margin", MARGIN_BOTTOM);
BIND_ENUM_CONSTANT(FILL_LEFT_TO_RIGHT);
BIND_ENUM_CONSTANT(FILL_RIGHT_TO_LEFT);
@@ -289,4 +410,10 @@ TextureProgress::TextureProgress() {
rad_center_off = Point2();
rad_max_degrees = 360;
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;
}
diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h
index 3c018febf3..20546bd11f 100644
--- a/scene/gui/texture_progress.h
+++ b/scene/gui/texture_progress.h
@@ -75,6 +75,12 @@ public:
void set_over_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_over_texture() const;
+ void set_stretch_margin(Margin p_margin, int p_size);
+ int get_stretch_margin(Margin p_margin) const;
+
+ void set_nine_patch_stretch(bool p_stretch);
+ bool get_nine_patch_stretch() const;
+
Size2 get_minimum_size() const;
TextureProgress();
@@ -84,9 +90,12 @@ private:
float rad_init_angle;
float rad_max_degrees;
Point2 rad_center_off;
+ bool nine_patch_stretch;
+ int stretch_margin[4];
Point2 unit_val_to_uv(float val);
Point2 get_relative_center();
+ void draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio);
};
VARIANT_ENUM_CAST(TextureProgress::FillMode);
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 00460e9eda..10ab28150b 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -630,7 +630,7 @@ void SceneTree::_notification(int p_notification) {
case NOTIFICATION_WM_ABOUT: {
#ifdef TOOLS_ENABLED
- if (Engine::get_singleton()->is_editor_hint()) {
+ if (EditorNode::get_singleton()) {
EditorNode::get_singleton()->show_about();
} else {
#endif
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 9309cef89f..7b2a9ffbc2 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -191,6 +191,22 @@ void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin, float p_siz
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;
+ emit_changed();
+}
+
+void StyleBoxTexture::set_expand_margin_size_all(float p_expand_margin_size) {
+ for (int i = 0; i < 4; i++) {
+
+ expand_margin[i] = p_expand_margin_size;
+ }
+ emit_changed();
+}
+
float StyleBoxTexture::get_expand_margin_size(Margin p_expand_margin) const {
ERR_FAIL_INDEX_V(p_expand_margin, 4, 0);
@@ -257,6 +273,8 @@ void StyleBoxTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_margin_size", "margin"), &StyleBoxTexture::get_margin_size);
ClassDB::bind_method(D_METHOD("set_expand_margin_size", "margin", "size"), &StyleBoxTexture::set_expand_margin_size);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_all", "size"), &StyleBoxTexture::set_expand_margin_size_all);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_individual", "size_left", "size_top", "size_right", "size_bottom"), &StyleBoxTexture::set_expand_margin_size_individual);
ClassDB::bind_method(D_METHOD("get_expand_margin_size", "margin"), &StyleBoxTexture::get_expand_margin_size);
ClassDB::bind_method(D_METHOD("set_region_rect", "region"), &StyleBoxTexture::set_region_rect);
@@ -421,7 +439,25 @@ void StyleBoxFlat::set_expand_margin_size(Margin p_expand_margin, float p_size)
expand_margin[p_expand_margin] = 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;
+ emit_changed();
+}
+
+void StyleBoxFlat::set_expand_margin_size_all(float p_expand_margin_size) {
+ for (int i = 0; i < 4; i++) {
+
+ expand_margin[i] = p_expand_margin_size;
+ }
+ emit_changed();
+}
+
float StyleBoxFlat::get_expand_margin_size(Margin p_expand_margin) const {
+
return expand_margin[p_expand_margin];
}
void StyleBoxFlat::set_filled(bool p_filled) {
@@ -736,6 +772,8 @@ void StyleBoxFlat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_corner_radius", "corner"), &StyleBoxFlat::get_corner_radius);
ClassDB::bind_method(D_METHOD("set_expand_margin", "margin", "size"), &StyleBoxFlat::set_expand_margin_size);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_all", "size"), &StyleBoxFlat::set_expand_margin_size_all);
+ ClassDB::bind_method(D_METHOD("set_expand_margin_individual", "size_left", "size_top", "size_right", "size_bottom"), &StyleBoxFlat::set_expand_margin_size_individual);
ClassDB::bind_method(D_METHOD("get_expand_margin", "margin"), &StyleBoxFlat::get_expand_margin_size);
ClassDB::bind_method(D_METHOD("set_filled", "filled"), &StyleBoxFlat::set_filled);
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index a750fae753..30eb9543e8 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -101,6 +101,8 @@ protected:
public:
void set_expand_margin_size(Margin p_expand_margin, 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;
void set_margin_size(Margin p_margin, float p_size);
@@ -196,6 +198,8 @@ public:
//EXPANDS
void set_expand_margin_size(Margin p_expand_margin, 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;
//FILLED