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
10namespace horizon {
12public:
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 unsigned int get_required_version() const;
20 virtual ObjectType get_type() const = 0;
21 std::string filename;
22
23 virtual RulesCheckResult run_checks() const = 0;
24
25 virtual ~EditorWindowStore()
26 {
27 }
28};
29
30class EditorWindow : public Gtk::Window, public PoolGotoProvider {
31public:
32 EditorWindow(ObjectType type, const std::string &filename, class IPool *p, class PoolParametric *pp, bool read_only,
33 bool is_temp);
34 void reload();
35 bool get_need_update() const;
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
56private:
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 Gtk::Label *info_bar_label = nullptr;
67 class IPool &pool;
68 class PoolParametric *pool_parametric;
69 bool need_update = false;
70 std::string original_filename;
71
72 type_signal_filename_changed s_signal_filename_changed;
73 type_signal_filename_changed s_signal_saved;
74
75 WindowStateStore state_store;
76 void run_checks();
77 bool read_only;
78
79 unsigned int saved_version = 0;
80 void update_version_warning();
81};
82} // namespace horizon
Definition: color_box.hpp:6
Definition: editor_window.hpp:11
Definition: editor_window.hpp:30
Definition: file_version.hpp:9
Definition: ipool.hpp:14
Definition: editor_interface.hpp:6
Definition: pool_goto_provider.hpp:7
Definition: pool_parametric.hpp:10
Definition: rules.hpp:37
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