Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
OverlapWidget Class Referencefinal

A widget for managing overlapping child widgets. More...

#include <overlap_widget.h>

Inheritance diagram for OverlapWidget:
[legend]
Collaboration diagram for OverlapWidget:
[legend]

Public Slots

void maxOverlapItemsChanged (int newValue)
 Updates the maximum number of overlapping items based on new value.
void overlapDirectionChanged (const QString &newDirection)
 Changes the layout direction based on the specified new direction.

Public Member Functions

 OverlapWidget (QWidget *parent, int overlapPercentage, int maxColumns, int maxRows, Qt::Orientation direction, bool adjustOnResize=false)
 Constructs an OverlapWidget with specified layout parameters.
void addWidget (QWidget *widgetToAdd) const
 Adds a widget to the overlap layout.
void insertWidgetAtIndex (QWidget *toInsert, int index)
void removeWidget (QWidget *widgetToRemove) const
void clearLayout ()
 Clears all widgets from the layout and deletes them.
void adjustMaxColumnsAndRows ()
 Dynamically adjusts maxColumns and maxRows based on widget size and layout direction.

Protected Member Functions

void resizeEvent (QResizeEvent *event) override
 Handles resizing events for the widget.

Private Attributes

OverlapLayoutoverlapLayout
int overlapPercentage
int maxColumns
int maxRows
Qt::Orientation direction
bool adjustOnResize = false

Detailed Description

A widget for managing overlapping child widgets.

The OverlapWidget class is a QWidget subclass that utilizes the OverlapLayout to arrange its child widgets in an overlapping manner. This widget allows configuration of overlap percentage, maximum columns, maximum rows, and layout direction, making it suitable for displaying elements that can partially stack over each other. The widget automatically manages resizing and re-layout of its child widgets based on the available space and specified parameters.

Constructor & Destructor Documentation

◆ OverlapWidget()

OverlapWidget::OverlapWidget ( QWidget * parent,
int overlapPercentage,
int maxColumns,
int maxRows,
Qt::Orientation direction,
bool adjustOnResize = false )

Constructs an OverlapWidget with specified layout parameters.

Initializes the OverlapWidget with the given overlap percentage, maximum number of columns and rows, and layout direction. Sets size policies to ensure the widget can expand as needed. A new OverlapLayout is created and assigned to manage the layout of child widgets.

Parameters
overlapPercentageThe percentage of overlap between child widgets (0-100).
maxColumnsThe maximum number of columns for the layout (0 for unlimited).
maxRowsThe maximum number of rows for the layout (0 for unlimited).
directionThe orientation of the layout, either Qt::Horizontal or Qt::Vertical.
adjustOnResizeIf the overlap widgets should adjust its max columns/rows on resize to fit.
parentThe parent widget of this OverlapWidget.

Member Function Documentation

◆ addWidget()

void OverlapWidget::addWidget ( QWidget * widgetToAdd) const

Adds a widget to the overlap layout.

This method appends the specified widget to the internal OverlapLayout, allowing it to be arranged with the existing child widgets. The widget's visibility and behavior will be managed by the layout.

Parameters
widgetToAddA pointer to the QWidget to be added to the layout.

◆ adjustMaxColumnsAndRows()

void OverlapWidget::adjustMaxColumnsAndRows ( )

Dynamically adjusts maxColumns and maxRows based on widget size and layout direction.

This function calculates the maximum number of columns or rows that can fit within the widget's width and height, depending on the layout direction. It then updates the OverlapLayout with these calculated values to ensure the layout is optimized.

Here is the caller graph for this function:

◆ clearLayout()

void OverlapWidget::clearLayout ( )

Clears all widgets from the layout and deletes them.

This method removes all child widgets from the OverlapLayout, deleting both the widget instances and their corresponding layout items. This ensures that the layout is empty and can be reused or refreshed as needed.

◆ insertWidgetAtIndex()

void OverlapWidget::insertWidgetAtIndex ( QWidget * toInsert,
int index )

◆ maxOverlapItemsChanged

void OverlapWidget::maxOverlapItemsChanged ( int newValue)
slot

Updates the maximum number of overlapping items based on new value.

This method updates the maximum number of columns or rows for the overlap layout based on the given new value. It adjusts the layout direction accordingly and triggers a size adjustment for the widget, ensuring the layout reflects the changes.

Parameters
newValueThe new maximum number of overlapping items allowed in the layout.
Here is the caller graph for this function:

◆ overlapDirectionChanged

void OverlapWidget::overlapDirectionChanged ( const QString & newDirection)
slot

Changes the layout direction based on the specified new direction.

This method modifies the layout direction of the OverlapLayout based on the input string. It updates the direction and triggers a size adjustment for the widget. Valid inputs are "Qt::Horizontal" and "Qt::Vertical".

Parameters
newDirectionThe new layout direction as a QString.
Here is the caller graph for this function:

◆ removeWidget()

void OverlapWidget::removeWidget ( QWidget * widgetToRemove) const

◆ resizeEvent()

void OverlapWidget::resizeEvent ( QResizeEvent * event)
overrideprotected

Handles resizing events for the widget.

This overridden method is called when the widget is resized. It invokes layout recalculation to ensure that the child widgets are correctly arranged based on the new dimensions. It marks the layout as dirty and activates it to reflect the changes.

Parameters
eventThe resize event containing the new size information.
Here is the call graph for this function:

Member Data Documentation

◆ adjustOnResize

bool OverlapWidget::adjustOnResize = false
private

◆ direction

Qt::Orientation OverlapWidget::direction
private

◆ maxColumns

int OverlapWidget::maxColumns
private

◆ maxRows

int OverlapWidget::maxRows
private

◆ overlapLayout

OverlapLayout* OverlapWidget::overlapLayout
private

◆ overlapPercentage

int OverlapWidget::overlapPercentage
private

The documentation for this class was generated from the following files: