View for an area of the user interface. More...

#include <view.h>

+ Inheritance diagram for clan::View:

Public Member Functions

 View ()
 
virtual ~View ()
 
const std::vector< std::shared_ptr< ViewAction > > & actions () const
 List of all action recognizers.
 
void add_action (const std::shared_ptr< ViewAction > &action)
 Add an action recognizer.
 
template<typename T , typename... Types>
std::shared_ptr< T > add_action (Types &&... args)
 
std::shared_ptr< View > add_child ()
 
void add_child (const std::shared_ptr< View > &view)
 Add a child view.
 
template<typename T , typename... Types>
std::shared_ptr< T > add_child (Types &&... args)
 
void animate (float from, float to, const std::function< void(float)> &setter, int duration_ms=400, const std::function< float(float)> &easing=Easing::linear, std::function< void()> animation_end=std::function< void()>())
 Continously call an animation function for the specified duration.
 
Canvas canvas () const
 
const std::vector< std::shared_ptr< View > > & children () const
 List of all immediate child views.
 
void clear_exception_encountered ()
 
bool content_clipped () const
 Content clipping flag.
 
float definite_height ()
 The content height used for percentages or other definite calculations.
 
float definite_width ()
 The content width used for percentages or other definite calculations.
 
void draw_without_layout ()
 Render view and its children directly, without re-layout.
 
std::shared_ptr< View > find_view_at (const Pointf &pos) const
 Find descendant view at the specified content relative position.
 
float first_baseline_offset (Canvas &canvas, float width)
 Calculates the offset to the first baseline.
 
FocusPolicy focus_policy () const
 Focus policy active for this view.
 
View * focus_view () const
 The view receiving keyboard events or nullptr if no view has the focus.
 
Pointf from_root_pos (const Pointf &pos)
 Map from root content to local content coordinates.
 
Pointf from_screen_pos (const Pointf &pos)
 Map from screen to local content coordinates.
 
const ViewGeometry & geometry () const
 Actual view position and size after layout.
 
bool has_focus () const
 Test if this view is receiving keyboard input.
 
bool hidden () const
 Test if view is set to hidden.
 
bool is_height_definite ()
 Test if the view has a definite height.
 
bool is_static_position_and_visible () const
 Test if view should participate in static layout calculations (layout_children)
 
bool is_width_definite ()
 Test if the view has a definite width.
 
float last_baseline_offset (Canvas &canvas, float width)
 Calculates the offset to the last baseline.
 
virtual void layout_children (Canvas &canvas)
 Sets the view geometry for all children of this view.
 
bool needs_layout () const
 Test if view geometry needs to be recalculated.
 
void next_focus ()
 Give focus to the next view in the keyboard tab index order.
 
View * parent () const
 Parent view node or nullptr if the view is the current root node.
 
float preferred_height (Canvas &canvas, float width)
 Calculates the preferred height of this view.
 
float preferred_width (Canvas &canvas)
 Calculates the preferred width of this view.
 
void prev_focus ()
 Give focus to the previous view in the keyboard tab index order.
 
void remove_focus ()
 Remove focus from this view.
 
void remove_from_parent ()
 Remove view from parent.
 
bool render_exception_encountered () const
 Test if this view generated an exception during rendering.
 
void set_content_clipped (bool clipped)
 Specifies if content should be clipped during rendering.
 
void set_cursor (const CursorDescription &cursor)
 Set the cursor icon used when cursor is above this view.
 
void set_cursor (StandardCursor type)
 
void set_focus ()
 Set this view as the focused view.
 
void set_focus_policy (FocusPolicy policy)
 Set if this view automatically can gain focus.
 
void set_geometry (const ViewGeometry &geometry)
 
void set_hidden (bool value=true)
 Hides a view from layout and rendering.
 
void set_inherit_cursor ()
 Specify that the cursor icon is inherited from the parent view.
 
void set_needs_layout ()
 Forces recalculation of view geometry before next rendering.
 
void set_needs_render ()
 Signals this view needs to be rendered again.
 
void set_state (const std::string &name, bool value)
 Set or clear style state.
 
void set_state_cascade (const std::string &name, bool value)
 Sets the state for this view and all children recursively, until a manually set state of the same name is found.
 
void set_tab_index (unsigned int index)
 Sets the tab index used for keyboard focus changes.
 
void set_view_transform (const Mat4f &transform)
 Specifies the view transform to be applied before its contents and children are rendered.
 
bool state (const std::string &name) const
 Test if a style state is currently set.
 
void stop_animations ()
 Stop all activate animation functions.
 
