Skip to main content

default_size

Function default_size 

Source
pub fn default_size(kind: &str) -> Size
Expand description

How big a new widget of this kind should start out.

Authoring defaults, not intrinsic sizes. This toolkit has no layout engine and nothing here has a size of its own: a button is whatever rectangle the form gives it. These are the rectangles that make a dropped widget look like what it is, so that somebody can see what they placed before they resize it — which is a question about writing forms, and so this crate’s, rather than a question about widgets.

// A button is wider than it is tall; an avatar is square.
let button = default_size("button");
assert!(button.width > button.height);
let avatar = default_size("avatar");
assert_eq!(avatar.width, avatar.height);
// A kind nobody has heard of still gets something you can see and click.
assert!(default_size("banana").width > 0);