libwtk-sdl2  0.0.1
Public Member Functions | Protected Attributes | List of all members
embedded_widget< BaseWidget > Struct Template Reference

#include <embedded_widget.hpp>

Inheritance diagram for embedded_widget< BaseWidget >:
Inheritance graph
[legend]
Collaboration diagram for embedded_widget< BaseWidget >:
Collaboration graph
[legend]

Public Member Functions

template<typename... Args>
 embedded_widget (Args &&... args)
 
void on_draw (draw_context &dc, selection_context const &sc) const override
 
void on_mouse_up_event (mouse_up_event const &e) override
 
void on_mouse_down_event (mouse_down_event const &e) override
 
void on_mouse_move_event (mouse_move_event const &e) override
 
void on_key_event (key_event const &e) override
 
void on_activate () override
 
std::vector< widget * > get_children () override
 
std::vector< widget const * > get_children () const override
 
void on_box_allocated () override
 
widgetfind_selectable (navigation_type nt, point center) override
 
widgetnavigate_selectable (navigation_type nt, point center) override
 
widgetnavigate_selectable_from_children (navigation_type nt, widget *w, point center) override
 
size_hint get_size_hint (int width, int height) const override
 
virtual bool can_use_intermediate_size () const
 
- Public Member Functions inherited from widget
 widget (widget const &)=delete
 
widgetoperator= (widget const &)=delete
 
SDL_Rect const & get_box () const
 
context_info const & get_context_info () const
 
void set_context_info (context_info const &ci)
 
void set_parent (widget *parent)
 
virtual void on_child_dirty (widget *child)
 
virtual std::vector< widget * > get_visible_children ()
 
virtual std::vector< widget const * > get_visible_children () const
 
void clear_dirty ()
 
void mark_dirty ()
 
void mark_child_dirty (widget *child)
 
void draw (draw_context &dc, selection_context const &sc) const
 
void draw_dirty (draw_context &dc, selection_context const &sc) const
 
void apply_layout (SDL_Rect box)
 
virtual void on_select ()
 
virtual void on_unselect ()
 

Protected Attributes

BaseWidget _embedded_widget
 
- Protected Attributes inherited from widget
widget_parent
 

Additional Inherited Members

- Protected Member Functions inherited from widget
std::optional< swipe_infoget_swipe_info_with_context_info (mouse_up_event const &e)
 
widgetnavigate_selectable_parent (navigation_type nt, point center)
 

Detailed Description

template<typename BaseWidget>
struct embedded_widget< BaseWidget >

Embeds a widget without sharing details of the concrete type to the outside while forwarding its widget interface.

Constructor & Destructor Documentation

◆ embedded_widget()

template<typename BaseWidget >
template<typename... Args>
embedded_widget< BaseWidget >::embedded_widget ( Args &&...  args)
inline

Construct the embedded widget by forwarding the given argument to it.

Member Function Documentation

◆ can_use_intermediate_size()

template<typename BaseWidget >
virtual bool embedded_widget< BaseWidget >::can_use_intermediate_size ( ) const
inlinevirtual

Whether a widget is able to use an intermediate value between minimal and natural size (e.g., assigning more width or height). This might change the aspect ratio of the widget.

Whenever a widget does not fit with natural but more than minimal, some widgets profit from using additional space. For example, an image in aspect ratio or a list view. A label in general can't profit from extra space and would only look awkward.

Reimplemented from widget.

◆ find_selectable()

template<typename BaseWidget >
widget* embedded_widget< BaseWidget >::find_selectable ( navigation_type  nt,
point  center 
)
inlineoverridevirtual

Should return the first selectable widget according to the navigation type. If a widget is selectable it should return itself. Containers should return the first selectable child widget. Otherwise nullptr is returned.

The point may serve as a hint to provide a more accurate selection.

Reimplemented from widget.

◆ get_children()

template<typename BaseWidget >
std::vector<widget *> embedded_widget< BaseWidget >::get_children ( )
inlineoverridevirtual

Return child widgets in Z-order. Should be implemented by containers.

Reimplemented from widget.

◆ get_size_hint()

template<typename BaseWidget >
size_hint embedded_widget< BaseWidget >::get_size_hint ( int  width,
int  height 
) const
inlineoverridevirtual

Computes the widgets preferred minimal and natural size. When given a specific width or height the widget might use that to give a more accurate size.

Implements widget.

◆ navigate_selectable()

template<typename BaseWidget >
widget* embedded_widget< BaseWidget >::navigate_selectable ( navigation_type  nt,
point  center 
)
inlineoverridevirtual

Perform a navigation request from this widget as source.

A widget that is not selectable doesn't have to implement this. Containers on the other hand should implement this to enable navigation of their children.

The point may serve as a hint to provide a more accurate selection.

Reimplemented from widget.

◆ navigate_selectable_from_children()

template<typename BaseWidget >
widget* embedded_widget< BaseWidget >::navigate_selectable_from_children ( navigation_type  nt,
widget w,
point  center 
)
inlineoverridevirtual

When a child widget has exhausted its selectable widgets it may ask its parent for the next widget according to the navigation. The coordinates of the widget are provided to get a more accurate result for some navigation types (i.e. 2-dimensional). The widget passed has to be the direct child, otherwise the parent is not able to find it.

Only containers should implement this.

Reimplemented from widget.

◆ on_activate()

template<typename BaseWidget >
void embedded_widget< BaseWidget >::on_activate ( )
inlineoverridevirtual

A widget may get activated by other means (e.g., infrared remote or return key).

Reimplemented from widget.

◆ on_box_allocated()

template<typename BaseWidget >
void embedded_widget< BaseWidget >::on_box_allocated ( )
inlineoverridevirtual

Refresh layout with existing box. This should not be called if the widget does not have a box already. Otherwise no space is allocated.

Reimplemented from widget.

◆ on_draw()

template<typename BaseWidget >
void embedded_widget< BaseWidget >::on_draw ( draw_context dc,
selection_context const &  sc 
) const
inlineoverridevirtual

Draw the widget. No children should be drawn here.

Implements widget.


The documentation for this struct was generated from the following file: