mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-01 21:58:43 +00:00
feat: minor ui changes
This commit is contained in:
parent
0682071dbd
commit
1f3df63861
2 changed files with 37 additions and 46 deletions
|
@ -1,9 +1,9 @@
|
||||||
use super::{styles::bordered_container::BorderedContainer, widgets::widgets::hspacer};
|
use super::styles::bordered_container::BorderedContainer;
|
||||||
use crate::{
|
use crate::{
|
||||||
builders::build_monado::get_build_monado_runner,
|
builders::build_monado::get_build_monado_runner,
|
||||||
config::{get_config, save_config, Config},
|
config::{get_config, save_config, Config},
|
||||||
constants::APP_NAME,
|
constants::APP_NAME,
|
||||||
profile::{self, load_profile, Profile},
|
profile::Profile,
|
||||||
profiles::valve_index::valve_index_profile,
|
profiles::valve_index::valve_index_profile,
|
||||||
runner::{Runner, RunnerStatus},
|
runner::{Runner, RunnerStatus},
|
||||||
ui::widgets::widgets::vseparator,
|
ui::widgets::widgets::vseparator,
|
||||||
|
@ -12,7 +12,9 @@ use iced::{
|
||||||
executor,
|
executor,
|
||||||
theme::{Button, Container},
|
theme::{Button, Container},
|
||||||
time,
|
time,
|
||||||
widget::{button, checkbox, column, container, pick_list, row, scrollable, text, text_input},
|
widget::{
|
||||||
|
button, checkbox, column, container, pick_list, row, scrollable, text, text_input, Space,
|
||||||
|
},
|
||||||
Alignment, Application, Command, Element, Length, Padding, Subscription, Theme,
|
Alignment, Application, Command, Element, Length, Padding, Subscription, Theme,
|
||||||
};
|
};
|
||||||
use iced_aw::{Card, Modal};
|
use iced_aw::{Card, Modal};
|
||||||
|
@ -138,7 +140,7 @@ impl Application for MainWin {
|
||||||
Message::ProfileChanged(profile) => {
|
Message::ProfileChanged(profile) => {
|
||||||
if self.config.selected_profile_name != profile.name {
|
if self.config.selected_profile_name != profile.name {
|
||||||
self.config.selected_profile_name = profile.name;
|
self.config.selected_profile_name = profile.name;
|
||||||
save_config(&self.config);
|
save_config(&self.config).expect("Failed to save config");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::EditProfile => {
|
Message::EditProfile => {
|
||||||
|
@ -146,7 +148,7 @@ impl Application for MainWin {
|
||||||
}
|
}
|
||||||
Message::DebugViewChanged(nval) => {
|
Message::DebugViewChanged(nval) => {
|
||||||
self.config.debug_view_enabled = nval;
|
self.config.debug_view_enabled = nval;
|
||||||
save_config(&self.config);
|
save_config(&self.config).expect("Failed to save config");
|
||||||
}
|
}
|
||||||
Message::DebugSearchChanged(term) => self.debug_search_term = term,
|
Message::DebugSearchChanged(term) => self.debug_search_term = term,
|
||||||
Message::InstallMonado => {
|
Message::InstallMonado => {
|
||||||
|
@ -192,7 +194,7 @@ impl Application for MainWin {
|
||||||
|
|
||||||
fn view(&self) -> Element<Message> {
|
fn view(&self) -> Element<Message> {
|
||||||
let debug_view: Element<Message> = match self.config.debug_view_enabled {
|
let debug_view: Element<Message> = match self.config.debug_view_enabled {
|
||||||
false => row![].into(),
|
false => Space::new(Length::Shrink, Length::Shrink).into(),
|
||||||
true => {
|
true => {
|
||||||
let debug_toolbar = container(row![
|
let debug_toolbar = container(row![
|
||||||
pick_list(
|
pick_list(
|
||||||
|
@ -205,7 +207,7 @@ impl Application for MainWin {
|
||||||
Some("Debug".into()),
|
Some("Debug".into()),
|
||||||
Message::LogLevelChanged
|
Message::LogLevelChanged
|
||||||
),
|
),
|
||||||
hspacer!(),
|
Space::new(Length::Fill, Length::Shrink),
|
||||||
text_input("Search...", self.debug_search_term.as_str())
|
text_input("Search...", self.debug_search_term.as_str())
|
||||||
.on_input(Message::DebugSearchChanged),
|
.on_input(Message::DebugSearchChanged),
|
||||||
])
|
])
|
||||||
|
@ -226,25 +228,29 @@ impl Application for MainWin {
|
||||||
];
|
];
|
||||||
|
|
||||||
row![vseparator(), view]
|
row![vseparator(), view]
|
||||||
.width(Length::FillPortion(2))
|
.width(Length::FillPortion(3))
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let toolbar = container(row![
|
let toolbar = container(
|
||||||
pick_list(
|
row![
|
||||||
self.profiles.to_vec(),
|
pick_list(
|
||||||
self.get_selected_profile().cloned(),
|
self.profiles.to_vec(),
|
||||||
Message::ProfileChanged
|
self.get_selected_profile().cloned(),
|
||||||
),
|
Message::ProfileChanged
|
||||||
button("Edit").on_press(Message::EditProfile),
|
),
|
||||||
hspacer!(),
|
button("Edit").on_press(Message::EditProfile),
|
||||||
checkbox(
|
Space::new(Length::Fill, Length::Shrink),
|
||||||
"Debug View",
|
checkbox(
|
||||||
self.config.debug_view_enabled,
|
"Debug View",
|
||||||
Message::DebugViewChanged
|
self.config.debug_view_enabled,
|
||||||
),
|
Message::DebugViewChanged
|
||||||
])
|
),
|
||||||
|
]
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.spacing(3),
|
||||||
|
)
|
||||||
.padding(12)
|
.padding(12)
|
||||||
.style(Container::Custom(Box::new(BorderedContainer)));
|
.style(Container::Custom(Box::new(BorderedContainer)));
|
||||||
|
|
||||||
|
@ -256,16 +262,18 @@ impl Application for MainWin {
|
||||||
false => button("Start").on_press(Message::Start),
|
false => button("Start").on_press(Message::Start),
|
||||||
}
|
}
|
||||||
.padding(Padding::from([6, 24])),
|
.padding(Padding::from([6, 24])),
|
||||||
scrollable(column![
|
scrollable(
|
||||||
button("DEBUG: install monado").on_press(Message::InstallMonado),
|
column![button("DEBUG: install monado").on_press(Message::InstallMonado),]
|
||||||
]) // device info goes here
|
.spacing(6)
|
||||||
|
) // device info goes here
|
||||||
]
|
]
|
||||||
|
.spacing(12)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.padding(12)
|
.padding(12)
|
||||||
.align_items(Alignment::Center);
|
.align_items(Alignment::Center);
|
||||||
|
|
||||||
let main_view = column![monado_view, toolbar,]
|
let main_view = column![monado_view, toolbar,]
|
||||||
.width(Length::FillPortion(1))
|
.width(Length::FillPortion(2))
|
||||||
.height(Length::Fill);
|
.height(Length::Fill);
|
||||||
|
|
||||||
let win_content = row![main_view, debug_view,];
|
let win_content = row![main_view, debug_view,];
|
||||||
|
@ -273,11 +281,9 @@ impl Application for MainWin {
|
||||||
Modal::new(self.show_build_monado_modal, win_content, || {
|
Modal::new(self.show_build_monado_modal, win_content, || {
|
||||||
Card::new(
|
Card::new(
|
||||||
text("Installing Monado..."),
|
text("Installing Monado..."),
|
||||||
column![
|
column![scrollable(text(self.build_monado_log.clone())),].spacing(12),
|
||||||
scrollable(text(self.build_monado_log.clone())),
|
)
|
||||||
]
|
.foot(row![
|
||||||
.spacing(12),
|
|
||||||
).foot(row![
|
|
||||||
button("Close").on_press(Message::CloseBuildMonadoModal),
|
button("Close").on_press(Message::CloseBuildMonadoModal),
|
||||||
])
|
])
|
||||||
.max_width(600.0)
|
.max_width(600.0)
|
||||||
|
|
|
@ -1,22 +1,7 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod widgets {
|
pub mod widgets {
|
||||||
macro_rules! vspacer {
|
|
||||||
() => {
|
|
||||||
column![].height(Length::Fill)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! hspacer {
|
|
||||||
() => {
|
|
||||||
row![].width(Length::Fill)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
use iced::Length;
|
use iced::Length;
|
||||||
use iced_aw::quad::{Quad, InnerBounds};
|
use iced_aw::quad::{Quad, InnerBounds};
|
||||||
pub(crate) use vspacer;
|
|
||||||
pub(crate) use hspacer;
|
|
||||||
|
|
||||||
pub fn vseparator() -> Quad {
|
pub fn vseparator() -> Quad {
|
||||||
Quad {
|
Quad {
|
||||||
width: Length::Fixed(1.0),
|
width: Length::Fixed(1.0),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue