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 settings_modal;
mod socket_panel; mod socket_panel;
mod tracker_panel; mod tracker_panel;
mod control_panel;
use socket_panel::SocketPanel; use socket_panel::SocketPanel;
use tracker_panel::TrackerPanel; use tracker_panel::TrackerPanel;
pub enum GuiUpdate { pub enum GuiUpdate {
SocketState(bool), SocketDisconnected,
SocketConnecting,
SocketConnected,
MoveEvent(MoveEvent), MoveEvent(MoveEvent),
UpdatePaintable(gstreamer::Element), 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() format!("X: {:>4} Y: {:>4}", msg.x, msg.y).as_str()
); );
} }
GuiUpdate::SocketState(v) => { GuiUpdate::SocketConnected => {
let label = { tabpanel.set_show_tabs(true);
if v {
// tabpanel.set_show_tabs(true); socket_panel.button_enable(true);
"Currently Connected" socket_panel.button_label("Press to Disconnect");
} else { conn_status_label.set_label("Connected");
// tabpanel.set_page(0);
// tabpanel.set_show_tabs(false);
"Currently Disconnected"
}
};
socket_panel.button_label(label);
conn_status_label.set_label(label);
if v {
conn_status_label.set_css_classes(&["YesConnection"]); conn_status_label.set_css_classes(&["YesConnection"]);
// button.set_css_classes(&["YesConnection"]);
} else { },
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"]); conn_status_label.set_css_classes(&["NoConnection"]);
// button.set_css_classes(&["NoConnection"]);
}
} }
GuiUpdate::UpdatePaintable(sink) => { GuiUpdate::UpdatePaintable(sink) => {
let paintable = sink.property::<Paintable>("paintable"); let paintable = sink.property::<Paintable>("paintable");

View file

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