feat: revealer for steamvr calibration card

This commit is contained in:
Gabriele Musco 2024-05-26 10:37:34 +02:00
commit 10af1ee05f
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE

View file

@ -5,6 +5,7 @@ use super::job_worker::{
}; };
use crate::paths::get_steamvr_bin_dir_path; use crate::paths::get_steamvr_bin_dir_path;
use relm4::{ use relm4::{
binding::{Binding, ConnectBinding, StringBinding},
gtk::{self, prelude::*}, gtk::{self, prelude::*},
ComponentParts, ComponentSender, RelmWidgetExt, SimpleComponent, ComponentParts, ComponentSender, RelmWidgetExt, SimpleComponent,
}; };
@ -58,10 +59,32 @@ impl SimpleComponent for SteamVrCalibrationBox {
add_css_class: "heading", add_css_class: "heading",
set_hexpand: true, set_hexpand: true,
set_xalign: 0.0, set_xalign: 0.0,
set_label: "SteamVR Calibration", set_label: "SteamVR Quick Calibration",
set_wrap: true, set_wrap: true,
set_wrap_mode: gtk::pango::WrapMode::Word, set_wrap_mode: gtk::pango::WrapMode::Word,
}, },
gtk::Button {
add_css_class: "flat",
gtk::Box {
set_orientation: gtk::Orientation::Horizontal,
set_hexpand: true,
set_vexpand: false,
set_spacing: 6,
set_halign: gtk::Align::Start,
#[name(revealer_icon)]
gtk::Image {
set_icon_name: Some("pan-end-symbolic"),
},
gtk::Label {
set_label: "Details"
}
},
connect_clicked[revealer] => move |_| {
revealer.set_reveal_child(!revealer.reveals_child())
},
},
#[name(revealer)]
gtk::Revealer {
gtk::Label { gtk::Label {
add_css_class: "dim-label", add_css_class: "dim-label",
set_hexpand: true, set_hexpand: true,
@ -80,6 +103,7 @@ impl SimpleComponent for SteamVrCalibrationBox {
set_wrap: true, set_wrap: true,
set_wrap_mode: gtk::pango::WrapMode::Word, set_wrap_mode: gtk::pango::WrapMode::Word,
}, },
},
gtk::Label { gtk::Label {
add_css_class: "error", add_css_class: "error",
add_css_class: "success", add_css_class: "success",
@ -203,6 +227,16 @@ impl SimpleComponent for SteamVrCalibrationBox {
let widgets = view_output!(); let widgets = view_output!();
let _ = &widgets
.revealer
.bind_property("reveal-child", &widgets.revealer_icon, "icon-name")
.transform_to(|_, reveal_child| match reveal_child {
true => Some("pan-down-symbolic"),
false => Some("pan-end-symbolic"),
})
.sync_create()
.build();
ComponentParts { model, widgets } ComponentParts { model, widgets }
} }
} }