48 , m_is_animating(false)
51 : QSplitter(orientation, parent)
52 , m_is_animating(false)
59 m_is_animating = animating;
68 for (
int i = 0; i < count(); i++)
70 total += (orientation() == Qt::Orientation::Horizontal) ? widget(i)->sizeHint().width() : widget(i)->sizeHint().height();
72 int our_size = availableSize();
73 if (our_size == 0 || total == 0)
75 return cast<fltp08>(total) / cast<fltp08>(our_size);
79 int available_size = orientation() == Qt::Orientation::Horizontal ? width() : height();
80 available_size -= count() * style()->pixelMetric(QStyle::PixelMetric::PM_SplitterWidth,
nullptr,
this);
81 return available_size;
85 preferred_size =
getMax(preferred_size, min_size);
86 int available_size = availableSize();
88 if (available_size == 0)
89 return preferred_size;
91 return available_size;
93 for (
int i = 0; i < count(); i++)
95 total += (orientation() == Qt::Orientation::Horizontal) ? widget(i)->sizeHint().width() : widget(i)->sizeHint().height();
98 return available_size;
99 fltp08 multiple = cast<fltp08>(available_size) / cast<fltp08>(total + preferred_size - current_size);
100 if (preferred_size * multiple < min_size)
103 return cast<sint04>(preferred_size * multiple);
116 switch (event->type())
118 case QEvent::LayoutRequest:
124 return QSplitter::eventFilter(
object, event);
128 QList<int> current_sizes;
130 for (
int i = 0; i < count(); i++)
132 QWidget* w = widget(i);
133 QSize size_hint = w->sizeHint();
134 int local_size =
getMax(1, orientation() == Qt::Orientation::Horizontal ? size_hint.width() : size_hint.height());
135 total_size += local_size;
136 current_sizes.append(local_size);
138 int our_size = (orientation() == Qt::Orientation::Horizontal) ? width() : height();
139 if (total_size < our_size)
141 fltp08 size_multiple = cast<fltp08>(our_size) / cast<fltp08>(total_size);
143 for (
int i = 0; i < count(); i++)
145 current_sizes[i] = cast<int>(size_multiple * current_sizes[i]);
153 setSizes(current_sizes);
160 QList<int> current_sizes;
162 for (
int i = 0; i < count(); i++)
164 QWidget* w = widget(i);
165 QSize size_hint = w->sizeHint();
166 size_hint = size_hint.expandedTo(w->minimumSize());
167 int local_size =
getMax(1, orientation() == Qt::Orientation::Horizontal ? size_hint.width() : size_hint.height());
168 total_size += local_size;
169 current_sizes.append(local_size + offset);
171 int our_size = availableSize();
172 if (total_size < our_size)
174 fltp08 size_multiple = cast<fltp08>(our_size) / cast<fltp08>(total_size);
175 for (
int i = 0; i < count(); i++)
177 current_sizes[i] = cast<int>(size_multiple * current_sizes[i]);
180 setSizes(current_sizes);
A splitter lets the user control the size of 2 child widgets by dragging the boundary between them.
Definition QCustomSplitter.h:43
QSize minimumSizeHint() const override
Definition QCustomSplitter.h:110
QCustomSplitter(Qt::Orientation orientation, QWidget *parent=nullptr)
Definition QCustomSplitter.h:50
bool eventFilter(QObject *object, QEvent *event) override
Definition QCustomSplitter.h:114
bool m_is_animating
Definition QCustomSplitter.h:185
sint04 sizeIfAdded(sint04 preferred_size, sint04 min_size, sint04 current_size) const
Definition QCustomSplitter.h:83
void refreshSizes(int offset)
Definition QCustomSplitter.h:158
void refreshSizes()
Definition QCustomSplitter.h:126
int availableSize() const
Definition QCustomSplitter.h:77
QCustomSplitter(QWidget *parent=nullptr)
Definition QCustomSplitter.h:46
void setAnimating(bool animating)
Definition QCustomSplitter.h:57
fltp08 sizeMultiple()
Definition QCustomSplitter.h:65
virtual ~QCustomSplitter()
Definition QCustomSplitter.h:54
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:64
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator The only requirement is that t_type have > ...
Definition BaseFunctions.hpp:94
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Definition BaseValues.hpp:71
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149