Element Properties
PBElementProperty
Enumeration/bitset of type int32_t: The types of properties that can be set on an element. Positive values can be defined by applications; negative values are reserved for system use.
Constants
PBElementProperty_INSETS
PBElementProperty_INSETS = -1
A rectangle that specifies the distance (in dps) between each edge of this element and its child elements.
PBElementProperty_GAP
PBElementProperty_GAP = -2
A float that specifies the distance between each pair of child elements (in dps).
PBElementProperty_WIDTH
PBElementProperty_WIDTH = -3
A float that specifies the exact width of this element (in dps). If an element doesn't have this property, its width is determined automatically based on the size of its child elements. To make an element fill the width of its parent element, see PBElement_H_FILL.
PBElementProperty_HEIGHT
PBElementProperty_HEIGHT = -4
A float that specifies the exact height of this element (in dps). If an element doesn't have this property, its height is determined automatically based on the size of its child elements. To make an element fill the height of its parent element, see PBElement_V_FILL.
PBElementProperty_FILL_COLOR
PBElementProperty_FILL_COLOR = -5
A color that fills the bounds of the element. Setting this property on a standard control may remove its default styling.
PBElementProperty_BORDER_COLOR
PBElementProperty_BORDER_COLOR = -6
A color that fills the border of the element. You must also set PBElementProperty_BORDER_SIZE to define a border. Setting this property on a standard control may remove its default styling.
PBElementProperty_BORDER_SIZE
PBElementProperty_BORDER_SIZE = -7
A float giving the size of the element's border (in dps). This is a visual property only; it does not affect layout. To specify the layout gap between the edge of the element and its children, see PBElementProperty_INSETS. You must also set PBElementProperty_BORDER_COLOR to define a border. The border is drawn inside the element, not outside. Setting this property on a standard control may remove its default styling.
PBElementProperty_CORNER_RADIUS
PBElementProperty_CORNER_RADIUS = -8
A float giving the radius of the rounded corners (in dps). You must set a fill or border color property for this to take effect. Setting this property on a standard control may remove its default styling.
PBElementProperty_TEXT_COLOR
PBElementProperty_TEXT_COLOR = -9
A color to use for drawing text. This property is used by PBInputField and PBTextDisplay. For the latter, you can use the flag PBTextDisplay_INHERIT_COLORS to allow it to search its ancestor elements until it finds one which has the property. Changing this property causes this element and all descendents to be redrawn
PBElementProperty_SELECTED_HIGHLIGHT_COLOR
PBElementProperty_SELECTED_HIGHLIGHT_COLOR = -10
A color to use for drawing text selections. This property is used by PBInputField and PBTextDisplay. For the latter, you can use the flag PBTextDisplay_INHERIT_COLORS to allow it to search its ancestor elements until it finds one which has the property. Changing this property causes this element and all descendents to be redrawn.
PBElementProperty_SHADOW_COLOR
PBElementProperty_SHADOW_COLOR = -11
A color that fills the drop shadow of the element. There are several other shadow properties that must be set to define an element's shadow. The shadow is drawn below the element, at draw depth PBDepthIndex_SHADOW. Setting this property on a standard control may remove its default styling.
PBElementProperty_SHADOW_OFFSET_X
PBElementProperty_SHADOW_OFFSET_X = -12
A float giving the horizontal offset of the element's shadow (in dps). You must also set the shadow color with PBElementProperty_SHADOW_COLOR for this property to be used. Setting this property on a standard control may remove its default styling.
PBElementProperty_SHADOW_OFFSET_Y
PBElementProperty_SHADOW_OFFSET_Y = -13
A float giving the vertical offset of the element's shadow (in dps). You must also set the shadow color with PBElementProperty_SHADOW_COLOR for this property to be used. Setting this property on a standard control may remove its default styling.
PBElementProperty_SHADOW_BLUR
PBElementProperty_SHADOW_BLUR = -14
A float giving the blur radius of the element's shadow. This is the standard deviation for an approximated Gaussian blur. You must also set the shadow color with PBElementProperty_SHADOW_COLOR for this property to be used. Setting this property on a standard control may remove its default styling.
PBElementProperty_DRAW_OFFSET
PBElementProperty_DRAW_OFFSET = -15
A rectangle giving the offset from each side of element to where the element's fill and border should be drawn (in dps). This property has no effect if neither PBElementProperty_FILL_COLOR nor PBElementProperty_BORDER_COLOR has been set.
PBElementProperty_AUTOMATION_ID
PBElementProperty_AUTOMATION_ID = -16
PBElementPropertyAnimationFlags
Enumeration/bitset of type uint32_t: Flags controlling the animation of an element property.
Constants
PBElementPropertyAnimation_IGNORE_REDUCE_MOTION
PBElementPropertyAnimation_IGNORE_REDUCE_MOTION = 1<<0
If this bit is not set and PBSystemProperty_REDUCE_MOTION is enabled, then the animation will complete immediately. If this bit is set, then the animation will always play.
PBElementPropertyAnimation
Tagged union: Animation parameters for a property modification.
Tags
PBElementPropertyAnimation_NONE
PBElementPropertyAnimation_NONE
with field none
(PBElementPropertyAnimationNone):
No animation. The value is changed immediately.
PBElementPropertyAnimation_LINEAR
PBElementPropertyAnimation_LINEAR
with field linear
(PBElementPropertyAnimationLinear):
The value is linearly interpolated from the old value to the new value at a constant velocity.
PBElementPropertyAnimation_CAPACITOR
PBElementPropertyAnimation_CAPACITOR
with field capacitor
(PBElementPropertyAnimationCapacitor):
The property is changed smoothly from the old value to the new value. The greater the difference between the two values, the faster it changes. As the new value is approached, the rate of change decreases smoothly.
PBElementPropertyAnimation_SPRING
PBElementPropertyAnimation_SPRING
with field spring
(PBElementPropertyAnimationSpring):
The property and its velocity are changed smoothly from their old values to the new property value and zero respectively using a spring model.
PBElementPropertyAnimationNone
Structure:
Fields
unused (bool
):
See Also
PBElementPropertyAnimationLinear
Structure:
Fields
duration (float
): The duration of the animation in seconds.
flags (PBElementPropertyAnimationFlags): Flags controlling the animation.
See Also
PBElementPropertyAnimationCapacitor
Structure:
Fields
coefficient (float
): The capacitor's coefficient.
doneThreshold (float
): The maximum distance between the current and target values at which the animation is considered complete and the property is set to the target value.
flags (PBElementPropertyAnimationFlags): Flags controlling the animation.
See Also
PBElementPropertyAnimationSpring
Structure:
Fields
k (float
): The stiffness of the spring.
c (float
): The damping constant. The spring is critically dampened when the square of the damping constant is equal to four times the stiffness of the spring. If the square of the damping constant is less than this, then the spring will overshoot the target value before being pulled back. It may oscillate a few times before coming to rest, depending on the doneThreshold.
doneThreshold (float
): The maximum distance between the current and target values at which the animation is considered complete and the property is set to the target value.
flags (PBElementPropertyAnimationFlags): Flags controlling the animation.
See Also
PBElementPropertyVariantState
Enumeration/bitset of type int32_t:
Constants
PBElementPropertyVariantState_PUSHED
PBElementPropertyVariantState_PUSHED = 1
PBElementPropertyVariantState_FOCUSED
PBElementPropertyVariantState_FOCUSED = 2
PBElementPropertyVariantState_DISABLED
PBElementPropertyVariantState_DISABLED = 3
PBElementPropertyVariantState_HOVER_WITHIN
PBElementPropertyVariantState_HOVER_WITHIN = 4
PBElementPropertyVariantState_FOCUS_WITHIN
PBElementPropertyVariantState_FOCUS_WITHIN = 5
PBElementPropertyColorVariant
Structure:
Fields
color (PBColor):
animation (PBElementPropertyAnimation):
state (PBElementPropertyVariantState):
PBElementPropertyAnimationNoneMake
Function: Initialize a PBElementPropertyAnimation union with no animation.
Syntax (C/C++)
PBElementPropertyAnimation PBElementPropertyAnimationNoneMake();
Syntax (Python)
ElementPropertyAnimationNoneMake() -> (animation)
Parameters and Return Values
[out] animation (PBElementPropertyAnimation): The populated animation union.
PBElementPropertyAnimationLinearMake
Function: Initialize a PBElementPropertyAnimation union with a linear animation.
Syntax (C/C++)
PBElementPropertyAnimation PBElementPropertyAnimationLinearMake(float duration,
PBElementPropertyAnimationFlags flags);
Syntax (Python)
ElementPropertyAnimationLinearMake(duration, flags) -> (animation)
Parameters and Return Values
[in] duration (float
): The duration of the animation in seconds.
[in] flags (PBElementPropertyAnimationFlags): Flags controlling the animation.
[out] animation (PBElementPropertyAnimation): The populated animation union.
PBElementPropertyAnimationCapacitorMake
Function: Initialize a PBElementPropertyAnimation union with a capacitor animation.
Syntax (C/C++)
PBElementPropertyAnimation PBElementPropertyAnimationCapacitorMake(
float halfLife, float doneThreshold, PBElementPropertyAnimationFlags flags);
Syntax (Python)
ElementPropertyAnimationCapacitorMake(halfLife, doneThreshold, flags) -> (animation)
Parameters and Return Values
[in] halfLife (float
): The time in seconds it takes for the difference between the current and target values to halve.
[in] doneThreshold (float
): The maximum distance between the current and target values at which the animation is considered complete and the property is set to the target value.
[in] flags (PBElementPropertyAnimationFlags): Flags controlling the animation.
[out] animation (PBElementPropertyAnimation): The populated animation union.
PBElementPropertyAnimationSpringMake
Function: Initialize a PBElementPropertyAnimation union with a spring animation.
Syntax (C/C++)
PBElementPropertyAnimation PBElementPropertyAnimationSpringMake(float k, float c,
float doneThreshold, PBElementPropertyAnimationFlags flags);
Syntax (Python)
ElementPropertyAnimationSpringMake(k, c, doneThreshold, flags) -> (animation)
Parameters and Return Values
[in] k (float
): The stiffness of the spring.
[in] c (float
): The damping constant. The spring is critically dampened when the square of the damping constant is equal to four times the stiffness of the spring. If the square of the damping constant is less than this, then the spring will overshoot the target value before being pulled back. It may oscillate a few times before coming to rest, depending on the doneThreshold.
[in] doneThreshold (float
): The maximum distance between the current and target values at which the animation is considered complete and the property is set to the target value.
[in] flags (PBElementPropertyAnimationFlags): Flags controlling the animation.
[out] animation (PBElementPropertyAnimation): The populated animation union.
PBElementSetPropertyF32
Function:
Syntax (C/C++)
bool PBElementSetPropertyF32(PBElementRef element, PBElementProperty key,
float value,
/* optional */ const PBElementPropertyAnimation * _Nullable __restrict animation);
Syntax (Python)
ElementSetPropertyF32(element, key, value, animation) -> (success)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] value (float
):
[optional-in] animation (PBElementPropertyAnimation):
[out] success (bool
):
PBElementGetPropertyF32
Function:
Syntax (C/C++)
bool PBElementGetPropertyF32(PBElementRef element, PBElementProperty key,
bool ignoreAnimation, /* output */ float * _Nullable __restrict value);
Syntax (Python)
ElementGetPropertyF32(element, key, ignoreAnimation) -> (found, value)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] ignoreAnimation (bool
):
[out] found (bool
):
[optional-out] value (float
):
PBElementSetPropertyRectangle
Function:
Syntax (C/C++)
bool PBElementSetPropertyRectangle(PBElementRef element, PBElementProperty key,
PBRectangle value,
/* optional */ const PBElementPropertyAnimation * _Nullable __restrict animation);
Syntax (Python)
ElementSetPropertyRectangle(element, key, value, animation) -> (success)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] value (PBRectangle):
[optional-in] animation (PBElementPropertyAnimation):
[out] success (bool
):
PBElementGetPropertyRectangle
Function:
Syntax (C/C++)
bool PBElementGetPropertyRectangle(PBElementRef element, PBElementProperty key,
bool ignoreAnimation, /* output */ PBRectangle * _Nullable __restrict value);
Syntax (Python)
ElementGetPropertyRectangle(element, key, ignoreAnimation) -> (found, value)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] ignoreAnimation (bool
):
[out] found (bool
):
[optional-out] value (PBRectangle):
PBElementSetPropertyColor
Function:
Syntax (C/C++)
bool PBElementSetPropertyColor(PBElementRef element, PBElementProperty key,
PBColor value,
/* optional */ const PBElementPropertyAnimation * _Nullable __restrict animation);
Syntax (Python)
ElementSetPropertyColor(element, key, value, animation) -> (success)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] value (PBColor):
[optional-in] animation (PBElementPropertyAnimation):
[out] success (bool
):
PBElementSetPropertyColorVarying
Function:
Syntax (C/C++)
bool PBElementSetPropertyColorVarying(PBElementRef element,
PBElementProperty key,
const PBElementPropertyColorVariant *_Nullable colors, size_t colorsCount);
Syntax (Python)
ElementSetPropertyColorVarying(element, key, colors) -> (success)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] colors (referenced array of PBElementPropertyColorVariant): The number of variants in the array must be between 1 and 5. The array should be ordered by priority; the first variant in the array has highest priority. Regardless of its state field, the last variant in the array will always be used as a default when no other variant applies.
[out] success (bool
):
PBElementGetPropertyColor
Function:
Syntax (C/C++)
bool PBElementGetPropertyColor(PBElementRef element, PBElementProperty key,
bool ignoreAnimation, /* output */ PBColor * _Nullable __restrict value);
Syntax (Python)
ElementGetPropertyColor(element, key, ignoreAnimation) -> (found, value)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] ignoreAnimation (bool
):
[out] found (bool
):
[optional-out] value (PBColor):
PBElementSetPropertyStr
Function:
Syntax (C/C++)
bool PBElementSetPropertyStr(PBElementRef element, PBElementProperty key,
ConstStr value);
Syntax (Python)
ElementSetPropertyStr(element, key, value) -> (success)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[in] value (referenced string):
[out] success (bool
):
PBElementGetPropertyStr
Function:
Syntax (C/C++)
bool PBElementGetPropertyStr(PBElementRef element, PBElementProperty key,
/* output */ MutStr * _Nullable __restrict value);
Syntax (Python)
ElementGetPropertyStr(element, key) -> (found, value)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[out] found (bool
):
[optional-out] value (owned string):
PBElementIsPropertyAnimating
Function:
Syntax (C/C++)
bool PBElementIsPropertyAnimating(PBElementRef element, PBElementProperty key);
Syntax (Python)
ElementIsPropertyAnimating(element, key) -> (foundAndIsAnimating)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[out] foundAndIsAnimating (bool
):
PBElementRemoveProperty
Function:
Syntax (C/C++)
bool PBElementRemoveProperty(PBElementRef element, PBElementProperty key);
Syntax (Python)
ElementRemoveProperty(element, key) -> (found)
Parameters and Return Values
[in] element (referenced PBElement):
[in] key (PBElementProperty):
[out] found (bool
):