CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
PushButton Class Reference

Push button (a button that is pressed down) More...

#include <cc/PushButton>

Inheritance diagram for PushButton:

Public Types

using Style = PushButtonStyle
 Push button style.
 
- Public Types inherited from View
using Id = double
 View identifier
 

Public Member Functions

 PushButton ()
 Create a primordial button.
 
 PushButton (Style style, const String &text=String{}, const Picture &icon=Picture{})
 Create a new button.
 
 PushButton (Style style, const Picture &icon)
 Create a new button.
 
 PushButton (const String &text, const Picture &icon=Picture{})
 Create a new button.
 
 PushButton (const Picture &icon)
 Create a new button.
 
PushButtonassociate (Out< PushButton > self)
 Get a weak reference in self.
 
String text () const
 Get text.
 
PushButtontext (const String &newValue)
 Set text
 
PushButtontext (Definition< String > &&f)
 Define text
 
PushButtononTriggered (Function< void()> &&f)
 Setup callback to be called when the button is pressed
 
PushButtonoperator() (Function< void()> &&f)
 Setup callback to be called when the button is pressed
 
- Public Member Functions inherited from InputControl
 InputControl ()=default
 Create a null input control.
 
InputControlonAccepted (Function< void()> &&f)
 Input accepted
 
InputControlonRejected (Function< void()> &&f)
 Input rejected
 
- Public Member Functions inherited from Control
 Control ()
 Create a primordial control.
 
 Control (double width, double height)
 Create a new top-level control of size (width, height)
 
Controlassociate (Out< Control > self)
 Get a weak reference in self.
 
Control delegate () const
 Specific child control to cascade all input events to.
 
bool cascade () const
 Allow input events to cascade to any child control.
 
bool hover () const
 Pointer is currently hovering over this control
 
bool pressed () const
 Control is currently pressed by the user
 
bool focus () const
 Control has text input focus
 
Controlfocus (bool newValue)
 Grab or release input focus
 
Cursor cursor () const
 Get cursor.
 
Controlcursor (Cursor newValue)
 Set cursor
 
Controlcursor (Definition< Cursor > &&f)
 Define cursor
 
Point pointerPos () const
 Pointer position when hovered, pressed or clicked
 
ControlonClicked (Function< void()> &&f)
 Handle clicked event
 
ControlonPointerClicked (Filter< PointerEvent > &&f)
 Handle pointer clicked event
 
ControlonMouseClicked (Filter< MouseEvent > &&f)
 Handle mouse clicked event
 
ControlonFingerClicked (Filter< FingerEvent > &&f)
 Handle finger clicked event
 
bool operator== (const Control &other) const
 
- Public Member Functions inherited from View
 View ()=default
 Create a primordial view.
 
 View (double width, double height)
 Create a new view of initial size (width, height)
 
Viewassociate (Out< View > self)
 Get a weak reference in self.
 
Viewpopulate (const Function< void(View)> &&f)
 Invoke custom initialization function f.
 
void touch ()
 Materialize if this view is still primordial.
 
void show ()
 Convenience method to show this view.
 
int run ()
 Convenience method to show this view and run the application loop.
 
Viewpaint (Definition< void > &&f)
 Define foreground.
 
Color paper () const
 Get background color.
 
Viewpaper (Color newValue)
 Set background color
 
Viewpaper (Definition< Color > &&f)
 Define background color.
 
bool visible () const
 Get visible.
 
Viewvisible (bool newValue)
 Set visible
 
Viewvisible (Definition< bool > &&f)
 Define visible.
 
double opacity () const
 Get opacity.
 
Viewopacity (double newValue)
 Set opacity
 
Viewopacity (Definition< double > &&f)
 Define opacity.
 
ViewopacityEasing (const EasingCurve &easing, double duration)
 Set easing on opacity
 
bool clip () const
 Get clip.
 
Viewclip (bool newValue)
 Set clip
 
Viewclip (Definition< bool > &&f)
 Define clip.
 
bool moving () const
 Get moving.
 
Viewmoving (bool newValue)
 Set moving
 
Viewmoving (Definition< bool > &&f)
 Define moving.
 
Point pos () const
 Get position.
 
Viewpos (Point newValue)
 Set position
 
Viewpos (double x, double y)
 Set position
 
Viewpos (Definition< Point > &&f)
 Define position.
 
ViewposEasing (const EasingCurve &easing, double duration, Function< bool()> &&direct=nullptr)
 Set easing on position
 
Size size () const
 Get size.
 
