mirror of https://github.com/wayvr-org/wayvr.git
dash-frontend: clickable links
This commit is contained in:
parent
c3f762a0f3
commit
bb43da3b08
|
|
@ -5,7 +5,7 @@
|
|||
<div position="absolute" width="100%" height="100%" padding="4">
|
||||
<!-- <rectangle width="100%" height="100%" color="#000000" round="6"/> -->
|
||||
</div>
|
||||
<div margin="32" flex_direction="column" align_items="center" gap="16">
|
||||
<div margin="32" flex_direction="column" align_items="center" justify_content="center" gap="16" height="100%">
|
||||
<div gap="16" align_items="center" width="100%">
|
||||
<sprite color="#FFAAAA" src_builtin="dashboard/donate.svg" min_width="64" min_height="64"/>
|
||||
<label wrap="1" size="20" translation="DONATE.DESCRIPTION"/>
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
<TextDescBig translation="WELCOME.ALL_SET"/>
|
||||
<label size="16" wrap="1" translation="WELCOME.BASICS"/>
|
||||
<label size="16" wrap="1" translation="WELCOME.FEATURES_DOCUMENTATION"/>
|
||||
<div flex_direction="row" align_items="center" gap="8">
|
||||
<sprite src_builtin="dashboard/globe.svg" width="24" height="24" color="~color_accent"/>
|
||||
<label size="20" weight="bold" text="wayvr.org" color="~color_accent"/>
|
||||
</div>
|
||||
<Button id="btn_wayvr_org" align_self="baseline" height="48">
|
||||
<sprite src_builtin="dashboard/globe.svg" width="24" height="24" color="~color_accent" margin="8"/>
|
||||
<label size="20" weight="bold" text="wayvr.org" margin_right="8" />
|
||||
</Button>
|
||||
<Button margin_top="16" sprite_src_builtin="dashboard/home.svg" id="btn_home_screen" translation="WELCOME.GO_BACK_HOME" min_height="32" align_self="baseline"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ pub enum FrontendTask {
|
|||
RecenterPlayspace,
|
||||
PushToast(Translation),
|
||||
PlaySound(SoundType),
|
||||
OpenURL(Rc<str>),
|
||||
HideDashboard,
|
||||
}
|
||||
|
||||
|
|
@ -367,6 +368,7 @@ impl<T: 'static> Frontend<T> {
|
|||
FrontendTask::PushToast(content) => self.toast_manager.push(content),
|
||||
FrontendTask::PlaySound(sound_type) => self.queue_play_sound(sound_type),
|
||||
FrontendTask::HideDashboard => self.action_hide_dashboard(params.data),
|
||||
FrontendTask::OpenURL(url) => self.action_open_url(url),
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -542,4 +544,14 @@ impl<T: 'static> Frontend<T> {
|
|||
fn action_hide_dashboard(&mut self, data: &mut T) {
|
||||
self.interface.toggle_dashboard(data);
|
||||
}
|
||||
|
||||
fn action_open_url(&mut self, url: Rc<str>) {
|
||||
let _ = std::process::Command::new("xdg-open").arg(url.as_ref()).spawn();
|
||||
self
|
||||
.tasks
|
||||
.push(FrontendTask::PushToast(Translation::from_raw_text_string(format!(
|
||||
"Opened URL: {}",
|
||||
url
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ use wgui::{
|
|||
assets::AssetPath,
|
||||
components::button::ComponentButton,
|
||||
globals::WguiGlobals,
|
||||
layout::{Layout, WidgetID},
|
||||
parser::{Fetchable, ParseDocumentParams, ParserState, TemplateParams},
|
||||
layout::WidgetID,
|
||||
parser::{Fetchable, ParseDocumentParams, ParserState},
|
||||
task::Tasks,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
frontend::{Frontend, FrontendTask, FrontendTasks},
|
||||
frontend::{Frontend, FrontendTask},
|
||||
tab::{Tab, TabType},
|
||||
};
|
||||
|
||||
|
|
@ -22,8 +22,8 @@ pub struct TabDonate<T> {
|
|||
#[allow(dead_code)]
|
||||
pub state: ParserState,
|
||||
marker: PhantomData<T>,
|
||||
#[allow(dead_code)]
|
||||
tasks: Tasks<Task>,
|
||||
frontend_tasks: FrontendTasks,
|
||||
}
|
||||
|
||||
impl<T> Tab<T> for TabDonate<T> {
|
||||
|
|
@ -31,10 +31,10 @@ impl<T> Tab<T> for TabDonate<T> {
|
|||
TabType::Donate
|
||||
}
|
||||
|
||||
fn update(&mut self, frontend: &mut Frontend<T>, _time_ms: u32, _user_data: &mut T) -> anyhow::Result<()> {
|
||||
for task in self.tasks.drain() {
|
||||
match task {}
|
||||
}
|
||||
fn update(&mut self, _frontend: &mut Frontend<T>, _time_ms: u32, _user_data: &mut T) -> anyhow::Result<()> {
|
||||
// for task in self.tasks.drain() {
|
||||
// match task {}
|
||||
// }
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -52,13 +52,17 @@ impl<T> TabDonate<T> {
|
|||
pub fn new(frontend: &mut Frontend<T>, parent_id: WidgetID, _data: &mut T) -> anyhow::Result<Self> {
|
||||
let state = wgui::parser::parse_from_assets(&doc_params(&frontend.globals), &mut frontend.layout, parent_id)?;
|
||||
|
||||
frontend.tasks.handle_button(
|
||||
&state.fetch_component_as::<ComponentButton>("btn_donate")?,
|
||||
FrontendTask::OpenURL(Rc::from("https://opencollective.com/wayvr-org")),
|
||||
);
|
||||
|
||||
let tasks = Tasks::<Task>::new();
|
||||
|
||||
Ok(Self {
|
||||
state,
|
||||
marker: PhantomData,
|
||||
tasks,
|
||||
frontend_tasks: frontend.tasks.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,6 +145,12 @@ impl<T> TabWelcome<T> {
|
|||
});
|
||||
}
|
||||
|
||||
if let Ok(btn) = state.fetch_component_as::<ComponentButton>("btn_wayvr_org") {
|
||||
self
|
||||
.frontend_tasks
|
||||
.handle_button(&btn, FrontendTask::OpenURL(Rc::from("https://wayvr.org")));
|
||||
}
|
||||
|
||||
self.state_tab = Some(state);
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ pub struct ParsedOpenXrInputPath {
|
|||
pub component: XrInputComponent,
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a str> for ParsedOpenXrInputPath {
|
||||
impl TryFrom<&str> for ParsedOpenXrInputPath {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(path: &str) -> anyhow::Result<Self> {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ impl ViewTrait for View {
|
|||
}
|
||||
Task::UpdateThreshold(action_name, side, i, val) => {
|
||||
let cur_profile = &mut self.profiles[self.cur_profile_idx];
|
||||
let action_mut = get_action_mut(cur_profile, &*action_name);
|
||||
let action_mut = get_action_mut(cur_profile, &action_name);
|
||||
|
||||
let threshold = if matches!(side, XrInputSide::Right) {
|
||||
action_mut.threshold_right.get_or_insert(DEFAULT_BUTTON_THRESHOLDS)
|
||||
|
|
@ -124,10 +124,10 @@ impl ViewTrait for View {
|
|||
*side_mut = None;
|
||||
}
|
||||
"subpath" => {
|
||||
apply_subpath(side_mut, &side, &value, self.controller_profile);
|
||||
apply_subpath(side_mut, side, value, self.controller_profile);
|
||||
}
|
||||
"comp" => {
|
||||
apply_comp(side_mut, &side, &value);
|
||||
apply_comp(side_mut, side, value);
|
||||
}
|
||||
"click" => match value {
|
||||
"triple" => {
|
||||
|
|
@ -244,7 +244,7 @@ impl View {
|
|||
&mut mp,
|
||||
self.list_parent,
|
||||
action.into(),
|
||||
&self.controller_profile,
|
||||
self.controller_profile,
|
||||
current,
|
||||
)?;
|
||||
}
|
||||
|
|
@ -616,7 +616,7 @@ fn create_dropdown<B: 'static + BindingsDropdown>(
|
|||
let title = item.translation();
|
||||
|
||||
context_menu::Cell {
|
||||
action_name: Some(item.action_str(&*action, side)),
|
||||
action_name: Some(item.action_str(&action, side)),
|
||||
title,
|
||||
tooltip: None,
|
||||
attribs: vec![],
|
||||
|
|
@ -624,7 +624,7 @@ fn create_dropdown<B: 'static + BindingsDropdown>(
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if let Some(action_str) = B::clear_str(&*action, side) {
|
||||
if let Some(action_str) = B::clear_str(&action, side) {
|
||||
cells.insert(
|
||||
0,
|
||||
context_menu::Cell {
|
||||
|
|
|
|||
Loading…
Reference in New Issue