const std::shared_ptr< Style > & style (const std::string &state=std::string()) const
 Style properties for the specified state.
 
const StyleCascade & style_cascade () const
 Style cascade currently active for this view.
 
unsigned int tab_index () const
 Tab index for keyboard focus changes.
 
Pointf to_root_pos (const Pointf &pos, bool relative_to_margin=false)
 Map from local content to root content or margin (plus content, padding, border and margin) coordinates.
 
Pointf to_screen_pos (const Pointf &pos)
 Map from local content to screen coordinates.
 
void update_cursor (DisplayWindow &window)
 Update window cursor to the cursor used by this view.
 
const Mat4f & view_transform () const
 Current view transform.
 
ViewTree * view_tree ()
 
const ViewTree * view_tree () const
 Tree in view hierachy.
 

Static Public Member Functions

static void dispatch_event (View *target, EventUI *e, bool no_propagation=false)
 Dispatch event to signals listening for events.
 

Public Attributes

Signal< void(ActivationChangeEvent &)> sig_activated )(bool use_capture=false)
 Window activated event.
 
Signal< void(CloseEvent &)> sig_close )(bool use_capture=false)
 Window close button clicked event.
 
Signal< void(ActivationChangeEvent &)> sig_deactivated )(bool use_capture=false)
 Window deactivated event.
 
Signal< void(FocusChangeEvent &)> sig_focus_gained )(bool use_capture=false)
 View gained focus event.
 
Signal< void(FocusChangeEvent &)> sig_focus_lost )(bool use_capture=false)
 View lost focus event.
 
Signal< void(KeyEvent &)> sig_key_press )(bool use_capture=false)
 Key pressed event.
 
Signal< void(KeyEvent &)> sig_key_release )(bool use_capture=false)
 Key released event.
 
Signal< void(PointerEvent &)> sig_pointer_double_click )(bool use_capture=false)
 Pointer button double clicked event.
 
Signal< void(PointerEvent &)> sig_pointer_enter )(bool use_capture=false)
 Pointer entering view geometry event.
 
Signal< void(PointerEvent &)> sig_pointer_leave )(bool use_capture=false)
 Pointer leaving view geometry event.
 
Signal< void(PointerEvent &)> sig_pointer_move )(bool use_capture=false)
 Pointer moved above view event.
 
Signal< void(PointerEvent &)> sig_pointer_press )(bool use_capture=false)
 Pointer button pressed event.
 
Signal< void(PointerEvent &)> sig_pointer_proximity_change )(bool use_capture=false)
 Pointer proximity change event.
 
Signal< void(PointerEvent &)> sig_pointer_release )(bool use_capture=false)
 Pointer button released event.
 
Signal< void(ResizeEvent &)> sig_resize )(bool use_capture=false)
 Window resize event.
 
SlotContainer slots
 Slot container helping with automatic disconnection of connected slots when the view is destroyed.
 

Protected Member Functions

virtual float calculate_definite_height (bool &out_is_definite)
 The content height used for percentages or other definite calculations.
 
virtual float calculate_definite_width (bool &out_is_definite)
 The content width used for percentages or other definite calculations.
 
virtual float calculate_first_baseline_offset (Canvas &canvas, float width)
 Calculates the offset to the first baseline.
 
virtual float calculate_last_baseline_offset (Canvas &canvas, float width)
 Calculates the offset to the last baseline.
 
virtual float calculate_preferred_height (Canvas &canvas, float width)
 Calculates the preferred height of this view.
 
virtual float calculate_preferred_width (Canvas &canvas)
 Calculates the preferred width of this view.
 
virtual void child_added (const std::shared_ptr< View > &view)
 Child view was added to this view.
 
virtual void child_removed (const std::shared_ptr< View > &view)
 Child view was removed from this view.
 
virtual void render_background (Canvas &canvas)
 Renders the background of a view.
 
virtual void render_border (Canvas &canvas)
 Renders the border of a view.
 
virtual void render_content (Canvas &canvas)
 Renders the content of a view.
 
virtual void updated_view_tree ()
 

Friends

class ViewAction
 
class ViewImpl
 
class ViewTree
 

Detailed Description

View for an area of the user interface.

Constructor & Destructor Documentation

◆ View()

clan::View::View ( )

◆ ~View()

virtual clan::View::~View ( )
virtual

Member Function Documentation

◆ actions()

const std::vector< std::shared_ptr< ViewAction > > & clan::View::actions ( ) const

List of all action recognizers.

◆ add_action() [1/2]

