Add margin to text
This commit is contained in:
parent
62c4cc8f26
commit
602ad96cfe
1 changed files with 9 additions and 4 deletions
|
|
@ -2,9 +2,9 @@ use cosmic_text::{Attrs, Metrics};
|
||||||
use palette::Srgba;
|
use palette::Srgba;
|
||||||
use showbits_common::{
|
use showbits_common::{
|
||||||
widgets::{FontStuff, HasFontStuff, Text},
|
widgets::{FontStuff, HasFontStuff, Text},
|
||||||
Tree, WidgetExt,
|
Node, Tree, WidgetExt,
|
||||||
};
|
};
|
||||||
use taffy::style_helpers::length;
|
use taffy::style_helpers::{length, percent};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
|
|
@ -68,14 +68,19 @@ impl Drawer {
|
||||||
fn on_test(&mut self) -> anyhow::Result<()> {
|
fn on_test(&mut self) -> anyhow::Result<()> {
|
||||||
let mut tree = Tree::<Context>::new(Srgba::new(1.0, 1.0, 1.0, 1.0));
|
let mut tree = Tree::<Context>::new(Srgba::new(1.0, 1.0, 1.0, 1.0));
|
||||||
|
|
||||||
let root = Text::simple(
|
let text = Text::simple(
|
||||||
&mut self.ctx.font_stuff,
|
&mut self.ctx.font_stuff,
|
||||||
Metrics::new(16.0, 32.0),
|
Metrics::new(16.0, 32.0),
|
||||||
Attrs::new(),
|
Attrs::new(),
|
||||||
"Hello world!",
|
"Hello world!",
|
||||||
)
|
)
|
||||||
.node()
|
.node()
|
||||||
.margin_all(length(10.0))
|
.margin_horiz(length(10.0))
|
||||||
|
.register(&mut tree)?;
|
||||||
|
|
||||||
|
let root = Node::empty()
|
||||||
|
.size_width(percent(1.0))
|
||||||
|
.child(text)
|
||||||
.register(&mut tree)?;
|
.register(&mut tree)?;
|
||||||
|
|
||||||
self.printer.print_tree(&mut tree, &mut self.ctx, root)?;
|
self.printer.print_tree(&mut tree, &mut self.ctx, root)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue