#[repr(C)]pub struct Titlebar {
pub title: AzString,
pub height: f32,
pub font_size: f32,
pub padding_left: f32,
pub padding_right: f32,
pub title_color: ColorU,
}Expand description
A titlebar widget with optional close / minimize / maximize buttons, drag-to-move, and double-click-to-maximize.
§Two modes
-
Title-only (
Titlebar::dom, the default forWindowDecorations::NoTitleAutoInject): The OS still draws the native window-control buttons (traffic lights on macOS, caption buttons on Windows). The titlebar reservespadding_left/padding_rightso the title text doesn’t overlap them. -
Full CSD (
Titlebar::dom_with_buttons, used whenWindowDecorations::None+has_decorations): The titlebar renders its own close / minimize / maximize buttons as regular DOM nodes. Each button carries a plainMouseDowncallback that callsCallbackInfo::modify_window_state()— exactly the same mechanism used for window dragging. No special event-system hooks.
Window-control buttons use Dom::create_icon("close") etc. so that
icons are resolved through the icon provider system (Material Icons
by default) and can be swapped out by registering a different icon pack.
§Button layout
button_side controls where the buttons appear:
Left— macOS traffic-light style (buttons before title)Right— Windows / Linux style (title then buttons)
§Styling
The DOM uses CSS classes .csd-titlebar, .csd-title, .csd-buttons,
.csd-button, .csd-close, .csd-minimize, .csd-maximize.
These match the output of SystemStyle::create_csd_stylesheet().
Fields§
§title: AzStringThe title text to display.
height: f32Height of the titlebar in CSS pixels.
font_size: f32Font size for the title text in CSS pixels.
padding_left: f32Extra padding on the left side (px).
padding_right: f32Extra padding on the right side (px).
title_color: ColorUTitle text color (resolved from SystemStyle.colors.text or platform default).
Implementations§
Source§impl Titlebar
impl Titlebar
Sourcepub fn new(title: AzString) -> Self
pub fn new(title: AzString) -> Self
Create a titlebar with compile-time platform defaults.
Use Titlebar::from_system_style when you have a
SystemStyle available for pixel-perfect metrics.
Sourcepub fn create(title: AzString) -> Self
pub fn create(title: AzString) -> Self
FFI-compatible alias for Titlebar::new.
Sourcepub fn with_height(title: AzString, height: f32) -> Self
pub fn with_height(title: AzString, height: f32) -> Self
Create a titlebar with a custom height.
Sourcepub fn set_height(&mut self, height: f32)
pub fn set_height(&mut self, height: f32)
Set the titlebar height.
Sourcepub fn swap_with_default(&mut self) -> Self
pub fn swap_with_default(&mut self) -> Self
Swap this titlebar with a default instance, returning the old value.
Sourcepub fn from_system_style(title: AzString, system_style: &SystemStyle) -> Self
pub fn from_system_style(title: AzString, system_style: &SystemStyle) -> Self
Create from a live SystemStyle (for title-only mode, padding
reserves space for OS-drawn buttons).
Sourcepub fn from_system_style_csd(
title: AzString,
system_style: &SystemStyle,
) -> Self
pub fn from_system_style_csd( title: AzString, system_style: &SystemStyle, ) -> Self
Create from SystemStyle for full CSD mode (no padding — the
buttons are rendered as DOM children).
Sourcepub fn dom(self) -> Dom
pub fn dom(self) -> Dom
Title-only DOM (for NoTitleAutoInject).
The OS draws the native window-control buttons; this just renders a centred title with drag support.
Full-CSD DOM with close / minimize / maximize buttons.
Each button is a div with a MouseDown callback that calls
modify_window_state() — no special hooks needed.
Trait Implementations§
Source§impl PartialOrd for Titlebar
impl PartialOrd for Titlebar
impl StructuralPartialEq for Titlebar
Auto Trait Implementations§
impl Freeze for Titlebar
impl RefUnwindSafe for Titlebar
impl Send for Titlebar
impl Sync for Titlebar
impl Unpin for Titlebar
impl UnsafeUnpin for Titlebar
impl UnwindSafe for Titlebar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more