summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authornjust <njust@users.noreply.github.com>2024-02-10 09:17:12 +0100
committerEmil Ernerfeldt <emil.ernerfeldt@gmail.com>2024-02-10 17:51:09 +0100
commit820a3baf3017c2f84c062850159be8c819e5112b (patch)
tree5ae4f85419dfc2a57fcd5857f0875fc5f0957cd6 /crates
parent1fe0f2417ab815611f0178f7b62ae5e7009254bb (diff)
egui demo: Fix space reserved for source code link (#3983)
Clip the cell of the source code link to prevent the strip from growing infinitely if the reserved size for the link is not sufficient. ![image](https://github.com/emilk/egui/assets/2380253/0cf214fc-addc-4212-90fc-d68834c1cfe7) Closes <https://github.com/emilk/egui/issues/3980>.
Diffstat (limited to 'crates')
-rw-r--r--crates/egui_demo_lib/src/demo/strip_demo.rs5
-rw-r--r--crates/egui_demo_lib/src/demo/table_demo.rs5
2 files changed, 7 insertions, 3 deletions
diff --git a/crates/egui_demo_lib/src/demo/strip_demo.rs b/crates/egui_demo_lib/src/demo/strip_demo.rs
index db42fcb0..defeac82 100644
--- a/crates/egui_demo_lib/src/demo/strip_demo.rs
+++ b/crates/egui_demo_lib/src/demo/strip_demo.rs
@@ -1,4 +1,4 @@
-use egui::Color32;
+use egui::{Color32, TextStyle};
use egui_extras::{Size, StripBuilder};
/// Shows off a table with dynamic layout
@@ -33,11 +33,12 @@ impl super::View for StripDemo {
egui::lerp(Rgba::from(color)..=Rgba::from(faded_color), t).into()
};
+ let body_text_size = TextStyle::Body.resolve(ui.style()).size;
StripBuilder::new(ui)
.size(Size::exact(50.0))
.size(Size::remainder())
.size(Size::relative(0.5).at_least(60.0))
- .size(Size::exact(10.5))
+ .size(Size::exact(body_text_size))
.vertical(|mut strip| {
strip.cell(|ui| {
ui.painter().rect_filled(
diff --git a/crates/egui_demo_lib/src/demo/table_demo.rs b/crates/egui_demo_lib/src/demo/table_demo.rs
index edb0fec3..f15d2df9 100644
--- a/crates/egui_demo_lib/src/demo/table_demo.rs
+++ b/crates/egui_demo_lib/src/demo/table_demo.rs
@@ -1,3 +1,5 @@
+use egui::TextStyle;
+
#[derive(PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
enum DemoType {
@@ -105,10 +107,11 @@ impl super::View for TableDemo {
ui.separator();
// Leave room for the source code link after the table demo:
+ let body_text_size = TextStyle::Body.resolve(ui.style()).size;
use egui_extras::{Size, StripBuilder};
StripBuilder::new(ui)
.size(Size::remainder().at_least(100.0)) // for the table
- .size(Size::exact(10.5)) // for the source code link
+ .size(Size::exact(body_text_size)) // for the source code link
.vertical(|mut strip| {
strip.cell(|ui| {
egui::ScrollArea::horizontal().show(ui, |ui| {