FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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).

    View source

    Members

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<RatingControl>
    

    Returns a strong reference to this object.

    Source

    caption_property

    fn caption_property() -> &'static StyledProperty<String>
    

    Defines the Caption property: the text beside the items.

    Source

    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.

    Source

    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.

    Source

    is_read_only_property

    fn is_read_only_property() -> &'static StyledProperty<bool>
    

    Defines the IsReadOnly property: whether the user cannot change the rating.

    Source

    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.

    Source

    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.

    Source

    item_info_property

    fn item_info_property() -> &'static StyledProperty<Option<Ref<RatingItemInfo>>>
    

    Defines the ItemInfo property: the glyphs or the images of the items.

    Source

    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).

    Source

    construct

    fn construct() -> Self
    

    Creates the class data; see ferroui_base::FerroObject::construct.

    Source

    new

    fn new() -> Ref<Self>
    

    Source

    caption

    fn caption(self: &Self) -> String
    

    Gets the text beside the items.

    Source

    set_caption

    fn set_caption(self: &Self, value: impl Into<String>)
    

    Sets the text beside the items.

    Source

    initial_set_value

    fn initial_set_value(self: &Self) -> i32
    

    Gets the rating the keys start from while the rating is not set.

    Source

    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.

    Source

    is_clear_enabled

    fn is_clear_enabled(self: &Self) -> bool
    

    Gets whether choosing the rating again clears it.

    Source

    set_is_clear_enabled

    fn set_is_clear_enabled(self: &Self, value: bool)
    

    Sets whether choosing the rating again clears it.

    Source

    is_read_only

    fn is_read_only(self: &Self) -> bool
    

    Gets whether the user cannot change the rating.

    Source

    set_is_read_only

    fn set_is_read_only(self: &Self, value: bool)
    

    Sets whether the user cannot change the rating.

    Source

    max_rating

    fn max_rating(self: &Self) -> i32
    

    Gets the number of items.

    Source

    set_max_rating

    fn set_max_rating(self: &Self, value: i32)
    

    Sets the number of items.

    Source

    placeholder_value

    fn placeholder_value(self: &Self) -> f64
    

    Gets the rating shown while the rating is not set.

    Source

    set_placeholder_value

    fn set_placeholder_value(self: &Self, value: f64)
    

    Sets the rating shown while the rating is not set.

    Source

    item_info

    fn item_info(self: &Self) -> Option<Ref<RatingItemInfo>>
    

    Gets the glyphs or the images of the items.

    Source

    set_item_info

    fn set_item_info(self: &Self, value: Option<Ref<RatingItemInfo>>)
    

    Sets the glyphs or the images of the items.

    Source

    value

    fn value(self: &Self) -> f64
    

    Gets the rating: -1 while it is not set.

    Source

    set_rating_value

    fn set_rating_value(self: &Self, value: f64)
    

    Sets the rating. A change made here does not raise ValueChanged.

    Source

    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.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.