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);
136
137 /**--------------------------------------------------------------------------------------------------
138 Sets a callback for when the round "Main" button is pressed. The default behavior is to open the
139 "About" page. Will revert to default behavior if parameter is null.
140
141 Author: Tyler Parke
142
143 Date: 2020-05-21
144
145 Parameters:
146 main_callback - The callback for when the button is pressed.
147 **/
148 void setMainButtonCallback(const std::function<void(const PopupInfo&)>& main_callback);
149
150 /**--------------------------------------------------------------------------------------------------
151 Adds a widget to the left of the normal ribbon objects
152
153 Author: Tyler Parke
154
155 Date: 2023-01-16
156
157 Parameters:
158 widget - The widget to be added to the left of the normal ribbon objects
159 **/
160 void addLeftWidget(QWidget* widget);
161
162 /**--------------------------------------------------------------------------------------------------
163 Adds a widget to the right of the normal ribbon objects
164
165 Author: Tyler Parke
166
167 Date: 2023-01-16
168
169 Parameters:
170 widget - The widget to be added to the right of the normal ribbon objects
171 **/
172 void addRightWidget(QWidget* widget);
173
174 /**--------------------------------------------------------------------------------------------------
175 Gets the active options of the ribbon. Can be copied, modified and set with setRibbonOptions
176
177 Author: Tyler Parke
178
179 Date: 2023-01-16
180
181 \returns the active ribbon options
182 **/
183 const NDEVRRibbonOptions& options() const { return m_ribbon_options; };
184
185 /**--------------------------------------------------------------------------------------------------
186 Sets the ribbon options and immidiately refreshes the widget
187
188 Author: Tyler Parke
189
190 Date: 2023-01-16
191
192 Parameters:
193 options - The options to apply to the ribbon
194 **/
196
197 /**--------------------------------------------------------------------------------------------------
198 Gets the underlying ribbon object used for this widget
199
200 Author: Tyler Parke
201
202 Date: 2023-01-16
203
204 \returns a copy of the buffer.
205 **/
206 Ribbon* ribbon() const { return m_ribbon; }
207
208 /**--------------------------------------------------------------------------------------------------
209 Adds a button to the general/home tab. Button is disabled or enabled automatically based on the
210 disable_with_no_project flag
211
212 Author: Tyler Parke
213
214 Date: 2020-05-21
215
216 Parameters:
217 button - The button to add to the ribbon
218 disable_with_no_project - if true, button will be disabled until a project is loaded or created
219 **/
220 void addButtonToGeneralHome(Button* button, bool disable_with_no_project);
221
222 /**--------------------------------------------------------------------------------------------------
223 Adds a button to the general/file 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 addButtonToGeneralFile(Button* button, bool disable_with_no_project);
235
236 /**--------------------------------------------------------------------------------------------------
237 Gets the ribbon group for objects on the "home" tab
238
239 Author: Tyler Parke
240
241 Date: 2023-01-16
242
243 \returns the "home" tab ribbon group
244 **/
246
247 /**--------------------------------------------------------------------------------------------------
248 Gets the ribbon sub-group for objects on the "home/file" tab. Note buttons should be generally be
249 added with "addButtonToGeneralFile" and not this function
250
251 Author: Tyler Parke
252
253 Date: 2023-01-16
254
255 \returns the "home/file" tab ribbon subgroup
256 **/
258
259 /**--------------------------------------------------------------------------------------------------
260 Gets the ribbon sub-group for objects on the "home/general" tab. Note buttons should be generally be
261 added with "addButtonToGeneralHome" and not this function
262
263 Author: Tyler Parke
264
265 Date: 2023-01-16
266
267 \returns the "home/general" tab ribbon subgroup
268 **/
270
271 /**--------------------------------------------------------------------------------------------------
272 Gets the ribbon group for objects on the "edit" tab
273
274 Author: Tyler Parke
275
276 Date: 2023-01-16
277
278 \returns the "edit" tab ribbon group
279 **/
281
282 /**--------------------------------------------------------------------------------------------------
283 To be called by WindowManager when a scene is added or removed from the program
284
285 Author: Tyler Parke
286
287 Date: 2023-01-16
288
289 Parameters:
290 scene_visible - Whether the scene is visible
291 **/
292 void setSceneVisible(bool scene_visible);
293
294 /**--------------------------------------------------------------------------------------------------
295 To be called by WindowManager when UI is ready to be displayed
296
297 Author: Tyler Parke
298
299 Date: 2023-01-16
300 **/
301 void setup();
302
303 /**--------------------------------------------------------------------------------------------------
304 Defines whether buttons are layed out horizontally, or vertically. Typically called by windowmanager based
305 on application vertical or horizontal mode
306
307 Author: Tyler Parke
308
309 Date: 2020-05-21
310
311 Parameters:
312 is_vertical - Use to set whether or not the ribbon is vertical
313 **/
314 void setIsVertical(bool is_vertical);
315 protected:
317 void showHome(bool visible);
318 void showEdit(bool visible);
322 virtual bool processKeyEvent(const String& id, const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) override;
325 void showView(bool visible);
327 void showDraw(bool visible);
330 void showMeasure(bool visible);
332 protected slots:
333 void updateUndoRedoSlot(UUID last_command);
335 protected:
339 MainWindow* m_main_window;
345
346 RibbonGroup* m_home_ribbon_group = nullptr;
347 RibbonGroup* m_view_ribbon_group = nullptr;
348 RibbonGroup* m_edit_ribbon_group = nullptr;
349 RibbonGroup* m_draw_ribbon_group = nullptr;
350 RibbonGroup* m_measure_ribbon_group = nullptr;
351 RibbonSubGroup* m_home_file_subgroup = nullptr;
353 RibbonSubGroup* m_home_general_subgroup = nullptr;
355 Button* m_open_button = nullptr;
356 Button* m_import_file_button = nullptr;
357 Button* m_about_button = nullptr;
358 Button* m_main_icon_button = nullptr;
361 Button* m_undo_button = nullptr;
362 Button* m_settings_button = nullptr;
363 Button* m_project_settings_button = nullptr;
364 Button* m_redo_button = nullptr;
366 Button* m_save_button = nullptr;
367 Button* m_save_as_button = nullptr;
368 Button* m_export_button = nullptr;
369 Button* m_log_button = nullptr;
370 Button* m_project_browser = nullptr;
371 Button* m_generate_reports = nullptr;
372 Button* m_exit_button = nullptr;
373 Button* m_wifi_button = nullptr;
374 //Button* m_rotate_ui_button = nullptr;
375
379 std::function<void(const PopupInfo&)> m_main_button_callback;
383 protected:
384 class NDEVRRibbonWidget : public QWidget
385 {
386 public:
387 explicit NDEVRRibbonWidget(QWidget* parent = nullptr);
388 void setIsVertical(bool is_vertical) { m_is_vertical = is_vertical; };
389 QSize sizeHint() const override;
390 protected:
392 };
393 };
394}
#define NDEVR_API
Definition DLLInfo.h:50
The core class for assigning actions to key-presses and registering them as a program-wide service.
Definition KeyController.h:71
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A core widget that allows the user to click one of many button types.
Definition Button.h:66
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:49
A widget that allows the user to set or interface with the current layer.
Definition LayerWidget.h:88
Definition NDEVRRibbon.h:385
NDEVRRibbonWidget(QWidget *parent=nullptr)
bool m_is_vertical
Definition NDEVRRibbon.h:391
void setIsVertical(bool is_vertical)
Definition NDEVRRibbon.h:388
Definition NDEVRRibbon.h:130
Buffer< QWidget * > m_left_widgets
Definition NDEVRRibbon.h:343
RibbonGroup * drawRibbonGroup()
std::function< void(const PopupInfo &)> m_main_button_callback
Definition NDEVRRibbon.h:379
QWidget * m_main_button_widget
Definition NDEVRRibbon.h:342
Ribbon * ribbon() const
Definition NDEVRRibbon.h:206
void createDrawRibbonGroup()
QTResourceListener * m_command_listener
Definition NDEVRRibbon.h:377
RibbonGroup * measureRibbonGroup()
Buffer< Button * > m_buttons_to_add_to_home_file_subgroup
Definition NDEVRRibbon.h:352
NDEVRRibbon(WindowManager *window_manager, QTModelManager *manager, RibbonArea area)
RibbonGroup * editRibbonGroup()
const NDEVRRibbonOptions & options() const
Definition NDEVRRibbon.h:183
RibbonSubGroup * homeFileRibbonSubGroup()
RibbonSubGroup * homeGeneralRibbonSubGroup()
void addButtonToGeneralHome(Button *button, bool disable_with_no_project)
void showHome(bool visible)
bool m_is_vertical
Definition NDEVRRibbon.h:380
void showDraw(bool visible)
NDEVRRibbon(MainWindow *window, WindowManager *window_manager, QTModelManager *manager, RibbonArea area)
Buffer< Button * > m_buttons_to_add_to_home_general_subgroup
Definition NDEVRRibbon.h:354
bool m_scene_visible
Definition NDEVRRibbon.h:381
void setRibbonOptions(const NDEVRRibbonOptions &options)
void addLeftWidget(QWidget *widget)
void setSceneVisible(bool scene_visible)
LayerWidget * m_layer_tools_dock
Definition NDEVRRibbon.h:341
void resetKeyControllerToDefaults() override
Buffer< Button * > m_touch_theme_buttons
Definition NDEVRRibbon.h:365
void createEditRibbonGroup()
RibbonGroup * homeRibbonGroup()
Buffer< Button * > m_ui_theme_buttons
Definition NDEVRRibbon.h:360
Buffer< Button * > m_disable_with_no_project_buttons
Definition NDEVRRibbon.h:376
void setMainButtonCallback(const std::function< void(const PopupInfo &)> &main_callback)
NDEVRRibbonOptions m_ribbon_options
Definition NDEVRRibbon.h:382
Ribbon * m_ribbon
Definition NDEVRRibbon.h:336
void addRightWidget(QWidget *widget)
QTResourceListener * m_background_listener
Definition NDEVRRibbon.h:378
Buffer< Button * > m_window_theme_buttons
Definition NDEVRRibbon.h:359
SnapsEditorWidget * m_snaps_dock
Definition NDEVRRibbon.h:340
void setIsVertical(bool is_vertical)
void addButtonToGeneralFile(Button *button, bool disable_with_no_project)
WindowManager * m_window_manager
Definition NDEVRRibbon.h:338
QTModelManager * m_model_manager
Definition NDEVRRibbon.h:337
void showEdit(bool visible)
MainWindow * m_main_window
Definition NDEVRRibbon.h:339
Buffer< QWidget * > m_right_widgets
Definition NDEVRRibbon.h:344
RibbonGroup * viewRibbonGroup()
void showView(bool visible)
virtual bool processKeyEvent(const String &id, const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera) override
void showMeasure(bool visible)
void updateUndoRedoSlot(UUID last_command)
Provides a wrapper for a widget that can be docked inside a Container or floated as a top-level windo...
Definition QCustomDockWidget.h:61
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Definition QTModelManager.h:105
Definition QTTools.h:168
Represents the "Tab" of a widget. For example sections such as Home, View, Edit, Measurements would a...
Definition RibbonGroup.h:51
The UI ribbon is a horizontal menu bar typically located at the top of the application interface or a...
Definition Ribbon.h:54
Represents a sub-section of "Tab" of a ribbon represting a grouping of buttons or widgets within a ta...
Definition RibbonSubGroup.h:47
Definition SnapsEditorWidget.h:41
The core String class for the NDEVR API.
Definition String.h:69
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
Manages all windows and logic surrounding dialogs and views for displaying and managing any environme...
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
Requests a ribbon or tab area to be in a certain location and orientation relative to another widget.
Definition RibbonArea.h:71
Definition NDEVRRibbon.h:71
bool showFileActions() const
RibbonVisibleOption light_theme_visible
Definition NDEVRRibbon.h:90
RibbonVisibleOption view_actions_visible
Definition NDEVRRibbon.h:82
RibbonVisibleOption about_visible
Definition NDEVRRibbon.h:93
RibbonVisibleOption draw_actions_visible
Definition NDEVRRibbon.h:83
RibbonVisibleOption wifi_visible
Definition NDEVRRibbon.h:96
RibbonVisibleOption layers_visible
Definition NDEVRRibbon.h:86
bool showEditActions() const
RibbonVisibleOption measure_actions_visible
Definition NDEVRRibbon.h:85
bool showMeasureActions() const
RibbonVisibleOption reports_visible
Definition NDEVRRibbon.h:92
bool showHomeGeneral() const
bool showProjectBrowser() const
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
static bool ShouldShow(RibbonVisibleOption option, bool default_option)
RibbonVisibleOption main_button_visible
Definition NDEVRRibbon.h:87
RibbonVisibleOption file_actions_visible
Definition NDEVRRibbon.h:81
bool showViewActions() const
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
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
Class which is used to pass arguments and requests for creating a popup dialog or widget....
Definition PopupInfo.h:15