Skip to content
  1. Docs
  2. enzUI framework
  3. Developers

App shell and titlebars

How enz_app_shell frames a window, the titlebar pattern every app follows, shell tokens, and the reference apps.

enz_app_shell is the window frame of an enzUI application: titlebar, sidebar, content, window controls, resize edges and the adaptive drawer, in one composition with one owner for collapse rules and window chrome. The wiring basics (slots, NavSplitState, WindowCommand) are on Building an app. This page covers the titlebar pattern, the shell's surface tokens and the reference apps.

See every widget in the widget catalog.

Layouts

ShellLayoutShape
TitlebarContent (default)One titlebar above the content
TitlebarSidebarContentA sidebar beside the content; by default its header sits inside the full-height sidebar
ContentOnlyContent without shell titlebar or sidebar chrome
FloatingSidebarThe sidebar floats over the content instead of reserving width beside it
FloatingTitlebarThe content fills the window and the titlebar floats over it
FloatingTitlebarSidebarA full-height sidebar beside the content, with a titlebar floating over the content

A layout mounts only the slots it supports. For window settings that match the layout, start from enz_window_settings(layout); enz_window_settings_with_frame(.., ShellFrame::Desktop) or the ENZUI_SSD=1 environment variable asks for the desktop's own decorations instead.

The shell draws its own titlebar, window controls and resize edges and asks the desktop for no decorations. If a compositor decorates the window anyway (sway does for tiled windows), the shell drops its own controls and edges, so the window never shows two sets. Tiled edges get square corners and no resize edge.

The titlebar pattern

Every enzUI app builds its titlebar the same way, so the band looks and behaves the same everywhere:

  • The shell owns the band. Height, side padding and window controls come from the shell. .on_window_gesture(..) gives the window its controls; a titlebar inside the shell draws none of its own. The height is title_bar::DEFAULT_TITLEBAR_HEIGHT (44 px).
  • enz_title_bar() fills it. .leading(..) holds a back button or another control before the title; .title(..) and .subtitle(..) sit at the leading edge; .center(..) is centred on the whole band (a search field or view switcher); .actions(..) holds the commands.
  • Commands go in .actions(..). ActionItem::icon(id, icon, label, message) is the usual command: an icon button named and tooltipped with label, which becomes a labelled row once it folds into the ⋯ menu.
  • Icon buttons name their action once. enz_toolbar_icon(..).label(..) sets the accessible name and the tooltip together.

When the window narrows, the commands fold first, then the centre shrinks, then the title shortens. Window controls never fold and .leading(..) controls never shrink, so every command stays reachable at phone width. Which of minimize and maximize show follows the desktop's button layout (or the theme file's [window] buttons key); Close always shows.

In a right-to-left locale the titlebar mirrors: window controls move to the left, close outermost.

Action priorities and overflow

rust
use enzui_core::{Action, action_overflow::{Descriptor, VisibilityPriority}};
use enzui_widgets::action_bar::ActionItem;
use enzui_widgets::title_bar::enz_title_bar;

enz_title_bar()
    .actions(
        vec![
            ActionItem::command(
                Descriptor::new("file.save").with_priority(VisibilityPriority(100)),
                Action::new("file.save", Message::Save).with_label("Save"),
            ),
            ActionItem::command(
                Descriptor::new("edit.find").with_priority(VisibilityPriority(50)),
                Action::new("edit.find", Message::Find).with_label("Find"),
            ),
            ActionItem::command(
                Descriptor::new("app.settings").pinned(),
                Action::new("app.settings", Message::Settings).with_label("Settings"),
            ),
            ActionItem::command(
                Descriptor::new("help.about").always_overflow(),
                Action::new("help.about", Message::About).with_label("About"),
            ),
        ],
        Message::ToggleOverflowMenu,
    )
    .action_menu_id_prefix("documents-titlebar-overflow")
    .overflow_open(model.overflow_menu_open)

pinned() keeps an action inline, always_overflow() keeps it in the menu, and VisibilityPriority chooses which foldable commands stay inline first. Authored order is kept within the inline group and the menu. Keep the pinned set small enough for the narrowest supported frame. The overflow trigger is named "More actions" and is translated with the rest of the framework strings. enz_titlebar_actions is the same engine outside a titlebar band.

Floating chrome over media

Over photos or video, use ShellLayout::FloatingTitlebar or FloatingTitlebarSidebar, add .titlebar_scrim(true) so the title stays legible over any picture, and hide the chrome while the pointer rests with .chrome_visible(..), driven by enz_activity_pulse(..).on_idle(..). The titlebar fades out and back. ShellTokens::edge_inset(0.0) runs the picture to the window's edges.

The sidebar's top strip

.sidebar_titlebar(|| ..) takes chrome for the sidebar's header, such as a second enz_title_bar(), a titlebar icon group, a search field or an account switcher. In TitlebarSidebarContent, SidebarHeader::SpanningBand uses a window-wide band and ignores the sidebar-side slot.

Holding an app to the pattern

enzui_test_support::titlebar_adoption::assert_titlebar_adoption scans an app's sources and reports a hand-set titlebar height or padding, .show_close(false), an icon button labelled twice, and commands pushed into the bar instead of .actions(..). A deliberate exception is listed with its reason.

rust
#[test]
fn the_titlebar_follows_the_framework() {
    let src = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
    enzui_test_support::titlebar_adoption::assert_titlebar_adoption(&src, &[]);
}

Shell tokens and pane styles

ShellTokens sets the shell's surface language. Each pane has a PaneStyle: raised (surface fill), recessed (alternate surface), outlined (fill and border), blended (no fill or border) or floating (elevated chrome). By default content, secondary_content, titlebar, subtitlebar and footer are blended, and sidebar is recessed.

Use the named arrangements instead of zeroing fields one by one:

ArrangementBehaviour
ShellTokens::default()Blended content with layout-resolved geometry and seams
ShellTokens::floating_cards()Raised primary and secondary content as inset cards with gaps
ShellTokens::inset_panes()Default pane styles, inset; unset insets and gutters follow gap
ShellTokens::flat_page() / flush_page()Flush, square, blended content; titlebar-to-content gutters close

Panes can also take a material or grain: PaneStyle::material(style) puts a pane on glass, .behind_window() shows the desktop through it, and PaneStyle::default().grain(..) adds paper grain. See Materials.

Reference apps

Run the notes example to try the shell in Alpha 0.3:

sh
cargo run --locked --example app

It uses TitlebarSidebarContent with an editor and a sidebar that becomes an overlay in a narrow window. See Your first app.

Several windows

A multi-window app can use a WindowLedger (from enzui_widgets::window_lifecycle) to decide when to exit. For example, closing a secondary window leaves the others open, closing the main window closes the rest. Give every window its settings through the same DesktopApplicationIdentity (window_settings, secondary_window_settings, content_window_settings) so the compositor groups them under one app; see Packaging.

When to use the split view instead

enz_navigation_split_view is the standalone sidebar/content split. Use it only for an embedded region, a secondary window whose host draws the chrome, or a test harness. For a full application frame, use enz_app_shell.