Support label for sliders
tb.select_scrubber_item(&scrubber2_id, 3);
// Create a slider for the popbar.
- let slider1_id = tb.create_slider(0.0, 50.0, true,
+ let slider1_id = tb.create_slider(0.0, 50.0, true, "Slide",
Box::new(move |_s,v| {info!("Slid to: {}", v);}));
tb.update_slider(&slider1_id, 15.0);
///
/// * `min` - Minimum value (slider all the way left)
/// * `max` - Maximum value (slider all the way right)
+ /// * `label` - Text label displayed on left of slider (optional)
/// * `continuous` - Whether callback is called while sliding, or only
/// * `cb` - Callback called when the slider value is changed
/// after it is released.
///
/// A newly allocated slider item
fn create_slider(&mut self, min: f64, max: f64,
+ label: Option<&str>,
continuous: bool, cb: SliderCb) -> ItemId {0}
/// Update the current position of a slider
}
fn create_slider(&mut self, min: f64, max: f64,
+ label: Option<&str>,
continuous: bool, cb: SliderCb) -> ItemId {
unsafe {
let ident = self.generate_ident();
let item: *mut Object = msg_send![cls, alloc];
let item: *mut Object = msg_send![item, initWithIdentifier: ident];
let slider: *mut Object = msg_send![item, slider];
+ if let Some(label) = label {
+ let objc_text: *mut Object = NSString::alloc(nil).init_str(label);
+ msg_send![item, setLabel: objc_text];
+ msg_send![objc_text, release];
+ }
msg_send![slider, setMinValue: min];
msg_send![slider, setMaxValue: max];
msg_send![slider, setContinuous: continuous];