mitsuami-headless 2.5.2

In-memory mitsuami backend with deterministic measurement, for tests
Documentation
//! Fixed metrics, and the sizes of the platform's own chrome.

use mitsuami_core::backend::{FontSizes, PlatformMetrics};
use mitsuami_core::units::SpacingScale;
use mitsuami_core::{Insets, Size};

/// A window's toolbar: this high, above its content, with its items this
/// far apart and from its trailing edge.
pub(super) const TOOLBAR_HEIGHT: f32 = 40.0;
pub(super) const TOOLBAR_SPACING: f32 = 8.0;

/// A popover shows this far under its parent.
pub(super) const POPOVER_GAP: f32 = 6.0;

/// A window's sidebar: this wide, on the leading side of its content, as
/// high as it.
pub(super) const SIDEBAR_WIDTH: f32 = 200.0;

/// A tab view: its pages this far in from its edges, below its tab strip,
/// and each tab this much wider than its title.
pub(super) const TAB_INSETS: Insets = Insets::new(32.0, 8.0, 8.0, 8.0);
pub(super) const TAB_PADDING: f32 = 24.0;
/// Document tabs: a strip this high, each tab this much wider than its
/// title, with a close button this wide where tabs close, and a new-tab
/// button this wide after them.
pub(super) const DOCUMENT_TAB_HEIGHT: f32 = 32.0;
pub(super) const DOCUMENT_TAB_BUTTON: f32 = 24.0;
/// A group's border and margins, and room for a heading at the top.
pub(super) const GROUP_INSETS: Insets = Insets::new(8.0, 8.0, 8.0, 8.0);
pub(super) const TITLED_GROUP_INSETS: Insets = Insets::new(32.0, 8.0, 8.0, 8.0);
/// A table: its header this high above its rows, its rows at least this
/// high, its columns this far apart and this wide unless the app says.
pub(super) const TABLE_HEADER_HEIGHT: f32 = 24.0;
pub(super) const TABLE_ROW_HEIGHT: f32 = 24.0;
pub(super) const COLUMN_SPACING: f32 = 4.0;
pub(super) const COLUMN_WIDTH: f32 = 100.0;
/// A tree's rows' content: after a disclosure this wide, and in this much
/// more each level.
pub(super) const TREE_INDENT: mitsuami_core::TreeIndent = mitsuami_core::TreeIndent { start: 16.0, per_level: 16.0 };
/// Between a radio group's buttons.
pub(super) const RADIO_GAP: f32 = 6.0;

/// The screen a window in full screen fills.
pub(super) const SCREEN: Size = Size::new(1280.0, 800.0);
/// What a maximized window's content fills: the screen less a bar and the
/// window's title bar.
/// A text area's text, as its measure has it.
pub(super) const TEXT_AREA_INSETS: Insets = Insets::new(4.0, 4.0, 4.0, 4.0);
/// A split's divider: a line, as AppKit's and GTK's thin ones.
pub(super) const SPLIT_DIVIDER: f32 = 1.0;

pub(super) const WORK_AREA: Size = Size::new(1280.0, 740.0);
/// The screen's bar, above the work area.
pub(super) const BAR: f32 = 24.0;
/// A window's title bar, above its content.
pub(super) const TITLE_BAR: f32 = 36.0;
/// Where the platform puts a new window that isn't placed: the work
/// area's top left, a little in.
pub(super) const NEW_WINDOW_AT: mitsuami_core::Point = mitsuami_core::Point::new(60.0, 84.0);

/// Fixed metrics: 16px body text, 4/8/12/16/24 spacing, scale factor 1.
pub fn metrics() -> PlatformMetrics {
    PlatformMetrics {
        scale_factor: 1.0,
        spacing: SpacingScale { xs: 4.0, sm: 8.0, md: 12.0, lg: 16.0, xl: 24.0, indent: 16.0 },
        font_sizes: FontSizes {
            large_title: 32.0,
            title: 24.0,
            headline: 18.0,
            body: 16.0,
            callout: 15.0,
            caption: 12.0,
            monospace: 14.0,
        },
        dark_mode: false,
        high_contrast: false,
        reduced_motion: false,
        tab_insets: TAB_INSETS,
        group_insets: GROUP_INSETS,
        titled_group_insets: TITLED_GROUP_INSETS,
        split_divider: SPLIT_DIVIDER,
        text_area_insets: TEXT_AREA_INSETS,
    }
}