Add padding to text::Span
This commit is contained in:
parent
f7fe1edcbb
commit
2796a6bc97
4 changed files with 57 additions and 12 deletions
|
|
@ -262,7 +262,8 @@ pub fn parse<'a>(
|
|||
.font(Font::MONOSPACE)
|
||||
.color(Color::WHITE)
|
||||
.background(color!(0x111111))
|
||||
.border(border::rounded(2));
|
||||
.border(border::rounded(2))
|
||||
.padding(padding::left(2).right(2));
|
||||
|
||||
let span = if let Some(link) = link.as_ref() {
|
||||
span.color(palette.primary).link(link.clone())
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::core::widget::text::{
|
|||
use crate::core::widget::tree::{self, Tree};
|
||||
use crate::core::{
|
||||
self, Clipboard, Color, Element, Event, Layout, Length, Pixels, Point,
|
||||
Rectangle, Shell, Size, Widget,
|
||||
Rectangle, Shell, Size, Vector, Widget,
|
||||
};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
|
@ -252,6 +252,16 @@ where
|
|||
let translation = layout.position() - Point::ORIGIN;
|
||||
|
||||
for bounds in state.paragraph.span_bounds(index) {
|
||||
let bounds = Rectangle::new(
|
||||
bounds.position()
|
||||
- Vector::new(span.padding.left, span.padding.top),
|
||||
bounds.size()
|
||||
+ Size::new(
|
||||
span.padding.horizontal(),
|
||||
span.padding.vertical(),
|
||||
),
|
||||
);
|
||||
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds: bounds + translation,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue