Horizon
pool_notebook.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include <memory>
4 #include "util/uuid.hpp"
5 #include "pool/part.hpp"
6 #include "pool/unit.hpp"
7 #include "pool/entity.hpp"
8 #include "pool/symbol.hpp"
9 #include "pool/package.hpp"
10 #include "pool/padstack.hpp"
11 
12 #include "pool/pool.hpp"
13 #include "pool/pool_parametric.hpp"
14 #include "util/editor_process.hpp"
15 #include <zmq.hpp>
16 #include "util/win32_undef.hpp"
17 #include "util/paned_state_store.hpp"
18 
19 namespace horizon {
20 class PoolNotebook : public Gtk::Notebook {
21  friend class PoolRemoteBox;
22  friend class PoolGitBox;
23 
24 public:
25  PoolNotebook(const std::string &bp, class PoolProjectManagerAppWindow &aw);
26  void populate();
27  bool get_close_prohibited() const;
28  void prepare_close();
29  void pool_update(const std::vector<std::string> &filenames = {});
30  bool get_needs_save() const;
31  void save();
32  void go_to(ObjectType type, const UUID &uu);
33  class PoolSettingsBox &get_pool_settings_box();
34  const UUID &get_pool_uuid() const;
35  ~PoolNotebook();
37 
38  typedef sigc::signal<void> type_signal_saved;
39  type_signal_saved signal_saved()
40  {
41  return s_signal_saved;
42  }
43 
44  void show_settings_tab();
45 
46 private:
47  const std::string base_path;
48  Pool pool;
49  PoolParametric pool_parametric;
50  std::map<ObjectType, class PoolBrowser *> browsers;
51  std::map<std::string, class PoolBrowserParametric *> browsers_parametric;
52  class PartWizard *part_wizard = nullptr;
53  class KiCadSymbolImportWizard *kicad_symbol_import_wizard = nullptr;
54  class DuplicateWindow *duplicate_window = nullptr;
55  class ImportKiCadPackageWindow *import_kicad_package_window = nullptr;
56  bool closing = false;
57 
58  void reload();
59  std::function<void()> pool_update_done_cb = nullptr;
60 
61  void show_duplicate_window(ObjectType ty, const UUID &uu);
62 
63  void construct_units();
64  void handle_create_unit();
65  void handle_edit_unit(const UUID &uu);
66  void handle_create_symbol_for_unit(const UUID &uu);
67  void handle_create_entity_for_unit(const UUID &uu);
68  void handle_duplicate_unit(const UUID &uu);
69 
70  void construct_symbols();
71  void handle_edit_symbol(const UUID &uu);
72  void handle_create_symbol();
73  void handle_duplicate_symbol(const UUID &uu);
74 
75  void construct_entities();
76  void handle_edit_entity(const UUID &uu);
77  void handle_create_entity();
78  void handle_duplicate_entity(const UUID &uu);
79 
80  void construct_padstacks();
81  void handle_edit_padstack(const UUID &uu);
82  void handle_create_padstack();
83  void handle_duplicate_padstack(const UUID &uu);
84 
85  void construct_packages();
86  void handle_edit_package(const UUID &uu);
87  void handle_create_package();
88  void handle_create_padstack_for_package(const UUID &uu);
89  void handle_duplicate_package(const UUID &uu);
90  void handle_import_kicad_package();
91 
92  void handle_part_wizard();
93  void handle_kicad_symbol_import_wizard();
94 
95  void construct_parts();
96  void handle_edit_part(const UUID &uu);
97  void handle_create_part();
98  void handle_create_part_from_part(const UUID &uu);
99  void handle_duplicate_part(const UUID &uu);
100 
101  void construct_frames();
102  void handle_edit_frame(const UUID &uu);
103  void handle_create_frame();
104  void handle_duplicate_frame(const UUID &uu);
105 
106  void construct_decals();
107  void handle_edit_decal(const UUID &uu);
108  void handle_create_decal();
109  void handle_duplicate_decal(const UUID &uu);
110 
111  void construct_parametric();
112 
113  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, sigc::slot0<void>);
114  Gtk::Button *add_action_button(const std::string &label, Gtk::Box *bbox, class PoolBrowser *br,
115  sigc::slot1<void, UUID>);
116  Gtk::Button *add_merge_button(Gtk::Box *bbox, class PoolBrowser *br, std::function<void(UUID)> cb = nullptr);
117  void add_preview_stack_switcher(Gtk::Box *bbox, Gtk::Stack *stack);
118 
119  void handle_delete(ObjectType ty, const UUID &uu);
120  void handle_move_rename(ObjectType ty, const UUID &uu);
121  void handle_copy_path(ObjectType ty, const UUID &uu);
122  void add_context_menu(class PoolBrowser *br);
123 
124  Pool::ItemPoolInfo get_pool_uuids(ObjectType ty, const UUID &uu);
125  void handle_edit_item(ObjectType ty, const UUID &uu);
126  void handle_duplicate_item(ObjectType ty, const UUID &uu);
127 
128  void install_search_once(Gtk::Widget *page, PoolBrowser *browser);
129  bool widget_is_visible(Gtk::Widget *widget);
130 
131  void create_paned_state_store(Gtk::Paned *paned, const std::string &prefix);
132  std::vector<std::unique_ptr<PanedStateStore>> paned_state_stores;
133 
134  std::string remote_repo;
135  class PoolRemoteBox *remote_box = nullptr;
136  class PoolSettingsBox *settings_box = nullptr;
137  class PoolGitBox *git_box = nullptr;
138  class PoolCacheBox *cache_box = nullptr;
139 
140  UUID pool_uuid;
141 
142  void pool_updated();
143  bool pool_busy = false;
144 
145  type_signal_saved s_signal_saved;
146 };
147 } // namespace horizon
Definition: duplicate_window.hpp:7
Definition: import_kicad_package_window.hpp:9
Definition: kicad_symbol_import_wizard.hpp:14
Definition: part_wizard.hpp:16
Definition: pool_browser.hpp:15
Definition: pool_cache_box.hpp:14
Definition: pool_git_box.hpp:16
Definition: pool_notebook.hpp:20
Definition: pool_parametric.hpp:10
Definition: pool-prj-mgr-app_win.hpp:22
Definition: pool_remote_box.hpp:18
Definition: pool_settings_box.hpp:15
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:22
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: pool.hpp:81