Skip to content

Commit

Permalink
Merge pull request #2 from bu5hm4nn/fix-wrapping-issue-gossip
Browse files Browse the repository at this point in the history
Fix issue emilk#2578
  • Loading branch information
mikedilger authored Mar 8, 2023
2 parents 1e15343 + f77b1ac commit 2e59a45
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 0 additions & 1 deletion crates/epaint/src/text/text_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ fn line_break(
rect: rect_from_x_range(first_row_indentation..=first_row_indentation),
ends_with_newline: false,
});
row_start_x += first_row_indentation;
first_row_indentation = 0.0;
} else if let Some(last_kept_index) = row_break_candidates.get(job.wrap.break_anywhere)
{
Expand Down
12 changes: 12 additions & 0 deletions examples/wrapping-layout/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "wrapping-layout"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a screenshot using EFRAME_SCREENSHOT_TO
] }
tracing-subscriber = "0.3"
35 changes: 35 additions & 0 deletions examples/wrapping-layout/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use eframe::{
egui::{self, TextFormat},
epaint::text::LayoutJob,
};

fn main() -> Result<(), eframe::Error> {
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");
let text = " lnbc10u1p3lz4dppp5dsj2mh5kgqfqqxwhkrkw60stn8aph4gm2h2053xvwvvlvjm3q9eqdpqxycrqvpqd3hhgar9wfujqarfvd4k2arncqzpgxqzz6sp5vfenc5l4uafsky0w069zs329edf608ggpjjveguwxfl3xlswg5vq9qyyssqj46d5x3gsnljffm79eqwszk4mk47lkxywdp8mxum7un3qm0ztwj9jf46cm4lw2un9hk4gttgtjdrk29h27xu4e3ume20sqsna8q7xwspqqkwq7";
let job = LayoutJob::single_section(text.to_owned(), TextFormat::default());
ui.label(job);
});
});
}
}

0 comments on commit 2e59a45

Please sign in to comment.