CoreComponents 3.0.0
A Modern C++ Toolkit
|
User interface building block More...
#include <cc/View>
Classes | |
class | Layout |
Automatic geometry for children views More... | |
struct | State |
Internal state. More... | |
Public Types | |
using | Id = double |
View identifier | |
Protected Types | |
using | CreateState = State *() |
Protected Member Functions | |
View (State *newState) | |
Initialize view. | |
View (CreateState onDemand) | |
Initialize view. | |
template<class T > | |
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) | |
State & | me () |
const State & | me () 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 > | |
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) | |
Object & | operator= (std::nullptr_t) |
Static Protected Member Functions | |
template<class T > | |
static View::State * | onDemand () |
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) |
Construction | |
View ()=default | |
Create a primordial view. | |
View (double width, double height) | |
Create a new view of initial size (width, height) | |
View & | associate (Out< View > self) |
Get a weak reference in self. | |
View & | populate (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. | |
View Properties | |
View & | paint (Definition< void > &&f) |
Define foreground. | |
Color | paper () const |
Get background color. | |
View & | paper (Color newValue) |
Set background color | |
View & | paper (Definition< Color > &&f) |
Define background color. | |
bool | visible () const |
Get visible. | |
View & | visible (bool newValue) |
Set visible | |
View & | visible (Definition< bool > &&f) |
Define visible. | |
double | opacity () const |
Get opacity. | |
View & | opacity (double newValue) |
Set opacity | |
View & | opacity (Definition< double > &&f) |
Define opacity. | |
View & | opacityEasing (const EasingCurve &easing, double duration) |
Set easing on opacity | |
bool | clip () const |
Get clip. | |
View & | clip (bool newValue) |
Set clip | |
View & | clip (Definition< bool > &&f) |
Define clip. | |
bool | moving () const |
Get moving. | |
View & | moving (bool newValue) |
Set moving | |
View & | moving (Definition< bool > &&f) |
Define moving. | |
Point | pos () const |
Get position. | |
View & | pos (Point newValue) |
Set position | |
View & | pos (double x, double y) |
Set position | |
View & | pos (Definition< Point > &&f) |
Define position. | |
View & | posEasing (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. | |
View & | size (Size newValue) |
Set size to newValue | |
View & | size (double width, double height) |
Set size to Size{width, height} | |
View & | size (Definition< Size > &&f) |
Define size. | |
View & | sizeEasing (const EasingCurve &easing, double duration) |
Set easing on size | |
Padding | padding () const |
Padding to apply when adding this view to a layout | |
View & | padding (const Padding &newValue) |
Set padding | |
View & | padding (Definition< Padding > &&f) |
Define padding. | |
Point | pivot () const |
Get rotation center. | |
View & | pivot (Point newValue) |
Set rotation center | |
View & | pivot (Definition< Point > &&f) |
Define rotation center. | |
View & | pivotEasing (const EasingCurve &easing, double duration) |
Set easing on rotation center | |
double | angle () const |
Get rotation angle. | |
View & | angle (double newValue) |
Set rotation angle | |
View & | angle (Definition< double > &&f) |
Define rotation angle. | |
View & | angleEasing (const EasingCurve &easing, double duration) |
Set easing on rotation angle | |
double | scale () const |
Get scale factor. | |
View & | scale (double newValue) |
Set scale factor | |
View & | scale (Definition< double > &&f) |
Define scale factor. | |
View & | scaleEasing (const EasingCurve &easing, double duration) |
Set easing on scale | |
View | decoration () const |
Get decoration. | |
View & | decoration (const View &newValue) |
Set decoration | |
View & | decoration (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) | |
View & | objectName (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() | |
View Hierarchy | |
Id | id () const |
Get view identifier. | |
List< Id > | fullId () 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. | |
View & | add (const View &child) |
Add new child placed visually above all existing children. | |
View & | addAbove (const View &child) |
Add new child placed visually above all existing children. | |
View & | addBelow (const View &child) |
Add child place visually below all existing children. | |
View & | insertAt (Locator target, const View &child) |
Insert new child at target. | |
View & | insertAt (long index, const View &child) |
Insert new child at index. | |
void | remove (const View &child) |
Remove a child. | |
View & | push (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. | |
View & | layout (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. | |
Positional Anchors | |
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. | |
View & | topLeft (Point newValue) |
Make this view's top-left match newValue. | |
View & | topCenter (Point newValue) |
Make this view's top-center match newValue. | |
View & | topRight (Point newValue) |
Make this view's top-right match newValue. | |
View & | bottomLeft (Point newValue) |
Make this view's bottom-left match newValue. | |
View & | bottomCenter (Point newValue) |
Make this view's bottom-center match newValue. | |
View & | bottomRight (Point newValue) |
Make this view's bottom-right match newValue. | |
View & | centerLeft (Point newValue) |
Make this view's center-left match newValue. | |
View & | centerRight (Point newValue) |
Make this view's center-right match newValue. | |
View & | center (Point newValue) |
Make this view's center match newValue. | |
View & | topLeft (Definition< Point > &&a) |
Anchor the top-left corner to a | |
View & | topCenter (Definition< Point > &&a) |
Anchor the top-center corner to a | |
View & | topRight (Definition< Point > &&a) |
Anchor the top-right corner to a | |
View & | bottomLeft (Definition< Point > &&a) |
Anchor the bottom-left corner to a | |
View & | bottomCenter (Definition< Point > &&a) |
Anchor the bottom-center corner to a | |
View & | bottomRight (Definition< Point > &&a) |
Anchor the bottom-right corner to a | |
View & | centerLeft (Definition< Point > &&a) |
Anchor the center-left to a | |
View & | centerRight (Definition< Point > &&a) |
Anchor the center-right to a | |
View & | center (Definition< Point > &&a) |
Anchor the center to a | |
View & | centerInParent () |
Anchor this view's center to its parent's center. | |
Triggers and Events | |
View & | onWindowEntered (Function< void()> &&f) |
Handle window enter event | |
View & | onWindowLeft (Function< void()> &&f) |
Handle window leave event | |
View & | onPointerPressed (Filter< PointerEvent > &&f) |
Handle pointer pressed event | |
View & | onPointerReleased (Filter< PointerEvent > &&f) |
Handle pointer release event | |
View & | onPointerMoved (Filter< PointerEvent > &&f) |
Handle pointer moved event | |
View & | onMousePressed (Filter< MouseEvent > &&f) |
Handle move pressed event | |
View & | onMouseReleased (Filter< MouseEvent > &&f) |
Handle mouse release event | |
View & | onMouseMoved (Filter< MouseEvent > &&f) |
Handle move moved event | |
View & | onFingerPressed (Filter< FingerEvent > &&f) |
Handle finger pressed event | |
View & | onFingerReleased (Filter< FingerEvent > &&f) |
Handle finger released event | |
View & | onFingerMoved (Filter< FingerEvent > &&f) |
Handle finger moved event | |
View & | onWheelMoved (Filter< WheelEvent > &&f) |
Handle mouse wheel moved event | |
View & | onKeyPressed (Filter< KeyEvent > &&f) |
Handle key pressed event | |
View & | onKeyReleased (Filter< KeyEvent > &&f) |
Handle key released event | |
View & | onEndOfLife (Function< void()> &&f) |
Get notified when the View's lifetime ends. | |
View & | attach (const Object &other) |
Attach a non-visual object (e.g. | |
View & | attach (Function< void()> &&f) |
Convenience method for attaching a monitor. | |
Additional Inherited Members | |
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 > | |
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 Attributes inherited from Object | |
Handle< State > | me |
Internal object state | |
User interface building block
using Id = double |
View identifier
|
default |
Create a primordial view.
View | ( | double | width, |
double | height ) |
Create a new view of initial size (width, height)
|
explicitprotected |
Initialize view.
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.
View & paint | ( | Definition< void > && | f | ) |
Define foreground.
Color paper | ( | ) | const |
Get background color.
View & paper | ( | Definition< Color > && | f | ) |
Define background color.
bool visible | ( | ) | const |
Get visible.
View & visible | ( | bool | newValue | ) |
Set visible
View & visible | ( | Definition< bool > && | f | ) |
Define visible.
double opacity | ( | ) | const |
Get opacity.
View & opacity | ( | double | newValue | ) |
Set opacity
View & opacity | ( | Definition< double > && | f | ) |
Define opacity.
View & opacityEasing | ( | const EasingCurve & | easing, |
double | duration ) |
Set easing on opacity
bool clip | ( | ) | const |
Get clip.
View & clip | ( | bool | newValue | ) |
Set clip
View & clip | ( | Definition< bool > && | f | ) |
Define clip.
bool moving | ( | ) | const |
Get moving.
View & moving | ( | bool | newValue | ) |
Set moving
View & moving | ( | Definition< bool > && | f | ) |
Define moving.
Point pos | ( | ) | const |
Get position.
View & pos | ( | double | x, |
double | y ) |
Set position
View & pos | ( | Definition< Point > && | f | ) |
Define position.
View & posEasing | ( | 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.
View & size | ( | double | width, |
double | height ) |
Set size to Size{width, height}
View & size | ( | Definition< Size > && | f | ) |
Define size.
View & sizeEasing | ( | const EasingCurve & | easing, |
double | duration ) |
Set easing on size
Padding padding | ( | ) | const |
Padding to apply when adding this view to a layout
The padding also extends the views bounds in terms of event propagation.
View & padding | ( | Definition< Padding > && | f | ) |
Define padding.
Point pivot | ( | ) | const |
Get rotation center.
View & pivot | ( | Definition< Point > && | f | ) |
Define rotation center.
View & pivotEasing | ( | const EasingCurve & | easing, |
double | duration ) |
Set easing on rotation center
double angle | ( | ) | const |
Get rotation angle.
View & angle | ( | double | newValue | ) |
Set rotation angle
View & angle | ( | Definition< double > && | f | ) |
Define rotation angle.
View & angleEasing | ( | const EasingCurve & | easing, |
double | duration ) |
Set easing on rotation angle
double scale | ( | ) | const |
Get scale factor.
View & scale | ( | double | newValue | ) |
Set scale factor
View & scale | ( | Definition< double > && | f | ) |
Define scale factor.
View & scaleEasing | ( | const EasingCurve & | easing, |
double | duration ) |
Set easing on scale
View decoration | ( | ) | const |
Get decoration.
View & decoration | ( | 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)
View & objectName | ( | 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.
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.
void remove | ( | const View & | child | ) |
Remove a child.
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.
Rect childrenRect | ( | ) | const |
Get bounding box containing all visible child views including their paddings.
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.
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.
Get a list of all visible children in this view tree which are of type T.
Layout layout | ( | ) | const |
Get layout.
void renderTo | ( | Image & | image | ) | const |
Capture a rendered image of this view (including its children) as rendered on the screen.
image | Output image (needs to be allocated by the caller) |
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.
View & topLeft | ( | Definition< Point > && | a | ) |
Anchor the top-left corner to a
View & topCenter | ( | Definition< Point > && | a | ) |
Anchor the top-center corner to a
View & topRight | ( | Definition< Point > && | a | ) |
Anchor the top-right corner to a
View & bottomLeft | ( | Definition< Point > && | a | ) |
Anchor the bottom-left corner to a
View & bottomCenter | ( | Definition< Point > && | a | ) |
Anchor the bottom-center corner to a
View & bottomRight | ( | Definition< Point > && | a | ) |
Anchor the bottom-right corner to a
View & centerLeft | ( | Definition< Point > && | a | ) |
Anchor the center-left to a
View & centerRight | ( | Definition< Point > && | a | ) |
Anchor the center-right to a
View & center | ( | Definition< Point > && | a | ) |
Anchor the center to a
View & centerInParent | ( | ) |
Anchor this view's center to its parent's center.
View & onPointerPressed | ( | Filter< PointerEvent > && | f | ) |
Handle pointer pressed event
View & onPointerReleased | ( | Filter< PointerEvent > && | f | ) |
Handle pointer release event
View & onPointerMoved | ( | Filter< PointerEvent > && | f | ) |
Handle pointer moved event
View & onMousePressed | ( | Filter< MouseEvent > && | f | ) |
Handle move pressed event
View & onMouseReleased | ( | Filter< MouseEvent > && | f | ) |
Handle mouse release event
View & onMouseMoved | ( | Filter< MouseEvent > && | f | ) |
Handle move moved event
View & onFingerPressed | ( | Filter< FingerEvent > && | f | ) |
Handle finger pressed event
View & onFingerReleased | ( | Filter< FingerEvent > && | f | ) |
Handle finger released event
View & onFingerMoved | ( | Filter< FingerEvent > && | f | ) |
Handle finger moved event
View & onWheelMoved | ( | Filter< WheelEvent > && | f | ) |
Handle mouse wheel moved event
|
protected |
Get a weak reference version of this object.
|
protected |
Convenience method to associate a weak reference to this objet.
|
protected |
Get access to the object's state (create it if needed)
T | Type of internal state |
|
protected |
Get access to the object's state (create it if needed)
T | Type of internal state |