init
This commit is contained in:
commit
9b1491cebb
157
src/components/app.rs
Normal file
157
src/components/app.rs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
use crate::components::new_project::NewPageModel;
|
||||||
|
use adw::prelude::*;
|
||||||
|
use gtk::prelude::*;
|
||||||
|
use relm4::actions::RelmActionGroup;
|
||||||
|
use relm4::{actions::*, prelude::*, Component, ComponentParts, ComponentSender};
|
||||||
|
use std::{
|
||||||
|
any::Any,
|
||||||
|
borrow::{Borrow, BorrowMut},
|
||||||
|
cell::RefCell,
|
||||||
|
collections::{BTreeMap, HashMap},
|
||||||
|
path::PathBuf,
|
||||||
|
rc::Rc,
|
||||||
|
sync::{Arc, Mutex},
|
||||||
|
};
|
||||||
|
|
||||||
|
relm4::new_action_group!(FileActionGroup, "file");
|
||||||
|
relm4::new_stateless_action!(OpenAction, FileActionGroup, "open");
|
||||||
|
pub type ElementKey = String;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum AppMsg {
|
||||||
|
NewProject
|
||||||
|
}
|
||||||
|
pub struct AppModel {
|
||||||
|
new_page_model: Controller<NewPageModel>,
|
||||||
|
tracker: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum AppCommand {
|
||||||
|
CloseRequest,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(pub)]
|
||||||
|
impl Component for AppModel {
|
||||||
|
type CommandOutput = AppCommand;
|
||||||
|
type Init = ();
|
||||||
|
type Input = AppMsg;
|
||||||
|
type Output = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
main_window=adw::ApplicationWindow {
|
||||||
|
set_default_width: 1200,
|
||||||
|
set_default_height: 900,
|
||||||
|
set_focus_on_click:true,
|
||||||
|
connect_close_request[sender] => move |_| {
|
||||||
|
gtk::Inhibit(true)
|
||||||
|
},
|
||||||
|
gtk::Box{
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_valign:gtk::Align::Fill,
|
||||||
|
set_spacing:2,
|
||||||
|
gtk::HeaderBar{},
|
||||||
|
gtk::Box{
|
||||||
|
set_hexpand: true,
|
||||||
|
set_vexpand: true,
|
||||||
|
#[name="stack"]
|
||||||
|
gtk::Stack{
|
||||||
|
set_transition_type:gtk::StackTransitionType::SlideUp,
|
||||||
|
set_transition_duration:300,
|
||||||
|
set_hexpand:true,
|
||||||
|
set_vexpand:true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
home_page = adw::Clamp{
|
||||||
|
set_maximum_size: 1000,
|
||||||
|
gtk::Box{
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_hexpand: true,
|
||||||
|
set_vexpand: true,
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_halign: gtk::Align::Center,
|
||||||
|
set_spacing: 10,
|
||||||
|
gtk::Label{
|
||||||
|
set_text: "Rayshon Radar Project Tools"
|
||||||
|
},
|
||||||
|
gtk::Button {
|
||||||
|
set_icon_name: "add-filled",
|
||||||
|
connect_clicked[sender] => move |_| {
|
||||||
|
sender.input(AppMsg::NewProject);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
home_stack_page = stack.add_titled(&home_page, Some("home"), "Home") -> gtk::StackPage{},
|
||||||
|
new_project_page = stack.add_titled(model.new_page_model.widget(),Some("new_page"), "New") -> gtk::StackPage{},
|
||||||
|
}
|
||||||
|
|
||||||
|
menu! {
|
||||||
|
main_menu: {
|
||||||
|
"File" {
|
||||||
|
"Open" => OpenAction,
|
||||||
|
"Open Folder" => OpenAction,
|
||||||
|
},
|
||||||
|
"Edit" {
|
||||||
|
"New Layer" => OpenAction,
|
||||||
|
"Undo" => OpenAction,
|
||||||
|
"Redo" => OpenAction,
|
||||||
|
},
|
||||||
|
"Plugins" {
|
||||||
|
"Plugin1" => OpenAction,
|
||||||
|
"Plugin2" => OpenAction,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init(
|
||||||
|
params: Self::Init,
|
||||||
|
root: &Self::Root,
|
||||||
|
sender: ComponentSender<Self>,
|
||||||
|
) -> ComponentParts<Self> {
|
||||||
|
relm4_icons::initialize_icons();
|
||||||
|
let app = relm4::main_application();
|
||||||
|
|
||||||
|
let new_page_model = NewPageModel::builder()
|
||||||
|
.launch(())
|
||||||
|
.forward(sender.input_sender(), |a| AppMsg::NewProject);
|
||||||
|
let model = AppModel {
|
||||||
|
new_page_model,
|
||||||
|
tracker: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
let new_project_page = model.new_page_model.widget();
|
||||||
|
let widgets = view_output!();
|
||||||
|
ComponentParts { model, widgets }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_with_view(
|
||||||
|
&mut self,
|
||||||
|
widgets: &mut Self::Widgets,
|
||||||
|
msg: Self::Input,
|
||||||
|
_sender: ComponentSender<Self>,
|
||||||
|
root: &Self::Root,
|
||||||
|
) {
|
||||||
|
match msg {
|
||||||
|
AppMsg::NewProject => {
|
||||||
|
widgets.stack.set_visible_child_name("new_page");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update_cmd(
|
||||||
|
&mut self,
|
||||||
|
message: Self::CommandOutput,
|
||||||
|
sender: ComponentSender<Self>,
|
||||||
|
root: &Self::Root,
|
||||||
|
) {
|
||||||
|
match message {
|
||||||
|
_ => {
|
||||||
|
println!("test");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
0
src/components/history_list.rs
Normal file
0
src/components/history_list.rs
Normal file
8
src/components/mod.rs
Normal file
8
src/components/mod.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
mod app;
|
||||||
|
mod history_list;
|
||||||
|
mod new_project;
|
||||||
|
mod setting_item;
|
||||||
|
|
||||||
|
pub use app::*;
|
||||||
|
pub use new_project::*;
|
||||||
|
pub use setting_item::*;
|
||||||
78
src/components/new_project.rs
Normal file
78
src/components/new_project.rs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
use adw::prelude::*;
|
||||||
|
use gtk::glib::clone;
|
||||||
|
use gtk::prelude::{BoxExt, ButtonExt, GtkWindowExt, OrientableExt, ToggleButtonExt};
|
||||||
|
use relm4::{prelude::*, view};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::rc::Rc;
|
||||||
|
use gtk::ResponseType::No;
|
||||||
|
use gtk::Widget;
|
||||||
|
use relm4::factory::FactoryVecDeque;
|
||||||
|
use crate::components::setting_item::{SettingItem, SettingType};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct NewPageModel {
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(pub)]
|
||||||
|
impl SimpleComponent for NewPageModel {
|
||||||
|
type Init = ();
|
||||||
|
type Output = ();
|
||||||
|
type Input = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
adw::NavigationSplitView{
|
||||||
|
set_hexpand: true,
|
||||||
|
set_vexpand: true,
|
||||||
|
#[wrap(Some)]
|
||||||
|
set_sidebar = &adw::NavigationPage{
|
||||||
|
#[wrap(Some)]
|
||||||
|
set_child=>k::StackSidebar{
|
||||||
|
set_stack: &stack
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#[wrap(Some)]
|
||||||
|
set_content = &adw::NavigationPage{
|
||||||
|
#[wrap(Some)]
|
||||||
|
#[name="stack"]
|
||||||
|
set_child=>k::Stack {
|
||||||
|
set_hexpand: true,
|
||||||
|
set_vexpand: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
common_setting = gtk::Box{
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
adw::PreferencesPage{
|
||||||
|
set_title: "Common",
|
||||||
|
add=&adw::PreferencesGroup{
|
||||||
|
#[iterate]
|
||||||
|
add:widgets.iter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
algorithm_setting = gtk::Box{},
|
||||||
|
stack.add_titled(&common_setting, Some("Common"), "Common"),
|
||||||
|
stack.add_titled(&algorithm_setting, Some("Algorithm"), "Algorithm"),
|
||||||
|
}
|
||||||
|
fn init(
|
||||||
|
init: Self::Init,
|
||||||
|
root: &Self::Root,
|
||||||
|
sender: relm4::ComponentSender<Self>,
|
||||||
|
) -> relm4::ComponentParts<Self> {
|
||||||
|
let mut common_settings = Vec::new();
|
||||||
|
common_settings.push(SettingItem::new("Name".to_string(), SettingType::Entry(None, None)));
|
||||||
|
common_settings.push(SettingItem::new("Name".to_string(), SettingType::Entry(None, None)));
|
||||||
|
common_settings.push(SettingItem::new("Name".to_string(), SettingType::Entry(None, None)));
|
||||||
|
let widgets:Vec<_> = common_settings.iter_mut().map(|setting: &mut SettingItem| {
|
||||||
|
setting.to_widget()
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
let model = NewPageModel {};
|
||||||
|
|
||||||
|
let widgets = view_output!();
|
||||||
|
ComponentParts { model, widgets }
|
||||||
|
}
|
||||||
|
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {}
|
||||||
|
}
|
||||||
32
src/config.rs
Normal file
32
src/config.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
use crate::components::{SettingItem, SettingType};
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct CommonConfig{
|
||||||
|
pub name: String,
|
||||||
|
pub version: String,
|
||||||
|
pub radars: Vec<RadarConfig>,
|
||||||
|
pub algorithms: Vec<AlgorithmConfig>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive( Clone, Debug)]
|
||||||
|
pub struct RadarConfig{
|
||||||
|
pub name: String,
|
||||||
|
pub _type: String,
|
||||||
|
loc: [f64;3],
|
||||||
|
az_beam_width: f64,
|
||||||
|
el_beam_width: f64,
|
||||||
|
azs_method: usize,
|
||||||
|
els_method: usize,
|
||||||
|
r_limit: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive( Clone, Debug)]
|
||||||
|
pub struct AlgorithmConfig {
|
||||||
|
name: String,
|
||||||
|
version: String,
|
||||||
|
info: HashMap<String, String>
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn default_common_items() {
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user