Expand description
Rating stars: zero to five stars, edited with the pointer (and the
keyboard when focusable) or only shown. One widget for every place a
rating appears: a thumbnail’s overlay, a panel, a table’s column, a
file’s facts. Its behaviour follows the photo applications it is
modelled on (docs/rating.md):
Experimental: may change in any release
(docs/stability.md).
- empty stars are outlines, shown always or only while the item
they rate (or the stars) is under the pointer (
EmptyStars), so an unrated item still says it can be rated; - under the pointer the stars up to the pointer light in a
preview look (
hover), the rest stay outlines; the current value past the preview stays visible as a ghost (selectedin themutedtone); - a click gives the star’s value; on the star of the current value it clears the rating (its preview: every star a ghost). Each star’s tooltip and accessible name say it: “Set 3 of 5”, “Clear rating”;
- read-only, the stars are drawn by
rating-star-displayand read as “3 of 5”.
The application owns the value: the widget takes the current one and
says what the user asked for (RatingResponse::changed).
use egui_pop_core::rating::{EmptyStars, RatingStars};
fn ui(ui: &mut egui::Ui, rating: &mut u8) {
if let Some(r) = RatingStars::new(*rating).show(ui).changed {
*rating = r;
}
// In a table's cell: shown, not edited.
let _ = RatingStars::new(*rating).read_only(true).show(ui);
// Over a thumbnail: outlines only while the cell is hovered.
let _ = RatingStars::new(*rating).empty(EmptyStars::OnHover);
}Structs§
- Rating
Response - What
RatingStarsreturns. - Rating
Stars - Five stars (see the module).
Enums§
- Empty
Stars - When empty stars (outlines) show.
- Star
Look - What a star shows.
Constants§
- MAX_
RATING - The highest rating.
Functions§
- click_
value - What a click on star
star(1 to 5) gives: its value, or 0 on the star of the current value (it clears the rating).