Fix existing examples

This commit is contained in:
Ryan McGrath 2021-02-07 20:51:40 -08:00
parent c507d2e3b2
commit 3a77fd8a91
No known key found for this signature in database
GPG key ID: DA6CBD9233593DEA
4 changed files with 18 additions and 6 deletions

View file

@ -5,7 +5,7 @@ use cacao::color::rgb;
use cacao::layout::{Layout, LayoutConstraint}; use cacao::layout::{Layout, LayoutConstraint};
use cacao::view::View; use cacao::view::View;
use cacao::macos::app::{App, AppDelegate}; use cacao::macos::{App, AppDelegate};
use cacao::macos::window::{Window, WindowConfig, WindowDelegate}; use cacao::macos::window::{Window, WindowConfig, WindowDelegate};
struct BasicApp { struct BasicApp {
@ -14,6 +14,7 @@ struct BasicApp {
impl AppDelegate for BasicApp { impl AppDelegate for BasicApp {
fn did_finish_launching(&self) { fn did_finish_launching(&self) {
App::activate();
self.window.show(); self.window.show();
} }
} }
@ -28,7 +29,9 @@ struct AppWindow {
} }
impl WindowDelegate for 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_title("AutoLayout Example");
window.set_minimum_content_size(300., 300.); window.set_minimum_content_size(300., 300.);

View file

@ -1,6 +1,6 @@
//! This example showcases setting up a basic application and window. //! 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; use cacao::macos::window::Window;
#[derive(Default)] #[derive(Default)]
@ -10,6 +10,8 @@ struct BasicApp {
impl AppDelegate for BasicApp { impl AppDelegate for BasicApp {
fn did_finish_launching(&self) { fn did_finish_launching(&self) {
App::activate();
self.window.set_minimum_content_size(400., 400.); self.window.set_minimum_content_size(400., 400.);
self.window.set_title("A Basic Window"); self.window.set_title("A Basic Window");
self.window.show(); self.window.show();

View file

@ -4,7 +4,7 @@
//! //!
//! If you're not using that, you can probably get by fine with a standard `NSWindow`. //! 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}; use cacao::macos::window::{Window, WindowConfig, WindowController, WindowDelegate};
struct BasicApp { struct BasicApp {
@ -13,6 +13,8 @@ struct BasicApp {
impl AppDelegate for BasicApp { impl AppDelegate for BasicApp {
fn did_finish_launching(&self) { fn did_finish_launching(&self) {
App::activate();
self.window.show(); self.window.show();
} }
} }
@ -21,6 +23,8 @@ impl AppDelegate for BasicApp {
struct MyWindow; struct MyWindow;
impl WindowDelegate for MyWindow { impl WindowDelegate for MyWindow {
const NAME: &'static str = "MyWindow";
fn did_load(&mut self, window: Window) { fn did_load(&mut self, window: Window) {
window.set_minimum_content_size(400., 400.); window.set_minimum_content_size(400., 400.);
window.set_title("A Basic Window!?"); window.set_title("A Basic Window!?");

View file

@ -1,7 +1,7 @@
//! This example showcases setting up a basic application and window delegate. //! This example showcases setting up a basic application and window delegate.
//! Window Delegate's give you lifecycle methods that you can respond to. //! 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}; use cacao::macos::window::{Window, WindowConfig, WindowDelegate};
struct BasicApp { struct BasicApp {
@ -10,6 +10,7 @@ struct BasicApp {
impl AppDelegate for BasicApp { impl AppDelegate for BasicApp {
fn did_finish_launching(&self) { fn did_finish_launching(&self) {
App::activate();
self.window.show(); self.window.show();
} }
} }
@ -18,7 +19,9 @@ impl AppDelegate for BasicApp {
struct MyWindow; struct MyWindow;
impl WindowDelegate for 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_minimum_content_size(400., 400.);
window.set_title("A Basic Window!?"); window.set_title("A Basic Window!?");
} }