Skip to content
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

Text wrapping too late #2578

Open
mikedilger opened this issue Jan 12, 2023 · 4 comments
Open

Text wrapping too late #2578

mikedilger opened this issue Jan 12, 2023 · 4 comments
Labels
bug Something is broken

Comments

@mikedilger
Copy link

mikedilger commented Jan 12, 2023

Describe the bug

Under certain conditions, text wrapping leaves one line of text too wide compared to the container, in my case pushing the container width (or it's ancestors) beyond the bounds of the window.

Tested on master, 60b4f5e

To Reproduce

Steps to reproduce the behavior:

  1. Within an area that is not as wide as the window...
  2. Horizontally wrapped...
  3. Render a short link, and then a very long string of characters with no space to natrually break them on.
  4. The first line of that very long string of characters will be too long, but subsequent lines won't.

Expected behavior

Wrapping that doesn't expand the width of the container.

Screenshots

https://user-images.githubusercontent.com/1653275/212086814-c878a200-f7ab-4a84-a5f0-a0b89ec740a5.png

Normally subsequent posts (below the horizontal lines) line up on the left edge. Here, they are pushed left beyond the edge of the window.

Desktop (please complete the following information):

  • OS: ArchLinux (X11/winit)
  • Browser: n/a
  • Version: eframe 0.20.1
@mikedilger mikedilger added the bug Something is broken label Jan 12, 2023
@emilk
Copy link
Owner

emilk commented Feb 8, 2023

A simple reproduce would help a lot, preferably just a call to text_layout::layout

@mikedilger
Copy link
Author

Ok I did some digging and this reproduces it

main.rs:

use eframe::egui;

fn main() {
    let native_options = eframe::NativeOptions::default();
    eframe::run_native("My egui App", native_options, Box::new(|cc| Box::new(MyEguiApp::new(cc))));
}

#[derive(Default)]
struct MyEguiApp {}

impl MyEguiApp {
    fn new(cc: &eframe::CreationContext<'_>) -> Self {
        Self::default()
    }
}

impl eframe::App for MyEguiApp {
   fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
       egui::CentralPanel::default().show(ctx, |ui| {
           ui.horizontal_wrapped(|ui| {
               ui.hyperlink_to("@npub1vdaeclr2mnntmyw...", "whocares");
               ui.label(" lnbc10u1p3lz4dppp5dsj2mh5kgqfqqxwhkrkw60stn8aph4gm2h2053xvwvvlvjm3q9eqdpqxycrqvpqd3hhgar9wfujqarfvd4k2arncqzpgxqzz6sp5vfenc5l4uafsky0w069zs329edf608ggpjjveguwxfl3xlswg5vq9qyyssqj46d5x3gsnljffm79eqwszk4mk47lkxywdp8mxum7un3qm0ztwj9jf46cm4lw2un9hk4gttgtjdrk29h27xu4e3ume20sqsna8q7xwspqqkwq7");
           });
       });
   }
}

bu5hm4nn pushed a commit to bu5hm4nn/egui that referenced this issue Mar 8, 2023
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
bu5hm4nn pushed a commit to bu5hm4nn/egui that referenced this issue Mar 8, 2023
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
@bu5hm4nn
Copy link
Contributor

bu5hm4nn commented Mar 8, 2023

Should be fixed in #2791. Read description of PR for explanation why that line shouldn't be there.

