NDEVR
API Documentation
RibbonGroup.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: RibbonGroup
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/RibbonLayoutMode.h>
35#include <NDEVR/Buffer.h>
36#include <NDEVR/String.h>
37#include <NDEVR/Dictionary.h>
38#include <QWidget>
39#include <QBoxLayout>
40class QFrame;
41namespace NDEVR
42{
43 class QCustomLabel;
44 class RibbonSubGroup;
45 class TranslatedString;
51 class NDEVR_WIDGETS_API RibbonGroup : public QWidget
52 {
53 Q_OBJECT
54 public:
59 RibbonGroup(QWidget* parent = nullptr);
70 void addSubGroup(QWidget* sub_group);
81 QSize minimumSizeHint() const override;
87 bool hasSubGroup(const TranslatedString& sub_group) const;
92 void removeSubGroup(const TranslatedString& sub_group);
113 int marginThickness() const;
114 bool event(QEvent* ev) override;
119 int largeButtonWidth() const;
124 int mediumButtonWidth() const;
133 bool isEmpty() const;
143 void setupSeparator(QFrame* seperator) const;
153 void setNumberOfRows(uint04 number_of_rows);
159 void ribbonResizeEvent(int primary, int secondary);
160 void resizeEvent(QResizeEvent* resize_event) override;
165 void updateLayout(QSize size);
170 void setVertical(bool is_vertical);
180 void adjustButtonsToFit(int primary, int secondary);
185 void setFixedNumOfRows(uint01 fixed_num_of_rows);
186 public slots:
191 public:
200 QBoxLayout* m_layout;
201 };
202
203}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Displays translated text.
bool hasSubGroup(const TranslatedString &sub_group) const
Checks whether a sub-group with the given name exists.
void setFixedNumOfRows(uint01 fixed_num_of_rows)
Sets a fixed number of rows for the layout.
RibbonSubGroup * removeSubGroup(const String &sub_group)
Removes the sub-group with the given string key.
int currentSecondaryDimension() const
Returns the current size along the secondary layout axis.
uint01 m_fixed_num_of_rows
Fixed number of rows, or 0 for automatic.
bool m_is_vertical
Whether the layout is vertical.
RibbonSubGroup * addSubGroup(const TranslatedString &sub_group_name)
Adds a new sub-group with the given name.
int largeButtonWidth() const
Returns the width of a large button in the current layout.
int mediumButtonWidth() const
Returns the width of a medium button in the current layout.
void removeSubGroup(const TranslatedString &sub_group)
Removes the sub-group with the given translated name.
void updateLayout(QSize size)
Updates the internal layout to fit the given size.
uint04 maxNumOfColumns() const
Returns the maximum number of columns across all sub-groups.
void layoutSubGroups()
Slot that performs the layout of all sub-groups within this ribbon group.
Dictionary< String, RibbonSubGroup * > m_sub_group_lookup
Sub-groups indexed by name.
uint04 m_row_num
Current number of layout rows.
Vector< 2, int > minSize() const
Returns the minimum size as a 2D vector (primary, secondary).
Buffer< QFrame * > m_separators
Visual separators between sub-groups.
int marginThickness() const
Returns the margin thickness around the ribbon group content.
void setNumberOfRows(uint04 number_of_rows)
Sets the number of rows used for laying out buttons.
int m_last_width
The last known width, used to detect resize changes.
QBoxLayout * m_layout
The box layout managing sub-group arrangement.
void setVertical(bool is_vertical)
Sets whether the ribbon group layout is vertical.
int currentPrimaryDimension() const
Returns the current size along the primary layout axis (width or height).
Buffer< QWidget * > m_sub_groups
Ordered list of sub-group widgets.
RibbonGroup(QWidget *parent=nullptr)
Constructs a ribbon group widget.
void cleanupEmpty()
Removes any empty sub-groups.
void ribbonResizeEvent(int primary, int secondary)
Notifies the group of a ribbon resize, triggering sub-group relayout.
void addSubGroup(QWidget *sub_group)
Adds an existing widget as a sub-group.
bool isEmpty() const
Returns whether this ribbon group has no sub-groups or all are empty.
void adjustButtonsToFit(int primary, int secondary)
Adjusts button sizes and states to fit within the given dimensions.
RibbonLayoutMode m_layout_mode
The current layout mode.
void resetButtonStates()
Resets all button states in all sub-groups to their defaults.
QSize minimumSizeHint() const override
Returns the minimum recommended size for this ribbon group.
void setupSeparator(QFrame *seperator) const
Configures a separator frame for visual separation between sub-groups.
RibbonSubGroup & operator[](const TranslatedString &location)
Returns the sub-group with the given name, creating it if it does not exist.
Represents a sub-section of "Tab" of a ribbon representing a grouping of buttons or widgets within a ...
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
RibbonLayoutMode
The orientations a ribbon can take on.