double x () const
 Get pos()[0].
 
double y () const
 Get pos()[1].
 
double width () const
 Get size()[0].
 
double height () const
 Get size()[1].
 
double innerWidth () const
 Get inner width.
 
double innerHeight () const
 Get inner height.
 
Viewsize (Size newValue)
 Set size to newValue
 
Viewsize (double width, double height)
 Set size to Size{width, height}
 
Viewsize (Definition< Size > &&f)
 Define size.
 
ViewsizeEasing (const EasingCurve &easing, double duration)
 Set easing on size
 
Padding padding () const
 Padding to apply when adding this view to a layout
 
Viewpadding (const Padding &newValue)
 Set padding
 
Viewpadding (Definition< Padding > &&f)
 Define padding.
 
Point pivot () const
 Get rotation center.
 
Viewpivot (Point newValue)
 Set rotation center
 
Viewpivot (Definition< Point > &&f)
 Define rotation center.
 
ViewpivotEasing (const EasingCurve &easing, double duration)
 Set easing on rotation center
 
double angle () const
 Get rotation angle.
 
Viewangle (double newValue)
 Set rotation angle
 
Viewangle (Definition< double > &&f)
 Define rotation angle.
 
ViewangleEasing (const EasingCurve &easing, double duration)
 Set easing on rotation angle
 
double scale () const
 Get scale factor.
 
Viewscale (double newValue)
 Set scale factor
 
Viewscale (Definition< double > &&f)
 Define scale factor.
 
ViewscaleEasing (const EasingCurve &easing, double duration)
 Set easing on scale
 
View decoration () const
 Get decoration.
 
Viewdecoration (const View &newValue)
 Set decoration
 
Viewdecoration (Definition< View > &&f)
 Define decoration.
 
Size preferredSize () const
 Get preferred size.
 
Size minSize () const
 Get minimal size.
 
Size maxSize () const
 Get maximal size.
 
Color basePaper () const
 Get the background paper.
 
const char * objectName () const
 Get the object name (for debugging)
 
ViewobjectName (const char *name)
 Set the object name
 
bool hasWindow () const
 Check if this view is already shown in a window.
 
Window window () const
 Get the window this view is shown in.
 
bool isHandheld () const
 Get window().display().isHandheld()
 
Id id () const
 Get view identifier.
 
List< IdfullId () const
 Get view identifier heritage list.
 
bool operator== (const View &other) const
 Equality operator.
 
std::strong_ordering operator<=> (const View &other) const
 Ordering operator.
 
bool hasParent () const
 Check if this is a child view.
 
View parent () const
 Get parent view.
 
View root () const
 Get the root view of this window.
 
long childrenCount () const
 Number of children.
 
long count () const
 Number of children.
 
bool hasChildren () const
 Check if there are any children.
 
Viewadd (const View &child)
 Add new child placed visually above all existing children.
 
ViewaddAbove (const View &child)
 Add new child placed visually above all existing children.
 
ViewaddBelow (const View &child)
 Add child place visually below all existing children.
 
ViewinsertAt (Locator target, const View &child)
 Insert new child at target.
 
ViewinsertAt (long index, const View &child)
 Insert new child at index.
 
void remove (const View &child)
 Remove a child.
 
Viewpush (const View &child)
 Add new child placed visually above all existing children.
 
void pop ()
 Remove the top-most visible child.
 
void deplete ()
 Remove all children.
 
void moveToTop ()
 Make this view be visible above any other visible sibling.
 
void moveToBottom ()
 Make this view be visible beneath any other visible sibling.
 
const Set< View > & children () const
 Get all child views.
 
const Set< View > & visibleChildren () const
 Get visible child views.
 
Rect childrenRect () const
 Get bounding box containing all visible child views including their paddings.
 
Point mapToGlobal (Point l) const
 Map view coordinates l to window coordinates
 
Point mapToLocal (Point g) const
 Map window coordinates g to view coordinates
 
Point mapToChild (const View &child, Point l) const
 Map local coordinates l to child coordinates
 
Point mapToParent (const View &parent, Point l) const
 Map local coordinates l to parent coordinates
 
bool containsLocal (Point l) const
 Check if local point l lays inside this view.
 
bool containsGlobal (Point g) const
 Check if global point l lays inside this view.
 
View findChild (Point l) const
 Find the first child which contains local point l.
 
Control findControl (Point l) const
 Find the first control which contains local point l.
 
bool isParentOf (const View &other) const
 Check if this view is parent of other.
 
