src/gui.h

changeset 603
47e7773c7841
parent 600
209e3f1f7b2c
child 604
01bdac75994a
equal deleted inserted replaced
602:ac1744536b33 603:47e7773c7841
56 #define SHIFT(N) (Qt::SHIFT | Qt::Key_##N) 56 #define SHIFT(N) (Qt::SHIFT | Qt::Key_##N)
57 #define CTRL_SHIFT(N) (Qt::CTRL | Qt::SHIFT | Qt::Key_##N) 57 #define CTRL_SHIFT(N) (Qt::CTRL | Qt::SHIFT | Qt::Key_##N)
58 58
59 // ============================================================================= 59 // =============================================================================
60 class LDQuickColor 60 class LDQuickColor
61 { PROPERTY (public, LDColor*, Color, NO_OPS, STOCK_WRITE) 61 {
62 PROPERTY (public, LDColor*, Color, NO_OPS, STOCK_WRITE)
62 PROPERTY (public, QToolButton*, ToolButton, NO_OPS, STOCK_WRITE) 63 PROPERTY (public, QToolButton*, ToolButton, NO_OPS, STOCK_WRITE)
63 64
64 public: 65 public:
65 LDQuickColor (LDColor* color, QToolButton* toolButton); 66 LDQuickColor (LDColor* color, QToolButton* toolButton);
66 bool isSeparator() const; 67 bool isSeparator() const;
72 // ObjectList 73 // ObjectList
73 // 74 //
74 // Object list class for ForgeWindow 75 // Object list class for ForgeWindow
75 // ============================================================================= 76 // =============================================================================
76 class ObjectList : public QListWidget 77 class ObjectList : public QListWidget
77 { Q_OBJECT 78 {
79 Q_OBJECT
78 80
79 protected: 81 protected:
80 void contextMenuEvent (QContextMenuEvent* ev); 82 void contextMenuEvent (QContextMenuEvent* ev);
81 }; 83 };
82 84
86 // The one main GUI class. Hosts the renderer, object list, message log. Contains 88 // The one main GUI class. Hosts the renderer, object list, message log. Contains
87 // slot_action, which is what all actions connect to. Manages menus and toolbars. 89 // slot_action, which is what all actions connect to. Manages menus and toolbars.
88 // Large and in charge. 90 // Large and in charge.
89 // ============================================================================= 91 // =============================================================================
90 class ForgeWindow : public QMainWindow 92 class ForgeWindow : public QMainWindow
91 { Q_OBJECT 93 {
94 Q_OBJECT
92 95
93 typedefs: 96 typedefs:
94 using ActionMethodType = void (ForgeWindow::*)(); 97 using ActionMethodType = void (ForgeWindow::*)();
95 98
96 public: 99 public:
116 void deleteByColor (const int colnum); 119 void deleteByColor (const int colnum);
117 bool save (LDDocument* f, bool saveAs); 120 bool save (LDDocument* f, bool saveAs);
118 void updateActions(); 121 void updateActions();
119 122
120 inline GLRenderer* R() 123 inline GLRenderer* R()
121 { return m_renderer; 124 {
125 return m_renderer;
122 } 126 }
123 127
124 inline void setQuickColors (QList<LDQuickColor>& colors) 128 inline void setQuickColors (QList<LDQuickColor>& colors)
125 { m_quickColors = colors; 129 {
130 m_quickColors = colors;
126 } 131 }
127 132
128 void setStatusBarText (str text); 133 void setStatusBarText (str text);
129 void addMessage (str msg); 134 void addMessage (str msg);
130 Ui_LDForgeUI* getInterface() const; 135 Ui_LDForgeUI* getInterface() const;
278 // Takes in pairs of radio buttons and respective values and returns the value of 283 // Takes in pairs of radio buttons and respective values and returns the value of
279 // the first found radio button that was checked. 284 // the first found radio button that was checked.
280 // ============================================================================= 285 // =============================================================================
281 template<class T> 286 template<class T>
282 T radioSwitch (const T& defval, QList<pair<QRadioButton*, T>> haystack) 287 T radioSwitch (const T& defval, QList<pair<QRadioButton*, T>> haystack)
283 { for (pair<QRadioButton*, const T&> i : haystack) 288 {
289 for (pair<QRadioButton*, const T&> i : haystack)
284 if (i.first->isChecked()) 290 if (i.first->isChecked())
285 return i.second; 291 return i.second;
286 292
287 return defval; 293 return defval;
288 } 294 }
292 // Takes in pairs of radio buttons and respective values and checks the first 298 // Takes in pairs of radio buttons and respective values and checks the first
293 // found radio button to have the given value. 299 // found radio button to have the given value.
294 // ============================================================================= 300 // =============================================================================
295 template<class T> 301 template<class T>
296 void radioDefault (const T& expr, QList<pair<QRadioButton*, T>> haystack) 302 void radioDefault (const T& expr, QList<pair<QRadioButton*, T>> haystack)
297 { for (pair<QRadioButton*, const T&> i : haystack) 303 {
298 { if (i.second == expr) 304 for (pair<QRadioButton*, const T&> i : haystack)
299 { i.first->setChecked (true); 305 {
306 if (i.second == expr)
307 {
308 i.first->setChecked (true);
300 return; 309 return;
301 } 310 }
302 } 311 }
303 } 312 }
304 313

mercurial