34#include <NDEVR/BaseValues.h>
62 : QSplitter(orientation, parent)
89 for (
int i = 0; i < count(); i++)
91 total += (orientation() == Qt::Orientation::Horizontal) ? widget(i)->sizeHint().width() : widget(i)->sizeHint().height();
94 if (our_size == 0 || total == 0)
104 int available_size = orientation() == Qt::Orientation::Horizontal ? width() : height();
105 available_size -= count() * style()->pixelMetric(QStyle::PixelMetric::PM_SplitterWidth,
nullptr,
this);
106 return available_size;
118 preferred_size =
getMax(preferred_size, min_size);
121 if (available_size == 0)
122 return preferred_size;
124 return available_size;
126 for (
int i = 0; i < count(); i++)
128 total += (orientation() == Qt::Orientation::Horizontal) ? widget(i)->sizeHint().width() : widget(i)->sizeHint().height();
131 return available_size;
133 if (preferred_size * multiple < min_size)
159 switch (
event->type())
161 case QEvent::LayoutRequest:
167 return QSplitter::eventFilter(
object,
event);
175 QList<int> current_sizes;
177 for (
int i = 0; i < count(); i++)
179 QWidget* w = widget(i);
180 QSize size_hint = w->sizeHint();
181 int local_size =
getMax(1, orientation() == Qt::Orientation::Horizontal ? size_hint.width() : size_hint.height());
182 total_size += local_size;
183 current_sizes.append(local_size);
185 int our_size = (orientation() == Qt::Orientation::Horizontal) ? width() : height();
186 if (total_size < our_size)
190 for (
int i = 0; i < count(); i++)
192 current_sizes[i] =
cast<int>(size_multiple * current_sizes[i]);
200 setSizes(current_sizes);
212 QList<int> current_sizes;
214 for (
int i = 0; i < count(); i++)
216 QWidget* w = widget(i);
217 QSize size_hint = w->sizeHint();
218 size_hint = size_hint.expandedTo(w->minimumSize());
219 int local_size =
getMax(1, orientation() == Qt::Orientation::Horizontal ? size_hint.width() : size_hint.height());
220 total_size += local_size;
221 current_sizes.append(local_size + offset);
224 if (total_size < our_size)
227 for (
int i = 0; i < count(); i++)
229 current_sizes[i] =
cast<int>(size_multiple * current_sizes[i]);
232 setSizes(current_sizes);
246 return QWidget::event(e);
248 return QSplitter::event(e);
259 bool visible = isVisible();
262 QSplitter::childEvent(c);
273 return QSplitter::childEvent(c);
A splitter lets the user control the size of 2 child widgets by dragging the boundary between them.
QSize minimumSizeHint() const override
Returns a minimal size hint to allow the splitter to be as small as possible.
QCustomSplitter(QWidget *parent=nullptr)
Constructs a splitter with default orientation.
bool m_is_animating
Whether the splitter is currently in an animation state.
sint04 sizeIfAdded(sint04 preferred_size, sint04 min_size, sint04 current_size) const
Calculates the size a widget would be given if added to the splitter, accounting for proportional sca...
bool event(QEvent *e) override
Handles events, optionally blocking them during visibility toggling to prevent recursive layout issue...
fltp08 sizeMultiple()
Calculates the ratio of the total preferred size of all child widgets to the available splitter space...
void childEvent(QChildEvent *c) override
Handles child widget add and remove events, temporarily hiding and re-showing the splitter on removal...
bool m_block_events
Whether to block events during visibility toggling.
void setAnimating(bool animating)
Sets whether the splitter is currently in an animation state.
void refreshSizes()
Recalculates and applies proportional sizes for all child widgets based on their size hints and the a...
int availableSize() const
Returns the available space for child widgets, excluding splitter handle widths.
bool eventFilter(QObject *object, QEvent *event) override
Filters events for child widgets, refreshing sizes on layout requests.
QCustomSplitter(Qt::Orientation orientation, QWidget *parent=nullptr)
Constructs a splitter with the specified orientation.
void refreshSizes(int offset)
Recalculates and applies proportional sizes for all child widgets with an additional offset applied t...
The primary namespace for the NDEVR SDK.
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 > ...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.