void clan::View::add_action ( const std::shared_ptr< ViewAction > & action)

Add an action recognizer.

Referenced by add_action().

◆ add_action() [2/2]

template<typename T , typename... Types>
std::shared_ptr< T > clan::View::add_action ( Types &&... args)
inline

References add_action().

◆ add_child() [1/3]

std::shared_ptr< View > clan::View::add_child ( )
inline

Referenced by add_child().

◆ add_child() [2/3]

void clan::View::add_child ( const std::shared_ptr< View > & view)

Add a child view.

◆ add_child() [3/3]

template<typename T , typename... Types>
std::shared_ptr< T > clan::View::add_child ( Types &&... args)
inline

References add_child().

◆ animate()

void clan::View::animate ( float from,
float to,
const std::function< void(float)> & setter,
int duration_ms = 400,
const std::function< float(float)> & easing = Easing::linear,
std::function< void()> animation_end = std::function< void()>() )

Continously call an animation function for the specified duration.

◆ calculate_definite_height()

virtual float clan::View::calculate_definite_height ( bool & out_is_definite)
protectedvirtual

The content height used for percentages or other definite calculations.

◆ calculate_definite_width()

virtual float clan::View::calculate_definite_width ( bool & out_is_definite)
protectedvirtual

The content width used for percentages or other definite calculations.

◆ calculate_first_baseline_offset()

virtual float clan::View::calculate_first_baseline_offset ( Canvas & canvas,
float width )
protectedvirtual

Calculates the offset to the first baseline.

Reimplemented in clan::LabelView, clan::ScrollView, clan::SpanLayoutView, clan::TextFieldView, and clan::TextView.

◆ calculate_last_baseline_offset()

virtual float clan::View::calculate_last_baseline_offset ( Canvas & canvas,
float width )
protectedvirtual

Calculates the offset to the last baseline.

Reimplemented in clan::LabelView, clan::ScrollView, clan::SpanLayoutView, clan::TextFieldView, and clan::TextView.

◆ calculate_preferred_height()

virtual float clan::View::calculate_preferred_height ( Canvas & canvas,
float width )
protectedvirtual

Calculates the preferred height of this view.

Reimplemented in clan::ImageView, clan::LabelView, clan::ScrollView, clan::SpanLayoutView, clan::TextFieldView, and clan::TextView.

◆ calculate_preferred_width()

virtual float clan::View::calculate_preferred_width ( Canvas & canvas)
protectedvirtual

Calculates the preferred width of this view.

Reimplemented in clan::ImageView, clan::LabelView, clan::ScrollView, clan::SpanLayoutView, clan::TextFieldView, and clan::TextView.

◆ canvas()

Canvas clan::View::canvas ( ) const

Gets the current canvas used to render this view

This function may return a null canvas if the view does not have a canvas attached to it yet.

◆ child_added()

virtual void clan::View::child_added ( const std::shared_ptr< View > & view)
inlineprotectedvirtual

Child view was added to this view.

Reimplemented in clan::SpanLayoutView.

◆ child_removed()

virtual void clan::View::child_removed ( const std::shared_ptr< View > & view)
inlineprotectedvirtual

Child view was removed from this view.

Reimplemented in clan::SpanLayoutView.

◆ children()

const std::vector< std::shared_ptr< View > > & clan::View::children ( ) const

List of all immediate child views.

◆ clear_exception_encountered()

void clan::View::clear_exception_encountered ( )

Clears exception encountered flag

If a view generates an exception during rendering the view's render_content function will not be called again until this function is called.

◆ content_clipped()

bool clan::View::content_clipped ( ) const

Content clipping flag.

◆ definite_height()

float clan::View::definite_height ( )

The content height used for percentages or other definite calculations.

◆ definite_width()

float clan::View::definite_width ( )

The content width used for percentages or other definite calculations.

◆ dispatch_event()

static void clan::View::dispatch_event ( View * target,
EventUI * e,
bool no_propagation = false )
static

Dispatch event to signals listening for events.

◆ draw_without_layout()

void clan::View::draw_without_layout ( )

Render view and its children directly, without re-layout.

◆ find_view_at()

std::shared_ptr< View > clan::View::find_view_at ( const Pointf & pos) const

Find descendant view at the specified content relative position.

◆ first_baseline_offset()

float clan::View::first_baseline_offset ( Canvas & canvas,
float width )

Calculates the offset to the first baseline.

◆ focus_policy()

FocusPolicy clan::View::focus_policy ( ) const

Focus policy active for this view.

◆ focus_view()

