Horizon
pool_browser.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include <memory>
4 #include <set>
5 #include "util/uuid.hpp"
6 #include "util/sort_controller.hpp"
7 #include "util/selection_provider.hpp"
8 #include "common/common.hpp"
9 
10 namespace horizon {
11 class PoolBrowser : public Gtk::Box, public SelectionProvider {
12 public:
13  PoolBrowser(class Pool *pool);
14  UUID get_selected() override;
15  void set_show_none(bool v);
16  void set_show_path(bool v);
17  void add_context_menu_item(const std::string &label, sigc::slot1<void, UUID> cb);
18  virtual void search() = 0;
19  virtual ObjectType get_type() const
20  {
21  return ObjectType::INVALID;
22  };
23  void go_to(const UUID &uu);
24  void clear_search();
25 
26 protected:
27  void construct();
28  class Pool *pool = nullptr;
29  bool show_none = false;
30  bool show_path = false;
31  int path_column = -1;
32 
33 
34  Gtk::TreeView *treeview = nullptr;
35 
36  Gtk::Entry *create_search_entry(const std::string &label);
37  void add_search_widget(const std::string &label, Gtk::Widget &w);
38 
39 
40  virtual Glib::RefPtr<Gtk::ListStore> create_list_store() = 0;
41  virtual void create_columns() = 0;
42  virtual void add_sort_controller_columns() = 0;
43  virtual UUID uuid_from_row(const Gtk::TreeModel::Row &row) = 0;
44 
45  Glib::RefPtr<Gtk::ListStore> store;
46  std::unique_ptr<SortController> sort_controller;
47 
48  void row_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *column);
49  void selection_changed();
50 
51  void select_uuid(const UUID &uu);
52  void scroll_to_selection();
53 
54  Gtk::Menu context_menu;
55  std::set<Gtk::Entry *> search_entries;
56 
57 private:
58  Gtk::Grid *grid = nullptr;
59  int grid_top = 0;
60 };
61 } // namespace horizon
Definition: selection_provider.hpp:6
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: pool_browser.hpp:11
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:18
Definition: block.cpp:7