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  static std::string fix_filename(std::string s);
36  void save();
37  void force_close();
38  bool get_needs_save() const;
39  std::string get_filename() const;
40  void set_original_filename(const std::string &s);
41  ObjectType get_object_type() const;
42  const UUID &get_uuid() const;
43 
44  void select(const ItemSet &items);
45 
46  typedef sigc::signal<void, std::string> type_signal_filename_changed;
47  type_signal_filename_changed signal_filename_changed()
48  {
49  return s_signal_filename_changed;
50  }
51  type_signal_filename_changed signal_saved()
52  {
53  return s_signal_saved;
54  }
55 
56 private:
57  ObjectType type;
58  std::unique_ptr<EditorWindowStore> store = nullptr;
59  class PoolEditorInterface *iface = nullptr;
60  Gtk::Button *save_button = nullptr;
61  Gtk::MenuButton *check_button = nullptr;
62  class ColorBox *check_color_box = nullptr;
63  Gtk::Popover *check_popover = nullptr;
64  Gtk::Label *check_label = nullptr;
65  Gtk::InfoBar *info_bar = nullptr;
66  class IPool &pool;
67  class PoolParametric *pool_parametric;
68  bool need_update = false;
69  std::string original_filename;
70 
71  type_signal_filename_changed s_signal_filename_changed;
72  type_signal_filename_changed s_signal_saved;
73 
74  WindowStateStore state_store;
75  void run_checks();
76 };
77 } // namespace horizon
horizon::EditorWindow
Definition: editor_window.hpp:29
horizon::PoolGotoProvider
Definition: pool_goto_provider.hpp:7
horizon::WindowStateStore
Definition: window_state_store.hpp:20
horizon::FileVersion
Definition: file_version.hpp:8
horizon::ColorBox
Definition: color_box.hpp:6
horizon::IPool
Definition: ipool.hpp:12
horizon::PoolEditorInterface
Definition: editor_interface.hpp:6
horizon::EditorWindowStore
Definition: editor_window.hpp:11
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::RulesCheckResult
Definition: rules.hpp:34
horizon::PoolParametric
Definition: pool_parametric.hpp:10