bool laysInsideOf (const View &other, double margin) const
 Check if this view is fully visible inside other with given surrounding margin.
 
void update ()
 Manually force repaint.
 
template<class T >
void collectVisible (InOut< List< T > > collection) const
 Get a list of all visible children in this view tree which are of type T.
 
Layout layout () const
 Get layout.
 
Viewlayout (const Layout &newValue)
 Set layout
 
void renderTo (Image &image) const
 Capture a rendered image of this view (including its children) as rendered on the screen.
 
double top () const
 Get y-coordinate of this view's top border.
 
double bottom () const
 Get y-coordinate of this view's bottom border.
 
double left () const
 Get x-coordinate of this view's left border.
 
double right () const
 Get x-coordinate of this view's right border.
 
Point topLeft () const
 Get this view's top-left corner.
 
Point topCenter () const
 Get this view's top-center point.
 
Point topRight () const
 Get this view's top-right corner.
 
Point bottomLeft () const
 Get this view's bottom-left corner.
 
Point bottomCenter () const
 Get this view's bottom-center point.
 
Point bottomRight () const
 Get this view's bottom-right corner.
 
Point centerLeft () const
 Get this view's center-left point.
 
Point centerRight () const
 Get this view's center-right point.
 
ViewtopLeft (Point newValue)
 Make this view's top-left match newValue.
 
ViewtopCenter (Point newValue)
 Make this view's top-center match newValue.
 
ViewtopRight (Point newValue)
 Make this view's top-right match newValue.
 
ViewbottomLeft (Point newValue)
 Make this view's bottom-left match newValue.
 
ViewbottomCenter (Point newValue)
 Make this view's bottom-center match newValue.
 
ViewbottomRight (Point newValue)
 Make this view's bottom-right match newValue.
 
ViewcenterLeft (Point newValue)
 Make this view's center-left match newValue.
 
ViewcenterRight (Point newValue)
 Make this view's center-right match newValue.
 
Viewcenter (Point newValue)
 Make this view's center match newValue.
 
ViewtopLeft (Definition< Point > &&a)
 Anchor the top-left corner to a
 
ViewtopCenter (Definition< Point > &&a)
 Anchor the top-center corner to a
 
ViewtopRight (Definition< Point > &&a)
 Anchor the top-right corner to a
 
ViewbottomLeft (Definition< Point > &&a)
 Anchor the bottom-left corner to a
 
ViewbottomCenter (Definition< Point > &&a)
 Anchor the bottom-center corner to a
 
ViewbottomRight (Definition< Point > &&a)
 Anchor the bottom-right corner to a
 
ViewcenterLeft (Definition< Point > &&a)
 Anchor the center-left to a
 
ViewcenterRight (Definition< Point > &&a)
 Anchor the center-right to a
 
Viewcenter (Definition< Point > &&a)
 Anchor the center to a
 
ViewcenterInParent ()
 Anchor this view's center to its parent's center.
 
ViewonWindowEntered (Function< void()> &&f)
 Handle window enter event
 
ViewonWindowLeft (Function< void()> &&f)
 Handle window leave event
 
ViewonPointerPressed (Filter< PointerEvent > &&f)
 Handle pointer pressed event
 
ViewonPointerReleased (Filter< PointerEvent > &&f)
 Handle pointer release event
 
ViewonPointerMoved (Filter< PointerEvent > &&f)
 Handle pointer moved event
 
ViewonMousePressed (Filter< MouseEvent > &&f)
 Handle move pressed event
 
ViewonMouseReleased (Filter< MouseEvent > &&f)
 Handle mouse release event
 
ViewonMouseMoved (Filter< MouseEvent > &&f)
 Handle move moved event
 
ViewonFingerPressed (Filter< FingerEvent > &&f)
 Handle finger pressed event
 
ViewonFingerReleased (Filter< FingerEvent > &&f)
 Handle finger released event
 
ViewonFingerMoved (Filter< FingerEvent > &&f)
 Handle finger moved event
 
ViewonWheelMoved (Filter< WheelEvent > &&f)
 Handle mouse wheel moved event
 
ViewonKeyPressed (Filter< KeyEvent > &&f)
 Handle key pressed event
 
ViewonKeyReleased (Filter< KeyEvent > &&f)
 Handle key released event
 
ViewonEndOfLife (Function< void()> &&f)
 Get notified when the View's lifetime ends.
 
