Skip to content

Commit

Permalink
Update to egui 0.28 (#243)
Browse files Browse the repository at this point in the history
* Update to egui 0.28

* Fix examples

* Fix inefficiency in `hello` example
  • Loading branch information
Adanos020 committed Jul 3, 2024
1 parent fe9f46d commit 054d0fa
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 21 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
name = "egui_dock"
description = "Docking system for egui - an immediate-mode GUI library for Rust"
authors = ["lain-dono", "Adam Gąsior (Adanos020)"]
version = "0.12.0"
version = "0.13.0"
edition = "2021"
rust-version = "1.72"
rust-version = "1.76"
license = "MIT"
readme = "README.md"
repository = "https://github.com/Adanos020/egui_dock"
Expand All @@ -18,14 +18,14 @@ default = []
serde = ["dep:serde", "egui/serde"]

[dependencies]
egui = { version = "0.27", default-features = false }
egui = { version = "0.28", default-features = false }
serde = { version = "1", optional = true, features = ["derive"] }

duplicate = "1.0"
paste = "1.0"

[dev-dependencies]
eframe = { version = "0.27", default-features = false, features = [
eframe = { version = "0.28", default-features = false, features = [
"default_fonts",
"glow",
] }
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.27-blue)](https://github.com/emilk/egui)
[![egui_version](https://img.shields.io/badge/egui-0.28-blue)](https://github.com/emilk/egui)

Originally created by [@lain-dono](https://github.com/lain-dono), this library provides a docking system for `egui`.

Expand Down Expand Up @@ -32,8 +32,8 @@ Add `egui` and `egui_dock` to your project's dependencies.

```toml
[dependencies]
egui = "0.27"
egui_dock = "0.12"
egui = "0.28"
egui_dock = "0.13"
```

Then proceed by setting up `egui`, following its [quick start guide](https://github.com/emilk/egui#quick-start).
Expand Down
4 changes: 2 additions & 2 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Box::<MyApp>::default()),
Box::new(|_cc| Ok(Box::<MyApp>::default())),
)
}

Expand Down Expand Up @@ -509,7 +509,7 @@ impl Default for MyApp {
fn default() -> Self {
let mut dock_state =
DockState::new(vec!["Simple Demo".to_owned(), "Style Editor".to_owned()]);
dock_state.translations.tab_context_menu.eject_button = "Undock".to_owned();
"Undock".clone_into(&mut dock_state.translations.tab_context_menu.eject_button);
let [a, b] = dock_state.main_surface_mut().split_left(
NodeIndex::root(),
0.3,
Expand Down
2 changes: 1 addition & 1 deletion examples/reject_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Box::<MyApp>::default()),
Box::new(|_cc| Ok(Box::<MyApp>::default())),
)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Box::<MyApp>::default()),
Box::new(|_cc| Ok(Box::<MyApp>::default())),
)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/tab_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Box::<MyApp>::default()),
Box::new(|_cc| Ok(Box::<MyApp>::default())),
)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/tab_add_popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Box::<MyApp>::default()),
Box::new(|_cc| Ok(Box::<MyApp>::default())),
)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/text_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"Text editor examples",
options,
Box::new(|_cc| Box::<MyApp>::default()),
Box::new(|_cc| Ok(Box::<MyApp>::default())),
)
}

Expand Down
9 changes: 7 additions & 2 deletions src/widgets/dock_area/show/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, Vec2, WidgetText,
Ui, UiStackInfo, Vec2, WidgetText,
};

use crate::{
Expand Down Expand Up @@ -36,6 +36,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
rect,
Layout::top_down_justified(Align::Min),
(node_index, "node"),
None,
);
let spacing = ui.spacing().item_spacing;
ui.spacing_mut().item_spacing = Vec2::ZERO;
Expand Down Expand Up @@ -115,6 +116,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
tabbar_inner_rect,
Layout::left_to_right(Align::Center),
"tabs",
None,
);

let mut clip_rect = tabbar_outer_rect;
Expand Down Expand Up @@ -256,7 +258,8 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
.response;
let title_id = response.id;

let response = tabs_ui.interact(response.rect, id, Sense::click_and_drag());
let response =
tabs_ui.interact(response.rect, id.with("dragged"), Sense::click_and_drag());

if let Some(pointer_pos) = tabs_ui.ctx().pointer_interact_pos() {
let start = *state.drag_start.get_or_insert(pointer_pos);
Expand Down Expand Up @@ -433,6 +436,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
rect,
Layout::left_to_right(Align::Center),
(node_index, "tab_add"),
None,
);

let (rect, mut response) = ui.allocate_exact_size(ui.available_size(), Sense::click());
Expand Down Expand Up @@ -770,6 +774,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
id,
body_rect,
ui.clip_rect(),
UiStackInfo::default(),
);
ui.set_clip_rect(Rect::from_min_max(ui.cursor().min, ui.clip_rect().max));

Expand Down
9 changes: 4 additions & 5 deletions src/widgets/dock_area/show/window_surface.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::convert::identity;
use std::sync::Arc;

use egui::{
CollapsingHeader, CollapsingResponse, Frame, Galley, Id, Layout, Rect, Response, Sense,
TextStyle, Ui, Vec2, Widget,
TextStyle, TextWrapMode, Ui, Vec2, Widget,
};
use std::convert::identity;
use std::sync::Arc;

use crate::{
dock_area::{state::State, tab_removal::TabRemoval},
Expand Down Expand Up @@ -61,7 +60,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
tab_viewer
.title(&mut tabs[active.0])
.color(ui.visuals().widgets.noninteractive.fg_stroke.color)
.into_galley(ui, Some(false), 0.0, TextStyle::Button)
.into_galley(ui, Some(TextWrapMode::Extend), 0.0, TextStyle::Button)
};

// Fade window frame (if necessary)
Expand Down

0 comments on commit 054d0fa

Please sign in to comment.