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 // SectionWidget manages multiple instances of SectionContent.
52 // It displays a title TAB, which is clickable and will switch to
53 // the contents associated to the title when clicked.
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;
66 ContainerWidgetBase* containerWidget() const;
67
68 QRect titleAreaGeometry() const;
69 RibbonArea ribbonArea() const { return m_ribbon_area; }
70 void setRibbonArea(RibbonArea area);
71 const Buffer<SectionContent*>& contents() const { return m_contents; }
72 void addContent(SectionContent* c);
73 void addContent(SectionContent* data, bool animate);
74 void insertContent(uint04 index, SectionContent* data, bool animate);
75 void createCollapseAnimation();
76 bool takeContent(uint04 index);
77 bool takeContent(SectionContent* data);
78 uint04 indexOfContent(SectionContent* c) const;
79 uint04 contentCount() const;
80 uint04 indexOfContentByUid(UUID uid) const;
81 uint04 indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = nullptr) const;
82 bool isLayoutVertical() const;
83 void hideCurrentSection();
84 bool isRibbonHorizontal() const;
85 bool isRibbonLayoutHorizontal() const;
86 void setTabLock(bool tab_lock);
87 void setTabVisible(bool visible);
88 uint04 activeIndex() const;
89 uint04 currentIndex() const;
90 bool event(QEvent* event) override;
91 uint04 indexOf(SectionContent* c);
92 void moveContent(uint04 from, uint04 to) override;
93 void swapIndices(uint04 from, uint04 to) override;
94 void setAnimationProgress(double width);
95 int prefferedContentWidth() const;
96 double animationProgress() const { return m_max_animation_progress; };
97 QSize minimumSizeHint() const override;
98 QSize normalMinimumSize() const;
99 QSize sizeHint() const override;
100 void finishAnimation();
101 void setCurrentIndex(uint04 index, bool animate);
102
103 SectionWidgetTabsScrollArea* tabScrollArea() { return m_tabs_scroll_area; };
104 bool showTabs() const { return m_show_tabs; }
105 bool hasVisibleTab() const;
106 void updateLayout(QBoxLayout* layout);
107 void setMinimizeAllowed(bool allowed);
108 bool minimizeAllowed();
109 void resizeEvent(QResizeEvent* event) override;
110 void setupAsBoxWidget(bool is_box_widget);
111 protected:
112 uint04 convertToIndexVisibleIndex(uint04 index);
113 int tabSize() const;
114 virtual void showEvent(QShowEvent*) override;
115 signals:
119 private slots:
120 void showTabMenuButtonIfNeeded();
121 void onTabsMenuButtonClicked();
122 void onSectionTitleClicked(SectionContent* content);
123 void onSpecialTitleClicked(SectionContent* content);
124 void onTabsMenuActionTriggered(bool);
125 public slots:
126 void updateTabs();
127
128 private:
129 const UUID m_uid;
130
131 ContainerWidgetBase* m_container;
132 Buffer<SectionContent*> m_contents;
133 Buffer<SectionTab*> m_section_titles;
134 Buffer<QWidget*> m_section_contents;
135 RibbonArea m_ribbon_area;
136 SectionWidgetTabsScrollArea* m_tabs_scroll_area;
137 Button* m_tabs_button;
138
139 uint04 m_current_index;
140 int m_last_width;
141 double m_max_animation_progress;
142 QPixmap* m_cached_image;
143 QPointer<QPropertyAnimation> m_resize_animation;
144 fltp08 m_location;
145 bool m_has_rendered = false;
146 bool m_minimize_allowed = true;
147 bool m_show_tabs = true;
148 };
149
150
151}
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition Button.h:60
Definition ContainerWidget.h:85
Definition QCustomStackedWidget.h:45
Definition SectionContent.h:47
Definition SectionWidget.h:55
double animationProgress() const
Definition SectionWidget.h:96
void ribbonLocationChangedSignal(RibbonArea area)
const Buffer< SectionContent * > & contents() const
Definition SectionWidget.h:71
void userChangedCurrentTabSignal(uint04 idx)
bool showTabs() const
Definition SectionWidget.h:104
void tabChangedSignal(uint04 idx)
SectionWidgetTabsScrollArea * tabScrollArea()
Definition SectionWidget.h:103
RibbonArea ribbonArea() const
Definition SectionWidget.h:69
Definition SectionWidgetTabsScrollArea.h:47
Definition UUID.h:66
Definition ACIColor.h:37
RibbonArea
Definition RibbonArea.h:68
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181