Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSizeGroup Class Reference

#include <kis_size_group.h>

+ Inheritance diagram for KisSizeGroup:

Public Types

enum  mode { KIS_SIZE_GROUP_NONE = 0 , KIS_SIZE_GROUP_HORIZONTAL = 1 << 0 , KIS_SIZE_GROUP_VERTICAL = 1 << 1 , KIS_SIZE_GROUP_BOTH = (KIS_SIZE_GROUP_HORIZONTAL | KIS_SIZE_GROUP_VERTICAL) }
 

Public Member Functions

void addWidget (QWidget *widget)
 
KisSizeGroup::mode getMode () const
 Returns the current mode of the group size.
 
bool isIgnoreHidden () const
 Returns whether the group ignores not visible widgets.
 
 KisSizeGroup (QObject *parent=0, KisSizeGroup::mode mode=KisSizeGroup::KIS_SIZE_GROUP_HORIZONTAL, bool ignoreHidden=false)
 
void removeWidget (QWidget *widget)
 Removes a widget from the size group.
 
void setIgnoreHidden (bool ignoreHidden)
 Sets whether the group will ignore not visible widgets.
 
void setMode (KisSizeGroup::mode mode)
 Changes the group size mode.
 
 ~KisSizeGroup () override
 

Private Attributes

KisSizeGroupPrivate *const d
 

Detailed Description

KisSizeGroup provides a mechanism to group widgets together so they all request the same amount of space. Also, the widgets will share the same amount of minimum space. The mode of KisSizeGroup determines the direction of the space that are affected by the size group.

All widgets inside of KisSizeGroup will use the same size hint value, computed as the maximum of all of his size hint values. The same value is used for the minimum size of all widgets. When KisSizeGroup ignore hidden widgets, the size of widgets that are not visible don't count in the computation of the current size value. When one of these widgets becomes visible again, a new size value is computed and applied to all visible widgets.

KisSizeGroup cannot share the same widget with other size groups, so one widget can be in one, and only one, KisSizeGroup at time.

NOTE: Added widgets in size groups must be laid out inside of a valid layout. The current implementation supports widgets laid out inside of QGridLayout, QFormLayout and QBoxLayout. If the parent widget layout is not one of them, then the group size will not affect the widget size.

Definition at line 37 of file kis_size_group.h.

Member Enumeration Documentation

◆ mode

Determines the direction in which the size group affects the requested and minimum sizes of his component widgets.

Enumerator
KIS_SIZE_GROUP_NONE 
KIS_SIZE_GROUP_HORIZONTAL 

group has no effect

KIS_SIZE_GROUP_VERTICAL 

group affects horizontal size

KIS_SIZE_GROUP_BOTH 

group affects vertical size

Definition at line 46 of file kis_size_group.h.

47 {
52 };
@ KIS_SIZE_GROUP_BOTH
group affects vertical size
@ KIS_SIZE_GROUP_VERTICAL
group affects horizontal size
@ KIS_SIZE_GROUP_HORIZONTAL
group has no effect

Constructor & Destructor Documentation

◆ KisSizeGroup()

KisSizeGroup::KisSizeGroup ( QObject * parent = 0,
KisSizeGroup::mode mode = KisSizeGroup::KIS_SIZE_GROUP_HORIZONTAL,
bool ignoreHidden = false )
explicit

Creates a new size group.

By default, the mode of the size group is KIS_SIZE_GROUP_HORIZONTAL and the group will not ignore hidden widgets.

Definition at line 11 of file kis_size_group.cpp.

12 : QObject(parent)
13 , d(new KisSizeGroupPrivate(this, mode, ignoreHidden))
14{}
KisSizeGroupPrivate *const d

◆ ~KisSizeGroup()

KisSizeGroup::~KisSizeGroup ( )
override

Definition at line 16 of file kis_size_group.cpp.

17{
18 delete d;
19}

References d.

Member Function Documentation

◆ addWidget()

void KisSizeGroup::addWidget ( QWidget * widget)

Adds a new widget to the group. WARNING: adding the same widget to multiple size groups is not supported!

Definition at line 47 of file kis_size_group.cpp.

48{
49 d->addWidget(widget);
51}
void addWidget(QWidget *widget)
void scheduleSizeUpdate()
Schedules an update of all widgets size.

References KisSizeGroupPrivate::addWidget(), d, and KisSizeGroupPrivate::scheduleSizeUpdate().

◆ getMode()

KisSizeGroup::mode KisSizeGroup::getMode ( ) const

Returns the current mode of the group size.

Definition at line 29 of file kis_size_group.cpp.

30{
31 return d->m_mode;
32}
KisSizeGroup::mode m_mode

References d, and KisSizeGroupPrivate::m_mode.

◆ isIgnoreHidden()

bool KisSizeGroup::isIgnoreHidden ( ) const

Returns whether the group ignores not visible widgets.

Definition at line 42 of file kis_size_group.cpp.

43{
44 return d->m_ignoreHidden;
45}

References d, and KisSizeGroupPrivate::m_ignoreHidden.

◆ removeWidget()

void KisSizeGroup::removeWidget ( QWidget * widget)

Removes a widget from the size group.

Definition at line 53 of file kis_size_group.cpp.

54{
55 d->removeWidget(widget);
57}
void removeWidget(QWidget *widget)

References d, KisSizeGroupPrivate::removeWidget(), and KisSizeGroupPrivate::scheduleSizeUpdate().

◆ setIgnoreHidden()

void KisSizeGroup::setIgnoreHidden ( bool ignoreHidden)

Sets whether the group will ignore not visible widgets.

Definition at line 34 of file kis_size_group.cpp.

35{
36 if (d->m_ignoreHidden != ignoreHidden) {
37 d->m_ignoreHidden = ignoreHidden;
39 }
40}

References d, KisSizeGroupPrivate::m_ignoreHidden, and KisSizeGroupPrivate::scheduleSizeUpdate().

◆ setMode()

void KisSizeGroup::setMode ( KisSizeGroup::mode mode)

Changes the group size mode.

Definition at line 21 of file kis_size_group.cpp.

22{
23 if (d->m_mode != mode) {
24 d->m_mode = mode;
26 }
27}

References d, KisSizeGroupPrivate::m_mode, and KisSizeGroupPrivate::scheduleSizeUpdate().

Member Data Documentation

◆ d

KisSizeGroupPrivate* const KisSizeGroup::d
private

Definition at line 86 of file kis_size_group.h.


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