45 , m_is_animating(false)
48 : QSplitter(orientation, parent)
49 , m_is_animating(false)
56 m_is_animating = animating;
65 for (
int i = 0; i < count(); i++)
67 total += (orientation() == Qt::Orientation::Horizontal) ? widget(i)->sizeHint().width() : widget(i)->sizeHint().height();
69 int our_size = availableSize();
70 if (our_size == 0 || total == 0)
72 return cast<fltp08>(total) / cast<fltp08>(our_size);
76 int available_size = orientation() == Qt::Orientation::Horizontal ? width() : height();
77 available_size -= count() * style()->pixelMetric(QStyle::PixelMetric::PM_SplitterWidth,
nullptr,
this);
78 return available_size;
82 preferred_size =
getMax(preferred_size, min_size);
83 int available_size = availableSize();
85 if (available_size == 0)
86 return preferred_size;
88 return available_size;
90 for (
int i = 0; i < count(); i++)
92 total += (orientation() == Qt::Orientation::Horizontal) ? widget(i)->sizeHint().width() : widget(i)->sizeHint().height();
95 return available_size;
96 fltp08 multiple = cast<fltp08>(available_size) / cast<fltp08>(total + preferred_size - current_size);
97 if (preferred_size * multiple < min_size)
100 return cast<sint04>(preferred_size * multiple);
113 switch (event->type())
115 case QEvent::LayoutRequest:
121 return QSplitter::eventFilter(
object, event);
125 QList<int> current_sizes;
127 for (
int i = 0; i < count(); i++)
129 QWidget* w = widget(i);
130 QSize size_hint = w->sizeHint();
131 int local_size =
getMax(1, orientation() == Qt::Orientation::Horizontal ? size_hint.width() : size_hint.height());
132 total_size += local_size;
133 current_sizes.append(local_size);
135 int our_size = (orientation() == Qt::Orientation::Horizontal) ? width() : height();
136 if (total_size < our_size)
138 fltp08 size_multiple = cast<fltp08>(our_size) / cast<fltp08>(total_size);
140 for (
int i = 0; i < count(); i++)
142 current_sizes[i] = cast<int>(size_multiple * current_sizes[i]);
150 setSizes(current_sizes);
157 QList<int> current_sizes;
159 for (
int i = 0; i < count(); i++)
161 QWidget* w = widget(i);
162 QSize size_hint = w->sizeHint();
163 size_hint = size_hint.expandedTo(w->minimumSize());
164 int local_size =
getMax(1, orientation() == Qt::Orientation::Horizontal ? size_hint.width() : size_hint.height());
165 total_size += local_size;
166 current_sizes.append(local_size + offset);
168 int our_size = availableSize();
169 if (total_size < our_size)
171 fltp08 size_multiple = cast<fltp08>(our_size) / cast<fltp08>(total_size);
172 for (
int i = 0; i < count(); i++)
174 current_sizes[i] = cast<int>(size_multiple * current_sizes[i]);
177 setSizes(current_sizes);
Definition QCustomSplitter.h:40
QSize minimumSizeHint() const override
Definition QCustomSplitter.h:107
QCustomSplitter(Qt::Orientation orientation, QWidget *parent=nullptr)
Definition QCustomSplitter.h:47
bool eventFilter(QObject *object, QEvent *event) override
Definition QCustomSplitter.h:111
bool m_is_animating
Definition QCustomSplitter.h:182
sint04 sizeIfAdded(sint04 preferred_size, sint04 min_size, sint04 current_size) const
Definition QCustomSplitter.h:80
void refreshSizes(int offset)
Definition QCustomSplitter.h:155
void refreshSizes()
Definition QCustomSplitter.h:123
int availableSize() const
Definition QCustomSplitter.h:74
QCustomSplitter(QWidget *parent=nullptr)
Definition QCustomSplitter.h:43
void setAnimating(bool animating)
Definition QCustomSplitter.h:54
fltp08 sizeMultiple()
Definition QCustomSplitter.h:62
virtual ~QCustomSplitter()
Definition QCustomSplitter.h:51
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:76
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator.
Definition BaseFunctions.hpp:116
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
Definition BaseValues.hpp:86
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181