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 
7 namespace horizon {
8 class PropertyEditor : public Gtk::Box {
9 public:
10  PropertyEditor(ObjectType t, ObjectProperty::ID prop, class PropertyPanel *p);
11  void construct();
12  void set_can_apply_all(bool v);
13 
14  virtual void reload(){};
15  virtual PropertyValue &get_value()
16  {
17  return dummy;
18  }
19  virtual PropertyMeta &get_meta()
20  {
21  return meta;
22  }
23 
24  typedef sigc::signal<void> type_signal_changed;
25  type_signal_changed signal_changed()
26  {
27  return s_signal_changed;
28  }
29 
30  type_signal_changed signal_apply_all()
31  {
32  return s_signal_apply_all;
33  }
34 
35  virtual ~PropertyEditor()
36  {
37  }
38 
39  class PropertyPanel *parent;
40  const ObjectProperty::ID property_id;
41 
42 protected:
43  const ObjectType type;
44 
45  const ObjectProperty &property;
46  Gtk::Button *apply_all_button = nullptr;
47 
48  virtual Gtk::Widget *create_editor();
49 
50  type_signal_changed s_signal_changed;
51  type_signal_changed s_signal_apply_all;
52  PropertyValue dummy;
53  PropertyMeta meta;
54 
55  bool readonly = false;
56 
57  std::deque<sigc::connection> connections;
58 
59 private:
60 };
61 
63  using PropertyEditor::PropertyEditor;
64 
65 public:
66  void reload() override;
67  PropertyValue &get_value() override;
68 
69 protected:
70  virtual Gtk::Widget *create_editor();
71 
72 private:
73  Gtk::Switch *sw = nullptr;
74  PropertyValueBool value;
75 };
76 
78  using PropertyEditor::PropertyEditor;
79 
80 public:
81  void reload() override;
82  PropertyValue &get_value() override;
83 
84 protected:
85  virtual Gtk::Widget *create_editor();
86 
87 private:
88  Gtk::Entry *en = nullptr;
89  void changed();
90  void activate();
91  bool focus_out_event(GdkEventFocus *e);
92  bool modified = false;
93 
94  PropertyValueString value;
95 };
96 
98  using PropertyEditor::PropertyEditor;
99 
100 public:
101  void reload() override;
102  PropertyValue &get_value() override;
103  void set_range(int64_t min, int64_t max);
104 
105 protected:
106  virtual Gtk::Widget *create_editor();
107 
108 private:
109  class SpinButtonDim *sp = nullptr;
110  PropertyValueInt value;
111  std::pair<int64_t, int64_t> range = {-1e9, 1e9};
112 };
113 
115  using PropertyEditor::PropertyEditor;
116 
117 public:
118  void reload() override;
119  PropertyValue &get_value() override;
120 
121 protected:
122  virtual Gtk::Widget *create_editor();
123 
124 private:
125  Gtk::ComboBoxText *combo = nullptr;
126  void changed();
127  PropertyValueInt value;
128 };
129 
131  using PropertyEditor::PropertyEditor;
132 
133 public:
134  void reload() override;
135  PropertyValue &get_value() override;
136 
137 protected:
138  virtual Gtk::Widget *create_editor();
139 
140 private:
141  Gtk::Label *la = nullptr;
142  PropertyValueString value;
143 };
144 
146  using PropertyEditor::PropertyEditor;
147 
148 public:
149  void reload() override;
150  PropertyValue &get_value() override;
151  PropertyMeta &get_meta() override
152  {
153  return my_meta;
154  };
155 
156 protected:
157  virtual Gtk::Widget *create_editor();
158 
159 private:
160  Gtk::ComboBoxText *combo = nullptr;
161  void changed();
162  PropertyValueUUID value;
163  PropertyMetaNetClasses my_meta;
164 };
165 
167  using PropertyEditor::PropertyEditor;
168 
169 public:
170  void reload() override;
171  PropertyValue &get_value() override;
172  PropertyMeta &get_meta() override
173  {
174  return my_meta;
175  };
176  bool copper_only = false;
177 
178 protected:
179  virtual Gtk::Widget *create_editor();
180 
181 private:
182  Gtk::ComboBoxText *combo = nullptr;
183  void changed();
184  PropertyValueInt value;
185  PropertyMetaLayers my_meta;
186 };
187 
189  using PropertyEditor::PropertyEditor;
190 
191 public:
192  void reload() override;
193  PropertyValue &get_value() override;
194 
195 protected:
196  virtual Gtk::Widget *create_editor();
197 
198 private:
199  Gtk::SpinButton *sp = nullptr;
200  PropertyValueInt value;
201  bool sp_output();
202  void changed();
203  int sp_input(double *v);
204 };
205 } // namespace horizon
Definition: property_editor.hpp:188
Definition: spin_button_dim.hpp:5
Definition: property_editor.hpp:8
Definition: property_editor.hpp:145
Definition: core_properties.hpp:7
Definition: property_editor.hpp:114
Definition: property_panel.hpp:10
Definition: core_properties.hpp:88
Definition: core_properties.hpp:25
Definition: core_properties.hpp:64
Definition: core_properties.hpp:51
Definition: object_descr.hpp:6
Definition: property_editor.hpp:77
Definition: core_properties.hpp:38
Definition: property_editor.hpp:130
Definition: property_editor.hpp:62
Definition: property_editor.hpp:166
Definition: property_editor.hpp:97
Definition: core_properties.hpp:77
Definition: block.cpp:7
Definition: core_properties.hpp:94