![]() |
Iridescence 1.00
Embedded Graphic Framework
|
DsView is a base class that represents any view on the screen. More...
#include <ds_view.h>
Classes | |
class | StateObserver |
StateObserver is a pure virtual class implementing the interface for notifying state observers of changes in the visibility of a DsView object. More... | |
Public Member Functions | |
DsView (DsView *parent, const DsPoint &pos=DsPoint(), const DsSize &size=DsSize()) | |
Creates a DsView with an optional position and size. | |
DsView (DsView *parent, DsOrientation layout_orientation) | |
Creates a DsView with the auto-layout mode active. This view can align it's children automatically. | |
void | addChild (DsView *view) |
Adds a child to the current DsView. | |
void | removeChild (DsView *view) |
Removes a child to the current DsView. | |
void | removeAllChildren (void) |
Removes all children of the current DsView. | |
void | bringFront (void) |
Brings the current view to the top of the drawing order. | |
void | sendBack (void) |
Sends the current view to the bottom of the drawing order. | |
DsView * | getParent (void) const |
Returns the parent of the current view. | |
void | setParent (DsView *parent) |
Sets a new parent to the view. | |
const DsPoint & | getPosition (void) const |
Returns the position of the view in parent coordinates. | |
DsFPoint | getCenterPoint (void) const |
Returns the center point of the view in current coordinates. | |
DsPoint | translatePositionInParentCoordinates (const DsView *parent, DsPoint pos) const |
Translates position (x, y) in parent coordinate system. | |
DsPoint | translatePositionInParentCoordinates (uint32_t parent_level, DsPoint pos) const |
Translates position (x, y) in parent coordinate system. | |
DsPoint | getPositionInParentCoordinates (const DsView *parent) const |
Returns the position in the parent's coordinate system. | |
void | setPosition (const DsPoint &pos) |
Sets the position of the view in parent coordinates. | |
void | setCenterPosition (const DsPoint &pos) |
Sets the position of the center of the view in parent coordinates. | |
void | centerVertically (DsView *view) |
Aligns vertically the center of the current view with the center of another view. | |
void | centerHorizontally (DsView *view) |
Aligns horizontally the center of the current view with the center of another view. | |
const DsSize & | getParentSize (void) const |
Returns the size of the parent view. | |
const DsSize & | getSize (void) const |
Returns the size of the view. | |
void | setMinimumSize (const DsSize &size) |
Returns the minimum size of the view. | |
void | setSize (const DsSize &size) |
Sets the size of the view. | |
void | setWidth (int32_t width) |
Sets the width of the view. | |
void | setHeight (int32_t height) |
Sets the height of the view. | |
DsRect | getRegion (void) const |
Returns a rectangle describing the space occupied by the current view in it's own coordinate system (X and Y coordinates are 0). | |
DsRect | getRegionInParentCoordinates (const DsView *parent) const |
Returns a rectangle describing the space occupied by the current view in the parent's coordinate system. | |
void | alignInParent (void) |
Aligns the view relative to it's parent. | |
void | alignInParent (const DsAlignment &alignment, int32_t padding_top, int32_t padding_left, int32_t padding_bottom, int32_t padding_right) |
Aligns the view relative to it's parent. | |
DsView * | setPaddingTop (int16_t padding, uint16_t proportion=0) |
Sets the top padding used by the auto-layout. | |
DsView * | setPaddingBottom (int16_t padding, uint16_t proportion=0) |
Sets the bottom padding used by the auto-layout. | |
DsView * | setPaddingLeft (int32_t padding, uint16_t proportion=0) |
Sets the left padding used by the auto-layout. | |
DsView * | setPaddingRight (int16_t padding, uint16_t proportion=0) |
Sets the right padding used by the auto-layout. | |
DsView * | setPadding (int16_t padding, uint16_t proportion=0) |
Sets the padding used by the auto-layout. | |
DsView * | setPaddingHorizontal (int16_t padding, uint16_t proportion=0) |
Sets the horizontal padding used by the auto-layout. | |
DsView * | setPaddingVertical (int16_t padding, uint16_t proportion=0) |
Sets the vertical padding used by the auto-layout. | |
DsView * | setProportion (uint32_t proportion) |
Sets the view proportion used by the auto-layout. | |
DsAlignment | getParentAlignment (void) const |
Returns parent alignment mode of the view. | |
DsView * | setParentAlignment (const DsAlignment &alignment) |
Sets parent alignment mode of the view. | |
void | reserveSpace (bool state) |
Configures if during auto-layout the view will reserve space even if it's hidden. | |
void | setAutoLayout (DsOrientation orientation, bool enable) |
Enables or disables the auto-layout mode and sets the primary orientation. | |
virtual DsSize | fitContent (void) |
Calculates the minimum size required by the view. | |
void | doLayout (void) |
Runs the auto-layout algorithm. | |
void | setBackgroundColor (DsColor color) |
Sets the background color of the view. | |
void | setBackgroundImage (const DsSurface *surface) |
Sets the background image. | |
void | setPanelColor (DsColor color) |
Sets the color of the panel. | |
void | setPanelBorderColor (DsColor color) |
Sets the color of the panel border. | |
void | setPanelCornerRadius (uint16_t radius) |
Sets the radius of the panel corners. | |
void | setPanelBorderThickness (uint8_t thickness) |
Sets the thickness of the panel border. | |
DsScreen & | getScreen (void) |
Returns a reference to the screen to which this view belongs. | |
bool | isFocused (void) |
Is the view focused? | |
bool | getIsVisible (void) const |
Is the view visibility enabled? | |
bool | isVisible (void) const |
Is the view actually visible on the screen? | |
bool | isParentVisible (void) const |
Is the parent view actually visible on the screen? | |
bool | show (void) |
Shortcut to setVisible(true). | |
bool | hide (void) |
Shortcut to setVisible(false). | |
bool | setVisible (bool is_visible) |
Changes the visibility of the view. | |
virtual void | onShow (void) |
This virtual method is called when the view becomes visible on the screen. | |
virtual void | onHide (void) |
This virtual method is called when the view becomes invisible (hidden) on the screen. | |
void | enable (bool state) |
Enables or disables the view. | |
bool | isEnabled (void) const |
Is the view enabled? | |
void | enableTouch (bool state) |
Enables or disables processing of touch events. | |
bool | isTouchEnabled (void) const |
Is the view enabled to process touch events? | |
void | sendTap (DsPoint pos) |
Sends a tap event to the view. | |
void | setOnTapCallback (const lambda< void(const DsPoint &p)> &cb) |
Sets the lambda to be executed when the user taps on the view. | |
void | setOnLongTapCallback (const lambda< void(const DsPoint &p)> &cb) |
Sets the lambda to be executed when the user taps the view and holds for a specific time (set with setLongTapDetection()). | |
void | setOnTouchActiveCallback (const lambda< void(const DsPoint &p)> &cb) |
Sets the lambda to be executed when the user touches the view. | |
void | setOnTouchReleaseCallback (const lambda< void(void)> &cb) |
Sets the lambda to be executed when the user touch is released. | |
void | setLongTapDetection (uint32_t delay_ms) |
Configures the long tap detection. | |
bool | isInputInside (void) const |
Returns if there is user input (touch) inside the view. | |
const DsPoint & | getTouchPosition (void) const |
Returns the location of the user touch input inside the view. | |
void | enableHorizontalScroll (bool state) |
Enables or disables the horizontal scroll of the view contents. | |
void | enableVerticalScroll (bool state) |
Enables or disables the vertical scroll of the view contents. | |
void | setScrollbarColor (DsColor color) |
Configure the color of the scroll bars. | |
virtual void | invalidate (void) |
Invalidates the view. | |
virtual void | invalidateRegion (DsRect region) |
Invalidates only a region of the view. | |
void | addStateObserver (StateObserver *observer) |
Adds a state observer object. | |
void | removeStateObserver (StateObserver *observer) |
Removes a state observer object. | |
Protected Member Functions | |
virtual void | onChildAdd (DsView *child) |
This virtual method will be called when a new child had been added to the view. | |
virtual void | onSizeChange (void) |
This virtual method will be called when the size of the view changes. | |
virtual void | onPaint (DsRenderer &renderer) |
This virtual method will be called when the view needs to repaint it's content. | |
virtual void | onPaintOver (DsRenderer &renderer) |
This virtual method will be called when the view needs to repaint it's content, but after the view and it's children had been painted. | |
virtual bool | onTouch (const DsTouchEvent &event) |
This virtual method will be called when there is touch user input. | |
virtual void | onVSync (void) |
This virtual method is be called at every vertical sync period. | |
virtual void | onKeyboard (int32_t key) |
This virtual method is called when there is a keyboard event that needs to be processed. | |
void | inputCapture (void) |
Captures the touch input. | |
bool | isInputCaptured (void) const |
Is the input captured? | |
void | skipInput (void) |
Skips receiving touch inputs until the end of the current touch event. | |
void | forAllChildren (const lambda< void(DsView *child)> &lambda) |
Calls the supplied lambda for every view in the children list. | |
void | forAllChildrenBackwards (const lambda< void(DsView *child)> &lambda) |
Calls the supplied lambda for every view in the children list. | |
Protected Attributes | |
DsPoint | mScrollPosition |
DsPoint | mPreviousScrollPosition |
DsPoint | mScrollPositionBase |
DsColor | mScrollbarColor |
DsPoint | mTouchPos |
uint32_t | mTouchTimestamp |
Friends | |
class | DsScreen |
class | DsList |
class | DsGrid |
class | DsBookView |
DsView is a base class that represents any view on the screen.
All view classes, including custom ones written by the user must have DsView as a base class.
A DsView is a rectangular area on the screen. The area is defined by the view X,Y coordinates (position) and the view size (W, H). Each DsView contains a list of children views and a pointer to the parent view. Painting always happens from top down, recursively. First the parent is painted, followed by the children in the order in which they were created. After a view and all it's children are painted, the onPainOver() virtual method is called. This gives the oportunity to paint on top of the view's children. A view class can be in multiple states:
Creates a DsView with an optional position and size.
parent | The parent view |
pos | The position of the view in the parent coordinate system |
size | The size of the view |
DsView::DsView | ( | DsView * | parent, |
DsOrientation | layout_orientation | ||
) |
Creates a DsView with the auto-layout mode active. This view can align it's children automatically.
void DsView::addChild | ( | DsView * | view | ) |
Adds a child to the current DsView.
view | The view to add as a child. The view will not be added if it already has a parent. |
void DsView::addStateObserver | ( | StateObserver * | observer | ) |
Adds a state observer object.
The state observer will be notified when the view's visibility state changes.
observer | State observer |
void DsView::alignInParent | ( | const DsAlignment & | alignment, |
int32_t | padding_top, | ||
int32_t | padding_left, | ||
int32_t | padding_bottom, | ||
int32_t | padding_right | ||
) |
Aligns the view relative to it's parent.
alignment | The alignment mode |
padding_top | Top padding |
padding_left | Left padding |
padding_bottom | Bottom padding |
padding_right | Right padding |
void DsView::alignInParent | ( | void | ) |
Aligns the view relative to it's parent.
The alignment is done according to the parent alignment mode set using setParentAlignment() and the view padding.
void DsView::bringFront | ( | void | ) |
Brings the current view to the top of the drawing order.
This view will be drawn on top of it's other siblings.
void DsView::centerHorizontally | ( | DsView * | view | ) |
Aligns horizontally the center of the current view with the center of another view.
view | The view to align the current view with |
void DsView::centerVertically | ( | DsView * | view | ) |
Aligns vertically the center of the current view with the center of another view.
view | The view to align the current view with |
void DsView::doLayout | ( | void | ) |
Runs the auto-layout algorithm.
This method only produces result if the auto-layout mode is enabled.
void DsView::enable | ( | bool | state | ) |
Enables or disables the view.
When a view is disabled, neither itself nor it's children can receive any events including user input.
state | True to enable the view, false to disable |
void DsView::enableHorizontalScroll | ( | bool | state | ) |
Enables or disables the horizontal scroll of the view contents.
If scrolling is enabled, the user can scroll the contents of this view by dragging it.
state | True to enable or false to disable the horizontal scrolling |
void DsView::enableTouch | ( | bool | state | ) |
Enables or disables processing of touch events.
state | True to enable processing of touch events, false to disable it |
void DsView::enableVerticalScroll | ( | bool | state | ) |
Enables or disables the vertical scroll of the view contents.
If scrolling is enabled, the user can scroll the contents of this view by dragging it.
state | True to enable or false to disable the vertical scrolling |
|
virtual |
Calculates the minimum size required by the view.
This method only produces result if the auto-layout mode is enabled.
It recursively calls fitContent() of all it's children to get their minimum size and then calculates the minimum size of the current view, taking into consideration the padding for all it's children.
It also sets the minimum size of the view.
Calls the supplied lambda for every view in the children list.
This method travels through all the children of a view, from top to bottom (in order of painting on the screen) and it calls the specified lambda.
lambda | Lambda of type void(DsView* child) to call |
Calls the supplied lambda for every view in the children list.
This method travels through all the children of a view, from bottom to top (in order of painting on the screen) and it calls the specified lambda.
lambda | Lambda of type void(DsView* child) to call |
DsFPoint DsView::getCenterPoint | ( | void | ) | const |
Returns the center point of the view in current coordinates.
bool DsView::getIsVisible | ( | void | ) | const |
Is the view visibility enabled?
DsView * DsView::getParent | ( | void | ) | const |
Returns the parent of the current view.
DsAlignment DsView::getParentAlignment | ( | void | ) | const |
Returns parent alignment mode of the view.
const DsSize & DsView::getParentSize | ( | void | ) | const |
Returns the size of the parent view.
const DsPoint & DsView::getPosition | ( | void | ) | const |
Returns the position of the view in parent coordinates.
Returns the position in the parent's coordinate system.
parent | Pointer to the parent to use for coordinate translation. |
DsRect DsView::getRegion | ( | void | ) | const |
Returns a rectangle describing the space occupied by the current view in it's own coordinate system (X and Y coordinates are 0).
Returns a rectangle describing the space occupied by the current view in the parent's coordinate system.
parent | Pointer to the parent to use for coordinate translation. |
DsScreen & DsView::getScreen | ( | void | ) |
const DsSize & DsView::getSize | ( | void | ) | const |
Returns the size of the view.
const DsPoint & DsView::getTouchPosition | ( | void | ) | const |
Returns the location of the user touch input inside the view.
It is only valid if isInputInside() returns true, otherwise it returns the last know location of user touch input.
|
protected |
Captures the touch input.
When a view captures the touch input, all touch events will be routed to that view alone. No other view will receive touch inputs until the touch event is finished (user lift finger off the screen)
|
virtual |
Invalidates the view.
Invalidating a view marks it for repainting by the graphic framework.
|
virtual |
Invalidates only a region of the view.
Invalidating a region of the view marks it for repainting by the graphic framework. It is important to not invalidate the entire view if only a small portion of it needs to be refreshed.
bool DsView::isEnabled | ( | void | ) | const |
Is the view enabled?
bool DsView::isFocused | ( | void | ) |
Is the view focused?
Only a focused view can receive user input events (keypresses for example)
|
protected |
Is the input captured?
bool DsView::isInputInside | ( | void | ) | const |
Returns if there is user input (touch) inside the view.
bool DsView::isParentVisible | ( | void | ) | const |
Is the parent view actually visible on the screen?
bool DsView::isTouchEnabled | ( | void | ) | const |
Is the view enabled to process touch events?
bool DsView::isVisible | ( | void | ) | const |
Is the view actually visible on the screen?
|
protectedvirtual |
This virtual method will be called when a new child had been added to the view.
child | DsView child that has been added |
|
protectedvirtual |
This virtual method is called when there is a keyboard event that needs to be processed.
key | ASCII code of the key |
|
protectedvirtual |
This virtual method will be called when the view needs to repaint it's content.
A derived class must override it and implement it's own content painting. In the default implementation, it implements the window scrolling mechanism.
Paint events are propagated recursively, from top down. First the view's own onPaint() is called, followed by painting it's children and finally its own onPaintAfter(). Views only receive the onPaint() event if they need to repaint their contents.
renderer | A DsRenderer object that can be used for painting operations. This object already has a DsSurface attached to it. This DsSurface object is a subsurface of the framebuffer representing only the area used by the view. All coordinates are zero based (in the current view coordinate system). |
Reimplemented in DsLabel.
|
protectedvirtual |
This virtual method will be called when the view needs to repaint it's content, but after the view and it's children had been painted.
This can be used to draw on top of all children of the current view. A derived class must override it and implement it's own content painting. In the default implementation, it implements the window scrolling mechanism.
Views only receive the onPaint() event if they need to repaint their contents.
renderer | A DsRenderer object that can be used for painting operations. This object already has a DsSurface attached to it. This DsSurface object is a subsurface of the framebuffer representing only the area used by the view. All coordinates are zero based (in the current view coordinate system). |
|
protectedvirtual |
This virtual method will be called when the size of the view changes.
In the default implementation, it will run the auto-layout algorithm if enabled.
|
protectedvirtual |
This virtual method will be called when there is touch user input.
A derived class must override it and implement it's own touch input processing. In the default implementation, it implements standard touch detection: tap / touch / release / drag to scroll. The default implementation is required for setOnTapCallback(), setOnLongTapCallback(), setOnTouchCallback(), setOnReleaseCallback() to work. Touch detection can be enabled / disabled using enableTouch() and setLongTapDetection().
The touch events propagate recursively, bottom up. It starting from the child view on the top of the painting order and gord up towards the parent. When onTouch() returns true, it signals that the view handleded the event. In this case, the event stops propagating towards the parents. If onTouch returns false, the parent will receive the same onTouch() event. In an overridden implementation of onTouch() it's important to detect early on if the event is of no interest to the view and call skipInput(). This will make it so the current touch event (until user removes the finger from the screen) will not make it to the current view anymore, allowing the parent views to handle the event.
Under normal conditions, if the touch coordinates exit a view, that view will not receive touch events. This may not be desirable in cases where the user is dragging in order to cause some change in the current view. For this reason, captureInput() can be called. This captures the input in the currnet view, making it so for the rest of the touch event, only the current view will receive touch events.
event | The touch event. This contains the touch mode, position in current view coordinates and timestamp of the touch event. |
|
protectedvirtual |
This virtual method is be called at every vertical sync period.
It can be used for timing, animations or to implement low granularity timers and timeouts.
void DsView::removeChild | ( | DsView * | view | ) |
Removes a child to the current DsView.
view | The view to remove from the children list. The view will not be removed if it's not already a child. |
void DsView::removeStateObserver | ( | StateObserver * | observer | ) |
Removes a state observer object.
observer | State observer to remove |
void DsView::reserveSpace | ( | bool | state | ) |
Configures if during auto-layout the view will reserve space even if it's hidden.
This method has no effect if the parent auto-layout is not enabled.
state | If true, the view will reserve space in the layout of the parent even if it's hidden |
void DsView::sendBack | ( | void | ) |
Sends the current view to the bottom of the drawing order.
This view will be drawn under all of it's other siblings.
void DsView::sendTap | ( | DsPoint | pos | ) |
Sends a tap event to the view.
pos | The coordinates of the tap event |
void DsView::setAutoLayout | ( | DsOrientation | orientation, |
bool | enable | ||
) |
Enables or disables the auto-layout mode and sets the primary orientation.
orientation | Primary orientation of the auto-layout. |
enable | The auto-layout state (enabled / disabled) |
void DsView::setBackgroundColor | ( | DsColor | color | ) |
Sets the background color of the view.
color | Background color. If the alpha channel is set to zero, the view will not paint the background. |
void DsView::setBackgroundImage | ( | const DsSurface * | surface | ) |
Sets the background image.
surface | Background surface. |
void DsView::setCenterPosition | ( | const DsPoint & | pos | ) |
Sets the position of the center of the view in parent coordinates.
This is used to easily align the center of the view.
pos | DsPoint representing the position in parent coordinates |
void DsView::setHeight | ( | int32_t | height | ) |
Sets the height of the view.
height | Height of the view |
void DsView::setLongTapDetection | ( | uint32_t | delay_ms | ) |
Configures the long tap detection.
delay_ms | Delay in milliseconds to detect a long tap (tap and hold). If 0, it disables the long tap detection. |
void DsView::setMinimumSize | ( | const DsSize & | size | ) |
Returns the minimum size of the view.
Sets the lambda to be executed when the user taps the view and holds for a specific time (set with setLongTapDetection()).
cb | Lambda of type void(const DsPoint &p) . The parameter p is the position in the current view coordinates where the user tapped and held. |
Sets the lambda to be executed when the user taps on the view.
cb | Lambda of type void(const DsPoint &p) . The parameter p is the position in the current view coordinates where the user tapped. |
Sets the lambda to be executed when the user touches the view.
cb | Lambda of type void(const DsPoint &p) . The parameter p is the position in the current view coordinates where the user touched. |
void DsView::setOnTouchReleaseCallback | ( | const lambda< void(void)> & | cb | ) |
Sets the lambda to be executed when the user touch is released.
cb | Lambda of type void(void) |
DsView * DsView::setPadding | ( | int16_t | padding, |
uint16_t | proportion = 0 |
||
) |
Sets the padding used by the auto-layout.
This is the space left between the current view and the other neighboring views during auto-layout.
padding | Padding (applied to top, left, bottom, right) |
proportion | The proportion used for padding |
DsView * DsView::setPaddingBottom | ( | int16_t | padding, |
uint16_t | proportion = 0 |
||
) |
Sets the bottom padding used by the auto-layout.
This is the space left between the current view and the view to the bottom during auto-layout.
padding | Bottom padding |
proportion | The proportion used for padding |
DsView * DsView::setPaddingHorizontal | ( | int16_t | padding, |
uint16_t | proportion = 0 |
||
) |
Sets the horizontal padding used by the auto-layout.
This is the space left between the current view and the other neighboring views during auto-layout.
padding | Horizontal padding (left and right) |
proportion | The proportion used for the horizontal padding |
DsView * DsView::setPaddingLeft | ( | int32_t | padding, |
uint16_t | proportion = 0 |
||
) |
Sets the left padding used by the auto-layout.
This is the space left between the current view and the view to the left during auto-layout.
padding | Left padding |
proportion | The proportion used for padding |
DsView * DsView::setPaddingRight | ( | int16_t | padding, |
uint16_t | proportion = 0 |
||
) |
Sets the right padding used by the auto-layout.
This is the space left between the current view and the view to the right during auto-layout.
padding | Right padding |
proportion | The proportion used for padding |
DsView * DsView::setPaddingTop | ( | int16_t | padding, |
uint16_t | proportion = 0 |
||
) |
Sets the top padding used by the auto-layout.
This is the space left between the current view and the view to the top during auto-layout.
padding | Top padding |
proportion | The proportion used for padding |
DsView * DsView::setPaddingVertical | ( | int16_t | padding, |
uint16_t | proportion = 0 |
||
) |
Sets the vertical padding used by the auto-layout.
This is the space left between the current view and the other neighboring views during auto-layout.
padding | Vertical padding (top and bottom) |
proportion | The proportion used for the vertical padding |
void DsView::setPanelBorderColor | ( | DsColor | color | ) |
Sets the color of the panel border.
color | Panel border color |
void DsView::setPanelBorderThickness | ( | uint8_t | thickness | ) |
Sets the thickness of the panel border.
thickness | Panel border thickness |
void DsView::setPanelColor | ( | DsColor | color | ) |
Sets the color of the panel.
color | Panel color. If the alpha channel is set to zero, the view will not paint a panel. |
void DsView::setPanelCornerRadius | ( | uint16_t | radius | ) |
Sets the radius of the panel corners.
radius | Panel corner radius |
void DsView::setParent | ( | DsView * | parent | ) |
Sets a new parent to the view.
The view will be removed from it's old parent and added to the new parent. If "parent" is nullptr, the view will become orphan.
parent | New parent view. |
DsView * DsView::setParentAlignment | ( | const DsAlignment & | alignment | ) |
Sets parent alignment mode of the view.
This aligment mode applies when the parent view has auto-layout enabled. This method has no effect if the parent auto-layout is not enabled. The parent view will use the alignment mode to align it's children in the secondary direction. The primary direction of a view with the auto-layout mode enabled is the one set in the constructor. The secondary direction is the direction perpendicular to the primary direction.
Example: If the DsView is created using DsView(parent, DS_VERTICAL), the primary direction is vertical and secondary direction is horizontal.
If the alignment mode is DS_ALIGN_FIT, the view will be expanded in the secondary direction to fit the parent.
alignment | Alignment mode |
void DsView::setPosition | ( | const DsPoint & | pos | ) |
Sets the position of the view in parent coordinates.
pos | DsPoint representing the position in parent coordinates |
DsView * DsView::setProportion | ( | uint32_t | proportion | ) |
Sets the view proportion used by the auto-layout.
The proportion is used by the parent auto-layout to distribute surplus available size to it's children in the primary direction. This method has no effect if the parent auto-layout is not enabled.
Example: If the DsView is created using DsView(parent, DS_VERTICAL), the primary direction is vertical and secondary direction is horizontal.
Each child will receive size proportional to it's proportion divided by the sum of all proportion values of all it's siblings.
Example:
A DsView has auto-layout enabled and the orientation set to DS_VERTICAL. It contains 3 children:
Child 1: proportion = 0 Child 2: proportion = 2 Child 3: proportion = 1
The auto-layout calculates the minimum size a child requires by calling the fitContent()
method of each child. Since the orientation is set to DS_VERTICAL, the view will arrange it's children vertically, in the order in which they were added. If the parent has extra size available in the vertical direction (H of parent > sum of H of all children) then it will distribute that remaining size to it's children in the following way:
Child 1 receives 0 / 3 of the extra size Child 2 receives 2 / 3 of the extra size Child 3 receives 1 / 3 of the extra size
proportion | Proportion |
void DsView::setScrollbarColor | ( | DsColor | color | ) |
Configure the color of the scroll bars.
Scrollbars appear if scrolling is enabled and the user is actively scrolling the contents of the view.
color | Scrollbar color. If the alpha channel is zero, the scrollbars will not be painted. |
void DsView::setSize | ( | const DsSize & | size | ) |
Sets the size of the view.
If the view's auto-layout is enabled it computes the layout as well using the new size.
size | Size of the view |
bool DsView::setVisible | ( | bool | is_visible | ) |
Changes the visibility of the view.
The change is propagated to all it's children.
is_visible | Visibility state |
void DsView::setWidth | ( | int32_t | width | ) |
Sets the width of the view.
width | Width of the view |
Translates position (x, y) in parent coordinate system.
parent | Pointer to the parent to use for coordinate translation. |
pos | Position to translate in parent coordinate system |
Translates position (x, y) in parent coordinate system.
parent_level | The parent to use for translation. 0 = immediate parent, 1 = grandparent, ... |
pos | Position to translate in parent coordinate system |