6#include "fifechan/widgets/adjustingcontainer.hpp"
15#include "fifechan/exception.hpp"
19 AdjustingContainer::AdjustingContainer()
29 AdjustingContainer::~AdjustingContainer() =
default;
33 assert(
"number of columns must be positive" && numberOfColumns > 0);
63 return Alignment::Left;
111 assert(
"widget must not be null" && widget !=
nullptr);
144 if (std::cmp_greater(
148 if (std::cmp_greater(
178 unsigned int columnCount = 0;
179 unsigned int rowCount = 0;
195 case Alignment::Left:
196 mContainedWidget->setX(basex);
198 case Alignment::Center:
199 mContainedWidget->setX(basex + ((
mColumnWidths.at(columnCount) - mContainedWidget->getWidth()) / 2));
201 case Alignment::Right:
202 mContainedWidget->setX(basex +
mColumnWidths.at(columnCount) - mContainedWidget->getWidth());
208 mContainedWidget->setY(y);
Alignment getColumnAlignment(unsigned int column) const
Get a specific column's alignment.
virtual void adjustContent()
Rearrange the widgets and resize the container.
unsigned int mNumberOfRows
Number of rows in the layout (derived from children count).
std::vector< Alignment > mColumnAlignment
The alignment of each column.
unsigned int mWidth
Cached container width used during layout.
std::vector< unsigned int > mColumnWidths
Computed width for each column (in pixels).
void adjustSize() override
Resizes the widget's size to fit the content exactly.
virtual void setNumberOfColumns(unsigned int numberOfColumns)
Set the number of columns to divide the widgets into.
virtual unsigned int getNumberOfColumns() const
Get the number of columns the widget is divided.
Rectangle getChildrenArea() override
Gets the area of the widget occupied by the widget's children.
virtual void setColumnAlignment(unsigned int column, Alignment alignment)
Set a specific column's alignment.
unsigned int mHeight
Cached container height used during layout.
void resizeToContent(bool recursion=true) override
Resize the adjusting container to fit its children.
std::vector< Widget * > mContainedWidgets
The widgets contained in the adjusting container in layout order.
unsigned int mNumberOfColumns
Number of columns in the layout.
void remove(Widget *widget) override
Removes a specific child from the widget.
Alignment
Possible alignment values for each column.
std::vector< unsigned int > mRowHeights
Computed height for each row (in pixels).
void removeAllChildren() override
Remvoes all children from the widget.
void add(Widget *widget) override
Adds a widget to the container.
void remove(Widget *widget) override
Removes a widget from the Container.
virtual void setHorizontalSpacing(unsigned int spacing)
Set the horizontal spacing between columns.
unsigned int mVerticalSpacing
VerticalSpacing.
unsigned int mHorizontalSpacing
HorizontalSpacing.
void resizeToContent(bool recursion=true) override
Resize this container to fit its children.
virtual void add(Widget *widget)
Adds a widget to the container.
void removeAllChildren() override
Removes all widgets from the the container.
virtual void setVerticalSpacing(unsigned int spacing)
Set the vertical spacing between rows.
Represents a rectangular area (X, Y, Width, Height).
int width
Holds the width of the rectangle.
int y
Holds the x coordinate of the rectangle.
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.
Used replacement tokens by configure_file():
void throwException(std::string const &message, std::source_location location=std::source_location::current())
Throw an Exception capturing the current source location.