fix: 'static
lifetime elision for examples
Takes advantage of lifetime elision on some examples where the rule applies. Refer: https://doc.rust-lang.org/reference/lifetime-elision.html#static-lifetime-elision
This commit is contained in:
parent
e91e4217cb
commit
399600d443
|
@ -15,7 +15,7 @@ use cacao::appkit::{AnimationContext, App, AppDelegate};
|
||||||
use cacao::appkit::{Event, EventMask, EventMonitor};
|
use cacao::appkit::{Event, EventMask, EventMonitor};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window<AppWindow>
|
window: Window<AppWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
|
@ -54,22 +54,22 @@ const ANIMATIONS: [[[f64; 5]; 4]; 3] = [
|
||||||
[44., 16., 100., 100., 1.],
|
[44., 16., 100., 100., 1.],
|
||||||
[128., 84., 144., 124., 1.],
|
[128., 84., 144., 124., 1.],
|
||||||
[32., 32., 44., 44., 0.7],
|
[32., 32., 44., 44., 0.7],
|
||||||
[328., 157., 200., 200., 0.7]
|
[328., 157., 200., 200., 0.7],
|
||||||
],
|
],
|
||||||
// Red
|
// Red
|
||||||
[
|
[
|
||||||
[44., 132., 100., 100., 1.],
|
[44., 132., 100., 100., 1.],
|
||||||
[40., 47., 80., 64., 0.7],
|
[40., 47., 80., 64., 0.7],
|
||||||
[84., 220., 600., 109., 1.0],
|
[84., 220., 600., 109., 1.0],
|
||||||
[48., 600., 340., 44., 0.7]
|
[48., 600., 340., 44., 0.7],
|
||||||
],
|
],
|
||||||
// Green
|
// Green
|
||||||
[
|
[
|
||||||
[44., 248., 100., 100., 1.],
|
[44., 248., 100., 100., 1.],
|
||||||
[420., 232., 420., 244., 0.7],
|
[420., 232., 420., 244., 0.7],
|
||||||
[310., 440., 150., 238., 0.7],
|
[310., 440., 150., 238., 0.7],
|
||||||
[32., 32., 44., 44., 1.]
|
[32., 32., 44., 44., 1.],
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/// A helper method for generating frame constraints that we want to be animating.
|
/// A helper method for generating frame constraints that we want to be animating.
|
||||||
|
@ -84,7 +84,7 @@ fn apply_styles(view: &View, parent: &View, background_color: Color, animation_t
|
||||||
view.top.constraint_equal_to(&parent.top).offset(animation[0]),
|
view.top.constraint_equal_to(&parent.top).offset(animation[0]),
|
||||||
view.left.constraint_equal_to(&parent.left).offset(animation[1]),
|
view.left.constraint_equal_to(&parent.left).offset(animation[1]),
|
||||||
view.width.constraint_equal_to_constant(animation[2]),
|
view.width.constraint_equal_to_constant(animation[2]),
|
||||||
view.height.constraint_equal_to_constant(animation[3])
|
view.height.constraint_equal_to_constant(animation[3]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ struct AppWindow {
|
||||||
blue: View,
|
blue: View,
|
||||||
red: View,
|
red: View,
|
||||||
green: View,
|
green: View,
|
||||||
key_monitor: Option<EventMonitor>
|
key_monitor: Option<EventMonitor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowDelegate for AppWindow {
|
impl WindowDelegate for AppWindow {
|
||||||
|
@ -139,7 +139,7 @@ impl WindowDelegate for AppWindow {
|
||||||
"a" => 1,
|
"a" => 1,
|
||||||
"s" => 2,
|
"s" => 2,
|
||||||
"d" => 3,
|
"d" => 3,
|
||||||
_ => 4
|
_ => 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
if animation_index == 4 {
|
if animation_index == 4 {
|
||||||
|
@ -170,8 +170,11 @@ impl WindowDelegate for AppWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new(
|
||||||
window: Window::with(WindowConfig::default(), AppWindow::default())
|
"com.test.window",
|
||||||
})
|
BasicApp {
|
||||||
|
window: Window::with(WindowConfig::default(), AppWindow::default()),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,29 +10,35 @@ use cacao::appkit::window::{Window, WindowConfig, WindowDelegate};
|
||||||
use cacao::appkit::{App, AppDelegate};
|
use cacao::appkit::{App, AppDelegate};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window<AppWindow>
|
window: Window<AppWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![
|
App::set_menu(vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
App::activate();
|
App::activate();
|
||||||
|
@ -50,7 +56,7 @@ struct AppWindow {
|
||||||
content: View,
|
content: View,
|
||||||
blue: View,
|
blue: View,
|
||||||
red: View,
|
red: View,
|
||||||
green: View
|
green: View,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowDelegate for AppWindow {
|
impl WindowDelegate for AppWindow {
|
||||||
|
@ -62,7 +68,7 @@ impl WindowDelegate for AppWindow {
|
||||||
|
|
||||||
let dynamic = Color::dynamic(|style| match (style.theme, style.contrast) {
|
let dynamic = Color::dynamic(|style| match (style.theme, style.contrast) {
|
||||||
(Theme::Dark, _) => Color::SystemGreen,
|
(Theme::Dark, _) => Color::SystemGreen,
|
||||||
_ => Color::SystemRed
|
_ => Color::SystemRed,
|
||||||
});
|
});
|
||||||
|
|
||||||
self.blue.set_background_color(Color::SystemBlue);
|
self.blue.set_background_color(Color::SystemBlue);
|
||||||
|
@ -89,14 +95,17 @@ impl WindowDelegate for AppWindow {
|
||||||
self.green.leading.constraint_equal_to(&self.red.trailing).offset(16.),
|
self.green.leading.constraint_equal_to(&self.red.trailing).offset(16.),
|
||||||
self.green.trailing.constraint_equal_to(&self.content.trailing).offset(-16.),
|
self.green.trailing.constraint_equal_to(&self.content.trailing).offset(-16.),
|
||||||
self.green.bottom.constraint_equal_to(&self.content.bottom).offset(-16.),
|
self.green.bottom.constraint_equal_to(&self.content.bottom).offset(-16.),
|
||||||
self.green.width.constraint_equal_to_constant(100.)
|
self.green.width.constraint_equal_to_constant(100.),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new(
|
||||||
window: Window::with(WindowConfig::default(), AppWindow::default())
|
"com.test.window",
|
||||||
})
|
BasicApp {
|
||||||
|
window: Window::with(WindowConfig::default(), AppWindow::default()),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use toolbar::BrowserToolbar;
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
Back,
|
Back,
|
||||||
Forwards,
|
Forwards,
|
||||||
Load(String)
|
Load(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Action {
|
impl Action {
|
||||||
|
@ -26,39 +26,48 @@ impl Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window<AppWindow>
|
window: Window<AppWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![
|
App::set_menu(vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("Edit", vec![
|
Menu::new(
|
||||||
MenuItem::Undo,
|
"Edit",
|
||||||
MenuItem::Redo,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Undo,
|
||||||
MenuItem::Cut,
|
MenuItem::Redo,
|
||||||
MenuItem::Copy,
|
MenuItem::Separator,
|
||||||
MenuItem::Paste,
|
MenuItem::Cut,
|
||||||
MenuItem::Separator,
|
MenuItem::Copy,
|
||||||
MenuItem::SelectAll,
|
MenuItem::Paste,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::SelectAll,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("Help", vec![]),
|
Menu::new("Help", vec![]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -83,7 +92,7 @@ impl Dispatcher for BasicApp {
|
||||||
},
|
},
|
||||||
Action::Load(url) => {
|
Action::Load(url) => {
|
||||||
window.load_url(&url);
|
window.load_url(&url);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,14 +104,14 @@ impl WebViewDelegate for WebViewInstance {}
|
||||||
|
|
||||||
struct AppWindow {
|
struct AppWindow {
|
||||||
toolbar: Toolbar<BrowserToolbar>,
|
toolbar: Toolbar<BrowserToolbar>,
|
||||||
content: WebView<WebViewInstance>
|
content: WebView<WebViewInstance>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppWindow {
|
impl AppWindow {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
AppWindow {
|
AppWindow {
|
||||||
toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()),
|
toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()),
|
||||||
content: WebView::with(WebViewConfig::default(), WebViewInstance::default())
|
content: WebView::with(WebViewConfig::default(), WebViewInstance::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,18 +137,21 @@ impl WindowDelegate for AppWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new(
|
||||||
window: Window::with(
|
"com.test.window",
|
||||||
{
|
BasicApp {
|
||||||
let mut config = WindowConfig::default();
|
window: Window::with(
|
||||||
|
{
|
||||||
|
let mut config = WindowConfig::default();
|
||||||
|
|
||||||
// This flag is necessary for Big Sur to use the correct toolbar style.
|
// This flag is necessary for Big Sur to use the correct toolbar style.
|
||||||
config.toolbar_style = WindowToolbarStyle::Expanded;
|
config.toolbar_style = WindowToolbarStyle::Expanded;
|
||||||
|
|
||||||
config
|
config
|
||||||
},
|
},
|
||||||
AppWindow::new()
|
AppWindow::new(),
|
||||||
)
|
),
|
||||||
})
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ use cacao::appkit::toolbar::{ItemIdentifier, Toolbar, ToolbarDelegate, ToolbarDi
|
||||||
|
|
||||||
use super::Action;
|
use super::Action;
|
||||||
|
|
||||||
const BACK_BUTTON: &'static str = "BackButton";
|
const BACK_BUTTON: &str = "BackButton";
|
||||||
const FWDS_BUTTON: &'static str = "FwdsButton";
|
const FWDS_BUTTON: &str = "FwdsButton";
|
||||||
const URL_BAR: &'static str = "URLBar";
|
const URL_BAR: &str = "URLBar";
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct URLBar;
|
pub struct URLBar;
|
||||||
|
@ -27,7 +27,7 @@ pub struct BrowserToolbar {
|
||||||
back_item: ToolbarItem,
|
back_item: ToolbarItem,
|
||||||
forwards_item: ToolbarItem,
|
forwards_item: ToolbarItem,
|
||||||
url_bar: TextField<URLBar>,
|
url_bar: TextField<URLBar>,
|
||||||
url_bar_item: ToolbarItem
|
url_bar_item: ToolbarItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BrowserToolbar {
|
impl BrowserToolbar {
|
||||||
|
@ -59,7 +59,7 @@ impl BrowserToolbar {
|
||||||
back_item,
|
back_item,
|
||||||
forwards_item,
|
forwards_item,
|
||||||
url_bar,
|
url_bar,
|
||||||
url_bar_item
|
url_bar_item,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ impl ToolbarDelegate for BrowserToolbar {
|
||||||
URL_BAR => &self.url_bar_item,
|
URL_BAR => &self.url_bar_item,
|
||||||
_ => {
|
_ => {
|
||||||
std::unreachable!();
|
std::unreachable!();
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::content_view::{button, BUTTON_HEIGHT, BUTTON_WIDTH};
|
||||||
|
|
||||||
pub struct ButtonRow {
|
pub struct ButtonRow {
|
||||||
pub view: View,
|
pub view: View,
|
||||||
pub buttons: Vec<Button>
|
pub buttons: Vec<Button>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ButtonRow {
|
impl ButtonRow {
|
||||||
|
@ -36,9 +36,9 @@ impl ButtonRow {
|
||||||
Msg::Push(i) if *i == 7 => "7",
|
Msg::Push(i) if *i == 7 => "7",
|
||||||
Msg::Push(i) if *i == 8 => "8",
|
Msg::Push(i) if *i == 8 => "8",
|
||||||
Msg::Push(i) if *i == 9 => "9",
|
Msg::Push(i) if *i == 9 => "9",
|
||||||
_ => "W"
|
_ => "W",
|
||||||
},
|
},
|
||||||
y.clone()
|
y.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
view.add_subview(&button);
|
view.add_subview(&button);
|
||||||
|
@ -71,7 +71,7 @@ impl ButtonRow {
|
||||||
buttons[3].trailing.constraint_equal_to(&view.trailing),
|
buttons[3].trailing.constraint_equal_to(&view.trailing),
|
||||||
buttons[3].bottom.constraint_equal_to(&view.bottom),
|
buttons[3].bottom.constraint_equal_to(&view.bottom),
|
||||||
buttons[3].width.constraint_equal_to(&width),
|
buttons[3].width.constraint_equal_to(&width),
|
||||||
view.height.constraint_equal_to_constant(BUTTON_HEIGHT)
|
view.height.constraint_equal_to_constant(BUTTON_HEIGHT),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Self { view, buttons }
|
Self { view, buttons }
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub enum Msg {
|
||||||
Clear,
|
Clear,
|
||||||
Mod,
|
Mod,
|
||||||
Invert,
|
Invert,
|
||||||
Equals
|
Equals,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Asynchronously calls back through to the top of the application
|
/// Asynchronously calls back through to the top of the application
|
||||||
|
@ -97,11 +97,11 @@ impl Calculator {
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Error parsing expression: {:?}", e);
|
eprintln!("Error parsing expression: {:?}", e);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub struct CalculatorView {
|
||||||
pub row3: ButtonRow,
|
pub row3: ButtonRow,
|
||||||
pub dot: Button,
|
pub dot: Button,
|
||||||
pub zero: Button,
|
pub zero: Button,
|
||||||
pub equals: Button
|
pub equals: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CalculatorView {
|
impl CalculatorView {
|
||||||
|
@ -56,30 +56,30 @@ impl CalculatorView {
|
||||||
row0: ButtonRow::new(
|
row0: ButtonRow::new(
|
||||||
[Msg::Clear, Msg::Invert, Msg::Mod, Msg::Divide],
|
[Msg::Clear, Msg::Invert, Msg::Mod, Msg::Divide],
|
||||||
Color::rgb(69, 69, 69),
|
Color::rgb(69, 69, 69),
|
||||||
Color::rgb(255, 148, 10)
|
Color::rgb(255, 148, 10),
|
||||||
),
|
),
|
||||||
|
|
||||||
row1: ButtonRow::new(
|
row1: ButtonRow::new(
|
||||||
[Msg::Push(7), Msg::Push(8), Msg::Push(9), Msg::Multiply],
|
[Msg::Push(7), Msg::Push(8), Msg::Push(9), Msg::Multiply],
|
||||||
Color::rgb(100, 100, 100),
|
Color::rgb(100, 100, 100),
|
||||||
Color::rgb(255, 148, 10)
|
Color::rgb(255, 148, 10),
|
||||||
),
|
),
|
||||||
|
|
||||||
row2: ButtonRow::new(
|
row2: ButtonRow::new(
|
||||||
[Msg::Push(4), Msg::Push(5), Msg::Push(6), Msg::Subtract],
|
[Msg::Push(4), Msg::Push(5), Msg::Push(6), Msg::Subtract],
|
||||||
Color::rgb(100, 100, 100),
|
Color::rgb(100, 100, 100),
|
||||||
Color::rgb(255, 148, 10)
|
Color::rgb(255, 148, 10),
|
||||||
),
|
),
|
||||||
|
|
||||||
row3: ButtonRow::new(
|
row3: ButtonRow::new(
|
||||||
[Msg::Push(1), Msg::Push(2), Msg::Push(3), Msg::Add],
|
[Msg::Push(1), Msg::Push(2), Msg::Push(3), Msg::Add],
|
||||||
Color::rgb(100, 100, 100),
|
Color::rgb(100, 100, 100),
|
||||||
Color::rgb(255, 148, 10)
|
Color::rgb(255, 148, 10),
|
||||||
),
|
),
|
||||||
|
|
||||||
zero: button("0", Msg::Push(0)),
|
zero: button("0", Msg::Push(0)),
|
||||||
dot: button(".", Msg::Decimal),
|
dot: button(".", Msg::Decimal),
|
||||||
equals: button("=", Msg::Equals)
|
equals: button("=", Msg::Equals),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ impl ViewDelegate for CalculatorView {
|
||||||
self.equals.trailing.constraint_equal_to(&view.trailing),
|
self.equals.trailing.constraint_equal_to(&view.trailing),
|
||||||
self.equals.bottom.constraint_equal_to(&view.bottom),
|
self.equals.bottom.constraint_equal_to(&view.bottom),
|
||||||
self.equals.width.constraint_equal_to_constant(BUTTON_WIDTH),
|
self.equals.width.constraint_equal_to_constant(BUTTON_WIDTH),
|
||||||
self.equals.height.constraint_equal_to_constant(BUTTON_HEIGHT)
|
self.equals.height.constraint_equal_to_constant(BUTTON_HEIGHT),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use content_view::CalculatorView;
|
||||||
struct CalculatorApp {
|
struct CalculatorApp {
|
||||||
window: Window,
|
window: Window,
|
||||||
content: View<CalculatorView>,
|
content: View<CalculatorView>,
|
||||||
key_monitor: RwLock<Option<EventMonitor>>
|
key_monitor: RwLock<Option<EventMonitor>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for CalculatorApp {
|
impl AppDelegate for CalculatorApp {
|
||||||
|
@ -105,10 +105,13 @@ fn main() {
|
||||||
let mut config = WindowConfig::default();
|
let mut config = WindowConfig::default();
|
||||||
config.set_initial_dimensions(100., 100., 240., 300.);
|
config.set_initial_dimensions(100., 100., 240., 300.);
|
||||||
|
|
||||||
App::new("com.example.calculator", CalculatorApp {
|
App::new(
|
||||||
window: Window::new(config),
|
"com.example.calculator",
|
||||||
content: View::with(CalculatorView::new()),
|
CalculatorApp {
|
||||||
key_monitor: RwLock::new(None)
|
window: Window::new(config),
|
||||||
})
|
content: View::with(CalculatorView::new()),
|
||||||
|
key_monitor: RwLock::new(None),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct BasicApp {
|
||||||
window: Window,
|
window: Window,
|
||||||
content_view: View,
|
content_view: View,
|
||||||
image_view: ImageView,
|
image_view: ImageView,
|
||||||
image: Image
|
image: Image,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BasicApp {
|
impl Default for BasicApp {
|
||||||
|
@ -23,7 +23,7 @@ impl Default for BasicApp {
|
||||||
let config = DrawConfig {
|
let config = DrawConfig {
|
||||||
source: (100., 100.),
|
source: (100., 100.),
|
||||||
target: (800., 800.),
|
target: (800., 800.),
|
||||||
resize: cacao::image::ResizeBehavior::Stretch
|
resize: cacao::image::ResizeBehavior::Stretch,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -91,22 +91,25 @@ impl Default for BasicApp {
|
||||||
context.fill_path();
|
context.fill_path();
|
||||||
|
|
||||||
true
|
true
|
||||||
})
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![Menu::new("", vec![
|
App::set_menu(vec![Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
])]);
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
)]);
|
||||||
|
|
||||||
App::activate();
|
App::activate();
|
||||||
self.window.set_title("Hello World!");
|
self.window.set_title("Hello World!");
|
||||||
|
@ -119,7 +122,7 @@ impl AppDelegate for BasicApp {
|
||||||
self.image_view.top.constraint_equal_to(&self.content_view.top),
|
self.image_view.top.constraint_equal_to(&self.content_view.top),
|
||||||
self.image_view.leading.constraint_equal_to(&self.content_view.leading),
|
self.image_view.leading.constraint_equal_to(&self.content_view.leading),
|
||||||
self.image_view.trailing.constraint_equal_to(&self.content_view.trailing),
|
self.image_view.trailing.constraint_equal_to(&self.content_view.trailing),
|
||||||
self.image_view.bottom.constraint_equal_to(&self.content_view.bottom)
|
self.image_view.bottom.constraint_equal_to(&self.content_view.bottom),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self.window.set_content_view(&self.content_view);
|
self.window.set_content_view(&self.content_view);
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl AppDelegate for DefaultsTest {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Error converting bytes {}", e);
|
eprintln!("Error converting bytes {}", e);
|
||||||
"Error converting bytes"
|
"Error converting bytes"
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(s, "BYTES TEST");
|
assert_eq!(s, "BYTES TEST");
|
||||||
|
|
|
@ -17,29 +17,35 @@ const WIDTH: f64 = 100.;
|
||||||
const HEIGHT: f64 = 100.;
|
const HEIGHT: f64 = 100.;
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window<AppWindow>
|
window: Window<AppWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![
|
App::set_menu(vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
App::activate();
|
App::activate();
|
||||||
|
@ -58,7 +64,7 @@ struct AppWindow {
|
||||||
content: View,
|
content: View,
|
||||||
blue: View,
|
blue: View,
|
||||||
red: View,
|
red: View,
|
||||||
green: View
|
green: View,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppWindow {
|
impl AppWindow {
|
||||||
|
@ -68,7 +74,7 @@ impl AppWindow {
|
||||||
top: TOP,
|
top: TOP,
|
||||||
left: SPACING,
|
left: SPACING,
|
||||||
width: WIDTH,
|
width: WIDTH,
|
||||||
height: HEIGHT
|
height: HEIGHT,
|
||||||
});
|
});
|
||||||
self.blue.layer.set_corner_radius(CORNER_RADIUS);
|
self.blue.layer.set_corner_radius(CORNER_RADIUS);
|
||||||
self.content.add_subview(&self.blue);
|
self.content.add_subview(&self.blue);
|
||||||
|
@ -78,7 +84,7 @@ impl AppWindow {
|
||||||
top: TOP,
|
top: TOP,
|
||||||
left: WIDTH + (SPACING * 2.),
|
left: WIDTH + (SPACING * 2.),
|
||||||
width: WIDTH,
|
width: WIDTH,
|
||||||
height: HEIGHT
|
height: HEIGHT,
|
||||||
});
|
});
|
||||||
self.red.layer.set_corner_radius(CORNER_RADIUS);
|
self.red.layer.set_corner_radius(CORNER_RADIUS);
|
||||||
self.content.add_subview(&self.red);
|
self.content.add_subview(&self.red);
|
||||||
|
@ -88,7 +94,7 @@ impl AppWindow {
|
||||||
top: TOP,
|
top: TOP,
|
||||||
left: (WIDTH * 2.) + (SPACING * 3.),
|
left: (WIDTH * 2.) + (SPACING * 3.),
|
||||||
width: WIDTH,
|
width: WIDTH,
|
||||||
height: HEIGHT
|
height: HEIGHT,
|
||||||
});
|
});
|
||||||
self.green.layer.set_corner_radius(CORNER_RADIUS);
|
self.green.layer.set_corner_radius(CORNER_RADIUS);
|
||||||
self.content.add_subview(&self.green);
|
self.content.add_subview(&self.green);
|
||||||
|
@ -106,8 +112,11 @@ impl WindowDelegate for AppWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new(
|
||||||
window: Window::with(WindowConfig::default(), AppWindow::default())
|
"com.test.window",
|
||||||
})
|
BasicApp {
|
||||||
|
window: Window::with(WindowConfig::default(), AppWindow::default()),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub struct RootView {
|
||||||
pub red: View,
|
pub red: View,
|
||||||
pub green: View,
|
pub green: View,
|
||||||
pub blue: View,
|
pub blue: View,
|
||||||
pub image: ImageView
|
pub image: ImageView,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewDelegate for RootView {
|
impl ViewDelegate for RootView {
|
||||||
|
@ -55,7 +55,7 @@ impl ViewDelegate for RootView {
|
||||||
self.blue.top.constraint_equal_to(&self.green.bottom).offset(16.),
|
self.blue.top.constraint_equal_to(&self.green.bottom).offset(16.),
|
||||||
self.blue.leading.constraint_equal_to(&view.leading).offset(16.),
|
self.blue.leading.constraint_equal_to(&view.leading).offset(16.),
|
||||||
self.blue.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
self.blue.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
||||||
self.blue.bottom.constraint_equal_to(&view.bottom).offset(-16.)
|
self.blue.bottom.constraint_equal_to(&view.bottom).offset(-16.),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ impl ViewDelegate for RootView {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WindowScene {
|
pub struct WindowScene {
|
||||||
pub window: RwLock<Option<Window>>,
|
pub window: RwLock<Option<Window>>,
|
||||||
pub root_view_controller: RwLock<Option<ViewController<RootView>>>
|
pub root_view_controller: RwLock<Option<ViewController<RootView>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowSceneDelegate for WindowScene {
|
impl WindowSceneDelegate for WindowScene {
|
||||||
|
|
|
@ -10,39 +10,48 @@ use cacao::appkit::window::{Window, WindowConfig, WindowDelegate};
|
||||||
use cacao::appkit::{App, AppDelegate};
|
use cacao::appkit::{App, AppDelegate};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window<AppWindow>
|
window: Window<AppWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![
|
App::set_menu(vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("Edit", vec![
|
Menu::new(
|
||||||
MenuItem::Undo,
|
"Edit",
|
||||||
MenuItem::Redo,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Undo,
|
||||||
MenuItem::Cut,
|
MenuItem::Redo,
|
||||||
MenuItem::Copy,
|
MenuItem::Separator,
|
||||||
MenuItem::Paste,
|
MenuItem::Cut,
|
||||||
MenuItem::Separator,
|
MenuItem::Copy,
|
||||||
MenuItem::SelectAll,
|
MenuItem::Paste,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::SelectAll,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("Help", vec![]),
|
Menu::new("Help", vec![]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -78,14 +87,14 @@ impl TextFieldDelegate for ConsoleLogger {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct AppWindow {
|
struct AppWindow {
|
||||||
input: TextField<ConsoleLogger>,
|
input: TextField<ConsoleLogger>,
|
||||||
content: View
|
content: View,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppWindow {
|
impl AppWindow {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
AppWindow {
|
AppWindow {
|
||||||
input: TextField::with(ConsoleLogger),
|
input: TextField::with(ConsoleLogger),
|
||||||
content: View::new()
|
content: View::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,14 +112,17 @@ impl WindowDelegate for AppWindow {
|
||||||
LayoutConstraint::activate(&[
|
LayoutConstraint::activate(&[
|
||||||
self.input.center_x.constraint_equal_to(&self.content.center_x),
|
self.input.center_x.constraint_equal_to(&self.content.center_x),
|
||||||
self.input.center_y.constraint_equal_to(&self.content.center_y),
|
self.input.center_y.constraint_equal_to(&self.content.center_y),
|
||||||
self.input.width.constraint_equal_to_constant(280.)
|
self.input.width.constraint_equal_to_constant(280.),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new(
|
||||||
window: Window::with(WindowConfig::default(), AppWindow::new())
|
"com.test.window",
|
||||||
})
|
BasicApp {
|
||||||
|
window: Window::with(WindowConfig::default(), AppWindow::new()),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ mod view;
|
||||||
use view::AddNewTodoContentView;
|
use view::AddNewTodoContentView;
|
||||||
|
|
||||||
pub struct AddNewTodoWindow {
|
pub struct AddNewTodoWindow {
|
||||||
pub content: ViewController<AddNewTodoContentView>
|
pub content: ViewController<AddNewTodoContentView>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddNewTodoWindow {
|
impl AddNewTodoWindow {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::storage::{dispatch_ui, Message};
|
||||||
pub struct AddNewTodoContentView {
|
pub struct AddNewTodoContentView {
|
||||||
pub view: Option<View>,
|
pub view: Option<View>,
|
||||||
pub input: Option<TextField>,
|
pub input: Option<TextField>,
|
||||||
pub button: Option<Button>
|
pub button: Option<Button>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddNewTodoContentView {
|
impl AddNewTodoContentView {
|
||||||
|
@ -34,7 +34,7 @@ impl AddNewTodoContentView {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ impl ViewDelegate for AddNewTodoContentView {
|
||||||
input.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
input.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
||||||
button.top.constraint_equal_to(&input.bottom).offset(8.),
|
button.top.constraint_equal_to(&input.bottom).offset(8.),
|
||||||
button.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
button.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
||||||
button.bottom.constraint_equal_to(&view.bottom).offset(-16.)
|
button.bottom.constraint_equal_to(&view.bottom).offset(-16.),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self.view = Some(view);
|
self.view = Some(view);
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::windows::WindowManager;
|
||||||
/// This handles routing lifecycle events, and maintains our `WindowManager`.
|
/// This handles routing lifecycle events, and maintains our `WindowManager`.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TodosApp {
|
pub struct TodosApp {
|
||||||
pub window_manager: WindowManager
|
pub window_manager: WindowManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for TodosApp {
|
impl AppDelegate for TodosApp {
|
||||||
|
|
|
@ -11,49 +11,61 @@ use crate::storage::{dispatch_ui, Message};
|
||||||
/// Installs the menu.
|
/// Installs the menu.
|
||||||
pub fn menu() -> Vec<Menu> {
|
pub fn menu() -> Vec<Menu> {
|
||||||
vec![
|
vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::About("Todos".to_string()),
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::new("Preferences").key(",").action(|| {
|
MenuItem::About("Todos".to_string()),
|
||||||
dispatch_ui(Message::OpenPreferencesWindow);
|
MenuItem::Separator,
|
||||||
}),
|
MenuItem::new("Preferences").key(",").action(|| {
|
||||||
MenuItem::Separator,
|
dispatch_ui(Message::OpenPreferencesWindow);
|
||||||
MenuItem::Services,
|
}),
|
||||||
MenuItem::Separator,
|
MenuItem::Separator,
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
Menu::new("File", vec![
|
MenuItem::Quit,
|
||||||
MenuItem::new("Open/Show Window").key("n").action(|| {
|
],
|
||||||
dispatch_ui(Message::OpenMainWindow);
|
),
|
||||||
}),
|
Menu::new(
|
||||||
MenuItem::Separator,
|
"File",
|
||||||
MenuItem::new("Add Todo").key("+").action(|| {
|
vec![
|
||||||
dispatch_ui(Message::OpenNewTodoSheet);
|
MenuItem::new("Open/Show Window").key("n").action(|| {
|
||||||
}),
|
dispatch_ui(Message::OpenMainWindow);
|
||||||
MenuItem::Separator,
|
}),
|
||||||
MenuItem::CloseWindow,
|
MenuItem::Separator,
|
||||||
]),
|
MenuItem::new("Add Todo").key("+").action(|| {
|
||||||
Menu::new("Edit", vec![
|
dispatch_ui(Message::OpenNewTodoSheet);
|
||||||
MenuItem::Undo,
|
}),
|
||||||
MenuItem::Redo,
|
MenuItem::Separator,
|
||||||
MenuItem::Separator,
|
MenuItem::CloseWindow,
|
||||||
MenuItem::Cut,
|
],
|
||||||
MenuItem::Copy,
|
),
|
||||||
MenuItem::Paste,
|
Menu::new(
|
||||||
MenuItem::Separator,
|
"Edit",
|
||||||
MenuItem::SelectAll,
|
vec![
|
||||||
]),
|
MenuItem::Undo,
|
||||||
|
MenuItem::Redo,
|
||||||
|
MenuItem::Separator,
|
||||||
|
MenuItem::Cut,
|
||||||
|
MenuItem::Copy,
|
||||||
|
MenuItem::Paste,
|
||||||
|
MenuItem::Separator,
|
||||||
|
MenuItem::SelectAll,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("Help", vec![]),
|
Menu::new("Help", vec![]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use cacao::view::{View, ViewDelegate};
|
||||||
/// A blank advanced preferences view.
|
/// A blank advanced preferences view.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct AdvancedPreferencesContentView {
|
pub struct AdvancedPreferencesContentView {
|
||||||
label: Label
|
label: Label,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewDelegate for AdvancedPreferencesContentView {
|
impl ViewDelegate for AdvancedPreferencesContentView {
|
||||||
|
@ -21,7 +21,7 @@ impl ViewDelegate for AdvancedPreferencesContentView {
|
||||||
self.label.top.constraint_equal_to(&view.top).offset(100.),
|
self.label.top.constraint_equal_to(&view.top).offset(100.),
|
||||||
self.label.leading.constraint_equal_to(&view.leading).offset(16.),
|
self.label.leading.constraint_equal_to(&view.leading).offset(16.),
|
||||||
self.label.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
self.label.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
||||||
self.label.bottom.constraint_equal_to(&view.bottom).offset(-100.)
|
self.label.bottom.constraint_equal_to(&view.bottom).offset(-100.),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ use super::toggle_option_view::ToggleOptionView;
|
||||||
/// A general preferences view.
|
/// A general preferences view.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct GeneralPreferencesContentView {
|
pub struct GeneralPreferencesContentView {
|
||||||
pub example_option: ToggleOptionView
|
pub example_option: ToggleOptionView,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewDelegate for GeneralPreferencesContentView {
|
impl ViewDelegate for GeneralPreferencesContentView {
|
||||||
|
@ -23,7 +23,7 @@ impl ViewDelegate for GeneralPreferencesContentView {
|
||||||
"An example preference",
|
"An example preference",
|
||||||
"This can be true, or it can be false.",
|
"This can be true, or it can be false.",
|
||||||
Defaults::should_whatever(), // initial value
|
Defaults::should_whatever(), // initial value
|
||||||
Defaults::toggle_should_whatever
|
Defaults::toggle_should_whatever,
|
||||||
);
|
);
|
||||||
|
|
||||||
view.add_subview(&self.example_option.view);
|
view.add_subview(&self.example_option.view);
|
||||||
|
@ -40,7 +40,7 @@ impl ViewDelegate for GeneralPreferencesContentView {
|
||||||
.trailing
|
.trailing
|
||||||
.constraint_equal_to(&view.trailing)
|
.constraint_equal_to(&view.trailing)
|
||||||
.offset(-22.),
|
.offset(-22.),
|
||||||
self.example_option.view.bottom.constraint_equal_to(&view.bottom).offset(-22.)
|
self.example_option.view.bottom.constraint_equal_to(&view.bottom).offset(-22.),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub struct PreferencesWindow {
|
||||||
pub toolbar: Toolbar<PreferencesToolbar>,
|
pub toolbar: Toolbar<PreferencesToolbar>,
|
||||||
pub general: ViewController<GeneralPreferencesContentView>,
|
pub general: ViewController<GeneralPreferencesContentView>,
|
||||||
pub advanced: ViewController<AdvancedPreferencesContentView>,
|
pub advanced: ViewController<AdvancedPreferencesContentView>,
|
||||||
window: Option<Window>
|
window: Option<Window>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PreferencesWindow {
|
impl PreferencesWindow {
|
||||||
|
@ -30,7 +30,7 @@ impl PreferencesWindow {
|
||||||
toolbar: Toolbar::new("PreferencesToolbar", PreferencesToolbar::default()),
|
toolbar: Toolbar::new("PreferencesToolbar", PreferencesToolbar::default()),
|
||||||
general: ViewController::new(GeneralPreferencesContentView::default()),
|
general: ViewController::new(GeneralPreferencesContentView::default()),
|
||||||
advanced: ViewController::new(AdvancedPreferencesContentView::default()),
|
advanced: ViewController::new(AdvancedPreferencesContentView::default()),
|
||||||
window: None
|
window: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ impl PreferencesWindow {
|
||||||
window.set_content_view_controller(&self.advanced);
|
window.set_content_view_controller(&self.advanced);
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub struct ToggleOptionView {
|
||||||
pub view: View,
|
pub view: View,
|
||||||
pub switch: Switch,
|
pub switch: Switch,
|
||||||
pub title: Label,
|
pub title: Label,
|
||||||
pub subtitle: Label
|
pub subtitle: Label,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ToggleOptionView {
|
impl Default for ToggleOptionView {
|
||||||
|
@ -37,14 +37,14 @@ impl Default for ToggleOptionView {
|
||||||
subtitle.top.constraint_equal_to(&title.bottom),
|
subtitle.top.constraint_equal_to(&title.bottom),
|
||||||
subtitle.leading.constraint_equal_to(&switch.trailing),
|
subtitle.leading.constraint_equal_to(&switch.trailing),
|
||||||
subtitle.trailing.constraint_equal_to(&view.trailing),
|
subtitle.trailing.constraint_equal_to(&view.trailing),
|
||||||
subtitle.bottom.constraint_equal_to(&view.bottom)
|
subtitle.bottom.constraint_equal_to(&view.bottom),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
ToggleOptionView {
|
ToggleOptionView {
|
||||||
view,
|
view,
|
||||||
switch,
|
switch,
|
||||||
title,
|
title,
|
||||||
subtitle
|
subtitle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl ToggleOptionView {
|
||||||
/// can toggle your settings and such there.
|
/// can toggle your settings and such there.
|
||||||
pub fn configure<F>(&mut self, text: &str, subtitle: &str, state: bool, handler: F)
|
pub fn configure<F>(&mut self, text: &str, subtitle: &str, state: bool, handler: F)
|
||||||
where
|
where
|
||||||
F: Fn() + Send + Sync + 'static
|
F: Fn() + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
self.title.set_text(text);
|
self.title.set_text(text);
|
||||||
self.subtitle.set_text(subtitle);
|
self.subtitle.set_text(subtitle);
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl Default for PreferencesToolbar {
|
||||||
});
|
});
|
||||||
|
|
||||||
item
|
item
|
||||||
}
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ impl ToolbarDelegate for PreferencesToolbar {
|
||||||
"advanced" => &self.0 .1,
|
"advanced" => &self.0 .1,
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use cacao::defaults::{UserDefaults, Value};
|
use cacao::defaults::{UserDefaults, Value};
|
||||||
|
|
||||||
const EXAMPLE: &'static str = "exampleSetting";
|
const EXAMPLE: &str = "exampleSetting";
|
||||||
|
|
||||||
/// A very basic wrapper around UserDefaults. If I wind up implementing Serde support for
|
/// A very basic wrapper around UserDefaults. If I wind up implementing Serde support for
|
||||||
/// UserDefaults, then much of this could be removed or simplified - but I'm not sold on that yet,
|
/// UserDefaults, then much of this could be removed or simplified - but I'm not sold on that yet,
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub enum Message {
|
||||||
MarkTodoComplete(usize),
|
MarkTodoComplete(usize),
|
||||||
|
|
||||||
/// Mark a todo as incomplete.
|
/// Mark a todo as incomplete.
|
||||||
MarkTodoIncomplete(usize)
|
MarkTodoIncomplete(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dispatch a message on a background thread.
|
/// Dispatch a message on a background thread.
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub enum TodoStatus {
|
||||||
Incomplete,
|
Incomplete,
|
||||||
|
|
||||||
/// Completed. ;P
|
/// Completed. ;P
|
||||||
Complete
|
Complete,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Todo. Represents... something to do.
|
/// A Todo. Represents... something to do.
|
||||||
|
@ -22,7 +22,7 @@ pub struct Todo {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
|
|
||||||
/// The status of this todo.
|
/// The status of this todo.
|
||||||
pub status: TodoStatus
|
pub status: TodoStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A single-threaded Todos "database".
|
/// A single-threaded Todos "database".
|
||||||
|
@ -36,7 +36,7 @@ impl Todos {
|
||||||
|
|
||||||
let mut todos = vec![Todo {
|
let mut todos = vec![Todo {
|
||||||
title: title,
|
title: title,
|
||||||
status: TodoStatus::Incomplete
|
status: TodoStatus::Incomplete,
|
||||||
}];
|
}];
|
||||||
|
|
||||||
todos.append(&mut stack);
|
todos.append(&mut stack);
|
||||||
|
@ -47,7 +47,7 @@ impl Todos {
|
||||||
/// Edit a Todo at the row specified.
|
/// Edit a Todo at the row specified.
|
||||||
pub fn with_mut<F>(&self, row: usize, handler: F)
|
pub fn with_mut<F>(&self, row: usize, handler: F)
|
||||||
where
|
where
|
||||||
F: Fn(&mut Todo)
|
F: Fn(&mut Todo),
|
||||||
{
|
{
|
||||||
let mut stack = self.0.borrow_mut();
|
let mut stack = self.0.borrow_mut();
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ impl Todos {
|
||||||
/// Run a block with the given Todo.
|
/// Run a block with the given Todo.
|
||||||
pub fn with<F>(&self, row: usize, mut handler: F)
|
pub fn with<F>(&self, row: usize, mut handler: F)
|
||||||
where
|
where
|
||||||
F: FnMut(&Todo)
|
F: FnMut(&Todo),
|
||||||
{
|
{
|
||||||
let stack = self.0.borrow();
|
let stack = self.0.borrow();
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ use crate::storage::Message;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TodosContentView {
|
pub struct TodosContentView {
|
||||||
pub todos_list_view: ListView<TodosListView>
|
pub todos_list_view: ListView<TodosListView>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TodosContentView {
|
impl Default for TodosContentView {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
TodosContentView {
|
TodosContentView {
|
||||||
todos_list_view: ListView::with(TodosListView::default())
|
todos_list_view: ListView::with(TodosListView::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ impl ViewDelegate for TodosContentView {
|
||||||
self.todos_list_view.top.constraint_equal_to(&view.top),
|
self.todos_list_view.top.constraint_equal_to(&view.top),
|
||||||
self.todos_list_view.leading.constraint_equal_to(&view.leading),
|
self.todos_list_view.leading.constraint_equal_to(&view.leading),
|
||||||
self.todos_list_view.trailing.constraint_equal_to(&view.trailing),
|
self.todos_list_view.trailing.constraint_equal_to(&view.trailing),
|
||||||
self.todos_list_view.bottom.constraint_equal_to(&view.bottom)
|
self.todos_list_view.bottom.constraint_equal_to(&view.bottom),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@ mod row;
|
||||||
use row::TodoViewRow;
|
use row::TodoViewRow;
|
||||||
|
|
||||||
/// An identifier for the cell(s) we dequeue.
|
/// An identifier for the cell(s) we dequeue.
|
||||||
const TODO_ROW: &'static str = "TodoViewRowCell";
|
const TODO_ROW: &str = "TodoViewRowCell";
|
||||||
|
|
||||||
/// The list view for todos.
|
/// The list view for todos.
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct TodosListView {
|
pub struct TodosListView {
|
||||||
view: Option<ListView>,
|
view: Option<ListView>,
|
||||||
todos: Todos
|
todos: Todos,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TodosListView {
|
impl TodosListView {
|
||||||
|
@ -49,7 +49,7 @@ impl TodosListView {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ impl ListViewDelegate for TodosListView {
|
||||||
RowActionStyle::Destructive,
|
RowActionStyle::Destructive,
|
||||||
move |_action, row| {
|
move |_action, row| {
|
||||||
dispatch_ui(Message::MarkTodoIncomplete(row));
|
dispatch_ui(Message::MarkTodoIncomplete(row));
|
||||||
}
|
},
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -109,9 +109,9 @@ impl ListViewDelegate for TodosListView {
|
||||||
RowActionStyle::Regular,
|
RowActionStyle::Regular,
|
||||||
move |_action, row| {
|
move |_action, row| {
|
||||||
dispatch_ui(Message::MarkTodoComplete(row));
|
dispatch_ui(Message::MarkTodoComplete(row));
|
||||||
}
|
},
|
||||||
));
|
));
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
actions
|
actions
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::storage::{Todo, TodoStatus};
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct TodoViewRow {
|
pub struct TodoViewRow {
|
||||||
pub title: Label,
|
pub title: Label,
|
||||||
pub status: Label
|
pub status: Label,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TodoViewRow {
|
impl TodoViewRow {
|
||||||
|
@ -27,7 +27,7 @@ impl TodoViewRow {
|
||||||
TodoStatus::Complete => {
|
TodoStatus::Complete => {
|
||||||
self.status.set_text_color(Color::SystemBlue);
|
self.status.set_text_color(Color::SystemBlue);
|
||||||
self.status.set_text("Complete");
|
self.status.set_text("Complete");
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ impl ViewDelegate for TodoViewRow {
|
||||||
self.status.top.constraint_equal_to(&self.title.bottom).offset(8.),
|
self.status.top.constraint_equal_to(&self.title.bottom).offset(8.),
|
||||||
self.status.leading.constraint_equal_to(&view.leading).offset(16.),
|
self.status.leading.constraint_equal_to(&view.leading).offset(16.),
|
||||||
self.status.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
self.status.trailing.constraint_equal_to(&view.trailing).offset(-16.),
|
||||||
self.status.bottom.constraint_equal_to(&view.bottom).offset(-16.)
|
self.status.bottom.constraint_equal_to(&view.bottom).offset(-16.),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@ mod list;
|
||||||
|
|
||||||
pub struct TodosWindow {
|
pub struct TodosWindow {
|
||||||
pub content: ViewController<TodosContentView>,
|
pub content: ViewController<TodosContentView>,
|
||||||
pub toolbar: Toolbar<TodosToolbar>
|
pub toolbar: Toolbar<TodosToolbar>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TodosWindow {
|
impl TodosWindow {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
TodosWindow {
|
TodosWindow {
|
||||||
content: ViewController::new(TodosContentView::default()),
|
content: ViewController::new(TodosContentView::default()),
|
||||||
toolbar: Toolbar::new("TodosToolbar", TodosToolbar::default())
|
toolbar: Toolbar::new("TodosToolbar", TodosToolbar::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ use crate::todos::TodosWindow;
|
||||||
pub struct WindowManager {
|
pub struct WindowManager {
|
||||||
pub main: RwLock<Option<Window<TodosWindow>>>,
|
pub main: RwLock<Option<Window<TodosWindow>>>,
|
||||||
pub preferences: RwLock<Option<Window<PreferencesWindow>>>,
|
pub preferences: RwLock<Option<Window<PreferencesWindow>>>,
|
||||||
pub add: RwLock<Option<Window<AddNewTodoWindow>>>
|
pub add: RwLock<Option<Window<AddNewTodoWindow>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper method to handle checking for window existence, and creating
|
/// A helper method to handle checking for window existence, and creating
|
||||||
|
@ -26,7 +26,7 @@ pub struct WindowManager {
|
||||||
fn open_or_show<T, F>(window: &RwLock<Option<Window<T>>>, vendor: F)
|
fn open_or_show<T, F>(window: &RwLock<Option<Window<T>>>, vendor: F)
|
||||||
where
|
where
|
||||||
T: WindowDelegate + 'static,
|
T: WindowDelegate + 'static,
|
||||||
F: Fn() -> (WindowConfig, T)
|
F: Fn() -> (WindowConfig, T),
|
||||||
{
|
{
|
||||||
let mut lock = window.write().unwrap();
|
let mut lock = window.write().unwrap();
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ impl WindowManager {
|
||||||
pub fn begin_sheet<W, F>(&self, window: &Window<W>, completion: F)
|
pub fn begin_sheet<W, F>(&self, window: &Window<W>, completion: F)
|
||||||
where
|
where
|
||||||
W: WindowDelegate + 'static,
|
W: WindowDelegate + 'static,
|
||||||
F: Fn() + Send + Sync + 'static
|
F: Fn() + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let main = self.main.write().unwrap();
|
let main = self.main.write().unwrap();
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ impl WindowManager {
|
||||||
WindowStyle::Resizable,
|
WindowStyle::Resizable,
|
||||||
WindowStyle::Miniaturizable,
|
WindowStyle::Miniaturizable,
|
||||||
WindowStyle::Closable,
|
WindowStyle::Closable,
|
||||||
WindowStyle::Titled
|
WindowStyle::Titled,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
config.toolbar_style = WindowToolbarStyle::Preferences;
|
config.toolbar_style = WindowToolbarStyle::Preferences;
|
||||||
|
@ -137,7 +137,7 @@ impl Dispatcher for WindowManager {
|
||||||
self.close_sheet();
|
self.close_sheet();
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(w) = &*(self.main.read().unwrap()) {
|
if let Some(w) = &*(self.main.read().unwrap()) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use cacao::appkit::{App, AppDelegate};
|
||||||
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window<AppWindow>
|
window: Window<AppWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
|
@ -56,13 +56,13 @@ impl WebViewDelegate for WebViewInstance {
|
||||||
|
|
||||||
return match requested_asset_path.as_str() {
|
return match requested_asset_path.as_str() {
|
||||||
"/hello.html" => Some(link_html.as_bytes().into()),
|
"/hello.html" => Some(link_html.as_bytes().into()),
|
||||||
_ => Some(index_html.as_bytes().into())
|
_ => Some(index_html.as_bytes().into()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AppWindow {
|
struct AppWindow {
|
||||||
content: WebView<WebViewInstance>
|
content: WebView<WebViewInstance>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppWindow {
|
impl AppWindow {
|
||||||
|
@ -73,7 +73,7 @@ impl AppWindow {
|
||||||
webview_config.add_custom_protocol("cacao");
|
webview_config.add_custom_protocol("cacao");
|
||||||
|
|
||||||
AppWindow {
|
AppWindow {
|
||||||
content: WebView::with(webview_config, WebViewInstance::default())
|
content: WebView::with(webview_config, WebViewInstance::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +98,11 @@ impl WindowDelegate for AppWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new(
|
||||||
window: Window::with(WindowConfig::default(), AppWindow::new())
|
"com.test.window",
|
||||||
})
|
BasicApp {
|
||||||
|
window: Window::with(WindowConfig::default(), AppWindow::new()),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,29 +6,35 @@ use cacao::appkit::{App, AppDelegate};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window
|
window: Window,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![
|
App::set_menu(vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
App::activate();
|
App::activate();
|
||||||
|
|
|
@ -9,29 +9,35 @@ use cacao::appkit::window::{Window, WindowConfig, WindowController, WindowDelega
|
||||||
use cacao::appkit::{App, AppDelegate};
|
use cacao::appkit::{App, AppDelegate};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: WindowController<MyWindow>
|
window: WindowController<MyWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![
|
App::set_menu(vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
App::activate();
|
App::activate();
|
||||||
|
@ -61,8 +67,11 @@ impl WindowDelegate for MyWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window-delegate", BasicApp {
|
App::new(
|
||||||
window: WindowController::with(WindowConfig::default(), MyWindow::default())
|
"com.test.window-delegate",
|
||||||
})
|
BasicApp {
|
||||||
|
window: WindowController::with(WindowConfig::default(), MyWindow::default()),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,29 +6,35 @@ use cacao::appkit::window::{Window, WindowConfig, WindowDelegate};
|
||||||
use cacao::appkit::{App, AppDelegate};
|
use cacao::appkit::{App, AppDelegate};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
window: Window<MyWindow>
|
window: Window<MyWindow>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppDelegate for BasicApp {
|
impl AppDelegate for BasicApp {
|
||||||
fn did_finish_launching(&self) {
|
fn did_finish_launching(&self) {
|
||||||
App::set_menu(vec![
|
App::set_menu(vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
App::activate();
|
App::activate();
|
||||||
|
@ -71,8 +77,11 @@ impl WindowDelegate for MyWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window-delegate", BasicApp {
|
App::new(
|
||||||
window: Window::with(WindowConfig::default(), MyWindow::default())
|
"com.test.window-delegate",
|
||||||
})
|
BasicApp {
|
||||||
|
window: Window::with(WindowConfig::default(), MyWindow::default()),
|
||||||
|
},
|
||||||
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl AnimationContext {
|
||||||
/// the supported methods here.
|
/// the supported methods here.
|
||||||
pub fn run<F>(animation: F)
|
pub fn run<F>(animation: F)
|
||||||
where
|
where
|
||||||
F: Fn(&mut AnimationContext) + Send + Sync + 'static
|
F: Fn(&mut AnimationContext) + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let block = ConcreteBlock::new(move |ctx| {
|
let block = ConcreteBlock::new(move |ctx| {
|
||||||
let mut context = AnimationContext(ctx);
|
let mut context = AnimationContext(ctx);
|
||||||
|
@ -53,7 +53,7 @@ impl AnimationContext {
|
||||||
pub fn run_with_completion_handler<F, C>(animation: F, completion_handler: C)
|
pub fn run_with_completion_handler<F, C>(animation: F, completion_handler: C)
|
||||||
where
|
where
|
||||||
F: Fn(&mut AnimationContext) + Send + Sync + 'static,
|
F: Fn(&mut AnimationContext) + Send + Sync + 'static,
|
||||||
C: Fn() + Send + Sync + 'static
|
C: Fn() + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let block = ConcreteBlock::new(move |ctx| {
|
let block = ConcreteBlock::new(move |ctx| {
|
||||||
let mut context = AnimationContext(ctx);
|
let mut context = AnimationContext(ctx);
|
||||||
|
|
|
@ -107,7 +107,7 @@ extern "C" fn did_update<T: AppDelegate>(this: &Object, _: Sel, _: id) {
|
||||||
extern "C" fn should_handle_reopen<T: AppDelegate>(this: &Object, _: Sel, _: id, has_visible_windows: BOOL) -> BOOL {
|
extern "C" fn should_handle_reopen<T: AppDelegate>(this: &Object, _: Sel, _: id, has_visible_windows: BOOL) -> BOOL {
|
||||||
match app::<T>(this).should_handle_reopen(to_bool(has_visible_windows)) {
|
match app::<T>(this).should_handle_reopen(to_bool(has_visible_windows)) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ extern "C" fn should_handle_reopen<T: AppDelegate>(this: &Object, _: Sel, _: id,
|
||||||
extern "C" fn dock_menu<T: AppDelegate>(this: &Object, _: Sel, _: id) -> id {
|
extern "C" fn dock_menu<T: AppDelegate>(this: &Object, _: Sel, _: id) -> id {
|
||||||
match app::<T>(this).dock_menu() {
|
match app::<T>(this).dock_menu() {
|
||||||
Some(mut menu) => &mut *menu.0,
|
Some(mut menu) => &mut *menu.0,
|
||||||
None => nil
|
None => nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ extern "C" fn will_continue_user_activity_with_type<T: AppDelegate>(this: &Objec
|
||||||
|
|
||||||
match app::<T>(this).will_continue_user_activity(activity.to_str()) {
|
match app::<T>(this).will_continue_user_activity(activity.to_str()) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ extern "C" fn continue_user_activity<T: AppDelegate>(this: &Object, _: Sel, _: i
|
||||||
(*handler).call((nil,));
|
(*handler).call((nil,));
|
||||||
}) {
|
}) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ extern "C" fn open_file_without_ui<T: AppDelegate>(this: &Object, _: Sel, _: id,
|
||||||
|
|
||||||
match app::<T>(this).open_file_without_ui(filename.to_str()) {
|
match app::<T>(this).open_file_without_ui(filename.to_str()) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ extern "C" fn open_file_without_ui<T: AppDelegate>(this: &Object, _: Sel, _: id,
|
||||||
extern "C" fn should_open_untitled_file<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
extern "C" fn should_open_untitled_file<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
||||||
match app::<T>(this).should_open_untitled_file() {
|
match app::<T>(this).should_open_untitled_file() {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ extern "C" fn should_open_untitled_file<T: AppDelegate>(this: &Object, _: Sel, _
|
||||||
extern "C" fn should_terminate_after_last_window_closed<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
extern "C" fn should_terminate_after_last_window_closed<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
||||||
match app::<T>(this).should_terminate_after_last_window_closed() {
|
match app::<T>(this).should_terminate_after_last_window_closed() {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ extern "C" fn should_terminate_after_last_window_closed<T: AppDelegate>(this: &O
|
||||||
extern "C" fn open_untitled_file<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
extern "C" fn open_untitled_file<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
||||||
match app::<T>(this).open_untitled_file() {
|
match app::<T>(this).open_untitled_file() {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ extern "C" fn open_temp_file<T: AppDelegate>(this: &Object, _: Sel, _: id, filen
|
||||||
|
|
||||||
match app::<T>(this).open_temp_file(filename.to_str()) {
|
match app::<T>(this).open_temp_file(filename.to_str()) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ extern "C" fn print_file<T: AppDelegate>(this: &Object, _: Sel, _: id, file: id)
|
||||||
|
|
||||||
match app::<T>(this).print_file(filename.to_str()) {
|
match app::<T>(this).print_file(filename.to_str()) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ extern "C" fn print_files<T: AppDelegate>(
|
||||||
_: id,
|
_: id,
|
||||||
files: id,
|
files: id,
|
||||||
settings: id,
|
settings: id,
|
||||||
show_print_panels: BOOL
|
show_print_panels: BOOL,
|
||||||
) -> NSUInteger {
|
) -> NSUInteger {
|
||||||
let files = NSArray::retain(files).map(|file| NSString::retain(file).to_str().to_string());
|
let files = NSArray::retain(files).map(|file| NSString::retain(file).to_str().to_string());
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ extern "C" fn delegate_handles_key<T: AppDelegate>(this: &Object, _: Sel, _: id,
|
||||||
|
|
||||||
match app::<T>(this).delegate_handles_key(key.to_str()) {
|
match app::<T>(this).delegate_handles_key(key.to_str()) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,43 +307,43 @@ pub(crate) fn register_app_delegate_class<T: AppDelegate + AppDelegate>() -> *co
|
||||||
// Launching Applications
|
// Launching Applications
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationWillFinishLaunching:),
|
sel!(applicationWillFinishLaunching:),
|
||||||
will_finish_launching::<T> as extern "C" fn(&Object, _, _)
|
will_finish_launching::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationDidFinishLaunching:),
|
sel!(applicationDidFinishLaunching:),
|
||||||
did_finish_launching::<T> as extern "C" fn(&Object, _, _)
|
did_finish_launching::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Managing Active Status
|
// Managing Active Status
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationWillBecomeActive:),
|
sel!(applicationWillBecomeActive:),
|
||||||
will_become_active::<T> as extern "C" fn(&Object, _, _)
|
will_become_active::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationDidBecomeActive:),
|
sel!(applicationDidBecomeActive:),
|
||||||
did_become_active::<T> as extern "C" fn(&Object, _, _)
|
did_become_active::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationWillResignActive:),
|
sel!(applicationWillResignActive:),
|
||||||
will_resign_active::<T> as extern "C" fn(&Object, _, _)
|
will_resign_active::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationDidResignActive:),
|
sel!(applicationDidResignActive:),
|
||||||
did_resign_active::<T> as extern "C" fn(&Object, _, _)
|
did_resign_active::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Terminating Applications
|
// Terminating Applications
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationShouldTerminate:),
|
sel!(applicationShouldTerminate:),
|
||||||
should_terminate::<T> as extern "C" fn(&Object, _, _) -> NSUInteger
|
should_terminate::<T> as extern "C" fn(&Object, _, _) -> NSUInteger,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationWillTerminate:),
|
sel!(applicationWillTerminate:),
|
||||||
will_terminate::<T> as extern "C" fn(&Object, _, _)
|
will_terminate::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationShouldTerminateAfterLastWindowClosed:),
|
sel!(applicationShouldTerminateAfterLastWindowClosed:),
|
||||||
should_terminate_after_last_window_closed::<T> as extern "C" fn(&Object, _, _) -> BOOL
|
should_terminate_after_last_window_closed::<T> as extern "C" fn(&Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Hiding Applications
|
// Hiding Applications
|
||||||
|
@ -357,100 +357,100 @@ pub(crate) fn register_app_delegate_class<T: AppDelegate + AppDelegate>() -> *co
|
||||||
decl.add_method(sel!(applicationDidUpdate:), did_update::<T> as extern "C" fn(&Object, _, _));
|
decl.add_method(sel!(applicationDidUpdate:), did_update::<T> as extern "C" fn(&Object, _, _));
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationShouldHandleReopen:hasVisibleWindows:),
|
sel!(applicationShouldHandleReopen:hasVisibleWindows:),
|
||||||
should_handle_reopen::<T> as extern "C" fn(&Object, _, _, BOOL) -> BOOL
|
should_handle_reopen::<T> as extern "C" fn(&Object, _, _, BOOL) -> BOOL,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Dock Menu
|
// Dock Menu
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationDockMenu:),
|
sel!(applicationDockMenu:),
|
||||||
dock_menu::<T> as extern "C" fn(&Object, _, _) -> id
|
dock_menu::<T> as extern "C" fn(&Object, _, _) -> id,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Displaying Errors
|
// Displaying Errors
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:willPresentError:),
|
sel!(application:willPresentError:),
|
||||||
will_present_error::<T> as extern "C" fn(&Object, _, _, id) -> id
|
will_present_error::<T> as extern "C" fn(&Object, _, _, id) -> id,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Managing the Screen
|
// Managing the Screen
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationDidChangeScreenParameters:),
|
sel!(applicationDidChangeScreenParameters:),
|
||||||
did_change_screen_parameters::<T> as extern "C" fn(&Object, _, _)
|
did_change_screen_parameters::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationDidChangeOcclusionState:),
|
sel!(applicationDidChangeOcclusionState:),
|
||||||
did_change_occlusion_state::<T> as extern "C" fn(&Object, _, _)
|
did_change_occlusion_state::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// User Activities
|
// User Activities
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:willContinueUserActivityWithType:),
|
sel!(application:willContinueUserActivityWithType:),
|
||||||
will_continue_user_activity_with_type::<T> as extern "C" fn(&Object, _, _, id) -> BOOL
|
will_continue_user_activity_with_type::<T> as extern "C" fn(&Object, _, _, id) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:continueUserActivity:restorationHandler:),
|
sel!(application:continueUserActivity:restorationHandler:),
|
||||||
continue_user_activity::<T> as extern "C" fn(&Object, _, _, id, id) -> BOOL
|
continue_user_activity::<T> as extern "C" fn(&Object, _, _, id, id) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:didFailToContinueUserActivityWithType:error:),
|
sel!(application:didFailToContinueUserActivityWithType:error:),
|
||||||
failed_to_continue_user_activity::<T> as extern "C" fn(&Object, _, _, id, id)
|
failed_to_continue_user_activity::<T> as extern "C" fn(&Object, _, _, id, id),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:didUpdateUserActivity:),
|
sel!(application:didUpdateUserActivity:),
|
||||||
did_update_user_activity::<T> as extern "C" fn(&Object, _, _, id)
|
did_update_user_activity::<T> as extern "C" fn(&Object, _, _, id),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handling push notifications
|
// Handling push notifications
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:didRegisterForRemoteNotificationsWithDeviceToken:),
|
sel!(application:didRegisterForRemoteNotificationsWithDeviceToken:),
|
||||||
registered_for_remote_notifications::<T> as extern "C" fn(&Object, _, _, id)
|
registered_for_remote_notifications::<T> as extern "C" fn(&Object, _, _, id),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:didFailToRegisterForRemoteNotificationsWithError:),
|
sel!(application:didFailToRegisterForRemoteNotificationsWithError:),
|
||||||
failed_to_register_for_remote_notifications::<T> as extern "C" fn(&Object, _, _, id)
|
failed_to_register_for_remote_notifications::<T> as extern "C" fn(&Object, _, _, id),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:didReceiveRemoteNotification:),
|
sel!(application:didReceiveRemoteNotification:),
|
||||||
did_receive_remote_notification::<T> as extern "C" fn(&Object, _, _, id)
|
did_receive_remote_notification::<T> as extern "C" fn(&Object, _, _, id),
|
||||||
);
|
);
|
||||||
|
|
||||||
// CloudKit
|
// CloudKit
|
||||||
#[cfg(feature = "cloudkit")]
|
#[cfg(feature = "cloudkit")]
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:userDidAcceptCloudKitShareWithMetadata:),
|
sel!(application:userDidAcceptCloudKitShareWithMetadata:),
|
||||||
accepted_cloudkit_share::<T> as extern "C" fn(&Object, _, _, id)
|
accepted_cloudkit_share::<T> as extern "C" fn(&Object, _, _, id),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Opening Files
|
// Opening Files
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:openURLs:),
|
sel!(application:openURLs:),
|
||||||
open_urls::<T> as extern "C" fn(&Object, _, _, id)
|
open_urls::<T> as extern "C" fn(&Object, _, _, id),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:openFileWithoutUI:),
|
sel!(application:openFileWithoutUI:),
|
||||||
open_file_without_ui::<T> as extern "C" fn(&Object, _, _, id) -> BOOL
|
open_file_without_ui::<T> as extern "C" fn(&Object, _, _, id) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationShouldOpenUntitledFile:),
|
sel!(applicationShouldOpenUntitledFile:),
|
||||||
should_open_untitled_file::<T> as extern "C" fn(&Object, _, _) -> BOOL
|
should_open_untitled_file::<T> as extern "C" fn(&Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(applicationOpenUntitledFile:),
|
sel!(applicationOpenUntitledFile:),
|
||||||
open_untitled_file::<T> as extern "C" fn(&Object, _, _) -> BOOL
|
open_untitled_file::<T> as extern "C" fn(&Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:openTempFile:),
|
sel!(application:openTempFile:),
|
||||||
open_temp_file::<T> as extern "C" fn(&Object, _, _, id) -> BOOL
|
open_temp_file::<T> as extern "C" fn(&Object, _, _, id) -> BOOL,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Printing
|
// Printing
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:printFile:),
|
sel!(application:printFile:),
|
||||||
print_file::<T> as extern "C" fn(&Object, _, _, id) -> BOOL
|
print_file::<T> as extern "C" fn(&Object, _, _, id) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:printFiles:withSettings:showPrintPanels:),
|
sel!(application:printFiles:withSettings:showPrintPanels:),
|
||||||
print_files::<T> as extern "C" fn(&Object, _, id, id, id, BOOL) -> NSUInteger
|
print_files::<T> as extern "C" fn(&Object, _, id, id, id, BOOL) -> NSUInteger,
|
||||||
);
|
);
|
||||||
|
|
||||||
// @TODO: Restoring Application State
|
// @TODO: Restoring Application State
|
||||||
|
@ -459,7 +459,7 @@ pub(crate) fn register_app_delegate_class<T: AppDelegate + AppDelegate>() -> *co
|
||||||
// Scripting
|
// Scripting
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(application:delegateHandlesKey:),
|
sel!(application:delegateHandlesKey:),
|
||||||
delegate_handles_key::<T> as extern "C" fn(&Object, _, _, id) -> BOOL
|
delegate_handles_key::<T> as extern "C" fn(&Object, _, _, id) -> BOOL,
|
||||||
);
|
);
|
||||||
|
|
||||||
DELEGATE_CLASS = decl.register();
|
DELEGATE_CLASS = decl.register();
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub enum TerminateResponse {
|
||||||
///
|
///
|
||||||
/// This return value is for primarily for cases where you need to provide alerts
|
/// This return value is for primarily for cases where you need to provide alerts
|
||||||
/// in order to decide whether to quit.
|
/// in order to decide whether to quit.
|
||||||
Later
|
Later,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TerminateResponse> for NSUInteger {
|
impl From<TerminateResponse> for NSUInteger {
|
||||||
|
@ -25,7 +25,7 @@ impl From<TerminateResponse> for NSUInteger {
|
||||||
match response {
|
match response {
|
||||||
TerminateResponse::Now => 1,
|
TerminateResponse::Now => 1,
|
||||||
TerminateResponse::Cancel => 0,
|
TerminateResponse::Cancel => 0,
|
||||||
TerminateResponse::Later => 2
|
TerminateResponse::Later => 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ pub enum AppDelegateResponse {
|
||||||
Success,
|
Success,
|
||||||
|
|
||||||
/// Failed.
|
/// Failed.
|
||||||
Failure
|
Failure,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AppDelegateResponse> for NSUInteger {
|
impl From<AppDelegateResponse> for NSUInteger {
|
||||||
|
@ -52,7 +52,7 @@ impl From<AppDelegateResponse> for NSUInteger {
|
||||||
match response {
|
match response {
|
||||||
AppDelegateResponse::Cancelled => 1,
|
AppDelegateResponse::Cancelled => 1,
|
||||||
AppDelegateResponse::Success => 0,
|
AppDelegateResponse::Success => 0,
|
||||||
AppDelegateResponse::Failure => 2
|
AppDelegateResponse::Failure => 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ pub enum PresentationOption {
|
||||||
AutoHideToolbar,
|
AutoHideToolbar,
|
||||||
|
|
||||||
/// The behavior that allows the user to shake the mouse to locate the cursor is disabled.
|
/// The behavior that allows the user to shake the mouse to locate the cursor is disabled.
|
||||||
DisableCursorLocationAssistance
|
DisableCursorLocationAssistance,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PresentationOption> for NSUInteger {
|
impl From<PresentationOption> for NSUInteger {
|
||||||
|
@ -131,7 +131,7 @@ impl From<PresentationOption> for NSUInteger {
|
||||||
PresentationOption::DisableMenuBarTransparency => (1 << 9),
|
PresentationOption::DisableMenuBarTransparency => (1 << 9),
|
||||||
PresentationOption::FullScreen => (1 << 10),
|
PresentationOption::FullScreen => (1 << 10),
|
||||||
PresentationOption::AutoHideToolbar => (1 << 11),
|
PresentationOption::AutoHideToolbar => (1 << 11),
|
||||||
PresentationOption::DisableCursorLocationAssistance => (1 << 12)
|
PresentationOption::DisableCursorLocationAssistance => (1 << 12),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ impl From<&PresentationOption> for NSUInteger {
|
||||||
PresentationOption::DisableMenuBarTransparency => (1 << 9),
|
PresentationOption::DisableMenuBarTransparency => (1 << 9),
|
||||||
PresentationOption::FullScreen => (1 << 10),
|
PresentationOption::FullScreen => (1 << 10),
|
||||||
PresentationOption::AutoHideToolbar => (1 << 11),
|
PresentationOption::AutoHideToolbar => (1 << 11),
|
||||||
PresentationOption::DisableCursorLocationAssistance => (1 << 12)
|
PresentationOption::DisableCursorLocationAssistance => (1 << 12),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ pub struct App<T = (), M = ()> {
|
||||||
/// The main-thread AutoReleasePool. Drains on app exit.
|
/// The main-thread AutoReleasePool. Drains on app exit.
|
||||||
pub pool: AutoReleasePool,
|
pub pool: AutoReleasePool,
|
||||||
|
|
||||||
_message: std::marker::PhantomData<M>
|
_message: std::marker::PhantomData<M>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, M> fmt::Debug for App<T, M> {
|
impl<T, M> fmt::Debug for App<T, M> {
|
||||||
|
@ -130,7 +130,7 @@ impl<T> App<T> {
|
||||||
|
|
||||||
impl<T> App<T>
|
impl<T> App<T>
|
||||||
where
|
where
|
||||||
T: AppDelegate + 'static
|
T: AppDelegate + 'static,
|
||||||
{
|
{
|
||||||
/// Creates an NSAutoReleasePool, configures various NSApplication properties (e.g, activation
|
/// Creates an NSAutoReleasePool, configures various NSApplication properties (e.g, activation
|
||||||
/// policies), injects an `NSObject` delegate wrapper, and retains everything on the
|
/// policies), injects an `NSObject` delegate wrapper, and retains everything on the
|
||||||
|
@ -163,7 +163,7 @@ where
|
||||||
objc_delegate,
|
objc_delegate,
|
||||||
delegate: app_delegate,
|
delegate: app_delegate,
|
||||||
pool,
|
pool,
|
||||||
_message: std::marker::PhantomData
|
_message: std::marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ where
|
||||||
impl<T, M> App<T, M>
|
impl<T, M> App<T, M>
|
||||||
where
|
where
|
||||||
M: Send + Sync + 'static,
|
M: Send + Sync + 'static,
|
||||||
T: AppDelegate + Dispatcher<Message = M>
|
T: AppDelegate + Dispatcher<Message = M>,
|
||||||
{
|
{
|
||||||
/// Dispatches a message by grabbing the `sharedApplication`, getting ahold of the delegate,
|
/// Dispatches a message by grabbing the `sharedApplication`, getting ahold of the delegate,
|
||||||
/// and passing back through there.
|
/// and passing back through there.
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub enum CursorType {
|
||||||
DragCopy,
|
DragCopy,
|
||||||
|
|
||||||
/// Indicates a context menu will open.
|
/// Indicates a context menu will open.
|
||||||
ContextMenu
|
ContextMenu,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A wrapper around NSCursor.
|
/// A wrapper around NSCursor.
|
||||||
|
@ -127,7 +127,7 @@ impl Cursor {
|
||||||
CursorType::OperationNotAllowed => msg_send![class!(NSCursor), operationNotAllowedCursor],
|
CursorType::OperationNotAllowed => msg_send![class!(NSCursor), operationNotAllowedCursor],
|
||||||
CursorType::DragLink => msg_send![class!(NSCursor), dragLinkCursor],
|
CursorType::DragLink => msg_send![class!(NSCursor), dragLinkCursor],
|
||||||
CursorType::DragCopy => msg_send![class!(NSCursor), dragCopyCursor],
|
CursorType::DragCopy => msg_send![class!(NSCursor), dragCopyCursor],
|
||||||
CursorType::ContextMenu => msg_send![class!(NSCursor), contextualMenuCursor]
|
CursorType::ContextMenu => msg_send![class!(NSCursor), contextualMenuCursor],
|
||||||
};
|
};
|
||||||
|
|
||||||
let _: () = msg_send![cursor, push];
|
let _: () = msg_send![cursor, push];
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub enum FocusRingType {
|
||||||
|
|
||||||
// Should never be used, but used as a placeholder in case the underlying
|
// Should never be used, but used as a placeholder in case the underlying
|
||||||
// system framework ever opts to return something we don't expect.
|
// system framework ever opts to return something we don't expect.
|
||||||
Unknown(NSUInteger)
|
Unknown(NSUInteger),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FocusRingType> for NSUInteger {
|
impl From<FocusRingType> for NSUInteger {
|
||||||
|
@ -25,7 +25,7 @@ impl From<FocusRingType> for NSUInteger {
|
||||||
FocusRingType::Default => 0,
|
FocusRingType::Default => 0,
|
||||||
FocusRingType::None => 1,
|
FocusRingType::None => 1,
|
||||||
FocusRingType::Exterior => 2,
|
FocusRingType::Exterior => 2,
|
||||||
FocusRingType::Unknown(i) => i
|
FocusRingType::Unknown(i) => i,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ impl From<NSUInteger> for FocusRingType {
|
||||||
0 => Self::Default,
|
0 => Self::Default,
|
||||||
1 => Self::None,
|
1 => Self::None,
|
||||||
2 => Self::Exterior,
|
2 => Self::Exterior,
|
||||||
i => Self::Unknown(i)
|
i => Self::Unknown(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::foundation::{id, nil, NSString};
|
||||||
/// An EventMask describes the type of event.
|
/// An EventMask describes the type of event.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum EventMask {
|
pub enum EventMask {
|
||||||
KeyDown
|
KeyDown,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A wrapper over an `NSEvent`.
|
/// A wrapper over an `NSEvent`.
|
||||||
|
@ -55,14 +55,14 @@ impl Event {
|
||||||
/// monitors are required - the streams don't mix.
|
/// monitors are required - the streams don't mix.
|
||||||
pub fn local_monitor<F>(_mask: EventMask, handler: F) -> EventMonitor
|
pub fn local_monitor<F>(_mask: EventMask, handler: F) -> EventMonitor
|
||||||
where
|
where
|
||||||
F: Fn(Event) -> Option<Event> + Send + Sync + 'static
|
F: Fn(Event) -> Option<Event> + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
let block = ConcreteBlock::new(move |event: id| {
|
let block = ConcreteBlock::new(move |event: id| {
|
||||||
let evt = Event::new(event);
|
let evt = Event::new(event);
|
||||||
|
|
||||||
match handler(evt) {
|
match handler(evt) {
|
||||||
Some(mut evt) => &mut *evt.0,
|
Some(mut evt) => &mut *evt.0,
|
||||||
None => nil
|
None => nil,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let block = block.copy();
|
let block = block.copy();
|
||||||
|
@ -82,7 +82,7 @@ pub enum EventModifierFlag {
|
||||||
Control,
|
Control,
|
||||||
Option,
|
Option,
|
||||||
Command,
|
Command,
|
||||||
DeviceIndependentFlagsMask
|
DeviceIndependentFlagsMask,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EventModifierFlag> for NSUInteger {
|
impl From<EventModifierFlag> for NSUInteger {
|
||||||
|
@ -92,7 +92,7 @@ impl From<EventModifierFlag> for NSUInteger {
|
||||||
EventModifierFlag::Control => 1 << 18,
|
EventModifierFlag::Control => 1 << 18,
|
||||||
EventModifierFlag::Option => 1 << 19,
|
EventModifierFlag::Option => 1 << 19,
|
||||||
EventModifierFlag::Command => 1 << 20,
|
EventModifierFlag::Command => 1 << 20,
|
||||||
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000
|
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ impl From<&EventModifierFlag> for NSUInteger {
|
||||||
EventModifierFlag::Control => 1 << 18,
|
EventModifierFlag::Control => 1 << 18,
|
||||||
EventModifierFlag::Option => 1 << 19,
|
EventModifierFlag::Option => 1 << 19,
|
||||||
EventModifierFlag::Command => 1 << 20,
|
EventModifierFlag::Command => 1 << 20,
|
||||||
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000
|
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn make_menu_item<S: AsRef<str>>(
|
||||||
title: S,
|
title: S,
|
||||||
key: Option<&str>,
|
key: Option<&str>,
|
||||||
action: Option<Sel>,
|
action: Option<Sel>,
|
||||||
modifiers: Option<&[EventModifierFlag]>
|
modifiers: Option<&[EventModifierFlag]>,
|
||||||
) -> Id<Object> {
|
) -> Id<Object> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let title = NSString::new(title.as_ref());
|
let title = NSString::new(title.as_ref());
|
||||||
|
@ -47,7 +47,7 @@ fn make_menu_item<S: AsRef<str>>(
|
||||||
// Note that AppKit requires a blank string if nil, not nil.
|
// Note that AppKit requires a blank string if nil, not nil.
|
||||||
let key = NSString::new(match key {
|
let key = NSString::new(match key {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => ""
|
None => "",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Stock menu items that use selectors targeted at system pieces are just standard
|
// Stock menu items that use selectors targeted at system pieces are just standard
|
||||||
|
@ -59,7 +59,7 @@ fn make_menu_item<S: AsRef<str>>(
|
||||||
|
|
||||||
None => msg_send![alloc, initWithTitle:&*title
|
None => msg_send![alloc, initWithTitle:&*title
|
||||||
action:sel!(fireBlockAction:)
|
action:sel!(fireBlockAction:)
|
||||||
keyEquivalent:&*key]
|
keyEquivalent:&*key],
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(modifiers) = modifiers {
|
if let Some(modifiers) = modifiers {
|
||||||
|
@ -147,7 +147,7 @@ pub enum MenuItem {
|
||||||
|
|
||||||
/// Represents a Separator. It's useful nonetheless for
|
/// Represents a Separator. It's useful nonetheless for
|
||||||
/// separating out pieces of the `NSMenu` structure.
|
/// separating out pieces of the `NSMenu` structure.
|
||||||
Separator
|
Separator,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MenuItem {
|
impl MenuItem {
|
||||||
|
@ -178,7 +178,7 @@ impl MenuItem {
|
||||||
"Hide Others",
|
"Hide Others",
|
||||||
Some("h"),
|
Some("h"),
|
||||||
Some(sel!(hide:)),
|
Some(sel!(hide:)),
|
||||||
Some(&[EventModifierFlag::Command, EventModifierFlag::Option])
|
Some(&[EventModifierFlag::Command, EventModifierFlag::Option]),
|
||||||
),
|
),
|
||||||
|
|
||||||
Self::ShowAll => make_menu_item("Show All", None, Some(sel!(unhideAllApplications:)), None),
|
Self::ShowAll => make_menu_item("Show All", None, Some(sel!(unhideAllApplications:)), None),
|
||||||
|
@ -195,7 +195,7 @@ impl MenuItem {
|
||||||
"Enter Full Screen",
|
"Enter Full Screen",
|
||||||
Some("f"),
|
Some("f"),
|
||||||
Some(sel!(toggleFullScreen:)),
|
Some(sel!(toggleFullScreen:)),
|
||||||
Some(&[EventModifierFlag::Command, EventModifierFlag::Control])
|
Some(&[EventModifierFlag::Command, EventModifierFlag::Control]),
|
||||||
),
|
),
|
||||||
|
|
||||||
Self::Minimize => make_menu_item("Minimize", Some("m"), Some(sel!(performMiniaturize:)), None),
|
Self::Minimize => make_menu_item("Minimize", Some("m"), Some(sel!(performMiniaturize:)), None),
|
||||||
|
@ -205,14 +205,14 @@ impl MenuItem {
|
||||||
"Toggle Sidebar",
|
"Toggle Sidebar",
|
||||||
Some("s"),
|
Some("s"),
|
||||||
Some(sel!(toggleSidebar:)),
|
Some(sel!(toggleSidebar:)),
|
||||||
Some(&[EventModifierFlag::Command, EventModifierFlag::Option])
|
Some(&[EventModifierFlag::Command, EventModifierFlag::Option]),
|
||||||
),
|
),
|
||||||
|
|
||||||
Self::Separator => {
|
Self::Separator => {
|
||||||
let cls = class!(NSMenuItem);
|
let cls = class!(NSMenuItem);
|
||||||
let separator: id = msg_send![cls, separatorItem];
|
let separator: id = msg_send![cls, separatorItem];
|
||||||
Id::from_ptr(separator)
|
Id::from_ptr(separator)
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,33 +75,42 @@ impl Menu {
|
||||||
/// applications, as expected.
|
/// applications, as expected.
|
||||||
pub fn standard() -> Vec<Menu> {
|
pub fn standard() -> Vec<Menu> {
|
||||||
vec![
|
vec![
|
||||||
Menu::new("", vec![
|
Menu::new(
|
||||||
MenuItem::Services,
|
"",
|
||||||
MenuItem::Separator,
|
vec![
|
||||||
MenuItem::Hide,
|
MenuItem::Services,
|
||||||
MenuItem::HideOthers,
|
MenuItem::Separator,
|
||||||
MenuItem::ShowAll,
|
MenuItem::Hide,
|
||||||
MenuItem::Separator,
|
MenuItem::HideOthers,
|
||||||
MenuItem::Quit,
|
MenuItem::ShowAll,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::Quit,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("File", vec![MenuItem::CloseWindow]),
|
Menu::new("File", vec![MenuItem::CloseWindow]),
|
||||||
Menu::new("Edit", vec![
|
Menu::new(
|
||||||
MenuItem::Undo,
|
"Edit",
|
||||||
MenuItem::Redo,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Undo,
|
||||||
MenuItem::Cut,
|
MenuItem::Redo,
|
||||||
MenuItem::Copy,
|
MenuItem::Separator,
|
||||||
MenuItem::Paste,
|
MenuItem::Cut,
|
||||||
MenuItem::Separator,
|
MenuItem::Copy,
|
||||||
MenuItem::SelectAll,
|
MenuItem::Paste,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::SelectAll,
|
||||||
|
],
|
||||||
|
),
|
||||||
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
||||||
Menu::new("Window", vec![
|
Menu::new(
|
||||||
MenuItem::Minimize,
|
"Window",
|
||||||
MenuItem::Zoom,
|
vec![
|
||||||
MenuItem::Separator,
|
MenuItem::Minimize,
|
||||||
MenuItem::new("Bring All to Front"),
|
MenuItem::Zoom,
|
||||||
]),
|
MenuItem::Separator,
|
||||||
|
MenuItem::new("Bring All to Front"),
|
||||||
|
],
|
||||||
|
),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub enum PrintResponse {
|
||||||
/// For when the result of printing cannot be returned immediately (e.g, if printing causes a sheet to appear).
|
/// For when the result of printing cannot be returned immediately (e.g, if printing causes a sheet to appear).
|
||||||
/// If your method returns PrintResponse::ReplyLater it must always invoke `App::reply_to_open_or_print()` when the
|
/// If your method returns PrintResponse::ReplyLater it must always invoke `App::reply_to_open_or_print()` when the
|
||||||
/// entire print operation has been completed, successfully or not.
|
/// entire print operation has been completed, successfully or not.
|
||||||
ReplyLater
|
ReplyLater,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PrintResponse> for NSUInteger {
|
impl From<PrintResponse> for NSUInteger {
|
||||||
|
@ -26,7 +26,7 @@ impl From<PrintResponse> for NSUInteger {
|
||||||
PrintResponse::Cancelled => 0,
|
PrintResponse::Cancelled => 0,
|
||||||
PrintResponse::Success => 1,
|
PrintResponse::Success => 1,
|
||||||
PrintResponse::Failure => 3,
|
PrintResponse::Failure => 3,
|
||||||
PrintResponse::ReplyLater => 2
|
PrintResponse::ReplyLater => 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,14 @@ use crate::foundation::id;
|
||||||
/// application/user.
|
/// application/user.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PrintSettings {
|
pub struct PrintSettings {
|
||||||
pub inner: ShareId<Object>
|
pub inner: ShareId<Object>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrintSettings {
|
impl PrintSettings {
|
||||||
/// Internal method, constructs a wrapper around the backing `NSDictionary` print settings.
|
/// Internal method, constructs a wrapper around the backing `NSDictionary` print settings.
|
||||||
pub(crate) fn with_inner(inner: id) -> Self {
|
pub(crate) fn with_inner(inner: id) -> Self {
|
||||||
PrintSettings {
|
PrintSettings {
|
||||||
inner: unsafe { ShareId::from_ptr(inner) }
|
inner: unsafe { ShareId::from_ptr(inner) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,19 +73,19 @@ pub(crate) fn register_toolbar_class<T: ToolbarDelegate>(instance: &T) -> *const
|
||||||
// Add callback methods
|
// Add callback methods
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(toolbarAllowedItemIdentifiers:),
|
sel!(toolbarAllowedItemIdentifiers:),
|
||||||
allowed_item_identifiers::<T> as extern "C" fn(&Object, _, _) -> id
|
allowed_item_identifiers::<T> as extern "C" fn(&Object, _, _) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(toolbarDefaultItemIdentifiers:),
|
sel!(toolbarDefaultItemIdentifiers:),
|
||||||
default_item_identifiers::<T> as extern "C" fn(&Object, _, _) -> id
|
default_item_identifiers::<T> as extern "C" fn(&Object, _, _) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(toolbarSelectableItemIdentifiers:),
|
sel!(toolbarSelectableItemIdentifiers:),
|
||||||
selectable_item_identifiers::<T> as extern "C" fn(&Object, _, _) -> id
|
selectable_item_identifiers::<T> as extern "C" fn(&Object, _, _) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:),
|
sel!(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:),
|
||||||
item_for_identifier::<T> as extern "C" fn(&Object, _, _, _, _) -> id
|
item_for_identifier::<T> as extern "C" fn(&Object, _, _, _, _) -> id,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub enum ToolbarDisplayMode {
|
||||||
IconOnly,
|
IconOnly,
|
||||||
|
|
||||||
/// Show label only.
|
/// Show label only.
|
||||||
LabelOnly
|
LabelOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ToolbarDisplayMode> for NSUInteger {
|
impl From<ToolbarDisplayMode> for NSUInteger {
|
||||||
|
@ -24,7 +24,7 @@ impl From<ToolbarDisplayMode> for NSUInteger {
|
||||||
ToolbarDisplayMode::Default => 0,
|
ToolbarDisplayMode::Default => 0,
|
||||||
ToolbarDisplayMode::IconAndLabel => 1,
|
ToolbarDisplayMode::IconAndLabel => 1,
|
||||||
ToolbarDisplayMode::IconOnly => 2,
|
ToolbarDisplayMode::IconOnly => 2,
|
||||||
ToolbarDisplayMode::LabelOnly => 3
|
ToolbarDisplayMode::LabelOnly => 3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ pub enum ItemIdentifier {
|
||||||
/// Note that this API was introduced in Big Sur (11.0), and you may need to check against this
|
/// Note that this API was introduced in Big Sur (11.0), and you may need to check against this
|
||||||
/// at runtime to ensure behavior is appropriate on older OS versions (if you support them).
|
/// at runtime to ensure behavior is appropriate on older OS versions (if you support them).
|
||||||
///
|
///
|
||||||
SidebarTracker
|
SidebarTracker,
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -106,7 +106,7 @@ impl ItemIdentifier {
|
||||||
|
|
||||||
// This ensures that the framework compiles and runs on 10.15.7 and lower; it will
|
// This ensures that the framework compiles and runs on 10.15.7 and lower; it will
|
||||||
// not actually work on anything except 11.0+. Use a runtime check to be safe.
|
// not actually work on anything except 11.0+. Use a runtime check to be safe.
|
||||||
Self::SidebarTracker => NSString::no_copy("NSToolbarSidebarTrackingSeparatorItemIdentifier").into()
|
Self::SidebarTracker => NSString::no_copy("NSToolbarSidebarTrackingSeparatorItemIdentifier").into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ pub enum ToolbarSizeMode {
|
||||||
Regular,
|
Regular,
|
||||||
|
|
||||||
/// The small size mode.
|
/// The small size mode.
|
||||||
Small
|
Small,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ToolbarSizeMode> for NSUInteger {
|
impl From<ToolbarSizeMode> for NSUInteger {
|
||||||
|
@ -130,7 +130,7 @@ impl From<ToolbarSizeMode> for NSUInteger {
|
||||||
match mode {
|
match mode {
|
||||||
ToolbarSizeMode::Default => 0,
|
ToolbarSizeMode::Default => 0,
|
||||||
ToolbarSizeMode::Regular => 1,
|
ToolbarSizeMode::Regular => 1,
|
||||||
ToolbarSizeMode::Small => 2
|
ToolbarSizeMode::Small => 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub struct ToolbarItem {
|
||||||
pub objc: Id<Object>,
|
pub objc: Id<Object>,
|
||||||
pub button: Option<Button>,
|
pub button: Option<Button>,
|
||||||
pub image: Option<Image>,
|
pub image: Option<Image>,
|
||||||
handler: Option<TargetActionHandler>
|
handler: Option<TargetActionHandler>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToolbarItem {
|
impl ToolbarItem {
|
||||||
|
@ -43,7 +43,7 @@ impl ToolbarItem {
|
||||||
objc,
|
objc,
|
||||||
button: None,
|
button: None,
|
||||||
image: None,
|
image: None,
|
||||||
handler: None
|
handler: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ impl ToolbarItem {
|
||||||
objc: unsafe { Id::from_retained_ptr(item) },
|
objc: unsafe { Id::from_retained_ptr(item) },
|
||||||
button: None,
|
button: None,
|
||||||
image: None,
|
image: None,
|
||||||
handler: None
|
handler: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,12 @@ pub struct Toolbar<T = ()> {
|
||||||
pub objc_delegate: ShareId<Object>,
|
pub objc_delegate: ShareId<Object>,
|
||||||
|
|
||||||
/// The user supplied delegate.
|
/// The user supplied delegate.
|
||||||
pub delegate: Option<Box<T>>
|
pub delegate: Option<Box<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Toolbar<T>
|
impl<T> Toolbar<T>
|
||||||
where
|
where
|
||||||
T: ToolbarDelegate + 'static
|
T: ToolbarDelegate + 'static,
|
||||||
{
|
{
|
||||||
/// Creates a new `NSToolbar` instance, configures it appropriately, sets up the delegate
|
/// Creates a new `NSToolbar` instance, configures it appropriately, sets up the delegate
|
||||||
/// chain, and retains it all.
|
/// chain, and retains it all.
|
||||||
|
@ -69,14 +69,14 @@ where
|
||||||
objc: objc.clone(),
|
objc: objc.clone(),
|
||||||
objc_delegate: objc_delegate.clone(),
|
objc_delegate: objc_delegate.clone(),
|
||||||
identifier: identifier.clone(),
|
identifier: identifier.clone(),
|
||||||
delegate: None
|
delegate: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
Toolbar {
|
Toolbar {
|
||||||
identifier,
|
identifier,
|
||||||
objc,
|
objc,
|
||||||
objc_delegate,
|
objc_delegate,
|
||||||
delegate: Some(delegate)
|
delegate: Some(delegate),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ impl<T> fmt::Debug for Toolbar<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let delegate = match &self.delegate {
|
let delegate = match &self.delegate {
|
||||||
Some(d) => format!("Some({:p})", d),
|
Some(d) => format!("Some({:p})", d),
|
||||||
None => "None".to_string()
|
None => "None".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
f.debug_struct("Toolbar")
|
f.debug_struct("Toolbar")
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern "C" fn should_close<T: WindowDelegate>(this: &Object, _: Sel, _: id) -> B
|
||||||
|
|
||||||
match window.should_close() {
|
match window.should_close() {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ extern "C" fn will_resize<T: WindowDelegate>(this: &Object, _: Sel, _: id, size:
|
||||||
|
|
||||||
CGSize {
|
CGSize {
|
||||||
width: s.0 as CGFloat,
|
width: s.0 as CGFloat,
|
||||||
height: s.1 as CGFloat
|
height: s.1 as CGFloat,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ extern "C" fn content_size_for_full_screen<T: WindowDelegate>(this: &Object, _:
|
||||||
|
|
||||||
CGSize {
|
CGSize {
|
||||||
width: width as CGFloat,
|
width: width as CGFloat,
|
||||||
height: height as CGFloat
|
height: height as CGFloat,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,71 +234,71 @@ pub(crate) fn register_window_class_with_delegate<T: WindowDelegate>(instance: &
|
||||||
// NSWindowDelegate methods
|
// NSWindowDelegate methods
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowShouldClose:),
|
sel!(windowShouldClose:),
|
||||||
should_close::<T> as extern "C" fn(&Object, _, _) -> BOOL
|
should_close::<T> as extern "C" fn(&Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(sel!(windowWillClose:), will_close::<T> as extern "C" fn(&Object, _, _));
|
decl.add_method(sel!(windowWillClose:), will_close::<T> as extern "C" fn(&Object, _, _));
|
||||||
|
|
||||||
// Sizing
|
// Sizing
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowWillResize:toSize:),
|
sel!(windowWillResize:toSize:),
|
||||||
will_resize::<T> as extern "C" fn(&Object, _, _, CGSize) -> CGSize
|
will_resize::<T> as extern "C" fn(&Object, _, _, CGSize) -> CGSize,
|
||||||
);
|
);
|
||||||
decl.add_method(sel!(windowDidResize:), did_resize::<T> as extern "C" fn(&Object, _, _));
|
decl.add_method(sel!(windowDidResize:), did_resize::<T> as extern "C" fn(&Object, _, _));
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowWillStartLiveResize:),
|
sel!(windowWillStartLiveResize:),
|
||||||
will_start_live_resize::<T> as extern "C" fn(&Object, _, _)
|
will_start_live_resize::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidEndLiveResize:),
|
sel!(windowDidEndLiveResize:),
|
||||||
did_end_live_resize::<T> as extern "C" fn(&Object, _, _)
|
did_end_live_resize::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Minimizing
|
// Minimizing
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowWillMiniaturize:),
|
sel!(windowWillMiniaturize:),
|
||||||
will_miniaturize::<T> as extern "C" fn(&Object, _, _)
|
will_miniaturize::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidMiniaturize:),
|
sel!(windowDidMiniaturize:),
|
||||||
did_miniaturize::<T> as extern "C" fn(&Object, _, _)
|
did_miniaturize::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidDeminiaturize:),
|
sel!(windowDidDeminiaturize:),
|
||||||
did_deminiaturize::<T> as extern "C" fn(&Object, _, _)
|
did_deminiaturize::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Full Screen
|
// Full Screen
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(window:willUseFullScreenContentSize:),
|
sel!(window:willUseFullScreenContentSize:),
|
||||||
content_size_for_full_screen::<T> as extern "C" fn(&Object, _, _, CGSize) -> CGSize
|
content_size_for_full_screen::<T> as extern "C" fn(&Object, _, _, CGSize) -> CGSize,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(window:willUseFullScreenPresentationOptions:),
|
sel!(window:willUseFullScreenPresentationOptions:),
|
||||||
options_for_full_screen::<T> as extern "C" fn(&Object, _, _, NSUInteger) -> NSUInteger
|
options_for_full_screen::<T> as extern "C" fn(&Object, _, _, NSUInteger) -> NSUInteger,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowWillEnterFullScreen:),
|
sel!(windowWillEnterFullScreen:),
|
||||||
will_enter_full_screen::<T> as extern "C" fn(&Object, _, _)
|
will_enter_full_screen::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidEnterFullScreen:),
|
sel!(windowDidEnterFullScreen:),
|
||||||
did_enter_full_screen::<T> as extern "C" fn(&Object, _, _)
|
did_enter_full_screen::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowWillExitFullScreen:),
|
sel!(windowWillExitFullScreen:),
|
||||||
will_exit_full_screen::<T> as extern "C" fn(&Object, _, _)
|
will_exit_full_screen::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidExitFullScreen:),
|
sel!(windowDidExitFullScreen:),
|
||||||
did_exit_full_screen::<T> as extern "C" fn(&Object, _, _)
|
did_exit_full_screen::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidFailToEnterFullScreen:),
|
sel!(windowDidFailToEnterFullScreen:),
|
||||||
did_fail_to_enter_full_screen::<T> as extern "C" fn(&Object, _, _)
|
did_fail_to_enter_full_screen::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidFailToExitFullScreen:),
|
sel!(windowDidFailToExitFullScreen:),
|
||||||
did_fail_to_exit_full_screen::<T> as extern "C" fn(&Object, _, _)
|
did_fail_to_exit_full_screen::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Key status
|
// Key status
|
||||||
|
@ -308,11 +308,11 @@ pub(crate) fn register_window_class_with_delegate<T: WindowDelegate>(instance: &
|
||||||
// Main status
|
// Main status
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidBecomeMain:),
|
sel!(windowDidBecomeMain:),
|
||||||
did_become_main::<T> as extern "C" fn(&Object, _, _)
|
did_become_main::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidResignMain:),
|
sel!(windowDidResignMain:),
|
||||||
did_resign_main::<T> as extern "C" fn(&Object, _, _)
|
did_resign_main::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Moving Windows
|
// Moving Windows
|
||||||
|
@ -320,21 +320,21 @@ pub(crate) fn register_window_class_with_delegate<T: WindowDelegate>(instance: &
|
||||||
decl.add_method(sel!(windowDidMove:), did_move::<T> as extern "C" fn(&Object, _, _));
|
decl.add_method(sel!(windowDidMove:), did_move::<T> as extern "C" fn(&Object, _, _));
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidChangeScreen:),
|
sel!(windowDidChangeScreen:),
|
||||||
did_change_screen::<T> as extern "C" fn(&Object, _, _)
|
did_change_screen::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidChangeScreenProfile:),
|
sel!(windowDidChangeScreenProfile:),
|
||||||
did_change_screen_profile::<T> as extern "C" fn(&Object, _, _)
|
did_change_screen_profile::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidChangeBackingProperties:),
|
sel!(windowDidChangeBackingProperties:),
|
||||||
did_change_backing_properties::<T> as extern "C" fn(&Object, _, _)
|
did_change_backing_properties::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Random
|
// Random
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(windowDidChangeOcclusionState:),
|
sel!(windowDidChangeOcclusionState:),
|
||||||
did_change_occlusion_state::<T> as extern "C" fn(&Object, _, _)
|
did_change_occlusion_state::<T> as extern "C" fn(&Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(sel!(windowDidExpose:), did_expose::<T> as extern "C" fn(&Object, _, _));
|
decl.add_method(sel!(windowDidExpose:), did_expose::<T> as extern "C" fn(&Object, _, _));
|
||||||
decl.add_method(sel!(windowDidUpdate:), did_update::<T> as extern "C" fn(&Object, _, _));
|
decl.add_method(sel!(windowDidUpdate:), did_update::<T> as extern "C" fn(&Object, _, _));
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub struct WindowConfig {
|
||||||
/// for other variants.
|
/// for other variants.
|
||||||
///
|
///
|
||||||
/// This setting is notably important for Preferences windows.
|
/// This setting is notably important for Preferences windows.
|
||||||
pub toolbar_style: WindowToolbarStyle
|
pub toolbar_style: WindowToolbarStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowConfig {
|
impl Default for WindowConfig {
|
||||||
|
@ -41,7 +41,7 @@ impl Default for WindowConfig {
|
||||||
style: 0,
|
style: 0,
|
||||||
initial_dimensions: Rect::new(100., 100., 1024., 768.),
|
initial_dimensions: Rect::new(100., 100., 1024., 768.),
|
||||||
defer: true,
|
defer: true,
|
||||||
toolbar_style: WindowToolbarStyle::Automatic
|
toolbar_style: WindowToolbarStyle::Automatic,
|
||||||
};
|
};
|
||||||
|
|
||||||
config.set_styles(&[
|
config.set_styles(&[
|
||||||
|
@ -50,7 +50,7 @@ impl Default for WindowConfig {
|
||||||
WindowStyle::UnifiedTitleAndToolbar,
|
WindowStyle::UnifiedTitleAndToolbar,
|
||||||
WindowStyle::Closable,
|
WindowStyle::Closable,
|
||||||
WindowStyle::Titled,
|
WindowStyle::Titled,
|
||||||
WindowStyle::FullSizeContentView
|
WindowStyle::FullSizeContentView,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
config
|
config
|
||||||
|
|
|
@ -48,12 +48,12 @@ pub struct WindowController<T> {
|
||||||
pub objc: Id<Object>,
|
pub objc: Id<Object>,
|
||||||
|
|
||||||
/// The underlying `Window` that this controller wraps.
|
/// The underlying `Window` that this controller wraps.
|
||||||
pub window: Window<T>
|
pub window: Window<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> WindowController<T>
|
impl<T> WindowController<T>
|
||||||
where
|
where
|
||||||
T: WindowDelegate + 'static
|
T: WindowDelegate + 'static,
|
||||||
{
|
{
|
||||||
/// Allocates and configures an `NSWindowController` in the Objective-C/Cocoa runtime that maps over
|
/// Allocates and configures an `NSWindowController` in the Objective-C/Cocoa runtime that maps over
|
||||||
/// to your supplied delegate.
|
/// to your supplied delegate.
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub enum WindowStyle {
|
||||||
NonActivatingPanel,
|
NonActivatingPanel,
|
||||||
|
|
||||||
/// A HUD window.
|
/// A HUD window.
|
||||||
HUDWindow
|
HUDWindow,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<WindowStyle> for NSUInteger {
|
impl From<WindowStyle> for NSUInteger {
|
||||||
|
@ -56,7 +56,7 @@ impl From<WindowStyle> for NSUInteger {
|
||||||
WindowStyle::Utility => 1 << 4,
|
WindowStyle::Utility => 1 << 4,
|
||||||
WindowStyle::DocModalWindow => 1 << 6,
|
WindowStyle::DocModalWindow => 1 << 6,
|
||||||
WindowStyle::NonActivatingPanel => 1 << 7,
|
WindowStyle::NonActivatingPanel => 1 << 7,
|
||||||
WindowStyle::HUDWindow => 1 << 13
|
WindowStyle::HUDWindow => 1 << 13,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ impl From<&WindowStyle> for NSUInteger {
|
||||||
WindowStyle::Utility => 1 << 4,
|
WindowStyle::Utility => 1 << 4,
|
||||||
WindowStyle::DocModalWindow => 1 << 6,
|
WindowStyle::DocModalWindow => 1 << 6,
|
||||||
WindowStyle::NonActivatingPanel => 1 << 7,
|
WindowStyle::NonActivatingPanel => 1 << 7,
|
||||||
WindowStyle::HUDWindow => 1 << 13
|
WindowStyle::HUDWindow => 1 << 13,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,14 +87,14 @@ pub enum TitleVisibility {
|
||||||
Visible,
|
Visible,
|
||||||
|
|
||||||
/// Title is hidden.
|
/// Title is hidden.
|
||||||
Hidden
|
Hidden,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TitleVisibility> for NSInteger {
|
impl From<TitleVisibility> for NSInteger {
|
||||||
fn from(visibility: TitleVisibility) -> Self {
|
fn from(visibility: TitleVisibility) -> Self {
|
||||||
match visibility {
|
match visibility {
|
||||||
TitleVisibility::Visible => 0,
|
TitleVisibility::Visible => 0,
|
||||||
TitleVisibility::Hidden => 1
|
TitleVisibility::Hidden => 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ pub enum WindowToolbarStyle {
|
||||||
|
|
||||||
/// The Big Sur (11.0+) style, but more compact. Toolbar flushes up against the title and
|
/// The Big Sur (11.0+) style, but more compact. Toolbar flushes up against the title and
|
||||||
/// spacing is reduced.
|
/// spacing is reduced.
|
||||||
UnifiedCompact
|
UnifiedCompact,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<WindowToolbarStyle> for NSUInteger {
|
impl From<WindowToolbarStyle> for NSUInteger {
|
||||||
|
@ -130,7 +130,7 @@ impl From<WindowToolbarStyle> for NSUInteger {
|
||||||
WindowToolbarStyle::Expanded => 1,
|
WindowToolbarStyle::Expanded => 1,
|
||||||
WindowToolbarStyle::Preferences => 2,
|
WindowToolbarStyle::Preferences => 2,
|
||||||
WindowToolbarStyle::Unified => 3,
|
WindowToolbarStyle::Unified => 3,
|
||||||
WindowToolbarStyle::UnifiedCompact => 4
|
WindowToolbarStyle::UnifiedCompact => 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub struct Window<T = ()> {
|
||||||
pub objc: ShareId<Object>,
|
pub objc: ShareId<Object>,
|
||||||
|
|
||||||
/// A delegate for this window.
|
/// A delegate for this window.
|
||||||
pub delegate: Option<Box<T>>
|
pub delegate: Option<Box<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Window {
|
impl Default for Window {
|
||||||
|
@ -109,14 +109,14 @@ impl Window {
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
objc: objc,
|
objc: objc,
|
||||||
delegate: None
|
delegate: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Window<T>
|
impl<T> Window<T>
|
||||||
where
|
where
|
||||||
T: WindowDelegate + 'static
|
T: WindowDelegate + 'static,
|
||||||
{
|
{
|
||||||
/// Constructs a new Window with a `config` and `delegate`. Using a `WindowDelegate` enables
|
/// Constructs a new Window with a `config` and `delegate`. Using a `WindowDelegate` enables
|
||||||
/// you to respond to window lifecycle events - visibility, movement, and so on. It also
|
/// you to respond to window lifecycle events - visibility, movement, and so on. It also
|
||||||
|
@ -176,13 +176,13 @@ where
|
||||||
{
|
{
|
||||||
(&mut delegate).did_load(Window {
|
(&mut delegate).did_load(Window {
|
||||||
delegate: None,
|
delegate: None,
|
||||||
objc: objc.clone()
|
objc: objc.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
objc: objc,
|
objc: objc,
|
||||||
delegate: Some(delegate)
|
delegate: Some(delegate),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,7 +462,7 @@ impl<T> Window<T> {
|
||||||
pub fn begin_sheet<F, W>(&self, window: &Window<W>, completion: F)
|
pub fn begin_sheet<F, W>(&self, window: &Window<W>, completion: F)
|
||||||
where
|
where
|
||||||
F: Fn() + Send + Sync + 'static,
|
F: Fn() + Send + Sync + 'static,
|
||||||
W: WindowDelegate + 'static
|
W: WindowDelegate + 'static,
|
||||||
{
|
{
|
||||||
let block = ConcreteBlock::new(move |_response: NSInteger| {
|
let block = ConcreteBlock::new(move |_response: NSInteger| {
|
||||||
completion();
|
completion();
|
||||||
|
@ -477,7 +477,7 @@ impl<T> Window<T> {
|
||||||
/// Closes a sheet.
|
/// Closes a sheet.
|
||||||
pub fn end_sheet<W>(&self, window: &Window<W>)
|
pub fn end_sheet<W>(&self, window: &Window<W>)
|
||||||
where
|
where
|
||||||
W: WindowDelegate + 'static
|
W: WindowDelegate + 'static,
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
let _: () = msg_send![&*self.objc, endSheet:&*window.objc];
|
let _: () = msg_send![&*self.objc, endSheet:&*window.objc];
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub enum BezelStyle {
|
||||||
|
|
||||||
/// Any style that's not known by this framework (e.g, if Apple
|
/// Any style that's not known by this framework (e.g, if Apple
|
||||||
/// introduces something new).
|
/// introduces something new).
|
||||||
Unknown(NSUInteger)
|
Unknown(NSUInteger),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
|
@ -66,7 +66,7 @@ impl From<BezelStyle> for NSUInteger {
|
||||||
BezelStyle::SmallSquare => 10,
|
BezelStyle::SmallSquare => 10,
|
||||||
BezelStyle::TexturedRounded => 11,
|
BezelStyle::TexturedRounded => 11,
|
||||||
BezelStyle::TexturedSquare => 8,
|
BezelStyle::TexturedSquare => 8,
|
||||||
BezelStyle::Unknown(i) => i
|
BezelStyle::Unknown(i) => i,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ impl From<NSUInteger> for BezelStyle {
|
||||||
10 => Self::SmallSquare,
|
10 => Self::SmallSquare,
|
||||||
11 => Self::TexturedRounded,
|
11 => Self::TexturedRounded,
|
||||||
8 => Self::TexturedSquare,
|
8 => Self::TexturedSquare,
|
||||||
i => Self::Unknown(i)
|
i => Self::Unknown(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ pub struct Button {
|
||||||
|
|
||||||
/// A pointer to the Objective-C runtime center Y layout constraint.
|
/// A pointer to the Objective-C runtime center Y layout constraint.
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
pub center_y: LayoutAnchorY
|
pub center_y: LayoutAnchorY,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Button {
|
impl Button {
|
||||||
|
@ -179,7 +179,7 @@ impl Button {
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(view),
|
center_y: LayoutAnchorY::center(view),
|
||||||
|
|
||||||
objc: ObjcProperty::retain(view)
|
objc: ObjcProperty::retain(view),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,14 +226,14 @@ impl Button {
|
||||||
/// button will fire.
|
/// button will fire.
|
||||||
pub fn set_key_equivalent<'a, K>(&self, key: K)
|
pub fn set_key_equivalent<'a, K>(&self, key: K)
|
||||||
where
|
where
|
||||||
K: Into<Key<'a>>
|
K: Into<Key<'a>>,
|
||||||
{
|
{
|
||||||
let key: Key<'a> = key.into();
|
let key: Key<'a> = key.into();
|
||||||
|
|
||||||
self.objc.with_mut(|obj| {
|
self.objc.with_mut(|obj| {
|
||||||
let keychar = match key {
|
let keychar = match key {
|
||||||
Key::Char(s) => NSString::new(s),
|
Key::Char(s) => NSString::new(s),
|
||||||
Key::Delete => NSString::new("\u{08}")
|
Key::Delete => NSString::new("\u{08}"),
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -9,14 +9,14 @@ use crate::foundation::id;
|
||||||
/// to, say, handle accepting an invite for a share.
|
/// to, say, handle accepting an invite for a share.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CKShareMetaData {
|
pub struct CKShareMetaData {
|
||||||
pub inner: ShareId<Object>
|
pub inner: ShareId<Object>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CKShareMetaData {
|
impl CKShareMetaData {
|
||||||
/// Internal method for wrapping a system-provided `CKShareMetaData` object.
|
/// Internal method for wrapping a system-provided `CKShareMetaData` object.
|
||||||
pub(crate) fn with_inner(object: id) -> Self {
|
pub(crate) fn with_inner(object: id) -> Self {
|
||||||
CKShareMetaData {
|
CKShareMetaData {
|
||||||
inner: unsafe { ShareId::from_ptr(object) }
|
inner: unsafe { ShareId::from_ptr(object) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ fn get_effective_color(this: &Object) -> id {
|
||||||
NSAppearanceNameAqua,
|
NSAppearanceNameAqua,
|
||||||
NSAppearanceNameAccessibilityHighContrastAqua,
|
NSAppearanceNameAccessibilityHighContrastAqua,
|
||||||
NSAppearanceNameDarkAqua,
|
NSAppearanceNameDarkAqua,
|
||||||
NSAppearanceNameAccessibilityHighContrastDarkAqua
|
NSAppearanceNameAccessibilityHighContrastDarkAqua,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let style: id = msg_send![appearance, bestMatchFromAppearancesWithNames:&*names];
|
let style: id = msg_send![appearance, bestMatchFromAppearancesWithNames:&*names];
|
||||||
|
@ -270,22 +270,22 @@ pub(crate) fn register_class() -> *const Class {
|
||||||
decl.add_method(sel!(colorSpace), color_space as extern "C" fn(&Object, _) -> id);
|
decl.add_method(sel!(colorSpace), color_space as extern "C" fn(&Object, _) -> id);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(colorUsingColorSpace:),
|
sel!(colorUsingColorSpace:),
|
||||||
color_using_color_space as extern "C" fn(&Object, _, id) -> id
|
color_using_color_space as extern "C" fn(&Object, _, id) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(sel!(colorSpaceName), color_space_name as extern "C" fn(&Object, _) -> id);
|
decl.add_method(sel!(colorSpaceName), color_space_name as extern "C" fn(&Object, _) -> id);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(colorUsingColorSpaceName:),
|
sel!(colorUsingColorSpaceName:),
|
||||||
color_using_color_space_name as extern "C" fn(&Object, _, id) -> id
|
color_using_color_space_name as extern "C" fn(&Object, _, id) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(numberOfComponents),
|
sel!(numberOfComponents),
|
||||||
number_of_components as extern "C" fn(&Object, _) -> NSInteger
|
number_of_components as extern "C" fn(&Object, _) -> NSInteger,
|
||||||
);
|
);
|
||||||
|
|
||||||
decl.add_method(sel!(getComponents:), get_components as extern "C" fn(&Object, _, CGFloat));
|
decl.add_method(sel!(getComponents:), get_components as extern "C" fn(&Object, _, CGFloat));
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(getRed:green:blue:alpha:),
|
sel!(getRed:green:blue:alpha:),
|
||||||
get_rgba as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat)
|
get_rgba as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat),
|
||||||
);
|
);
|
||||||
decl.add_method(sel!(redComponent), red_component as extern "C" fn(&Object, _) -> CGFloat);
|
decl.add_method(sel!(redComponent), red_component as extern "C" fn(&Object, _) -> CGFloat);
|
||||||
decl.add_method(sel!(greenComponent), green_component as extern "C" fn(&Object, _) -> CGFloat);
|
decl.add_method(sel!(greenComponent), green_component as extern "C" fn(&Object, _) -> CGFloat);
|
||||||
|
@ -294,36 +294,36 @@ pub(crate) fn register_class() -> *const Class {
|
||||||
decl.add_method(sel!(hueComponent), hue_component as extern "C" fn(&Object, _) -> CGFloat);
|
decl.add_method(sel!(hueComponent), hue_component as extern "C" fn(&Object, _) -> CGFloat);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(saturationComponent),
|
sel!(saturationComponent),
|
||||||
saturation_component as extern "C" fn(&Object, _) -> CGFloat
|
saturation_component as extern "C" fn(&Object, _) -> CGFloat,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(brightnessComponent),
|
sel!(brightnessComponent),
|
||||||
brightness_component as extern "C" fn(&Object, _) -> CGFloat
|
brightness_component as extern "C" fn(&Object, _) -> CGFloat,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(getHue:saturation:brightness:alpha:),
|
sel!(getHue:saturation:brightness:alpha:),
|
||||||
get_hsba as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat)
|
get_hsba as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat),
|
||||||
);
|
);
|
||||||
|
|
||||||
decl.add_method(sel!(whiteComponent), white_component as extern "C" fn(&Object, _) -> CGFloat);
|
decl.add_method(sel!(whiteComponent), white_component as extern "C" fn(&Object, _) -> CGFloat);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(getWhite:alpha:),
|
sel!(getWhite:alpha:),
|
||||||
get_white as extern "C" fn(&Object, _, CGFloat, CGFloat)
|
get_white as extern "C" fn(&Object, _, CGFloat, CGFloat),
|
||||||
);
|
);
|
||||||
|
|
||||||
decl.add_method(sel!(cyanComponent), cyan_component as extern "C" fn(&Object, _) -> CGFloat);
|
decl.add_method(sel!(cyanComponent), cyan_component as extern "C" fn(&Object, _) -> CGFloat);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(magentaComponent),
|
sel!(magentaComponent),
|
||||||
magenta_component as extern "C" fn(&Object, _) -> CGFloat
|
magenta_component as extern "C" fn(&Object, _) -> CGFloat,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(yellowComponent),
|
sel!(yellowComponent),
|
||||||
yellow_component as extern "C" fn(&Object, _) -> CGFloat
|
yellow_component as extern "C" fn(&Object, _) -> CGFloat,
|
||||||
);
|
);
|
||||||
decl.add_method(sel!(blackComponent), black_component as extern "C" fn(&Object, _) -> CGFloat);
|
decl.add_method(sel!(blackComponent), black_component as extern "C" fn(&Object, _) -> CGFloat);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(getCyan:magenta:yellow:black:alpha:),
|
sel!(getCyan:magenta:yellow:black:alpha:),
|
||||||
get_cmyk as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat, CGFloat)
|
get_cmyk as extern "C" fn(&Object, _, CGFloat, CGFloat, CGFloat, CGFloat, CGFloat),
|
||||||
);
|
);
|
||||||
|
|
||||||
decl.add_method(sel!(alphaComponent), alpha_component as extern "C" fn(&Object, _) -> CGFloat);
|
decl.add_method(sel!(alphaComponent), alpha_component as extern "C" fn(&Object, _) -> CGFloat);
|
||||||
|
@ -335,24 +335,24 @@ pub(crate) fn register_class() -> *const Class {
|
||||||
|
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(highlightWithLevel:),
|
sel!(highlightWithLevel:),
|
||||||
highlight_with_level as extern "C" fn(&Object, _, CGFloat) -> id
|
highlight_with_level as extern "C" fn(&Object, _, CGFloat) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(shadowWithLevel:),
|
sel!(shadowWithLevel:),
|
||||||
shadow_with_level as extern "C" fn(&Object, _, CGFloat) -> id
|
shadow_with_level as extern "C" fn(&Object, _, CGFloat) -> id,
|
||||||
);
|
);
|
||||||
|
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(colorWithAlphaComponent:),
|
sel!(colorWithAlphaComponent:),
|
||||||
color_with_alpha_component as extern "C" fn(&Object, _, CGFloat) -> id
|
color_with_alpha_component as extern "C" fn(&Object, _, CGFloat) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(blendedColorWithFraction:ofColor:),
|
sel!(blendedColorWithFraction:ofColor:),
|
||||||
blended_color as extern "C" fn(&Object, _, CGFloat, id) -> id
|
blended_color as extern "C" fn(&Object, _, CGFloat, id) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(colorWithSystemEffect:),
|
sel!(colorWithSystemEffect:),
|
||||||
color_with_system_effect as extern "C" fn(&Object, _, NSInteger) -> id
|
color_with_system_effect as extern "C" fn(&Object, _, NSInteger) -> id,
|
||||||
);
|
);
|
||||||
|
|
||||||
decl.add_ivar::<id>(AQUA_LIGHT_COLOR_NORMAL_CONTRAST);
|
decl.add_ivar::<id>(AQUA_LIGHT_COLOR_NORMAL_CONTRAST);
|
||||||
|
|
|
@ -31,7 +31,7 @@ mod appkit_dynamic_color;
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
use appkit_dynamic_color::{
|
use appkit_dynamic_color::{
|
||||||
AQUA_DARK_COLOR_HIGH_CONTRAST, AQUA_DARK_COLOR_NORMAL_CONTRAST, AQUA_LIGHT_COLOR_HIGH_CONTRAST,
|
AQUA_DARK_COLOR_HIGH_CONTRAST, AQUA_DARK_COLOR_NORMAL_CONTRAST, AQUA_LIGHT_COLOR_HIGH_CONTRAST,
|
||||||
AQUA_LIGHT_COLOR_NORMAL_CONTRAST
|
AQUA_LIGHT_COLOR_NORMAL_CONTRAST,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents a rendering style - dark mode or light mode.
|
/// Represents a rendering style - dark mode or light mode.
|
||||||
|
@ -45,7 +45,7 @@ pub enum Theme {
|
||||||
Light,
|
Light,
|
||||||
|
|
||||||
/// Dark mode.
|
/// Dark mode.
|
||||||
Dark
|
Dark,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the contrast level for a rendering context.
|
/// Represents the contrast level for a rendering context.
|
||||||
|
@ -55,7 +55,7 @@ pub enum Contrast {
|
||||||
Normal,
|
Normal,
|
||||||
|
|
||||||
/// The high contrast level for the system.
|
/// The high contrast level for the system.
|
||||||
High
|
High,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `Style` is passed to you when doing dynamic color calculations. You can opt to
|
/// A `Style` is passed to you when doing dynamic color calculations. You can opt to
|
||||||
|
@ -67,7 +67,7 @@ pub struct Style {
|
||||||
pub theme: Theme,
|
pub theme: Theme,
|
||||||
|
|
||||||
/// Represents the current contrast level for where this color may render.
|
/// Represents the current contrast level for where this color may render.
|
||||||
pub contrast: Contrast
|
pub contrast: Contrast,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a Color. You can create custom colors using the various
|
/// Represents a Color. You can create custom colors using the various
|
||||||
|
@ -235,7 +235,7 @@ pub enum Color {
|
||||||
|
|
||||||
/// The background color that should appear under a page per the system theme.
|
/// The background color that should appear under a page per the system theme.
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
MacOSUnderPageBackgroundColor
|
MacOSUnderPageBackgroundColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Color {
|
impl Color {
|
||||||
|
@ -337,7 +337,7 @@ impl Color {
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
pub fn dynamic<F>(handler: F) -> Self
|
pub fn dynamic<F>(handler: F) -> Self
|
||||||
where
|
where
|
||||||
F: Fn(Style) -> Color + 'static
|
F: Fn(Style) -> Color + 'static,
|
||||||
{
|
{
|
||||||
// It's *possible* that we shouldn't cache these up-front and let them be truly dynamically
|
// It's *possible* that we shouldn't cache these up-front and let them be truly dynamically
|
||||||
// allocated, but this is fine for now (and more predictable, even if perhaps wrong). I'm
|
// allocated, but this is fine for now (and more predictable, even if perhaps wrong). I'm
|
||||||
|
@ -350,7 +350,7 @@ impl Color {
|
||||||
(&mut *color).set_ivar(AQUA_LIGHT_COLOR_NORMAL_CONTRAST, {
|
(&mut *color).set_ivar(AQUA_LIGHT_COLOR_NORMAL_CONTRAST, {
|
||||||
let color: id = handler(Style {
|
let color: id = handler(Style {
|
||||||
theme: Theme::Light,
|
theme: Theme::Light,
|
||||||
contrast: Contrast::Normal
|
contrast: Contrast::Normal,
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ impl Color {
|
||||||
(&mut *color).set_ivar(AQUA_LIGHT_COLOR_HIGH_CONTRAST, {
|
(&mut *color).set_ivar(AQUA_LIGHT_COLOR_HIGH_CONTRAST, {
|
||||||
let color: id = handler(Style {
|
let color: id = handler(Style {
|
||||||
theme: Theme::Light,
|
theme: Theme::Light,
|
||||||
contrast: Contrast::High
|
contrast: Contrast::High,
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ impl Color {
|
||||||
(&mut *color).set_ivar(AQUA_DARK_COLOR_NORMAL_CONTRAST, {
|
(&mut *color).set_ivar(AQUA_DARK_COLOR_NORMAL_CONTRAST, {
|
||||||
let color: id = handler(Style {
|
let color: id = handler(Style {
|
||||||
theme: Theme::Dark,
|
theme: Theme::Dark,
|
||||||
contrast: Contrast::Normal
|
contrast: Contrast::Normal,
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ impl Color {
|
||||||
(&mut *color).set_ivar(AQUA_DARK_COLOR_HIGH_CONTRAST, {
|
(&mut *color).set_ivar(AQUA_DARK_COLOR_HIGH_CONTRAST, {
|
||||||
let color: id = handler(Style {
|
let color: id = handler(Style {
|
||||||
theme: Theme::Light,
|
theme: Theme::Light,
|
||||||
contrast: Contrast::Normal
|
contrast: Contrast::Normal,
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
|
@ -517,6 +517,6 @@ unsafe fn to_objc(obj: &Color) -> id {
|
||||||
Color::MacOSWindowBackgroundColor => system_color_with_fallback!(color, windowBackgroundColor, clearColor),
|
Color::MacOSWindowBackgroundColor => system_color_with_fallback!(color, windowBackgroundColor, clearColor),
|
||||||
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
Color::MacOSUnderPageBackgroundColor => system_color_with_fallback!(color, underPageBackgroundColor, clearColor)
|
Color::MacOSUnderPageBackgroundColor => system_color_with_fallback!(color, underPageBackgroundColor, clearColor),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub enum ControlSize {
|
||||||
/// A large control. Only available on macOS 11.0+.
|
/// A large control. Only available on macOS 11.0+.
|
||||||
/// If you pass this to the `set_control_size` method on the `Control` trait, it will
|
/// If you pass this to the `set_control_size` method on the `Control` trait, it will
|
||||||
/// transparently map to `Regular` on 10.15 and below.
|
/// transparently map to `Regular` on 10.15 and below.
|
||||||
Large
|
Large,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait that view wrappers must conform to. Enables managing the subview tree.
|
/// A trait that view wrappers must conform to. Enables managing the subview tree.
|
||||||
|
@ -44,8 +44,8 @@ pub trait Control: ObjcAccess {
|
||||||
|
|
||||||
ControlSize::Large => match crate::utils::os::is_minimum_version(11) {
|
ControlSize::Large => match crate::utils::os::is_minimum_version(11) {
|
||||||
true => 3,
|
true => 3,
|
||||||
false => 0
|
false => 0,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
self.with_backing_obj_mut(|obj| unsafe {
|
self.with_backing_obj_mut(|obj| unsafe {
|
||||||
|
|
|
@ -213,7 +213,7 @@ impl UserDefaults {
|
||||||
println!("Unexpected code type found: {}", _x);
|
println!("Unexpected code type found: {}", _x);
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub enum Value {
|
||||||
|
|
||||||
/// Represents Data (bytes). You can use this to store arbitrary things that aren't supported
|
/// Represents Data (bytes). You can use this to store arbitrary things that aren't supported
|
||||||
/// above. You're responsible for moving things back and forth to the necessary types.
|
/// above. You're responsible for moving things back and forth to the necessary types.
|
||||||
Data(Vec<u8>)
|
Data(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Value {
|
impl Value {
|
||||||
|
@ -36,7 +36,7 @@ impl Value {
|
||||||
pub fn is_boolean(&self) -> bool {
|
pub fn is_boolean(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Value::Bool(_) => true,
|
Value::Bool(_) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ impl Value {
|
||||||
pub fn as_bool(&self) -> Option<bool> {
|
pub fn as_bool(&self) -> Option<bool> {
|
||||||
match self {
|
match self {
|
||||||
Value::Bool(v) => Some(*v),
|
Value::Bool(v) => Some(*v),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl Value {
|
||||||
pub fn is_string(&self) -> bool {
|
pub fn is_string(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Value::String(_) => true,
|
Value::String(_) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ impl Value {
|
||||||
pub fn as_str(&self) -> Option<&str> {
|
pub fn as_str(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
Value::String(s) => Some(s),
|
Value::String(s) => Some(s),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ impl Value {
|
||||||
pub fn is_integer(&self) -> bool {
|
pub fn is_integer(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Value::Integer(_) => true,
|
Value::Integer(_) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ impl Value {
|
||||||
pub fn as_i32(&self) -> Option<i32> {
|
pub fn as_i32(&self) -> Option<i32> {
|
||||||
match self {
|
match self {
|
||||||
Value::Integer(i) => Some(*i as i32),
|
Value::Integer(i) => Some(*i as i32),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ impl Value {
|
||||||
pub fn as_i64(&self) -> Option<i64> {
|
pub fn as_i64(&self) -> Option<i64> {
|
||||||
match self {
|
match self {
|
||||||
Value::Integer(i) => Some(*i as i64),
|
Value::Integer(i) => Some(*i as i64),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ impl Value {
|
||||||
pub fn is_float(&self) -> bool {
|
pub fn is_float(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Value::Float(_) => true,
|
Value::Float(_) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ impl Value {
|
||||||
pub fn as_f32(&self) -> Option<f32> {
|
pub fn as_f32(&self) -> Option<f32> {
|
||||||
match self {
|
match self {
|
||||||
Value::Float(f) => Some(*f as f32),
|
Value::Float(f) => Some(*f as f32),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ impl Value {
|
||||||
pub fn as_f64(&self) -> Option<f64> {
|
pub fn as_f64(&self) -> Option<f64> {
|
||||||
match self {
|
match self {
|
||||||
Value::Float(f) => Some(*f as f64),
|
Value::Float(f) => Some(*f as f64),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ impl Value {
|
||||||
pub fn is_data(&self) -> bool {
|
pub fn is_data(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Value::Data(_) => true,
|
Value::Data(_) => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ impl Value {
|
||||||
pub fn as_data(&self) -> Option<&[u8]> {
|
pub fn as_data(&self) -> Option<&[u8]> {
|
||||||
match self {
|
match self {
|
||||||
Value::Data(data) => Some(data),
|
Value::Data(data) => Some(data),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,14 +140,14 @@ impl From<Value> for id {
|
||||||
Value::String(s) => NSString::new(&s).into(),
|
Value::String(s) => NSString::new(&s).into(),
|
||||||
Value::Float(f) => NSNumber::float(f).into(),
|
Value::Float(f) => NSNumber::float(f).into(),
|
||||||
Value::Integer(i) => NSNumber::integer(i).into(),
|
Value::Integer(i) => NSNumber::integer(i).into(),
|
||||||
Value::Data(data) => NSData::new(data).into()
|
Value::Data(data) => NSData::new(data).into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K> From<HashMap<K, Value>> for NSMutableDictionary
|
impl<K> From<HashMap<K, Value>> for NSMutableDictionary
|
||||||
where
|
where
|
||||||
K: AsRef<str>
|
K: AsRef<str>,
|
||||||
{
|
{
|
||||||
/// Translates a `HashMap` of `Value`s into an `NSDictionary`.
|
/// Translates a `HashMap` of `Value`s into an `NSDictionary`.
|
||||||
fn from(map: HashMap<K, Value>) -> Self {
|
fn from(map: HashMap<K, Value>) -> Self {
|
||||||
|
|
|
@ -31,9 +31,9 @@ pub enum DragOperation {
|
||||||
Move,
|
Move,
|
||||||
|
|
||||||
/// The data can be deleted.
|
/// The data can be deleted.
|
||||||
Delete // All of the above.
|
Delete, // All of the above.
|
||||||
// @TODO: NSUIntegerMax, a tricky beast
|
// @TODO: NSUIntegerMax, a tricky beast
|
||||||
// Every
|
// Every
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DragOperation> for NSUInteger {
|
impl From<DragOperation> for NSUInteger {
|
||||||
|
@ -45,7 +45,7 @@ impl From<DragOperation> for NSUInteger {
|
||||||
DragOperation::Generic => 4,
|
DragOperation::Generic => 4,
|
||||||
DragOperation::Private => 8,
|
DragOperation::Private => 8,
|
||||||
DragOperation::Move => 16,
|
DragOperation::Move => 16,
|
||||||
DragOperation::Delete => 32
|
DragOperation::Delete => 32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl From<DragOperation> for NSUInteger {
|
||||||
/// this only provides getters - merely a Rust-y way to grab what you need.
|
/// this only provides getters - merely a Rust-y way to grab what you need.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct DragInfo {
|
pub struct DragInfo {
|
||||||
pub info: ShareId<Object>
|
pub info: ShareId<Object>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DragInfo {
|
impl DragInfo {
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub struct Error {
|
||||||
pub domain: String,
|
pub domain: String,
|
||||||
|
|
||||||
/// Maps over to `[NSError localizedDescription]`.
|
/// Maps over to `[NSError localizedDescription]`.
|
||||||
pub description: String
|
pub description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
@ -42,7 +42,7 @@ impl Error {
|
||||||
Error {
|
Error {
|
||||||
code,
|
code,
|
||||||
domain: domain.to_string(),
|
domain: domain.to_string(),
|
||||||
description: description.to_string()
|
description: description.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub enum EventModifierFlag {
|
||||||
Command,
|
Command,
|
||||||
|
|
||||||
/// Device independent flags mask.
|
/// Device independent flags mask.
|
||||||
DeviceIndependentFlagsMask
|
DeviceIndependentFlagsMask,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EventModifierFlag> for NSUInteger {
|
impl From<EventModifierFlag> for NSUInteger {
|
||||||
|
@ -29,7 +29,7 @@ impl From<EventModifierFlag> for NSUInteger {
|
||||||
EventModifierFlag::Control => 1 << 18,
|
EventModifierFlag::Control => 1 << 18,
|
||||||
EventModifierFlag::Option => 1 << 19,
|
EventModifierFlag::Option => 1 << 19,
|
||||||
EventModifierFlag::Command => 1 << 20,
|
EventModifierFlag::Command => 1 << 20,
|
||||||
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000
|
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ impl From<&EventModifierFlag> for NSUInteger {
|
||||||
EventModifierFlag::Control => 1 << 18,
|
EventModifierFlag::Control => 1 << 18,
|
||||||
EventModifierFlag::Option => 1 << 19,
|
EventModifierFlag::Option => 1 << 19,
|
||||||
EventModifierFlag::Command => 1 << 20,
|
EventModifierFlag::Command => 1 << 20,
|
||||||
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000
|
EventModifierFlag::DeviceIndependentFlagsMask => 0xffff0000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,5 +50,5 @@ impl From<&EventModifierFlag> for NSUInteger {
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum EventType {
|
pub enum EventType {
|
||||||
/// A keydown event.
|
/// A keydown event.
|
||||||
KeyDown
|
KeyDown,
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub enum ModalResponse {
|
||||||
SecondButtonReturned,
|
SecondButtonReturned,
|
||||||
|
|
||||||
/// The third button in the dialog was clicked.
|
/// The third button in the dialog was clicked.
|
||||||
ThirdButtonReturned
|
ThirdButtonReturned,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NSInteger> for ModalResponse {
|
impl From<NSInteger> for ModalResponse {
|
||||||
|
@ -47,7 +47,7 @@ impl From<NSInteger> for ModalResponse {
|
||||||
// gracefully handle.
|
// gracefully handle.
|
||||||
e => {
|
e => {
|
||||||
panic!("Unknown NSModalResponse sent back! {}", e);
|
panic!("Unknown NSModalResponse sent back! {}", e);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ pub enum SearchPathDomainMask {
|
||||||
Domain,
|
Domain,
|
||||||
|
|
||||||
/// Search all domains. Not typically used these days.
|
/// Search all domains. Not typically used these days.
|
||||||
AllDomains
|
AllDomains,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SearchPathDomainMask> for NSUInteger {
|
impl From<SearchPathDomainMask> for NSUInteger {
|
||||||
|
@ -78,7 +78,7 @@ impl From<SearchPathDomainMask> for NSUInteger {
|
||||||
SearchPathDomainMask::Local => 2,
|
SearchPathDomainMask::Local => 2,
|
||||||
SearchPathDomainMask::Network => 4,
|
SearchPathDomainMask::Network => 4,
|
||||||
SearchPathDomainMask::Domain => 8,
|
SearchPathDomainMask::Domain => 8,
|
||||||
SearchPathDomainMask::AllDomains => 0x0ffff
|
SearchPathDomainMask::AllDomains => 0x0ffff,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ pub enum SearchPathDirectory {
|
||||||
AllLibraries,
|
AllLibraries,
|
||||||
|
|
||||||
/// The Trash directory.
|
/// The Trash directory.
|
||||||
Trash
|
Trash,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SearchPathDirectory> for NSUInteger {
|
impl From<SearchPathDirectory> for NSUInteger {
|
||||||
|
@ -204,7 +204,7 @@ impl From<SearchPathDirectory> for NSUInteger {
|
||||||
SearchPathDirectory::ItemReplacement => 99,
|
SearchPathDirectory::ItemReplacement => 99,
|
||||||
SearchPathDirectory::AllApplications => 100,
|
SearchPathDirectory::AllApplications => 100,
|
||||||
SearchPathDirectory::AllLibraries => 101,
|
SearchPathDirectory::AllLibraries => 101,
|
||||||
SearchPathDirectory::Trash => 102
|
SearchPathDirectory::Trash => 102,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub struct FileSavePanel {
|
||||||
pub delegate: ShareId<Object>,
|
pub delegate: ShareId<Object>,
|
||||||
|
|
||||||
/// Whether the user can choose files. Defaults to `true`.
|
/// Whether the user can choose files. Defaults to `true`.
|
||||||
pub can_create_directories: bool
|
pub can_create_directories: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FileSavePanel {
|
impl Default for FileSavePanel {
|
||||||
|
@ -41,7 +41,7 @@ impl FileSavePanel {
|
||||||
|
|
||||||
delegate: unsafe { ShareId::from_ptr(msg_send![class!(NSObject), new]) },
|
delegate: unsafe { ShareId::from_ptr(msg_send![class!(NSObject), new]) },
|
||||||
|
|
||||||
can_create_directories: true
|
can_create_directories: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub struct FileSelectPanel {
|
||||||
|
|
||||||
/// When the value of this property is true, the user may select multiple items from the
|
/// When the value of this property is true, the user may select multiple items from the
|
||||||
/// browser. Defaults to `false`.
|
/// browser. Defaults to `false`.
|
||||||
pub allows_multiple_selection: bool
|
pub allows_multiple_selection: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FileSelectPanel {
|
impl Default for FileSelectPanel {
|
||||||
|
@ -63,7 +63,7 @@ impl FileSelectPanel {
|
||||||
can_choose_files: true,
|
can_choose_files: true,
|
||||||
can_choose_directories: false,
|
can_choose_directories: false,
|
||||||
resolves_aliases: true,
|
resolves_aliases: true,
|
||||||
allows_multiple_selection: true
|
allows_multiple_selection: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ impl FileSelectPanel {
|
||||||
/// script) or can't easily pass one to use as a sheet.
|
/// script) or can't easily pass one to use as a sheet.
|
||||||
pub fn show<F>(&self, handler: F)
|
pub fn show<F>(&self, handler: F)
|
||||||
where
|
where
|
||||||
F: Fn(Vec<NSURL>) + 'static
|
F: Fn(Vec<NSURL>) + 'static,
|
||||||
{
|
{
|
||||||
let panel = self.panel.clone();
|
let panel = self.panel.clone();
|
||||||
let completion = ConcreteBlock::new(move |result: NSInteger| {
|
let completion = ConcreteBlock::new(move |result: NSInteger| {
|
||||||
|
@ -143,7 +143,7 @@ impl FileSelectPanel {
|
||||||
|
|
||||||
handler(match response {
|
handler(match response {
|
||||||
ModalResponse::Ok => get_urls(&panel),
|
ModalResponse::Ok => get_urls(&panel),
|
||||||
_ => Vec::new()
|
_ => Vec::new(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ impl FileSelectPanel {
|
||||||
/// retain/ownership rules here.
|
/// retain/ownership rules here.
|
||||||
pub fn begin_sheet<T, F>(&self, window: &Window<T>, handler: F)
|
pub fn begin_sheet<T, F>(&self, window: &Window<T>, handler: F)
|
||||||
where
|
where
|
||||||
F: Fn(Vec<NSURL>) + 'static
|
F: Fn(Vec<NSURL>) + 'static,
|
||||||
{
|
{
|
||||||
let panel = self.panel.clone();
|
let panel = self.panel.clone();
|
||||||
let completion = ConcreteBlock::new(move |result: NSInteger| {
|
let completion = ConcreteBlock::new(move |result: NSInteger| {
|
||||||
|
@ -179,7 +179,7 @@ impl FileSelectPanel {
|
||||||
|
|
||||||
handler(match response {
|
handler(match response {
|
||||||
ModalResponse::Ok => get_urls(&panel),
|
ModalResponse::Ok => get_urls(&panel),
|
||||||
_ => Vec::new()
|
_ => Vec::new(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ impl AutoReleasePool {
|
||||||
/// with an autorelease pool - otherwise your memory footprint will continue to grow.
|
/// with an autorelease pool - otherwise your memory footprint will continue to grow.
|
||||||
pub fn run<F>(handler: F)
|
pub fn run<F>(handler: F)
|
||||||
where
|
where
|
||||||
F: Fn() + 'static
|
F: Fn() + 'static,
|
||||||
{
|
{
|
||||||
let _pool = AutoReleasePool::new();
|
let _pool = AutoReleasePool::new();
|
||||||
handler();
|
handler();
|
||||||
|
|
|
@ -122,7 +122,7 @@ impl ClassMap {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn load_or_register_class<F>(superclass_name: &'static str, subclass_name: &'static str, config: F) -> *const Class
|
pub fn load_or_register_class<F>(superclass_name: &'static str, subclass_name: &'static str, config: F) -> *const Class
|
||||||
where
|
where
|
||||||
F: Fn(&mut ClassDecl) + 'static
|
F: Fn(&mut ClassDecl) + 'static,
|
||||||
{
|
{
|
||||||
if let Some(subclass) = CLASSES.load_subclass(subclass_name, superclass_name) {
|
if let Some(subclass) = CLASSES.load_subclass(subclass_name, superclass_name) {
|
||||||
return subclass;
|
return subclass;
|
||||||
|
@ -145,7 +145,7 @@ where
|
||||||
"Subclass of type {}_{} could not be allocated.",
|
"Subclass of type {}_{} could not be allocated.",
|
||||||
subclass_name, superclass_name
|
subclass_name, superclass_name
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub fn to_bool(result: BOOL) -> bool {
|
||||||
#[cfg(not(target_arch = "aarch64"))]
|
#[cfg(not(target_arch = "aarch64"))]
|
||||||
_ => {
|
_ => {
|
||||||
std::unreachable!();
|
std::unreachable!();
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ const UTF8_ENCODING: usize = 4;
|
||||||
pub struct NSString<'a> {
|
pub struct NSString<'a> {
|
||||||
/// A reference to the backing `NSString`.
|
/// A reference to the backing `NSString`.
|
||||||
pub objc: Id<Object>,
|
pub objc: Id<Object>,
|
||||||
phantom: PhantomData<&'a ()>
|
phantom: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NSString<'a> {
|
impl<'a> NSString<'a> {
|
||||||
|
@ -34,7 +34,7 @@ impl<'a> NSString<'a> {
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
phantom: PhantomData
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ impl<'a> NSString<'a> {
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
phantom: PhantomData
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ impl<'a> NSString<'a> {
|
||||||
pub fn retain(object: id) -> Self {
|
pub fn retain(object: id) -> Self {
|
||||||
NSString {
|
NSString {
|
||||||
objc: unsafe { Id::from_ptr(object) },
|
objc: unsafe { Id::from_ptr(object) },
|
||||||
phantom: PhantomData
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ impl<'a> NSString<'a> {
|
||||||
pub fn from_retained(object: id) -> Self {
|
pub fn from_retained(object: id) -> Self {
|
||||||
NSString {
|
NSString {
|
||||||
objc: unsafe { Id::from_retained_ptr(object) },
|
objc: unsafe { Id::from_retained_ptr(object) },
|
||||||
phantom: PhantomData
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub enum NSURLBookmarkCreationOption {
|
||||||
/// When combined with the NSURLBookmarkCreationOptions::SecurityScoped option, specifies that you
|
/// When combined with the NSURLBookmarkCreationOptions::SecurityScoped option, specifies that you
|
||||||
/// want to create a security-scoped bookmark that, when resolved, provides a security-scoped URL allowing
|
/// want to create a security-scoped bookmark that, when resolved, provides a security-scoped URL allowing
|
||||||
/// read-only access to a file-system resource.
|
/// read-only access to a file-system resource.
|
||||||
SecurityScopedReadOnly
|
SecurityScopedReadOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NSURLBookmarkCreationOption> for NSUInteger {
|
impl From<NSURLBookmarkCreationOption> for NSUInteger {
|
||||||
|
@ -25,7 +25,7 @@ impl From<NSURLBookmarkCreationOption> for NSUInteger {
|
||||||
NSURLBookmarkCreationOption::Minimal => 1u64 << 9,
|
NSURLBookmarkCreationOption::Minimal => 1u64 << 9,
|
||||||
NSURLBookmarkCreationOption::SuitableForBookmarkFile => 1u64 << 10,
|
NSURLBookmarkCreationOption::SuitableForBookmarkFile => 1u64 << 10,
|
||||||
NSURLBookmarkCreationOption::SecurityScoped => 1 << 11,
|
NSURLBookmarkCreationOption::SecurityScoped => 1 << 11,
|
||||||
NSURLBookmarkCreationOption::SecurityScopedReadOnly => 1 << 12
|
NSURLBookmarkCreationOption::SecurityScopedReadOnly => 1 << 12,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ impl From<&NSURLBookmarkCreationOption> for NSUInteger {
|
||||||
NSURLBookmarkCreationOption::Minimal => 1u64 << 9,
|
NSURLBookmarkCreationOption::Minimal => 1u64 << 9,
|
||||||
NSURLBookmarkCreationOption::SuitableForBookmarkFile => 1u64 << 10,
|
NSURLBookmarkCreationOption::SuitableForBookmarkFile => 1u64 << 10,
|
||||||
NSURLBookmarkCreationOption::SecurityScoped => 1 << 11,
|
NSURLBookmarkCreationOption::SecurityScoped => 1 << 11,
|
||||||
NSURLBookmarkCreationOption::SecurityScopedReadOnly => 1 << 12
|
NSURLBookmarkCreationOption::SecurityScopedReadOnly => 1 << 12,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ pub enum NSURLBookmarkResolutionOption {
|
||||||
|
|
||||||
/// Specifies that the security scope, applied to the bookmark when it was created, should
|
/// Specifies that the security scope, applied to the bookmark when it was created, should
|
||||||
/// be used during resolution of the bookmark data.
|
/// be used during resolution of the bookmark data.
|
||||||
SecurityScoped
|
SecurityScoped,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NSURLBookmarkResolutionOption> for NSUInteger {
|
impl From<NSURLBookmarkResolutionOption> for NSUInteger {
|
||||||
|
@ -60,7 +60,7 @@ impl From<NSURLBookmarkResolutionOption> for NSUInteger {
|
||||||
match flag {
|
match flag {
|
||||||
NSURLBookmarkResolutionOption::WithoutUI => 1u64 << 8,
|
NSURLBookmarkResolutionOption::WithoutUI => 1u64 << 8,
|
||||||
NSURLBookmarkResolutionOption::WithoutMounting => 1u64 << 9,
|
NSURLBookmarkResolutionOption::WithoutMounting => 1u64 << 9,
|
||||||
NSURLBookmarkResolutionOption::SecurityScoped => 1 << 10
|
NSURLBookmarkResolutionOption::SecurityScoped => 1 << 10,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub use resource_keys::{NSURLFileResource, NSURLResourceKey, NSUbiquitousItemDow
|
||||||
pub struct NSURL<'a> {
|
pub struct NSURL<'a> {
|
||||||
/// A reference to the backing `NSURL`.
|
/// A reference to the backing `NSURL`.
|
||||||
pub objc: ShareId<Object>,
|
pub objc: ShareId<Object>,
|
||||||
phantom: PhantomData<&'a ()>
|
phantom: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> NSURL<'a> {
|
impl<'a> NSURL<'a> {
|
||||||
|
@ -41,7 +41,7 @@ impl<'a> NSURL<'a> {
|
||||||
pub fn retain(object: id) -> Self {
|
pub fn retain(object: id) -> Self {
|
||||||
NSURL {
|
NSURL {
|
||||||
objc: unsafe { ShareId::from_ptr(object) },
|
objc: unsafe { ShareId::from_ptr(object) },
|
||||||
phantom: PhantomData
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl<'a> NSURL<'a> {
|
||||||
pub fn from_retained(object: id) -> Self {
|
pub fn from_retained(object: id) -> Self {
|
||||||
NSURL {
|
NSURL {
|
||||||
objc: unsafe { ShareId::from_retained_ptr(object) },
|
objc: unsafe { ShareId::from_retained_ptr(object) },
|
||||||
phantom: PhantomData
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ impl<'a> NSURL<'a> {
|
||||||
Self {
|
Self {
|
||||||
objc: unsafe { ShareId::from_ptr(msg_send![class!(NSURL), URLWithString:&*url]) },
|
objc: unsafe { ShareId::from_ptr(msg_send![class!(NSURL), URLWithString:&*url]) },
|
||||||
|
|
||||||
phantom: PhantomData
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ impl<'a> NSURL<'a> {
|
||||||
&self,
|
&self,
|
||||||
options: &[NSURLBookmarkCreationOption],
|
options: &[NSURLBookmarkCreationOption],
|
||||||
resource_value_keys: &[NSURLResourceKey],
|
resource_value_keys: &[NSURLResourceKey],
|
||||||
relative_to_url: Option<NSURL>
|
relative_to_url: Option<NSURL>,
|
||||||
) -> Result<NSData, Box<dyn Error>> {
|
) -> Result<NSData, Box<dyn Error>> {
|
||||||
let mut opts: NSUInteger = 0;
|
let mut opts: NSUInteger = 0;
|
||||||
for mask in options {
|
for mask in options {
|
||||||
|
@ -118,7 +118,7 @@ impl<'a> NSURL<'a> {
|
||||||
relativeToURL:nil
|
relativeToURL:nil
|
||||||
error:nil
|
error:nil
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check for errors...
|
// Check for errors...
|
||||||
|
@ -132,7 +132,7 @@ impl<'a> NSURL<'a> {
|
||||||
data: NSData,
|
data: NSData,
|
||||||
options: &[NSURLBookmarkResolutionOption],
|
options: &[NSURLBookmarkResolutionOption],
|
||||||
relative_to_url: Option<NSURL>,
|
relative_to_url: Option<NSURL>,
|
||||||
data_is_stale: bool
|
data_is_stale: bool,
|
||||||
) -> Result<Self, Box<dyn Error>> {
|
) -> Result<Self, Box<dyn Error>> {
|
||||||
Err("LOL".into())
|
Err("LOL".into())
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub enum NSURLFileResource {
|
||||||
Socket,
|
Socket,
|
||||||
|
|
||||||
/// The resource’s type is unknown.
|
/// The resource’s type is unknown.
|
||||||
Unknown
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Values that describe the iCloud storage state of a file.
|
/// Values that describe the iCloud storage state of a file.
|
||||||
|
@ -38,7 +38,7 @@ pub enum NSUbiquitousItemDownloadingStatus {
|
||||||
Downloaded,
|
Downloaded,
|
||||||
|
|
||||||
/// This item has not been downloaded yet. Initiate a download.
|
/// This item has not been downloaded yet. Initiate a download.
|
||||||
NotDownloaded
|
NotDownloaded,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -166,5 +166,5 @@ pub enum NSURLResourceKey {
|
||||||
MayHaveExtendedAttributes,
|
MayHaveExtendedAttributes,
|
||||||
MayShareFileContent,
|
MayShareFileContent,
|
||||||
UbiquitousItemIsExcludedFromSync,
|
UbiquitousItemIsExcludedFromSync,
|
||||||
VolumeSupportsFileProtection
|
VolumeSupportsFileProtection,
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub struct Rect {
|
||||||
pub width: f64,
|
pub width: f64,
|
||||||
|
|
||||||
/// Height, in points.
|
/// Height, in points.
|
||||||
pub height: f64
|
pub height: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rect {
|
impl Rect {
|
||||||
|
@ -26,7 +26,7 @@ impl Rect {
|
||||||
top: top,
|
top: top,
|
||||||
left: left,
|
left: left,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ impl Rect {
|
||||||
top: 0.0,
|
top: 0.0,
|
||||||
left: 0.0,
|
left: 0.0,
|
||||||
width: 0.0,
|
width: 0.0,
|
||||||
height: 0.0
|
height: 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ impl From<CGRect> for Rect {
|
||||||
top: rect.origin.y as f64,
|
top: rect.origin.y as f64,
|
||||||
left: rect.origin.x as f64,
|
left: rect.origin.x as f64,
|
||||||
width: rect.size.width as f64,
|
width: rect.size.width as f64,
|
||||||
height: rect.size.height as f64
|
height: rect.size.height as f64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub enum MacSystemIcon {
|
||||||
Remove,
|
Remove,
|
||||||
|
|
||||||
/// Returns a Folder icon.
|
/// Returns a Folder icon.
|
||||||
Folder
|
Folder,
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -53,7 +53,7 @@ impl MacSystemIcon {
|
||||||
MacSystemIcon::PreferencesUserAccounts => NSImageNameUserAccounts,
|
MacSystemIcon::PreferencesUserAccounts => NSImageNameUserAccounts,
|
||||||
MacSystemIcon::Add => NSImageNameAddTemplate,
|
MacSystemIcon::Add => NSImageNameAddTemplate,
|
||||||
MacSystemIcon::Remove => NSImageNameRemoveTemplate,
|
MacSystemIcon::Remove => NSImageNameRemoveTemplate,
|
||||||
MacSystemIcon::Folder => NSImageNameFolder
|
MacSystemIcon::Folder => NSImageNameFolder,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ impl MacSystemIcon {
|
||||||
MacSystemIcon::PreferencesUserAccounts => SFSymbol::AtSymbol.to_str(),
|
MacSystemIcon::PreferencesUserAccounts => SFSymbol::AtSymbol.to_str(),
|
||||||
MacSystemIcon::Add => SFSymbol::Plus.to_str(),
|
MacSystemIcon::Add => SFSymbol::Plus.to_str(),
|
||||||
MacSystemIcon::Remove => SFSymbol::Minus.to_str(),
|
MacSystemIcon::Remove => SFSymbol::Minus.to_str(),
|
||||||
MacSystemIcon::Folder => SFSymbol::FolderFilled.to_str()
|
MacSystemIcon::Folder => SFSymbol::FolderFilled.to_str(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ pub enum SFSymbol {
|
||||||
SquareAndArrowUpOnSquareFill,
|
SquareAndArrowUpOnSquareFill,
|
||||||
SquareAndArrowDownOnSquare,
|
SquareAndArrowDownOnSquare,
|
||||||
SquareAndArrowDownOnSquareFill,
|
SquareAndArrowDownOnSquareFill,
|
||||||
SquareDashed
|
SquareDashed,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SFSymbol {
|
impl SFSymbol {
|
||||||
|
@ -103,7 +103,7 @@ impl SFSymbol {
|
||||||
Self::SquareAndArrowUpOnSquareFill => "square.and.arrow.up.on.square.fill",
|
Self::SquareAndArrowUpOnSquareFill => "square.and.arrow.up.on.square.fill",
|
||||||
Self::SquareAndArrowDownOnSquare => "square.and.arrow.down.on.square",
|
Self::SquareAndArrowDownOnSquare => "square.and.arrow.down.on.square",
|
||||||
Self::SquareAndArrowDownOnSquareFill => "square.and.arrow.down.on.square.fill",
|
Self::SquareAndArrowDownOnSquareFill => "square.and.arrow.down.on.square.fill",
|
||||||
Self::SquareDashed => "square.dashed"
|
Self::SquareDashed => "square.dashed",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use block::ConcreteBlock;
|
||||||
use core_graphics::context::{CGContext, CGContextRef};
|
use core_graphics::context::{CGContext, CGContextRef};
|
||||||
use core_graphics::{
|
use core_graphics::{
|
||||||
base::CGFloat,
|
base::CGFloat,
|
||||||
geometry::{CGPoint, CGRect, CGSize}
|
geometry::{CGPoint, CGRect, CGSize},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::icons::*;
|
use super::icons::*;
|
||||||
|
@ -28,7 +28,7 @@ pub enum ResizeBehavior {
|
||||||
Stretch,
|
Stretch,
|
||||||
|
|
||||||
/// Center and then let whatever else flow around it.
|
/// Center and then let whatever else flow around it.
|
||||||
Center
|
Center,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn max_cgfloat(x: CGFloat, y: CGFloat) -> CGFloat {
|
fn max_cgfloat(x: CGFloat, y: CGFloat) -> CGFloat {
|
||||||
|
@ -38,7 +38,7 @@ fn max_cgfloat(x: CGFloat, y: CGFloat) -> CGFloat {
|
||||||
|
|
||||||
match x > y {
|
match x > y {
|
||||||
true => x,
|
true => x,
|
||||||
false => y
|
false => y,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ fn min_cgfloat(x: CGFloat, y: CGFloat) -> CGFloat {
|
||||||
|
|
||||||
match x < y {
|
match x < y {
|
||||||
true => x,
|
true => x,
|
||||||
false => y
|
false => y,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ impl ResizeBehavior {
|
||||||
ResizeBehavior::Center => {
|
ResizeBehavior::Center => {
|
||||||
scales.width = 1.;
|
scales.width = 1.;
|
||||||
scales.height = 1.;
|
scales.height = 1.;
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut result = source;
|
let mut result = source;
|
||||||
|
@ -113,7 +113,7 @@ pub struct DrawConfig {
|
||||||
pub target: (CGFloat, CGFloat),
|
pub target: (CGFloat, CGFloat),
|
||||||
|
|
||||||
/// The type of resizing to use during drawing and scaling.
|
/// The type of resizing to use during drawing and scaling.
|
||||||
pub resize: ResizeBehavior
|
pub resize: ResizeBehavior,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps `NSImage` under AppKit, and `UIImage` on under UIKit (iOS and tvOS). Can be used to display images, icons,
|
/// Wraps `NSImage` under AppKit, and `UIImage` on under UIKit (iOS and tvOS). Can be used to display images, icons,
|
||||||
|
@ -195,7 +195,7 @@ impl Image {
|
||||||
false => {
|
false => {
|
||||||
let icon = icon.to_id();
|
let icon = icon.to_id();
|
||||||
msg_send![Self::class(), imageNamed: icon]
|
msg_send![Self::class(), imageNamed: icon]
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ impl Image {
|
||||||
|
|
||||||
#[cfg(all(feature = "uikit", not(feature = "appkit")))]
|
#[cfg(all(feature = "uikit", not(feature = "appkit")))]
|
||||||
panic!("SFSymbols are only supported on macOS 11.0 and up.");
|
panic!("SFSymbols are only supported on macOS 11.0 and up.");
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ impl Image {
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
pub fn draw<F>(config: DrawConfig, handler: F) -> Self
|
pub fn draw<F>(config: DrawConfig, handler: F) -> Self
|
||||||
where
|
where
|
||||||
F: Fn(CGRect, &CGContextRef) -> bool + 'static
|
F: Fn(CGRect, &CGContextRef) -> bool + 'static,
|
||||||
{
|
{
|
||||||
let source_frame = CGRect::new(&CGPoint::new(0., 0.), &CGSize::new(config.source.0, config.source.1));
|
let source_frame = CGRect::new(&CGPoint::new(0., 0.), &CGSize::new(config.source.0, config.source.1));
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ impl Image {
|
||||||
context.translate(resized_frame.origin.x, resized_frame.origin.y);
|
context.translate(resized_frame.origin.x, resized_frame.origin.y);
|
||||||
context.scale(
|
context.scale(
|
||||||
resized_frame.size.width / config.source.0,
|
resized_frame.size.width / config.source.0,
|
||||||
resized_frame.size.height / config.source.1
|
resized_frame.size.height / config.source.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
let result = handler(resized_frame, &context);
|
let result = handler(resized_frame, &context);
|
||||||
|
@ -270,7 +270,7 @@ impl Image {
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let block = block.copy();
|
let block = block.copy();
|
||||||
|
|
|
@ -90,7 +90,7 @@ pub struct ImageView {
|
||||||
|
|
||||||
/// A pointer to the Objective-C runtime center Y layout constraint.
|
/// A pointer to the Objective-C runtime center Y layout constraint.
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
pub center_y: LayoutAnchorY
|
pub center_y: LayoutAnchorY,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ImageView {
|
impl Default for ImageView {
|
||||||
|
@ -135,7 +135,7 @@ impl ImageView {
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(view),
|
center_y: LayoutAnchorY::center(view),
|
||||||
|
|
||||||
objc: ObjcProperty::retain(view)
|
objc: ObjcProperty::retain(view),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ extern "C" fn text_should_begin_editing<T: TextFieldDelegate>(this: &mut Object,
|
||||||
|
|
||||||
match view.text_should_begin_editing(s.to_str()) {
|
match view.text_should_begin_editing(s.to_str()) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ extern "C" fn text_should_end_editing<T: TextFieldDelegate>(this: &mut Object, _
|
||||||
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
|
let s = NSString::retain(unsafe { msg_send![this, stringValue] });
|
||||||
match view.text_should_end_editing(s.to_str()) {
|
match view.text_should_end_editing(s.to_str()) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,20 +74,20 @@ pub(crate) fn register_view_class_with_delegate<T: TextFieldDelegate>(instance:
|
||||||
|
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(textDidEndEditing:),
|
sel!(textDidEndEditing:),
|
||||||
text_did_end_editing::<T> as extern "C" fn(&mut Object, _, _)
|
text_did_end_editing::<T> as extern "C" fn(&mut Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(textDidBeginEditing:),
|
sel!(textDidBeginEditing:),
|
||||||
text_did_begin_editing::<T> as extern "C" fn(&mut Object, _, _)
|
text_did_begin_editing::<T> as extern "C" fn(&mut Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(sel!(textDidChange:), text_did_change::<T> as extern "C" fn(&mut Object, _, _));
|
decl.add_method(sel!(textDidChange:), text_did_change::<T> as extern "C" fn(&mut Object, _, _));
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(textShouldBeginEditing:),
|
sel!(textShouldBeginEditing:),
|
||||||
text_should_begin_editing::<T> as extern "C" fn(&mut Object, Sel, id) -> BOOL
|
text_should_begin_editing::<T> as extern "C" fn(&mut Object, Sel, id) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(textShouldEndEditing:),
|
sel!(textShouldEndEditing:),
|
||||||
text_should_end_editing::<T> as extern "C" fn(&mut Object, Sel, id) -> BOOL
|
text_should_end_editing::<T> as extern "C" fn(&mut Object, Sel, id) -> BOOL,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ pub struct TextField<T = ()> {
|
||||||
|
|
||||||
/// A pointer to the Objective-C runtime center Y layout constraint.
|
/// A pointer to the Objective-C runtime center Y layout constraint.
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
pub center_y: LayoutAnchorY
|
pub center_y: LayoutAnchorY,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TextField {
|
impl Default for TextField {
|
||||||
|
@ -185,14 +185,14 @@ impl TextField {
|
||||||
center_x: LayoutAnchorX::center(view),
|
center_x: LayoutAnchorX::center(view),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(view)
|
center_y: LayoutAnchorY::center(view),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> TextField<T>
|
impl<T> TextField<T>
|
||||||
where
|
where
|
||||||
T: TextFieldDelegate + 'static
|
T: TextFieldDelegate + 'static,
|
||||||
{
|
{
|
||||||
/// Initializes a new TextField with a given `TextFieldDelegate`. This enables you to respond to events
|
/// Initializes a new TextField with a given `TextFieldDelegate`. This enables you to respond to events
|
||||||
/// and customize the view as a module, similar to class-based systems.
|
/// and customize the view as a module, similar to class-based systems.
|
||||||
|
@ -238,7 +238,7 @@ where
|
||||||
center_x: LayoutAnchorX::center(label),
|
center_x: LayoutAnchorX::center(label),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(label)
|
center_y: LayoutAnchorY::center(label),
|
||||||
};
|
};
|
||||||
|
|
||||||
(&mut delegate).did_load(label.clone_as_handle());
|
(&mut delegate).did_load(label.clone_as_handle());
|
||||||
|
@ -285,7 +285,7 @@ impl<T> TextField<T> {
|
||||||
center_x: self.center_x.clone(),
|
center_x: self.center_x.clone(),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: self.center_y.clone()
|
center_y: self.center_y.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl fmt::Debug for Action {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TargetActionHandler {
|
pub struct TargetActionHandler {
|
||||||
action: Box<Action>,
|
action: Box<Action>,
|
||||||
invoker: ShareId<Object>
|
invoker: ShareId<Object>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TargetActionHandler {
|
impl TargetActionHandler {
|
||||||
|
@ -71,7 +71,7 @@ impl TargetActionHandler {
|
||||||
|
|
||||||
TargetActionHandler {
|
TargetActionHandler {
|
||||||
invoker: invoker,
|
invoker: invoker,
|
||||||
action: unsafe { Box::from_raw(ptr) }
|
action: unsafe { Box::from_raw(ptr) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub enum Key<'a> {
|
||||||
Delete,
|
Delete,
|
||||||
|
|
||||||
/// Whatever character you want.
|
/// Whatever character you want.
|
||||||
Char(&'a str)
|
Char(&'a str),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a str> for Key<'a> {
|
impl<'a> From<&'a str> for Key<'a> {
|
||||||
|
|
|
@ -35,21 +35,21 @@ use crate::utils::properties::ObjcProperty;
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Layer {
|
pub struct Layer {
|
||||||
/// The underlying layer pointer.
|
/// The underlying layer pointer.
|
||||||
pub objc: ObjcProperty
|
pub objc: ObjcProperty,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Layer {
|
impl Layer {
|
||||||
/// Creates a new `CALayer` and retains it.
|
/// Creates a new `CALayer` and retains it.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Layer {
|
Layer {
|
||||||
objc: ObjcProperty::retain(unsafe { msg_send![class!(CALayer), new] })
|
objc: ObjcProperty::retain(unsafe { msg_send![class!(CALayer), new] }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps an existing (already retained) `CALayer`.
|
/// Wraps an existing (already retained) `CALayer`.
|
||||||
pub fn wrap(layer: id) -> Self {
|
pub fn wrap(layer: id) -> Self {
|
||||||
Layer {
|
Layer {
|
||||||
objc: ObjcProperty::from_retained(layer)
|
objc: ObjcProperty::from_retained(layer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub enum LayoutConstraintOrientation {
|
||||||
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
||||||
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
||||||
/// caught here, and applications can handle it themselves if need be.
|
/// caught here, and applications can handle it themselves if need be.
|
||||||
Unknown(NSInteger)
|
Unknown(NSInteger),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NSInteger> for LayoutConstraintOrientation {
|
impl From<NSInteger> for LayoutConstraintOrientation {
|
||||||
|
@ -20,7 +20,7 @@ impl From<NSInteger> for LayoutConstraintOrientation {
|
||||||
match i {
|
match i {
|
||||||
0 => Self::Horizontal,
|
0 => Self::Horizontal,
|
||||||
1 => Self::Vertical,
|
1 => Self::Vertical,
|
||||||
i => Self::Unknown(i)
|
i => Self::Unknown(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ pub enum LayoutRelation {
|
||||||
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
||||||
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
||||||
/// caught here, and applications can handle it themselves if need be.
|
/// caught here, and applications can handle it themselves if need be.
|
||||||
Unknown(NSInteger)
|
Unknown(NSInteger),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NSInteger> for LayoutRelation {
|
impl From<NSInteger> for LayoutRelation {
|
||||||
|
@ -49,7 +49,7 @@ impl From<NSInteger> for LayoutRelation {
|
||||||
-1 => Self::LessThanOrEqual,
|
-1 => Self::LessThanOrEqual,
|
||||||
0 => Self::Equal,
|
0 => Self::Equal,
|
||||||
1 => Self::GreaterThanOrEqual,
|
1 => Self::GreaterThanOrEqual,
|
||||||
i => Self::Unknown(i)
|
i => Self::Unknown(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ pub enum LayoutAttribute {
|
||||||
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
||||||
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
||||||
/// caught here, and applications can handle it themselves if need be.
|
/// caught here, and applications can handle it themselves if need be.
|
||||||
Unknown(NSInteger)
|
Unknown(NSInteger),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NSInteger> for LayoutAttribute {
|
impl From<NSInteger> for LayoutAttribute {
|
||||||
|
@ -127,7 +127,7 @@ impl From<NSInteger> for LayoutAttribute {
|
||||||
11 => Self::LastBaseline,
|
11 => Self::LastBaseline,
|
||||||
12 => Self::FirstBaseline,
|
12 => Self::FirstBaseline,
|
||||||
0 => Self::NotAnAttribute,
|
0 => Self::NotAnAttribute,
|
||||||
i => Self::Unknown(i)
|
i => Self::Unknown(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ pub enum LayoutFormat {
|
||||||
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
/// Represents an unknown value. This should never be constructed, but acts as a guard against
|
||||||
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
/// a change in representation on the framework side. If a new value was ever introduced, it's
|
||||||
/// caught here, and applications can handle it themselves if need be.
|
/// caught here, and applications can handle it themselves if need be.
|
||||||
Unknown(NSUInteger)
|
Unknown(NSUInteger),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NSUInteger> for LayoutFormat {
|
impl From<NSUInteger> for LayoutFormat {
|
||||||
|
@ -200,7 +200,7 @@ impl From<NSUInteger> for LayoutFormat {
|
||||||
0 => Self::DirectionLeadingToTrailing,
|
0 => Self::DirectionLeadingToTrailing,
|
||||||
65536 => Self::DirectionLeftToRight,
|
65536 => Self::DirectionLeftToRight,
|
||||||
131072 => Self::DirectionRightToLeft,
|
131072 => Self::DirectionRightToLeft,
|
||||||
i => Self::Unknown(i)
|
i => Self::Unknown(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,5 +215,5 @@ pub enum LayoutPriority {
|
||||||
High,
|
High,
|
||||||
|
|
||||||
/// Low priority.
|
/// Low priority.
|
||||||
Low
|
Low,
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub struct LayoutConstraint {
|
||||||
/// An animator proxy that can be used inside animation contexts.
|
/// An animator proxy that can be used inside animation contexts.
|
||||||
/// This is currently only supported on macOS with the `appkit` feature.
|
/// This is currently only supported on macOS with the `appkit` feature.
|
||||||
#[cfg(all(feature = "appkit", target_os = "macos"))]
|
#[cfg(all(feature = "appkit", target_os = "macos"))]
|
||||||
pub animator: LayoutConstraintAnimatorProxy
|
pub animator: LayoutConstraintAnimatorProxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayoutConstraint {
|
impl LayoutConstraint {
|
||||||
|
@ -47,7 +47,7 @@ impl LayoutConstraint {
|
||||||
constraint: unsafe { ShareId::from_ptr(object) },
|
constraint: unsafe { ShareId::from_ptr(object) },
|
||||||
offset: 0.0,
|
offset: 0.0,
|
||||||
multiplier: 0.0,
|
multiplier: 0.0,
|
||||||
priority: 0.0
|
priority: 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ impl LayoutConstraint {
|
||||||
constraint: self.constraint,
|
constraint: self.constraint,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
multiplier: self.multiplier,
|
multiplier: self.multiplier,
|
||||||
priority: self.priority
|
priority: self.priority,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub enum LayoutAnchorDimension {
|
||||||
Width(ShareId<Object>),
|
Width(ShareId<Object>),
|
||||||
|
|
||||||
/// Represents a Height anchor.
|
/// Represents a Height anchor.
|
||||||
Height(ShareId<Object>)
|
Height(ShareId<Object>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LayoutAnchorDimension {
|
impl Default for LayoutAnchorDimension {
|
||||||
|
@ -87,7 +87,7 @@ impl LayoutAnchorDimension {
|
||||||
/// wrong.
|
/// wrong.
|
||||||
fn constraint_with<F>(&self, anchor_to: &LayoutAnchorDimension, handler: F) -> LayoutConstraint
|
fn constraint_with<F>(&self, anchor_to: &LayoutAnchorDimension, handler: F) -> LayoutConstraint
|
||||||
where
|
where
|
||||||
F: Fn(&ShareId<Object>, &ShareId<Object>) -> id
|
F: Fn(&ShareId<Object>, &ShareId<Object>) -> id,
|
||||||
{
|
{
|
||||||
match (self, anchor_to) {
|
match (self, anchor_to) {
|
||||||
(Self::Width(from), Self::Width(to))
|
(Self::Width(from), Self::Width(to))
|
||||||
|
@ -105,7 +105,7 @@ impl LayoutAnchorDimension {
|
||||||
|
|
||||||
(_, Self::Uninitialized) => {
|
(_, Self::Uninitialized) => {
|
||||||
panic!("Attempted to create constraints with an uninitialized \"to\" dimension anchor.");
|
panic!("Attempted to create constraints with an uninitialized \"to\" dimension anchor.");
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub enum LayoutAnchorX {
|
||||||
Right(ShareId<Object>),
|
Right(ShareId<Object>),
|
||||||
|
|
||||||
/// Represents a center anchor on the X axis.
|
/// Represents a center anchor on the X axis.
|
||||||
Center(ShareId<Object>)
|
Center(ShareId<Object>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LayoutAnchorX {
|
impl Default for LayoutAnchorX {
|
||||||
|
@ -69,7 +69,7 @@ impl LayoutAnchorX {
|
||||||
/// wrong.
|
/// wrong.
|
||||||
fn constraint_with<F>(&self, anchor_to: &LayoutAnchorX, handler: F) -> LayoutConstraint
|
fn constraint_with<F>(&self, anchor_to: &LayoutAnchorX, handler: F) -> LayoutConstraint
|
||||||
where
|
where
|
||||||
F: Fn(&ShareId<Object>, &ShareId<Object>) -> id
|
F: Fn(&ShareId<Object>, &ShareId<Object>) -> id,
|
||||||
{
|
{
|
||||||
match (self, anchor_to) {
|
match (self, anchor_to) {
|
||||||
// The anchors that can connect to each other. These blocks could be condensed, but are
|
// The anchors that can connect to each other. These blocks could be condensed, but are
|
||||||
|
@ -153,7 +153,7 @@ impl LayoutAnchorX {
|
||||||
|
|
||||||
(_, Self::Uninitialized) => {
|
(_, Self::Uninitialized) => {
|
||||||
panic!("Attempted to create constraints with an uninitialized \"to\" X anchor.");
|
panic!("Attempted to create constraints with an uninitialized \"to\" X anchor.");
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub struct SafeAreaLayoutGuide {
|
||||||
pub center_x: LayoutAnchorX,
|
pub center_x: LayoutAnchorX,
|
||||||
|
|
||||||
/// A pointer to the Objective-C runtime center Y layout constraint.
|
/// A pointer to the Objective-C runtime center Y layout constraint.
|
||||||
pub center_y: LayoutAnchorY
|
pub center_y: LayoutAnchorY,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SafeAreaLayoutGuide {
|
impl SafeAreaLayoutGuide {
|
||||||
|
@ -48,7 +48,7 @@ impl SafeAreaLayoutGuide {
|
||||||
// For versions prior to Big Sur, we'll just use the default view anchors in place.
|
// For versions prior to Big Sur, we'll just use the default view anchors in place.
|
||||||
let guide: id = match os::is_minimum_version(11) {
|
let guide: id = match os::is_minimum_version(11) {
|
||||||
true => unsafe { msg_send![view, layoutMarginsGuide] },
|
true => unsafe { msg_send![view, layoutMarginsGuide] },
|
||||||
false => view
|
false => view,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -61,7 +61,7 @@ impl SafeAreaLayoutGuide {
|
||||||
width: LayoutAnchorDimension::width(guide),
|
width: LayoutAnchorDimension::width(guide),
|
||||||
height: LayoutAnchorDimension::height(guide),
|
height: LayoutAnchorDimension::height(guide),
|
||||||
center_x: LayoutAnchorX::center(guide),
|
center_x: LayoutAnchorX::center(guide),
|
||||||
center_y: LayoutAnchorY::center(guide)
|
center_y: LayoutAnchorY::center(guide),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub enum LayoutAnchorY {
|
||||||
Bottom(ShareId<Object>),
|
Bottom(ShareId<Object>),
|
||||||
|
|
||||||
/// Represents a center anchor for the Y axis.
|
/// Represents a center anchor for the Y axis.
|
||||||
Center(ShareId<Object>)
|
Center(ShareId<Object>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LayoutAnchorY {
|
impl Default for LayoutAnchorY {
|
||||||
|
@ -49,7 +49,7 @@ impl LayoutAnchorY {
|
||||||
/// wrong.
|
/// wrong.
|
||||||
fn constraint_with<F>(&self, anchor_to: &LayoutAnchorY, handler: F) -> LayoutConstraint
|
fn constraint_with<F>(&self, anchor_to: &LayoutAnchorY, handler: F) -> LayoutConstraint
|
||||||
where
|
where
|
||||||
F: Fn(&ShareId<Object>, &ShareId<Object>) -> id
|
F: Fn(&ShareId<Object>, &ShareId<Object>) -> id,
|
||||||
{
|
{
|
||||||
match (self, anchor_to) {
|
match (self, anchor_to) {
|
||||||
(Self::Top(from), Self::Top(to))
|
(Self::Top(from), Self::Top(to))
|
||||||
|
@ -72,7 +72,7 @@ impl LayoutAnchorY {
|
||||||
|
|
||||||
(_, Self::Uninitialized) => {
|
(_, Self::Uninitialized) => {
|
||||||
panic!("Attempted to create constraints with an uninitialized \"to\" y anchor.");
|
panic!("Attempted to create constraints with an uninitialized \"to\" y anchor.");
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub enum RowActionStyle {
|
||||||
Regular,
|
Regular,
|
||||||
|
|
||||||
/// Use this to denote that an action is destructive.
|
/// Use this to denote that an action is destructive.
|
||||||
Destructive
|
Destructive,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RowActionStyle {
|
impl Default for RowActionStyle {
|
||||||
|
@ -30,7 +30,7 @@ impl From<RowActionStyle> for NSUInteger {
|
||||||
fn from(style: RowActionStyle) -> Self {
|
fn from(style: RowActionStyle) -> Self {
|
||||||
match style {
|
match style {
|
||||||
RowActionStyle::Regular => 0,
|
RowActionStyle::Regular => 0,
|
||||||
RowActionStyle::Destructive => 1
|
RowActionStyle::Destructive => 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ impl RowAction {
|
||||||
/// our definitions.
|
/// our definitions.
|
||||||
pub fn new<F>(title: &str, style: RowActionStyle, handler: F) -> Self
|
pub fn new<F>(title: &str, style: RowActionStyle, handler: F) -> Self
|
||||||
where
|
where
|
||||||
F: Fn(RowAction, usize) + 'static
|
F: Fn(RowAction, usize) + 'static,
|
||||||
{
|
{
|
||||||
let title = NSString::new(title);
|
let title = NSString::new(title);
|
||||||
let block = ConcreteBlock::new(move |action: id, row: NSUInteger| {
|
let block = ConcreteBlock::new(move |action: id, row: NSUInteger| {
|
||||||
|
|
|
@ -31,7 +31,7 @@ extern "C" fn view_for_column<T: ListViewDelegate>(
|
||||||
_: Sel,
|
_: Sel,
|
||||||
_table_view: id,
|
_table_view: id,
|
||||||
_table_column: id,
|
_table_column: id,
|
||||||
item: NSInteger
|
item: NSInteger,
|
||||||
) -> id {
|
) -> id {
|
||||||
/*use core_graphics::geometry::CGRect;
|
/*use core_graphics::geometry::CGRect;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -61,7 +61,7 @@ extern "C" fn will_display_cell<T: ListViewDelegate>(
|
||||||
_table_view: id,
|
_table_view: id,
|
||||||
_cell: id,
|
_cell: id,
|
||||||
_column: id,
|
_column: id,
|
||||||
item: NSInteger
|
item: NSInteger,
|
||||||
) {
|
) {
|
||||||
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
||||||
view.will_display_item(item as usize);
|
view.will_display_item(item as usize);
|
||||||
|
@ -109,7 +109,7 @@ extern "C" fn row_actions_for_row<T: ListViewDelegate>(
|
||||||
_: Sel,
|
_: Sel,
|
||||||
_table_view: id,
|
_table_view: id,
|
||||||
row: NSInteger,
|
row: NSInteger,
|
||||||
edge: NSInteger
|
edge: NSInteger,
|
||||||
) -> id {
|
) -> id {
|
||||||
let edge: RowEdge = edge.into();
|
let edge: RowEdge = edge.into();
|
||||||
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
||||||
|
@ -133,7 +133,7 @@ extern "C" fn enforce_normalcy(_: &Object, _: Sel) -> BOOL {
|
||||||
extern "C" fn dragging_entered<T: ListViewDelegate>(this: &mut Object, _: Sel, info: id) -> NSUInteger {
|
extern "C" fn dragging_entered<T: ListViewDelegate>(this: &mut Object, _: Sel, info: id) -> NSUInteger {
|
||||||
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
||||||
view.dragging_entered(DragInfo {
|
view.dragging_entered(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
@ -143,10 +143,10 @@ extern "C" fn prepare_for_drag_operation<T: ListViewDelegate>(this: &mut Object,
|
||||||
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
||||||
|
|
||||||
match view.prepare_for_drag_operation(DragInfo {
|
match view.prepare_for_drag_operation(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
}) {
|
}) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +155,10 @@ extern "C" fn perform_drag_operation<T: ListViewDelegate>(this: &mut Object, _:
|
||||||
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
||||||
|
|
||||||
match view.perform_drag_operation(DragInfo {
|
match view.perform_drag_operation(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
}) {
|
}) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ extern "C" fn conclude_drag_operation<T: ListViewDelegate>(this: &mut Object, _:
|
||||||
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
||||||
|
|
||||||
view.conclude_drag_operation(DragInfo {
|
view.conclude_drag_operation(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ extern "C" fn dragging_exited<T: ListViewDelegate>(this: &mut Object, _: Sel, in
|
||||||
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_DELEGATE_PTR);
|
||||||
|
|
||||||
view.dragging_exited(DragInfo {
|
view.dragging_exited(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,23 +210,23 @@ pub(crate) fn register_listview_class_with_delegate<T: ListViewDelegate>(instanc
|
||||||
// Tableview-specific
|
// Tableview-specific
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(numberOfRowsInTableView:),
|
sel!(numberOfRowsInTableView:),
|
||||||
number_of_items::<T> as extern "C" fn(&Object, _, id) -> NSInteger
|
number_of_items::<T> as extern "C" fn(&Object, _, id) -> NSInteger,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(tableView:willDisplayCell:forTableColumn:row:),
|
sel!(tableView:willDisplayCell:forTableColumn:row:),
|
||||||
will_display_cell::<T> as extern "C" fn(&Object, _, id, id, id, NSInteger)
|
will_display_cell::<T> as extern "C" fn(&Object, _, id, id, id, NSInteger),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(tableView:viewForTableColumn:row:),
|
sel!(tableView:viewForTableColumn:row:),
|
||||||
view_for_column::<T> as extern "C" fn(&Object, _, id, id, NSInteger) -> id
|
view_for_column::<T> as extern "C" fn(&Object, _, id, id, NSInteger) -> id,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(tableViewSelectionDidChange:),
|
sel!(tableViewSelectionDidChange:),
|
||||||
selection_did_change::<T> as extern "C" fn(&Object, _, id)
|
selection_did_change::<T> as extern "C" fn(&Object, _, id),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(tableView:rowActionsForRow:edge:),
|
sel!(tableView:rowActionsForRow:edge:),
|
||||||
row_actions_for_row::<T> as extern "C" fn(&Object, _, id, NSInteger, NSInteger) -> id
|
row_actions_for_row::<T> as extern "C" fn(&Object, _, id, NSInteger, NSInteger) -> id,
|
||||||
);
|
);
|
||||||
|
|
||||||
// A slot for some menu handling; we just let it be done here for now rather than do the
|
// A slot for some menu handling; we just let it be done here for now rather than do the
|
||||||
|
@ -234,29 +234,29 @@ pub(crate) fn register_listview_class_with_delegate<T: ListViewDelegate>(instanc
|
||||||
// menu.
|
// menu.
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(menuNeedsUpdate:),
|
sel!(menuNeedsUpdate:),
|
||||||
menu_needs_update::<T> as extern "C" fn(&Object, _, id)
|
menu_needs_update::<T> as extern "C" fn(&Object, _, id),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Drag and drop operations (e.g, accepting files)
|
// Drag and drop operations (e.g, accepting files)
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(draggingEntered:),
|
sel!(draggingEntered:),
|
||||||
dragging_entered::<T> as extern "C" fn(&mut Object, _, _) -> NSUInteger
|
dragging_entered::<T> as extern "C" fn(&mut Object, _, _) -> NSUInteger,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(prepareForDragOperation:),
|
sel!(prepareForDragOperation:),
|
||||||
prepare_for_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL
|
prepare_for_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(performDragOperation:),
|
sel!(performDragOperation:),
|
||||||
perform_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL
|
perform_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(concludeDragOperation:),
|
sel!(concludeDragOperation:),
|
||||||
conclude_drag_operation::<T> as extern "C" fn(&mut Object, _, _)
|
conclude_drag_operation::<T> as extern "C" fn(&mut Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(draggingExited:),
|
sel!(draggingExited:),
|
||||||
dragging_exited::<T> as extern "C" fn(&mut Object, _, _)
|
dragging_exited::<T> as extern "C" fn(&mut Object, _, _),
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub enum RowAnimation {
|
||||||
SlideLeft,
|
SlideLeft,
|
||||||
|
|
||||||
/// Animates in or out by sliding right.
|
/// Animates in or out by sliding right.
|
||||||
SlideRight
|
SlideRight,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<NSUInteger> for RowAnimation {
|
impl Into<NSUInteger> for RowAnimation {
|
||||||
|
@ -37,7 +37,7 @@ impl Into<NSUInteger> for RowAnimation {
|
||||||
RowAnimation::SlideUp => 0x10,
|
RowAnimation::SlideUp => 0x10,
|
||||||
RowAnimation::SlideDown => 0x20,
|
RowAnimation::SlideDown => 0x20,
|
||||||
RowAnimation::SlideLeft => 0x30,
|
RowAnimation::SlideLeft => 0x30,
|
||||||
RowAnimation::SlideRight => 0x40
|
RowAnimation::SlideRight => 0x40,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ pub enum RowEdge {
|
||||||
Leading,
|
Leading,
|
||||||
|
|
||||||
/// The trailing edge.
|
/// The trailing edge.
|
||||||
Trailing
|
Trailing,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<RowEdge> for NSInteger {
|
impl Into<RowEdge> for NSInteger {
|
||||||
|
@ -65,7 +65,7 @@ impl Into<RowEdge> for NSInteger {
|
||||||
// feel like there's a better way to do this, though...
|
// feel like there's a better way to do this, though...
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ pub struct ListView<T = ()> {
|
||||||
|
|
||||||
/// A pointer to the Objective-C runtime center Y layout constraint.
|
/// A pointer to the Objective-C runtime center Y layout constraint.
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
pub center_y: LayoutAnchorY
|
pub center_y: LayoutAnchorY,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ListView {
|
impl Default for ListView {
|
||||||
|
@ -270,14 +270,14 @@ impl ListView {
|
||||||
|
|
||||||
objc: ObjcProperty::retain(view),
|
objc: ObjcProperty::retain(view),
|
||||||
|
|
||||||
scrollview
|
scrollview,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ListView<T>
|
impl<T> ListView<T>
|
||||||
where
|
where
|
||||||
T: ListViewDelegate + 'static
|
T: ListViewDelegate + 'static,
|
||||||
{
|
{
|
||||||
/// Initializes a new View with a given `ViewDelegate`. This enables you to respond to events
|
/// Initializes a new View with a given `ViewDelegate`. This enables you to respond to events
|
||||||
/// and customize the view as a module, similar to class-based systems.
|
/// and customize the view as a module, similar to class-based systems.
|
||||||
|
@ -349,7 +349,7 @@ where
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(anchor_view),
|
center_y: LayoutAnchorY::center(anchor_view),
|
||||||
|
|
||||||
scrollview
|
scrollview,
|
||||||
};
|
};
|
||||||
|
|
||||||
(&mut delegate).did_load(view.clone_as_handle());
|
(&mut delegate).did_load(view.clone_as_handle());
|
||||||
|
@ -401,7 +401,7 @@ impl<T> ListView<T> {
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: self.center_y.clone(),
|
center_y: self.center_y.clone(),
|
||||||
|
|
||||||
scrollview: self.scrollview.clone_as_handle()
|
scrollview: self.scrollview.clone_as_handle(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ impl<T> ListView<T> {
|
||||||
pub fn register<F, R>(&self, identifier: &'static str, vendor: F)
|
pub fn register<F, R>(&self, identifier: &'static str, vendor: F)
|
||||||
where
|
where
|
||||||
F: Fn() -> R + 'static,
|
F: Fn() -> R + 'static,
|
||||||
R: ViewDelegate + 'static
|
R: ViewDelegate + 'static,
|
||||||
{
|
{
|
||||||
self.cell_factory.insert(identifier, vendor);
|
self.cell_factory.insert(identifier, vendor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ extern "C" fn enforce_normalcy(_: &Object, _: Sel) -> BOOL {
|
||||||
extern "C" fn dragging_entered<T: ViewDelegate>(this: &mut Object, _: Sel, info: id) -> NSUInteger {
|
extern "C" fn dragging_entered<T: ViewDelegate>(this: &mut Object, _: Sel, info: id) -> NSUInteger {
|
||||||
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
||||||
view.dragging_entered(DragInfo {
|
view.dragging_entered(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ extern "C" fn prepare_for_drag_operation<T: ViewDelegate>(this: &mut Object, _:
|
||||||
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
||||||
|
|
||||||
match view.prepare_for_drag_operation(DragInfo {
|
match view.prepare_for_drag_operation(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
}) {
|
}) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,10 +50,10 @@ extern "C" fn perform_drag_operation<T: ViewDelegate>(this: &mut Object, _: Sel,
|
||||||
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
||||||
|
|
||||||
match view.perform_drag_operation(DragInfo {
|
match view.perform_drag_operation(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
}) {
|
}) {
|
||||||
true => YES,
|
true => YES,
|
||||||
false => NO
|
false => NO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ extern "C" fn conclude_drag_operation<T: ViewDelegate>(this: &mut Object, _: Sel
|
||||||
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
||||||
|
|
||||||
view.conclude_drag_operation(DragInfo {
|
view.conclude_drag_operation(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ extern "C" fn dragging_exited<T: ViewDelegate>(this: &mut Object, _: Sel, info:
|
||||||
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
let view = load::<T>(this, LISTVIEW_ROW_DELEGATE_PTR);
|
||||||
|
|
||||||
view.dragging_exited(DragInfo {
|
view.dragging_exited(DragInfo {
|
||||||
info: unsafe { Id::from_ptr(info) }
|
info: unsafe { Id::from_ptr(info) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,23 +143,23 @@ pub(crate) fn register_listview_row_class_with_delegate<T: ViewDelegate>() -> *c
|
||||||
// Drag and drop operations (e.g, accepting files)
|
// Drag and drop operations (e.g, accepting files)
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(draggingEntered:),
|
sel!(draggingEntered:),
|
||||||
dragging_entered::<T> as extern "C" fn(&mut Object, _, _) -> NSUInteger
|
dragging_entered::<T> as extern "C" fn(&mut Object, _, _) -> NSUInteger,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(prepareForDragOperation:),
|
sel!(prepareForDragOperation:),
|
||||||
prepare_for_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL
|
prepare_for_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(performDragOperation:),
|
sel!(performDragOperation:),
|
||||||
perform_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL
|
perform_drag_operation::<T> as extern "C" fn(&mut Object, _, _) -> BOOL,
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(concludeDragOperation:),
|
sel!(concludeDragOperation:),
|
||||||
conclude_drag_operation::<T> as extern "C" fn(&mut Object, _, _)
|
conclude_drag_operation::<T> as extern "C" fn(&mut Object, _, _),
|
||||||
);
|
);
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(draggingExited:),
|
sel!(draggingExited:),
|
||||||
dragging_exited::<T> as extern "C" fn(&mut Object, _, _)
|
dragging_exited::<T> as extern "C" fn(&mut Object, _, _),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
|
|
@ -146,7 +146,7 @@ pub struct ListViewRow<T = ()> {
|
||||||
|
|
||||||
/// A pointer to the Objective-C runtime center Y layout constraint.
|
/// A pointer to the Objective-C runtime center Y layout constraint.
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
pub center_y: LayoutAnchorY
|
pub center_y: LayoutAnchorY,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ListViewRow {
|
impl Default for ListViewRow {
|
||||||
|
@ -196,14 +196,14 @@ impl ListViewRow {
|
||||||
center_x: LayoutAnchorX::center(view),
|
center_x: LayoutAnchorX::center(view),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(view)
|
center_y: LayoutAnchorY::center(view),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ListViewRow<T>
|
impl<T> ListViewRow<T>
|
||||||
where
|
where
|
||||||
T: ViewDelegate + 'static
|
T: ViewDelegate + 'static,
|
||||||
{
|
{
|
||||||
/// When we're able to retrieve a reusable view cell from the backing table view, we can check
|
/// When we're able to retrieve a reusable view cell from the backing table view, we can check
|
||||||
/// for the pointer and attempt to reconstruct the ListViewRow<T> that corresponds to this.
|
/// for the pointer and attempt to reconstruct the ListViewRow<T> that corresponds to this.
|
||||||
|
@ -260,7 +260,7 @@ where
|
||||||
center_x: LayoutAnchorX::center(view),
|
center_x: LayoutAnchorX::center(view),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(view)
|
center_y: LayoutAnchorY::center(view),
|
||||||
};
|
};
|
||||||
|
|
||||||
view
|
view
|
||||||
|
@ -316,7 +316,7 @@ where
|
||||||
center_x: LayoutAnchorX::center(view),
|
center_x: LayoutAnchorX::center(view),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: LayoutAnchorY::center(view)
|
center_y: LayoutAnchorY::center(view),
|
||||||
};
|
};
|
||||||
|
|
||||||
(&mut delegate).did_load(view.clone_as_handle());
|
(&mut delegate).did_load(view.clone_as_handle());
|
||||||
|
@ -368,7 +368,7 @@ where
|
||||||
center_x: self.center_x.clone(),
|
center_x: self.center_x.clone(),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: self.center_y.clone()
|
center_y: self.center_y.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ impl<T> ListViewRow<T> {
|
||||||
center_x: self.center_x.clone(),
|
center_x: self.center_x.clone(),
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
center_y: self.center_y.clone()
|
center_y: self.center_y.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1310,13 +1310,13 @@ pub enum NotificationName {
|
||||||
SKStorefrontCountryCodeDidChange,
|
SKStorefrontCountryCodeDidChange,
|
||||||
|
|
||||||
///
|
///
|
||||||
WKAccessibilityReduceMotionStatusDidChange
|
WKAccessibilityReduceMotionStatusDidChange,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NotificationName> for NSString<'_> {
|
impl From<NotificationName> for NSString<'_> {
|
||||||
fn from(name: NotificationName) -> Self {
|
fn from(name: NotificationName) -> Self {
|
||||||
match name {
|
match name {
|
||||||
_ => NSString::no_copy("")
|
_ => NSString::no_copy(""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl Pasteboard {
|
||||||
return Err(Box::new(Error {
|
return Err(Box::new(Error {
|
||||||
code: 666,
|
code: 666,
|
||||||
domain: "com.cacao-rs.pasteboard".to_string(),
|
domain: "com.cacao-rs.pasteboard".to_string(),
|
||||||
description: "Pasteboard server returned no data.".to_string()
|
description: "Pasteboard server returned no data.".to_string(),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub enum PasteboardName {
|
||||||
General,
|
General,
|
||||||
|
|
||||||
/// The ruler pasteboard.
|
/// The ruler pasteboard.
|
||||||
Ruler
|
Ruler,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PasteboardName> for NSString<'_> {
|
impl From<PasteboardName> for NSString<'_> {
|
||||||
|
@ -26,7 +26,7 @@ impl From<PasteboardName> for NSString<'_> {
|
||||||
PasteboardName::Find => "Apple CFPasteboard find",
|
PasteboardName::Find => "Apple CFPasteboard find",
|
||||||
PasteboardName::Font => "Apple CFPasteboard font",
|
PasteboardName::Font => "Apple CFPasteboard font",
|
||||||
PasteboardName::General => "Apple CFPasteboard general",
|
PasteboardName::General => "Apple CFPasteboard general",
|
||||||
PasteboardName::Ruler => "Apple CFPasteboard ruler"
|
PasteboardName::Ruler => "Apple CFPasteboard ruler",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ pub enum PasteboardType {
|
||||||
TabularText,
|
TabularText,
|
||||||
|
|
||||||
/// Tag Image File Format (TIFF) data.
|
/// Tag Image File Format (TIFF) data.
|
||||||
TIFF
|
TIFF,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PasteboardType> for NSString<'_> {
|
impl From<PasteboardType> for NSString<'_> {
|
||||||
|
@ -97,7 +97,7 @@ impl From<PasteboardType> for NSString<'_> {
|
||||||
PasteboardType::Sound => "com.apple.cocoa.pasteboard.sound",
|
PasteboardType::Sound => "com.apple.cocoa.pasteboard.sound",
|
||||||
PasteboardType::String => "public.utf8-plain-text",
|
PasteboardType::String => "public.utf8-plain-text",
|
||||||
PasteboardType::TabularText => "public.utf8-tab-separated-values-text",
|
PasteboardType::TabularText => "public.utf8-tab-separated-values-text",
|
||||||
PasteboardType::TIFF => "public.tiff"
|
PasteboardType::TIFF => "public.tiff",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@ pub enum ProgressIndicatorStyle {
|
||||||
Bar,
|
Bar,
|
||||||
|
|
||||||
/// A spinning circle.
|
/// A spinning circle.
|
||||||
Spinner
|
Spinner,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ProgressIndicatorStyle> for NSUInteger {
|
impl From<ProgressIndicatorStyle> for NSUInteger {
|
||||||
fn from(style: ProgressIndicatorStyle) -> Self {
|
fn from(style: ProgressIndicatorStyle) -> Self {
|
||||||
match style {
|
match style {
|
||||||
ProgressIndicatorStyle::Bar => 0,
|
ProgressIndicatorStyle::Bar => 0,
|
||||||
ProgressIndicatorStyle::Spinner => 1
|
ProgressIndicatorStyle::Spinner => 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue