NDEVR
API Documentation
ContainerWidget.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: ContainerWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/RibbonArea.h>
35#include <NDEVR/QCustomStackedWidget.h>
36#include <NDEVR/Dictionary.h>
37#include <NDEVR/UUID.h>
38#include <QPointer>
39class QPoint;
40class QSplitter;
41class QMenu;
42class QBoxLayout;
43class QGridLayout;
44
45namespace NDEVR
46{
47 class SectionWidget;
48 class DropOverlay;
49 class InternalContentData;
50 class QCustomSplitter;
51 class FloatingWidget;
52 class SectionContent;
53 class SharedSectionContentArea;
65 class NDEVR_WIDGETS_API ContainerWidgetBase : public QCustomStackedWidgetBase
66 {
67 Q_OBJECT
68 friend class SectionContent;
69 friend class SectionWidget;
70 friend class FloatingWidget;
71 friend class SectionTab;
72 friend class DockItem;
73 friend class QCustomDockWidget;
74 friend class CustomDockButton;
75 friend class MainWindow;
76 public:
81 explicit ContainerWidgetBase(QWidget *parent = nullptr);
82 virtual ~ContainerWidgetBase();
83 protected:
91 virtual SectionWidget* addSectionContent(SectionContent* sc, SectionWidget* sw, DropArea area = e_drop_center);
97 virtual FloatingWidget* addSectionContent(SectionContent* sc);
106 FloatingWidget* makeFloating(SectionContent* sc, bool show, PopupInfo start = PopupInfo(), PopupInfo end = PopupInfo());
113 FloatingWidget* makeFullScreen(SectionContent* sc, PopupInfo start = PopupInfo());
124 bool hasSectionContent(SectionContent* sc);
130 bool removeSectionContent(SectionContent* sc);
135 void resizeEvent(QResizeEvent* event) override;
143 bool showSectionContent(SectionContent* sc, PopupInfo start = PopupInfo(), PopupInfo end = PopupInfo());
150 bool hideSectionContent(SectionContent* sc, PopupInfo end = PopupInfo());
156 bool raiseSectionContent(SectionContent* sc);
165 void setTabLock(bool tab_lock);
184 bool isSectionContentVisible(SectionContent* sc);
190 void swapSectionContent(SectionContent* section_a, SectionContent* section_b);
200 QRect outerTopDropRect() const;
205 QRect outerRightDropRect() const;
210 QRect outerBottomDropRect() const;
215 QRect outerLeftDropRect() const;
220 QSize sizeHint() const override;
230 virtual void setShouldAnimateAdd(bool animate);
239 protected:
244 QSize minimumSizeHint() const override;
250 bool event(QEvent* event) override;
251 private:
252 SharedSectionContentArea* createSection(Qt::Orientation orientation, QWidget* parent);
253 void exitCurrentFullscreen();
254 void pullFromFullScreenStack(FloatingWidget* widget);
255 SharedSectionContentArea* findParentSplitter(const QWidget* w, QWidget** parent_widget = nullptr);
256 void pullContent(SectionWidget* sw, SectionContent* data);
257 SectionWidget* dropContent(SectionContent* data, SectionWidget* targetSection, DropArea area);
258 void addSection(SectionWidget* section);
259 SectionWidget* sectionAt(const QPoint& pos) const;
260 SectionWidget* dropContentOuterHelper(QLayout* l, SectionContent* data, Qt::Orientation orientation, bool append);
261 bool splitterContainsSectionWidget(SharedSectionContentArea* splitter);
262 void deleteEmptySplitters();
263 void pushCurrentToFullscreenStack();
264 protected:
267 SharedSectionContentArea* m_top_splitter = nullptr;
269 SectionWidget* m_top_section_widget = nullptr;
274 bool m_animate_add = true;
275 bool m_reset_is_on_home = false;
276 };
277
290 class NDEVR_WIDGETS_API ContainerWidget : public ContainerWidgetBase
291 {
292 public:
297 ContainerWidget(QWidget* parent = nullptr)
298 : ContainerWidgetBase(parent)
299 {}
300
307
311 void setShouldAnimateAdd(bool animate) override
312 {
314 }
315
319 void setTabLock(bool tab_lock)
320 {
322 }
323 };
324}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
bool m_reset_is_on_home
Whether the reset state corresponds to the home layout.
void beginResetAll()
Begins a reset-all operation, saving current state for later restoration.
virtual void clearAllSectionContent()
Removes all section content from this container, including floating widgets.
Dictionary< UUID, SectionWidget * > m_sections
Maps section UUIDs to their SectionWidget pointers.
QRect outerLeftDropRect() const
Returns the drop rectangle for the outer left area of this container.
FloatingWidget * makeFloating(SectionContent *sc, bool show, PopupInfo start=PopupInfo(), PopupInfo end=PopupInfo())
Makes the given section content into a floating widget.
bool hideSectionContent(SectionContent *sc, PopupInfo end=PopupInfo())
Hides the given section content, optionally with popup animation.
Dictionary< UUID, SectionContent * > m_section_content
Maps section content UUIDs to their SectionContent pointers.
QSize sizeHint() const override
Returns the recommended size for this widget.
QRect outerTopDropRect() const
Returns the drop rectangle for the outer top area of this container.
bool removeSectionContent(SectionContent *sc)
Removes the given section content from this container.
SharedSectionContentArea * m_top_splitter
The top-level splitter managing the layout of all sections.
void removeFromResetShow(UUID id)
Removes the given section ID from the list of sections to be shown during reset restoration.
FloatingWidget * makeFullScreen(SectionContent *sc, PopupInfo start=PopupInfo())
Makes the given section content fullscreen.
void swapSectionContent(SectionContent *section_a, SectionContent *section_b)
Swaps the positions of two section contents within the container.
ContainerWidgetBase(QWidget *parent=nullptr)
Constructs a ContainerWidgetBase with the given parent widget.
QSize minimumSizeHint() const override
Returns the minimum recommended size for this widget.
Buffer< std::pair< QPointer< QWidget >, Buffer< QPointer< FloatingWidget > > > > m_reset_fullscreen_stack
Saved fullscreen stack for reset restoration.
DropOverlay * m_drop_overlay
The overlay shown during drag-and-drop operations.
bool raiseSectionContent(SectionContent *sc)
Raises the given section content to the front of its section widget.
QRect outerBottomDropRect() const
Returns the drop rectangle for the outer bottom area of this container.
void bringFloatingWidgetsForward()
Brings all floating widgets owned by this container to the front of the window stack.
bool event(QEvent *event) override
Handles events for this widget, including custom event processing.
virtual SectionWidget * addSectionContent(SectionContent *sc, SectionWidget *sw, DropArea area=e_drop_center)
Adds section content to an existing section widget in the specified drop area.
Buffer< UUID > m_reset_visible_sections
UUIDs of sections that should be visible after a reset.
SectionWidget * m_top_section_widget
The top-level section widget, if any.
void resizeEvent(QResizeEvent *event) override
Handles resize events to update internal layout geometry.
bool isSectionContentVisible(SectionContent *sc)
Checks whether the given section content is currently visible.
DropOverlay * dropOverlay()
Returns the drop overlay used for drag-and-drop visual feedback.
QRect outerRightDropRect() const
Returns the drop rectangle for the outer right area of this container.
bool hasSectionContent(SectionContent *sc)
Checks whether the given section content exists within this container.
void setTabLock(bool tab_lock)
Locks or unlocks tab movement for all section widgets in this container.
bool popWindowStack()
Pops the top item from the fullscreen window stack, restoring the previous state.
Buffer< std::pair< QPointer< QWidget >, Buffer< QPointer< FloatingWidget > > > > m_fullscreen_stack
Stack of fullscreen states for navigating back.
Buffer< SharedSectionContentArea * > m_shared_content
All shared content area splitters in this container.
bool m_animate_add
Whether to animate the addition of new section content.
virtual void clearAllNonFloatingContent()
Removes all non-floating section content from this container.
void endResetAll()
Ends a reset-all operation, restoring layout to the saved state.
bool showSectionContent(SectionContent *sc, PopupInfo start=PopupInfo(), PopupInfo end=PopupInfo())
Shows the given section content, optionally with popup animation.
virtual void setShouldAnimateAdd(bool animate)
Sets whether adding new section content should be animated.
virtual FloatingWidget * addSectionContent(SectionContent *sc)
Adds section content as a new floating widget.
Buffer< SectionContent * > contents() const
Returns all section contents managed by this container.
void setTabLock(bool tab_lock)
Locks or unlocks tab movement for all section widgets in this container.
void setShouldAnimateAdd(bool animate) override
Sets whether adding new section content should be animated.
ContainerWidget(QWidget *parent=nullptr)
Constructs a ContainerWidget with the given parent widget.
void clearAllSectionContent() override
Removes all section content from this container, including floating widgets.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Paints a translucent rectangle over another widget.
Definition DropOverlay.h:46
Used with the NDEVR API Widget Docking system for widgets that are floating.
A splitter lets the user control the size of 2 child widgets by dragging the boundary between them.
QCustomStackedWidgetBase(QWidget *parent=nullptr)
Constructs the stacked widget base.
QWidget * widget(uint04 index) const
Returns the widget at the given index.
The core container for objects using the NDEVR API Widget Docking system.
SectionWidget manages multiple instances of SectionContent.
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.
DropArea
relates where a widget should be dropped relative to another.
Definition RibbonArea.h:46
@ e_drop_center
Drop into the center (tabbed area) of the target.
Definition RibbonArea.h:49
Class which is used to pass arguments and requests for creating a popup dialog or widget.
Definition PopupInfo.h:16