Horizon
editor_window.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include "common/common.hpp"
4 #include <memory>
5 #include "util/window_state_store.hpp"
6 #include "util/pool_goto_provider.hpp"
7 #include "util/item_set.hpp"
8 #include "rules/rules.hpp"
9 
10 namespace horizon {
12 public:
13  EditorWindowStore(const std::string &fn);
14  void save();
15  virtual void save_as(const std::string &fn) = 0;
16  virtual std::string get_name() const = 0;
17  virtual const UUID &get_uuid() const = 0;
18  virtual const class FileVersion &get_version() const = 0;
19  virtual ObjectType get_type() const = 0;
20  std::string filename;
21 
22  virtual RulesCheckResult run_checks() const = 0;
23 
24  virtual ~EditorWindowStore()
25  {
26  }
27 };
28 
29 class EditorWindow : public Gtk::Window, public PoolGotoProvider {
30 public:
31  EditorWindow(ObjectType type, const std::string &filename, class IPool *p, class PoolParametric *pp, bool read_only,
32  bool is_temp);
33  void reload();
34  bool get_need_update() const;
35  void save();
36  void force_close();
37  bool get_needs_save() const;
38  std::string get_filename() const;
39  void set_original_filename(const std::string &s);
40  ObjectType get_object_type() const;
41  const UUID &get_uuid() const;
42 
43  void select(const ItemSet &items);
44 
45  typedef sigc::signal<void, std::string> type_signal_filename_changed;
46  type_signal_filename_changed signal_filename_changed()
47  {
48  return s_signal_filename_changed;
49  }
50  type_signal_filename_changed signal_saved()
51  {
52  return s_signal_saved;
53  }
54 
55 private:
56  ObjectType type;
57  std::unique_ptr<EditorWindowStore> store = nullptr;
58  class PoolEditorInterface *iface = nullptr;
59  Gtk::Button *save_button = nullptr;
60  Gtk::MenuButton *check_button = nullptr;
61  class ColorBox *check_color_box = nullptr;
62  Gtk::Popover *check_popover = nullptr;
63  Gtk::Label *check_label = nullptr;
64  Gtk::InfoBar *info_bar = nullptr;
65  class IPool &pool;
66  class PoolParametric *pool_parametric;
67  bool need_update = false;
68  std::string original_filename;
69 
70  type_signal_filename_changed s_signal_filename_changed;
71  type_signal_filename_changed s_signal_saved;
72 
73  WindowStateStore state_store;
74  void run_checks();
75  bool read_only;
76 };
77 } // namespace horizon
Definition: color_box.hpp:6
Definition: editor_window.hpp:11
Definition: editor_window.hpp:29
Definition: file_version.hpp:8
Definition: ipool.hpp:14
Definition: editor_interface.hpp:6
Definition: pool_goto_provider.hpp:7
Definition: pool_parametric.hpp:10
Definition: rules.hpp:34
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: window_state_store.hpp:25