snap text on shader
This commit is contained in:
@@ -2,16 +2,33 @@ use crate::prelude::*;
|
||||
|
||||
pub struct Text {
|
||||
content: String,
|
||||
attrs: TextAttrs,
|
||||
}
|
||||
|
||||
impl Text {
|
||||
pub fn size(mut self, size: impl UiNum) -> Self {
|
||||
self.attrs.size = size.to_f32();
|
||||
self
|
||||
}
|
||||
pub fn color(mut self, color: UiColor) -> Self {
|
||||
self.attrs.color = color;
|
||||
self
|
||||
}
|
||||
pub fn line_height(mut self, height: f32) -> Self {
|
||||
self.attrs.line_height = height;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ctx> Widget<Ctx> for Text {
|
||||
fn draw(&self, painter: &mut Painter<Ctx>) {
|
||||
painter.draw_text(&self.content);
|
||||
painter.draw_text(&self.content, &self.attrs);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text(text: impl Into<String>) -> Text {
|
||||
Text {
|
||||
content: text.into(),
|
||||
attrs: TextAttrs::default(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user