diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 740dd360ae2..0675cf2c757 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5388,12 +5388,12 @@ EditorNode::EditorNode() { save_confirmation->connect("confirmed", this, "_menu_confirm_current"); save_confirmation->connect("custom_action", this, "_discard_changes"); - file_templates = memnew(FileDialog); + file_templates = memnew(EditorFileDialog); file_templates->set_title(TTR("Import Templates From ZIP File")); gui_base->add_child(file_templates); - file_templates->set_mode(FileDialog::MODE_OPEN_FILE); - file_templates->set_access(FileDialog::ACCESS_FILESYSTEM); + file_templates->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_templates->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_templates->clear_filters(); file_templates->add_filter("*.tpz ; Template Package"); @@ -5401,15 +5401,15 @@ EditorNode::EditorNode() { gui_base->add_child(file); file->set_current_dir("res://"); - file_export = memnew(FileDialog); - file_export->set_access(FileDialog::ACCESS_FILESYSTEM); + file_export = memnew(EditorFileDialog); + file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); gui_base->add_child(file_export); file_export->set_title(TTR("Export Project")); file_export->connect("file_selected", this, "_dialog_action"); - file_export_lib = memnew(FileDialog); + file_export_lib = memnew(EditorFileDialog); file_export_lib->set_title(TTR("Export Library")); - file_export_lib->set_mode(FileDialog::MODE_SAVE_FILE); + file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_export_lib->connect("file_selected", this, "_dialog_action"); file_export_lib_merge = memnew(CheckButton); file_export_lib_merge->set_text(TTR("Merge With Existing")); @@ -5422,10 +5422,10 @@ EditorNode::EditorNode() { file_export_password->set_editable(false); file_export->get_vbox()->add_margin_child(TTR("Password:"), file_export_password); - file_script = memnew(FileDialog); + file_script = memnew(EditorFileDialog); file_script->set_title(TTR("Open & Run a Script")); - file_script->set_access(FileDialog::ACCESS_FILESYSTEM); - file_script->set_mode(FileDialog::MODE_OPEN_FILE); + file_script->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_script->set_mode(EditorFileDialog::MODE_OPEN_FILE); List sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); for (List::Element *E = sexts.front(); E; E = E->next()) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 6e0117a4ac9..7d0649cef3e 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -294,10 +294,10 @@ private: ProjectSettingsEditor *project_settings; EditorFileDialog *file; ExportTemplateManager *export_template_manager; - FileDialog *file_templates; - FileDialog *file_export; - FileDialog *file_export_lib; - FileDialog *file_script; + EditorFileDialog *file_templates; + EditorFileDialog *file_export; + EditorFileDialog *file_export_lib; + EditorFileDialog *file_script; CheckButton *file_export_lib_merge; LineEdit *file_export_password; String current_path; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index de0c3f55ccf..ffa978e1948 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -568,6 +568,11 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton + theme->set_stylebox("normal", "CheckButton", style_menu); + theme->set_stylebox("pressed", "CheckButton", style_menu); + theme->set_stylebox("disabled", "CheckButton", style_menu); + theme->set_stylebox("hover", "CheckButton", style_menu); + theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons")); theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons")); diff --git a/editor/icons/icon_GUI_toggle_off.svg b/editor/icons/icon_GUI_toggle_off.svg index 0d43b158b5b..aea0f85f969 100644 --- a/editor/icons/icon_GUI_toggle_off.svg +++ b/editor/icons/icon_GUI_toggle_off.svg @@ -1,5 +1,5 @@ - - - + + + diff --git a/editor/icons/icon_GUI_toggle_on.svg b/editor/icons/icon_GUI_toggle_on.svg index fd2b915fc35..c0a11810d44 100644 --- a/editor/icons/icon_GUI_toggle_on.svg +++ b/editor/icons/icon_GUI_toggle_on.svg @@ -1,5 +1,5 @@ - - - + + + diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index c19b80e6493..0f1712c224b 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -703,9 +703,7 @@ ScriptCreateDialog::ScriptCreateDialog() { internal = memnew(CheckButton); internal->connect("pressed", this, "_built_in_pressed"); hb = memnew(HBoxContainer); - Control *empty = memnew(Control); hb->add_child(internal); - hb->add_child(empty); l = memnew(Label); l->set_text(TTR("Built-in Script")); l->set_align(Label::ALIGN_RIGHT); diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index e68159e27fc..77fdedd5e5e 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 af3b80fe041..eb68943fe78 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: