TitleBar
struct · ferroui-controls · v0.5.0
struct TitleBar
The title bar of a window (WinUI's TitleBar): a back button, a pane toggle button, a left
header, an icon, a title and a subtitle, content (a search box, in WinUI Gallery) and a right
header, drawn in the title bar of the window when the client area extends into it.
The control sets the states of WinUI as pseudo-classes, which the control theme of the WinUI
theme (src/FerroUI.Themes.WinUI/Controls/TitleBar.xaml) styles: :back-button-visible,
:pane-toggle-button-visible, :left-header-visible, :icon-visible,
:title-text-visible, :subtitle-text-visible, :content-visible,
:right-header-visible (the Visible states of their groups; their absence is Collapsed),
:deactivated (the Deactivated states: the window is not active), :expanded-height
(HeightGroup: content or a header), :compact (DisplayModeGroup: the content no longer fits
beside the title) and :negative-inset-spacing (LeftHeaderSpacingGroup). The template parts
are WinUI's: LeftPaddingColumn and RightPaddingColumn (borders in FerroUI, a column
definition has no name), PART_BackButton,
PART_PaneToggleButton, PART_Icon, PART_LeftHeaderPresenter, PART_ContentPresenterGrid,
PART_ContentPresenter and PART_RightHeaderPresenter. The Fluent and Simple themes have no
template for it (docs/porting/winui-controls.md, section 5.1).
The window: WinUI's AppWindow gives the insets of the caption buttons, the drag regions and
the activation. The port takes the insets from Window::caption_button_insets (the traffic
lights of macOS at the left, the caption buttons the toolkit draws at the right), marks the
title bar as the drag region of the window and its back button, pane toggle button, headers and
the interactive controls of its content as elements that take the input
(WindowDecorationProperties roles, which take effect while the client area extends into the
decorations), and follows WindowBase::is_active. A title is the title of the window while
the bar shows it, as in WinUI.
Members
TYPEto_reftitle_propertysubtitle_propertyicon_source_propertyleft_header_propertycontent_propertyright_header_propertyis_back_button_visible_propertyis_back_button_enabled_propertyis_pane_toggle_button_visible_propertyauto_refresh_drag_regions_propertytemplate_settings_propertyis_drag_region_propertyconstructnewtitleset_titlesubtitleset_subtitleicon_sourceset_icon_sourceleft_headerset_left_headercontentset_contentright_headerset_right_headeris_back_button_visibleset_is_back_button_visibleis_back_button_enabledset_is_back_button_enabledis_pane_toggle_button_visibleset_is_pane_toggle_button_visibleauto_refresh_drag_regionsset_auto_refresh_drag_regionstemplate_settingsget_is_drag_regionset_is_drag_regionrecompute_drag_regionsback_requestedpane_toggle_requestedwindow
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<TitleBar>
Returns a strong reference to this object.
title_property
fn title_property() -> &'static StyledProperty<String>
Defines the Title property: the title the bar shows, which is also the title of its
window.
subtitle_property
fn subtitle_property() -> &'static StyledProperty<String>
Defines the Subtitle property: the text beside the title.
icon_source_property
fn icon_source_property() -> &'static StyledProperty<Option<Ref<IconSource>>>
Defines the IconSource property: the icon before the title.
left_header_property
fn left_header_property() -> &'static StyledProperty<Option<Ref<Control>>>
Defines the LeftHeader property: an element after the buttons, before the icon.
content_property
fn content_property() -> &'static StyledProperty<Option<Ref<Control>>>
Defines the Content property: the element in the middle of the bar (a search box).
right_header_property
fn right_header_property() -> &'static StyledProperty<Option<Ref<Control>>>
Defines the RightHeader property: an element at the right of the bar, before the
caption buttons.
is_back_button_visible_property
fn is_back_button_visible_property() -> &'static StyledProperty<bool>
Defines the IsBackButtonVisible property (false by default).
is_back_button_enabled_property
fn is_back_button_enabled_property() -> &'static StyledProperty<bool>
Defines the IsBackButtonEnabled property (true by default).
is_pane_toggle_button_visible_property
fn is_pane_toggle_button_visible_property() -> &'static StyledProperty<bool>
Defines the IsPaneToggleButtonVisible property (false by default).
auto_refresh_drag_regions_property
fn auto_refresh_drag_regions_property() -> &'static StyledProperty<bool>
Defines the AutoRefreshDragRegions property: whether the bar finds the interactive
elements of its content again when the content changes its layout (false by default:
once, after the content is first laid out, as in WinUI).
template_settings_property
fn template_settings_property() -> &'static DirectProperty<TitleBar, Ref<TitleBarTemplateSettings>>
Defines the TemplateSettings property: the values the template binds to (read-only).
is_drag_region_property
fn is_drag_region_property() -> &'static AttachedProperty<Option<bool>>
Defines the IsDragRegion attached property of an element of the content: Some(true)
drags the window (and, on a control, its whole area), Some(false) takes the input, and
None (the default) leaves it to the bar, which makes the enabled controls take the
input.
construct
fn construct() -> Self
new
fn new() -> Ref<Self>
title
fn title(self: &Self) -> String
set_title
fn set_title(self: &Self, value: &str)
subtitle
fn subtitle(self: &Self) -> String
set_subtitle
fn set_subtitle(self: &Self, value: &str)
icon_source
fn icon_source(self: &Self) -> Option<Ref<IconSource>>
set_icon_source
fn set_icon_source(self: &Self, value: Option<Ref<IconSource>>)
left_header
fn left_header(self: &Self) -> Option<Ref<Control>>
set_left_header
fn set_left_header(self: &Self, value: Option<Ref<Control>>)
content
fn content(self: &Self) -> Option<Ref<Control>>
set_content
fn set_content(self: &Self, value: Option<Ref<Control>>)
right_header
fn right_header(self: &Self) -> Option<Ref<Control>>
set_right_header
fn set_right_header(self: &Self, value: Option<Ref<Control>>)
is_back_button_visible
fn is_back_button_visible(self: &Self) -> bool
set_is_back_button_visible
fn set_is_back_button_visible(self: &Self, value: bool)
is_back_button_enabled
fn is_back_button_enabled(self: &Self) -> bool
set_is_back_button_enabled
fn set_is_back_button_enabled(self: &Self, value: bool)
is_pane_toggle_button_visible
fn is_pane_toggle_button_visible(self: &Self) -> bool
set_is_pane_toggle_button_visible
fn set_is_pane_toggle_button_visible(self: &Self, value: bool)
auto_refresh_drag_regions
fn auto_refresh_drag_regions(self: &Self) -> bool
set_auto_refresh_drag_regions
fn set_auto_refresh_drag_regions(self: &Self, value: bool)
template_settings
fn template_settings(self: &Self) -> Ref<TitleBarTemplateSettings>
get_is_drag_region
fn get_is_drag_region(element: &Visual) -> Option<bool>
The IsDragRegion of element.
set_is_drag_region
fn set_is_drag_region(element: &Visual, value: Option<bool>)
Sets the IsDragRegion of element; the title bar it is in finds its interactive
elements again.
recompute_drag_regions
fn recompute_drag_regions(self: &Self)
Finds the interactive elements of the bar again after the application changed its
content (WinUI's RecomputeDragRegions).
back_requested
fn back_requested(self: &Self, handler: impl Fn(&TitleBar) -> () + 'static) -> Subscription
Adds a handler of BackRequested: the back button was clicked.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the title bar.
pane_toggle_requested
fn pane_toggle_requested(self: &Self, handler: impl Fn(&TitleBar) -> () + 'static) -> Subscription
Adds a handler of PaneToggleRequested: the pane toggle button was clicked.
Dropping the returned guard removes the handler; Subscription::detach
keeps it for the life of the title bar.
window
fn window(self: &Self) -> Option<Ref<Window>>
The window of the bar, while it is in one.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeTemplatedControlImplExtControlImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<TitleBar>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleStyledElementImplInteractiveImplInputElementImplFerroObjectImplVisualImplLayoutableImplControlImplTemplatedControlImpl
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.