mirror of https://github.com/wayvr-org/wayvr.git
dash sidebar + bottom buttons
This commit is contained in:
parent
0516270dcb
commit
895e95dcf4
|
|
@ -14,7 +14,10 @@
|
||||||
height="~side_button_size"
|
height="~side_button_size"
|
||||||
color="background_contrast(transparent)"
|
color="background_contrast(transparent)"
|
||||||
border_color="background_contrast"
|
border_color="background_contrast"
|
||||||
hover_border_color="on_background_contrast"
|
hover_color="tertiary"
|
||||||
|
hover_border_color="tertiary(rgb-mult-0.5)"
|
||||||
|
sticky_color="primary"
|
||||||
|
sticky_border_color="primary(rgb-mult-0.5)"
|
||||||
tooltip="${tooltip}"
|
tooltip="${tooltip}"
|
||||||
tooltip_side="${tooltip_side}"
|
tooltip_side="${tooltip_side}"
|
||||||
>
|
>
|
||||||
|
|
@ -22,6 +25,8 @@
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<macro name="button_style" sticky_color="primary" sticky_border_color="primary(rgb-mult-0.5)" hover_color="tertiary" hover_border_color="tertiary(rgb-mult-0.5)" />
|
||||||
|
|
||||||
<elements>
|
<elements>
|
||||||
<!-- left/right separator (menu and rest) -->
|
<!-- left/right separator (menu and rest) -->
|
||||||
<div flex_direction="row" gap="8" width="100%" height="100%" padding="4" interactable="0">
|
<div flex_direction="row" gap="8" width="100%" height="100%" padding="4" interactable="0">
|
||||||
|
|
@ -136,10 +141,10 @@
|
||||||
|
|
||||||
<!-- Left bottom side -->
|
<!-- Left bottom side -->
|
||||||
<div margin_left="8">
|
<div margin_left="8">
|
||||||
<Button id="btn_audio" color="highlight(transparent)" border_color="highlight(transparent)" tooltip="AUDIO.VOLUME" tooltip_side="top">
|
<Button macro="button_style" id="btn_audio" color="highlight(transparent)" border_color="highlight(transparent)" tooltip="AUDIO.VOLUME" tooltip_side="top">
|
||||||
<sprite src_builtin="dashboard/volume.svg" width="24" height="24" margin="8" color="on_background" />
|
<sprite src_builtin="dashboard/volume.svg" width="24" height="24" margin="8" color="on_background" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button id="btn_recenter" color="highlight(transparent)" border_color="highlight(transparent)" tooltip="ACTIONS.RECENTER_PLAYSPACE" tooltip_side="top">
|
<Button macro="button_style" id="btn_recenter" color="highlight(transparent)" border_color="highlight(transparent)" tooltip="ACTIONS.RECENTER_PLAYSPACE" tooltip_side="top">
|
||||||
<sprite src_builtin="dashboard/recenter.svg" width="24" height="24" margin="8" color="on_background" />
|
<sprite src_builtin="dashboard/recenter.svg" width="24" height="24" margin="8" color="on_background" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
use std::{path::PathBuf, rc::Rc};
|
use std::{collections::HashMap, path::PathBuf, rc::Rc};
|
||||||
|
|
||||||
use chrono::Timelike;
|
use chrono::Timelike;
|
||||||
use glam::Vec2;
|
use glam::Vec2;
|
||||||
|
use strum::EnumCount;
|
||||||
use wgui::{
|
use wgui::{
|
||||||
assets::{AssetPath, AssetProvider},
|
assets::{AssetPath, AssetProvider},
|
||||||
components::button::ComponentButton,
|
components::button::ComponentButton,
|
||||||
event::StyleSetRequest,
|
event::{CallbackDataCommon, StyleSetRequest},
|
||||||
font_config::WguiFontConfig,
|
font_config::WguiFontConfig,
|
||||||
globals::WguiGlobals,
|
globals::WguiGlobals,
|
||||||
i18n::Translation,
|
i18n::Translation,
|
||||||
|
|
@ -61,6 +62,7 @@ pub struct Frontend<T> {
|
||||||
state: ParserState,
|
state: ParserState,
|
||||||
|
|
||||||
current_tab: Option<Box<dyn Tab<T>>>,
|
current_tab: Option<Box<dyn Tab<T>>>,
|
||||||
|
side_buttons: Vec<(TabType, Rc<ComponentButton>)>,
|
||||||
|
|
||||||
pub tasks: FrontendTasks,
|
pub tasks: FrontendTasks,
|
||||||
|
|
||||||
|
|
@ -181,6 +183,7 @@ impl<T: 'static> Frontend<T> {
|
||||||
layout,
|
layout,
|
||||||
state,
|
state,
|
||||||
current_tab: None,
|
current_tab: None,
|
||||||
|
side_buttons: Vec::with_capacity(TabType::COUNT),
|
||||||
globals,
|
globals,
|
||||||
tasks,
|
tasks,
|
||||||
ticks: 0,
|
ticks: 0,
|
||||||
|
|
@ -439,6 +442,15 @@ impl<T: 'static> Frontend<T> {
|
||||||
|
|
||||||
self.current_tab = Some(tab);
|
self.current_tab = Some(tab);
|
||||||
|
|
||||||
|
let mut common = CallbackDataCommon {
|
||||||
|
state: &self.layout.state,
|
||||||
|
alterables: &mut self.layout.alterables,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (t, btn) in self.side_buttons.iter() {
|
||||||
|
btn.set_sticky_state(&mut common, tab_type == *t);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,34 +466,29 @@ impl<T: 'static> Frontend<T> {
|
||||||
// ################################
|
// ################################
|
||||||
|
|
||||||
// "Home" side button
|
// "Home" side button
|
||||||
self.tasks.handle_button(
|
let btn = self.state.fetch_component_as::<ComponentButton>("btn_side_home")?;
|
||||||
&self.state.fetch_component_as::<ComponentButton>("btn_side_home")?,
|
self.tasks.handle_button(&btn, FrontendTask::SetTab(TabType::Home));
|
||||||
FrontendTask::SetTab(TabType::Home),
|
self.side_buttons.push((TabType::Home, btn));
|
||||||
);
|
|
||||||
|
|
||||||
// "Apps" side button
|
// "Apps" side button
|
||||||
self.tasks.handle_button(
|
let btn = self.state.fetch_component_as::<ComponentButton>("btn_side_apps")?;
|
||||||
&self.state.fetch_component_as::<ComponentButton>("btn_side_apps")?,
|
self.tasks.handle_button(&btn, FrontendTask::SetTab(TabType::Apps));
|
||||||
FrontendTask::SetTab(TabType::Apps),
|
self.side_buttons.push((TabType::Apps, btn));
|
||||||
);
|
|
||||||
|
|
||||||
// "Games" side button
|
// "Games" side button
|
||||||
self.tasks.handle_button(
|
let btn = self.state.fetch_component_as::<ComponentButton>("btn_side_games")?;
|
||||||
&self.state.fetch_component_as::<ComponentButton>("btn_side_games")?,
|
self.tasks.handle_button(&btn, FrontendTask::SetTab(TabType::Games));
|
||||||
FrontendTask::SetTab(TabType::Games),
|
self.side_buttons.push((TabType::Games, btn));
|
||||||
);
|
|
||||||
|
|
||||||
// "Monado side button"
|
// "Monado side button"
|
||||||
self.tasks.handle_button(
|
let btn = self.state.fetch_component_as::<ComponentButton>("btn_side_monado")?;
|
||||||
&self.state.fetch_component_as::<ComponentButton>("btn_side_monado")?,
|
self.tasks.handle_button(&btn, FrontendTask::SetTab(TabType::Monado));
|
||||||
FrontendTask::SetTab(TabType::Monado),
|
self.side_buttons.push((TabType::Monado, btn));
|
||||||
);
|
|
||||||
|
|
||||||
// "Settings" side button
|
// "Settings" side button
|
||||||
self.tasks.handle_button(
|
let btn = self.state.fetch_component_as::<ComponentButton>("btn_side_settings")?;
|
||||||
&self.state.fetch_component_as::<ComponentButton>("btn_side_settings")?,
|
self.tasks.handle_button(&btn, FrontendTask::SetTab(TabType::Settings));
|
||||||
FrontendTask::SetTab(TabType::Settings),
|
self.side_buttons.push((TabType::Settings, btn));
|
||||||
);
|
|
||||||
|
|
||||||
// ################################
|
// ################################
|
||||||
// BOTTOM BAR BUTTONS
|
// BOTTOM BAR BUTTONS
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use strum::EnumCount;
|
||||||
|
|
||||||
use crate::frontend::Frontend;
|
use crate::frontend::Frontend;
|
||||||
|
|
||||||
pub mod apps;
|
pub mod apps;
|
||||||
|
|
@ -8,7 +10,7 @@ pub mod monado;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
pub mod welcome;
|
pub mod welcome;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumCount)]
|
||||||
pub enum TabType {
|
pub enum TabType {
|
||||||
Home,
|
Home,
|
||||||
Apps,
|
Apps,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue