mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Constrain demo windows to the space left after the panels (#7785)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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:");
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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!());
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user