1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

Constrain demo windows to the space left after the panels (#7785)

This commit is contained in:
Emil Ernerfeldt
2025-12-17 21:03:52 +01:00
committed by GitHub
parent 51493be066
commit ca1e76f38b
84 changed files with 272 additions and 215 deletions

View File

@@ -8,14 +8,15 @@ impl crate::Demo for About {
"About egui"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.default_width(320.0)
.default_height(480.0)
.open(open)
.resizable([true, false])
.scroll(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -26,12 +26,13 @@ impl crate::Demo for CodeEditor {
"🖮 Code Editor"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
egui::Window::new(self.name())
.open(open)
.default_height(500.0)
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -105,7 +105,7 @@ impl crate::Demo for CodeExample {
"🖮 Code Example"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
egui::Window::new(self.name())
.open(open)
@@ -113,7 +113,8 @@ impl crate::Demo for CodeExample {
.default_size([390.0, 500.0])
.scroll(false)
.resizable([true, false]) // resizable so we can shrink if the text edit grows
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -1,5 +1,5 @@
use egui::{
Color32, Context, Pos2, Rect, Ui,
Color32, Pos2, Rect, Ui,
containers::{Frame, Window},
emath, epaint,
epaint::PathStroke,
@@ -18,13 +18,14 @@ impl crate::Demo for DancingStrings {
"♫ Dancing Strings"
}
fn show(&mut self, ctx: &Context, open: &mut bool) {
fn show(&mut self, ui: &mut Ui, open: &mut bool) {
use crate::View as _;
Window::new(self.name())
.open(open)
.default_size(vec2(512.0, 256.0))
.vscroll(false)
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -6,7 +6,7 @@ use crate::View as _;
use crate::is_mobile;
use egui::containers::menu;
use egui::style::StyleModifier;
use egui::{Context, Modifiers, ScrollArea, Ui};
use egui::{Modifiers, ScrollArea, Ui};
// ----------------------------------------------------------------------------
struct DemoGroup {
@@ -39,11 +39,11 @@ impl DemoGroup {
}
}
pub fn windows(&mut self, ctx: &Context, open: &mut BTreeSet<String>) {
pub fn windows(&mut self, ui: &mut Ui, open: &mut BTreeSet<String>) {
let Self { demos } = self;
for demo in demos {
let mut is_open = open.contains(demo.name());
demo.show(ctx, &mut is_open);
demo.show(ui, &mut is_open);
set_open(open, demo.name(), is_open);
}
}
@@ -137,7 +137,7 @@ impl DemoGroups {
tests.checkboxes(ui, open);
}
pub fn windows(&mut self, ctx: &Context, open: &mut BTreeSet<String>) {
pub fn windows(&mut self, ui: &mut Ui, open: &mut BTreeSet<String>) {
let Self {
about,
demos,
@@ -145,11 +145,11 @@ impl DemoGroups {
} = self;
{
let mut is_open = open.contains(about.name());
about.show(ctx, &mut is_open);
about.show(ui, &mut is_open);
set_open(open, about.name(), is_open);
}
demos.windows(ctx, open);
tests.windows(ctx, open);
demos.windows(ui, open);
tests.windows(ui, open);
}
}
@@ -231,7 +231,7 @@ impl DemoWindows {
}
} else {
self.mobile_top_bar(ui);
self.groups.windows(ui.ctx(), &mut self.open);
self.groups.windows(ui, &mut self.open);
}
}
@@ -295,7 +295,7 @@ impl DemoWindows {
});
});
self.groups.windows(ui.ctx(), &mut self.open);
self.groups.windows(ui, &mut self.open);
}
fn demo_list_ui(&mut self, ui: &mut egui::Ui) {

View File

@@ -1,4 +1,4 @@
use egui::{Color32, Context, Frame, Id, Ui, Window, vec2};
use egui::{Color32, Frame, Id, Ui, Window, vec2};
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@@ -27,14 +27,15 @@ impl crate::Demo for DragAndDropDemo {
"✋ Drag and Drop"
}
fn show(&mut self, ctx: &Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
Window::new(self.name())
.open(open)
.default_size(vec2(256.0, 256.0))
.vscroll(false)
.resizable(false)
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -10,14 +10,14 @@ impl crate::Demo for ExtraViewport {
"🗖 Extra Viewport"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
if !*open {
return;
}
let id = egui::Id::new(self.name());
ctx.show_viewport_immediate(
ui.show_viewport_immediate(
egui::ViewportId(id),
egui::ViewportBuilder::default()
.with_title(self.name())
@@ -28,7 +28,7 @@ impl crate::Demo for ExtraViewport {
ui.label("This egui integration does not support multiple viewports");
} else {
egui::CentralPanel::default().show_inside(ui, |ui| {
viewport_content(ui, ctx, open);
viewport_content(ui, open);
});
}
},
@@ -36,13 +36,13 @@ impl crate::Demo for ExtraViewport {
}
}
fn viewport_content(ui: &mut egui::Ui, ctx: &egui::Context, open: &mut bool) {
fn viewport_content(ui: &mut egui::Ui, open: &mut bool) {
ui.label("egui and eframe supports having multiple native windows like this, which egui calls 'viewports'.");
ui.label(format!(
"This viewport has id: {:?}, child of viewport {:?}",
ctx.viewport_id(),
ctx.parent_viewport_id()
ui.viewport_id(),
ui.parent_viewport_id()
));
ui.label("Here you can see all the open viewports:");

View File

@@ -28,11 +28,14 @@ impl crate::Demo for FontBook {
"🔤 Font Book"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
use crate::View as _;
self.ui(ui);
});
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});
}
}

View File

@@ -28,11 +28,12 @@ impl crate::Demo for FrameDemo {
"▣ Frame"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -8,11 +8,12 @@ impl crate::Demo for Highlighting {
"✨ Highlighting"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.default_width(320.0)
.open(open)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -13,12 +13,13 @@ impl crate::Demo for InteractiveContainerDemo {
"\u{20E3} Interactive Container"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.default_width(250.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -3,8 +3,8 @@ use std::sync::Arc;
use super::{Demo, View};
use egui::{
Align, Align2, Checkbox, CollapsingHeader, Color32, ComboBox, Context, FontId, Resize,
RichText, Sense, Slider, Stroke, TextFormat, TextStyle, Ui, Vec2, Window, vec2,
Align, Align2, Checkbox, CollapsingHeader, Color32, ComboBox, FontId, Resize, RichText, Sense,
Slider, Stroke, TextFormat, TextStyle, Ui, Vec2, Window, vec2,
};
/// Showcase some ui code
@@ -49,12 +49,13 @@ impl Demo for MiscDemoWindow {
"✨ Misc Demos"
}
fn show(&mut self, ctx: &Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
Window::new(self.name())
.open(open)
.vscroll(true)
.hscroll(true)
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -61,5 +61,5 @@ pub trait Demo {
fn name(&self) -> &'static str;
/// Show windows, etc
fn show(&mut self, ctx: &egui::Context, open: &mut bool);
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool);
}

View File

@@ -1,4 +1,4 @@
use egui::{ComboBox, Context, Id, Modal, ProgressBar, Ui, Widget as _, Window};
use egui::{ComboBox, Id, Modal, ProgressBar, Ui, Widget as _, Window};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
@@ -32,13 +32,14 @@ impl crate::Demo for Modals {
"🗖 Modals"
}
fn show(&mut self, ctx: &Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
Window::new(self.name())
.open(open)
.vscroll(false)
.resizable(false)
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -27,12 +27,13 @@ impl crate::Demo for MultiTouch {
"👌 Multi Touch"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.default_size(vec2(544.0, 512.0))
.resizable(true)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -1,6 +1,6 @@
use egui::{
Color32, Context, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, Vec2,
Widget as _, Window, emath,
Color32, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, Vec2, Widget as _,
Window, emath,
epaint::{self, CubicBezierShape, PathShape, QuadraticBezierShape},
pos2,
};
@@ -165,14 +165,15 @@ impl crate::Demo for PaintBezier {
" Bézier Curve"
}
fn show(&mut self, ctx: &Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
Window::new(self.name())
.open(open)
.vscroll(false)
.resizable(false)
.default_size([300.0, 350.0])
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -1,4 +1,4 @@
use egui::{Color32, Context, Frame, Pos2, Rect, Sense, Stroke, Ui, Window, emath, vec2};
use egui::{Color32, Frame, Pos2, Rect, Sense, Stroke, Ui, Window, emath, vec2};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
@@ -77,13 +77,14 @@ impl crate::Demo for Painting {
"🖊 Painting"
}
fn show(&mut self, ctx: &Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
Window::new(self.name())
.open(open)
.default_size(vec2(512.0, 512.0))
.vscroll(false)
.show(ctx, |ui| self.ui(ui));
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -7,14 +7,15 @@ impl crate::Demo for Panels {
"🗖 Panels"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
let window = egui::Window::new("Panels")
egui::Window::new("Panels")
.default_width(600.0)
.default_height(400.0)
.vscroll(false)
.open(open);
window.show(ctx, |ui| self.ui(ui));
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -128,13 +128,14 @@ impl crate::Demo for PopupsDemo {
"\u{2755} Popups"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.default_width(250.0)
.constrain(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -22,14 +22,15 @@ impl crate::Demo for SceneDemo {
"🔍 Scene"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
let window = egui::Window::new("Scene")
egui::Window::new("Scene")
.default_width(300.0)
.default_height(300.0)
.scroll(false)
.open(open);
window.show(ctx, |ui| self.ui(ui));
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -13,12 +13,13 @@ impl crate::Demo for Screenshot {
"📷 Screenshot"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.default_width(250.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -30,13 +30,14 @@ impl crate::Demo for Scrolling {
"↕ Scrolling"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(true)
.hscroll(false)
.vscroll(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -43,11 +43,12 @@ impl crate::Demo for Sliders {
"⬌ Sliders"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -11,12 +11,13 @@ impl crate::Demo for StripDemo {
"▣ Strip"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(true)
.default_width(400.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -47,11 +47,12 @@ impl crate::Demo for TableDemo {
"☰ Table"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.default_width(400.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -15,11 +15,14 @@ impl crate::Demo for ClipboardTest {
"Clipboard Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
use crate::View as _;
self.ui(ui);
});
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});
}
}

View File

@@ -6,11 +6,14 @@ impl crate::Demo for CursorTest {
"Cursor Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
use crate::View as _;
self.ui(ui);
});
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});
}
}

View File

@@ -24,11 +24,14 @@ impl crate::Demo for GridTest {
"Grid Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
use crate::View as _;
self.ui(ui);
});
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});
}
}

View File

@@ -6,11 +6,14 @@ impl crate::Demo for IdTest {
"ID Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
use crate::View as _;
self.ui(ui);
});
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});
}
}

View File

@@ -70,13 +70,14 @@ impl crate::Demo for InputEventHistory {
"Input Event History"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.default_width(800.0)
.open(open)
.resizable(true)
.scroll(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -59,13 +59,14 @@ impl crate::Demo for InputTest {
"Input Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.default_width(800.0)
.open(open)
.resizable(true)
.scroll(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -78,11 +78,12 @@ impl crate::Demo for LayoutTest {
"Layout Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -29,11 +29,12 @@ impl crate::Demo for ManualLayoutTest {
"Manual Layout Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.resizable(false)
.open(open)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -15,11 +15,14 @@ impl crate::Demo for SvgTest {
"SVG Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
egui::Window::new(self.name()).open(open).show(ctx, |ui| {
use crate::View as _;
self.ui(ui);
});
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});
}
}

View File

@@ -124,11 +124,12 @@ impl crate::Demo for TessellationTest {
"Tessellation Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.resizable(false)
.open(open)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -15,13 +15,14 @@ impl crate::Demo for WindowResizeTest {
"Window Resize Test"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use egui::{Resize, ScrollArea, TextEdit, Window};
Window::new("↔ auto-sized")
.open(open)
.auto_sized()
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
ui.label("This window will auto-size based on its contents.");
ui.heading("Resize this area:");
Resize::default().show(ui, |ui| {
@@ -35,7 +36,8 @@ impl crate::Demo for WindowResizeTest {
.vscroll(true)
.resizable(true)
.default_height(300.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
ui.label(
"This window is resizable and has a scroll area. You can shrink it to any size.",
);
@@ -48,7 +50,8 @@ impl crate::Demo for WindowResizeTest {
.vscroll(false)
.resizable(true)
.default_height(300.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
ui.label("This window is resizable but has no built-in scroll area.");
ui.label("However, we have a sub-region with a scroll bar:");
ui.separator();
@@ -64,7 +67,8 @@ impl crate::Demo for WindowResizeTest {
.open(open)
.vscroll(false)
.resizable(true)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
ui.label("This window is resizable but has no scroll area. This means it can only be resized to a size where all the contents is visible.");
ui.label("egui will not clip the contents of a window, nor add whitespace to it.");
ui.separator();
@@ -76,7 +80,8 @@ impl crate::Demo for WindowResizeTest {
.vscroll(false)
.resizable(true)
.default_height(300.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
ui.label("Shows how you can fill an area with a widget.");
ui.add_sized(ui.available_size(), TextEdit::multiline(&mut self.text));
});
@@ -86,7 +91,8 @@ impl crate::Demo for WindowResizeTest {
.vscroll(false)
.resizable(true)
.default_size([250.0, 150.0])
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
ui.label("This window has empty space that fills up the available space, preventing auto-shrink.");
ui.vertical_centered(|ui| {
ui.add(crate::egui_github_link_file!());

View File

@@ -19,11 +19,12 @@ impl crate::Demo for TextEditDemo {
"🖹 TextEdit"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -28,11 +28,12 @@ impl crate::Demo for TextLayoutDemo {
"🖹 Text Layout"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(true)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -15,15 +15,16 @@ impl crate::Demo for Tooltips {
"🗖 Tooltips"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
use crate::View as _;
let window = egui::Window::new("Tooltips")
egui::Window::new("Tooltips")
.constrain(false) // So we can test how tooltips behave close to the screen edge
.resizable(true)
.default_size([450.0, 300.0])
.scroll(false)
.open(open);
window.show(ctx, |ui| self.ui(ui));
.open(open)
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -31,11 +31,12 @@ impl crate::Demo for UndoRedoDemo {
"⟲ Undo Redo"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -64,12 +64,13 @@ impl crate::Demo for WidgetGallery {
"🗄 Widget Gallery"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable([true, false]) // resizable so we can shrink if the text edit grows
.default_width(280.0)
.show(ctx, |ui| {
.constrain_to(ui.available_rect_before_wrap())
.show(ui, |ui| {
use crate::View as _;
self.ui(ui);
});

View File

@@ -40,7 +40,7 @@ impl crate::Demo for WindowOptions {
"🗖 Window Options"
}
fn show(&mut self, ctx: &egui::Context, open: &mut bool) {
fn show(&mut self, ui: &mut egui::Ui, open: &mut bool) {
let Self {
title,
title_bar,
@@ -55,9 +55,9 @@ impl crate::Demo for WindowOptions {
anchor_offset,
} = self.clone();
let enabled = ctx.input(|i| i.time) - disabled_time > 2.0;
let enabled = ui.input(|i| i.time) - disabled_time > 2.0;
if !enabled {
ctx.request_repaint();
ui.request_repaint();
}
use crate::View as _;
@@ -68,6 +68,7 @@ impl crate::Demo for WindowOptions {
.collapsible(collapsible)
.title_bar(title_bar)
.scroll(scroll2)
.constrain_to(ui.available_rect_before_wrap())
.enabled(enabled);
if closable {
window = window.open(open);
@@ -75,7 +76,7 @@ impl crate::Demo for WindowOptions {
if anchored {
window = window.anchor(anchor, anchor_offset);
}
window.show(ctx, |ui| self.ui(ui));
window.show(ui, |ui| self.ui(ui));
}
}

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:83fa0f1398d89692f52914ac015c9cb2dd4ead027de9956832c78480c0d4d9c1
size 32892
oid sha256:bff16d453b960bb9abcdd9f72dab73f8f25da6339a0e1c310ed352f57080db93
size 32426

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7e5c1e2ce07d878a3cbcabea3463a8c7039f04f76a00d77b2dd22e67e6a4e21f
size 27430
oid sha256:52d2233594c4bad348f5479dcfad9576ee5fd7d49faedb6f5ba74b374cdaf3ad
size 26977

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0ee82be647dee0911470b881b320ab0acfcde24f650080e934d2c144e24b766e
size 27210
oid sha256:47f6cd15b88df83a9b2d8538e424041e661712f2e85312166a581f69f1254643
size 26839

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7ded3b3409d53c9ca105f00b94c055b39d00624548bb711a894e5e1ffa6f7633
size 76751
oid sha256:9302478abb0b86fae1af3af45d91f032272a56a2098405525d08aba4f9534644
size 76103

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0f6e810e750b30c8c5c9b887e40bf6a28bd4ed7f86f9d0fb3461d766ad8fa743
size 63152
oid sha256:6927950ccbc5c81d6fbfe0a90ddd79a4306518caced14bb60debd30c7e41d326
size 62604

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d08924744c5415658bb50a61c24a5a0f32da5980bf8a3bf9bc7fed7c438b8c38
size 28653
oid sha256:366d18457aabf1ebdd42fdbce8819cc67a4f59db85c452623b02ee1d0e8fc50a
size 27817

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:42c8b9fa8012d3fa003e15a6e9fca034290c289dd1d5c460f5a2733642cd511b
size 21449
oid sha256:d194db1705b36c1ee6189878a323a591555493c9319b7c2ddfc0cb0541055aca
size 20948

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0586f037cc3d4b1c71071088d2fe78d79b4758fb1764ef90983263a2503f685d
size 115118
oid sha256:3c5e803659e936268b476690427ef6a6802f477e078dc956a9d1c857b48da868
size 114409

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ec7746e0c7726a5dbd96f4b1889af692dbadf92ad9cecd1130bff66f197866d6
size 25845
oid sha256:f5e67baf0696792e50f7ab3121874d055ddee2de0514712aacbf8e135ec4743d
size 25425

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:50afb5e56eeb864d6887446eb3b59f1cfa0cb867d3fe6d34264f3db8ba8c45c7
size 99359
oid sha256:55c5fb90736a31fbccd72be5994fc8c62b4b9da9842ad1e6bb795a1e1461a6f8
size 98780

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f951893a437aeebcfefb3d209ceb857319af8792fa37ad93d43e16becaef95b9
size 18734
oid sha256:a4080ee1a16eea16c8f4246fe3e760ade7d0289b30d88068d1e49ffb88d88dca
size 18280

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1f2b751c6d8cc242f5cd8154f0dbb1ba6f9d5193f2081f693aff66f7a793c628
size 114391
oid sha256:600d9e0fc193396f36b599e4bfad2547128160d2e56dc2a989cb5f978d5115ae
size 113797

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a2c4dcc17baff6562834e4ecad12bd3c7a84c8c1ad9e49292e165c4a9d15cc96
size 26075
oid sha256:72d49d9a35e16e7413158ba14ce9cab762925f5f5e52fbbe16292de499a177f1
size 25791

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6380eb90d22f2106cdf281e0a36002574cdcd91461bcb38d386f233ad4501629
size 51993
oid sha256:bb7e3887cf12bd00ea09b297ac361562a961f64c15b28360bc87f72f270a4065
size 51649

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:38d59f1cb946946633c6d8ee0a9bf8e833069c39399ad04098788bd94e623428
size 23092
oid sha256:3ae5e843cc9d847b0f3c4092f55b914699adb506cb807b0a97bfc4ec7d94537b
size 22613

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4c7e32b5bcc55d868fc4572892af7954a36c19952b13b87d551d14f992fe28d8
size 47798
oid sha256:b0d38cb1eebf3ce7d661d094175b425db2b9eccc5e439b14256c5d801d4454d4
size 47285

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c4389d7f189deac9373fcac8eabf0e8f0d0c13132ea5fcbd27fab4798ae6c0c9
size 23225
oid sha256:00e4c7659cd50044d473dd2c138392f78ac7eba27f2b52bae61246f5dc5b2782
size 23156

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:809db3c8a05063eee51d81a5f4534ee6bf34b4fb6ecbab11270bd5e74b4e4b08
size 65871
oid sha256:604f716e687fc26abba92769fe2dae75d850b18598d2e8a9524451ab0f760251
size 65403

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9bca3502a86fd33cbfe69510daa66e69b620ac4cc0f43821339b5a98a8dcfdc5
size 33910
oid sha256:34de6fd788288174e8e6f1fa48cd49dbc7b14fcf649fe302aed49c8c50178aa8
size 33469

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c674aa4700a09da0ad48d29bc6c3846ac890312d2fb11ebf84c2206619991b60
size 38716
oid sha256:115398e2b4b459afc2f1c49c4e60ef3f63e562650f05581372002c93030da632
size 38374

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1279e7725b992e055e26598d3d0e4e940b32cabff86331b450536e8ecaa4d97a
size 18652
oid sha256:96760220222bdde8dd1b3d28f089af2892403b78df8d34d3d94dc1a604387083
size 18241

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fa1f59695d875e2c46dbec7264da6238a1cbf67d03aa5a58c13d9d2ee4d4f7a1
size 249947
oid sha256:627114dcbda4f3d2255d34926ed0b77c679d248ed1d822d723479b1e6652c67a
size 249258

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a4cc3709746144190774b25b59f680cab92eefdd603010649982c374af921ecb
size 57237
oid sha256:48d138634343edb251435bf6f9075502b913e806e8b280f3e6012977c13af16f
size 56753

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b00514b029e8f39c45ac9e00e8f8f8f08376f9c548a5dfaa72edc29d4bb14ce3
size 26133
oid sha256:888ed4281c2c779b08bc1719302b9923f542026811cff8ae91e44ea1faa25783
size 25804

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:25def5d3aa319eb1aba2808b7cb12febf0d8e433cb2500d480a8d447ea6e1628
size 34073
oid sha256:23efb79ca13367f4d8886142d015815c5bdf99c0ed243ece294a7cfd365fd166
size 33503

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2b638a97f8f8a0c85b3eb5106da0ecc81f71e0f69de98ad0acaf698c6f197890
size 24128
oid sha256:5d85faf6e7fa26741eb720e74695f3c207ea15097b118c3cafe5d52d5d85ea20
size 23666

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ed9dd9d592e3ec4683b4d9065de2cb93923117c3629b077bf18d07a11f5a2df5
size 173162
oid sha256:875eb687f3a1eed52a6617e532edc5332b0a16296e2b6addac66d5bea0448b14
size 172605

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ade558053054358653ac60aea9af9b6b8060b8c905c6fdb90bd81538012fb6f7
size 119146
oid sha256:fd3573be9ba5818b4edc371095f5c23b084e6c7eaae4f2fd3a6d2de051878c9d
size 118567

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9aaed5b7d7d24764f246b06cddce2f5ba24b2dd72894a62a43758046c74a66bc
size 27149
oid sha256:9d8d87e4cb944def0dc28e3515243a8c1b07b9b0f88e802924d4381c1cda74db
size 26763

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:be8d8c27e3f22f3aeade0d7e434adca9b876fef376846068e09092a5ede4b300
size 76018
oid sha256:ed1be0294fb65b11c54c6dc9e4cecb383ace16dad748e3c42f2ed65b2fb05ea8
size 75509

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b56b83076623669f3dbb1afc0fe09b83c9fa9337c01fbe88374d62fc727a1452
size 70743
oid sha256:7336c53885add09360df098b6b131323e8ad3ef0ec2b85bf022e78bc4269276a
size 70255

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8d866d8255cf7e15f4e82a94c13e4fdb4e35e69c4339762f05df872e538f3682
size 61290
oid sha256:411dd61eb182a70d46c7fc1fa0f9a4b8aeae88d08b11d5af948c5acccfa9d133
size 60950

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e66e42f1f58cd8494fb01b9424d0cb8c4570b097267dfb9428f0cbd138eed772
size 22200
oid sha256:78111e33d44a09beb9c1233dd2d5ef10103213a1c1c7df8b5e258d9684f1d93a
size 21810

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:21df96ea57444f727f456c4c5efbf80b5df9d259f33b210171f445bb0c2888ad
size 64423
oid sha256:89986132c5d2a3ccccf0a16cb2b0be07b7c5512838cc10ec9067022e7a238515
size 63918

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5960eebe2e6b2e5c47ffb62a709970a3a22c9a25dbf919b2d14361b9721707e3
size 14184
oid sha256:e9498a706de403ee7db3603ecc896688e584fede367ed6087cdf10b798a3ab2d
size 13698

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5dc99e08a8a43186ab21ef2209973fcf58a9f9ab5923b66c747d31403d21aa50
size 36165
oid sha256:42385da2eb74d54ba086aed973ade15f2a8d2be0c9281c05e6fb88846137bf81
size 35870

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a59fc052c1b447d78e63cb4887eed33bf4e794d8a3144f57a5652401bd200b2e
size 485365
oid sha256:9f1b6fa0c48479606539f2d98befe1c9ee881846c0b55d7a53313962d556380d
size 484629

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0054283b203602742d9819ba275c44ea40211ba18bf56fc66dca4fca766184d3
size 47076
oid sha256:b53b03212953e12915a0e41bff5f0cdea90f8f866220a01142edaeb915735a34
size 47077

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6a40e3e7314cb32398797665b2bebb237f1a9cc79e306df9c29f7f04faa3a435
size 47715
oid sha256:22e5d61a141b5a8663feb8a47371f9259d2a77fdacb1245bce411ffc85ce2cae
size 47716

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b1ddff4f50b9a245d270cc13a0ebb9ac71d3590b83d401afb10ab107439cf235
size 43893
oid sha256:120558ab0c267650744bd078aeace8d4122b3569c5998602f969766131d15c44
size 43894

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:50dea7c459cf291e6c0b3166354a7e622af6682842ec36f295d532df8c064b38
size 43984
oid sha256:af92548b6c8569081a91cb772b73988d9cb342498ddf9c0c86b6963cef8eda9e
size 43985

View File

@@ -68,6 +68,7 @@ impl<State> AppKind<'_, State> {
}
ui.scope_builder(builder, |ui| {
Frame::central_panel(ui.style())
// Only set outer margin, so we show no frame for tests with only free-floating windows/popups:
.outer_margin(8.0)
.inner_margin(0.0)
.show(ui, |ui| match self {