From 3a77fd8a91b1bdc2de7d724876f3d49702a48313 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Sun, 7 Feb 2021 20:51:40 -0800 Subject: [PATCH] Fix existing examples --- examples/autolayout.rs | 7 +++++-- examples/window.rs | 4 +++- examples/window_controller.rs | 6 +++++- examples/window_delegate.rs | 7 +++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/autolayout.rs b/examples/autolayout.rs index dc0cb54..0bdc947 100644 --- a/examples/autolayout.rs +++ b/examples/autolayout.rs @@ -5,7 +5,7 @@ use cacao::color::rgb; use cacao::layout::{Layout, LayoutConstraint}; use cacao::view::View; -use cacao::macos::app::{App, AppDelegate}; +use cacao::macos::{App, AppDelegate}; use cacao::macos::window::{Window, WindowConfig, WindowDelegate}; struct BasicApp { @@ -14,6 +14,7 @@ struct BasicApp { impl AppDelegate for BasicApp { fn did_finish_launching(&self) { + App::activate(); self.window.show(); } } @@ -28,7 +29,9 @@ struct AppWindow { } impl WindowDelegate for AppWindow { - fn did_load(&self, window: Window) { + const NAME: &'static str = "WindowDelegate"; + + fn did_load(&mut self, window: Window) { window.set_title("AutoLayout Example"); window.set_minimum_content_size(300., 300.); diff --git a/examples/window.rs b/examples/window.rs index cfa78f2..92e6248 100644 --- a/examples/window.rs +++ b/examples/window.rs @@ -1,6 +1,6 @@ //! This example showcases setting up a basic application and window. -use cacao::macos::app::{App, AppDelegate}; +use cacao::macos::{App, AppDelegate}; use cacao::macos::window::Window; #[derive(Default)] @@ -10,6 +10,8 @@ struct BasicApp { impl AppDelegate for BasicApp { fn did_finish_launching(&self) { + App::activate(); + self.window.set_minimum_content_size(400., 400.); self.window.set_title("A Basic Window"); self.window.show(); diff --git a/examples/window_controller.rs b/examples/window_controller.rs index c5d12da..d7239f9 100644 --- a/examples/window_controller.rs +++ b/examples/window_controller.rs @@ -4,7 +4,7 @@ //! //! If you're not using that, you can probably get by fine with a standard `NSWindow`. -use cacao::macos::app::{App, AppDelegate}; +use cacao::macos::{App, AppDelegate}; use cacao::macos::window::{Window, WindowConfig, WindowController, WindowDelegate}; struct BasicApp { @@ -13,6 +13,8 @@ struct BasicApp { impl AppDelegate for BasicApp { fn did_finish_launching(&self) { + App::activate(); + self.window.show(); } } @@ -21,6 +23,8 @@ impl AppDelegate for BasicApp { struct MyWindow; impl WindowDelegate for MyWindow { + const NAME: &'static str = "MyWindow"; + fn did_load(&mut self, window: Window) { window.set_minimum_content_size(400., 400.); window.set_title("A Basic Window!?"); diff --git a/examples/window_delegate.rs b/examples/window_delegate.rs index d392cf1..267c4a0 100644 --- a/examples/window_delegate.rs +++ b/examples/window_delegate.rs @@ -1,7 +1,7 @@ //! This example showcases setting up a basic application and window delegate. //! Window Delegate's give you lifecycle methods that you can respond to. -use cacao::macos::app::{App, AppDelegate}; +use cacao::macos::{App, AppDelegate}; use cacao::macos::window::{Window, WindowConfig, WindowDelegate}; struct BasicApp { @@ -10,6 +10,7 @@ struct BasicApp { impl AppDelegate for BasicApp { fn did_finish_launching(&self) { + App::activate(); self.window.show(); } } @@ -18,7 +19,9 @@ impl AppDelegate for BasicApp { struct MyWindow; impl WindowDelegate for MyWindow { - fn did_load(&self, window: Window) { + const NAME: &'static str = "MyWindow"; + + fn did_load(&mut self, window: Window) { window.set_minimum_content_size(400., 400.); window.set_title("A Basic Window!?"); }