diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index a30c05527cb..2912dcb3ae3 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2310,7 +2310,7 @@ void Control::_bind_methods() { BIND_CONSTANT( ANCHOR_BEGIN ); BIND_CONSTANT( ANCHOR_END ); BIND_CONSTANT( ANCHOR_RATIO ); - BIND_CONSTANT( ANCHOR_CENTER ); + BIND_CONSTANT( ANCHOR_CENTER ); BIND_CONSTANT( FOCUS_NONE ); BIND_CONSTANT( FOCUS_CLICK ); BIND_CONSTANT( FOCUS_ALL ); diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 74e59b09c3d..20405a57b2c 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -370,6 +370,13 @@ void Theme::get_stylebox_list(StringName p_type, List *p_list) const } +void Theme::get_stylebox_types(List *p_list) const { + const StringName *key=NULL; + while((key=style_map.next(key))) { + p_list->push_back(*key); + } +} + void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref& p_font) { ERR_FAIL_COND(p_font.is_null()); @@ -380,7 +387,6 @@ void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref if (new_value) { _change_notify(); emit_changed();; - } } Ref Theme::get_font(const StringName& p_name,const StringName& p_type) const { @@ -604,6 +610,7 @@ void Theme::_bind_methods() { ObjectTypeDB::bind_method(_MD("has_stylebox","name","type"),&Theme::has_stylebox); ObjectTypeDB::bind_method(_MD("clear_stylebox","name","type"),&Theme::clear_stylebox); ObjectTypeDB::bind_method(_MD("get_stylebox_list","type"),&Theme::_get_stylebox_list); + ObjectTypeDB::bind_method(_MD("get_stylebox_types"),&Theme::_get_stylebox_types); ObjectTypeDB::bind_method(_MD("set_font","name","type","font:Font"),&Theme::set_font); ObjectTypeDB::bind_method(_MD("get_font:Font","name","type"),&Theme::get_font); diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 36630087f69..9b84d0e8ad5 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -65,6 +65,7 @@ protected: DVector _get_icon_list(const String& p_type) const { DVector ilret; List il; get_icon_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } DVector _get_stylebox_list(const String& p_type) const { DVector ilret; List il; get_stylebox_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } + DVector _get_stylebox_types(void) const { DVector ilret; List il; get_stylebox_types(&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } DVector _get_font_list(const String& p_type) const { DVector ilret; List il; get_font_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } DVector _get_color_list(const String& p_type) const { DVector ilret; List il; get_color_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } DVector _get_constant_list(const String& p_type) const { DVector ilret; List il; get_constant_list(p_type,&il); for(List::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; } @@ -100,6 +101,7 @@ public: bool has_stylebox(const StringName& p_name,const StringName& p_type) const; void clear_stylebox(const StringName& p_name,const StringName& p_type); void get_stylebox_list(StringName p_type, List *p_list) const; + void get_stylebox_types(List *p_list) const; void set_font(const StringName& p_name,const StringName& p_type,const Ref& p_font); Ref get_font(const StringName& p_name,const StringName& p_type) const; diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 938b8344ba9..e792a2a9e24 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -398,7 +398,55 @@ void ThemeEditor::_dialog_cbk() { } - } break; + } break; + case POPUP_CLASS_REMOVE: { + StringName fromtype = type_edit->get_text(); + List names; + + { + names.clear(); + Theme::get_default()->get_icon_list(fromtype,&names); + for(List::Element *E=names.front();E;E=E->next()) { + theme->clear_icon(E->get(),fromtype); + + } + + } + { + names.clear(); + Theme::get_default()->get_stylebox_list(fromtype,&names); + for(List::Element *E=names.front();E;E=E->next()) { + theme->clear_stylebox(E->get(),fromtype); + + } + + } + { + names.clear(); + Theme::get_default()->get_font_list(fromtype,&names); + for(List::Element *E=names.front();E;E=E->next()) { + theme->clear_font(E->get(),fromtype); + + } + } + { + names.clear(); + Theme::get_default()->get_color_list(fromtype,&names); + for(List::Element *E=names.front();E;E=E->next()) { + theme->clear_color(E->get(),fromtype); + + } + } + { + names.clear(); + Theme::get_default()->get_constant_list(fromtype,&names); + for(List::Element *E=names.front();E;E=E->next()) { + theme->clear_constant(E->get(),fromtype); + + } + } + + }break; } } @@ -453,6 +501,19 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme=theme; + } else if (p_option==POPUP_CLASS_REMOVE) { + + add_del_dialog->set_title("Remove All Items"); + add_del_dialog->get_ok()->set_text("Remove All"); + add_del_dialog->popup_centered(Size2(240,85)); + + base_theme=Theme::get_default(); + + type_select->hide(); + name_select_label->hide(); + type_select_label->hide(); + name_edit->hide(); + name_menu->hide(); } popup_mode=p_option; @@ -538,6 +599,7 @@ ThemeEditor::ThemeEditor() { theme_menu->get_popup()->add_item("Add Item",POPUP_ADD); theme_menu->get_popup()->add_item("Add Class Items",POPUP_CLASS_ADD); theme_menu->get_popup()->add_item("Remove Item",POPUP_REMOVE); + theme_menu->get_popup()->add_item("Remove Class Items",POPUP_CLASS_REMOVE); theme_menu->get_popup()->add_separator(); theme_menu->get_popup()->add_item("Create Template",POPUP_CREATE_TEMPLATE); hb_menu->add_child(theme_menu); diff --git a/tools/editor/plugins/theme_editor_plugin.h b/tools/editor/plugins/theme_editor_plugin.h index 52c4aed839c..49d5ae30960 100644 --- a/tools/editor/plugins/theme_editor_plugin.h +++ b/tools/editor/plugins/theme_editor_plugin.h @@ -67,6 +67,7 @@ class ThemeEditor : public Control { POPUP_ADD, POPUP_CLASS_ADD, POPUP_REMOVE, + POPUP_CLASS_REMOVE, POPUP_CREATE_TEMPLATE };