From aa5b6c7d85bafef417938e56dd7a04ef0d1b81e7 Mon Sep 17 00:00:00 2001 From: Mounir Tohami <53877170+WhalesState@users.noreply.github.com> Date: Thu, 19 Dec 2024 02:45:15 +0200 Subject: [PATCH] Add method `set_margin_all` to MarginContainer --- scene/gui/margin_container.cpp | 11 +++++++++++ scene/gui/margin_container.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp index a47b131708e8..0fe15c45ad8f 100644 --- a/scene/gui/margin_container.cpp +++ b/scene/gui/margin_container.cpp @@ -91,6 +91,15 @@ int MarginContainer::get_margin_size(Side p_side) const { return 0; } +void MarginContainer::set_margin_all(int p_margin) { + begin_bulk_theme_override(); + add_theme_constant_override("margin_top", p_margin); + add_theme_constant_override("margin_right", p_margin); + add_theme_constant_override("margin_bottom", p_margin); + add_theme_constant_override("margin_left", p_margin); + end_bulk_theme_override(); +} + void MarginContainer::_notification(int p_what) { switch (p_what) { case NOTIFICATION_SORT_CHILDREN: { @@ -115,6 +124,8 @@ void MarginContainer::_notification(int p_what) { } void MarginContainer::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_margin_all", "margin"), &MarginContainer::set_margin_all); + BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, MarginContainer, margin_left); BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, MarginContainer, margin_top); BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, MarginContainer, margin_right); diff --git a/scene/gui/margin_container.h b/scene/gui/margin_container.h index d57ab9b4529a..2c098f247305 100644 --- a/scene/gui/margin_container.h +++ b/scene/gui/margin_container.h @@ -55,6 +55,8 @@ class MarginContainer : public Container { int get_margin_size(Side p_side) const; + void set_margin_all(int p_margin); + MarginContainer(); };