summaryrefslogtreecommitdiff
path: root/scene/gui/check_button.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/check_button.cpp')
-rw-r--r--scene/gui/check_button.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp
index 790faeb4fd..e58f56a99b 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -61,19 +61,40 @@ Size2 CheckButton::get_minimum_size() const {
}
void CheckButton::_notification(int p_what) {
- if (p_what == NOTIFICATION_THEME_CHANGED) {
- _set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
+ if ((p_what == NOTIFICATION_THEME_CHANGED) || (p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED) || (p_what == NOTIFICATION_TRANSLATION_CHANGED)) {
+ if (is_layout_rtl()) {
+ _set_internal_margin(MARGIN_LEFT, get_icon_size().width);
+ _set_internal_margin(MARGIN_RIGHT, 0.f);
+ } else {
+ _set_internal_margin(MARGIN_LEFT, 0.f);
+ _set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
+ }
} else if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
+ bool rtl = is_layout_rtl();
- Ref<Texture2D> on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on");
- Ref<Texture2D> off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off");
+ Ref<Texture2D> on;
+ if (rtl) {
+ on = Control::get_theme_icon(is_disabled() ? "on_disabled_mirrored" : "on_mirrored");
+ } else {
+ on = Control::get_theme_icon(is_disabled() ? "on_disabled" : "on");
+ }
+ Ref<Texture2D> off;
+ if (rtl) {
+ off = Control::get_theme_icon(is_disabled() ? "off_disabled_mirrored" : "off_mirrored");
+ } else {
+ off = Control::get_theme_icon(is_disabled() ? "off_disabled" : "off");
+ }
Ref<StyleBox> sb = get_theme_stylebox("normal");
Vector2 ofs;
Size2 tex_size = get_icon_size();
- ofs.x = get_size().width - (tex_size.width + sb->get_margin(MARGIN_RIGHT));
+ if (rtl) {
+ ofs.x = sb->get_margin(MARGIN_LEFT);
+ } else {
+ ofs.x = get_size().width - (tex_size.width + sb->get_margin(MARGIN_RIGHT));
+ }
ofs.y = (get_size().height - tex_size.height) / 2 + get_theme_constant("check_vadjust");
if (is_pressed()) {
@@ -87,8 +108,11 @@ void CheckButton::_notification(int p_what) {
CheckButton::CheckButton() {
set_toggle_mode(true);
set_text_align(ALIGN_LEFT);
-
- _set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
+ if (is_layout_rtl()) {
+ _set_internal_margin(MARGIN_LEFT, get_icon_size().width);
+ } else {
+ _set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
+ }
}
CheckButton::~CheckButton() {