plugin_system
This commit is contained in:
parent
8a855557da
commit
faf1995470
143
Cargo.lock
generated
143
Cargo.lock
generated
@ -18,6 +18,54 @@ version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
|
||||
|
||||
[[package]]
|
||||
name = "abi_stable"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69d6512d3eb05ffe5004c59c206de7f99c34951504056ce23fc953842f12c445"
|
||||
dependencies = [
|
||||
"abi_stable_derive",
|
||||
"abi_stable_shared",
|
||||
"const_panic",
|
||||
"core_extensions",
|
||||
"crossbeam-channel",
|
||||
"generational-arena",
|
||||
"libloading 0.7.4",
|
||||
"lock_api",
|
||||
"parking_lot",
|
||||
"paste 1.0.14",
|
||||
"repr_offset",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "abi_stable_derive"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7178468b407a4ee10e881bc7a328a65e739f0863615cca4429d43916b05e898"
|
||||
dependencies = [
|
||||
"abi_stable_shared",
|
||||
"as_derive_utils",
|
||||
"core_extensions",
|
||||
"proc-macro2 1.0.76",
|
||||
"quote 1.0.35",
|
||||
"rustc_version",
|
||||
"syn 1.0.109",
|
||||
"typed-arena",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "abi_stable_shared"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2b5df7688c123e63f4d4d649cba63f2967ba7f7861b1664fca3f77d3dad2b63"
|
||||
dependencies = [
|
||||
"core_extensions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.20.0"
|
||||
@ -128,6 +176,18 @@ version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
||||
|
||||
[[package]]
|
||||
name = "as_derive_utils"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff3c96645900a44cf11941c111bd08a6573b0e2f9f69bc9264b179d8fae753c4"
|
||||
dependencies = [
|
||||
"core_extensions",
|
||||
"proc-macro2 1.0.76",
|
||||
"quote 1.0.35",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.77"
|
||||
@ -419,6 +479,7 @@ dependencies = [
|
||||
name = "cinrad_g"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"abi_stable",
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"cairo-rs",
|
||||
@ -552,6 +613,12 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6"
|
||||
|
||||
[[package]]
|
||||
name = "const_panic"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6051f239ecec86fde3410901ab7860d458d160371533842974fc61f96d15879b"
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.5"
|
||||
@ -610,6 +677,21 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core_extensions"
|
||||
version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92c71dc07c9721607e7a16108336048ee978c3a8b129294534272e8bac96c0ee"
|
||||
dependencies = [
|
||||
"core_extensions_proc_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core_extensions_proc_macros"
|
||||
version = "1.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69f3b219d28b6e3b4ac87bc1fc522e0803ab22e055da177bff0068c4150c61a6"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.8"
|
||||
@ -1485,7 +1567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0051e4d4b01c6e853d7db02f181d08ee0e19d6a53e91bdf80543ceb062f0b57"
|
||||
dependencies = [
|
||||
"bork",
|
||||
"paste",
|
||||
"paste 0.1.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2496,6 +2578,29 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall 0.4.1",
|
||||
"smallvec",
|
||||
"windows-targets 0.48.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.4.2"
|
||||
@ -2517,6 +2622,12 @@ dependencies = [
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
|
||||
|
||||
[[package]]
|
||||
name = "paste-impl"
|
||||
version = "0.1.18"
|
||||
@ -3008,6 +3119,15 @@ dependencies = [
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "repr_offset"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb1070755bd29dffc19d0971cab794e607839ba2ef4b69a9e6fbc8733c1b72ea"
|
||||
dependencies = [
|
||||
"tstr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rgb"
|
||||
version = "0.8.36"
|
||||
@ -3640,6 +3760,21 @@ dependencies = [
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tstr"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cca3264971090dec0feef3b455a3c178f02762f7550cf4592991ac64b3be2d7e"
|
||||
dependencies = [
|
||||
"tstr_proc_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tstr_proc_macros"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e78122066b0cb818b8afd08f7ed22f7fdbc3e90815035726f0840d0d26c0747a"
|
||||
|
||||
[[package]]
|
||||
name = "ttf-parser"
|
||||
version = "0.17.1"
|
||||
@ -3658,6 +3793,12 @@ version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
|
||||
|
||||
[[package]]
|
||||
name = "typed-arena"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.16.0"
|
||||
|
||||
@ -67,6 +67,7 @@ gl = "0.14.0"
|
||||
crossbeam = "0.8.4"
|
||||
chrono = "0.4.32"
|
||||
tracker = "0.2.1"
|
||||
abi_stable = "0.11.3"
|
||||
# plotters-cairo = "0.5.0"
|
||||
|
||||
|
||||
|
||||
@ -1,41 +1,36 @@
|
||||
use super::{control_panel::ControlPanelModel, render_panel::RenderPanelModel};
|
||||
use gtk::{
|
||||
prelude::{
|
||||
ApplicationExt, BoxExt, ButtonExt, DialogExt, GtkWindowExt, ToggleButtonExt, WidgetExt,
|
||||
},
|
||||
prelude::{ApplicationExt, BoxExt, GtkWindowExt, WidgetExt},
|
||||
traits::OrientableExt,
|
||||
};
|
||||
use relm4::actions::{AccelsPlus, ActionablePlus, RelmAction, RelmActionGroup};
|
||||
use relm4::actions::{AccelsPlus, RelmAction, RelmActionGroup};
|
||||
use relm4::*;
|
||||
use relm4::{gtk, ComponentParts, ComponentSender, RelmWidgetExt, SimpleComponent};
|
||||
use relm4_components::open_dialog::{
|
||||
OpenDialog, OpenDialogMsg, OpenDialogResponse, OpenDialogSettings,
|
||||
};
|
||||
|
||||
relm4::new_action_group!(WindowActionGroup, "win");
|
||||
relm4::new_stateless_action!(ExampleAction, WindowActionGroup, "example");
|
||||
relm4::new_stateful_action!(ExampleU8Action, WindowActionGroup, "example2", u8, u8);
|
||||
relm4::new_action_group!(FileActionGroup, "file");
|
||||
relm4::new_stateless_action!(OpenAction, FileActionGroup, "open");
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum AppMode {
|
||||
View,
|
||||
Edit,
|
||||
Export,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum AppMsg {
|
||||
SetMode(AppMode),
|
||||
CloseRequest,
|
||||
Close,
|
||||
OpenDialog,
|
||||
OpenDialogMulti,
|
||||
}
|
||||
|
||||
pub struct AppModel {
|
||||
mode: AppMode,
|
||||
open_dialog: Controller<OpenDialog>,
|
||||
control: Controller<ControlPanelModel>,
|
||||
render: Controller<RenderPanelModel>,
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for AppModel {
|
||||
type Init = AppMode;
|
||||
type Init = ();
|
||||
type Input = AppMsg;
|
||||
type Output = ();
|
||||
|
||||
@ -45,19 +40,35 @@ impl SimpleComponent for AppModel {
|
||||
set_default_width: 1200,
|
||||
set_default_height: 900,
|
||||
set_focus_on_click:true,
|
||||
connect_close_request[sender,app] => move |_| {
|
||||
sender.input(AppMsg::CloseRequest);
|
||||
app.quit();
|
||||
gtk::Inhibit(true)
|
||||
},
|
||||
gtk::Box{
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
set_valign:gtk::Align::Fill,
|
||||
set_spacing:2,
|
||||
adw::HeaderBar {
|
||||
#[wrap(Some)]
|
||||
set_title_widget = &adw::WindowTitle {
|
||||
}
|
||||
gtk::HeaderBar{
|
||||
},
|
||||
// adw::HeaderBar {
|
||||
// #[wrap(Some)]
|
||||
// set_title_widget = &adw::WindowTitle {},
|
||||
// connect_show_end_title_buttons_notify[sender] => move |_| {
|
||||
// println!("show end title buttons");
|
||||
// sender.input(AppMsg::OpenDialog);
|
||||
// },
|
||||
// // connect_close_request[sender] => move |_| {
|
||||
// // sender.input(AppMsg::CloseRequest);
|
||||
// // gtk::Inhibit(true)
|
||||
// // },
|
||||
// }
|
||||
gtk::Box{
|
||||
set_margin_top: 2,
|
||||
set_margin_horizontal: 10,
|
||||
gtk::PopoverMenuBar::from_model(Some(&main_menu))->gtk::PopoverMenuBar{},
|
||||
gtk::PopoverMenuBar::from_model(Some(&main_menu))->gtk::PopoverMenuBar{
|
||||
set_hexpand:true,
|
||||
},
|
||||
},
|
||||
model.control.widget(),
|
||||
model.render.widget(),
|
||||
@ -76,10 +87,18 @@ impl SimpleComponent for AppModel {
|
||||
menu! {
|
||||
main_menu: {
|
||||
"File" {
|
||||
"Example" => ExampleAction,
|
||||
"Example2" => ExampleAction,
|
||||
"Example toggle" => ExampleU8Action(1_u8),
|
||||
}
|
||||
"Open" => OpenAction,
|
||||
"Open Folder" => OpenAction,
|
||||
},
|
||||
"Edit" {
|
||||
"New Layer" => OpenAction,
|
||||
"Undo" => OpenAction,
|
||||
"Redo" => OpenAction,
|
||||
},
|
||||
"Plugins" {
|
||||
"Plugin1" => OpenAction,
|
||||
"Plugin2" => OpenAction,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,37 +115,50 @@ impl SimpleComponent for AppModel {
|
||||
.launch(())
|
||||
.forward(sender.input_sender(), |a| AppMsg::Close);
|
||||
|
||||
let dialog = OpenDialog::builder()
|
||||
.transient_for_native(&root)
|
||||
.launch(OpenDialogSettings::default())
|
||||
.forward(sender.input_sender(), |response| match response {
|
||||
OpenDialogResponse::Accept(path) => {
|
||||
println!("Open file: {:?}", path);
|
||||
AppMsg::Close
|
||||
}
|
||||
OpenDialogResponse::Cancel => AppMsg::Close,
|
||||
});
|
||||
|
||||
let app = relm4::main_application();
|
||||
relm4_icons::initialize_icons();
|
||||
|
||||
app.set_accelerators_for_action::<ExampleAction>(&["<primary>W"]);
|
||||
|
||||
let action: RelmAction<ExampleAction> = {
|
||||
RelmAction::new_stateless(move |_| {
|
||||
println!("Statelesss action!");
|
||||
})
|
||||
};
|
||||
|
||||
let action2: RelmAction<ExampleU8Action> =
|
||||
RelmAction::new_stateful_with_target_value(&0, |_, state, _value| {
|
||||
*state ^= 1;
|
||||
dbg!(state);
|
||||
});
|
||||
|
||||
let model = AppModel {
|
||||
mode: AppMode::View,
|
||||
open_dialog: dialog,
|
||||
control: control,
|
||||
render: render,
|
||||
};
|
||||
|
||||
let widgets = view_output!();
|
||||
let mut group = RelmActionGroup::<WindowActionGroup>::new();
|
||||
let mut group = RelmActionGroup::<FileActionGroup>::new();
|
||||
|
||||
app.set_accelerators_for_action::<OpenAction>(&["<primary>O"]);
|
||||
let action: RelmAction<OpenAction> = {
|
||||
RelmAction::new_stateless(move |_| {
|
||||
sender.input(AppMsg::OpenDialog);
|
||||
})
|
||||
};
|
||||
group.add_action(action);
|
||||
group.add_action(action2);
|
||||
group.register_for_widget(&widgets.main_window);
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {}
|
||||
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
|
||||
match msg {
|
||||
AppMsg::CloseRequest => {
|
||||
}
|
||||
AppMsg::Close => {}
|
||||
AppMsg::OpenDialog => {
|
||||
self.open_dialog.emit(OpenDialogMsg::Open);
|
||||
}
|
||||
AppMsg::OpenDialogMulti => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
src/main.rs
10
src/main.rs
@ -1,3 +1,5 @@
|
||||
#![allow(unused)]
|
||||
#![allow(dead_code)]
|
||||
mod utils;
|
||||
use gtk::gio;
|
||||
use std::ptr;
|
||||
@ -13,7 +15,8 @@ mod pipeline;
|
||||
mod render;
|
||||
mod timeline;
|
||||
mod window;
|
||||
use components::app::{AppMode, AppModel};
|
||||
mod plugin_system;
|
||||
use components::app::AppModel;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
const APP_ID: &str = "org.tsuki.radar_g";
|
||||
@ -39,17 +42,16 @@ fn main() {
|
||||
.or_else(|_| libloading::os::windows::Library::open_already_loaded("epoxy-0.dll"))
|
||||
.unwrap();
|
||||
|
||||
// gio::resources_register_include!("p.gresource").expect("Failed to register resources.");
|
||||
|
||||
epoxy::load_with(|name| {
|
||||
unsafe { library.get(name.as_bytes()) }
|
||||
.map(|symbol| *symbol)
|
||||
.unwrap_or(ptr::null())
|
||||
});
|
||||
}
|
||||
|
||||
let relm = relm4::RelmApp::new(APP_ID);
|
||||
initialize_custom_css();
|
||||
relm.run::<AppModel>(AppMode::Edit);
|
||||
relm.run::<AppModel>(());
|
||||
}
|
||||
|
||||
fn initialize_custom_css() {
|
||||
|
||||
0
src/plugin_system/mod.rs
Normal file
0
src/plugin_system/mod.rs
Normal file
@ -59,5 +59,5 @@ pub fn creator() {
|
||||
};
|
||||
|
||||
renderer.set_screen_target(Some(fbo));
|
||||
device.destroy_context(&mut context);
|
||||
device.destroy_context(&mut context).unwrap();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user