From d1227388bc017c7427b906fc6bbfe0044830c0ed Mon Sep 17 00:00:00 2001 From: "alterwain@protonmail.com" Date: Thu, 5 Dec 2024 04:05:03 +0200 Subject: [PATCH] new file: src/content_view.rs modified: src/main.rs --- src/content_view.rs | 23 +++++++++++++++++++++++ src/main.rs | 40 +++++++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 src/content_view.rs diff --git a/src/content_view.rs b/src/content_view.rs new file mode 100644 index 0000000..adf4790 --- /dev/null +++ b/src/content_view.rs @@ -0,0 +1,23 @@ +use cacao::{appkit::toolbar::Toolbar, button::Button, layout::Layout, view::{View, ViewDelegate}}; + +pub struct ScreenView { + //pub toolbar: Toolbar + pub btn: Button +} + +impl ScreenView { + pub fn new() -> Self { + //let toolbar = Toolbar::new("toolbar", delegate); + let btn = Button::new("test"); + + Self { btn } + } +} + +impl ViewDelegate for ScreenView { + const NAME: &'static str = "ScreenView"; + + fn did_load(&mut self, view: View) { + view.add_subview(&self.btn); + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 7ee19fd..ae03436 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,25 +1,42 @@ +use cacao::appkit::window::{TitleVisibility, Window, WindowConfig}; use cacao::appkit::{App, AppDelegate}; -use cacao::appkit::window::Window; use cacao::color::Color; +use cacao::view::View; + +use content_view::ScreenView; mod disk_util; mod ipod_util; +mod content_view; + const VENDOR_ID: u16 = 1452; const PRODUCT_ID: u16 = 4617; -#[derive(Default)] -struct BasicApp { - window: Window +struct ILoaderApp { + window: Window, + content: View } -impl AppDelegate for BasicApp { +impl AppDelegate for ILoaderApp { + /// There should be stuff which loads underlying logic for communication with IPod + fn will_finish_launching(&self) {} + fn did_finish_launching(&self) { - self.window.set_minimum_content_size(400., 400.); - self.window.set_title("Hello World!"); - self.window.set_background_color(Color::rgb(255, 0,0)); + App::activate(); + + self.window.set_title("ILoader"); + self.window.set_title_visibility(TitleVisibility::Hidden); + self.window.set_titlebar_appears_transparent(true); + self.window.set_movable_by_background(true); + self.window.set_autosave_name("CacaoILoader"); + self.window.set_content_view(&self.content); self.window.show(); } + + fn should_terminate_after_last_window_closed(&self) -> bool { + true + } } fn main() { @@ -30,5 +47,10 @@ fn main() { println!("{}", ipod_util::get_ipod_path().is_some()); } }*/ - App::new("com.hello.world", BasicApp::default()).run(); + let config = WindowConfig::default(); + + App::new("com.alterdekim.iloader", ILoaderApp { + window: Window::new(config), + content: View::with(ScreenView::new()) + }).run(); }