From db4f2c072079e161b27943897c3214dbad44899f Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Fri, 15 Jul 2022 16:14:02 +0200 Subject: [PATCH] Run cargo fmt --- examples/animation.rs | 50 ++-- examples/autolayout.rs | 26 +- examples/browser/main.rs | 53 ++-- examples/browser/toolbar.rs | 9 +- examples/calculator/button_row.rs | 67 ++--- examples/calculator/calculator.rs | 12 +- examples/calculator/content_view.rs | 69 +++-- examples/calculator/main.rs | 7 +- examples/custom_image_drawing.rs | 30 +- examples/frame_layout.rs | 22 +- examples/ios-beta/main.rs | 18 +- examples/text_input.rs | 31 +- examples/todos_list/add/mod.rs | 6 +- examples/todos_list/add/view.rs | 4 +- examples/todos_list/main.rs | 5 +- examples/todos_list/menu.rs | 24 +- examples/todos_list/preferences/advanced.rs | 6 +- examples/todos_list/preferences/general.rs | 15 +- examples/todos_list/preferences/mod.rs | 2 +- .../preferences/toggle_option_view.rs | 6 +- examples/todos_list/preferences/toolbar.rs | 51 ++-- examples/todos_list/storage/defaults.rs | 5 +- examples/todos_list/storage/mod.rs | 2 +- examples/todos_list/storage/todos.rs | 2 +- examples/todos_list/todos/content_view.rs | 2 +- examples/todos_list/todos/list/mod.rs | 27 +- examples/todos_list/todos/list/row.rs | 3 +- examples/todos_list/todos/mod.rs | 4 +- examples/todos_list/todos/toolbar.rs | 5 +- examples/todos_list/windows.rs | 14 +- examples/webview_custom_protocol.rs | 9 +- examples/window.rs | 19 +- examples/window_controller.rs | 22 +- examples/window_delegate.rs | 22 +- rustfmt.toml | 1 + src/appkit/alert.rs | 10 +- src/appkit/animation.rs | 4 +- src/appkit/app/class.rs | 6 +- src/appkit/app/delegate.rs | 280 ++++++++++++------ src/appkit/app/enums.rs | 20 +- src/appkit/app/mod.rs | 27 +- src/appkit/app/traits.rs | 54 +++- src/appkit/cursor.rs | 2 +- src/appkit/enums.rs | 2 +- src/appkit/event/mod.rs | 11 +- src/appkit/menu/item.rs | 28 +- src/appkit/menu/menu.rs | 28 +- src/appkit/toolbar/class.rs | 61 ++-- src/appkit/toolbar/item.rs | 18 +- src/appkit/toolbar/mod.rs | 23 +- src/appkit/toolbar/traits.rs | 6 +- src/appkit/window/class.rs | 192 +++++++----- src/appkit/window/config.rs | 10 +- src/appkit/window/controller/class.rs | 6 +- src/appkit/window/controller/mod.rs | 13 +- src/appkit/window/mod.rs | 87 +++--- src/appkit/window/traits.rs | 12 +- src/button/mod.rs | 22 +- src/color/appkit_dynamic_color.rs | 218 +++++++++----- src/color/mod.rs | 49 +-- src/control/mod.rs | 7 +- src/defaults/mod.rs | 15 +- src/defaults/value.rs | 2 +- src/dragdrop.rs | 12 +- src/filesystem/enums.rs | 4 +- src/filesystem/manager.rs | 12 +- src/filesystem/mod.rs | 1 - src/filesystem/save.rs | 8 +- src/filesystem/select.rs | 14 +- src/filesystem/traits.rs | 8 +- src/foundation/array.rs | 20 +- src/foundation/autoreleasepool.rs | 6 +- src/foundation/class.rs | 29 +- src/foundation/data.rs | 20 +- src/foundation/dictionary.rs | 6 +- src/foundation/mod.rs | 6 +- src/foundation/number.rs | 32 +- src/foundation/string.rs | 12 +- src/foundation/urls/bookmark_options.rs | 4 +- src/foundation/urls/mod.rs | 16 +- src/geometry.rs | 14 +- src/image/appkit.rs | 4 +- src/image/icons.rs | 2 +- src/image/image.rs | 60 ++-- src/image/mod.rs | 16 +- src/input/appkit.rs | 27 +- src/input/mod.rs | 15 +- src/invoker.rs | 15 +- src/layer/mod.rs | 6 +- src/layout/animator.rs | 8 +- src/layout/constraint.rs | 23 +- src/layout/dimension.rs | 27 +- src/layout/horizontal.rs | 84 +++--- src/layout/safe_guide.rs | 2 +- src/layout/traits.rs | 36 +-- src/layout/vertical.rs | 33 +-- src/lib.rs | 5 +- src/listview/actions.rs | 10 +- src/listview/appkit.rs | 116 ++++---- src/listview/enums.rs | 4 +- src/listview/mod.rs | 67 +++-- src/listview/row/appkit.rs | 62 ++-- src/listview/row/mod.rs | 32 +- src/listview/traits.rs | 22 +- src/networking/mod.rs | 12 +- src/notification_center/mod.rs | 2 +- src/notification_center/name.rs | 1 - src/pasteboard/mod.rs | 18 +- src/pasteboard/types.rs | 2 +- src/progress/enums.rs | 2 +- src/progress/mod.rs | 22 +- src/quicklook/config.rs | 6 +- src/quicklook/mod.rs | 4 +- src/scrollview/appkit.rs | 50 ++-- src/scrollview/mod.rs | 25 +- src/scrollview/traits.rs | 12 +- src/select/mod.rs | 34 ++- src/switch.rs | 21 +- src/text/attributed_string.rs | 22 +- src/text/enums.rs | 2 - src/text/font.rs | 14 +- src/text/label/appkit.rs | 8 +- src/text/label/mod.rs | 40 +-- src/text/label/traits.rs | 3 +- src/uikit/app/class.rs | 6 +- src/uikit/app/delegate.rs | 23 +- src/uikit/app/enums.rs | 1 - src/uikit/app/mod.rs | 38 +-- src/uikit/scene/config.rs | 6 +- src/uikit/scene/delegate.rs | 36 +-- src/uikit/scene/enums.rs | 9 +- src/uikit/scene/mod.rs | 9 +- src/uikit/scene/options.rs | 6 +- src/uikit/scene/session.rs | 10 +- src/uikit/scene/traits.rs | 9 +- src/uikit/window/mod.rs | 5 +- src/user_activity.rs | 4 +- src/user_notifications/mod.rs | 5 +- src/user_notifications/notifications.rs | 6 +- src/utils/cell_factory.rs | 15 +- src/utils/mod.rs | 11 +- src/utils/os.rs | 2 +- src/utils/properties.rs | 10 +- src/view/animator.rs | 8 +- src/view/appkit.rs | 54 ++-- src/view/controller/appkit.rs | 18 +- src/view/controller/mod.rs | 8 +- src/view/controller/uikit.rs | 34 ++- src/view/mod.rs | 28 +- src/view/splitviewcontroller/mod.rs | 17 +- src/view/traits.rs | 12 +- src/view/uikit.rs | 4 +- src/webview/actions.rs | 20 +- src/webview/class.rs | 93 ++++-- src/webview/config.rs | 8 +- src/webview/enums.rs | 4 +- src/webview/mimetype.rs | 118 ++++---- src/webview/mod.rs | 43 ++- src/webview/traits.rs | 2 +- 159 files changed, 1925 insertions(+), 1820 deletions(-) diff --git a/examples/animation.rs b/examples/animation.rs index 0b813ee..8d9de6c 100644 --- a/examples/animation.rs +++ b/examples/animation.rs @@ -9,10 +9,10 @@ use cacao::color::Color; use cacao::layout::{Layout, LayoutConstraint, LayoutConstraintAnimatorProxy}; use cacao::view::{View, ViewAnimatorProxy}; -use cacao::appkit::{App, AppDelegate, AnimationContext}; -use cacao::appkit::{Event, EventMask, EventMonitor}; use cacao::appkit::menu::Menu; use cacao::appkit::window::{Window, WindowConfig, WindowDelegate}; +use cacao::appkit::{AnimationContext, App, AppDelegate}; +use cacao::appkit::{Event, EventMask, EventMonitor}; struct BasicApp { window: Window @@ -54,33 +54,26 @@ 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. -fn apply_styles( - view: &View, - parent: &View, - background_color: Color, - animation_table_index: usize -) -> [LayoutConstraint; 4] { +fn apply_styles(view: &View, parent: &View, background_color: Color, animation_table_index: usize) -> [LayoutConstraint; 4] { view.set_background_color(background_color); view.layer.set_corner_radius(16.); parent.add_subview(view); @@ -117,20 +110,24 @@ impl WindowDelegate for AppWindow { let red_frame = apply_styles(&self.red, &self.content, Color::SystemRed, 1); let green_frame = apply_styles(&self.green, &self.content, Color::SystemGreen, 2); - let alpha_animators = [&self.blue, &self.red, &self.green].iter().map(|view| { - view.animator.clone() - }).collect::>(); + let alpha_animators = [&self.blue, &self.red, &self.green] + .iter() + .map(|view| view.animator.clone()) + .collect::>(); - let constraint_animators = [blue_frame, red_frame, green_frame].iter().map(|frame| { - LayoutConstraint::activate(frame); + let constraint_animators = [blue_frame, red_frame, green_frame] + .iter() + .map(|frame| { + LayoutConstraint::activate(frame); - vec![ - frame[0].animator.clone(), - frame[1].animator.clone(), - frame[2].animator.clone(), - frame[3].animator.clone(), - ] - }).collect::>>(); + vec![ + frame[0].animator.clone(), + frame[1].animator.clone(), + frame[2].animator.clone(), + frame[3].animator.clone(), + ] + }) + .collect::>>(); // Monitor key change events for w/a/s/d, and then animate each view to their correct // frame and alpha value. @@ -175,5 +172,6 @@ impl WindowDelegate for AppWindow { fn main() { App::new("com.test.window", BasicApp { window: Window::with(WindowConfig::default(), AppWindow::default()) - }).run(); + }) + .run(); } diff --git a/examples/autolayout.rs b/examples/autolayout.rs index f64b284..6bcdecd 100644 --- a/examples/autolayout.rs +++ b/examples/autolayout.rs @@ -5,9 +5,9 @@ use cacao::color::{Color, Theme}; use cacao::layout::{Layout, LayoutConstraint}; use cacao::view::View; -use cacao::appkit::{App, AppDelegate}; use cacao::appkit::menu::{Menu, MenuItem}; use cacao::appkit::window::{Window, WindowConfig, WindowDelegate}; +use cacao::appkit::{App, AppDelegate}; struct BasicApp { window: Window @@ -23,23 +23,16 @@ impl AppDelegate for BasicApp { MenuItem::HideOthers, MenuItem::ShowAll, MenuItem::Separator, - MenuItem::Quit + MenuItem::Quit, ]), - - Menu::new("File", vec![ - MenuItem::CloseWindow - ]), - - Menu::new("View", vec![ - MenuItem::EnterFullScreen - ]), - + 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") - ]) + MenuItem::new("Bring All to Front"), + ]), ]); App::activate(); @@ -89,16 +82,14 @@ impl WindowDelegate for AppWindow { self.blue.leading.constraint_equal_to(&self.content.leading).offset(16.), self.blue.bottom.constraint_equal_to(&self.content.bottom).offset(-16.), self.blue.width.constraint_equal_to_constant(100.), - self.red.top.constraint_equal_to(&self.content.top).offset(46.), self.red.leading.constraint_equal_to(&self.blue.trailing).offset(16.), self.red.bottom.constraint_equal_to(&self.content.bottom).offset(-16.), - self.green.top.constraint_equal_to(&self.content.top).offset(46.), 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.) ]); } } @@ -106,5 +97,6 @@ impl WindowDelegate for AppWindow { fn main() { App::new("com.test.window", BasicApp { window: Window::with(WindowConfig::default(), AppWindow::default()) - }).run(); + }) + .run(); } diff --git a/examples/browser/main.rs b/examples/browser/main.rs index a386520..e6433fc 100644 --- a/examples/browser/main.rs +++ b/examples/browser/main.rs @@ -4,10 +4,10 @@ use cacao::notification_center::Dispatcher; use cacao::webview::{WebView, WebViewConfig, WebViewDelegate}; -use cacao::appkit::{App, AppDelegate}; use cacao::appkit::menu::{Menu, MenuItem}; use cacao::appkit::toolbar::Toolbar; use cacao::appkit::window::{Window, WindowConfig, WindowDelegate, WindowToolbarStyle}; +use cacao::appkit::{App, AppDelegate}; mod toolbar; use toolbar::BrowserToolbar; @@ -39,13 +39,9 @@ impl AppDelegate for BasicApp { MenuItem::HideOthers, MenuItem::ShowAll, MenuItem::Separator, - MenuItem::Quit + MenuItem::Quit, ]), - - Menu::new("File", vec![ - MenuItem::CloseWindow - ]), - + Menu::new("File", vec![MenuItem::CloseWindow]), Menu::new("Edit", vec![ MenuItem::Undo, MenuItem::Redo, @@ -54,21 +50,16 @@ impl AppDelegate for BasicApp { MenuItem::Copy, MenuItem::Paste, MenuItem::Separator, - MenuItem::SelectAll + MenuItem::SelectAll, ]), - - Menu::new("View", vec![ - MenuItem::EnterFullScreen - ]), - + Menu::new("View", vec![MenuItem::EnterFullScreen]), Menu::new("Window", vec![ MenuItem::Minimize, MenuItem::Zoom, MenuItem::Separator, - MenuItem::new("Bring All to Front") + MenuItem::new("Bring All to Front"), ]), - - Menu::new("Help", vec![]) + Menu::new("Help", vec![]), ]); App::activate(); @@ -84,9 +75,15 @@ impl Dispatcher for BasicApp { let webview = &window.content; match message { - Action::Back => { webview.go_back(); }, - Action::Forwards => { webview.go_forward(); }, - Action::Load(url) => { window.load_url(&url); } + Action::Back => { + webview.go_back(); + }, + Action::Forwards => { + webview.go_forward(); + }, + Action::Load(url) => { + window.load_url(&url); + } } } } @@ -132,13 +129,17 @@ impl WindowDelegate for AppWindow { fn main() { App::new("com.test.window", BasicApp { - window: Window::with({ - 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. - 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()) - }).run(); + config + }, + AppWindow::new() + ) + }) + .run(); } diff --git a/examples/browser/toolbar.rs b/examples/browser/toolbar.rs index 919cd17..ecdbb6c 100644 --- a/examples/browser/toolbar.rs +++ b/examples/browser/toolbar.rs @@ -1,10 +1,9 @@ - use cacao::objc::{msg_send, sel, sel_impl}; use cacao::button::Button; use cacao::input::{TextField, TextFieldDelegate}; -use cacao::appkit::toolbar::{Toolbar, ToolbarDisplayMode, ToolbarItem, ItemIdentifier, ToolbarDelegate}; +use cacao::appkit::toolbar::{ItemIdentifier, Toolbar, ToolbarDelegate, ToolbarDisplayMode, ToolbarItem}; use super::Action; @@ -74,7 +73,7 @@ impl BrowserToolbar { ItemIdentifier::Custom(FWDS_BUTTON), ItemIdentifier::Space, ItemIdentifier::Custom(URL_BAR), - ItemIdentifier::Space + ItemIdentifier::Space, ] } } @@ -99,7 +98,9 @@ impl ToolbarDelegate for BrowserToolbar { BACK_BUTTON => &self.back_item, FWDS_BUTTON => &self.forwards_item, URL_BAR => &self.url_bar_item, - _ => { std::unreachable!(); } + _ => { + std::unreachable!(); + } } } } diff --git a/examples/calculator/button_row.rs b/examples/calculator/button_row.rs index b0bc2d6..053c9bb 100644 --- a/examples/calculator/button_row.rs +++ b/examples/calculator/button_row.rs @@ -1,10 +1,10 @@ -use cacao::layout::{LayoutConstraint, Layout}; use cacao::button::Button; use cacao::color::Color; +use cacao::layout::{Layout, LayoutConstraint}; use cacao::view::View; use crate::calculator::Msg; -use crate::content_view::{button, BUTTON_WIDTH, BUTTON_HEIGHT}; +use crate::content_view::{button, BUTTON_HEIGHT, BUTTON_WIDTH}; pub struct ButtonRow { pub view: View, @@ -15,31 +15,36 @@ impl ButtonRow { pub fn new(x: [Msg; 4], color: Color, action_color: Color) -> Self { let view = View::new(); - let buttons: Vec