commit before rewrite
This commit is contained in:
parent
4b284cc7eb
commit
a62eb7fdf1
2 changed files with 37 additions and 24 deletions
|
@ -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);
|
|
||||||
"Currently Connected"
|
|
||||||
} else {
|
|
||||||
// tabpanel.set_page(0);
|
|
||||||
// tabpanel.set_show_tabs(false);
|
|
||||||
"Currently Disconnected"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
socket_panel.button_label(label);
|
socket_panel.button_enable(true);
|
||||||
conn_status_label.set_label(label);
|
socket_panel.button_label("Press to Disconnect");
|
||||||
if v {
|
conn_status_label.set_label("Connected");
|
||||||
conn_status_label.set_css_classes(&["YesConnection"]);
|
|
||||||
// button.set_css_classes(&["YesConnection"]);
|
conn_status_label.set_css_classes(&["YesConnection"]);
|
||||||
} else {
|
|
||||||
conn_status_label.set_css_classes(&["NoConnection"]);
|
},
|
||||||
// button.set_css_classes(&["NoConnection"]);
|
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) => {
|
GuiUpdate::UpdatePaintable(sink) => {
|
||||||
let paintable = sink.property::<Paintable>("paintable");
|
let paintable = sink.property::<Paintable>("paintable");
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue