NDEVR
API Documentation
QCustomDockWidget.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: QCustomDockWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/UUID.h>
35#include <NDEVR/Buffer.h>
36#include <NDEVR/DockItem.h>
37#include <NDEVR/ContainerWidget.h>
38#include <NDEVR/PopupInfo.h>
39#include <QFrame>
40#include <QPointer>
41class QIcon;
42class QString;
43class QLabel;
44
45
46namespace NDEVR
47{
48 enum DropArea;
49 enum class RibbonArea;
51 class SectionWidget;
52 class SectionContent;
53 class SectionIconTab;
54 class FloatingWidget;
55 class Button;
61 class NDEVR_WIDGETS_API QCustomDockWidget : public DockItem
62 {
63 Q_OBJECT
64 public:
70 explicit QCustomDockWidget(RibbonArea ribbon_area, ContainerWidgetBase* container = nullptr);
77 explicit QCustomDockWidget(QWidget* main_widget, RibbonArea ribbon_area, ContainerWidgetBase* container = nullptr);
83 explicit QCustomDockWidget(QWidget* main_widget, ContainerWidgetBase* container = nullptr);
92 void setMainWidget(QWidget* widget);
97 QWidget* mainWidget() { return m_main_widget; }
102 QString windowTitle() const;
107 void setSize(QSize size);
117 void showDock(bool show_dock);
122 void removeDock(bool delete_when_finished);
127 bool isVisible() const;
132 void setupButton(Button* button);
138 void showDockFullscreen(bool show_dock, const PopupInfo& start_location = PopupInfo());
145 void showDock(bool show_dock, DropArea area, SectionWidget* section);
152 void showDock(bool show_dock, const PopupInfo& start_location, SectionWidget* section = nullptr);
160 void showDock(bool show_dock, const PopupInfo& start_location, const PopupInfo& end_location, SectionWidget* section = nullptr);
165 QSize sizeHint() const;
170 void setSizeHint(const QSize& size);
175 bool isDockFullscreen() const;
180 virtual void setDockSelected(bool selected) override;
185 virtual void setIcon(const QIcon& icon) override;
190 QIcon icon() const;
195 virtual void setTitle(const TranslatedString& title) override;
200 virtual void setupDialogButton(Button* button);
205 virtual void removeButton(Button* button);
210 void setWindowFlags(Qt::WindowFlags type);
216 void setWindowFlag(Qt::WindowType type, bool on = true);
221 int width() const;
226 int height() const;
231 void setVisible(bool visible);
236 void setAllowAutoHideTitle(bool allow_auto_hide);
237 public slots:
242 void highlightDock(bool highlight);
247 void setIconSlot(const QIcon& icon);
252 void setTitleSlot(const QString& title);
253 signals:
266 void fullscreenSignal(bool is_fullscreen);
276 void windowTitleChanged(const TranslatedString& new_title);
281 void windowIconChanged(const QIcon& icon);
282 protected slots:
287 void onFullscreenButtonClicked(bool fullscreen);
292 protected:
296 virtual void createSectionContent() override;
297 protected:
298 QPointer<QWidget> m_main_widget;
302 };
303
309 template<class t_type>
311 {
312 public:
318 : QCustomDockWidget(new t_type(), container)
319 {}
320
325 DockWidget(t_type* child, ContainerWidgetBase* container = nullptr)
327 {}
328
334 DockWidget(t_type* child, RibbonArea ribbon_area, ContainerWidgetBase* container = nullptr)
335 : QCustomDockWidget(child, ribbon_area, container)
336 {}
337
341 t_type& widget() const
342 {
343 return *dynamic_cast<t_type*>(m_main_widget.data());
344 }
345 };
346}
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
The root class that manages a series of SectionContent that can share the same space or lay out in va...
SectionWidget * section() const
Returns the section widget that currently contains this dock item.
DockItem(RibbonArea ribbon_area, ContainerWidgetBase *container=nullptr)
Constructs a DockItem with a preferred ribbon area and optional container.
SectionContent * m_section_content
The section content representing this dock item.
Definition DockItem.h:248
virtual const TranslatedString & title() const
Returns the display title of this dock item.
Definition DockItem.h:234
ContainerWidgetBase * container() const
Returns the container widget that owns this dock item.
DockWidget(ContainerWidgetBase *container=nullptr)
Constructs a DockWidget with a new instance of the wrapped type.
t_type & widget() const
Returns a typed reference to the main widget.
DockWidget(t_type *child, RibbonArea ribbon_area, ContainerWidgetBase *container=nullptr)
Constructs a DockWidget wrapping an existing widget with a ribbon area.
DockWidget(t_type *child, ContainerWidgetBase *container=nullptr)
Constructs a DockWidget wrapping an existing widget.
Used with the NDEVR API Widget Docking system for widgets that are floating.
void onCloseButtonClicked()
Slot invoked when the close button is clicked.
QCustomDockWidget(QWidget *main_widget, ContainerWidgetBase *container=nullptr)
Constructs a dock widget wrapping a main widget with an optional container.
void setMainWidget(QWidget *widget)
Sets the main widget displayed inside the dock.
virtual void setTitle(const TranslatedString &title) override
Sets the title text displayed in the dock title bar.
void highlightDock(bool highlight)
Highlights or un-highlights the dock widget visually.
void windowTitleChanged(const TranslatedString &new_title)
Emitted when the window title changes.
void setTitleSlot(const QString &title)
Slot to set the dock title from a QString.
void showDockFullscreen(bool show_dock, const PopupInfo &start_location=PopupInfo())
Shows or hides the dock in fullscreen mode.
void showDock(bool show_dock, const PopupInfo &start_location, const PopupInfo &end_location, SectionWidget *section=nullptr)
Shows or hides the dock with start and end animation locations.
QCustomDockWidget(QWidget *main_widget, RibbonArea ribbon_area, ContainerWidgetBase *container=nullptr)
Constructs a dock widget wrapping a main widget with a specified ribbon area.
void dockSelectedSignal(bool)
Emitted when the dock widget selection state changes.
virtual void setIcon(const QIcon &icon) override
Sets the icon displayed in the dock title bar.
bool m_highlight_dock
Whether the dock is currently highlighted.
void setWindowFlags(Qt::WindowFlags type)
Sets the window flags for the dock widget when floating.
void setVisible(bool visible)
Sets the visibility of the dock widget.
QWidget * mainWidget()
Returns the main widget displayed inside the dock.
void onFullscreenButtonClicked(bool fullscreen)
Slot invoked when the fullscreen button is clicked.
int height() const
Returns the current height of the dock widget.
void showDock(bool show_dock)
Shows or hides the dock widget.
SectionContent * content() const
Returns the SectionContent associated with this dock widget.
QCustomDockWidget(RibbonArea ribbon_area, ContainerWidgetBase *container=nullptr)
Constructs a dock widget with a specified ribbon area and optional container.
void setIconSlot(const QIcon &icon)
Slot to set the dock icon from a QIcon.
void setSizeHint(const QSize &size)
Sets the preferred size hint for the dock widget.
virtual void createSectionContent() override
Creates the SectionContent that represents this dock in the container system.
QString windowTitle() const
Returns the window title of the dock widget.
void setAllowAutoHideTitle(bool allow_auto_hide)
Sets whether the title bar can be automatically hidden when not needed.
int width() const
Returns the current width of the dock widget.
Buffer< Button * > m_buttons_to_add
Buttons queued to be added to the dock title bar.
bool isDockFullscreen() const
Returns whether the dock is currently displayed in fullscreen mode.
bool isVisible() const
Returns whether the dock widget is currently visible to the user.
void windowIconChanged(const QIcon &icon)
Emitted when the window icon changes.
virtual void removeButton(Button *button)
Removes a previously registered button from this dock widget.
QSize sizeHint() const
Returns the recommended size for the dock widget.
virtual void setDockSelected(bool selected) override
Sets the selected state of the dock, updating visual indicators.
void closedSignal()
Emitted when the dock widget is closed.
void fullscreenSignal(bool is_fullscreen)
Emitted when the dock widget enters or exits fullscreen mode.
virtual void setupDialogButton(Button *button)
Sets up a button as a dialog toggle button for this dock widget.
void removeDock(bool delete_when_finished)
Removes the dock from its container.
void minimizedSignal()
Emitted when the dock widget is minimized.
QIcon icon() const
Returns the icon displayed in the dock title bar.
void showDock(bool show_dock, DropArea area, SectionWidget *section)
Shows or hides the dock in a specific drop area within a section.
void setWindowFlag(Qt::WindowType type, bool on=true)
Sets or clears a specific window flag.
void showDock(bool show_dock, const PopupInfo &start_location, SectionWidget *section=nullptr)
Shows or hides the dock with a popup start location.
QSize m_size_hint
The preferred size hint for the dock widget.
void setSize(QSize size)
Sets the preferred size of the dock widget.
void setupButton(Button *button)
Configures a button to toggle the visibility of this dock widget.
virtual ~QCustomDockWidget()
Destroys the dock widget and cleans up associated resources.
QPointer< QWidget > m_main_widget
The main widget displayed inside the dock.
The core container for objects using the NDEVR API Widget Docking system.
Provides a tab that contains an icon and some buttons used for either a tab if the section content is...
SectionWidget manages multiple instances of SectionContent.
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.
DropArea
relates where a widget should be dropped relative to another.
Definition RibbonArea.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
Class which is used to pass arguments and requests for creating a popup dialog or widget.
Definition PopupInfo.h:16