pub fn slider_ptr(&mut self, text: &str, range: Range<f32>, value: &mut f32) -> bool {
        let (id, text) = id_and_text(text, CompType::Slider, &self.salt);

        let width = self.style.comp_width;
        let height = self.default_height();
        let pos = self.caret;
        self.advance_caret(width, height);

        let hovered = self.mouse_pos.x > pos.x && self.mouse_pos.y > pos.y && 
                      self.mouse_pos.x < pos.x + width && self.mouse_pos.y < pos.y + height;
        if hovered && self.mouse_state.pressed() {
            self.held = Some(id);
        } 

        let slider_size = {
            let size = height - self.style.padding.y;
            Vec2::new(size, size)
        };
        let slider_pos = {
            let norm_value = (*value - range.start) / (range.end - range.start);
            let slide_distance = width - self.style.padding.x - slider_size.x;
            pos + Vec2::new(self.style.padding.x/2.0 + norm_value*slide_distance, self.style.padding.y/2.0)
        };

        self.internal_fmt_string.clear();
        write!(self.internal_fmt_string, "{}: {:.*}", text, 2, value).unwrap();

        let changed = if self.held == Some(id) {
            let new_value = {
                let new_value = (self.mouse_pos.x - pos.x - self.style.padding.x/2.0 - slider_size.x/2.0) /
                                (width - self.style.padding.x - slider_size.x);
                range.start + new_value*(range.end - range.start)
            };

            if new_value != *value {
                *value = new_value;
                true
            } else {
                false
            }
        } else { false };

        if *value < range.start { *value = range.start; }
        if *value > range.end   { *value = range.end; }

        let color = if hovered || self.held == Some(id) {
            (self.style.hover_color, self.style.top_hold_color)
        } else {
            (self.style.base_color, self.style.top_color)
        }; 

        let text = &self.internal_fmt_string;
        let size = Vec2::new(width, height);

        // Main bar
        quad(&mut self.draw_data, pos, size, color.0);
        text_in_quad(&mut self.font, self.style.font_size, pos, size, self.style.padding,
                     text, Alignment::Center, self.style.text_color);

        // Slidy thing
        quad(&mut self.draw_data, slider_pos, slider_size, color.1);

        changed
    }
/// Creates a new slider that allows selecting values from the given range. The initial value
/// is taken from `vaule`, and the selected value will be stored in that variable as well.
/// Returns true if the value was changed.
///
/// Every slider should have a unique display text. Buttons with the same name will behave
/// like a singe slider. If the text contains the character sequence "##", that sequence and
/// any subsequent characters will not be shown. Using this, you can have multiple sliders
/// show the same text.
Creates a new slider that allows selecting values from the given range. The initial value
is taken from `vaule`, and the selected value will be stored in that variable as well.
Returns true if the value was changed.

