API Documentation
Loading...
Searching...
No Matches
NDEVRRibbon.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: NDEVRRibbon
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Ribbon.h>
35#include <NDEVR/KeyController.h>
36namespace NDEVR
37{
49 class QTModelManager;
50 class QTWindowManager;
51 class StatusBar;
52 class SnapsEditorWidget;
53 class LayerWidget;
54 class MainWindow;
55 class WindowManager;
56 class QTResourceListener;
57 class RibbonSubGroup;
58 class NDEVRRibbonWidget;
59
60 /**--------------------------------------------------------------------------------------------------
61 Struct: NDEVRRibbonOptions
62
63 The options for the Ribbon that typically appears on the top of the window or,
64 in touch mode, to the side of the window. Controls the behavior of the ribbon
65
66 Author: Tyler Parke
67
68 Date: 2023-01-16
69 *-----------------------------------------------------------------------------------------------**/
71 {
79
80 RibbonVisibleOption home_general_visible = RibbonVisibleOption::e_default;//Whether or not to show general settings on the home tab
81 RibbonVisibleOption file_actions_visible = RibbonVisibleOption::e_default;//Whether or not to show file settings on the home tab
82 RibbonVisibleOption view_actions_visible = RibbonVisibleOption::e_not_visible;//Whether or not to show view actions tab which controls aspects of the UI
83 RibbonVisibleOption draw_actions_visible = RibbonVisibleOption::e_default;//Whether or not to show draw actions tab (Note that draw functionality must be enabled)
84 RibbonVisibleOption edit_actions_visible = RibbonVisibleOption::e_default;//Whether or not to show draw edit actions tab (Note that draw functionality must be enabled)
85 RibbonVisibleOption measure_actions_visible = RibbonVisibleOption::e_default;//Whether or not to show measurement actions tab (Note that measure functionality must be enabled)
86 RibbonVisibleOption layers_visible = RibbonVisibleOption::e_default;//Whether or not to show layers (Note that layers functionality must be enabled)
87 RibbonVisibleOption main_button_visible = RibbonVisibleOption::e_default;//Whether or not to show rounded main button on the far left. Behavior of this button can be set with setMainButtonCallback
89 RibbonVisibleOption save_as_visible = RibbonVisibleOption::e_default;//Whether or not to show save-as button
90 RibbonVisibleOption light_theme_visible = RibbonVisibleOption::e_default;//Whether or not to show color theme button which changes how the application looks
91 RibbonVisibleOption touch_theme_visible = RibbonVisibleOption::e_default;//When appropriate shows the touch theme button which changes the applicaiton mode of the application
92 RibbonVisibleOption reports_visible = RibbonVisibleOption::e_default;//Whether or not to showreports button which brings up reports manager for creating reports
93 RibbonVisibleOption about_visible = RibbonVisibleOption::e_default;//Whether or not to show about button which brings up information about the application such as build number and manuals.
94 RibbonVisibleOption project_browser_visible = RibbonVisibleOption::e_default;//Whether or not to show browse button which brings up the native file browser next to the project.
95 RibbonVisibleOption log_visible = RibbonVisibleOption::e_default;//Whether or not to show log button to bring up application logs dialog
97 RibbonVisibleOption exit_visible = RibbonVisibleOption::e_default;//Whether or not to show close button which exits the application
98 bool showHomeGeneral() const;
99 bool showFileActions() const;
100 bool showDrawActions() const;
101 bool showEditActions() const;
102 bool showMeasureActions() const;
103 bool showViewActions() const;
104 bool showMainButton() const;
105 bool showReports() const;
106 bool showExit() const;
107 bool showLayers() const;
108 bool showWifi() const;
109 bool showLog() const;
110 bool showSave() const;
111 bool showSaveAs() const;
112 bool showColorTheme() const;
113 bool showProjectBrowser() const;
114 bool showAbout() const;
115 bool showWidgetMode() const;
116 static bool ShouldShow(RibbonVisibleOption option, bool default_option);
117 };
118
119 /**--------------------------------------------------------------------------------------------------
120 Class: NDEVRRibbon
121
122 The Ribbon that typically appears on the top of the window or, in touch mode, to the side of the window.
123 Contains high level buttons and widgets for the application.
124
125 Author: Tyler Parke
126
127 Date: 2023-01-16
128 *-----------------------------------------------------------------------------------------------**/
130 {
131 Q_OBJECT
132 public:
133 NDEVRRibbon(MainWindow* window, WindowManager* window_manager, QTModelManager* manager, RibbonArea area);
134 NDEVRRibbon(WindowManager* window_manager, QTModelManager* manager, RibbonArea area);
135 ~NDEVRRibbon();
136
137 /**--------------------------------------------------------------------------------------------------
138 Fn: void NDEVRRibbon::setMainButtonCallback(const std::function<void(const PopupInfo&)>& main_callback)
139
140 Sets a callback for when the round "Main" button is pressed. The default behavior is to open the
141 "About" page. Will revert to default behavior if parameter is null.
142
143 Author: Tyler Parke
144
145 Date: 2020-05-21
146
147 Parameters:
148 main_callback - The callback for when the button is pressed.
149 *-----------------------------------------------------------------------------------------------**/
150 void setMainButtonCallback(const std::function<void(const PopupInfo&)>& main_callback);
151
152 /**--------------------------------------------------------------------------------------------------
153 Fn: void NDEVRRibbon::addLeftWidget(QWidget* widget)
154
155 Adds a widget to the left of the normal ribbon objects
156
157 Author: Tyler Parke
158
159 Date: 2023-01-16
160
161 Parameters:
162 widget - The widget to be added to the left of the normal ribbon objects
163 *-----------------------------------------------------------------------------------------------**/
164 void addLeftWidget(QWidget* widget);
165
166 /**--------------------------------------------------------------------------------------------------
167 Fn: void NDEVRRibbon::addRightWidget(QWidget* widget)
168
169 Adds a widget to the right of the normal ribbon objects
170
171 Author: Tyler Parke
172
173 Date: 2023-01-16
174
175 Parameters:
176 widget - The widget to be added to the right of the normal ribbon objects
177 *-----------------------------------------------------------------------------------------------**/
178 void addRightWidget(QWidget* widget);
179
180 /**--------------------------------------------------------------------------------------------------
181 Fn: const NDEVRRibbonOptions& NDEVRRibbon::options() const
182
183 Gets the active options of the ribbon. Can be copied, modified and set with setRibbonOptions
184
185 Author: Tyler Parke
186
187 Date: 2023-01-16
188
189 Returns: the active ribbon options
190 *-----------------------------------------------------------------------------------------------**/
191 const NDEVRRibbonOptions& options() const { return m_ribbon_options; };
192
193 /**--------------------------------------------------------------------------------------------------
194 Fn: void NDEVRRibbon::setRibbonOptions(const NDEVRRibbonOptions& options)
195
196 Sets the ribbon options and immidiately refreshes the widget
197
198 Author: Tyler Parke
199
200 Date: 2023-01-16
201
202 Parameters:
203 options - The options to apply to the ribbon
204 *-----------------------------------------------------------------------------------------------**/
205 void setRibbonOptions(const NDEVRRibbonOptions& options);
206
207 /**--------------------------------------------------------------------------------------------------
208 Fn: Ribbon* NDEVRRibbon::ribbon() const
209
210 Gets the underlying ribbon object used for this widget
211
212 Author: Tyler Parke
213
214 Date: 2023-01-16
215
216 Returns: a copy of the buffer.
217 *-----------------------------------------------------------------------------------------------**/
218 Ribbon* ribbon() const { return m_ribbon; }
219
220 /**--------------------------------------------------------------------------------------------------
221 Fn: void NDEVRRibbon::addButtonToGeneralFile(Button* button, bool disable_with_no_project)
222
223 Adds a button to the general/home tab. Button is disabled or enabled automatically based on the
224 disable_with_no_project flag
225
226 Author: Tyler Parke
227
228 Date: 2020-05-21
229
230 Parameters:
231 button - The button to add to the ribbon
232 disable_with_no_project - if true, button will be disabled until a project is loaded or created
233 *-----------------------------------------------------------------------------------------------**/
234 void addButtonToGeneralHome(Button* button, bool disable_with_no_project);
235
236 /**--------------------------------------------------------------------------------------------------
237 Fn: void NDEVRRibbon::addButtonToGeneralFile(Button* button, bool disable_with_no_project)
238
239 Adds a button to the general/file tab. Button is disabled or enabled automatically based on the
240 disable_with_no_project flag
241
242 Author: Tyler Parke
243
244 Date: 2020-05-21
245
246 Parameters:
247 button - The button to add to the ribbon
248 disable_with_no_project - if true, button will be disabled until a project is loaded or created
249 *-----------------------------------------------------------------------------------------------**/
250 void addButtonToGeneralFile(Button* button, bool disable_with_no_project);
251
252 /**--------------------------------------------------------------------------------------------------
253 Fn: RibbonGroup* NDEVRRibbon::homeRibbonGroup() const
254
255 Gets the ribbon group for objects on the "home" tab
256
257 Author: Tyler Parke
258
259 Date: 2023-01-16
260
261 Returns: the "home" tab ribbon group
262 *-----------------------------------------------------------------------------------------------**/
263 RibbonGroup* homeRibbonGroup();
264
265 /**--------------------------------------------------------------------------------------------------
266 Fn: RibbonSubGroup* NDEVRRibbon::homeFileRibbonSubGroup() const
267
268 Gets the ribbon sub-group for objects on the "home/file" tab. Note buttons should be generally be
269 added with "addButtonToGeneralFile" and not this function
270
271 Author: Tyler Parke
272
273 Date: 2023-01-16
274
275 Returns: the "home/file" tab ribbon subgroup
276 *-----------------------------------------------------------------------------------------------**/
277 RibbonSubGroup* homeFileRibbonSubGroup();
278
279 /**--------------------------------------------------------------------------------------------------
280 Fn: RibbonSubGroup* NDEVRRibbon::homeGeneralRibbonSubGroup() const
281
282 Gets the ribbon sub-group for objects on the "home/general" tab. Note buttons should be generally be
283 added with "addButtonToGeneralHome" and not this function
284
285 Author: Tyler Parke
286
287 Date: 2023-01-16
288
289 Returns: the "home/general" tab ribbon subgroup
290 *-----------------------------------------------------------------------------------------------**/
291 RibbonSubGroup* homeGeneralRibbonSubGroup();
292
293 /**--------------------------------------------------------------------------------------------------
294 Fn: RibbonGroup* NDEVRRibbon::homeRibbonGroup() const
295
296 Gets the ribbon group for objects on the "edit" tab
297
298 Author: Tyler Parke
299
300 Date: 2023-01-16
301
302 Returns: the "edit" tab ribbon group
303 *-----------------------------------------------------------------------------------------------**/
304 RibbonGroup* editRibbonGroup();
305
306 /**--------------------------------------------------------------------------------------------------
307 Fn: void NDEVRRibbon::setSceneVisible(bool visible)
308
309 To be called by WindowManager when a scene is added or removed from the program
310
311 Author: Tyler Parke
312
313 Date: 2023-01-16
314
315 Parameters:
316 scene_visible - Whether the scene is visible
317 *-----------------------------------------------------------------------------------------------**/
318 void setSceneVisible(bool scene_visible);
319
320 /**--------------------------------------------------------------------------------------------------
321 Fn: void NDEVRRibbon::setup()
322
323 To be called by WindowManager when UI is ready to be displayed
324
325 Author: Tyler Parke
326
327 Date: 2023-01-16
328 *-----------------------------------------------------------------------------------------------**/
329 void setup();
330
331 /**--------------------------------------------------------------------------------------------------
332 Fn: void NDEVRRibbon::setMainButtonCallback(const std::function<void(const PopupInfo&)>& main_callback)
333
334 Defines whether buttons are layed out horizontally, or vertically. Typically called by windowmanager based
335 on application vertical or horizontal mode
336
337 Author: Tyler Parke
338
339 Date: 2020-05-21
340
341 Parameters:
342 is_vertical - Use to set whether or not the ribbon is vertical
343 *-----------------------------------------------------------------------------------------------**/
344 void setIsVertical(bool is_vertical);
345 protected:
346 void initializeRibbon();
347 void showHome(bool visible);
348 void showEdit(bool visible);
349 void updateButtonStates();
350 void refreshWidget();
351 void retranslate();
352 virtual bool processKeyEvent(const String& id, const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) override;
353 void resetKeyControllerToDefaults() override;
354 void createEditRibbonGroup();
355 void showView(bool visible);
356 RibbonGroup* viewRibbonGroup();
357 void showDraw(bool visible);
358 RibbonGroup* drawRibbonGroup();
359 void createDrawRibbonGroup();
360 void showMeasure(bool visible);
361 RibbonGroup* measureRibbonGroup();
362 protected slots:
363 void updateUndoRedoSlot(UUID last_command);
364 void onClearAllSlot();
365 protected:
369 MainWindow* m_main_window;
375
376 RibbonGroup* m_home_ribbon_group = nullptr;
377 RibbonGroup* m_view_ribbon_group = nullptr;
378 RibbonGroup* m_edit_ribbon_group = nullptr;
379 RibbonGroup* m_draw_ribbon_group = nullptr;
380 RibbonGroup* m_measure_ribbon_group = nullptr;
381 RibbonSubGroup* m_home_file_subgroup = nullptr;
383 RibbonSubGroup* m_home_general_subgroup = nullptr;
385 Button* m_open_button = nullptr;
386 Button* m_import_file_button = nullptr;
387 Button* m_about_button = nullptr;
388 Button* m_main_icon_button = nullptr;
391 Button* m_undo_button = nullptr;
392 Button* m_settings_button = nullptr;
393 Button* m_project_settings_button = nullptr;
394 Button* m_redo_button = nullptr;
396 Button* m_save_button = nullptr;
397 Button* m_save_as_button = nullptr;
398 Button* m_export_button = nullptr;
399 Button* m_log_button = nullptr;
400 Button* m_project_browser = nullptr;
401 Button* m_generate_reports = nullptr;
402 Button* m_exit_button = nullptr;
403 Button* m_wifi_button = nullptr;
404 //Button* m_rotate_ui_button = nullptr;
405
409 std::function<void(const PopupInfo&)> m_main_button_callback;
413 protected:
414 class NDEVRRibbonWidget : public QWidget
415 {
416 public:
417 explicit NDEVRRibbonWidget(QWidget* parent = nullptr);
418 void setIsVertical(bool is_vertical) { m_is_vertical = is_vertical; };
419 QSize sizeHint() const override;
420 protected:
422 };
423 };
424}
#define NDEVR_API
Definition DLLInfo.h:67
The core class for assigning actions to key-presses and registering them as a program-wide service.
Definition KeyController.h:65
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
Definition Button.h:60
A core class where all Design Objects including models, materials, and geometries are stored.
Definition DesignObjectLookup.h:65
A class which describes a user key press.
Definition Event.h:47
Definition LayerWidget.h:79
Definition NDEVRRibbon.h:415
bool m_is_vertical
Definition NDEVRRibbon.h:421
void setIsVertical(bool is_vertical)
Definition NDEVRRibbon.h:418
Definition NDEVRRibbon.h:130
Buffer< QWidget * > m_left_widgets
Definition NDEVRRibbon.h:373
std::function< void(const PopupInfo &)> m_main_button_callback
Definition NDEVRRibbon.h:409
QWidget * m_main_button_widget
Definition NDEVRRibbon.h:372
Ribbon * ribbon() const
Definition NDEVRRibbon.h:218
QTResourceListener * m_command_listener
Definition NDEVRRibbon.h:407
Buffer< Button * > m_buttons_to_add_to_home_file_subgroup
Definition NDEVRRibbon.h:382
const NDEVRRibbonOptions & options() const
Definition NDEVRRibbon.h:191
bool m_is_vertical
Definition NDEVRRibbon.h:410
Buffer< Button * > m_buttons_to_add_to_home_general_subgroup
Definition NDEVRRibbon.h:384
bool m_scene_visible
Definition NDEVRRibbon.h:411
LayerWidget * m_layer_tools_dock
Definition NDEVRRibbon.h:371
Buffer< Button * > m_touch_theme_buttons
Definition NDEVRRibbon.h:395
Buffer< Button * > m_ui_theme_buttons
Definition NDEVRRibbon.h:390
Buffer< Button * > m_disable_with_no_project_buttons
Definition NDEVRRibbon.h:406
NDEVRRibbonOptions m_ribbon_options
Definition NDEVRRibbon.h:412
Ribbon * m_ribbon
Definition NDEVRRibbon.h:366
QTResourceListener * m_background_listener
Definition NDEVRRibbon.h:408
Buffer< Button * > m_window_theme_buttons
Definition NDEVRRibbon.h:389
SnapsEditorWidget * m_snaps_dock
Definition NDEVRRibbon.h:370
WindowManager * m_window_manager
Definition NDEVRRibbon.h:368
QTModelManager * m_model_manager
Definition NDEVRRibbon.h:367
MainWindow * m_main_window
Definition NDEVRRibbon.h:369
Buffer< QWidget * > m_right_widgets
Definition NDEVRRibbon.h:374
Definition QCustomDockWidget.h:57
Definition QTModelManager.h:94
Definition QTTools.h:183
Definition RibbonGroup.h:47
Definition Ribbon.h:47
Definition RibbonSubGroup.h:43
Definition SnapsEditorWidget.h:41
The core String class for the software.
Definition String.h:47
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:62
Definition WindowManager.h:68
Definition ACIColor.h:37
NDEVRRibbonAction
Definition NDEVRRibbon.h:39
@ e_undo
Definition NDEVRRibbon.h:43
@ e_settings
Definition NDEVRRibbon.h:46
@ e_save_file
Definition NDEVRRibbon.h:40
@ e_redo
Definition NDEVRRibbon.h:44
@ e_open_project
Definition NDEVRRibbon.h:42
@ e_help
Definition NDEVRRibbon.h:45
@ e_save_as_file
Definition NDEVRRibbon.h:41
@ e_ribbon_action_size
Definition NDEVRRibbon.h:47
RibbonArea
Definition RibbonArea.h:68
Definition NDEVRRibbon.h:71
bool showFileActions() const
Definition NDEVRRibbon.cpp:1090
RibbonVisibleOption light_theme_visible
Definition NDEVRRibbon.h:90
RibbonVisibleOption view_actions_visible
Definition NDEVRRibbon.h:82
bool showWifi() const
Definition NDEVRRibbon.cpp:1129
NDEVRRibbonOptions()
Definition NDEVRRibbon.cpp:1081
RibbonVisibleOption about_visible
Definition NDEVRRibbon.h:93
RibbonVisibleOption draw_actions_visible
Definition NDEVRRibbon.h:83
bool showAbout() const
Definition NDEVRRibbon.cpp:1155
bool showMainButton() const
Definition NDEVRRibbon.cpp:1110
bool showLog() const
Definition NDEVRRibbon.cpp:1134
bool showReports() const
Definition NDEVRRibbon.cpp:1114
RibbonVisibleOption wifi_visible
Definition NDEVRRibbon.h:96
RibbonVisibleOption layers_visible
Definition NDEVRRibbon.h:86
bool showEditActions() const
Definition NDEVRRibbon.cpp:1098
RibbonVisibleOption measure_actions_visible
Definition NDEVRRibbon.h:85
bool showMeasureActions() const
Definition NDEVRRibbon.cpp:1102
RibbonVisibleOption reports_visible
Definition NDEVRRibbon.h:92
bool showHomeGeneral() const
Definition NDEVRRibbon.cpp:1086
static bool ShouldShow(RibbonVisibleOption option, bool default_option)
Definition NDEVRRibbon.cpp:1163
bool showProjectBrowser() const
Definition NDEVRRibbon.cpp:1151
bool showColorTheme() const
Definition NDEVRRibbon.cpp:1147
RibbonVisibleOption log_visible
Definition NDEVRRibbon.h:95
RibbonVisibleOption touch_theme_visible
Definition NDEVRRibbon.h:91
RibbonVisibleOption save_visible
Definition NDEVRRibbon.h:88
RibbonVisibleOption save_as_visible
Definition NDEVRRibbon.h:89
RibbonVisibleOption main_button_visible
Definition NDEVRRibbon.h:87
RibbonVisibleOption file_actions_visible
Definition NDEVRRibbon.h:81
bool showViewActions() const
Definition NDEVRRibbon.cpp:1106
bool showWidgetMode() const
Definition NDEVRRibbon.cpp:1159
RibbonVisibleOption
Definition NDEVRRibbon.h:73
@ e_visible
Definition NDEVRRibbon.h:74
@ e_default
Definition NDEVRRibbon.h:76
@ e_not_visible
Definition NDEVRRibbon.h:75
RibbonVisibleOption home_general_visible
Definition NDEVRRibbon.h:80
bool showSaveAs() const
Definition NDEVRRibbon.cpp:1143
bool showExit() const
Definition NDEVRRibbon.cpp:1119
bool showLayers() const
Definition NDEVRRibbon.cpp:1124
bool showSave() const
Definition NDEVRRibbon.cpp:1139
RibbonVisibleOption project_browser_visible
Definition NDEVRRibbon.h:94
RibbonVisibleOption edit_actions_visible
Definition NDEVRRibbon.h:84
RibbonVisibleOption exit_visible
Definition NDEVRRibbon.h:97
bool showDrawActions() const
Definition NDEVRRibbon.cpp:1094
Definition PopupInfo.h:10