diff --git a/examples/animation.rs b/examples/animation.rs index c5d2bc5..8d9de6c 100644 --- a/examples/animation.rs +++ b/examples/animation.rs @@ -15,7 +15,7 @@ use cacao::appkit::{AnimationContext, App, AppDelegate}; use cacao::appkit::{Event, EventMask, EventMonitor}; struct BasicApp { - window: Window, + window: Window } impl AppDelegate for BasicApp { @@ -54,22 +54,22 @@ const ANIMATIONS: [[[f64; 5]; 4]; 3] = [ [44., 16., 100., 100., 1.], [128., 84., 144., 124., 1.], [32., 32., 44., 44., 0.7], - [328., 157., 200., 200., 0.7], + [328., 157., 200., 200., 0.7] ], // Red [ [44., 132., 100., 100., 1.], [40., 47., 80., 64., 0.7], [84., 220., 600., 109., 1.0], - [48., 600., 340., 44., 0.7], + [48., 600., 340., 44., 0.7] ], // Green [ [44., 248., 100., 100., 1.], [420., 232., 420., 244., 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. @@ -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.left.constraint_equal_to(&parent.left).offset(animation[1]), 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, red: View, green: View, - key_monitor: Option, + key_monitor: Option } impl WindowDelegate for AppWindow { @@ -139,7 +139,7 @@ impl WindowDelegate for AppWindow { "a" => 1, "s" => 2, "d" => 3, - _ => 4, + _ => 4 }; if animation_index == 4 { @@ -170,11 +170,8 @@ impl WindowDelegate for AppWindow { } fn main() { - App::new( - "com.test.window", - BasicApp { - window: Window::with(WindowConfig::default(), AppWindow::default()), - }, - ) + App::new("com.test.window", BasicApp { + window: Window::with(WindowConfig::default(), AppWindow::default()) + }) .run(); } diff --git a/examples/autolayout.rs b/examples/autolayout.rs index 0fdb031..6bcdecd 100644 --- a/examples/autolayout.rs +++ b/examples/autolayout.rs @@ -10,35 +10,29 @@ use cacao::appkit::window::{Window, WindowConfig, WindowDelegate}; use cacao::appkit::{App, AppDelegate}; struct BasicApp { - window: Window, + window: Window } impl AppDelegate for BasicApp { fn did_finish_launching(&self) { App::set_menu(vec![ - Menu::new( - "", - vec![ - MenuItem::Services, - MenuItem::Separator, - MenuItem::Hide, - MenuItem::HideOthers, - MenuItem::ShowAll, - MenuItem::Separator, - MenuItem::Quit, - ], - ), + Menu::new("", vec![ + MenuItem::Services, + MenuItem::Separator, + MenuItem::Hide, + MenuItem::HideOthers, + MenuItem::ShowAll, + MenuItem::Separator, + MenuItem::Quit, + ]), Menu::new("File", vec![MenuItem::CloseWindow]), Menu::new("View", vec![MenuItem::EnterFullScreen]), - Menu::new( - "Window", - vec![ - MenuItem::Minimize, - MenuItem::Zoom, - MenuItem::Separator, - MenuItem::new("Bring All to Front"), - ], - ), + Menu::new("Window", vec![ + MenuItem::Minimize, + MenuItem::Zoom, + MenuItem::Separator, + MenuItem::new("Bring All to Front"), + ]), ]); App::activate(); @@ -56,7 +50,7 @@ struct AppWindow { content: View, blue: View, red: View, - green: View, + green: View } impl WindowDelegate for AppWindow { @@ -68,7 +62,7 @@ impl WindowDelegate for AppWindow { let dynamic = Color::dynamic(|style| match (style.theme, style.contrast) { (Theme::Dark, _) => Color::SystemGreen, - _ => Color::SystemRed, + _ => Color::SystemRed }); self.blue.set_background_color(Color::SystemBlue); @@ -95,17 +89,14 @@ impl WindowDelegate for AppWindow { self.green.leading.constraint_equal_to(&self.red.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.width.constraint_equal_to_constant(100.), + self.green.width.constraint_equal_to_constant(100.) ]); } } fn main() { - App::new( - "com.test.window", - BasicApp { - window: Window::with(WindowConfig::default(), AppWindow::default()), - }, - ) + App::new("com.test.window", BasicApp { + window: Window::with(WindowConfig::default(), AppWindow::default()) + }) .run(); } diff --git a/examples/browser/main.rs b/examples/browser/main.rs index 4455317..e6433fc 100644 --- a/examples/browser/main.rs +++ b/examples/browser/main.rs @@ -16,7 +16,7 @@ use toolbar::BrowserToolbar; pub enum Action { Back, Forwards, - Load(String), + Load(String) } impl Action { @@ -26,48 +26,39 @@ impl Action { } struct BasicApp { - window: Window, + window: Window } impl AppDelegate for BasicApp { fn did_finish_launching(&self) { App::set_menu(vec![ - Menu::new( - "", - vec![ - MenuItem::Services, - MenuItem::Separator, - MenuItem::Hide, - MenuItem::HideOthers, - MenuItem::ShowAll, - MenuItem::Separator, - MenuItem::Quit, - ], - ), + Menu::new("", vec![ + MenuItem::Services, + MenuItem::Separator, + MenuItem::Hide, + MenuItem::HideOthers, + MenuItem::ShowAll, + MenuItem::Separator, + MenuItem::Quit, + ]), Menu::new("File", vec![MenuItem::CloseWindow]), - Menu::new( - "Edit", - vec![ - MenuItem::Undo, - MenuItem::Redo, - MenuItem::Separator, - MenuItem::Cut, - MenuItem::Copy, - MenuItem::Paste, - MenuItem::Separator, - MenuItem::SelectAll, - ], - ), + Menu::new("Edit", 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( - "Window", - vec![ - MenuItem::Minimize, - MenuItem::Zoom, - MenuItem::Separator, - MenuItem::new("Bring All to Front"), - ], - ), + Menu::new("Window", vec![ + MenuItem::Minimize, + MenuItem::Zoom, + MenuItem::Separator, + MenuItem::new("Bring All to Front"), + ]), Menu::new("Help", vec![]), ]); @@ -92,7 +83,7 @@ impl Dispatcher for BasicApp { }, Action::Load(url) => { window.load_url(&url); - }, + } } } } @@ -104,14 +95,14 @@ impl WebViewDelegate for WebViewInstance {} struct AppWindow { toolbar: Toolbar, - content: WebView, + content: WebView } impl AppWindow { pub fn new() -> Self { AppWindow { toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()), - content: WebView::with(WebViewConfig::default(), WebViewInstance::default()), + content: WebView::with(WebViewConfig::default(), WebViewInstance::default()) } } @@ -137,21 +128,18 @@ impl WindowDelegate for AppWindow { } fn main() { - App::new( - "com.test.window", - BasicApp { - window: Window::with( - { - let mut config = WindowConfig::default(); + App::new("com.test.window", BasicApp { + window: Window::with( + { + let mut config = WindowConfig::default(); - // This flag is necessary for Big Sur to use the correct toolbar style. - config.toolbar_style = WindowToolbarStyle::Expanded; + // This flag is necessary for Big Sur to use the correct toolbar style. + config.toolbar_style = WindowToolbarStyle::Expanded; - config - }, - AppWindow::new(), - ), - }, - ) + config + }, + AppWindow::new() + ) + }) .run(); } diff --git a/examples/browser/toolbar.rs b/examples/browser/toolbar.rs index fcdd8a3..ecdbb6c 100644 --- a/examples/browser/toolbar.rs +++ b/examples/browser/toolbar.rs @@ -27,7 +27,7 @@ pub struct BrowserToolbar { back_item: ToolbarItem, forwards_item: ToolbarItem, url_bar: TextField, - url_bar_item: ToolbarItem, + url_bar_item: ToolbarItem } impl BrowserToolbar { @@ -59,7 +59,7 @@ impl BrowserToolbar { back_item, forwards_item, url_bar, - url_bar_item, + url_bar_item } } @@ -100,7 +100,7 @@ impl ToolbarDelegate for BrowserToolbar { URL_BAR => &self.url_bar_item, _ => { std::unreachable!(); - }, + } } } } diff --git a/examples/calculator/button_row.rs b/examples/calculator/button_row.rs index 3842c1c..053c9bb 100644 --- a/examples/calculator/button_row.rs +++ b/examples/calculator/button_row.rs @@ -8,7 +8,7 @@ use crate::content_view::{button, BUTTON_HEIGHT, BUTTON_WIDTH}; pub struct ButtonRow { pub view: View, - pub buttons: Vec