From 8cf0d6ceb4f0c6c102a3166e8feb1589dd1030a9 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Fri, 10 Nov 2017 16:45:08 -0600 Subject: Some fixes and improvements. Changed FileDialogs for EditorFileDialogs in EditorNode. Updated CheckButton. --- scene/gui/check_button.cpp | 23 +++++++++++++++++++++-- scene/gui/check_button.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'scene') diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index e68159e27f..77fdedd5e5 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -32,6 +32,23 @@ #include "print_string.h" #include "servers/visual_server.h" +Size2 CheckButton::get_minimum_size() const { + + Size2 minsize = Button::get_minimum_size(); + + Ref on = Control::get_icon("on"); + Ref off = Control::get_icon("off"); + Size2 tex_size = Size2(0, 0); + if (!on.is_null()) + tex_size = Size2(on->get_width(), on->get_height()); + if (!off.is_null()) + tex_size = Size2(MAX(tex_size.width, off->get_width()), MAX(tex_size.height, off->get_height())); + minsize += Size2(tex_size.width + get_constant("hseparation"), 0); + minsize.height = MAX(minsize.height, tex_size.height); + + return get_stylebox("normal")->get_minimum_size() + minsize; +} + void CheckButton::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { @@ -41,9 +58,11 @@ void CheckButton::_notification(int p_what) { Ref on = Control::get_icon("on"); Ref off = Control::get_icon("off"); + Ref sb = get_stylebox("normal"); + Size2 sb_ofs = Size2(sb->get_margin(MARGIN_RIGHT), sb->get_margin(MARGIN_TOP)); Vector2 ofs; - ofs.x = get_size().width - on->get_width(); - ofs.y = int((get_size().height - on->get_height()) / 2); + ofs.x = get_minimum_size().width - (on->get_width() + sb_ofs.width); + ofs.y = sb_ofs.height; if (is_pressed()) on->draw(ci, ofs); diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index af3b80fe04..eb68943fe7 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -39,6 +39,7 @@ class CheckButton : public Button { GDCLASS(CheckButton, Button); protected: + virtual Size2 get_minimum_size() const; void _notification(int p_what); public: -- cgit v1.2.3