5#ifndef INCLUDE_FIFECHAN_WIDGETS_CONTAINER_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_CONTAINER_HPP_
14#include "fifechan/platform.hpp"
17#include "fifechan/graphics.hpp"
18#include "fifechan/listeners/containerlistener.hpp"
19#include "fifechan/widget.hpp"
129 virtual void addWidget(std::unique_ptr<Widget> widget);
141 virtual void add(
Widget* widget,
int x,
int y);
150 virtual void addWidget(std::unique_ptr<Widget> widget,
int x,
int y);
229 return mLayout != LayoutPolicy::Absolute;
239 virtual void setLayout(LayoutPolicy policy);
248 virtual LayoutPolicy getLayout()
const;
258 virtual void setUniformSize(
bool uniform);
267 virtual bool isUniformSize()
const;
275 virtual void setVerticalSpacing(
unsigned int spacing);
283 virtual unsigned int getVerticalSpacing()
const;
291 virtual void setHorizontalSpacing(
unsigned int spacing);
299 virtual unsigned int getHorizontalSpacing()
const;
306 void setBackgroundWidget(
Widget* widget);
313 Widget* getBackgroundWidget();
322 void distributeWidgetAddedEvent(
Widget* source);
330 void distributeWidgetRemovedEvent(
Widget* source);
Interface for listening to container modification events.
bool isLayouted() override
Helper function to decide if we need to layout.
void remove(Widget *widget) override
Removes a widget from the Container.
void draw(Graphics *graphics) override
Draws the widget.
bool mOpaque
True if the container is opaque, false otherwise.
void addContainerListener(ContainerListener *containerListener)
Adds a container listener to the container.
unsigned int mVerticalSpacing
VerticalSpacing.
LayoutPolicy mLayout
Layout.
unsigned int mHorizontalSpacing
HorizontalSpacing.
Widget * mBackgroundWidget
Optional widget that is rendered behind other children as the container background.
virtual void setOpacity(float opacity)
Sets the opacity of the container.
Widget * findWidgetById(std::string const &id) override
Finds a widget given an id.
void resizeToContent(bool recursion=true) override
Resize this container to fit its children.
virtual bool isOpaque() const
Checks if the container is opaque or not.
void expandContent(bool recursion) override
Expand children to occupy available space in this container.
float mOpacity
Opacity of the container, between 0.0 (fully transparent) and 1.0 (fully opaque).
virtual void add(Widget *widget)
Adds a widget to the container.
LayoutPolicy
The layout policy of the container.
ContainerListenerList::iterator ContainerListenerIterator
Iterator for ContainerListenerList.
void removeAllChildren() override
Removes all widgets from the the container.
Rectangle getChildrenArea() override
Gets the area of the widget occupied by the widget's children.
virtual void addWidget(std::unique_ptr< Widget > widget)
Adds a widget to the container, transferring ownership.
bool mUniform
Indicates if the childs should be expanded to a uniform size.
void removeContainerListener(ContainerListener *containerListener)
Removes a container listener from the container.
void adjustSize() override
Adjust the size of the container after layout computations.
Widget * getChild(unsigned int index) const
Gets child by index.
ContainerListenerList mContainerListeners
The container listeners of the container.
virtual void setOpaque(bool opaque)
Sets the container to be opaque or not.
std::list< ContainerListener * > ContainerListenerList
Typdef.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Represents a rectangular area (X, Y, Width, Height).
Used replacement tokens by configure_file():