From a62eb7fdf10293b2a5c5854d400c5da437e79888 Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Wed, 22 May 2024 19:01:24 -0600 Subject: [PATCH] commit before rewrite --- src/ui/mod.rs | 53 +++++++++++++++++++++++++----------------- src/ui/socket_panel.rs | 8 ++++--- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 5e25521..91bca06 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -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>, 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"); diff --git a/src/ui/socket_panel.rs b/src/ui/socket_panel.rs index 9dea4c7..3b04667 100644 --- a/src/ui/socket_panel.rs +++ b/src/ui/socket_panel.rs @@ -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; @@ -42,6 +40,10 @@ impl SocketPanel { pub fn button_label(&self, new_label: &str) { 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) { self.connect_button.connect_clicked(glib::clone!(@strong to_mec => move |_button| {