summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-07-29 10:11:56 +0200
committerGitHub <noreply@github.com>2019-07-29 10:11:56 +0200
commitd06da7193d9e02c43119e989ab88513b975e28e0 (patch)
tree54256c1dc690dad82e6d66eb206b18a572e1e918
parent47df673d737f10dcc7dbcc32a574a3589bddc3f7 (diff)
parentba63e0a5a27c2d861853294a87afd78fe1bef78c (diff)
Merge pull request #30869 from NilsIrl/#30841
Replace radion buttons with checkboxes in GDNativeLibrary editor
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp31
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.h2
2 files changed, 18 insertions, 15 deletions
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index e2a69b1635..e6660971a7 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -66,10 +66,13 @@ void GDNativeLibraryEditor::_update_tree() {
tree->clear();
TreeItem *root = tree->create_item();
- for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
+ PopupMenu *filter_list = filter->get_popup();
+ for (int i = 0; i < filter_list->get_item_count(); i++) {
- if (showing_platform != E->key() && showing_platform != "All")
+ if (!filter_list->is_item_checked(i)) {
continue;
+ }
+ Map<String, NativePlatformConfig>::Element *E = platforms.find(filter_list->get_item_metadata(i));
TreeItem *platform = tree->create_item(root);
platform->set_text(0, E->get().name);
@@ -162,9 +165,10 @@ void GDNativeLibraryEditor::_on_dependencies_selected(const PoolStringArray &fil
_set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), files);
}
-void GDNativeLibraryEditor::_on_filter_selected(int id) {
+void GDNativeLibraryEditor::_on_filter_selected(int index) {
- showing_platform = filter->get_item_metadata(id);
+ PopupMenu *filter_list = filter->get_popup();
+ filter_list->set_item_checked(index, !filter_list->is_item_checked(index));
_update_tree();
}
@@ -265,8 +269,6 @@ void GDNativeLibraryEditor::_translate_to_config_file() {
GDNativeLibraryEditor::GDNativeLibraryEditor() {
- showing_platform = "All";
-
{ // Define platforms
NativePlatformConfig platform_windows;
platform_windows.name = "Windows";
@@ -336,20 +338,21 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
Label *label = memnew(Label);
label->set_text(TTR("Platform:"));
hbox->add_child(label);
- filter = memnew(OptionButton);
+ filter = memnew(MenuButton);
+ filter->set_text(TTR("Choose platform"));
hbox->add_child(filter);
- filter->set_h_size_flags(SIZE_EXPAND_FILL);
+ PopupMenu *filter_list = filter->get_popup();
+ filter_list->set_hide_on_checkable_item_selection(false);
+ filter_list->set_h_size_flags(SIZE_EXPAND_FILL);
int idx = 0;
- filter->add_item(TTR("All"), idx);
- filter->set_item_metadata(idx, "All");
- idx += 1;
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
- filter->add_item(E->get().name, idx);
- filter->set_item_metadata(idx, E->key());
+ filter_list->add_check_item(E->get().name, idx);
+ filter_list->set_item_metadata(idx, E->key());
+ filter_list->set_item_checked(idx, true);
idx += 1;
}
- filter->connect("item_selected", this, "_on_filter_selected");
+ filter_list->connect("index_pressed", this, "_on_filter_selected");
tree = memnew(Tree);
container->add_child(tree);
diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h
index e7d50ba29f..8c1449f55a 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.h
+++ b/modules/gdnative/gdnative_library_editor_plugin.h
@@ -61,7 +61,7 @@ class GDNativeLibraryEditor : public Control {
};
Tree *tree;
- OptionButton *filter;
+ MenuButton *filter;
EditorFileDialog *file_dialog;
ConfirmationDialog *new_architecture_dialog;
LineEdit *new_architecture_input;