pub fn checkbox_ptr(&mut self, text: &str, value: &mut bool) -> bool {
        let (id, text) = id_and_text(text, CompType::Checkbox, &self.salt);

        let height = self.default_height();
        let width = height;
        let text_width = self.font.font().width(text, self.style.font_size);

        let pos = self.caret;
        let size = Vec2::new(width, height);

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

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

        // Draw checkbox
        quad(&mut self.draw_data, pos, size, color.0);
        if *value {
            let inset = Vec2::new(4.0, 4.0);
            quad(&mut self.draw_data, pos + inset, size - inset*2.0, color.1);
        }

        // Draw label
        let font_pos = {
            let text_start = self.style.padding.y/2.0 - self.font.font().descent(self.style.font_size);
            pos + Vec2::new(width + self.style.margin.x, height - text_start)
        };
        self.font.cache(text, self.style.font_size, font_pos, self.style.text_color);

        // Properly advance caret
        let total_width = width + text_width + self.style.margin.x;
        self.advance_caret(total_width, height);

        // Return true if the box state was changed
        if self.held == Some(id) && hovered && self.mouse_state.released() {
            *value = !*value;
            true
        } else {
            false
        }
    }
/// Inserts a checkbox with the given label on its right into the gui. Returns `true` if the
/// state of the checkbox (stored in `value`) was changed.
Inserts a checkbox with the given label on its right into the gui. Returns `true` if the
state of the checkbox (stored in `value`) was changed.
Inserts a checkbox with the given label on its right into the gui . Returns ` true ` if the state of the checkbox ( stored in ` value ` ) was changed .
pub fn checkbox_ptr(&mut self, text: &str, value: &mut bool) -> bool {
        let (id, text) = id_and_text(text, CompType::Checkbox, &self.salt);
        let height = self.default_height();
        let width = height;
        let text_width = self.font.font().width(text, self.style.font_size);
        let pos = self.caret;
        let size = Vec2::new(width, height);
        let hovered = self.mouse_pos.x > pos.x && self.mouse_pos.y > pos.y && 
                      self.mouse_pos.x < pos.x + size.x && self.mouse_pos.y < pos.y + size.y;
        if hovered && self.mouse_state.pressed() {
            self.held = Some(id);
        }
        let color = if self.held == Some(id) {
            (self.style.hold_color, self.style.top_hold_color)
        } else if hovered {
            (self.style.hover_color, self.style.top_hold_color)
        } else {
            (self.style.base_color, self.style.top_color)
        };
        // Draw checkbox
        quad(&mut self.draw_data, pos, size, color.0);
        if *value {
            let inset = Vec2::new(4.0, 4.0);
            quad(&mut self.draw_data, pos + inset, size - inset*2.0, color.1);
        }
        // Draw label
        let font_pos = {
            let text_start = self.style.padding.y/2.0 - self.font.font().descent(self.style.font_size);
            pos + Vec2::new(width + self.style.margin.x, height - text_start)
        };
        self.font.cache(text, self.style.font_size, font_pos, self.style.text_color);
        // Properly advance caret
        let total_width = width + text_width + self.style.margin.x;
        self.advance_caret(total_width, height);
        // Return true if the box state was changed
        if self.held == Some(id) && hovered && self.mouse_state.released() {
            *value = !*value;
            true
        } else {
            false
        }
    }
pub fn checkbox_ptr ( & mut self , text : & str , value : & mut bool ) -> bool { let ( id , text ) = id_and_text ( text , CompType :: Checkbox , & self . salt ) ; let height = self . default_height ( ) ; let width = height ; let text_width = self . font . font ( ) . width ( text , self . style . font_size ) ; let pos = self . caret ; let size = Vec2 :: new ( width , height ) ; let hovered = self . mouse_pos . x > pos . x && self . mouse_pos . y > pos . y && self . mouse_pos . x < pos . x + size . x && self . mouse_pos . y < pos . y + size . y ; if hovered && self . mouse_state . pressed ( ) { self . held = Some ( id ) ; } let color = if self . held == Some ( id ) { ( self . style . hold_color , self . style . top_hold_color ) } else if hovered { ( self . style . hover_color , self . style . top_hold_color ) } else { ( self . style . base_color , self . style . top_color ) } ; // Draw checkbox quad ( & mut self . draw_data , pos , size , color . 0 ) ; if * value { let inset = Vec2 :: new ( 4.0 , 4.0 ) ; quad ( & mut self . draw_data , pos + inset , size - inset * 2.0 , color . 1 ) ; } // Draw label let font_pos = { let text_start = self . style . padding . y / 2.0 - self . font . font ( ) . descent ( self . style . font_size ) ; pos + Vec2 :: new ( width + self . style . margin . x , height - text_start ) } ; self . font . cache ( text , self . style . font_size , font_pos , self . style . text_color ) ; // Properly advance caret let total_width = width + text_width + self . style . margin . x ; self . advance_caret ( total_width , height ) ; // Return true if the box state was changed if self . held == Some ( id ) && hovered && self . mouse_state . released ( ) { * value = ! * value ; true } else { false } }
Inserts a checkbox with the given label on its right into the gui.
Inserts a checkbox with the given label on its right into the gui .
&mut self
text
&str
value
&mut bool
&mut self
text
&str
value
&mut bool