NOCL  v0.1.0-2524
Modern C++ Class Library for GUI Projects
nocl::Flexbox Class Reference

Flexbox layout engine. More...

#include <Flexbox.hpp>

Inheritance diagram for nocl::Flexbox:
Collaboration diagram for nocl::Flexbox:

Public Types

enum  EDirection {
  EDirection::kRow,
  EDirection::kRowReverse,
  EDirection::kColumn,
  EDirection::kColumnReverse
}
 From https://css-tricks.com/snippets/css/a-guide-to-flexbox/. More...
 
enum  EWrap {
  EWrap::kNoWrap,
  EWrap::kWrap,
  EWrap::kWrapReverse
}
 From https://css-tricks.com/snippets/css/a-guide-to-flexbox/. More...
 
enum  EJustifyContent {
  EJustifyContent::kStart,
  EJustifyContent::kEnd,
  EJustifyContent::kCenter,
  EJustifyContent::kSpaceBetween,
  EJustifyContent::kSpaceAround,
  EJustifyContent::kSpaceEvenly
}
 From https://css-tricks.com/snippets/css/a-guide-to-flexbox/. More...
 
enum  EAlignItems {
  EAlignItems::kStart,
  EAlignItems::kEnd,
  EAlignItems::kCenter,
  EAlignItems::kStretch,
  EAlignItems::kBaseline
}
 From https://css-tricks.com/snippets/css/a-guide-to-flexbox/. More...
 
enum  EAlignContent {
  EAlignContent::kStart,
  EAlignContent::kEnd,
  EAlignContent::kCenter,
  EAlignContent::kSpaceBetween,
  EAlignContent::kSpaceAround,
  EAlignContent::kStretch
}
 From https://css-tricks.com/snippets/css/a-guide-to-flexbox/. More...
 

Public Member Functions

virtual ~Flexbox (void)
 Destructor. More...
 
 Flexbox (void)
 Constructor. More...
 
virtual Flexboxset (const EDirection d)
 
virtual Flexboxset (const EWrap w)
 
virtual Flexboxset (const EJustifyContent j)
 
virtual Flexboxset (const EAlignItems a)
 
virtual Flexboxset (const EAlignContent a)
 
virtual Flexboxadd_child (const FlexItem &item)
 Make a copy of item and pushes it into the vector items. More...
 
virtual Flexboxperform_layout (const int width, const int height)
 
virtual operator GtkLayout * (void) const
 Convert an instance of nocl::Layout to GtkLayout*. More...
 
virtual Layoutadd_child (GUIComponent &child) override
 Inherited from Container. More...
 
virtual Layoutadd_child (GUIComponent &child, const int x, const int y)
 
virtual Layoutmove_child (GUIComponent &child, const int x, const int y)
 
virtual operator GtkContainer * (void) const
 Convert an instance of Container to GtkContainer*. More...
 
virtual Containerremove_child (GUIComponent &child)
 Remove a child component from this container. More...
 
virtual operator GtkWidget * (void) const
 Convert an instance of GUIComponent to GtkWidget*. More...
 
virtual GUIComponentmove_to (const Point &p)
 Move to the specified coordinates. More...
 
virtual Size natural_size (void)
 Get the natural size of a widget. More...
 
virtual Size minimum_size (void)
 Get the minimum size of a widget. More...
 
virtual GUIComponentminimum_size (const Size &s)
 Set the minimum size of a widget. More...
 
virtual GUIComponentminimum_size (const int width, const int height)
 Set the minimum size of a widget. More...
 
virtual GUIComponentshow (const bool toggle=true)
 Make the immediate component visible. More...
 
virtual GUIComponentshow_all (const bool toggle=true)
 Make the component and all child components visible. More...
 
virtual GUIComponenthide (void)
 Hide a single component. More...
 
virtual bool is_visible (void) const
 Determine if the widget is shown. More...
 

Static Public Member Functions

