Add padding to text::Span

This commit is contained in:
Héctor Ramón Jiménez 2024-07-28 13:56:39 +02:00
parent f7fe1edcbb
commit 2796a6bc97
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 57 additions and 12 deletions

View file

@ -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,