View * clan::View::focus_view ( ) const

The view receiving keyboard events or nullptr if no view has the focus.

Referenced by has_focus().

◆ from_root_pos()

Pointf clan::View::from_root_pos ( const Pointf & pos)

Map from root content to local content coordinates.

◆ from_screen_pos()

Pointf clan::View::from_screen_pos ( const Pointf & pos)

Map from screen to local content coordinates.

◆ geometry()

const ViewGeometry & clan::View::geometry ( ) const

Actual view position and size after layout.

◆ has_focus()

bool clan::View::has_focus ( ) const
inline

Test if this view is receiving keyboard input.

References focus_view().

◆ hidden()

bool clan::View::hidden ( ) const

Test if view is set to hidden.

◆ is_height_definite()

bool clan::View::is_height_definite ( )

Test if the view has a definite height.

◆ is_static_position_and_visible()

bool clan::View::is_static_position_and_visible ( ) const

Test if view should participate in static layout calculations (layout_children)

◆ is_width_definite()

bool clan::View::is_width_definite ( )

Test if the view has a definite width.

◆ last_baseline_offset()

float clan::View::last_baseline_offset ( Canvas & canvas,
float width )

Calculates the offset to the last baseline.

◆ layout_children()

virtual void clan::View::layout_children ( Canvas & canvas)
virtual

Sets the view geometry for all children of this view.

Reimplemented in clan::LabelView, clan::ListBoxView, clan::ScrollView, clan::ScrollBarView, clan::SliderView, and clan::SpanLayoutView.

◆ needs_layout()

bool clan::View::needs_layout ( ) const

Test if view geometry needs to be recalculated.

◆ next_focus()

void clan::View::next_focus ( )

Give focus to the next view in the keyboard tab index order.

◆ parent()

View * clan::View::parent ( ) const

Parent view node or nullptr if the view is the current root node.

◆ preferred_height()

float clan::View::preferred_height ( Canvas & canvas,
float width )

Calculates the preferred height of this view.

◆ preferred_width()

float clan::View::preferred_width ( Canvas & canvas)

Calculates the preferred width of this view.

◆ prev_focus()

void clan::View::prev_focus ( )

Give focus to the previous view in the keyboard tab index order.

◆ remove_focus()

void clan::View::remove_focus ( )

Remove focus from this view.

◆ remove_from_parent()

void clan::View::remove_from_parent ( )

Remove view from parent.

◆ render_background()

virtual void clan::View::render_background ( Canvas & canvas)
protectedvirtual

Renders the background of a view.

Reimplemented in clan::CheckBoxView.

◆ render_border()

virtual void clan::View::render_border ( Canvas & canvas)
protectedvirtual

Renders the border of a view.

◆ render_content()

virtual void clan::View::render_content ( Canvas & canvas)
inlineprotectedvirtual

Renders the content of a view.

Reimplemented in clan::ImageView, clan::LabelView, clan::SpanLayoutView, clan::TextFieldView, and clan::TextView.

◆ render_exception_encountered()

bool clan::View::render_exception_encountered ( ) const

Test if this view generated an exception during rendering.

◆ set_content_clipped()

void clan::View::set_content_clipped ( bool clipped)

Specifies if content should be clipped during rendering.

◆ set_cursor() [1/2]

void clan::View::set_cursor ( const CursorDescription & cursor)

Set the cursor icon used when cursor is above this view.

◆ set_cursor() [2/2]

void clan::View::set_cursor ( StandardCursor type)

◆ set_focus()

void clan::View::set_focus ( )

Set this view as the focused view.

◆ set_focus_policy()

void clan::View::set_focus_policy ( FocusPolicy policy)

Set if this view automatically can gain focus.

◆ set_geometry()

void clan::View::set_geometry ( const ViewGeometry & geometry)

Sets the view position and size

This function should only be called by layout_children.

◆ set_hidden()

void clan::View::set_hidden ( bool value = true)

Hides a view from layout and rendering.

◆ set_inherit_cursor()

void clan::View::set_inherit_cursor ( )

Specify that the cursor icon is inherited from the parent view.

◆ set_needs_layout()

void clan::View::set_needs_layout ( )

Forces recalculation of view geometry before next rendering.

◆ set_needs_render()

void clan::View::set_needs_render ( )

Signals this view needs to be rendered again.

◆ set_state()

void clan::View::set_state ( const std::string & name,
bool value )

Set or clear style state.

◆ set_state_cascade()

void clan::View::set_state_cascade ( const std::string & name,
bool value )

Sets the state for this view and all children recursively, until a manually set state of the same name is found.