bu5hm4nn pushed a commit to bu5hm4nn/egui that referenced this issue Mar 8, 2023
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
mikedilger added a commit to mikedilger/egui that referenced this issue Mar 8, 2023
bu5hm4nn pushed a commit to bu5hm4nn/egui that referenced this issue Mar 9, 2023
There was confusion in the code over how to break when on a non-empty visual row (`first_row_indentation > 0.0`), causing text to be shifted left outside the ui frame. This is the case for example when another label has already been placed in this `ui.horizontal_wrapped()`.
This fix will not create an empty row, essentially starting a newline, but rather try to fit as much text as possible on the existing row. IMO this is the desired use of a wrapping layout.
I've also added an example that would demonstrate the problem if the line was included, and that is fixed with this commit
bu5hm4nn pushed a commit to bu5hm4nn/egui that referenced this issue Mar 9, 2023
There was confusion in the code over how to break when on a non-empty visual row (`first_row_indentation > 0.0`), causing text to be shifted left outside the ui frame. This is the case for example when another label has already been placed in this `ui.horizontal_wrapped()`.
This fix will not create an empty row, essentially starting a newline, but rather try to fit as much text as possible on the existing row. IMO this is the desired use of a wrapping layout.
I've also added an example that would demonstrate the problem if the line was included, and that is fixed with this commit
mikedilger added a commit to mikedilger/egui that referenced this issue Mar 9, 2023
mikedilger pushed a commit to mikedilger/egui that referenced this issue Mar 29, 2023
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
mikedilger pushed a commit to mikedilger/egui that referenced this issue Mar 31, 2023
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
mikedilger pushed a commit to mikedilger/egui that referenced this issue Apr 13, 2023
There was confusion in the code over how to break when on a non-empty visual row (`first_row_indentation > 0.0`), causing text to be shifted left outside the ui frame. This is the case for example when another label has already been placed in this `ui.horizontal_wrapped()`.
This fix will not create an empty row, essentially starting a newline, but rather try to fit as much text as possible on the existing row. IMO this is the desired use of a wrapping layout.
I've also added an example that would demonstrate the problem if the line was included, and that is fixed with this commit
mikedilger pushed a commit to mikedilger/egui that referenced this issue Sep 29, 2023
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
mikedilger pushed a commit to mikedilger/egui that referenced this issue Sep 29, 2023
There was confusion in the code over how to break when on a non-empty visual row (`first_row_indentation > 0.0`), causing text to be shifted left outside the ui frame. This is the case for example when another label has already been placed in this `ui.horizontal_wrapped()`.
This fix will not create an empty row, essentially starting a newline, but rather try to fit as much text as possible on the existing row. IMO this is the desired use of a wrapping layout.
I've also added an example that would demonstrate the problem if the line was included, and that is fixed with this commit
jeremyd pushed a commit to jeremyd/egui that referenced this issue Feb 9, 2024
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
jeremyd pushed a commit to jeremyd/egui that referenced this issue Feb 9, 2024
There was confusion in the code over how to break when on a non-empty visual row (`first_row_indentation > 0.0`), causing text to be shifted left outside the ui frame. This is the case for example when another label has already been placed in this `ui.horizontal_wrapped()`.
This fix will not create an empty row, essentially starting a newline, but rather try to fit as much text as possible on the existing row. IMO this is the desired use of a wrapping layout.
I've also added an example that would demonstrate the problem if the line was included, and that is fixed with this commit
jeremyd pushed a commit to jeremyd/egui that referenced this issue Feb 9, 2024
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
jeremyd pushed a commit to jeremyd/egui that referenced this issue Feb 9, 2024
There was confusion in the code over how to break when on a non-empty visual row (`first_row_indentation > 0.0`), causing text to be shifted left outside the ui frame. This is the case for example when another label has already been placed in this `ui.horizontal_wrapped()`.
This fix will not create an empty row, essentially starting a newline, but rather try to fit as much text as possible on the existing row. IMO this is the desired use of a wrapping layout.
I've also added an example that would demonstrate the problem if the line was included, and that is fixed with this commit
bu5hm4nn pushed a commit to bu5hm4nn/egui that referenced this issue Feb 9, 2024
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
bu5hm4nn pushed a commit to bu5hm4nn/egui that referenced this issue Feb 9, 2024
…k when on a non-empty visual row (`first_row_indentation > 0.0`), causing text to be shifted left outside the ui frame. This is the case for example when another label has already been placed in this `ui.horizontal_wrapped()`. This fix will not create an empty row, essentially starting a newline, but rather try to fit as much text as possible on the existing row. IMO this is the desired use of a wrapping layout. I've also added an example that would demonstrate the problem if the line was included, and that is fixed with this commi
bu5hm4nn added a commit to bu5hm4nn/egui that referenced this issue Mar 8, 2024
… source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph. - added example that would demonstrate the problem if the line was included, and that is fixed with this commit

Fix issue emilk#2578 There was confusion in the code over how to
 break when on a non-empty visual row (`first_row_indentation > 0.0`), causing
 text to be shifted left outside the ui frame. This is the case for example
 when another label has already been placed in this `ui.horizontal_wrapped()`.
 This fix will not create an empty row, essentially starting a newline, but
 rather try to fit as much text as possible on the existing row. IMO this is
 the desired use of a wrapping layout. I've also added an example that would
 demonstrate the problem if the line was included, and that is fixed with this
 commit
bu5hm4nn added a commit to bu5hm4nn/egui that referenced this issue Mar 11, 2024
… source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph. - added example that would demonstrate the problem if the line was included, and that is fixed with this commit

Fix issue emilk#2578 There was confusion in the code over how to
break when on a non-empty visual row (`first_row_indentation > 0.0`), causing
text to be shifted left outside the ui frame. This is the case for example
when another label has already been placed in this `ui.horizontal_wrapped()`.
This fix will not create an empty row, essentially starting a newline, but
rather try to fit as much text as possible on the existing row. IMO this is
the desired use of a wrapping layout. I've also added an example that would
demonstrate the problem if the line was included, and that is fixed with this
commit
@jb55
Copy link

jb55 commented Apr 27, 2024

I wonder if this is the same issue I'm running into:

late wrap (notice center Strip)

Xnapper-2024-04-27-02 18 39

slightly adjust windows size and it snaps into a better wrap:

Xnapper-2024-04-27-02 18 53

bu5hm4nn added a commit to bu5hm4nn/egui that referenced this issue Jul 23, 2024
- `row_start_x` tracks a virtual position in the source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph.
- added example that would demonstrate the problem if the line was included, and that is fixed with this commit
bu5hm4nn added a commit to bu5hm4nn/egui that referenced this issue Aug 6, 2024
… source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph. - added example that would demonstrate the problem if the line was included, and that is fixed with this commit
bu5hm4nn added a commit to bu5hm4nn/egui that referenced this issue Aug 8, 2024
… source paragraph (the one that is too long) for which length has already been processed. When creating an empty row, this position should not be updated as no glyphs were consumed from the source paragraph. - added example that would demonstrate the problem if the line was included, and that is fixed with this commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

4 participants