API Documentation
Loading...
Searching...
No Matches
SectionWidget.h
Go to the documentation of this file.
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: SectionWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/SectionContent.h>
35#include <NDEVR/QCustomStackedWidget.h>
36#include <NDEVR/UUID.h>
37#include <NDEVR/Buffer.h>
38#include <QScrollArea>
39class QBoxLayout;
40class QStackedLayout;
41class QPushButton;
42class QMenu;
43class QToolButton;
44class QPropertyAnimation;
45namespace NDEVR
46{
47 class ContainerWidgetBase;
48 class Button;
49 class SectionWidgetTabsScrollArea;
50 /**--------------------------------------------------------------------------------------------------
51 \brief SectionWidget manages multiple instances of SectionContent. It displays a title TAB, which is
52 clickable and will switch to the contents associated to the title when clicked.
53 **/
55 {
56 Q_OBJECT
57 Q_PROPERTY(double animation_progress READ animationProgress WRITE setAnimationProgress)
58 public:
59 explicit SectionWidget(ContainerWidgetBase* parent, RibbonArea ribbon_area);
60 virtual ~SectionWidget();
61 explicit operator const QWidget* () const { return this; }
62 explicit operator QWidget* () { return this; }
63 explicit operator const QObject* () const { return this; }
64 explicit operator QObject* () { return this; }
65 UUID uid() const;
67 RibbonArea ribbonArea() const { return m_ribbon_area; }
69 const Buffer<SectionContent*>& contents() const { return m_contents; }
71 void addContent(SectionContent* data, bool animate);
72 void insertContent(uint04 index, SectionContent* data, bool animate);
73 bool takeContent(uint04 index);
78 uint04 indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = nullptr) const;
79 bool isLayoutVertical() const;
81 bool isRibbonHorizontal() const;
83 void setTabLock(bool tab_lock);
84 void setTabVisible(bool visible);
88 void setAnimationProgress(double width);
90 void setCurrentIndex(uint04 index, bool animate);
91 SectionWidgetTabsScrollArea* tabScrollArea() { return m_tabs_scroll_area; };
92 bool showTabs() const { return m_show_tabs; }
93 bool hasVisibleTab() const;
94 void updateLayout(QBoxLayout* layout);
95 void setMinimizeAllowed(bool allowed);
97 void setupAsBoxWidget(bool is_box_widget);
98 QRect titleAreaGeometry() const;
99 void moveContent(uint04 from, uint04 to) override;
100 void swapIndices(uint04 from, uint04 to) override;
101 QSize minimumSizeHint() const override;
102 QSize sizeHint() const override;
103 protected:
104 virtual void showEvent(QShowEvent*) override;
105 void resizeEvent(QResizeEvent* event) override;
106 bool event(QEvent* event) override;
107 private:
108 int prefferedContentWidth() const;
109 double animationProgress() const { return m_max_animation_progress; };
110 QSize normalMinimumSize() const;
111 void createCollapseAnimation();
112 uint04 convertToIndexVisibleIndex(uint04 index);
113 int tabSize() const;
114 signals:
118 private slots:
119 void showTabMenuButtonIfNeeded();
120 void onTabsMenuButtonClicked();
121 void onSectionTitleClicked(SectionContent* content);
122 void onSpecialTitleClicked(SectionContent* content);
123 void onTabsMenuActionTriggered(bool);
124 public slots:
126 private:
127 const UUID m_uid;
128 ContainerWidgetBase* m_container;
129 Buffer<SectionContent*> m_contents;
130 Buffer<SectionTab*> m_section_titles;
131 Buffer<QWidget*> m_section_contents;
132 RibbonArea m_ribbon_area;
133 SectionWidgetTabsScrollArea* m_tabs_scroll_area;
134 Button* m_tabs_button;
135 uint04 m_current_index;
136 int m_last_width;
137 double m_max_animation_progress;
138 QPixmap* m_cached_image;
139 QPointer<QPropertyAnimation> m_resize_animation;
140 fltp08 m_location;
141 bool m_has_rendered = false;
142 bool m_minimize_allowed = true;
143 bool m_show_tabs = true;
144 };
145
146
147}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:59
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A core widget that allows the user to click one of many button types.
Definition Button.h:66
The root class that manages a series of SectionContent that can share the same space or lay out in va...
Definition ContainerWidget.h:66
A base class for a series of widgets where all widgets occupy the same same and only one widget is sh...
Definition QCustomStackedWidget.h:50
The core container for objects using the NDEVR API Widget Docking system. Contains information used t...
Definition SectionContent.h:51
SectionWidget manages multiple instances of SectionContent. It displays a title TAB,...
Definition SectionWidget.h:55
void moveContent(uint04 from, uint04 to) override
void setupAsBoxWidget(bool is_box_widget)
QSize minimumSizeHint() const override
virtual ~SectionWidget()
bool isRibbonLayoutHorizontal() const
void setTabLock(bool tab_lock)
void ribbonLocationChangedSignal(RibbonArea area)
uint04 indexOf(SectionContent *c)
QSize sizeHint() const override
void setCurrentIndex(uint04 index, bool animate)
const Buffer< SectionContent * > & contents() const
Definition SectionWidget.h:69
void setRibbonArea(RibbonArea area)
void userChangedCurrentTabSignal(uint04 idx)
uint04 currentIndex() const
void updateLayout(QBoxLayout *layout)
uint04 indexOfContentByTitlePos(const QPoint &pos, QWidget *exclude=nullptr) const
bool takeContent(SectionContent *data)
bool event(QEvent *event) override
bool isRibbonHorizontal() const
bool showTabs() const
Definition SectionWidget.h:92
void insertContent(uint04 index, SectionContent *data, bool animate)
uint04 contentCount() const
bool isLayoutVertical() const
uint04 indexOfContentByUid(UUID uid) const
bool hasVisibleTab() const
void addContent(SectionContent *data, bool animate)
ContainerWidgetBase * containerWidget() const
QRect titleAreaGeometry() const
void swapIndices(uint04 from, uint04 to) override
uint04 indexOfContent(SectionContent *c) const
void resizeEvent(QResizeEvent *event) override
bool takeContent(uint04 index)
void addContent(SectionContent *c)
void tabChangedSignal(uint04 idx)
uint04 activeIndex() const
void setAnimationProgress(double width)
void setTabVisible(bool visible)
SectionWidgetTabsScrollArea * tabScrollArea()
Definition SectionWidget.h:91
void setMinimizeAllowed(bool allowed)
virtual void showEvent(QShowEvent *) override
SectionWidget(ContainerWidgetBase *parent, RibbonArea ribbon_area)
RibbonArea ribbonArea() const
Definition SectionWidget.h:67
Custom scrollable implementation for docked tabs using the NDEVR API Widget Docking system.
Definition SectionWidgetTabsScrollArea.h:49
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
Definition ACIColor.h:37
RibbonArea
Requests a ribbon or tab area to be in a certain location and orientation relative to another widget.
Definition RibbonArea.h:71
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149