RatingControl
struct · ferroui-controls · v0.5.0
struct RatingControl
A control to rate with stars (WinUI's RatingControl): a value from 1 to MaxRating, or -1
while it is not set, a placeholder value (a community rating) shown while it is not set, and a
caption.
The items are drawn twice, in the background stack panel in the unset state and in the
foreground stack panel clipped to the value, from the glyphs of a RatingItemFontInfo (the
stars E735 and E734 of the symbol font by default, in the font of the control) or the images of
a RatingItemImageInfo. A click or a tap sets the rating under the pointer, and clears it
when it is the rating (with IsClearEnabled); the arrow keys, Home and End change it. Only the
changes of the user raise ValueChanged.
The template is the control theme of the WinUI theme (Controls/RatingControl.xaml, from
WinUI's RatingControl.xaml), with WinUI's parts RatingBackgroundStackPanel and
RatingForegroundStackPanel; the items take their size from the FontSize of the stack
panels (RatingControlFontSizeForRendering) and their brushes from the theme. The control
sets WinUI's visual states (CommonStates) as the pseudo-classes :placeholder,
:pointeroverplaceholder, :pointeroverunselected, :set and :pointeroverset (Disabled is
:disabled). The Fluent and Simple themes have no template for it
(docs/porting/winui-controls.md, section 5.1).
Missing (docs/porting/winui-controls.md, Input): the composition animations of the scale of the
items (the scale is set when the pointer moves), and the focus engagement of the gamepad
(IsFocusEngagementEnabled, GamepadA and GamepadB).
Members
TYPEto_refcaption_propertyinitial_set_value_propertyis_clear_enabled_propertyis_read_only_propertymax_rating_propertyplaceholder_value_propertyitem_info_propertyvalue_propertyconstructnewcaptionset_captioninitial_set_valueset_initial_set_valueis_clear_enabledset_is_clear_enabledis_read_onlyset_is_read_onlymax_ratingset_max_ratingplaceholder_valueset_placeholder_valueitem_infoset_item_infovalueset_rating_valuevalue_changed
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<RatingControl>
Returns a strong reference to this object.
caption_property
fn caption_property() -> &'static StyledProperty<String>
Defines the Caption property: the text beside the items.
initial_set_value_property
fn initial_set_value_property() -> &'static StyledProperty<i32>
Defines the InitialSetValue property: the rating the keys start from while the rating
is not set. 1 by default.
is_clear_enabled_property
fn is_clear_enabled_property() -> &'static StyledProperty<bool>
Defines the IsClearEnabled property: whether choosing the rating again clears it.
true by default.
is_read_only_property
fn is_read_only_property() -> &'static StyledProperty<bool>
Defines the IsReadOnly property: whether the user cannot change the rating.
max_rating_property
fn max_rating_property() -> &'static StyledProperty<i32>
Defines the MaxRating property: the number of items. 5 by default; a value less than 1
is 1.
placeholder_value_property
fn placeholder_value_property() -> &'static StyledProperty<f64>
Defines the PlaceholderValue property: the rating shown while the rating is not set
(a community rating), -1 for none (the default). From 0 to MaxRating.
item_info_property
fn item_info_property() -> &'static StyledProperty<Option<Ref<RatingItemInfo>>>
Defines the ItemInfo property: the glyphs or the images of the items.
value_property
fn value_property() -> &'static StyledProperty<f64>
Defines the Value property: the rating, from 1 to MaxRating, or -1 while it is not
set (the default).
construct
fn construct() -> Self
Creates the class data; see ferroui_base::FerroObject::construct.
new
fn new() -> Ref<Self>
caption
fn caption(self: &Self) -> String
Gets the text beside the items.
set_caption
fn set_caption(self: &Self, value: impl Into<String>)
Sets the text beside the items.
initial_set_value
fn initial_set_value(self: &Self) -> i32
Gets the rating the keys start from while the rating is not set.
set_initial_set_value
fn set_initial_set_value(self: &Self, value: i32)
Sets the rating the keys start from while the rating is not set.
is_clear_enabled
fn is_clear_enabled(self: &Self) -> bool
Gets whether choosing the rating again clears it.
set_is_clear_enabled
fn set_is_clear_enabled(self: &Self, value: bool)
Sets whether choosing the rating again clears it.
is_read_only
fn is_read_only(self: &Self) -> bool
Gets whether the user cannot change the rating.
set_is_read_only
fn set_is_read_only(self: &Self, value: bool)
Sets whether the user cannot change the rating.
max_rating
fn max_rating(self: &Self) -> i32
Gets the number of items.
set_max_rating
fn set_max_rating(self: &Self, value: i32)
Sets the number of items.
placeholder_value
fn placeholder_value(self: &Self) -> f64
Gets the rating shown while the rating is not set.
set_placeholder_value
fn set_placeholder_value(self: &Self, value: f64)
Sets the rating shown while the rating is not set.
item_info
fn item_info(self: &Self) -> Option<Ref<RatingItemInfo>>
Gets the glyphs or the images of the items.
set_item_info
fn set_item_info(self: &Self, value: Option<Ref<RatingItemInfo>>)
Sets the glyphs or the images of the items.
value
fn value(self: &Self) -> f64
Gets the rating: -1 while it is not set.
set_rating_value
fn set_rating_value(self: &Self, value: f64)
Sets the rating. A change made here does not raise ValueChanged.
value_changed
fn value_changed(self: &Self, handler: impl Fn(&RatingControl) -> () + 'static) -> Subscription
Adds a handler of the ValueChanged event, raised for the changes of the user only.
Dropping the returned guard removes the handler; Subscription::detach keeps it
for the life of the control.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeTemplatedControlImplExtControlImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<RatingControl>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleStyledElementImplVisualImplLayoutableImplInteractiveImplFerroObjectImplControlImplTemplatedControlImplInputElementImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.