Scrollbars typically have 2 types of increments using a mouse, a "line" increment and a "block" increment. A line increment is done by clicking on either arrow at the ends of the scrollbar, while a block increment is done by clicking on either side of the slider. I have a scrollbar that I want to represent a range from 0 to 360 (degrees), with a line increment of 1 (degree), and a block increment of 15 (degrees). How do I do this with the fltk toolkit. I have the following sample Rust program:
// Testing the fltk scrollbar
// Be sure to have the following line in Cargo.toml after [dependencies]:
// fltk = { version = "1.4.15", features = ["fltk-bundled"] }
use fltk::{prelude::*, window::Window, *};
fn main() {
let app = app::App::default();
let mut wind = Window::default()
.with_size(400, 100)
.with_label("Scrollbar test");
let mut col = group::Flex::default_fill().column();
col.set_pad(0);
let mut text = frame::Frame::default().with_label("0");
let mut bar = valuator::Scrollbar::default()
.with_type(valuator::ScrollbarType::Horizontal);
bar.set_range(0.0, 360.0);
bar.set_value(0.0);
// bar.set_step(<f64>, <i32>);
col.fixed(&bar, 20);
col.end();
wind.end();
wind.show();
bar.set_callback({
move |s| {
text.set_label(&(s.value().round() as i32).to_string());
s.parent().unwrap().redraw();
}
});
app.run().unwrap();
}
I tried using different parameters for bar.set_step(...), but could not get line increment to be different than block increment, and there seems to be a built-in default of 16. Is there something else I should try? Desiring to have a line increment of 1, and a block increment of 15. Thanks in advance for any help.