-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Implement tinyskia text bounds #2929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This looks like it also fixes #2851 <3 |
After more testing, though, I found a bug which is hard to explain. You can reproduce it by cloning my app from this repo https://git.sr.ht/~lufte/vimini/tree/tiny-skia-clipping (make sure you're on the tiny-skia-clipping branch), running it with tiny-skia, and scrolling down on the default page that opens up. You should notice an increasingly bigger rectangle, same color as the background, that is drawn on top of the text at the top. The tabs in the navigation bar at the top are using the new feature. Let me know if it's hard to reproduce and I can provide assistance. |
Hey @lufte, I had issues reproducing the visual bug. Do you think you could try to reproduce it based on this branch? |
@DKolter I was able to write a short program that shows the behavior, code below. Just run it with tiny-skia and scroll down, you should see how less and less text is shown. main.rs #[derive(Default)]
pub struct App {
}
#[derive(Debug)]
pub enum Message {
}
impl App {
fn update(&mut self, message: Message) -> iced::Task<Message> {
let mut command = iced::Task::none();
return command;
}
fn view(&self) -> iced::Element<Message> {
let mut tab_bar = iced::widget::Row::new().width(iced::Length::Fill);
tab_bar = tab_bar.push(
iced::widget::Container::new(
iced::widget::Text::new("Tab 1")
.wrapping(iced::widget::text::Wrapping::None)
)
.width(iced::Length::Fill)
.padding(2)
.clip(true)
);
tab_bar = tab_bar.push(
iced::widget::Container::new(
iced::widget::Text::new("Tab 2")
.wrapping(iced::widget::text::Wrapping::None)
)
.width(iced::Length::Fill)
.padding(2)
.clip(true)
);
let mut tabbed_browser = iced::widget::Column::new();
tabbed_browser = tabbed_browser.push(tab_bar);
let mut text_column = iced::widget::Column::new();
for _ in [0; 100] {
text_column = text_column.push(
iced::widget::Text::new("A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm.")
.size(17)
.shaping(iced::advanced::text::Shaping::Advanced)
);
}
let document_viewer = iced::widget::Container::new(
iced::widget::scrollable::Scrollable::new(
iced::widget::Container::new(
text_column
.max_width(800)
.width(iced::Length::Fill)
.padding(10)
)
.center_x(iced::Length::Fill),
)
)
.height(iced::Length::Fill);
tabbed_browser = tabbed_browser.push(document_viewer);
return iced::widget::Container::new(tabbed_browser)
.width(iced::Length::Fill)
.height(iced::Length::Fill)
.into();
}
}
pub fn main() -> iced::Result {
return iced::run(App::update, App::view);
} Cargo.toml [package]
name = "tiny-skia-bug"
[dependencies]
iced = { git = "https://github.com/DKolter/iced/", branch = "issue_2740", features=["advanced"] } |
Good catch, thank you @lufte! Shorter snippet to reproduce: use iced::{
Element, Length,
widget::{column, scrollable, text},
};
#[derive(Default)]
pub struct App {}
#[derive(Debug)]
pub enum Message {}
impl App {
fn update(&mut self, _message: ()) {}
fn view(&self) -> Element<()> {
scrollable(column((0..100).map(|i| text!("Item {i}").into())))
.width(Length::Fill)
.height(Length::Fill)
.into()
}
}
pub fn main() -> iced::Result {
return iced::run(App::update, App::view);
} |
Glad to be of help @DKolter. There is another bug, related with scrolling and tiny-skia but not with this patch here, for which you might be of help. If you're interested I'll try to come up with a minimal example for that too and get in touch with you. |
I would be happy to take a look at that issue too. This current branch performs much worse than master for many paragraphs, because there is a bug in the core This leads to clip masks being rerendered without needing to if text bounds and clip bounds are equal sized on any axis. Should I open a separate issue for this or fix it in this PR? |
Fixes #2740
Paragraph clip bounds are currently marked todo in the tiny skia backend. This PR makes an effort to change this by:
The original issue only mentions
text_input
, howevertext_editor
and cached text have the same todo comment and are also handled by this PR.Before
After