ui/ribbon.rs#
Source: lib/ui/ribbon.rs
Ribbon groups and typography tiles. Additive native UI component by office_ribbon;
no legacy counterpart. Uses normal focus, semantics, popups and style tokens.
struct RibbonSampleExplicit typography for a document sample, independent of the application's theme. Sizes and baseline displacement are 24.8 DIP; positive displacement moves downwards.font: u32size: i32color: u32highlight: Option<u32>baseline_shift: i32underline: boolstrike: bool
struct RibbonMetricsStyle-owned ribbon geometry in DIP. A scrolling ribbon keeps every group's original arrangement; a collapsing ribbon can use the compact/flyout layouts.content_height: i32caption_height: i32group_gap: i32content_gap: i32inset_x: i32-- Zero uses the style's existing uniformribbon_padding.inset_y: i32collapse_groups: bool
struct RibbonGroup<'a>One ribbon group. Reserveid..=id + 3for its box, overflow and popup.id: u32-- Stable base ID, unique across the window.label: &'a str-- Visible group caption and accessible overflow name.width: i32-- Preferred group width in DIP.compact_width: i32-- Smallest width that still displays all controls, in DIP.
impl<'a> RibbonGroup<'a>
const fn new(id: u32, label: &'a str, width: i32, compact_width: i32) -> SelfConstruct a group with a preferred and compact content width.enum RibbonGroupModePresentation of an open ribbon group; pass it toribbon_group_end.Inline(i32)-- Preferred or compact inline width in DIP.Flyout(i32)-- Group shown in a popup at its preferred width in DIP.
impl RibbonGroupMode
fn width(self) -> i32Actual width available to the controls, in DIP.struct RibbonLayoutPer-frame ribbon layout: shrink groups before moving them into labeled flyouts.
impl RibbonLayout
fn new(available_width: i32, groups: &[RibbonGroup<'_>]) -> SelfCompute group presentation for an available inner width in DIP. Groups collapse from right to left; extremely narrow windows can scroll.fn with_metrics( available_width: i32, groups: &[RibbonGroup<'_>], metrics: RibbonMetrics, ) -> SelfCompute a layout using the active style's sizing and overflow policy.fn is_collapsed(&self, index: usize) -> boolWhether a group is reachable through its labeled overflow button.fn group_width(&self, index: usize) -> Option<i32>Width occupied by a group in the ribbon, in DIP.
impl Ui
fn ribbon_begin(&mut self, id: u32, groups: &[RibbonGroup<'_>]) -> RibbonLayoutStart a style-sized ribbon (110 DIP by default). Pair withribbon_end. All groups remain keyboard reachable; a scroll strip is the final fallback.fn ribbon_group_begin( &mut self, layout: &RibbonLayout, index: usize, group: &RibbonGroup<'_>, ) -> Option<RibbonGroupMode>Begin a group's controls when visible, or render its overflow button. Only callribbon_group_endwhen this returnsSome.fn ribbon_group_end(&mut self, mode: RibbonGroupMode, label: &str)Finish controls and draw the inline group caption; closes overflow when appropriate. Flyouts already have their named opener, so no trailing caption is painted over a nested action menu emitted while building their controls.fn ribbon_group_end_launcher( &mut self, mode: RibbonGroupMode, label: &str, id: u32, action_label: &str, flags: u32, ) -> u32Finish a group with a separately focusable dialog-launch button in its caption.idis an additional unique widget ID;action_labelis its full semantic name. Activation is returned to the app, which opens its existing dialog. Disabled launchers retain their label and cannot be invoked through keyboard or agents.fn ribbon_end(&mut self)Finish the ribbon begun withribbon_begin.fn ribbon_gallery_begin(&mut self, id: u32)Begin an inset horizontal gallery on an input-colored surface. The caller supplies its size and tiles; finish withbox_end. The whole frame is painted before applying the three-DIP tile inset, including in dark themes.fn ribbon_tile( &mut self, id: u32, label: &str, preview: &str, typography: u32, selected: bool, ) -> u32Typography preview tile for a style gallery; selection is exposed semantically.typographyis aTS_*style; usenext_sizeto set a compact gallery width.fn ribbon_font_tile(&mut self, id: u32, label: &str, preview: &str, typography: u32, selected: bool, face: Option<(u32, i32, u32)>) -> u32A gallery tile with an optional document font, 24.8-DIP size and ARGB ink. The surrounding control follows the application theme; the sample stays document-colored.fn ribbon_sample_tile(&mut self, id: u32, label: &str, preview: &str, typography: u32, selected: bool, sample: Option<RibbonSample>) -> u32Style-gallery tile with explicit highlight, baseline and text decorations.