static WidgetToGUIComponentMapwidget_to_gui_component_map (void)
 There are times when we have a pointer to a Gtk+ widget, and we need to map it back to the corresponding NOCL GUI component. More...
 

Public Attributes

EDirection direction
 
EWrap wrap
 
EJustifyContent justify_content
 
EAlignItems align_items
 
EAlignContent align_content
 
MMFlexItems items
 
std::set< GUIComponent * > children
 Keep track of all children that have been added to this container. More...
 
Containerparent
 Pointer to the parent to which we've been added. Will be nullptr if this object hasn't been added to a parent container. More...
 
GtkWidget * gtk_widget
 Pointer to the underlying GTK framework. More...
 

Protected Member Functions

virtual Flexboxadd_children_to_parent (GUIComponent *child)
 

Detailed Description

Member Enumeration Documentation

◆ EDirection

From https://css-tricks.com/snippets/css/a-guide-to-flexbox/.

  • "This establishes the main-axis, thus defining the direction flex items are placed in the flex container. Flexbox is (aside from optional wrapping) a single-direction layout concept. Think of flex items as primarily laying out either in horizontal rows or vertical columns."
Enumerator
kRow 

Left to right (default value).

kRowReverse 

Right to left.

kColumn 

Top to bottom.

kColumnReverse 

Bottom to top.

◆ EWrap

enum nocl::Flexbox::EWrap
strong

From https://css-tricks.com/snippets/css/a-guide-to-flexbox/.

  • "By default, flex items will all try to fit onto one line. You can change that and allow the items to wrap as needed with this property."
Enumerator
kNoWrap 

All flex items will be on one line (default value).

kWrap 

Flex items will wrap onto multiple lines, from top to bottom.

kWrapReverse 

Flex items will wrap onto multiple lines, from bottom to top.

◆ EJustifyContent

From https://css-tricks.com/snippets/css/a-guide-to-flexbox/.

  • "This defines the alignment along the main axis. It helps distribute extra free space left over when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line."
Enumerator
kStart 

Items are packed toward the start line (default value).

kEnd 

Items are packed toward to end line.

kCenter 

Items are centered along the line.

kSpaceBetween 

Items are evenly distributed in the line; first item is on the start line, last item on the end line.

kSpaceAround 

Items are evenly distributed in the line with equal space around them. Note that visually the spaces aren't equal, since all the items have equal space on both sides. The first item will have one unit of space against the container edge, but two units of space between the next item because that next item has its own spacing that applies.

kSpaceEvenly 

Items are distributed so that the spacing between any two items (and the space to the edges) is equal.

◆ EAlignItems

From https://css-tricks.com/snippets/css/a-guide-to-flexbox/.

  • "This defines the default behaviour for how flex items are laid out along the cross axis on the current line. Think of it as the justify-content version for the cross-axis (perpendicular to the main-axis)."
Enumerator
kStart 

Cross-start margin edge of the items is placed on the cross-start line.

kEnd 

Cross-end margin edge of the items is placed on the cross-end line.

kCenter 

Items are centered in the cross-axis.

kStretch 

Items are aligned such as their baselines align.

kBaseline 

Stretch to fill the container (default value).

◆ EAlignContent

From https://css-tricks.com/snippets/css/a-guide-to-flexbox/.

  • "This aligns a flex container's lines within when there is extra space in the cross-axis, similar to how justify-content aligns individual items within the main-axis."
Enumerator
kStart 

Lines packed to the start of the container.

kEnd 

Lines packed to the end of the container.

kCenter 

Lines packed to the center of the container.

kSpaceBetween 

Lines evenly distributed; the first line is at the start of the container while the last one is at the end.

kSpaceAround 

Lines evenly distributed with equal space around each line.

kStretch 

Lines stretch to take up the remaining space (default value).

Constructor & Destructor Documentation

◆ ~Flexbox()

nocl::Flexbox::~Flexbox ( void  )
virtual

Destructor.

◆ Flexbox()

