diff options
author | NilsIrl <nils@nilsand.re> | 2019-07-27 16:45:37 +0200 |
---|---|---|
committer | NilsIrl <nils@nilsand.re> | 2019-07-27 16:46:14 +0200 |
commit | ba63e0a5a27c2d861853294a87afd78fe1bef78c (patch) | |
tree | 2f2c54d249b59f2ab4ce7361069cbbb42d980466 /modules/gdnative | |
parent | 94aabf56a0a22df689bc57c71981c0008eb40464 (diff) |
Replace radion buttons with checkboxes in GDNativeLibrary editor
Diffstat (limited to 'modules/gdnative')
-rw-r--r-- | modules/gdnative/gdnative_library_editor_plugin.cpp | 31 | ||||
-rw-r--r-- | modules/gdnative/gdnative_library_editor_plugin.h | 2 |
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; |