NDEVR
API Documentation
SectionWidget.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: 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/ResizeVisibleAnimation.h>
37#include <NDEVR/UUID.h>
38#include <NDEVR/Buffer.h>
39#include <QScrollArea>
40class QBoxLayout;
41class QStackedLayout;
42class QPushButton;
43class QMenu;
44class QToolButton;
45class QPropertyAnimation;
46namespace NDEVR
47{
49 class Button;
56 class NDEVR_WIDGETS_API SectionWidget : public QWidget
57 {
58 Q_OBJECT
59 Q_PROPERTY(double animation_progress READ animationProgress WRITE setAnimationProgress)
60 public:
66 explicit SectionWidget(ContainerWidgetBase* parent, RibbonArea ribbon_area);
67 virtual ~SectionWidget();
72 UUID uid() const;
82 RibbonArea ribbonArea() const { return m_ribbon_area; }
92 const Buffer<SectionContent*>& contents() const { return m_contents; }
103 void addContent(SectionContent* data, bool animate);
110 void insertContent(uint04 index, SectionContent* data, bool animate);
116 bool takeContent(uint04 index);
146 uint04 indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = nullptr) const;
151 bool isLayoutVertical() const;
160 bool isRibbonHorizontal() const;
170 void setTabLock(bool tab_lock);
175 void setTabVisible(bool visible);
196 void setAnimationProgress(double width);
206 void setCurrentIndex(uint04 index, bool animate);
211 SectionWidgetTabsScrollArea* tabScrollArea() { return m_tabs_scroll_area; };
216 bool showTabs() const { return m_show_tabs; }
221 bool hasVisibleTab() const;
226 void updateLayout(QBoxLayout* layout);
231 void setMinimizeAllowed(bool allowed);
241 void setupAsBoxWidget(bool is_box_widget);
246 QRect titleAreaGeometry() const;
252 void moveContent(uint04 from, uint04 to);
258 void swapIndices(uint04 from, uint04 to);
263 QSize minimumSizeHint() const override;
268 QSize sizeHint() const override;
269 protected:
273 virtual void showEvent(QShowEvent*) override;
278 void resizeEvent(QResizeEvent* event) override;
284 bool event(QEvent* event) override;
289 private:
294 int preferredContentWidth() const;
299 double animationProgress() const { return m_max_animation_progress; };
304 QSize normalMinimumSize() const;
309 void createCollapseAnimation(bool visible);
315 uint04 convertToIndexVisibleIndex(uint04 index);
320 int tabSize() const;
321 signals:
337 private slots:
341 void showTabMenuButtonIfNeeded();
345 void onTabsMenuButtonClicked();
350 void onSectionTitleClicked(SectionContent* content);
355 void onSpecialTitleClicked(SectionContent* content);
360 void onTabsMenuActionTriggered(bool);
361 public slots:
366 private:
367 const UUID m_uid;
368 QCustomStackedWidget* m_stacked_widget;
369 ContainerWidgetBase* m_container;
370 Buffer<SectionContent*> m_contents;
371 Buffer<SectionTab*> m_section_titles;
372 Buffer<QWidget*> m_section_contents;
373 RibbonArea m_ribbon_area;
374 SectionWidgetTabsScrollArea* m_tabs_scroll_area;
375 Button* m_tabs_button;
376 uint04 m_current_index;
377 int m_last_width;
378 double m_max_animation_progress;
379 QPixmap* m_cached_image;
380 QPointer<ResizeVisibleAnimation> m_resize_animation;
381 fltp08 m_location;
382 bool m_has_rendered = false;
383 bool m_minimize_allowed = true;
384 bool m_show_tabs = true;
385 };
386
387
388}
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...
The main class for a layout where all widgets occupy the same same and only one widget is shown at a ...
The core container for objects using the NDEVR API Widget Docking system.
Custom scrollable implementation for docked tabs using the NDEVR API Widget Docking system.
void resizeEvent(QResizeEvent *event) override
Handles resize events to update tab and content layout.
void insertContent(uint04 index, SectionContent *data, bool animate)
Inserts section content at the specified index with optional animation.
void moveContent(uint04 from, uint04 to)
Moves content from one index to another.
const Buffer< SectionContent * > & contents() const
Returns the buffer of all section contents managed by this widget.
void finishAnimation()
Immediately finishes any in-progress collapse or expand animation.
SectionWidgetTabsScrollArea * tabScrollArea()
Returns the scroll area widget that contains the tab bar.
void addContent(SectionContent *c)
Adds section content to this widget without animation.
uint04 indexOfContentByTitlePos(const QPoint &pos, QWidget *exclude=nullptr) const
Finds the index of section content whose tab title is at the given position.
void tabChangedSignal(uint04 idx)
Emitted when the active tab index changes.
void hideCurrentSection()
Hides the currently displayed section content.
void addContent(SectionContent *data, bool animate)
Adds section content to this widget with optional animation.
ContainerWidgetBase * containerWidget() const
Returns the container widget that owns this section widget.
void setRibbonArea(RibbonArea area)
Sets the ribbon area where this section widget is docked.
bool event(QEvent *event) override
Processes generic events such as style and layout changes.
void setTabLock(bool tab_lock)
Locks or unlocks tab dragging and reordering.
bool isRibbonLayoutHorizontal() const
Returns whether the ribbon layout direction is horizontal.
void setTabVisible(bool visible)
Sets whether the tab bar is visible.
UUID uid() const
Returns the unique identifier for this section widget.
bool takeContent(SectionContent *data)
Removes and releases the given section content.
QSize minimumSizeHint() const override
Returns the minimum recommended size for this section widget.
void updateLayout()
Updates the internal layout based on the current ribbon area and content.
bool hasVisibleTab() const
Returns whether at least one tab is currently visible.
void updateTabs()
Updates the tab bar display to reflect the current content state.
bool takeContent(uint04 index)
Removes and releases section content at the given index.
bool minimizeAllowed()
Returns whether the section widget can be minimized (collapsed).
bool isRibbonHorizontal() const
Returns whether the ribbon area is oriented horizontally (top or bottom).
void setCurrentIndex(uint04 index, bool animate)
Sets the currently displayed content by index with optional animation.
virtual void showEvent(QShowEvent *) override
Handles the show event to initialize rendering state.
void setMinimizeAllowed(bool allowed)
Sets whether the section widget can be minimized (collapsed).
void updateLayout(QBoxLayout *layout)
Updates the internal layout using the provided box layout.
void swapIndices(uint04 from, uint04 to)
Swaps the content at two indices.
SectionWidget(ContainerWidgetBase *parent, RibbonArea ribbon_area)
Constructs a SectionWidget within the given container and ribbon area.
uint04 activeIndex() const
Returns the index of the currently active (visible) content.
bool showTabs() const
Returns whether the tab bar is currently shown.
RibbonArea ribbonArea() const
Returns the ribbon area where this section widget is docked.
uint04 currentIndex() const
Returns the index of the currently selected content.
QRect titleAreaGeometry() const
Returns the geometry of the tab title area.
uint04 indexOf(SectionContent *c)
Returns the index of the given section content.
uint04 indexOfContentByUid(UUID uid) const
Finds the index of section content by its UUID.
void setupAsBoxWidget(bool is_box_widget)
Configures this section widget to behave as a box widget with simplified layout.
void userChangedCurrentTabSignal(uint04 idx)
Emitted when the user explicitly changes the active tab.
void ribbonLocationChangedSignal(RibbonArea area)
Emitted when the ribbon docking location changes.
uint04 indexOfContent(SectionContent *c) const
Returns the index of the given section content within this widget.
void setAnimationProgress(double width)
Sets the animation progress for the collapse or expand animation.
uint04 contentCount() const
Returns the number of section contents managed by this widget.
QSize sizeHint() const override
Returns the recommended size for this section widget.
bool isLayoutVertical() const
Returns whether the content layout direction is vertical.
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.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
RibbonArea
Requests a ribbon or tab area to be in a certain location and orientation relative to another widget.
Definition RibbonArea.h:71