Skip to content

Instantly share code, notes, and snippets.

@wyhinton
Created December 15, 2020 14:53
Show Gist options
  • Save wyhinton/568aafcd23b82be738090f63c5229a87 to your computer and use it in GitHub Desktop.
Save wyhinton/568aafcd23b82be738090f63c5229a87 to your computer and use it in GitHub Desktop.
Can't get coordinates of widget within group in fltk-rs
use fltk::*;
fn main() {
let app = app::App::default();
let mut win = window::Window::default().with_size(400, 300);
let mut hpack = group::Pack::default().with_size(400, 100);
hpack.set_spacing(10);
hpack.set_type(group::PackType::Horizontal);
let mut b1 = button::Button::new(0,0,100,100,"");
let mut b2 = button::Button::new(0,0,100,100,"");
let mut b3 = button::Button::new(0,0,100,100,"");
// println!("{}", coords(b1.x, b2.y));
// b1.set_label();
hpack.end();
hpack.auto_layout();
b1.set_label(&coords(b1.x(), b1.y()));
b2.set_label(&coords(b2.x(), b2.y()));
b3.set_label(&coords(b3.x(), b3.y()));
fn coords(x: i32, y: i32) -> String{
let myx = x.to_string();
let myy = y.to_string();
let l = vec!["(", &myx, ",", &myy, ")"];
let j = l.join("");
return j;
}
win.end();
win.show();
app.run().unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment