Horizon
property_editor.hpp
1 #pragma once
2 #include <gtkmm.h>
3 #include "core/core.hpp"
4 #include "common/object_descr.hpp"
5 #include "core/core_properties.hpp"
6 #include "widgets/generic_combo_box.hpp"
7 
8 namespace horizon {
9 class PropertyEditor : public Gtk::Box {
10 public:
11  PropertyEditor(ObjectType t, ObjectProperty::ID prop, class PropertyPanel *p);
12  virtual void construct();
13  void set_can_apply_all(bool v);
14 
15  virtual void reload(){};
16  virtual PropertyValue &get_value()
17  {
18  return dummy;
19  }
20  virtual PropertyMeta &get_meta()
21  {
22  return meta;
23  }
24 
25  typedef sigc::signal<void> type_signal_changed;
26  type_signal_changed signal_changed()
27  {
28  return s_signal_changed;
29  }
30 
31  type_signal_changed signal_apply_all()
32  {
33  return s_signal_apply_all;
34  }
35 
36  type_signal_changed signal_activate()
37  {
38  return s_signal_activate;
39  }
40 
41  bool get_apply_all();
42 
43  virtual ~PropertyEditor()
44  {
45  }
46 
47  class PropertyPanel *parent;
48  const ObjectProperty::ID property_id;
49 
50 protected:
51  const ObjectType type;
52 
53  const ObjectProperty &property;
54  Gtk::ToggleButton *apply_all_button = nullptr;
55 
56  virtual Gtk::Widget *create_editor();
57 
58  type_signal_changed s_signal_changed;
59  type_signal_changed s_signal_apply_all;
60  type_signal_changed s_signal_activate;
61  PropertyValue dummy;
62  PropertyMeta meta;
63 
64  bool readonly = false;
65 
66  std::deque<sigc::connection> connections;
67 
68 private:
69 };
70 
72  using PropertyEditor::PropertyEditor;
73 
74 public:
75  void reload() override;
76  PropertyValue &get_value() override;
77 
78 protected:
79  Gtk::Widget *create_editor() override;
80 
81 private:
82  Gtk::Switch *sw = nullptr;
83  PropertyValueBool value;
84 };
85 
87  using PropertyEditor::PropertyEditor;
88 
89 public:
90  void reload() override;
91  PropertyValue &get_value() override;
92 
93 protected:
94  Gtk::Widget *create_editor() override;
95 
96 private:
97  Gtk::Entry *en = nullptr;
98  void changed();
99  void activate();
100  bool focus_out_event(GdkEventFocus *e);
101  bool modified = false;
102 
103  PropertyValueString value;
104 };
105 
107  using PropertyEditor::PropertyEditor;
108 
109 public:
110  void reload() override;
111  PropertyValue &get_value() override;
112  void set_range(int64_t min, int64_t max);
113 
114 protected:
115  Gtk::Widget *create_editor() override;
116 
117 private:
118  class SpinButtonDim *sp = nullptr;
119  PropertyValueInt value;
120  std::pair<int64_t, int64_t> range = {-1e9, 1e9};
121 };
122 
124  using PropertyEditor::PropertyEditor;
125 
126 public:
127  void reload() override;
128  PropertyValue &get_value() override;
129 
130 protected:
131  Gtk::Widget *create_editor() override;
132 
133 private:
134  GenericComboBox<int> *combo = nullptr;
135  void changed();
136  PropertyValueInt value;
137 };
138 
140  using PropertyEditor::PropertyEditor;
141 
142 public:
143  void reload() override;
144  PropertyValue &get_value() override;
145 
146 protected:
147  Gtk::Widget *create_editor() override;
148 
149 private:
150  Gtk::Label *la = nullptr;
151  PropertyValueString value;
152 };
153 
155  using PropertyEditor::PropertyEditor;
156 
157 public:
158  void reload() override;
159  PropertyValue &get_value() override;
160  PropertyMeta &get_meta() override
161  {
162  return my_meta;
163  };
164 
165 protected:
166  Gtk::Widget *create_editor() override;
167 
168 private:
169  GenericComboBox<UUID> *combo = nullptr;
170  void changed();
171  PropertyValueUUID value;
172  PropertyMetaNetClasses my_meta;
173 };
174 
176  using PropertyEditor::PropertyEditor;
177 
178 public:
179  void reload() override;
180  PropertyValue &get_value() override;
181  PropertyMeta &get_meta() override
182  {
183  return my_meta;
184  };
185  bool copper_only = false;
186 
187 protected:
188  Gtk::Widget *create_editor() override;
189 
190 private:
191  class LayerComboBox *combo = nullptr;
192  void changed();
193  PropertyValueInt value;
194  PropertyMetaLayers my_meta;
195 };
196 
198  using PropertyEditor::PropertyEditor;
199 
200 public:
201  void reload() override;
202  PropertyValue &get_value() override;
203 
204 protected:
205  Gtk::Widget *create_editor() override;
206 
207 private:
208  Gtk::SpinButton *sp = nullptr;
209  PropertyValueInt value;
210 };
211 
213  using PropertyEditor::PropertyEditor;
214 
215 public:
216  void reload() override;
217  PropertyValue &get_value() override;
218  void construct() override;
219 
220 protected:
221  Gtk::Widget *create_editor() override;
222 
223 private:
224  class TextEditor *editor = nullptr;
225  void changed();
226  void activate();
227  bool modified = false;
228 
229  PropertyValueString value;
230 };
231 
233  using PropertyEditor::PropertyEditor;
234 
235 public:
236  void reload() override;
237  PropertyValue &get_value() override;
238 
239 protected:
240  Gtk::Widget *create_editor() override;
241 
242  Gtk::SpinButton *sp = nullptr;
243  PropertyValueInt value;
244 };
245 
247  using PropertyEditorInt::PropertyEditorInt;
248 
249 protected:
250  Gtk::Widget *create_editor() override;
251 };
252 
254  using PropertyEditorInt::PropertyEditorInt;
255 
256 protected:
257  Gtk::Widget *create_editor() override;
258 };
259 
261  using PropertyEditor::PropertyEditor;
262 
263 public:
264  void reload() override;
265  PropertyValue &get_value() override;
266 
267 protected:
268  Gtk::Widget *create_editor() override;
269 
270  Gtk::SpinButton *sp = nullptr;
271  PropertyValueDouble value;
272  void changed();
273 };
274 
276  using PropertyEditorDouble::PropertyEditorDouble;
277 
278 protected:
279  Gtk::Widget *create_editor() override;
280 };
281 
283  using PropertyEditorDouble::PropertyEditorDouble;
284 
285 protected:
286  Gtk::Widget *create_editor() override;
287 };
288 
289 } // namespace horizon
Definition: layer_combo_box.hpp:5
Definition: object_descr.hpp:6
Definition: property_editor.hpp:197
Definition: property_editor.hpp:71
Definition: property_editor.hpp:106
Definition: property_editor.hpp:260
Definition: property_editor.hpp:123
Definition: property_editor.hpp:246
Definition: property_editor.hpp:232
Definition: property_editor.hpp:175
Definition: property_editor.hpp:154
Definition: property_editor.hpp:275
Definition: property_editor.hpp:253
Definition: property_editor.hpp:282
Definition: property_editor.hpp:212
Definition: property_editor.hpp:139
Definition: property_editor.hpp:86
Definition: property_editor.hpp:9
Definition: core_properties.hpp:108
Definition: core_properties.hpp:102
Definition: core_properties.hpp:90
Definition: property_panel.hpp:10
Definition: core_properties.hpp:51
Definition: core_properties.hpp:38
Definition: core_properties.hpp:25
Definition: core_properties.hpp:64
Definition: core_properties.hpp:77
Definition: core_properties.hpp:7
Definition: spin_button_dim.hpp:5
Definition: text_editor.hpp:6
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103