TopLevel
struct · ferroui-controls · v0.5.0
struct TopLevel
Base class for top-level widgets.
This class acts as a base for top level widget. It handles scheduling
layout, styling and rendering as well as tracking the widget's
client_size.
Members
TYPEto_refhandle_closedhandle_resizedon_openedon_closedopened_popupsTEMPLATE_PARTSenable_visual_layer_manager_layersclient_size_propertyframe_size_propertytransparency_level_hint_propertyactual_transparency_level_propertytransparency_background_fallback_propertysystem_backdrop_propertyactual_theme_variant_propertyrequested_theme_variant_propertysystem_bar_color_propertyauto_safe_area_padding_propertyback_requested_eventopenedclosedscaling_changedplatform_lost_focusplatform_deactivatedplatform_position_changedclient_sizeset_client_sizeframe_sizeset_frame_sizetransparency_level_hintset_transparency_level_hintactual_transparency_leveltransparency_background_fallbackset_transparency_background_fallbackrequested_theme_variantset_requested_theme_variantback_requestedlayout_managertry_get_platform_handlecreate_platform_impl_bindinginput_roothit_tester_overrideset_hit_tester_overriderenderer_diagnosticslast_pointer_positionaccess_key_handlertests_keyboard_navigation_handlerset_system_bar_colorget_system_bar_colorset_auto_safe_area_paddingget_auto_safe_area_paddingrender_scalingstorage_providerinsets_managerinput_panelauncherscreensclipboardtry_get_clipboardfocus_managerget_top_levelrequest_platform_inhibitionrequest_animation_framestart_renderingstop_renderingmedia_context_keyensure_closedsystem_backdropset_system_backdropsystem_backdrop_targetadd_opened_popupremove_opened_popupas_closeable
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<TopLevel>
Returns a strong reference to this object.
handle_closed
fn handle_closed(self: &Self)
Handles a closed notification from the platform implementation.
handle_resized
fn handle_resized(self: &Self, client_size: Size, reason: WindowResizeReason)
Handles a resize notification from the platform implementation:
client_size is the new client size and reason the reason for
the resize.
on_opened
fn on_opened(self: &Self)
Raises the Opened event.
on_closed
fn on_closed(self: &Self)
Raises the Closed event.
opened_popups
fn opened_popups(self: &Self) -> Vec<Ref<crate::primitives::Popup>>
The popups that are currently open directly in this top level, in the order they were opened.
TEMPLATE_PARTS
const TEMPLATE_PARTS: &'static [TemplatePartAttribute]
The named parts expected in the control template.
enable_visual_layer_manager_layers
fn enable_visual_layer_manager_layers(self: &Self)
Enables the overlay, popup overlay and text selector layers of the layer manager of the control template (private protected upstream: for the top-levels that host their popups and overlays themselves).
client_size_property
fn client_size_property() -> &'static DirectProperty<TopLevel, Size>
Defines the ClientSize property.
frame_size_property
fn frame_size_property() -> &'static DirectProperty<TopLevel, Option<Size>>
Defines the FrameSize property.
transparency_level_hint_property
fn transparency_level_hint_property() -> &'static StyledProperty<WindowTransparencyLevelCollection>
Defines the TransparencyLevelHint property.
actual_transparency_level_property
fn actual_transparency_level_property() -> &'static DirectProperty<TopLevel, WindowTransparencyLevel>
Defines the ActualTransparencyLevel property.
transparency_background_fallback_property
fn transparency_background_fallback_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
Defines the TransparencyBackgroundFallback property.
system_backdrop_property
fn system_backdrop_property() -> &'static StyledProperty<Option<Ref<crate::media::SystemBackdrop>>>
Defines the SystemBackdrop property (WinUI Window.SystemBackdrop,
Popup.SystemBackdrop; winui-materials.md): the system backdrop
drawn behind the content of the top level.
actual_theme_variant_property
fn actual_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
Defines the ActualThemeVariant property.
requested_theme_variant_property
fn requested_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
Defines the RequestedThemeVariant property.
system_bar_color_property
fn system_bar_color_property() -> &'static AttachedProperty<Option<Ref<SolidColorBrush>>>
Defines the SystemBarColor attached property.
auto_safe_area_padding_property
fn auto_safe_area_padding_property() -> &'static AttachedProperty<bool>
Defines the AutoSafeAreaPadding attached property.
back_requested_event
fn back_requested_event() -> &'static RoutedEvent<RoutedEventArgs>
Defines the BackRequested event.
opened
fn opened(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
Fired when the window is opened.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the top-level.
closed
fn closed(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
Fired when the window is closed.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the top-level.
scaling_changed
fn scaling_changed(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
Fired when the top-level's scaling changes.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the top-level.
platform_lost_focus
fn platform_lost_focus(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
Adds a handler to the lost-focus notification of the platform
implementation (C# PlatformImpl.LostFocus += handler); it runs after
the top-level's own handling.
The callbacks of a platform implementation hold a single function, so handlers that come and go (an open popup watching its parent) are kept in a list of the top-level instead of being chained onto the callback, where a removed handler would stay behind.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the top-level.
platform_deactivated
fn platform_deactivated(self: &Self, handler: impl Fn() -> () + 'static) -> Subscription
Adds a handler to the deactivated notification of a window platform
implementation (C# impl.Deactivated += handler); see
platform_lost_focus.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the top-level.
platform_position_changed
fn platform_position_changed(self: &Self, handler: impl Fn(PixelPoint) -> () + 'static) -> Subscription
Adds a handler to the position-changed notification of a window
platform implementation (C# impl.PositionChanged += handler); see
platform_lost_focus.
Dropping the returned guard removes the handler;
Subscription::detach keeps it for the life of the top-level.
client_size
fn client_size(self: &Self) -> Size
The client size of the window.
set_client_size
fn set_client_size(self: &Self, value: Size)
Sets the client size of the window (protected upstream: for derived classes).
frame_size
fn frame_size(self: &Self) -> Option<Size>
The total size of the window.
set_frame_size
fn set_frame_size(self: &Self, value: Option<Size>)
Sets the total size of the window (protected upstream: for derived classes).
transparency_level_hint
fn transparency_level_hint(self: &Self) -> WindowTransparencyLevelCollection
The transparency levels that the top-level should use when possible. Accepts multiple values which are applied in a fallback order. For instance, with "Mica, Blur" Mica will be applied only on platforms where it is possible, and Blur will be used on the rest of them. Default value is an empty collection or "None".
set_transparency_level_hint
fn set_transparency_level_hint(self: &Self, value: WindowTransparencyLevelCollection)
actual_transparency_level
fn actual_transparency_level(self: &Self) -> WindowTransparencyLevel
The achieved transparency level that the platform was able to provide.
transparency_background_fallback
fn transparency_background_fallback(self: &Self) -> Option<Rc<dyn IBrush>>
The brush that transparency will blend with when transparency is not supported. By default this is a solid white brush.
set_transparency_background_fallback
fn set_transparency_background_fallback(self: &Self, value: Option<Rc<dyn IBrush>>)
requested_theme_variant
fn requested_theme_variant(self: &Self) -> Option<ThemeVariant>
The theme variant requested for the top-level and its descendants.
set_requested_theme_variant
fn set_requested_theme_variant(self: &Self, value: Option<ThemeVariant>)
back_requested
fn back_requested(self: &Self, handler: impl Fn(&Interactive, &RoutedEventArgs) -> () + 'static) -> RoutedEventHandlerToken
Occurs when physical Back Button is pressed or a back navigation has been requested.
layout_manager
fn layout_manager(self: &Self) -> Rc<LayoutManager>
The layout manager of the top-level.
try_get_platform_handle
fn try_get_platform_handle(self: &Self) -> Option<Rc<dyn IPlatformHandle>>
Tries to get the platform handle for the top-level-derived control.
Returns the handle describing the window, or None if the handle
could not be retrieved.
create_platform_impl_binding
fn create_platform_impl_binding<T: ferroui_base::PropertyValue>(self: &Self, property: &'static StyledProperty<T>, on_value: impl Fn(T) -> () + 'static)
Calls on_value with the value of property now and whenever the
property changes, for as long as the top-level has a platform
implementation (private protected upstream: for derived classes).
input_root
fn input_root(self: &Self) -> Rc<dyn IInputRoot>
The input root of the top-level.
hit_tester_override
fn hit_tester_override(self: &Self) -> Option<Rc<dyn IHitTester>>
The hit tester used instead of the renderer's. This is here purely for unit tests that don't want to set up a proper hit-testable visual tree.
set_hit_tester_override
fn set_hit_tester_override(self: &Self, value: Option<Rc<dyn IHitTester>>)
renderer_diagnostics
fn renderer_diagnostics(self: &Self) -> Rc<RendererDiagnostics>
A value controlling whether the renderer should draw specific diagnostics.
last_pointer_position
fn last_pointer_position(self: &Self) -> Option<PixelPoint>
The last known position of the pointer, in screen coordinates.
access_key_handler
fn access_key_handler(self: &Self) -> Option<Rc<dyn IAccessKeyHandler>>
The access key handler for the window.
tests_keyboard_navigation_handler
fn tests_keyboard_navigation_handler(self: &Self) -> Option<Rc<dyn IKeyboardNavigationHandler>>
The keyboard navigation handler of the window (for unit tests).
set_system_bar_color
fn set_system_bar_color(control: &Control, color: Option<Ref<SolidColorBrush>>)
Helper for setting the color of the platform's system bars.
control is the main view attached to the top-level, or the
top-level.
get_system_bar_color
fn get_system_bar_color(control: &Control) -> Option<Ref<SolidColorBrush>>
Helper for getting the color of the platform's system bars.
control is the main view attached to the top-level, or the
top-level.
set_auto_safe_area_padding
fn set_auto_safe_area_padding(control: &Control, value: bool)
Enables or disables whenever the top-level should automatically
adjust paddings depending on the safe area. control is the main
view attached to the top-level, or the top-level.
get_auto_safe_area_padding
fn get_auto_safe_area_padding(control: &Control) -> bool
Gets if auto safe area padding is enabled. control is the main
view attached to the top-level, or the top-level.
render_scaling
fn render_scaling(self: &Self) -> f64
The scaling factor to use in rendering.
storage_provider
fn storage_provider(self: &Self) -> Rc<dyn ferroui_base::platform::storage::IStorageProvider>
File System storage service used for file pickers and bookmarks: the provider of the registered storage provider factory, else the one of the platform, else one without pickers. The provider is created on first use and kept.
insets_manager
fn insets_manager(self: &Self) -> Option<Rc<dyn IInsetsManager>>
The insets manager of the platform, if it has one.
input_pane
fn input_pane(self: &Self) -> Option<Rc<dyn IInputPane>>
The input pane of the platform, if it has one.
launcher
fn launcher(self: &Self) -> Rc<dyn ferroui_base::platform::storage::ILauncher>
The launcher of the platform: starts the default app associated with a file or a URI. A launcher that launches nothing when the platform has none.
screens
fn screens(self: &Self) -> Option<Rc<Screens>>
The platform screens implementation.
clipboard
fn clipboard(self: &Self) -> Option<Rc<dyn IClipboard>>
The platform's clipboard implementation.
try_get_clipboard
fn try_get_clipboard(self: &Self, type_: ClipboardType) -> Option<Rc<dyn IClipboard>>
Gets the platform's clipboard of the specified type, or None if
the platform doesn't provide it.
focus_manager
fn focus_manager(self: &Self) -> Rc<FocusManager>
The focus manager of the root.
get_top_level
fn get_top_level(visual: Option<&Visual>) -> Option<Ref<TopLevel>>
Gets the top-level in which the given visual is hosted.
request_platform_inhibition
fn request_platform_inhibition(self: &Self, type_: PlatformInhibitionType, reason: &str) -> JoinHandle<Rc<dyn IDisposable>>
Requests a PlatformInhibitionType to be inhibited. The behavior
remains inhibited until the returned value is disposed. The
available set of PlatformInhibitionTypes depends on the platform.
If a behavior is inhibited on a platform where this type is not
supported the request will have no effect.
Like the asynchronous method of the reference, the request is sent to the platform before this returns; the returned handle ends, in a dispatcher job unless the platform completed at once, when the platform has applied it. Disposing the result starts the request that lifts the inhibition and returns without waiting for the platform to complete it.
request_animation_frame
fn request_animation_frame(self: &Self, action: impl FnOnce(ferroui_base::animation::SignedDuration) -> () + 'static)
Enqueues a callback to be called on the next animation tick.
start_rendering
fn start_rendering(self: &Self)
Registers the top-level with the media context, which starts its renderer (private protected upstream: for derived classes).
stop_rendering
fn stop_rendering(self: &Self)
Unregisters the top-level from the media context, which stops its renderer (private protected upstream: for derived classes).
media_context_key
fn media_context_key(self: &Self) -> usize
The key that identifies the top-level in the media context.
ensure_closed
fn ensure_closed(self: &Self)
Runs the top level teardown exactly once, no matter whether it was initiated by the platform via the closed notification or by a managed dispose (private protected upstream: for derived classes).
system_backdrop
fn system_backdrop(self: &Self) -> Option<Ref<crate::media::SystemBackdrop>>
SystemBackdrop.
set_system_backdrop
fn set_system_backdrop(self: &Self, value: Option<Ref<crate::media::SystemBackdrop>>)
system_backdrop_target
fn system_backdrop_target(self: &Self) -> Rc<crate::media::TopLevelBackdropTarget>
The top level as the target of system backdrops.
add_opened_popup
fn add_opened_popup(self: &Self, popup: &Ref<crate::primitives::Popup>)
Records a popup opened directly in this top level (internal upstream).
remove_opened_popup
fn remove_opened_popup(self: &Self, popup: &Ref<crate::primitives::Popup>)
Forgets a popup opened directly in this top level (internal upstream).
as_closeable
fn as_closeable(self: &Self) -> Rc<dyn ferroui_base::input::ICloseable>
The top-level as something that tells when it has been closed.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeTemplatedControlImplExtContentControlImplExtControlImplExtTopLevelImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<TopLevel>StaticTypeObjectTypeSubclassable<T>LayoutableImplInteractiveImplInputElementImplControlImplContentControlImplFerroObjectImplStyledElementImplVisualImplTemplatedControlImplTopLevelImplDrop
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.