Updated RenderScope with positions

This commit is contained in:
2025-08-02 17:07:09 -05:00
parent ec3576e6db
commit ba04a82980
3 changed files with 59 additions and 25 deletions
+9 -5
View File
@@ -32,11 +32,15 @@ impl Element for Heading {
}
}
if let Some(t) = self.font.convert(&s) {
scope.draw_text(&if self.smooth {
format!("{t}").replace("-", "─").replace("|", "│")
} else {
format!("{t}")
});
scope.draw_text(
0,
0,
&if self.smooth {
format!("{t}").replace("-", "─").replace("|", "│")
} else {
format!("{t}")
},
);
}
}
+4 -2
View File
@@ -1,16 +1,18 @@
pub mod div;
pub mod flex;
pub mod heading;
pub mod input;
pub use div::*;
pub use flex::*;
pub use heading::*;
pub use input::*;
use crate::Element;
impl Element for String {
fn render(&mut self, scope: &mut crate::render_scope::RenderScope) {
scope.draw_text(self);
scope.draw_text(0, 0, self);
}
fn as_any(&self) -> &dyn std::any::Any {
@@ -24,7 +26,7 @@ impl Element for String {
impl Element for (String, u32) {
fn render(&mut self, scope: &mut crate::render_scope::RenderScope) {
scope.draw_text_colored(&self.0, self.1);
scope.draw_text_colored(0, 0, &self.0, self.1);
}
fn as_any(&self) -> &dyn std::any::Any {