Horizon
editor_window.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include "common/common.hpp"
4 #include <memory>
5 #include "editor_interface.hpp"
6 #include "util/window_state_store.hpp"
7 #include "util/pool_goto_provider.hpp"
8 #include "util/item_set.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  std::string filename;
19  virtual ~EditorWindowStore()
20  {
21  }
22 };
23 
24 class EditorWindow : public Gtk::Window, public PoolGotoProvider {
25 public:
26  EditorWindow(ObjectType type, const std::string &filename, class Pool *p, class PoolParametric *pp, bool read_only,
27  bool is_temp);
28  void reload();
29  bool get_need_update() const;
30  static std::string fix_filename(std::string s);
31  void save();
32  void force_close();
33  bool get_needs_save() const;
34  std::string get_filename() const;
35  void set_original_filename(const std::string &s);
36  ObjectType get_object_type() const;
37  const UUID &get_uuid() const;
38 
39  void select(const ItemSet &items);
40 
41  typedef sigc::signal<void, std::string> type_signal_filename_changed;
42  type_signal_filename_changed signal_filename_changed()
43  {
44  return s_signal_filename_changed;
45  }
46  type_signal_filename_changed signal_saved()
47  {
48  return s_signal_saved;
49  }
50 
51 private:
52  ObjectType type;
53  std::unique_ptr<EditorWindowStore> store = nullptr;
54  PoolEditorInterface *iface = nullptr;
55  Gtk::Button *save_button = nullptr;
56  class Pool *pool;
57  class PoolParametric *pool_parametric;
58  bool need_update = false;
59  std::string original_filename;
60 
61  type_signal_filename_changed s_signal_filename_changed;
62  type_signal_filename_changed s_signal_saved;
63 
64  WindowStateStore state_store;
65 };
66 } // namespace horizon
horizon::EditorWindow
Definition: editor_window.hpp:24
horizon::PoolGotoProvider
Definition: pool_goto_provider.hpp:7
horizon::WindowStateStore
Definition: window_state_store.hpp:20
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::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::PoolParametric
Definition: pool_parametric.hpp:10