nocl::Flexbox::Flexbox ( void  )

Constructor.

Member Function Documentation

◆ set() [1/5]

nocl::Flexbox & nocl::Flexbox::set ( const EDirection  d)
virtual

References direction.

◆ set() [2/5]

nocl::Flexbox & nocl::Flexbox::set ( const EWrap  w)
virtual

References wrap.

◆ set() [3/5]

nocl::Flexbox & nocl::Flexbox::set ( const EJustifyContent  j)
virtual

References justify_content.

◆ set() [4/5]

nocl::Flexbox & nocl::Flexbox::set ( const EAlignItems  a)
virtual

References align_items.

◆ set() [5/5]

nocl::Flexbox & nocl::Flexbox::set ( const EAlignContent  a)
virtual

References align_content.

◆ add_child() [1/3]

nocl::Flexbox & nocl::Flexbox::add_child ( const FlexItem item)
virtual

Make a copy of item and pushes it into the vector items.

Note
Additional changes made to the item after this call will be ignored since Flexbox makes a copy and does not store a reference to the original object.

At the time the layout is performed, the items will be processed in the order described by FlexItem::order.

References add_children_to_parent(), nocl::FlexItem::child, items, and nocl::FlexItem::order.

Here is the call graph for this function:

◆ perform_layout()

nocl::Flexbox & nocl::Flexbox::perform_layout ( const int  width,
const int  height 
)
virtual

◆ add_children_to_parent()

nocl::Flexbox & nocl::Flexbox::add_children_to_parent ( GUIComponent child)
protectedvirtual

References nocl::Layout::add_child(), and items.

Referenced by add_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator GtkLayout *()

nocl::Layout::operator GtkLayout * ( void  ) const
virtualinherited

Convert an instance of nocl::Layout to GtkLayout*.

Exceptions
nocl::ExceptionObject was not created correctly and cannot be converted to GtkLayout*.

References nocl::GUIComponent::gtk_widget, and NOCL_WHERE.

◆ add_child() [2/3]

nocl::Layout & nocl::Layout::add_child ( GUIComponent child)
overridevirtualinherited

Inherited from Container.

Reimplemented from nocl::Container.

Referenced by add_children_to_parent().

Here is the caller graph for this function:

◆ add_child() [3/3]

nocl::Layout & nocl::Layout::add_child ( GUIComponent child,
const int  x,
const int  y 
)
virtualinherited

◆ move_child()

nocl::Layout & nocl::Layout::move_child ( GUIComponent child,
const int  x,
const int  y 
)
virtualinherited

◆ operator GtkContainer *()

nocl::Container::operator GtkContainer * ( void  ) const
virtualinherited

Convert an instance of Container to GtkContainer*.

Exceptions
nocl::ExceptionObject was not created correctly and cannot be converted to GtkContainer*.

References nocl::GUIComponent::gtk_widget, and NOCL_WHERE.

◆ remove_child()

nocl::Container & nocl::Container::remove_child ( GUIComponent child)
virtualinherited

Remove a child component from this container.

References nocl::Container::children, and nocl::GUIComponent::parent.

Referenced by nocl::Container::add_child(), nocl::Grid::add_child(), nocl::Container::~Container(), and nocl::GUIComponent::~GUIComponent().

Here is the caller graph for this function:

◆ operator GtkWidget *()

nocl::GUIComponent::operator GtkWidget * ( void  ) const
virtualinherited

Convert an instance of GUIComponent to GtkWidget*.

References nocl::GUIComponent::gtk_widget.

◆ move_to()

nocl::GUIComponent & nocl::GUIComponent::move_to ( const Point p)
virtualinherited

Move to the specified coordinates.

Todo:

◆ natural_size()

nocl::Size nocl::GUIComponent::natural_size ( void  )
virtualinherited

Get the natural size of a widget.

References nocl::GUIComponent::minimum_size().

Referenced by nocl::GUIComponent::minimum_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimum_size() [1/3]

