summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPoommetee Ketson <poommetee@protonmail.com>2017-11-11 13:23:53 +0700
committerGitHub <noreply@github.com>2017-11-11 13:23:53 +0700
commit11b2aa2729b5d8b2c03ed0d1f2d3b58f6d90d777 (patch)
tree44fa1bae0102aad913817113b2304d9f273cd74c
parent19b1ff0fc5f7acce23176ad6c8752604357472f0 (diff)
parent8cf0d6ceb4f0c6c102a3166e8feb1589dd1030a9 (diff)
Merge pull request #12827 from djrm/pr_fixes
Some fixes and improvements.
-rw-r--r--editor/editor_node.cpp20
-rw-r--r--editor/editor_node.h8
-rw-r--r--editor/editor_themes.cpp5
-rw-r--r--editor/icons/icon_GUI_toggle_off.svg6
-rw-r--r--editor/icons/icon_GUI_toggle_on.svg6
-rw-r--r--editor/script_create_dialog.cpp2
-rw-r--r--scene/gui/check_button.cpp23
-rw-r--r--scene/gui/check_button.h1
8 files changed, 47 insertions, 24 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 740dd360ae..0675cf2c75 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<String> sexts;
ResourceLoader::get_recognized_extensions_for_type("Script", &sexts);
for (List<String>::Element *E = sexts.front(); E; E = E->next()) {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 6e0117a4ac..7d0649cef3 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 de0c3f55cc..ffa978e194 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -568,6 +568,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> 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 0d43b158b5..aea0f85f96 100644
--- a/editor/icons/icon_GUI_toggle_off.svg
+++ b/editor/icons/icon_GUI_toggle_off.svg
@@ -1,5 +1,5 @@
-<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg">
-<g transform="translate(0 -1020.4)">
-<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996v0.003906c0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12v-0.003906c0-6.6307-5.3693-11.996-12-11.996h-16zm0 2h16c5.5573 0 10 4.4388 10 9.9961v0.003906c0 5.5573-4.4427 10-10 10h-16c-5.5573 0-10-4.4427-10-10v-0.003906c0-5.5573 4.4427-9.9961 10-9.9961zm7 4.9961a1.0001 1.0001 0 0 0 -1 1v8a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm9 0a1.0001 1.0001 0 0 0 -1 1v4 4a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm-17 0.003906c-2.7496 0-5 2.2504-5 5s2.2504 5 5 5 5-2.2504 5-5-2.2504-5-5-5zm0 2c1.6687 0 3 1.3313 3 3s-1.3313 3-3 3-3-1.3313-3-3 1.3313-3 3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="filter-blend-mode:normal;filter-gaussianBlur-deviation:0;font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
+<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1026.4)">
+<path d="m13 1027.4c-6.6307 0-12 5.3663-12 11.998 0 6.6318 5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002 0-6.6317-5.3693-11.998-12-11.998zm0 2.0003h16c5.5573 0 10 4.4395 10 9.9977 0 5.5583-4.4427 10.002-10 10.002h-16c-5.5573 0-10-4.4434-10-10.002 0-5.5582 4.4427-9.9977 10-9.9977zm7 4.9969a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm9 0a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm-17 0c-2.7496 0-5 2.2508-5 5.0008 0 2.7501 2.2504 5.0009 5 5.0009s5-2.2508 5-5.0009c0-2.75-2.2504-5.0008-5-5.0008zm0 2.0004c1.6687 0 3 1.3315 3 3.0004 0 1.669-1.3313 3.0005-3 3.0005s-3-1.3315-3-3.0005c0-1.6689 1.3313-3.0004 3-3.0004z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
</g>
</svg>
diff --git a/editor/icons/icon_GUI_toggle_on.svg b/editor/icons/icon_GUI_toggle_on.svg
index fd2b915fc3..c0a11810d4 100644
--- a/editor/icons/icon_GUI_toggle_on.svg
+++ b/editor/icons/icon_GUI_toggle_on.svg
@@ -1,5 +1,5 @@
-<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg">
-<g transform="translate(0 -1020.4)">
-<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996 0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12 0-6.6307-5.3693-11.996-12-11.996h-16zm17 6.9961a1 1 0 0 1 1 1v8a1.0001 1.0001 0 0 1 -1.752 0.66211l-5.248-6v5.3379a1 1 0 0 1 -1 1 1 1 0 0 1 -1 -1v-8a1.0001 1.0001 0 0 1 1.752 -0.6582l5.248 6v-5.3418a1 1 0 0 1 1 -1zm-15 0.003906c2.7496 0 5 2.2504 5 5s-2.2504 5-5 5-5-2.2504-5-5 2.2504-5 5-5zm0 2c-1.6687 0-3 1.3313-3 3s1.3313 3 3 3 3-1.3313 3-3-1.3313-3-3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
+<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg">
+<g transform="translate(0 -1026.4)">
+<path d="m13 1027.4c-6.6307 0-12 5.3662-12 11.998s5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002s-5.3693-11.998-12-11.998zm17 6.9972a1 1.0002 0 0 1 1 1.0001v8.0014a1.0001 1.0003 0 0 1 -1.752 0.6623l-5.248-6.001v5.3387a1 1.0002 0 0 1 -1 1.0001 1 1.0002 0 0 1 -1 -1.0001v-8.0014a1.0001 1.0003 0 0 1 1.752 -0.6583l5.248 6.001v-5.3427a1 1.0002 0 0 1 1 -1.0001zm-15 0c2.7496 0 5 2.2507 5 5.0008s-2.2504 5.0008-5 5.0008-5-2.2507-5-5.0008 2.2504-5.0008 5-5.0008zm0 2.0003c-1.6687 0-3 1.3315-3 3.0005s1.3313 3.0005 3 3.0005 3-1.3315 3-3.0005-1.3313-3.0005-3-3.0005z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
</g>
</svg>
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index c19b80e649..0f1712c224 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 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<Texture> on = Control::get_icon("on");
+ Ref<Texture> 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<Texture> on = Control::get_icon("on");
Ref<Texture> off = Control::get_icon("off");
+ Ref<StyleBox> 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: