commit before rewrite

This commit is contained in:
Nickiel12 2024-05-22 19:01:24 -06:00
parent 4b284cc7eb
commit a62eb7fdf1
2 changed files with 37 additions and 24 deletions

View file

@ -18,12 +18,15 @@ use crate::remote_sources::TrackerState;
mod settings_modal;
mod socket_panel;
mod tracker_panel;
mod control_panel;
use socket_panel::SocketPanel;
use tracker_panel::TrackerPanel;
pub enum GuiUpdate {
SocketState(bool),
SocketDisconnected,
SocketConnecting,
SocketConnected,
MoveEvent(MoveEvent),
UpdatePaintable(gstreamer::Element),
}
@ -257,27 +260,35 @@ pub fn build_ui(app: &Application, config: Arc<RwLock<AppConfig>>, runtime: Hand
format!("X: {:>4} Y: {:>4}", msg.x, msg.y).as_str()
);
}
GuiUpdate::SocketState(v) => {
let label = {
if v {
// tabpanel.set_show_tabs(true);
"Currently Connected"
} else {
// tabpanel.set_page(0);
// tabpanel.set_show_tabs(false);
"Currently Disconnected"
}
};
GuiUpdate::SocketConnected => {
tabpanel.set_show_tabs(true);
socket_panel.button_label(label);
conn_status_label.set_label(label);
if v {
conn_status_label.set_css_classes(&["YesConnection"]);
// button.set_css_classes(&["YesConnection"]);
} else {
conn_status_label.set_css_classes(&["NoConnection"]);
// button.set_css_classes(&["NoConnection"]);
}
socket_panel.button_enable(true);
socket_panel.button_label("Press to Disconnect");
conn_status_label.set_label("Connected");
conn_status_label.set_css_classes(&["YesConnection"]);
},
GuiUpdate::SocketConnecting => {
tabpanel.set_show_tabs(true);
socket_panel.button_enable(true);
socket_panel.button_label("Press to Cancel");
conn_status_label.set_label("Connected");
conn_status_label.set_css_classes(&["LoadingConnection"]);
},
GuiUpdate::SocketDisconnected => {
tabpanel.set_page(0);
tabpanel.set_show_tabs(false);
socket_panel.button_enable(false);
socket_panel.button_label("Press to Connect to Camera");
conn_status_label.set_label("Not Connected to Camera");
conn_status_label.set_css_classes(&["NoConnection"]);
}
GuiUpdate::UpdatePaintable(sink) => {
let paintable = sink.property::<Paintable>("paintable");

View file

@ -1,8 +1,6 @@
use async_channel::Sender;
use gtk::{
glib,
prelude::{BoxExt, ButtonExt},
Box, Button,
glib, prelude::{BoxExt, ButtonExt, WidgetExt}, Box, Button
};
use log::error;
@ -43,6 +41,10 @@ impl SocketPanel {
self.connect_button.set_label(new_label);
}
pub fn button_enable(&self, new_state: bool) {
self.connect_button.set_sensitive(new_state);
}
pub fn connect_button_callback(&self, to_mec: Sender<ApplicationEvent>) {
self.connect_button.connect_clicked(glib::clone!(@strong to_mec => move |_button| {
match to_mec.try_send(ApplicationEvent::StartCameraSocket) {