pub struct MacBackend {
pub(crate) mtm: MainThreadMarker,
pub(crate) app: Retained<NSApplication>,
pub(crate) _delegate: Retained<AppDelegate>,
pub(crate) menu_target: RefCell<Option<Retained<MenuTarget>>>,
}Fields§
§mtm: MainThreadMarker§app: Retained<NSApplication>§_delegate: Retained<AppDelegate>What the app’s own menu items tell when chosen; menu items hold it weakly.
Implementations§
Trait Implementations§
Source§impl Backend for MacBackend
impl Backend for MacBackend
Source§fn set_backdrop(&self, window: &MacWindow, backdrop: Backdrop)
fn set_backdrop(&self, window: &MacWindow, backdrop: Backdrop)
A Mica-like material doesn’t exist on macOS, where a standard window is already the
platform’s own look, so only Translucent changes anything.
type Window = MacWindow
type Widget = MacWidget
type Waker = MacWaker
Source§fn open_window(
&self,
title: &str,
size: Size,
on_resize: ResizeHandler,
on_close: CloseHandler,
) -> MacWindow
fn open_window( &self, title: &str, size: Size, on_resize: ResizeHandler, on_close: CloseHandler, ) -> MacWindow
The window starts hidden;
on_resize receives the new content size after every
resize, and whenever something else changes how the content must be laid out, such
as the width of scroll bars. on_close runs when the user asks to close the window,
such as with its close button, in place of closing it: the app closes it with
Backend::close_window. The app quits once its last window closes.fn content_size(&self, window: &MacWindow) -> Size
Source§fn show_window(&self, window: &MacWindow)
fn show_window(&self, window: &MacWindow)
Shows the window in front of the others, with the keyboard.
Source§fn focus_window(&self, window: &MacWindow)
fn focus_window(&self, window: &MacWindow)
Brings a window already shown to the front, with the keyboard.
fn set_title(&self, window: &MacWindow, title: &str)
Source§fn set_content_size(&self, window: &MacWindow, size: Size)
fn set_content_size(&self, window: &MacWindow, size: Size)
Resizes the window’s content area; its
on_resize handler then reports the new size.Source§fn close_window(&self, window: MacWindow)
fn close_window(&self, window: MacWindow)
Closes the window, whose widgets have all been removed already.
Source§fn title_bar_inset(&self, window: &MacWindow) -> f32
fn title_bar_inset(&self, window: &MacWindow) -> f32
How far the title bar reaches down over the content area, which is
0 where the
title bar sits outside it.Source§fn set_min_content_width(&self, window: &MacWindow, width: f32)
fn set_min_content_width(&self, window: &MacWindow, width: f32)
Stops the user from making the content area narrower than
width.Source§fn create_surface(
&self,
parent: Parent<'_, Self>,
surface: Surface,
) -> MacWidget
fn create_surface( &self, parent: Parent<'_, Self>, surface: Surface, ) -> MacWidget
Draws
surface behind the widgets created after it. Widgets stack in the order
they are created, and a stack’s surface is created before its children, so the
surface is behind everything inside it. It is never Surface::None.Source§fn create_scroll(&self, parent: Parent<'_, Self>) -> MacWidget
fn create_scroll(&self, parent: Parent<'_, Self>) -> MacWidget
An area whose content scrolls up and down when it is taller than the area. Widgets
created with it as their
Parent::Scroll are its content.Source§fn scroll_bar_width(&self, _window: &MacWindow) -> f32
fn scroll_bar_width(&self, _window: &MacWindow) -> f32
How much of a scroll area’s width its vertical scroll bar takes from the content, in
points;
0 where scroll bars float over the content. It is asked again at every
layout, since the user can change it while the app runs.Source§fn set_scroll_content(&self, scroll: &MacWidget, size: Size)
fn set_scroll_content(&self, scroll: &MacWidget, size: Size)
Sets the size of a scroll area’s content, which is as wide as the area less its
scroll bar, and may be taller than the area.
fn create_label( &self, parent: Parent<'_, Self>, text: &str, style: LabelStyle, ) -> MacWidget
A button that shows whether it is selected when
selected is Some; clicking
it leaves that to set_checked.A row of a sidebar list: an icon, a title and a badge such as a count, highlighted
while
selected. on_click runs when the user picks it; it stays as it is until
set_checked changes it.Source§fn create_text_field(
&self,
parent: Parent<'_, Self>,
text: &str,
placeholder: &str,
lines: u32,
on_change: TextHandler,
on_submit: Option<ClickHandler>,
) -> MacWidget
fn create_text_field( &self, parent: Parent<'_, Self>, text: &str, placeholder: &str, lines: u32, on_change: TextHandler, on_submit: Option<ClickHandler>, ) -> MacWidget
A text field
lines lines tall: one line, or more that wrap the text, take
Return as a new line, and scroll; only a one-line field shows its placeholder.
on_change runs after each edit the user makes, not when set_text changes the
value, with lines ending in \n. A one-line field with on_submit runs it when
the user presses Return in it, instead of pressing the window’s primary button.Source§fn create_checkbox(
&self,
parent: Parent<'_, Self>,
title: &str,
checked: bool,
style: ToggleStyle,
on_toggle: ToggleHandler,
) -> MacWidget
fn create_checkbox( &self, parent: Parent<'_, Self>, title: &str, checked: bool, style: ToggleStyle, on_toggle: ToggleHandler, ) -> MacWidget
A checkbox ticks a box before its title, and a switch sits at the end of its title.
on_toggle runs when the user toggles it, not when set_checked changes it.Source§fn create_slider(
&self,
parent: Parent<'_, Self>,
value: i64,
min: i64,
max: i64,
on_change: NumberHandler,
) -> MacWidget
fn create_slider( &self, parent: Parent<'_, Self>, value: i64, min: i64, max: i64, on_change: NumberHandler, ) -> MacWidget
A slider for whole numbers from
min to max, at value. on_change runs with
each new value as the user drags it, not when set_value moves it.Source§fn create_picker(
&self,
parent: Parent<'_, Self>,
options: &[String],
selected: &str,
on_pick: TextHandler,
) -> MacWidget
fn create_picker( &self, parent: Parent<'_, Self>, options: &[String], selected: &str, on_pick: TextHandler, ) -> MacWidget
A pop-up menu of
options, showing the one equal to selected, or none when no
option is. on_pick runs with the option the user picks, not when set_text or
set_options change what it shows.Source§fn create_divider(&self, parent: Parent<'_, Self>) -> MacWidget
fn create_divider(&self, parent: Parent<'_, Self>) -> MacWidget
A thin line separating content; it is drawn along its longer side.
Source§fn create_drop_target(
&self,
parent: Parent<'_, Self>,
on_drop: DropHandler,
) -> MacWidget
fn create_drop_target( &self, parent: Parent<'_, Self>, on_drop: DropHandler, ) -> MacWidget
An area that takes files and links the user drags onto it from other apps, such as
the Finder, File Explorer or a browser. It draws nothing, takes clicks from no
control, and is placed like any widget; where areas overlap, the smallest one takes
the drop.
on_drop runs with a path for each file and an address for each link,
in the order the system gives them.An area that shows a menu of
entries when the user right-clicks in it, or opens
the context menu from the keyboard there. It draws nothing, takes clicks from no
control, and is placed like any widget; where areas overlap, the smallest one’s menu
shows. Controls that have a menu of their own, such as text fields, keep it.
on_select runs with the number of the item the user chooses.Source§fn create_image(
&self,
parent: Parent<'_, Self>,
path: Option<&Path>,
size: ImageSize,
) -> MacWidget
fn create_image( &self, parent: Parent<'_, Self>, path: Option<&Path>, size: ImageSize, ) -> MacWidget
The image in the file at
path, as large as fits its frame, keeping its shape, and
centred; it measures as size.frame of the image’s own size, in points. With no
path, or a file that can’t be read as an image, it shows nothing.Source§fn set_image(&self, widget: &MacWidget, path: Option<&Path>)
fn set_image(&self, widget: &MacWidget, path: Option<&Path>)
Shows the image at
path instead, as create_image does.Source§fn create_progress(
&self,
parent: Parent<'_, Self>,
percent: Option<i64>,
) -> MacWidget
fn create_progress( &self, parent: Parent<'_, Self>, percent: Option<i64>, ) -> MacWidget
A progress bar filled to
percent, from 0 to 100, or one showing that work is under
way, animated, when there is no percentage.Source§fn set_text(&self, widget: &MacWidget, text: &str)
fn set_text(&self, widget: &MacWidget, text: &str)
Sets a label’s text, a button’s or nav item’s title, a text field’s value, or the
option a picker shows.
Source§fn set_checked(&self, widget: &MacWidget, checked: bool)
fn set_checked(&self, widget: &MacWidget, checked: bool)
Ticks a checkbox or switch, highlights a nav item as selected, or shows a button
made with a selection as selected.
Source§fn set_value(&self, widget: &MacWidget, value: i64)
fn set_value(&self, widget: &MacWidget, value: i64)
Fills a progress bar to
value percent, from 0 to 100, or moves a slider to value.Source§fn set_options(&self, widget: &MacWidget, options: &[String])
fn set_options(&self, widget: &MacWidget, options: &[String])
Replaces a picker’s options, keeping the one it shows if it is still there.
Source§fn measure(&self, widget: &MacWidget) -> Size
fn measure(&self, widget: &MacWidget) -> Size
The widget’s natural size for its current content.
Source§fn set_frame(&self, widget: &MacWidget, frame: Frame)
fn set_frame(&self, widget: &MacWidget, frame: Frame)
Positions the widget relative to its parent’s content.
Source§fn remove_widget(&self, widget: MacWidget)
fn remove_widget(&self, widget: MacWidget)
Takes the widget off screen. It may be the widget whose handler is running right now,
so the backend must keep that handler alive until the handler returns.
Gives the app
menus, in place of any it had, alongside the system’s own: in the
menu bar on macOS, and in every window’s menu bar on Windows, with their items’
shortcuts working wherever the app has the keyboard. on_select runs with an
item’s number when the user chooses it or presses its shortcut.Source§fn waker(&self, on_wake: WakeHandler) -> MacWaker
fn waker(&self, on_wake: WakeHandler) -> MacWaker
on_wake runs on the UI thread soon after each wake, which any thread may call.Source§fn show_file_dialog(&self, dialog: &FileDialog, on_close: DialogHandler)
fn show_file_dialog(&self, dialog: &FileDialog, on_close: DialogHandler)
Shows
dialog over the app’s active window, or on its own when no window is active,
and passes how it closed to on_close on the UI thread. It is only called between
events, so it may run a modal loop and call on_close before returning.Source§impl Debug for MacBackend
impl Debug for MacBackend
Auto Trait Implementations§
impl !Freeze for MacBackend
impl !RefUnwindSafe for MacBackend
impl !Send for MacBackend
impl !Sync for MacBackend
impl !UnwindSafe for MacBackend
impl Unpin for MacBackend
impl UnsafeUnpin for MacBackend
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
Mutably borrows from an owned value. Read more