Skip to content

Commit

Permalink
[libgui] Label allows the caller to pass in a Font
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Feb 7, 2024
1 parent 087ed72 commit 135d56e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions rust_programs/libgui/src/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ impl Label {
}
}

pub fn new_with_font<F: 'static + Fn(&Label, Size) -> Rect>(
text: &str,
color: Color,
font: Font,
font_size: Size,
sizer: F,
) -> Rc<Self> {
Rc::new(Self {
sizer: RefCell::new(Box::new(sizer)),
container: RefCell::new(None),
frame: RefCell::new(Rect::zero()),
text: RefCell::new(text.to_string()),
font,
font_size,
color,
})
}

pub fn set_text(&self, text: &str) {
self.text.replace(text.to_string());
}
Expand Down

0 comments on commit 135d56e

Please sign in to comment.