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  Gtk::ComboBoxText *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  bool sp_output();
211  void changed();
212  int sp_input(double *v);
213 };
214 
216  using PropertyEditor::PropertyEditor;
217 
218 public:
219  void reload() override;
220  PropertyValue &get_value() override;
221  void construct() override;
222 
223 protected:
224  Gtk::Widget *create_editor() override;
225 
226 private:
227  Gtk::TextView *en = nullptr;
228  void changed();
229  void activate();
230  bool focus_out_event(GdkEventFocus *e);
231  bool modified = false;
232 
233  PropertyValueString value;
234 };
235 
237  using PropertyEditor::PropertyEditor;
238 
239 public:
240  void reload() override;
241  PropertyValue &get_value() override;
242 
243 protected:
244  Gtk::Widget *create_editor() override;
245 
246  Gtk::SpinButton *sp = nullptr;
247  PropertyValueInt value;
248  void changed();
249 };
250 
252  using PropertyEditorInt::PropertyEditorInt;
253 
254 protected:
255  Gtk::Widget *create_editor() override;
256 };
257 
258 } // namespace horizon
Definition: property_editor.hpp:197
Definition: spin_button_dim.hpp:5
Definition: property_editor.hpp:251
Definition: property_editor.hpp:9
Definition: property_editor.hpp:154
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103
Definition: core_properties.hpp:7
Definition: property_editor.hpp:123
Definition: property_panel.hpp:10
Definition: property_editor.hpp:215
Definition: core_properties.hpp:89
Definition: core_properties.hpp:25
Definition: core_properties.hpp:64
Definition: core_properties.hpp:51
Definition: object_descr.hpp:6
Definition: property_editor.hpp:86
Definition: core_properties.hpp:38
Definition: property_editor.hpp:139
Definition: property_editor.hpp:71
Definition: property_editor.hpp:175
Definition: property_editor.hpp:106
Definition: core_properties.hpp:77
Definition: block.cpp:9
Definition: core_properties.hpp:95
Definition: property_editor.hpp:236