Viewattach (const Object &other)
 Attach a non-visual object (e.g.
 
Viewattach (Function< void()> &&f)
 Convenience method for attaching a monitor.
 
- Public Member Functions inherited from Surface
 Surface ()=default
 Create a null surface.
 
void nextPage (bool clear=true)
 Open next page.
 
cairo_surface_t * cairoSurface ()
 Get a pointer to the underlying Cairo surface.
 
void polish ()
 Prepare surface before start painting.
 
- Public Member Functions inherited from Object
 Object ()=default
 Create a null object.
 
 operator bool () const
 Check if this is a non-null object.
 
bool isNull () const
 Check if this is a null object.
 
template<class T >
bool is () const
 Check if this object is of type T.
 
template<class T >
as () const
 Cast this object to type T.
 
bool isWeak () const
 Check if the underlying object reference is weak.
 
bool operator== (const Object &other) const
 Equality operator.
 
std::strong_ordering operator<=> (const Object &other) const
 Ordering operator.
 
long useCount () const
 Reference count.
 

Protected Member Functions

 PushButton (CreateState onDemand)
 
 PushButton (State *newState)
 
State & me ()
 
const State & me () const
 
- Protected Member Functions inherited from InputControl
 InputControl (State *state)
 
 InputControl (CreateState onDemand)
 
State & me ()
 
const State & me () const
 
- Protected Member Functions inherited from Control
 Control (State *newState)
 
 Control (CreateState onDemand)
 
bool operator== (State *other) const
 
Stateme ()
 
const Stateme () const
 
- Protected Member Functions inherited from View
 View (State *newState)
 Initialize view.
 
 View (CreateState onDemand)
 Initialize view.
 
template<class T >
grab ()
 Get a weak reference version of this object.
 
template<class T >
T & associate (Out< T > self)
 Convenience method to associate a weak reference to this objet.
 
template<class T >
T & get ()
 Get access to the object's state (create it if needed)
 
template<class T >
const T & get () const
 Get access to the object's state (create it if needed)
 
Stateme ()
 
const Stateme () const
 
bool operator== (const State *other) const
 
- Protected Member Functions inherited from Surface
 Surface (State *newState)
 
State & me ()
 
const State & me () const
 
- Protected Member Functions inherited from Object
template<class T >
weak () const
 
template<class T >
void initOnce ()
 Create the object state when called the first time.
 
template<class T >
void initOncePerThread ()
 Create a distinct object state for each thread when called the first time in that thread.
 
 Object (State *newState)
 Initialize object with newState.
 
 Object (State *state, Alias)
 
 Object (State *state, Weak)
 
Objectoperator= (std::nullptr_t)
 

Additional Inherited Members

- Protected Types inherited from View
using CreateState = State *()
 
- Static Protected Member Functions inherited from Control
static View::StatecreateState ()
 
- Static Protected Member Functions inherited from View
template<class T >
static View::StateonDemand ()
 
- Static Protected Member Functions inherited from Object
template<class T >
static T alias (const State *state)
 Create an alias object for the given state.
 
template<class T >
static T weak (const State *state)
 
- Protected Attributes inherited from Object
Handle< Stateme
 Internal object state
 

Detailed Description

Push button (a button that is pressed down)

Todo

field definition or negative touch margins ("activeMargin"?-)

Some onPressed() is needed to be triggered when the button is pressed by keyboard or mouse/pointer.

Member Typedef Documentation

◆ Style

Push button style.

Constructor & Destructor Documentation

◆ PushButton() [1/5]

Create a primordial button.

◆ PushButton() [2/5]

PushButton ( Style style,
const String & text = String{},
const Picture & icon = Picture{} )
explicit

Create a new button.

◆ PushButton() [3/5]

PushButton ( Style style,
const Picture & icon )

Create a new button.

◆ PushButton() [4/5]

PushButton ( const String & text,
const Picture & icon = Picture{} )
explicit

Create a new button.

◆ PushButton() [5/5]

PushButton ( const Picture & icon)
explicit

Create a new button.

Member Function Documentation

◆ associate()

PushButton & associate ( Out< PushButton > self)

Get a weak reference in self.

◆ text() [1/3]

String text ( ) const

Get text.

◆ text() [2/3]

PushButton & text ( const String & newValue)

Set text

◆ text() [3/3]

PushButton & text ( Definition< String > && f)

Define text

◆ onTriggered()

PushButton & onTriggered ( Function< void()> && f)

Setup callback to be called when the button is pressed

◆ operator()()

PushButton & operator() ( Function< void()> && f)

Setup callback to be called when the button is pressed