💄 you can now add more ports, but it's still not useful
parent
227c9f7ba4
commit
17ed6cc4c5
|
@ -37,6 +37,7 @@ struct Opt {
|
||||||
enum Message {
|
enum Message {
|
||||||
OpenPort (usize),
|
OpenPort (usize),
|
||||||
ClosePort (usize),
|
ClosePort (usize),
|
||||||
|
AddPort,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GuiClient <'a> {
|
struct GuiClient <'a> {
|
||||||
|
@ -145,10 +146,12 @@ fn main () -> anyhow::Result <()> {
|
||||||
col.set_size (&mut row, 30);
|
col.set_size (&mut row, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut ports_col = Flex::default ().column ();
|
||||||
|
|
||||||
let ports = (0..3)
|
let ports = (0..3)
|
||||||
.map (|i| {
|
.map (|i| {
|
||||||
let mut gui = GuiPort::new (fltk_tx, i);
|
let mut gui = GuiPort::new (fltk_tx, i);
|
||||||
col.set_size (&mut gui.row, 30);
|
ports_col.set_size (&mut gui.row, 30);
|
||||||
|
|
||||||
Port {
|
Port {
|
||||||
gui,
|
gui,
|
||||||
|
@ -156,7 +159,11 @@ fn main () -> anyhow::Result <()> {
|
||||||
}
|
}
|
||||||
}).collect ();
|
}).collect ();
|
||||||
|
|
||||||
|
ports_col.end ();
|
||||||
|
|
||||||
let mut but_add_port = Button::default ().with_label ("+");
|
let mut but_add_port = Button::default ().with_label ("+");
|
||||||
|
but_add_port.set_trigger (CallbackTrigger::Release);
|
||||||
|
but_add_port.emit (fltk_tx, Message::AddPort);
|
||||||
col.set_size (&mut but_add_port, 30);
|
col.set_size (&mut but_add_port, 30);
|
||||||
|
|
||||||
col.end ();
|
col.end ();
|
||||||
|
@ -208,6 +215,20 @@ fn main () -> anyhow::Result <()> {
|
||||||
Some (Message::ClosePort (port_idx)) => {
|
Some (Message::ClosePort (port_idx)) => {
|
||||||
gui_client.close_port (port_idx)?;
|
gui_client.close_port (port_idx)?;
|
||||||
},
|
},
|
||||||
|
Some (Message::AddPort) => {
|
||||||
|
let mut gui = GuiPort::new (fltk_tx, gui_client.ports.len ());
|
||||||
|
ports_col.add (&gui.row);
|
||||||
|
ports_col.set_size (&mut gui.row, 30);
|
||||||
|
|
||||||
|
let port = Port {
|
||||||
|
gui,
|
||||||
|
forwarding_instance: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
gui_client.ports.push (port);
|
||||||
|
ports_col.recalc ();
|
||||||
|
ports_col.redraw ();
|
||||||
|
},
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue