pub struct MenuStyle {Show 21 fields
pub scale: f32,
pub panel: SkinInsets,
pub button: SkinInsets,
pub panel_padding: Vec2,
pub button_padding: Vec2,
pub item_gap: f32,
pub title_gap: f32,
pub title_size: f32,
pub item_size: f32,
pub hint_gap: f32,
pub track_width: f32,
pub track_height: f32,
pub handle_size: Vec2,
pub title_color: [f32; 4],
pub label_color: [f32; 4],
pub hint_color: [f32; 4],
pub warning_color: [f32; 4],
pub track_color: [f32; 4],
pub fill_color: [f32; 4],
pub handle_color: [f32; 4],
pub scrim_color: [f32; 4],
}Expand description
Re-exported for the same reason: menu_skin returns a MenuSkin, and
a caller that can name this crate’s menu art should not have to add a second
dependency to lay out and draw the menu it skins. It is also what lets an
end-to-end suite that depends on this crate take a golden image of the real
menu rather than of a replica.
Every length a menu is laid out with, in pixels.
Built from a whole-number scale by MenuStyle::pixel_art: the art is
pixel art and the panel is drawn at one texel per scale device pixels, so
every gap, pad and font size is a base metric times the same integer. A
fractional scale would put a nine-slice’s fixed corner on a half pixel, which
is the one thing SampleMode::Pixel cannot hide.
Fields§
§scale: f32Device pixels per texel of the menu art.
panel: SkinInsetsThe window frame’s fixed corners, in pixels.
A button skin’s fixed corners, in pixels.
panel_padding: Vec2Space between the panel’s frame and its contents.
Space between a button’s frame and its label.
item_gap: f32Vertical space between two buttons.
title_gap: f32Vertical space between the title and the first button.
title_size: f32The title’s font size.
item_size: f32An item label’s font size.
hint_gap: f32The least space between an item’s label and its key hint.
track_width: f32The least width a Slider row’s groove is given.
A least, not a width: Menu::layout_with stretches the groove into
whatever the panel’s widest row left over, so a slider beside a long
label is a long slider. This is what stops it collapsing when the slider
row is the widest one.
track_height: f32How tall a slider’s groove is drawn.
handle_size: Vec2The handle’s size. Its width is also the travel the groove loses at each end, so the handle stays inside the groove at both extremes.
title_color: [f32; 4]The title’s colour.
This and the other colours restate default.css’s menu rules, which
are what draw them: a style with different colours lays out the same
menu and draws it in the sheet’s. They are here for a caller measuring
what a menu drew — the scrim’s alpha over a golden image, say — and
the_sheet_draws_the_colours_and_the_slices_the_style_restates holds
MenuStyle::pixel_art’s to the sheet’s.
label_color: [f32; 4]An item label’s colour. See MenuStyle::title_color.
hint_color: [f32; 4]A key hint’s colour — dimmer than the label it belongs to — and a
CaptionTone::Hint caption’s. See MenuStyle::title_color.
warning_color: [f32; 4]A CaptionTone::Warning caption’s colour: the console’s amber for a
warning, so a line that warns reads as one. See
MenuStyle::title_color.
track_color: [f32; 4]A slider groove’s colour, behind the part not filled in. See
MenuStyle::title_color.
fill_color: [f32; 4]The colour of the groove up to the handle. See
MenuStyle::title_color.
handle_color: [f32; 4]The handle’s colour. See MenuStyle::title_color.
scrim_color: [f32; 4]What the frame behind the menu is dimmed with. See
MenuStyle::title_color.
Implementations§
Source§impl MenuStyle
impl MenuStyle
Sourcepub const MAX_SCALE: u32 = 4
pub const MAX_SCALE: u32 = 4
The largest scale Menu::layout will choose.
Four rather than unbounded: past it the title’s glyphs are taller than a brick and the menu stops reading as part of the game.
Sourcepub const MIN_FONT_SIZE: f32 = 8.0
pub const MIN_FONT_SIZE: f32 = 8.0
The smallest item font size Menu::layout_with_font_fitted shrinks
to, in pixels per em.
Eight: a typical face’s x-height is about half an em, so this leaves
lowercase four pixels tall — the fewest the hinter can snap e, c
and o apart in. A window that needs smaller text gets a scrolled
list, or a MenuFitError, rather than a menu nobody can read.
Sourcepub fn pixel_art(scale: u32) -> MenuStyle
pub fn pixel_art(scale: u32) -> MenuStyle
The shipped look, at scale device pixels per texel.
scale is clamped to at least one — a menu drawn at zero is not a
smaller menu, it is an invisible one.
Sourcepub fn panel_corners(&self) -> SkinInsets
pub fn panel_corners(&self) -> SkinInsets
The panel’s fixed corners, in device pixels.
MenuStyle::panel itself: pixel_art pre-multiplies the texel
source figure PANEL_INSETS by the scale, so the layout reads the
pixel corners through this accessor the same way it always has.
A button’s fixed corners, in device pixels.
MenuStyle::button itself — see panel_corners.