-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WidgetMatrix bug in all_widgets.rs #619
Comments
Hmmm I can't seem to be able to recreate this issue on my end? That code snippet looks fine to me also - note that a Sorry if I'm misunderstanding the issue! |
I'm able to recreate the issue. I can verify that it was not there as of my PR #586 |
Thanks a lot for the gif! This is super strange! Even as of testing #623 I am still unable to recreate this issue. Perhaps there's some sort of cross-platform behavioural issue going on or something? I'm finding it difficult to imagine what it might be... @bvssvni if you get a chance at all, could you test the latest version of conrod's all_widgets.rs example? @gkbrk @waynenilsen what version of rustc and platform are you using? I'm on osx 10.10.5, running |
Linux Mint KDE, running |
I'm on a vm running Ubuntu XFCE 15.4 inside of windows 10 running rust beta, don't have access to the machine so i can't say what exact version of rustc i'm running. I was clicking left click with the mouse |
I had got the same problem after updating to the last version. When I check it 5 days ago, it worked fine. Windows 8.1 Bug is reproduced only in debug version. In release version it works correctly. |
I also get this bug on |
I can confirm that it works when compiled on release mode. |
Oh wow, I've only been compiling in release mode so it makes sense that I've missed this. Confirmed it happens for me in debug also. Anyone have any ideas why this might only occur in debug? |
Interestingly, if I add some printing to the // A demonstration using widget_matrix to easily draw
// a matrix of any kind of widget.
let (cols, rows) = (8, 8);
WidgetMatrix::new(cols, rows)
.down(20.0)
.dimensions(260.0, 260.0) // matrix width and height.
.each_widget(|n, col: usize, row: usize| { // called for every matrix elem.
// Color effect for fun.
let (r, g, b, a) = (
0.5 + (col as f32 / cols as f32) / 2.0,
0.75,
1.0 - (row as f32 / rows as f32) / 2.0,
1.0
);
// Now return the widget we want to set in each element position.
// You can return any type that implements `Widget`.
// The returned widget will automatically be positioned and sized to the matrix
// element's rectangle.
Toggle::new(demo.bool_matrix[col][row])
.rgba(r, g, b, a)
.frame(demo.frame_width)
.react(|new_val: bool| {
println!("n: {:?}, col: {:?}, row: {:?}", n, col, row);
demo.bool_matrix[col][row] = new_val
})
})
.set(TOGGLE_MATRIX, ui); It prints a crazy number for
However in release it behaves correctly:
|
Moving the matrix, col and row into // A demonstration using widget_matrix to easily draw
// a matrix of any kind of widget.
let (cols, rows) = (8, 8);
WidgetMatrix::new(cols, rows)
.down(20.0)
.dimensions(260.0, 260.0) // matrix width and height.
.each_widget(|_n, col: usize, row: usize| { // called for every matrix elem.
// Color effect for fun.
let (r, g, b, a) = (
0.5 + (col as f32 / cols as f32) / 2.0,
0.75,
1.0 - (row as f32 / rows as f32) / 2.0,
1.0
);
// Now return the widget we want to set in each element position.
// You can return any type that implements `Widget`.
// The returned widget will automatically be positioned and sized to the matrix
// element's rectangle.
let val = demo.bool_matrix[col][row];
let mat = &mut demo.bool_matrix;
Toggle::new(val)
.rgba(r, g, b, a)
.frame(demo.frame_width)
.react(move |new_val: bool| mat[col][row] = new_val)
})
.set(TOGGLE_MATRIX, ui); |
When you click a box in the all_widgets.rs example, only the first block gets toggled. I presume the bug is because of this line here, when the closure runs it only changes the last value of col and row instead of the col and row when the closure was created.
The text was updated successfully, but these errors were encountered: