NDEVR
API Documentation
SectionContent.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: SectionContent
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/ButtonDialog.h>
35#include <NDEVR/RibbonArea.h>
36#include <NDEVR/UUID.h>
37#include <NDEVR/TranslatedString.h>
38#include <functional>
39#include <QObject>
40class QWidget;
41
42namespace NDEVR
43{
44 class SectionTab;
46 class FloatingWidget;
52 class NDEVR_WIDGETS_API SectionContent : public QObject, public ButtonDialog
53 {
54 Q_OBJECT
55 friend class ContainerWidgetBase;
56 private:
57 SectionContent(const SectionContent&) = delete;
58 SectionContent(SectionContent&&) noexcept;
59 SectionContent& operator=(const SectionContent&) = delete;
60 public:
68 SectionContent(ContainerWidgetBase* container, SectionTab* title, QWidget* content, RibbonArea preferred_ribbon_area);
76 SectionContent(ContainerWidgetBase* container, SectionTab* title, const std::function<void(SectionContent*)>& function, RibbonArea preferred_ribbon_area);
77 virtual ~SectionContent();
81 void onCheckedClick() override;
86 void setContainer(ContainerWidgetBase* container);
101 const TranslatedString& title() const { return m_title; }
106 void setTitle(const TranslatedString& title) { m_title = title; }
111 SectionWidget* sectionWidget() const { return m_section_widget; }
116 FloatingWidget* floatingWidget() const { return m_floating_widget; }
121 UUID uid() const;
126 ContainerWidgetBase* containerWidget() const;
136 QWidget* contentWidget() const;
141 void setContentWidget(QWidget* widget);
146 RibbonArea preferredRibbonArea() const { return m_preferred_ribbon_area; }
156 const std::function<void(SectionContent*)>& specialCallback() { return m_special_callback; }
161 bool hasSpecialCallback() const { return m_special_callback != nullptr; }
166 void setSpecialCallback(const std::function<void(SectionContent*)>& callback) { m_special_callback = callback; }
170 void runSpecialCallback() { m_special_callback(this); }
175 void setAllowHide(bool allow_hide) { m_allow_hide = allow_hide; }
180 bool allowHide() const { return m_allow_hide; }
185 void setAllowAutoHideTitle(bool allow_hide) { m_allow_auto_hide_title = allow_hide; emit autoHideTitleChangedSignal(allow_hide); }
190 bool allowAutoHideTitle() const { return m_allow_auto_hide_title; }
195 signals:
200 void autoHideTitleChangedSignal(bool allow_hide);
201 private:
202 const UUID m_uid;
203 ContainerWidgetBase* m_container_widget;
204 SectionTab* m_title_widget;
205 SectionWidget* m_section_widget;
206 FloatingWidget* m_floating_widget;
207 std::function<void(SectionContent*)> m_special_callback;
208 QWidget* m_widget;
209 // Optional attributes
210 TranslatedString m_title;
211 RibbonArea m_preferred_ribbon_area;
212 bool m_allow_hide;
213 bool m_allow_auto_hide_title = false;
214 };
215}
Typically used for dialogs which have any number of buttons associated with it that are toggled on wh...
The root class that manages a series of SectionContent that can share the same space or lay out in va...
Used with the NDEVR API Widget Docking system for widgets that are floating.
SectionContent(ContainerWidgetBase *container, SectionTab *title, QWidget *content, RibbonArea preferred_ribbon_area)
Constructs a SectionContent with the given container, title tab, content widget, and ribbon area.
SectionTab * sectionTab() const
Returns the section tab associated with this content.
RibbonArea preferredRibbonArea() const
Returns the preferred ribbon area for docking this content.
void onCheckedClick() override
Called when the associated button dialog is checked or clicked.
void setAllowAutoHideTitle(bool allow_hide)
Sets whether the title bar can be automatically hidden when not needed.
FloatingWidget * floatingWidget() const
Returns the floating widget currently hosting this content, if any.
void setContentWidget(QWidget *widget)
Sets the widget displaying the actual content.
const std::function< void(SectionContent *)> & specialCallback()
Returns the special callback function, if one has been set.
void setSpecialCallback(const std::function< void(SectionContent *)> &callback)
Sets a special callback function to be invoked for deferred content creation.
void setContainer(ContainerWidgetBase *container)
Sets the parent container widget for this content.
void autoHideTitleChangedSignal(bool allow_hide)
Emitted when the auto-hide title setting changes.
void setAllowHide(bool allow_hide)
Sets whether this section content is allowed to be hidden by the user.
const TranslatedString & title() const
Returns the display title of this section content.
QWidget * contentWidget() const
Returns the widget displaying the actual content.
UUID uid() const
Returns the unique identifier for this section content.
void setPreferredRibbonArea(RibbonArea area)
Sets the preferred ribbon area for docking this content.
void runSpecialCallback()
Executes the special callback function, passing this content as the argument.
ContainerWidgetBase * containerWidget() const
Returns the container widget that owns this section content.
void setTitle(const TranslatedString &title)
Sets the display title of this section content.
bool allowHide() const
Returns whether this section content is allowed to be hidden by the user.
SectionWidget * sectionWidget() const
Returns the section widget currently hosting this content, if any.
bool hasSpecialCallback() const
Checks whether a special callback has been set for this content.
SectionContent(ContainerWidgetBase *container, SectionTab *title, const std::function< void(SectionContent *)> &function, RibbonArea preferred_ribbon_area)
Constructs a SectionContent with a deferred creation callback instead of an immediate widget.
void setFloatingWidget(FloatingWidget *widget)
Sets the floating widget that currently hosts this content.
bool allowAutoHideTitle() const
Returns whether the title bar can be automatically hidden when not needed.
void setSectionWidget(SectionWidget *widget)
Sets the section widget that currently hosts this content.
void retranslate()
Retranslates all user-facing strings for this section content.
Provides a tab that is used for either a tab if the section content is attached to a Container,...
Definition SectionTab.h:48
SectionWidget manages multiple instances of SectionContent.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
RibbonArea
Requests a ribbon or tab area to be in a certain location and orientation relative to another widget.
Definition RibbonArea.h:71