Merge pull request #28548 from YeldhamDev/check_button_disabled_icon
Add "disabled" icon for 'CheckButton'
This commit is contained in:
commit
7b64a24eb3
8 changed files with 30 additions and 17 deletions
|
@ -585,7 +585,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
|
|||
theme->set_stylebox("hover", "CheckButton", style_menu);
|
||||
|
||||
theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons"));
|
||||
theme->set_icon("on_disabled", "CheckButton", theme->get_icon("GuiToggleOnDisabled", "EditorIcons"));
|
||||
theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons"));
|
||||
theme->set_icon("off_disabled", "CheckButton", theme->get_icon("GuiToggleOffDisabled", "EditorIcons"));
|
||||
|
||||
theme->set_color("font_color", "CheckButton", font_color);
|
||||
theme->set_color("font_color_hover", "CheckButton", font_color_hl);
|
||||
|
|
|
@ -567,23 +567,22 @@ void ScriptCreateDialog::_update_dialog() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!_can_be_built_in())
|
||||
internal->set_pressed(false);
|
||||
|
||||
/* Is Script created or loaded from existing file */
|
||||
|
||||
if (is_built_in) {
|
||||
get_ok()->set_text(TTR("Create"));
|
||||
parent_name->set_editable(true);
|
||||
parent_browse_button->set_disabled(false);
|
||||
internal->set_disabled(!_can_be_built_in());
|
||||
internal->set_visible(_can_be_built_in());
|
||||
internal_label->set_visible(_can_be_built_in());
|
||||
_msg_path_valid(true, TTR("Built-in script (into scene file)."));
|
||||
} else if (is_new_script_created) {
|
||||
// New Script Created
|
||||
get_ok()->set_text(TTR("Create"));
|
||||
parent_name->set_editable(true);
|
||||
parent_browse_button->set_disabled(false);
|
||||
internal->set_disabled(!_can_be_built_in());
|
||||
internal->set_visible(_can_be_built_in());
|
||||
internal_label->set_visible(_can_be_built_in());
|
||||
if (is_path_valid) {
|
||||
_msg_path_valid(true, TTR("Will create a new script file."));
|
||||
}
|
||||
|
@ -753,13 +752,13 @@ ScriptCreateDialog::ScriptCreateDialog() {
|
|||
/* Built-in Script */
|
||||
|
||||
internal = memnew(CheckButton);
|
||||
internal->set_h_size_flags(0);
|
||||
internal->connect("pressed", this, "_built_in_pressed");
|
||||
hb = memnew(HBoxContainer);
|
||||
hb->add_child(internal);
|
||||
l = memnew(Label(TTR("Built-in Script")));
|
||||
l->set_align(Label::ALIGN_RIGHT);
|
||||
gc->add_child(l);
|
||||
gc->add_child(hb);
|
||||
internal_label = memnew(Label(TTR("Built-in Script")));
|
||||
internal_label->set_text(TTR("Built-in Script"));
|
||||
internal_label->set_align(Label::ALIGN_RIGHT);
|
||||
gc->add_child(internal_label);
|
||||
gc->add_child(internal);
|
||||
|
||||
/* Path */
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
|
|||
Button *path_button;
|
||||
EditorFileDialog *file_browse;
|
||||
CheckButton *internal;
|
||||
Label *internal_label;
|
||||
VBoxContainer *path_vb;
|
||||
AcceptDialog *alert;
|
||||
CreateDialog *select_class;
|
||||
|
|
|
@ -34,13 +34,15 @@
|
|||
#include "servers/visual_server.h"
|
||||
|
||||
Size2 CheckButton::get_icon_size() const {
|
||||
Ref<Texture> on = Control::get_icon("on");
|
||||
Ref<Texture> off = Control::get_icon("off");
|
||||
|
||||
Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on");
|
||||
Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "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()));
|
||||
|
||||
return tex_size;
|
||||
}
|
||||
|
||||
|
@ -49,9 +51,8 @@ Size2 CheckButton::get_minimum_size() const {
|
|||
Size2 minsize = Button::get_minimum_size();
|
||||
Size2 tex_size = get_icon_size();
|
||||
minsize.width += tex_size.width;
|
||||
if (get_text().length() > 0) {
|
||||
if (get_text().length() > 0)
|
||||
minsize.width += get_constant("hseparation");
|
||||
}
|
||||
Ref<StyleBox> sb = get_stylebox("normal");
|
||||
minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM));
|
||||
|
||||
|
@ -67,8 +68,8 @@ void CheckButton::_notification(int p_what) {
|
|||
|
||||
RID ci = get_canvas_item();
|
||||
|
||||
Ref<Texture> on = Control::get_icon("on");
|
||||
Ref<Texture> off = Control::get_icon("off");
|
||||
Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on");
|
||||
Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "off");
|
||||
|
||||
Ref<StyleBox> sb = get_stylebox("normal");
|
||||
Vector2 ofs;
|
||||
|
|
|
@ -359,7 +359,9 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
|
|||
theme->set_stylebox("focus", "CheckButton", focus);
|
||||
|
||||
theme->set_icon("on", "CheckButton", make_icon(toggle_on_png));
|
||||
theme->set_icon("on_disabled", "CheckButton", make_icon(toggle_on_disabled_png));
|
||||
theme->set_icon("off", "CheckButton", make_icon(toggle_off_png));
|
||||
theme->set_icon("off_disabled", "CheckButton", make_icon(toggle_off_disabled_png));
|
||||
|
||||
theme->set_font("font", "CheckButton", default_font);
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
BIN
scene/resources/default_theme/toggle_off_disabled.png
Normal file
BIN
scene/resources/default_theme/toggle_off_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
scene/resources/default_theme/toggle_on_disabled.png
Normal file
BIN
scene/resources/default_theme/toggle_on_disabled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in a new issue