NDEVR
API Documentation
NDEVRRibbon.h
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{
52 class QTModelManager;
53 class QTWindowManager;
54 class StatusBar;
55 class SnapsEditorWidget;
56 class LayerWidget;
57 class MainWindow;
58 class WindowManager;
59 class QTResourceListener;
60 class RibbonSubGroup;
61 class NDEVRRibbonWidget;
62
73 struct NDEVRRibbonOptions
74 {
85
104 bool showHomeGeneral() const;
106 bool showFileActions() const;
108 bool showDrawActions() const;
110 bool showEditActions() const;
112 bool showMeasureActions() const;
114 bool showViewActions() const;
116 bool showMainButton() const;
118 bool showExit() const;
120 bool showLayers() const;
122 bool showWifi() const;
124 bool showLog() const;
126 bool showSave() const;
128 bool showSaveAs() const;
130 bool showColorTheme() const;
132 bool showProjectBrowser() const;
134 bool showAbout() const;
136 bool showWidgetMode() const;
143 static bool ShouldShow(RibbonVisibleOption option, bool default_option);
144 };
145
154 class NDEVR_API NDEVRRibbon : public QCustomDockWidget, public BasicKeyController
155 {
156 Q_OBJECT
157 public:
165 NDEVRRibbon(MainWindow* window, WindowManager* window_manager, QTModelManager* manager, RibbonArea area);
172 NDEVRRibbon(WindowManager* window_manager, QTModelManager* manager, RibbonArea area);
173 ~NDEVRRibbon();
174
186 void setMainButtonCallback(const std::function<void(const PopupInfo&)>& main_callback);
187
198 void addLeftWidget(QWidget* widget);
199
210 void addRightWidget(QWidget* widget);
211
221 const NDEVRRibbonOptions& options() const { return m_ribbon_options; };
222
234
244 Ribbon* ribbon() const { return m_ribbon; }
245
258 void addButtonToGeneralHome(Button* button, bool disable_with_no_project);
259
272 void addButtonToGeneralFile(Button* button, bool disable_with_no_project);
273
284
296
308
319
330 void setSceneVisible(bool scene_visible);
331
339 void setup();
340
352 void setIsVertical(bool is_vertical);
353 protected:
357 void showHome(bool visible);
359 void showEdit(bool visible);
366 virtual bool processKeyEvent(const StringView& id, const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) override;
371 void showView(bool visible);
375 void showDraw(bool visible);
381 void showMeasure(bool visible);
384 protected slots:
386 void updateUndoRedoSlot(UUID last_command);
389 protected:
390 Ribbon* m_ribbon = nullptr;
396 QWidget* m_main_button_widget = nullptr;
399
423 Button* m_log_button = nullptr;
427 //Button* m_rotate_ui_button = nullptr;
428
432 std::function<void(const PopupInfo&)> m_main_button_callback;
433 bool m_is_vertical = false;
434 bool m_scene_visible = false;
436 protected:
440 class NDEVRRibbonWidget : public QWidget
441 {
442 public:
443 explicit NDEVRRibbonWidget(QWidget* parent = nullptr);
444 void setIsVertical(bool is_vertical) { m_is_vertical = is_vertical; };
445 QSize sizeHint() const override;
446 protected:
448 };
449 };
450}
BasicKeyController(const TranslatedString &key_controller_title)
Constructs a BasicKeyController with the given title.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
A core object representing a user view as well as convenience functions for moving this view through ...
Definition Camera.h:95
A core class where all Design Objects including models, materials, and geometries are stored.
Describes a user key press event used to trigger behavior in the NDEVR API.
Definition Event.h:49
A widget that allows the user to set or interface with the current layer.
Definition LayerWidget.h:51
The primary Window within the NDEVR API.
Definition MainWindow.h:69
bool m_is_vertical
Whether the ribbon widget is in vertical layout mode.
QTResourceListener * m_command_listener
Listener for command history resource changes.
void showHome(bool visible)
Shows or hides the home ribbon tab.
Buffer< QPointer< Button > > m_disable_with_no_project_buttons
Buttons that should be disabled when no project is loaded.
Buffer< Button * > m_window_theme_buttons
Buttons for switching window color themes.
RibbonGroup * homeRibbonGroup()
Gets the ribbon group for objects on the "home" tab.
SnapsEditorWidget * m_snaps_dock
The snap settings editor dock widget.
void addLeftWidget(QWidget *widget)
Adds a widget to the left of the normal ribbon objects.
NDEVRRibbon(MainWindow *window, WindowManager *window_manager, QTModelManager *manager, RibbonArea area)
Constructs the ribbon attached to a main window.
Button * m_log_button
The application log button.
Ribbon * m_ribbon
The underlying ribbon widget.
void showEdit(bool visible)
Shows or hides the edit ribbon tab.
bool m_is_vertical
Whether the ribbon is in vertical layout mode.
RibbonGroup * viewRibbonGroup()
Gets or creates the view ribbon group.
bool m_scene_visible
Whether a 3D scene is currently visible.
Button * m_wifi_button
The wifi status/settings button.
QTResourceListener * m_background_listener
Listener for background task resource changes.
RibbonGroup * m_home_ribbon_group
The home tab ribbon group.
RibbonGroup * editRibbonGroup()
Gets the ribbon group for objects on the "edit" tab.
Button * m_settings_button
The application settings button.
Button * m_save_button
The save button.
RibbonGroup * drawRibbonGroup()
Gets or creates the draw ribbon group.
Button * m_main_icon_button
The main application icon button.
WindowManager * m_window_manager
The window manager for UI coordination.
NDEVRRibbonOptions m_ribbon_options
The current ribbon visibility options.
Button * m_redo_button
The redo button.
Buffer< Button * > m_buttons_to_add_to_home_general_subgroup
Buttons queued for adding to the home/general subgroup.
RibbonSubGroup * homeGeneralRibbonSubGroup()
Gets the ribbon sub-group for objects on the "home/general" tab.
Button * m_project_settings_button
The project settings button.
RibbonSubGroup * homeFileRibbonSubGroup()
Gets the ribbon sub-group for objects on the "home/file" tab.
void setup()
To be called by WindowManager when UI is ready to be displayed.
Button * m_export_button
The export button.
void setRibbonOptions(const NDEVRRibbonOptions &options)
Sets the ribbon options and immediately refreshes the widget.
void resetKeyControllerToDefaults() override
Resets all key mappings to their default values.
MainWindow * m_main_window
The main application window.
Button * m_about_button
The about/info button.
Button * m_project_browser
The project file browser button.
void onClearAllSlot()
Handles clearing all project data.
RibbonGroup * measureRibbonGroup()
Gets or creates the measure ribbon group.
void showDraw(bool visible)
Shows or hides the draw ribbon tab.
Button * m_open_button
The open project button.
void setSceneVisible(bool scene_visible)
To be called by WindowManager when a scene is added or removed from the program.
void setIsVertical(bool is_vertical)
Defines whether buttons are layed out horizontally, or vertically.
std::function< void(const PopupInfo &)> m_main_button_callback
Custom callback for the main button press.
void addButtonToGeneralFile(Button *button, bool disable_with_no_project)
Adds a button to the general/file tab.
const NDEVRRibbonOptions & options() const
Gets the active options of the ribbon.
LayerWidget * m_layer_tools_dock
The layer tools dock widget.
Ribbon * ribbon() const
Gets the underlying ribbon object used for this widget.
RibbonGroup * m_view_ribbon_group
The view tab ribbon group.
Button * m_save_as_button
The save-as button.
Buffer< QWidget * > m_left_widgets
Widgets added to the left side of the ribbon.
void addButtonToGeneralHome(Button *button, bool disable_with_no_project)
Adds a button to the general/home tab.
void initializeRibbon()
Creates and initializes all ribbon groups, buttons, and layout.
Buffer< QWidget * > m_right_widgets
Widgets added to the right side of the ribbon.
Button * m_exit_button
The exit application button.
RibbonGroup * m_measure_ribbon_group
The measure tab ribbon group.
QTModelManager * m_model_manager
The model manager for accessing design data.
QWidget * m_main_button_widget
The container widget for the main icon button.
Button * m_undo_button
The undo button.
void showMeasure(bool visible)
Shows or hides the measure ribbon tab.
RibbonSubGroup * m_home_file_subgroup
The file subgroup within the home tab.
void showView(bool visible)
Shows or hides the view ribbon tab.
Buffer< Button * > m_buttons_to_add_to_home_file_subgroup
Buttons queued for adding to the home/file subgroup.
Buffer< Button * > m_ui_theme_buttons
Buttons for switching UI themes.
void updateButtonStates()
Updates enabled/disabled states of all buttons based on current application state.
Buffer< Button * > m_touch_theme_buttons
Buttons for switching touch/desktop mode.
void createEditRibbonGroup()
Creates the edit ribbon group and populates it with edit action buttons.
void addRightWidget(QWidget *widget)
Adds a widget to the right of the normal ribbon objects.
RibbonGroup * m_draw_ribbon_group
The draw tab ribbon group.
void createDrawRibbonGroup()
Creates the draw ribbon group and populates it with drawing action buttons.
void setMainButtonCallback(const std::function< void(const PopupInfo &)> &main_callback)
Sets a callback for when the round "Main" button is pressed.
RibbonGroup * m_edit_ribbon_group
The edit tab ribbon group.
void refreshWidget()
Refreshes the widget layout and visibility based on current options.
RibbonSubGroup * m_home_general_subgroup
The general subgroup within the home tab.
void retranslate()
Retranslates all UI text for the current locale.
Button * m_import_file_button
The import file button.
virtual bool processKeyEvent(const StringView &id, const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera) override
Processes a key event identified by its string ID.
NDEVRRibbon(WindowManager *window_manager, QTModelManager *manager, RibbonArea area)
Constructs the ribbon without a main window reference.
void updateUndoRedoSlot(UUID last_command)
Updates the undo/redo button states when the command history changes.
QCustomDockWidget(RibbonArea ribbon_area, ContainerWidgetBase *container=nullptr)
Constructs a dock widget with a specified ribbon area and optional container.
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
A ResourceListener which will always be executed on the main UI thread and can be tied to a Qt Object...
Definition QTTools.h:493
Represents the "Tab" of a widget.
Definition RibbonGroup.h:52
Represents a sub-section of "Tab" of a ribbon representing a grouping of buttons or widgets within a ...
The UI ribbon is a horizontal menu bar typically located at the top of the application interface or a...
Definition Ribbon.h:56
A ribbon sub-group widget that allows the user to configure snap settings such as endpoint,...
The core String View class for the NDEVR API.
Definition StringView.h:58
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
Manages all windows and logic surrounding dialogs and views for displaying and managing any environme...
The primary namespace for the NDEVR SDK.
NDEVRRibbonAction
Enumerates the standard ribbon actions available in the NDEVR application.
Definition NDEVRRibbon.h:42
@ e_settings
Open the settings dialog.
Definition NDEVRRibbon.h:49
@ e_save_file
Save the current project file.
Definition NDEVRRibbon.h:43
@ e_save_as_file
Save the current project to a new file.
Definition NDEVRRibbon.h:44
@ e_help
Show help information.
Definition NDEVRRibbon.h:48
@ e_open_project
Open an existing project.
Definition NDEVRRibbon.h:45
@ e_ribbon_action_size
The number of ribbon actions.
Definition NDEVRRibbon.h:50
@ e_redo
Redo the last undone operation.
Definition NDEVRRibbon.h:47
@ e_undo
Undo the last operation.
Definition NDEVRRibbon.h:46
RibbonArea
Requests a ribbon or tab area to be in a certain location and orientation relative to another widget.
Definition RibbonArea.h:71
RibbonVisibleOption wifi_visible
Whether or not to show the wifi button.
bool showLog() const
Whether the log button should be shown.
RibbonVisibleOption main_button_visible
Whether or not to show the rounded main button on the far left.
Definition NDEVRRibbon.h:93
bool showHomeGeneral() const
Whether the home/general ribbon section should be shown.
RibbonVisibleOption save_visible
Whether or not to show the save button.
Definition NDEVRRibbon.h:94
RibbonVisibleOption edit_actions_visible
Whether or not to show draw edit actions tab (Note that draw functionality must be enabled).
Definition NDEVRRibbon.h:90
bool showLayers() const
Whether the layers section should be shown.
bool showExit() const
Whether the exit button should be shown.
bool showDrawActions() const
Whether the draw actions ribbon tab should be shown.
RibbonVisibleOption exit_visible
Whether or not to show the close/exit button.
bool showMainButton() const
Whether the main icon button should be shown.
RibbonVisibleOption measure_actions_visible
Whether or not to show measurement actions tab (Note that measure functionality must be enabled).
Definition NDEVRRibbon.h:91
RibbonVisibleOption about_visible
Whether or not to show the about button with application information.
Definition NDEVRRibbon.h:98
bool showAbout() const
Whether the about button should be shown.
RibbonVisibleOption save_as_visible
Whether or not to show the save-as button.
Definition NDEVRRibbon.h:95
RibbonVisibleOption touch_theme_visible
Whether or not to show the touch theme button which changes the application mode.
Definition NDEVRRibbon.h:97
RibbonVisibleOption project_browser_visible
Whether or not to show the browse button for the native file browser.
Definition NDEVRRibbon.h:99
RibbonVisibleOption view_actions_visible
Whether or not to show view actions tab which controls aspects of the UI.
Definition NDEVRRibbon.h:88
RibbonVisibleOption home_general_visible
Whether or not to show general settings on the home tab.
Definition NDEVRRibbon.h:86
bool showSaveAs() const
Whether the save-as button should be shown.
bool showSave() const
Whether the save button should be shown.
RibbonVisibleOption
Controls whether a ribbon element is visible, hidden, or uses the default behavior.
Definition NDEVRRibbon.h:79
@ e_default
The element uses the default visibility based on application state.
Definition NDEVRRibbon.h:82
@ e_visible
The element is always visible.
Definition NDEVRRibbon.h:80
@ e_not_visible
The element is always hidden.
Definition NDEVRRibbon.h:81
bool showWifi() const
Whether the wifi button should be shown.
RibbonVisibleOption layers_visible
Whether or not to show layers (Note that layers functionality must be enabled).
Definition NDEVRRibbon.h:92
bool showViewActions() const
Whether the view actions ribbon tab should be shown.
static bool ShouldShow(RibbonVisibleOption option, bool default_option)
Determines whether a ribbon element should be shown given its option and the default.
RibbonVisibleOption file_actions_visible
Whether or not to show file settings on the home tab.
Definition NDEVRRibbon.h:87
bool showEditActions() const
Whether the edit actions ribbon tab should be shown.
bool showWidgetMode() const
Whether the widget mode toggle should be shown.
bool showProjectBrowser() const
Whether the project browser button should be shown.
bool showMeasureActions() const
Whether the measure actions ribbon tab should be shown.
RibbonVisibleOption log_visible
Whether or not to show the log button for application logs.
bool showColorTheme() const
Whether the color theme toggle should be shown.
bool showFileActions() const
Whether the file actions ribbon section should be shown.
RibbonVisibleOption draw_actions_visible
Whether or not to show draw actions tab (Note that draw functionality must be enabled).
Definition NDEVRRibbon.h:89
RibbonVisibleOption light_theme_visible
Whether or not to show the color theme button.
Definition NDEVRRibbon.h:96
Class which is used to pass arguments and requests for creating a popup dialog or widget.
Definition PopupInfo.h:16