From 1f93c7b0b622408e07bc7f8a4e0da16141b92b73 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 7 Jan 2022 15:22:21 +0100 Subject: [PATCH 1/4] Implement Clone & PartialEq on RichText WidgetTextJob WidgetTextGalley --- egui/src/widget_text.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/egui/src/widget_text.rs b/egui/src/widget_text.rs index f2451d71..acd77878 100644 --- a/egui/src/widget_text.rs +++ b/egui/src/widget_text.rs @@ -9,7 +9,7 @@ use crate::{ /// /// The style choices (font, color) are applied to the entire text. /// For more detailed control, use [`crate::text::LayoutJob`] instead. -#[derive(Default)] +#[derive(Clone, Default, PartialEq)] pub struct RichText { text: String, text_style: Option, @@ -555,6 +555,7 @@ impl From> for WidgetText { // ---------------------------------------------------------------------------- +#[derive(Clone, PartialEq)] pub struct WidgetTextJob { pub job: LayoutJob, pub job_has_color: bool, @@ -574,6 +575,7 @@ impl WidgetTextJob { // ---------------------------------------------------------------------------- /// Text that has been layed out and ready to be painted. +#[derive(Clone, PartialEq)] pub struct WidgetTextGalley { pub galley: Arc, pub galley_has_color: bool, From 7b641be7b06be8b81b66d63968f081718acc7c89 Mon Sep 17 00:00:00 2001 From: Lampsitter <96946613+lampsitter@users.noreply.github.com> Date: Sat, 8 Jan 2022 10:07:02 +0100 Subject: [PATCH 2/4] Don't constrain immovable egui windows to native window (#1049) --- CHANGELOG.md | 1 + egui/src/containers/window.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be641726..0093f20a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w ### Fixed 🐛 * Context menu now respects the theme ([#1043](https://github.com/emilk/egui/pull/1043)) +* Immovable windows can no longer incorrectly move ([#1049](https://github.com/emilk/egui/pull/1049)) ## 0.16.1 - 2021-12-31 - Add back `CtxRef::begin_frame,end_frame` diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index 4eceac70..3c80a5d0 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -399,9 +399,11 @@ impl<'open> Window<'open> { content_inner }; - area.state_mut().pos = ctx - .constrain_window_rect_to_area(area.state().rect(), area.drag_bounds()) - .min; + if area.movable { + area.state_mut().pos = ctx + .constrain_window_rect_to_area(area.state().rect(), area.drag_bounds()) + .min; + } let full_response = area.end(ctx, area_content_ui); @@ -508,7 +510,11 @@ fn interact( let new_rect = move_and_resize_window(ctx, &window_interaction)?; let new_rect = ctx.round_rect_to_pixels(new_rect); - let new_rect = ctx.constrain_window_rect_to_area(new_rect, area.drag_bounds()); + let new_rect = if area.movable { + ctx.constrain_window_rect_to_area(new_rect, area.drag_bounds()) + } else { + new_rect + }; // TODO: add this to a Window state instead as a command "move here next frame" area.state_mut().pos = new_rect.min; From 342737e2f0510873493d9e397b985501a82cb269 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 8 Jan 2022 11:15:05 +0100 Subject: [PATCH 3/4] Improve a couple of docstrings --- epaint/src/texture_atlas.rs | 4 +++- epi/src/lib.rs | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/epaint/src/texture_atlas.rs b/epaint/src/texture_atlas.rs index 054a2c1c..a79501aa 100644 --- a/epaint/src/texture_atlas.rs +++ b/epaint/src/texture_atlas.rs @@ -6,7 +6,9 @@ pub struct FontImage { pub version: u64, pub width: usize, pub height: usize, - /// White color with the given alpha (linear space 0-255). + /// The alpha (linear space 0-255) of something white. + /// + /// One byte per pixel. Often you want to use [`Self::srgba_pixels`] instead. pub pixels: Vec, } diff --git a/epi/src/lib.rs b/epi/src/lib.rs index 7cd0bba2..b780b2eb 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -160,8 +160,13 @@ pub trait App { } /// The size limit of the web app canvas. + /// + /// By default the size if limited to 1024x2048. + /// + /// A larger canvas can lead to bad frame rates on some browsers on some platforms. + /// In particular, Firefox on Mac and Linux is really bad at handling large WebGL canvases: + /// (unfixed since 2014). fn max_size_points(&self) -> egui::Vec2 { - // Some browsers get slow with huge WebGL canvases, so we limit the size: egui::Vec2::new(1024.0, 2048.0) } From 611eaa52e8f669d8972588473413d413507bea32 Mon Sep 17 00:00:00 2001 From: Lampsitter <96946613+lampsitter@users.noreply.github.com> Date: Sun, 9 Jan 2022 15:32:09 +0100 Subject: [PATCH 4/4] Revert "Don't constrain immovable egui windows to native window (#1049)" (#1054) This reverts commit 7b641be7b06be8b81b66d63968f081718acc7c89. It accidentally disabled constraining for all windows --- CHANGELOG.md | 1 - egui/src/containers/window.rs | 14 ++++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0093f20a..be641726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,6 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w ### Fixed 🐛 * Context menu now respects the theme ([#1043](https://github.com/emilk/egui/pull/1043)) -* Immovable windows can no longer incorrectly move ([#1049](https://github.com/emilk/egui/pull/1049)) ## 0.16.1 - 2021-12-31 - Add back `CtxRef::begin_frame,end_frame` diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index 3c80a5d0..4eceac70 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -399,11 +399,9 @@ impl<'open> Window<'open> { content_inner }; - if area.movable { - area.state_mut().pos = ctx - .constrain_window_rect_to_area(area.state().rect(), area.drag_bounds()) - .min; - } + area.state_mut().pos = ctx + .constrain_window_rect_to_area(area.state().rect(), area.drag_bounds()) + .min; let full_response = area.end(ctx, area_content_ui); @@ -510,11 +508,7 @@ fn interact( let new_rect = move_and_resize_window(ctx, &window_interaction)?; let new_rect = ctx.round_rect_to_pixels(new_rect); - let new_rect = if area.movable { - ctx.constrain_window_rect_to_area(new_rect, area.drag_bounds()) - } else { - new_rect - }; + let new_rect = ctx.constrain_window_rect_to_area(new_rect, area.drag_bounds()); // TODO: add this to a Window state instead as a command "move here next frame" area.state_mut().pos = new_rect.min;