From 901f22bce336f09084839e84bc731639045e516e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20G=C4=85sior?= Date: Wed, 2 Oct 2024 14:03:04 +0100 Subject: [PATCH] Egui 0.29 (#251) * Upgrade to egui 0.29. * Update changelog and readme --- CHANGELOG.md | 19 ++++++++--- Cargo.toml | 4 +-- README.md | 4 +-- src/dock_state/surface.rs | 4 ++- src/widgets/dock_area/show/leaf.rs | 36 +++++++++----------- src/widgets/dock_area/show/window_surface.rs | 6 ++-- 6 files changed, 41 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b8ac30..1f1e503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.14.0 - Unreleased +### Breaking changes + +- Upgraded to egui 0.29. + ### Changed - `{DockState,Surface,Tree,Node}::{filter_map_tabs,map_tabs,filter_tabs,retain_tabs}` no longer require the predicate to @@ -302,14 +306,18 @@ provide a guide of how to use the library. to `TabStyle` ([89f3248](https://github.com/Adanos020/egui_dock/commit/89f32487a9e1fe8dee92f1fbdc296a2d460c0909)) - -Removed `StyleBuilder` ([9a9b275](https://github.com/Adanos020/egui_dock/commit/9a9b2750cd290bebcc4088761249e02102cb0ce7)) +Removed +`StyleBuilder` ([9a9b275](https://github.com/Adanos020/egui_dock/commit/9a9b2750cd290bebcc4088761249e02102cb0ce7)) - Removed `TabViewer::inner_margin_override` – no deprecation as it's in direct conflict - with `TabViewer::tab_style_override` ([99333b0](https://github.com/Adanos020/egui_dock/commit/99333b093d307181c288b3e134379cfe47647a7c)) + with + `TabViewer::tab_style_override` ([99333b0](https://github.com/Adanos020/egui_dock/commit/99333b093d307181c288b3e134379cfe47647a7c)) - Moved `Style::default_inner_margin` - to `TabsStyle::inner_margin` ([78ecf3a](https://github.com/Adanos020/egui_dock/commit/78ecf3a175ffb960724f328274682dfded800e0f)) + to + `TabsStyle::inner_margin` ([78ecf3a](https://github.com/Adanos020/egui_dock/commit/78ecf3a175ffb960724f328274682dfded800e0f)) - Moved `TabStyle::hline_color` - to `TabBarStyle::hline_color` ([99333b0](https://github.com/Adanos020/egui_dock/commit/99333b093d307181c288b3e134379cfe47647a7c)) + to + `TabBarStyle::hline_color` ([99333b0](https://github.com/Adanos020/egui_dock/commit/99333b093d307181c288b3e134379cfe47647a7c)) ## 0.5.2 - 2023-06-04 @@ -470,7 +478,8 @@ Removed `StyleBuilder` ([9a9b275](https://github.com/Adanos020/egui_dock/commit/ - Renamed `TabViewer::inner_margin` to `TabViewer::inner_margin_override`. ([#67](https://github.com/Adanos020/egui_dock/pull/67)) - `Style::with_separator_color` has been split - into `separator_color_idle`, `separator_color_hovered`, `separator_color_dragged` ([#68](https://github.com/Adanos020/egui_dock/pull/68)) + into `separator_color_idle`, `separator_color_hovered`, + `separator_color_dragged` ([#68](https://github.com/Adanos020/egui_dock/pull/68)) - Updated `egui` to 0.20.0 [#77](https://github.com/Adanos020/egui_dock/pull/77) ### Deprecated (will be deleted in the next release) diff --git a/Cargo.toml b/Cargo.toml index 0986d98..c79a6b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,14 +18,14 @@ default = [] serde = ["dep:serde", "egui/serde"] [dependencies] -egui = { version = "0.28", default-features = false } +egui = { version = "0.29", default-features = false } serde = { version = "1", optional = true, features = ["derive"] } duplicate = "2.0" paste = "1.0" [dev-dependencies] -eframe = { version = "0.28", default-features = false, features = [ +eframe = { version = "0.29", default-features = false, features = [ "default_fonts", "glow", ] } diff --git a/README.md b/README.md index eca933f..c70eb12 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![github](https://img.shields.io/badge/github-Adanos020/egui_dock-8da0cb?logo=github)](https://github.com/Adanos020/egui_dock) [![Crates.io](https://img.shields.io/crates/v/egui_dock)](https://crates.io/crates/egui_dock) [![docs.rs](https://img.shields.io/docsrs/egui_dock)](https://docs.rs/egui_dock/) -[![egui_version](https://img.shields.io/badge/egui-0.28-blue)](https://github.com/emilk/egui) +[![egui_version](https://img.shields.io/badge/egui-0.29-blue)](https://github.com/emilk/egui) Originally created by [@lain-dono](https://github.com/lain-dono), this library provides a docking system for `egui`. @@ -32,7 +32,7 @@ Add `egui` and `egui_dock` to your project's dependencies. ```toml [dependencies] -egui = "0.28" +egui = "0.29" egui_dock = "0.14" ``` diff --git a/src/dock_state/surface.rs b/src/dock_state/surface.rs index 66da3b9..169145f 100644 --- a/src/dock_state/surface.rs +++ b/src/dock_state/surface.rs @@ -1,7 +1,9 @@ use crate::{Node, NodeIndex, Tree, WindowState}; /// A [`Surface`] is the highest level component in a [`DockState`](crate::DockState). [`Surface`]s represent an area -/// in which nodes are placed. Typically, you're only using one surface, which is the main surface. However, if you drag +/// in which nodes are placed. +/// +/// Typically, you're only using one surface, which is the main surface. However, if you drag /// a tab out in a way which creates a window, you also create a new surface in which nodes can appear. #[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/src/widgets/dock_area/show/leaf.rs b/src/widgets/dock_area/show/leaf.rs index 0598260..7cf0248 100644 --- a/src/widgets/dock_area/show/leaf.rs +++ b/src/widgets/dock_area/show/leaf.rs @@ -4,7 +4,7 @@ use egui::emath::TSTransform; use egui::{ epaint::TextShape, lerp, pos2, vec2, Align, Align2, Button, CursorIcon, Frame, Id, Key, LayerId, Layout, NumExt, Order, Rect, Response, Rounding, ScrollArea, Sense, Stroke, TextStyle, - Ui, UiStackInfo, Vec2, WidgetText, + Ui, UiBuilder, Vec2, WidgetText, }; use crate::{ @@ -32,11 +32,11 @@ impl<'tree, Tab> DockArea<'tree, Tab> { let rect = self.dock_state[surface_index][node_index] .rect() .expect("This node must be a leaf"); - let ui = &mut ui.child_ui_with_id_source( - rect, - Layout::top_down_justified(Align::Min), - (node_index, "node"), - None, + let ui = &mut ui.new_child( + UiBuilder::new() + .max_rect(rect) + .layout(Layout::top_down_justified(Align::Min)) + .id_salt((node_index, "node")), ); let spacing = ui.spacing().item_spacing; ui.spacing_mut().item_spacing = Vec2::ZERO; @@ -112,11 +112,11 @@ impl<'tree, Tab> DockArea<'tree, Tab> { vec2(tabbar_outer_rect.width(), tabbar_outer_rect.height()), ); - let tabs_ui = &mut ui.child_ui_with_id_source( - tabbar_inner_rect, - Layout::left_to_right(Align::Center), - "tabs", - None, + let tabs_ui = &mut ui.new_child( + UiBuilder::new() + .max_rect(tabbar_inner_rect) + .layout(Layout::left_to_right(Align::Center)) + .id_salt("tabs"), ); let mut clip_rect = tabbar_outer_rect; @@ -432,11 +432,11 @@ impl<'tree, Tab> DockArea<'tree, Tab> { tabbar_outer_rect.right_bottom() - vec2(offset, 2.0), ); - let ui = &mut ui.child_ui_with_id_source( - rect, - Layout::left_to_right(Align::Center), - (node_index, "tab_add"), - None, + let ui = &mut ui.new_child( + UiBuilder::new() + .max_rect(rect) + .layout(Layout::left_to_right(Align::Center)) + .id_salt((node_index, "tab_add")), ); let (rect, mut response) = ui.allocate_exact_size(ui.available_size(), Sense::click()); @@ -772,9 +772,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> { ui.ctx().clone(), ui.layer_id(), id, - body_rect, - ui.clip_rect(), - UiStackInfo::default(), + UiBuilder::new().max_rect(body_rect), ); ui.set_clip_rect(Rect::from_min_max(ui.cursor().min, ui.clip_rect().max)); diff --git a/src/widgets/dock_area/show/window_surface.rs b/src/widgets/dock_area/show/window_surface.rs index 84cc655..6429074 100644 --- a/src/widgets/dock_area/show/window_surface.rs +++ b/src/widgets/dock_area/show/window_surface.rs @@ -1,6 +1,6 @@ use egui::{ CollapsingHeader, CollapsingResponse, Frame, Galley, Id, Layout, Rect, Response, Sense, - TextStyle, TextWrapMode, Ui, Vec2, Widget, + TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, Widget, }; use std::convert::identity; use std::sync::Arc; @@ -133,7 +133,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> { ) -> Option> { if self.show_window_collapse_buttons { let ch_response = CollapsingHeader::new("") - .id_source(id) + .id_salt(id) .open(open) .show_unindented(ui, |ui| { ui.set_min_size(Vec2::splat(100.0)); @@ -198,7 +198,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> { .as_str(), ), ); - ui.allocate_ui_at_rect(rect, |ui| { + ui.allocate_new_ui(UiBuilder::new().max_rect(rect), |ui| { ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.set_height(rect.height()); if ui.add(close_button).clicked() {