Every slider should have a unique display text. Buttons with the same name will behave
like a singe slider. If the text contains the character sequence "##", that sequence and
any subsequent characters will not be shown. Using this, you can have multiple sliders
show the same text.
Creates a new slider that allows selecting values from the given range . The initial value is taken from ` vaule ` and the selected value will be stored in that variable as well . Returns true if the value was changed . Every slider should have a unique display text . Buttons with the same name will behave like a singe slider . If the text contains the character sequence " ## " that sequence and any subsequent characters will not be shown . Using this you can have multiple sliders show the same text .
pub fn slider_ptr(&mut self, text: &str, range: Range<f32>, value: &mut f32) -> bool {
        let (id, text) = id_and_text(text, CompType::Slider, &self.salt);
        let width = self.style.comp_width;
        let height = self.default_height();
        let pos = self.caret;
        self.advance_caret(width, height);
        let hovered = self.mouse_pos.x > pos.x && self.mouse_pos.y > pos.y && 
                      self.mouse_pos.x < pos.x + width && self.mouse_pos.y < pos.y + height;
        if hovered && self.mouse_state.pressed() {
            self.held = Some(id);
        } 
        let slider_size = {
            let size = height - self.style.padding.y;
            Vec2::new(size, size)
        };
        let slider_pos = {
            let norm_value = (*value - range.start) / (range.end - range.start);
            let slide_distance = width - self.style.padding.x - slider_size.x;
            pos + Vec2::new(self.style.padding.x/2.0 + norm_value*slide_distance, self.style.padding.y/2.0)
        };
        self.internal_fmt_string.clear();
        write!(self.internal_fmt_string, "{}: {:.*}", text, 2, value).unwrap();
        let changed = if self.held == Some(id) {
            let new_value = {
                let new_value = (self.mouse_pos.x - pos.x - self.style.padding.x/2.0 - slider_size.x/2.0) /
                                (width - self.style.padding.x - slider_size.x);
                range.start + new_value*(range.end - range.start)
            };
            if new_value != *value {
                *value = new_value;
                true
            } else {
                false
            }
        } else { false };
        if *value < range.start { *value = range.start; }
        if *value > range.end   { *value = range.end; }
        let color = if hovered || self.held == Some(id) {
            (self.style.hover_color, self.style.top_hold_color)
        } else {
            (self.style.base_color, self.style.top_color)
        }; 
        let text = &self.internal_fmt_string;
        let size = Vec2::new(width, height);
        // Main bar
        quad(&mut self.draw_data, pos, size, color.0);
        text_in_quad(&mut self.font, self.style.font_size, pos, size, self.style.padding,
                     text, Alignment::Center, self.style.text_color);
        // Slidy thing
        quad(&mut self.draw_data, slider_pos, slider_size, color.1);
        changed
    }
pub fn slider_ptr ( & mut self , text : & str , range : Range < f32 > , value : & mut f32 ) -> bool { let ( id , text ) = id_and_text ( text , CompType :: Slider , & self . salt ) ; let width = self . style . comp_width ; let height = self . default_height ( ) ; let pos = self . caret ; self . advance_caret ( width , height ) ; let hovered = self . mouse_pos . x > pos . x && self . mouse_pos . y > pos . y && self . mouse_pos . x < pos . x + width && self . mouse_pos . y < pos . y + height ; if hovered && self . mouse_state . pressed ( ) { self . held = Some ( id ) ; } let slider_size = { let size = height - self . style . padding . y ; Vec2 :: new ( size , size ) } ; let slider_pos = { let norm_value = ( * value - range . start ) / ( range . end - range . start ) ; let slide_distance = width - self . style . padding . x - slider_size . x ; pos + Vec2 :: new ( self . style . padding . x / 2.0 + norm_value * slide_distance , self . style . padding . y / 2.0 ) } ; self . internal_fmt_string . clear ( ) ; write ! ( self internal_fmt_string " " text 2 value ) . unwrap ( ) ; let changed = if self . held == Some ( id ) { let new_value = { let new_value = ( self . mouse_pos . x - pos . x - self . style . padding . x / 2.0 - slider_size . x / 2.0 ) / ( width - self . style . padding . x - slider_size . x ) ; range . start + new_value * ( range . end - range . start ) } ; if new_value != * value { * value = new_value ; true } else { false } } else { false } ; if * value < range . start { * value = range . start ; } if * value > range . end { * value = range . end ; } let color = if hovered || self . held == Some ( id ) { ( self . style . hover_color , self . style . top_hold_color ) } else { ( self . style . base_color , self . style . top_color ) } ; let text = & self . internal_fmt_string ; let size = Vec2 :: new ( width , height ) ; // Main bar quad ( & mut self . draw_data , pos , size , color . 0 ) ; text_in_quad ( & mut self . font , self . style . font_size , pos , size , self . style . padding , text , Alignment :: Center , self . style . text_color ) ; // Slidy thing quad ( & mut self . draw_data , slider_pos , slider_size , color . 1 ) ; changed }
Creates a new slider that allows selecting values from the given range.
Creates a new slider that allows selecting values from the given range .
&mut self
text
&str
range
Range<f32>
value
&mut f32
&mut self
text
&str
range
Range<f32>
value
&mut f32