summaryrefslogtreecommitdiff
path: root/editor/plugins/theme_editor_plugin.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /editor/plugins/theme_editor_plugin.cpp
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
Diffstat (limited to 'editor/plugins/theme_editor_plugin.cpp')
-rw-r--r--editor/plugins/theme_editor_plugin.cpp40
1 files changed, 0 insertions, 40 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index d9be2e32cb..90ef1e1507 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -36,14 +36,12 @@
#include "scene/gui/progress_bar.h"
void ThemeEditor::edit(const Ref<Theme> &p_theme) {
-
theme = p_theme;
main_panel->set_theme(p_theme);
main_container->set_theme(p_theme);
}
void ThemeEditor::_propagate_redraw(Control *p_at) {
-
p_at->notification(NOTIFICATION_THEME_CHANGED);
p_at->minimum_size_changed();
p_at->update();
@@ -55,25 +53,20 @@ void ThemeEditor::_propagate_redraw(Control *p_at) {
}
void ThemeEditor::_refresh_interval() {
-
_propagate_redraw(main_panel);
_propagate_redraw(main_container);
}
void ThemeEditor::_type_menu_cbk(int p_option) {
-
type_edit->set_text(type_menu->get_popup()->get_item_text(p_option));
}
void ThemeEditor::_name_menu_about_to_show() {
-
String fromtype = type_edit->get_text();
List<StringName> names;
if (popup_mode == POPUP_ADD) {
-
switch (type_select->get_selected()) {
-
case 0:
Theme::get_default()->get_icon_list(fromtype, &names);
break;
@@ -91,7 +84,6 @@ void ThemeEditor::_name_menu_about_to_show() {
break;
}
} else if (popup_mode == POPUP_REMOVE) {
-
theme->get_icon_list(fromtype, &names);
theme->get_stylebox_list(fromtype, &names);
theme->get_font_list(fromtype, &names);
@@ -102,21 +94,17 @@ void ThemeEditor::_name_menu_about_to_show() {
name_menu->get_popup()->clear();
name_menu->get_popup()->set_size(Size2());
for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
-
name_menu->get_popup()->add_item(E->get());
}
}
void ThemeEditor::_name_menu_cbk(int p_option) {
-
name_edit->set_text(name_menu->get_popup()->get_item_text(p_option));
}
struct _TECategory {
-
template <class T>
struct RefItem {
-
Ref<T> item;
StringName name;
bool operator<(const RefItem<T> &p) const { return item->get_instance_id() < p.item->get_instance_id(); }
@@ -124,7 +112,6 @@ struct _TECategory {
template <class T>
struct Item {
-
T item;
String name;
bool operator<(const Item<T> &p) const { return name < p.name; }
@@ -139,7 +126,6 @@ struct _TECategory {
};
void ThemeEditor::_save_template_cbk(String fname) {
-
String filename = file_dialog->get_current_path();
Map<String, _TECategory> categories;
@@ -153,7 +139,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
// Fill default theme.
for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) {
-
_TECategory &tc = E->get();
List<StringName> stylebox_list;
@@ -270,7 +255,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
// Write default theme.
for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) {
-
_TECategory &tc = E->get();
String underline = "; ";
@@ -286,7 +270,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("\n; StyleBox Items:\n");
for (Set<_TECategory::RefItem<StyleBox>>::Element *F = tc.stylebox_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
@@ -294,7 +277,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("\n; Font Items:\n");
for (Set<_TECategory::RefItem<Font>>::Element *F = tc.font_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
@@ -302,7 +284,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("\n; Icon Items:\n");
for (Set<_TECategory::RefItem<Texture2D>>::Element *F = tc.icon_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
@@ -310,7 +291,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("\n; Color Items:\n");
for (Set<_TECategory::Item<Color>>::Element *F = tc.color_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
@@ -318,7 +298,6 @@ void ThemeEditor::_save_template_cbk(String fname) {
file->store_line("\n; Constant Items:\n");
for (Set<_TECategory::Item<int>>::Element *F = tc.constant_items.front(); F; F = F->next()) {
-
file->store_line(E->key() + "." + F->get().name + " = default");
}
}
@@ -328,12 +307,9 @@ void ThemeEditor::_save_template_cbk(String fname) {
}
void ThemeEditor::_dialog_cbk() {
-
switch (popup_mode) {
case POPUP_ADD: {
-
switch (type_select->get_selected()) {
-
case 0:
theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture2D>());
break;
@@ -353,7 +329,6 @@ void ThemeEditor::_dialog_cbk() {
} break;
case POPUP_CLASS_ADD: {
-
StringName fromtype = type_edit->get_text();
List<StringName> names;
@@ -395,7 +370,6 @@ void ThemeEditor::_dialog_cbk() {
} break;
case POPUP_REMOVE: {
switch (type_select->get_selected()) {
-
case 0:
theme->clear_icon(name_edit->get_text(), type_edit->get_text());
break;
@@ -459,9 +433,7 @@ void ThemeEditor::_dialog_cbk() {
}
void ThemeEditor::_theme_menu_cbk(int p_option) {
-
if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) {
-
bool import = (p_option == POPUP_IMPORT_EDITOR_THEME);
Ref<Theme> base_theme;
@@ -473,7 +445,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
}
{
-
List<StringName> types;
base_theme->get_type_list(&types);
@@ -555,7 +526,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
type_select->hide();
} else if (p_option == POPUP_REMOVE) {
-
add_del_dialog->set_title(TTR("Remove Item"));
add_del_dialog->get_ok()->set_text(TTR("Remove"));
add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
@@ -563,7 +533,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
base_theme = theme;
} else if (p_option == POPUP_CLASS_REMOVE) {
-
add_del_dialog->set_title(TTR("Remove All Items"));
add_del_dialog->get_ok()->set_text(TTR("Remove All"));
add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
@@ -589,10 +558,8 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
List<StringName> new_types;
theme->get_type_list(&new_types);
for (List<StringName>::Element *F = new_types.front(); F; F = F->next()) {
-
bool found = false;
for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
-
if (E->get() == F->get()) {
found = true;
break;
@@ -606,13 +573,11 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
types.sort_custom<StringName::AlphCompare>();
for (List<StringName>::Element *E = types.front(); E; E = E->next()) {
-
type_menu->get_popup()->add_item(E->get());
}
}
void ThemeEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_PROCESS: {
time_left -= get_process_delta_time();
@@ -631,7 +596,6 @@ void ThemeEditor::_bind_methods() {
}
ThemeEditor::ThemeEditor() {
-
time_left = 0;
HBoxContainer *top_menu = memnew(HBoxContainer);
@@ -901,7 +865,6 @@ ThemeEditor::ThemeEditor() {
}
void ThemeEditorPlugin::edit(Object *p_node) {
-
if (Object::cast_to<Theme>(p_node)) {
theme_editor->edit(Object::cast_to<Theme>(p_node));
} else {
@@ -910,12 +873,10 @@ void ThemeEditorPlugin::edit(Object *p_node) {
}
bool ThemeEditorPlugin::handles(Object *p_node) const {
-
return p_node->is_class("Theme");
}
void ThemeEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
theme_editor->set_process(true);
button->show();
@@ -930,7 +891,6 @@ void ThemeEditorPlugin::make_visible(bool p_visible) {
}
ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) {
-
editor = p_node;
theme_editor = memnew(ThemeEditor);
theme_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);