◆ set_tab_index()

void clan::View::set_tab_index ( unsigned int index)

Sets the tab index used for keyboard focus changes.

◆ set_view_transform()

void clan::View::set_view_transform ( const Mat4f & transform)

Specifies the view transform to be applied before its contents and children are rendered.

◆ state()

bool clan::View::state ( const std::string & name) const

Test if a style state is currently set.

◆ stop_animations()

void clan::View::stop_animations ( )

Stop all activate animation functions.

◆ style()

const std::shared_ptr< Style > & clan::View::style ( const std::string & state = std::string()) const

Style properties for the specified state.

Referenced by clan::ColumnView::ColumnView(), clan::RowView::RowView(), and clan::SpacerView::SpacerView().

◆ style_cascade()

const StyleCascade & clan::View::style_cascade ( ) const

Style cascade currently active for this view.

◆ tab_index()

unsigned int clan::View::tab_index ( ) const

Tab index for keyboard focus changes.

◆ to_root_pos()

Pointf clan::View::to_root_pos ( const Pointf & pos,
bool relative_to_margin = false )

Map from local content to root content or margin (plus content, padding, border and margin) coordinates.

◆ to_screen_pos()

Pointf clan::View::to_screen_pos ( const Pointf & pos)

Map from local content to screen coordinates.

◆ update_cursor()

void clan::View::update_cursor ( DisplayWindow & window)

Update window cursor to the cursor used by this view.

◆ updated_view_tree()

virtual void clan::View::updated_view_tree ( )
inlineprotectedvirtual

◆ view_transform()

const Mat4f & clan::View::view_transform ( ) const

Current view transform.

◆ view_tree() [1/2]

ViewTree * clan::View::view_tree ( )

◆ view_tree() [2/2]

const ViewTree * clan::View::view_tree ( ) const

Tree in view hierachy.

Friends And Related Symbol Documentation

◆ ViewAction

friend class ViewAction
friend

◆ ViewImpl

friend class ViewImpl
friend

◆ ViewTree

friend class ViewTree
friend

Member Data Documentation

◆ sig_activated

Signal< void(ActivationChangeEvent &)> clan::View::sig_activated) (bool use_capture=false)

Window activated event.

◆ sig_close

Signal< void(CloseEvent &)> clan::View::sig_close) (bool use_capture=false)

Window close button clicked event.

◆ sig_deactivated

Signal< void(ActivationChangeEvent &)> clan::View::sig_deactivated) (bool use_capture=false)

Window deactivated event.

◆ sig_focus_gained

Signal< void(FocusChangeEvent &)> clan::View::sig_focus_gained) (bool use_capture=false)

View gained focus event.

◆ sig_focus_lost

Signal< void(FocusChangeEvent &)> clan::View::sig_focus_lost) (bool use_capture=false)

View lost focus event.

◆ sig_key_press

Signal< void(KeyEvent &)> clan::View::sig_key_press) (bool use_capture=false)

Key pressed event.

◆ sig_key_release

Signal< void(KeyEvent &)> clan::View::sig_key_release) (bool use_capture=false)

Key released event.

◆ sig_pointer_double_click

Signal< void(PointerEvent &)> clan::View::sig_pointer_double_click) (bool use_capture=false)

Pointer button double clicked event.

◆ sig_pointer_enter

Signal< void(PointerEvent &)> clan::View::sig_pointer_enter) (bool use_capture=false)

Pointer entering view geometry event.

◆ sig_pointer_leave

Signal< void(PointerEvent &)> clan::View::sig_pointer_leave) (bool use_capture=false)

Pointer leaving view geometry event.

◆ sig_pointer_move

Signal< void(PointerEvent &)> clan::View::sig_pointer_move) (bool use_capture=false)

Pointer moved above view event.

◆ sig_pointer_press

Signal< void(PointerEvent &)> clan::View::sig_pointer_press) (bool use_capture=false)

Pointer button pressed event.

◆ sig_pointer_proximity_change

Signal< void(PointerEvent &)> clan::View::sig_pointer_proximity_change) (bool use_capture=false)

Pointer proximity change event.

◆ sig_pointer_release

Signal< void(PointerEvent &)> clan::View::sig_pointer_release) (bool use_capture=false)

Pointer button released event.

◆ sig_resize

Signal< void(ResizeEvent &)> clan::View::sig_resize) (bool use_capture=false)

Window resize event.

◆ slots

SlotContainer clan::View::slots

Slot container helping with automatic disconnection of connected slots when the view is destroyed.


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