NDEVR
API Documentation
Ribbon.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: Widgets
28File: Ribbon
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/RibbonLayoutMode.h>
35#include <NDEVR/ContainerWidget.h>
36#include <NDEVR/QCustomDockWidget.h>
37#include <NDEVR/RibbonArea.h>
38#include <NDEVR/String.h>
39#include <NDEVR/BaseValues.h>
40#include <NDEVR/Dictionary.h>
41#include <QFrame>
42class QBoxLayout;
43namespace NDEVR
44{
45 class RibbonGroup;
55 class NDEVR_WIDGETS_API Ribbon : public ContainerWidgetBase
56 {
57 public:
62 explicit Ribbon(QWidget* parent = nullptr);
63 ~Ribbon();
68 bool isVertical() { return m_is_vertical; };
74 const RibbonGroup& group(const TranslatedString& group_name) const;
80 void setGroupName(uint04 index, const TranslatedString& group_name);
85 void setInverseRibbonArea(bool inverse_ribbon_area);
91 RibbonGroup& group(const TranslatedString& group_name);
108 {
109 return m_groups[group_name];
110 }
111
123 {
124 return m_index_groups[index];
125 }
126
135 virtual RibbonGroup* addGroup(const TranslatedString& label);
142 virtual RibbonGroup* addGroup(uint04 index, const TranslatedString& label);
147 virtual void addGroup(RibbonGroup* group);
153 virtual void addGroup(uint04 index, RibbonGroup* group);
158 virtual void removeGroup(const TranslatedString& label);
163 virtual void removeGroup(uint04 index);
172 virtual void removeAllGroups();
178 virtual bool hasGroup(const TranslatedString& group) const;
183 SectionWidget* section() const;
190 {
191 if (!hasGroup(location))
192 addGroup(location);
193 return group(location);
194 }
195
200 void resizeEvent(QResizeEvent *resize_event) override;
205 void setFixedNumOfRows(uint01 fixed_num_of_rows);
210 QSize sizeHint() const override;
215 QSize minimumSizeHint() const override;
225 void addTopLeftWidget(QWidget* widget);
239
243 void setTabLock(bool tab_lock) { ContainerWidgetBase::setTabLock(tab_lock); }
244 private:
249 virtual void _setVertical(bool is_vertical);
250 private:
251 bool m_is_vertical;
252 bool m_inverse_ribbon_area;
253 RibbonLayoutMode m_layout_mode;
254 uint01 m_fixed_num_of_rows;
256 Buffer<DockWidget<RibbonGroup>*> m_index_groups;
257 Buffer<QPointer<QWidget>> m_top_left_widgets;
258 Buffer<QPointer<QWidget>> m_bottom_right_widgets;
259 Buffer<TranslatedString> m_index_names;
260 };
261
262
263}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
ContainerWidgetBase(QWidget *parent=nullptr)
Constructs a ContainerWidgetBase with the given parent widget.
void setTabLock(bool tab_lock)
Locks or unlocks tab movement for all section widgets in this container.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
A type-safe dock widget that wraps a specific widget type.
virtual void slideInIdx(uint04 idx, PopupInfo origin_rect, int delay_time=0, enum StackAnimationDirection direction=e_automatic)
Slides to the page at the given index with animation and popup origin info.
StackAnimationDirection
Defines the direction of slide animations between stacked pages.
@ e_automatic
Automatically determine direction based on index order.
QWidget * widget(uint04 index) const
Returns the widget at the given index.
Represents the "Tab" of a widget.
Definition RibbonGroup.h:52
void setInverseRibbonArea(bool inverse_ribbon_area)
Sets whether the ribbon area orientation should be inverted.
void setFixedNumOfRows(uint01 fixed_num_of_rows)
Sets a fixed number of rows for the ribbon layout.
SectionWidget * section() const
Returns the parent section widget that contains this ribbon.
virtual RibbonGroup * addGroup(const TranslatedString &label)
Adds a new ribbon group with the given label, creating it if necessary.
virtual bool hasGroup(const TranslatedString &group) const
Checks whether a ribbon group with the given name exists.
virtual void removeAllGroups()
Removes all ribbon groups from the ribbon.
bool isVertical()
Returns whether the ribbon is oriented vertically.
Definition Ribbon.h:68
DockWidget< RibbonGroup > * groupDock(uint04 index)
Returns the dock widget for the ribbon group at the given index.
Definition Ribbon.h:122
virtual void addGroup(uint04 index, RibbonGroup *group)
Adds an existing ribbon group at a specific index.
QSize sizeHint() const override
Returns the recommended size for the ribbon.
void addBottomRightWidget(QWidget *widget)
Adds a widget to the bottom-right area of the ribbon (after the groups).
Ribbon(QWidget *parent=nullptr)
Constructs a ribbon widget.
const RibbonGroup & group(const TranslatedString &group_name) const
Returns a const reference to the ribbon group with the given name.
void slideInIdx(uint04 idx, enum StackAnimationDirection direction=StackAnimationDirection::e_automatic) override
Slides to the ribbon page at the given index with an optional animation direction.
Definition Ribbon.h:236
void cleanupEmpty()
Removes any empty ribbon groups.
void addTopLeftWidget(QWidget *widget)
Adds a widget to the top-left area of the ribbon (before the groups).
RibbonGroup & group(uint04 index)
Returns a mutable reference to the ribbon group at the given index.
Dictionary< TranslatedString, DockWidget< RibbonGroup > * > & groups()
Returns a reference to the dictionary of all ribbon groups keyed by name.
Definition Ribbon.h:220
void setLayoutMode(RibbonLayoutMode mode)
Sets the layout mode for how ribbon groups are arranged.
virtual void removeGroup(const TranslatedString &label)
Removes the ribbon group with the given label.
DockWidget< RibbonGroup > * groupDock(const RibbonGroup *group)
Returns the dock widget wrapping the given ribbon group.
virtual void addGroup(RibbonGroup *group)
Adds an existing ribbon group to the ribbon.
RibbonGroup & operator[](const TranslatedString &location)
Returns the ribbon group with the given name, creating it if it does not exist.
Definition Ribbon.h:189
virtual RibbonGroup * addGroup(uint04 index, const TranslatedString &label)
Adds a new ribbon group at a specific index with the given label.
virtual void removeGroup(RibbonGroup *group)
Removes a specific ribbon group.
virtual void _setVertical(bool is_vertical)
Sets the ribbon orientation to vertical or horizontal.
void setTabLock(bool tab_lock)
Sets whether tabs are locked (preventing the user from switching tabs).
Definition Ribbon.h:243
void updateRibbonLayout()
Recalculates and updates the layout of all ribbon groups.
void setGroupName(uint04 index, const TranslatedString &group_name)
Renames the ribbon group at the given index.
QSize minimumSizeHint() const override
Returns the minimum recommended size for the ribbon.
virtual void removeGroup(uint04 index)
Removes the ribbon group at the given index.
DockWidget< RibbonGroup > * groupDock(const TranslatedString &group_name)
Returns the dock widget for the ribbon group with the given name.
Definition Ribbon.h:107
RibbonGroup & group(const TranslatedString &group_name)
Returns a mutable reference to the ribbon group with the given name.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
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.