nocl::Size nocl::GUIComponent::minimum_size ( void  )
virtualinherited

Get the minimum size of a widget.

References nocl::GUIComponent::natural_size().

Referenced by nocl::GUIComponent::minimum_size(), and nocl::GUIComponent::natural_size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minimum_size() [2/3]

nocl::GUIComponent & nocl::GUIComponent::minimum_size ( const Size s)
virtualinherited

Set the minimum size of a widget.

References nocl::Size::height, nocl::GUIComponent::minimum_size(), and nocl::Size::width.

Here is the call graph for this function:

◆ minimum_size() [3/3]

nocl::GUIComponent & nocl::GUIComponent::minimum_size ( const int  width,
const int  height 
)
virtualinherited

Set the minimum size of a widget.

◆ show()

nocl::GUIComponent & nocl::GUIComponent::show ( const bool  toggle = true)
virtualinherited

Make the immediate component visible.

Parameters
[in]toggleSet to true to show the widget, or to false to hide the widget.
See also
hide()
show_all()
is_visible()

References nocl::GUIComponent::gtk_widget, and nocl::GUIComponent::hide().

Here is the call graph for this function:

◆ show_all()

nocl::GUIComponent & nocl::GUIComponent::show_all ( const bool  toggle = true)
virtualinherited

Make the component and all child components visible.

Parameters
[in]toggleSet to true to show the widget and all children, or to false to hide the widget.
See also
show()
hide()
is_visible()

References nocl::GUIComponent::gtk_widget, and nocl::GUIComponent::hide().

Here is the call graph for this function:

◆ hide()

nocl::GUIComponent & nocl::GUIComponent::hide ( void  )
virtualinherited

Hide a single component.

See also
show()
show_all()
is_visible()

References nocl::GUIComponent::gtk_widget.

Referenced by nocl::GUIComponent::show(), and nocl::GUIComponent::show_all().

Here is the caller graph for this function:

◆ is_visible()

bool nocl::GUIComponent::is_visible ( void  ) const
virtualinherited

Determine if the widget is shown.

See also
show()
show_all()
hide()

References nocl::GUIComponent::gtk_widget.

◆ widget_to_gui_component_map()

nocl::WidgetToGUIComponentMap & nocl::GUIComponent::widget_to_gui_component_map ( void  )
staticinherited

There are times when we have a pointer to a Gtk+ widget, and we need to map it back to the corresponding NOCL GUI component.

For example, during event handling, Gtk+ tells us which Gtk+ widget generated the event, but we need the corresponding NOCL object so we can call the event handler with a reference to the correct object.

Note
This is not intended for end-users to access directly!

Referenced by nocl::ButtonHandler::handle_button_events_for(), and nocl::GUIComponent::~GUIComponent().

Here is the caller graph for this function:

Member Data Documentation

◆ direction

EDirection nocl::Flexbox::direction

Referenced by set().

◆ wrap

EWrap nocl::Flexbox::wrap

Referenced by set().

◆ justify_content

EJustifyContent nocl::Flexbox::justify_content

Referenced by set().

◆ align_items

EAlignItems nocl::Flexbox::align_items

Referenced by set().

◆ align_content

EAlignContent nocl::Flexbox::align_content

Referenced by set().

◆ items

MMFlexItems nocl::Flexbox::items

◆ children

std::set<GUIComponent*> nocl::Container::children
inherited

Keep track of all children that have been added to this container.

Referenced by nocl::Container::add_child(), nocl::Grid::add_child(), nocl::Container::remove_child(), and nocl::Container::~Container().

◆ parent

Container* nocl::GUIComponent::parent
inherited

Pointer to the parent to which we've been added. Will be nullptr if this object hasn't been added to a parent container.

Referenced by nocl::Container::add_child(), nocl::Grid::add_child(), nocl::Container::remove_child(), and nocl::GUIComponent::~GUIComponent().

◆ gtk_widget


The documentation for this class was generated from the following files: