Skip to content

Commit

Permalink
Update to egui 0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
Adanos020 committed Jul 3, 2024
1 parent 4397f11 commit 0ce423b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 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",
] }
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Add `egui` and `egui_dock` to your project's dependencies.

```toml
[dependencies]
egui = "0.26"
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 All @@ -53,11 +53,12 @@ You can run them with Cargo from the crate's root directory, for example: `cargo

## Alternatives

### [egui_tiles](https://github.com/rerun-io/egui_tiles)
### [egui_tiles](https://github.com/rerun-io/egui_tiles)

It's a library aiming to achieve similar goals in addition to being more flexible and customizable.

One feature it supports that `egui_dock` does not at the moment is the ability to divide nodes into more than two children,
One feature it supports that `egui_dock` does not at the moment is the ability to divide nodes into more than two
children,
enabling horizontal, vertical, and grid layouts.

> [!NOTE]
Expand Down
2 changes: 1 addition & 1 deletion 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
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 0ce423b

Please sign in to comment.