NDEVR
API Documentation
SectionWidgetTabsScrollArea.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: SectionWidgetTabsScrollArea
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/RibbonArea.h>
35#include <NDEVR/Buffer.h>
36#include <QWidget>
37class QScrollArea;
38class QFrame;
39class QBoxLayout;
40class QSpacerItem;
41namespace NDEVR
42{
44 class ScrollEdge;
48 class NDEVR_WIDGETS_API SectionWidgetTabsScrollArea : public QWidget
49 {
50 Q_OBJECT
51 public:
56 SectionWidgetTabsScrollArea(QWidget* parent = nullptr);
62 QSize sizeHint() const override;
67 QSize minimumSizeHint() const override;
72 QWidget* tabsContainer() const { return m_tabs_container_widget; }
77 void removeMainWidget(bool animate);
84 void insertMainWidget(uint04 index, QWidget* widget, bool animate);
90 void insertTabWidget(uint04 index, QWidget* widget);
95 void removeTabWidget(QWidget* widget);
101 bool hasTabWidget(QWidget* widget);
106 void setWidgetSelected(QWidget* widget);
111 void resizeEvent(QResizeEvent* event) override;
116 QScrollArea* scrollArea() { return m_scroll_area; }
126 RibbonArea area() const { return m_ribbon_area; }
132 uint04 indexOf(QWidget* widget) const;
137 uint04 count() const;
143 QWidget* widget(uint04 index);
149 void swap(uint04 a, uint04 b);
155 void move(uint04 from, uint04 to);
160 bool isAtBottom() const;
165 bool isAtTop() const;
170 bool isVertical() const;
175 bool isRelativeVertical() const;
180 bool isTextVertical() const;
189 void setAutoExpand(bool auto_expand);
194 void paintEvent(QPaintEvent* event) override;
202 void showEvent(QShowEvent*) override;
208 bool event(QEvent* event) override;
213 QWidget* mainWidget() const;
214 signals:
219 protected:
224 QSize scrollSizeHint() const;
229 void setupSeparator(QFrame* line);
234 QBoxLayout* tabsLayout() { return m_tabs_layout; }
255 protected:
259 virtual void wheelEvent(QWheelEvent*) override;
260 QScrollArea* m_scroll_area;
262 QBoxLayout* m_tabs_layout;
263 QWidget* m_inner_scroll;
265 QWidget* m_float_widget;
267 QSpacerItem* m_spacer_item;
270 QWidget* m_main_widget = nullptr;
274 ScrollEdge* m_top_edge;
275 ScrollEdge* m_bottom_edge;
277 bool m_is_bottom = false;
279 bool m_auto_expand = false;
281 uint04 m_main_widget_location = Constant<uint04>::Invalid;
282 };
283}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
QWidget * m_tabs_container_widget
The container widget holding all tabs.
void insertMainWidget(uint04 index, QWidget *widget, bool animate)
Inserts a main content widget at the given index.
QWidget * mainWidget() const
Returns the main content widget, if one has been inserted.
void setupSeparator(QFrame *line)
Configures a QFrame as a separator line between tabs.
void recalculateScrollerSnaps()
Recalculates snap positions for the scroller based on tab positions.
void setWidgetSelected(QWidget *widget)
Sets the given widget as the currently selected tab, updating the highlight.
RibbonArea m_ribbon_area
The current ribbon area for layout orientation.
bool isTextVertical() const
Returns whether the tab text should be rendered vertically.
bool event(QEvent *event) override
Processes generic events such as layout requests and style changes.
SectionWidgetTabsScrollArea(QWidget *parent=nullptr)
Constructs a SectionWidgetTabsScrollArea with the given parent widget.
uint04 m_main_widget_location
The index of the main widget in the layout.
QWidget * m_main_widget
The main content widget, if present.
bool m_auto_expand
Whether to auto-expand to fit all tabs without scrolling.
RibbonArea area() const
Returns the current ribbon area for this scroll area.
QBoxLayout * m_tabs_layout
The layout arranging the tab widgets.
void swap(uint04 a, uint04 b)
Swaps the positions of two tab widgets.
void insertTabWidget(uint04 index, QWidget *widget)
Inserts a tab widget at the given index.
void removeTabWidget(QWidget *widget)
Removes the given tab widget from the scroll area.
bool isAtBottom() const
Returns whether the scroll position is at the bottom (or right for horizontal).
QSize scrollSizeHint() const
Returns the recommended size for the internal scroll content.
uint04 count() const
Returns the number of tab widgets in this scroll area.
SelectionHighlightBar * m_highlight_bar
The animated selection highlight bar.
bool m_auto_scroll_to_bottom
Whether to automatically scroll to bottom on content change.
void jumpToBottom()
Scrolls the view to the bottom (or right for horizontal layout).
bool isAtTop() const
Returns whether the scroll position is at the top (or left for horizontal).
QWidget * m_selected_widget
The currently selected tab widget.
void move(uint04 from, uint04 to)
Moves a tab widget from one index to another.
ScrollEdge * m_bottom_edge
Fade indicator at the bottom (or right) scroll edge.
QWidget * m_inner_scroll
The inner scrollable widget.
QScrollArea * m_scroll_area
The scroll area containing the tab widgets.
virtual void wheelEvent(QWheelEvent *) override
Handles mouse wheel events for scrolling the tab area.
QWidget * m_float_widget
A floating widget used during drag operations.
void setArea(RibbonArea area)
Sets the ribbon area, updating layout direction accordingly.
void resetScroller()
Resets the scroller to its initial position.
uint04 indexOf(QWidget *widget) const
Returns the index of the given widget in the tab list.
void updateSeparatorSizes()
Updates the sizes of the separator lines between tabs.
QSpacerItem * m_spacer_item
Spacer item used for layout padding.
bool isVertical() const
Returns whether the layout direction is vertical.
Buffer< QWidget * > m_widgets
All tab widgets in display order.
void removeMainWidget(bool animate)
Removes the main content widget from the scroll area.
bool hasTabWidget(QWidget *widget)
Returns whether the given tab widget exists in this scroll area.
QBoxLayout * tabsLayout()
Returns the box layout used to arrange tab widgets.
void updateEdgeLocations()
Updates the positions of the scroll edge fade indicators.
QTimer * m_bounds_updater
Timer for deferred bounds recalculation.
QSize minimumSizeHint() const override
Returns the minimum recommended size for this scroll area.
bool isRelativeVertical() const
Returns whether the layout is relatively vertical, accounting for ribbon area orientation.
QSize sizeHint() const override
Returns the recommended size for this scroll area.
QBoxLayout * m_inner_scroll_layout
The layout for the inner scroll widget.
QScrollArea * scrollArea()
Returns the underlying QScrollArea used for scrolling tabs.
void updateSelectionWidgetHighlight()
Updates the position and size of the selection highlight bar.
void resizeEvent(QResizeEvent *event) override
Handles resize events to update scroll behavior and edge indicators.
void showEvent(QShowEvent *) override
Handles the show event to initialize scroll state.
QWidget * tabsContainer() const
Returns the container widget that holds the tab widgets.
void boundsUpdateFinishedSignal()
Emitted when the bounds update timer has finished recalculating layout.
bool m_is_shown
Whether this widget is currently shown.
void setAutoExpand(bool auto_expand)
Sets whether the scroll area should automatically expand to fit all tabs.
void paintEvent(QPaintEvent *event) override
Paints the scroll area background.
Buffer< QFrame * > m_separators
Separator lines between tab widgets.
uint04 m_update_count
Counter for pending layout updates.
QWidget * widget(uint04 index)
Returns the tab widget at the given index.
bool m_is_bottom
Whether the scroll is currently at the bottom.
void updateSizePolicy()
Updates the size policy based on the current layout orientation and content.
ScrollEdge * m_top_edge
Fade indicator at the top (or left) scroll edge.
Provides a highlighted animation for selecting docked tabs using the NDEVR API Widget Docking system.
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...
RibbonArea
Requests a ribbon or tab area to be in a certain location and orientation relative to another widget.
Definition RibbonArea.h:71