FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    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.

    View source

    Members

    TYPE

    const TYPE: &'static $crate::TypeInfo
    

    The runtime type of this class.

    Source

    to_ref

    fn to_ref(self: &Self) -> $crate::Ref<TopLevel>
    

    Returns a strong reference to this object.

    Source

    handle_closed

    fn handle_closed(self: &Self)
    

    Handles a closed notification from the platform implementation.

    Source

    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.

    Source

    on_opened

    fn on_opened(self: &Self)
    

    Raises the Opened event.

    Source

    on_closed

    fn on_closed(self: &Self)
    

    Raises the Closed event.

    Source

    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.

    Source

    TEMPLATE_PARTS

    const TEMPLATE_PARTS: &'static [TemplatePartAttribute]
    

    The named parts expected in the control template.

    Source

    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).

    Source

    client_size_property

    fn client_size_property() -> &'static DirectProperty<TopLevel, Size>
    

    Defines the ClientSize property.

    Source

    frame_size_property

    fn frame_size_property() -> &'static DirectProperty<TopLevel, Option<Size>>
    

    Defines the FrameSize property.

    Source

    transparency_level_hint_property

    fn transparency_level_hint_property() -> &'static StyledProperty<WindowTransparencyLevelCollection>
    

    Defines the TransparencyLevelHint property.

    Source

    actual_transparency_level_property

    fn actual_transparency_level_property() -> &'static DirectProperty<TopLevel, WindowTransparencyLevel>
    

    Defines the ActualTransparencyLevel property.

    Source

    transparency_background_fallback_property

    fn transparency_background_fallback_property() -> &'static StyledProperty<Option<Rc<dyn IBrush>>>
    

    Defines the TransparencyBackgroundFallback property.

    Source

    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.

    Source

    actual_theme_variant_property

    fn actual_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
    

    Defines the ActualThemeVariant property.

    Source

    requested_theme_variant_property

    fn requested_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
    

    Defines the RequestedThemeVariant property.

    Source

    system_bar_color_property

    fn system_bar_color_property() -> &'static AttachedProperty<Option<Ref<SolidColorBrush>>>
    

    Defines the SystemBarColor attached property.

    Source

    auto_safe_area_padding_property

    fn auto_safe_area_padding_property() -> &'static AttachedProperty<bool>
    

    Defines the AutoSafeAreaPadding attached property.

    Source

    back_requested_event

    fn back_requested_event() -> &'static RoutedEvent<RoutedEventArgs>
    

    Defines the BackRequested event.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    client_size

    fn client_size(self: &Self) -> Size
    

    The client size of the window.

    Source

    set_client_size

    fn set_client_size(self: &Self, value: Size)
    

    Sets the client size of the window (protected upstream: for derived classes).

    Source

    frame_size

    fn frame_size(self: &Self) -> Option<Size>
    

    The total size of the window.

    Source

    set_frame_size

    fn set_frame_size(self: &Self, value: Option<Size>)
    

    Sets the total size of the window (protected upstream: for derived classes).

    Source

    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".

    Source

    set_transparency_level_hint

    fn set_transparency_level_hint(self: &Self, value: WindowTransparencyLevelCollection)
    

    Source

    actual_transparency_level

    fn actual_transparency_level(self: &Self) -> WindowTransparencyLevel
    

    The achieved transparency level that the platform was able to provide.

    Source

    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.

    Source

    set_transparency_background_fallback

    fn set_transparency_background_fallback(self: &Self, value: Option<Rc<dyn IBrush>>)
    

    Source

    requested_theme_variant

    fn requested_theme_variant(self: &Self) -> Option<ThemeVariant>
    

    The theme variant requested for the top-level and its descendants.

    Source

    set_requested_theme_variant

    fn set_requested_theme_variant(self: &Self, value: Option<ThemeVariant>)
    

    Source

    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.

    Source

    layout_manager

    fn layout_manager(self: &Self) -> Rc<LayoutManager>
    

    The layout manager of the top-level.

    Source

    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.

    Source

    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).

    Source

    input_root

    fn input_root(self: &Self) -> Rc<dyn IInputRoot>
    

    The input root of the top-level.

    Source

    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.

    Source

    set_hit_tester_override

    fn set_hit_tester_override(self: &Self, value: Option<Rc<dyn IHitTester>>)
    

    Source

    renderer_diagnostics

    fn renderer_diagnostics(self: &Self) -> Rc<RendererDiagnostics>
    

    A value controlling whether the renderer should draw specific diagnostics.

    Source

    last_pointer_position

    fn last_pointer_position(self: &Self) -> Option<PixelPoint>
    

    The last known position of the pointer, in screen coordinates.

    Source

    access_key_handler

    fn access_key_handler(self: &Self) -> Option<Rc<dyn IAccessKeyHandler>>
    

    The access key handler for the window.

    Source

    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).

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    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.

    Source

    render_scaling

    fn render_scaling(self: &Self) -> f64
    

    The scaling factor to use in rendering.

    Source

    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.

    Source

    insets_manager

    fn insets_manager(self: &Self) -> Option<Rc<dyn IInsetsManager>>
    

    The insets manager of the platform, if it has one.

    Source

    input_pane

    fn input_pane(self: &Self) -> Option<Rc<dyn IInputPane>>
    

    The input pane of the platform, if it has one.

    Source

    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.

    Source

    screens

    fn screens(self: &Self) -> Option<Rc<Screens>>
    

    The platform screens implementation.

    Source

    clipboard

    fn clipboard(self: &Self) -> Option<Rc<dyn IClipboard>>
    

    The platform's clipboard implementation.

    Source

    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.

    Source

    focus_manager

    fn focus_manager(self: &Self) -> Rc<FocusManager>
    

    The focus manager of the root.

    Source

    get_top_level

    fn get_top_level(visual: Option<&Visual>) -> Option<Ref<TopLevel>>
    

    Gets the top-level in which the given visual is hosted.

    Source

    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.

    Source

    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.

    Source

    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).

    Source

    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).

    Source

    media_context_key

    fn media_context_key(self: &Self) -> usize
    

    The key that identifies the top-level in the media context.

    Source

    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).

    Source

    system_backdrop

    fn system_backdrop(self: &Self) -> Option<Ref<crate::media::SystemBackdrop>>
    

    SystemBackdrop.

    Source

    set_system_backdrop

    fn set_system_backdrop(self: &Self, value: Option<Ref<crate::media::SystemBackdrop>>)
    

    Source

    system_backdrop_target

    fn system_backdrop_target(self: &Self) -> Rc<crate::media::TopLevelBackdropTarget>
    

    The top level as the target of system backdrops.

    Source

    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).

    Source

    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).

    Source

    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.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.