Implementing UI
deleted: src/content_view.rs modified: src/main.rs new file: src/view.rs new file: src/window.rs
This commit is contained in:
parent
d1227388bc
commit
ec173f860d
@ -1,23 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
27
src/main.rs
27
src/main.rs
@ -1,21 +1,24 @@
|
||||
use cacao::appkit::window::{TitleVisibility, Window, WindowConfig};
|
||||
use cacao::appkit::window::{TitleVisibility, Window, WindowConfig, WindowController};
|
||||
use cacao::appkit::{App, AppDelegate};
|
||||
use cacao::color::Color;
|
||||
use cacao::view::View;
|
||||
use cacao::button::Button;
|
||||
use cacao::view::{SplitViewController, View, ViewDelegate};
|
||||
|
||||
use content_view::ScreenView;
|
||||
use crate::view::details_view::Details;
|
||||
use crate::view::sidebar::MainSidebar;
|
||||
use crate::view::content_view::ScreenView;
|
||||
use crate::window::main_window::MainWindow;
|
||||
|
||||
mod disk_util;
|
||||
mod ipod_util;
|
||||
|
||||
mod content_view;
|
||||
mod view;
|
||||
mod window;
|
||||
|
||||
const VENDOR_ID: u16 = 1452;
|
||||
const PRODUCT_ID: u16 = 4617;
|
||||
|
||||
struct ILoaderApp {
|
||||
window: Window,
|
||||
content: View<ScreenView>
|
||||
window: WindowController<MainWindow>
|
||||
}
|
||||
|
||||
impl AppDelegate for ILoaderApp {
|
||||
@ -24,13 +27,6 @@ impl AppDelegate for ILoaderApp {
|
||||
|
||||
fn did_finish_launching(&self) {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -50,7 +46,6 @@ fn main() {
|
||||
let config = WindowConfig::default();
|
||||
|
||||
App::new("com.alterdekim.iloader", ILoaderApp {
|
||||
window: Window::new(config),
|
||||
content: View::with(ScreenView::new())
|
||||
window: WindowController::with(config, MainWindow::default())
|
||||
}).run();
|
||||
}
|
||||
|
53
src/view.rs
Normal file
53
src/view.rs
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
pub mod sidebar {
|
||||
use cacao::view::{View, ViewDelegate};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MainSidebar {
|
||||
|
||||
}
|
||||
|
||||
impl ViewDelegate for MainSidebar {
|
||||
const NAME: &'static str = "MainSidebar";
|
||||
|
||||
fn did_load(&mut self, _view: View) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod content_view {
|
||||
use cacao::{button::Button, layout::Layout, view::{View, ViewDelegate}};
|
||||
|
||||
pub struct ScreenView {
|
||||
pub btn: Button
|
||||
}
|
||||
|
||||
impl Default for ScreenView {
|
||||
fn default() -> Self {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod details_view {
|
||||
use cacao::{button::Button, layout::Layout, view::{View, ViewDelegate}};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Details {
|
||||
|
||||
}
|
||||
|
||||
impl ViewDelegate for Details {
|
||||
const NAME: &'static str = "Details";
|
||||
}
|
||||
}
|
31
src/window.rs
Normal file
31
src/window.rs
Normal file
@ -0,0 +1,31 @@
|
||||
pub mod main_window {
|
||||
use cacao::{appkit::window::{TitleVisibility, Window, WindowDelegate}, view::SplitViewController};
|
||||
|
||||
use crate::view::{content_view::ScreenView, details_view::Details, sidebar::MainSidebar};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MainWindow {
|
||||
split_view_controller: Option<SplitViewController<MainSidebar, ScreenView, Details>>
|
||||
}
|
||||
|
||||
impl WindowDelegate for MainWindow {
|
||||
const NAME: &'static str = "MainWindow";
|
||||
|
||||
fn did_load(&mut self, window: Window) {
|
||||
window.set_title("ILoader");
|
||||
window.set_title_visibility(TitleVisibility::Hidden);
|
||||
window.set_titlebar_appears_transparent(true);
|
||||
window.set_movable_by_background(true);
|
||||
window.set_autosave_name("CacaoILoader");
|
||||
window.set_minimum_content_size(980., 700.);
|
||||
|
||||
let split_view_controller = SplitViewController::new(MainSidebar::default(),
|
||||
ScreenView::default(),
|
||||
Some(Details::default())); // Some(DetailView::default())
|
||||
|
||||
window.set_content_view_controller(&split_view_controller);
|
||||
|
||||
self.split_view_controller = Some(split_view_controller);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user