Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to egui 0.25 #214

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ default = []
serde = ["dep:serde", "egui/serde"]

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

duplicate = "1.0"
paste = "1.0"

[dev-dependencies]
eframe = { version = "0.24", default-features = false, features = [
eframe = { version = "0.25", default-features = false, features = [
"default_fonts",
"glow",
] }
2 changes: 1 addition & 1 deletion 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.24-blue)](https://github.com/emilk/egui)
[![egui_version](https://img.shields.io/badge/egui-0.25-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
11 changes: 2 additions & 9 deletions src/widgets/dock_area/show/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,15 +588,8 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
pos - galley.size() / 2.0
};

let override_text_color = (!galley.galley_has_color).then_some(tab_style.text_color);

ui.painter().add(TextShape {
pos: text_pos,
galley: galley.galley,
underline: Stroke::NONE,
override_text_color,
angle: 0.0,
});
ui.painter()
.add(TextShape::new(text_pos, galley, tab_style.text_color));

let close_response = show_close_button.then(|| {
let mut close_button_rect = rect;
Expand Down
7 changes: 6 additions & 1 deletion src/widgets/dock_area/show/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,12 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
if response.has_focus() {
// Prevent the default behaviour of removing focus from the separators when the
// arrow keys are pressed
ui.memory_mut(|m| m.set_focus_lock_filter(response.id, EventFilter { arrows: should_respond_to_arrow_keys, tab: false, escape: false }));
ui.memory_mut(|m| m.set_focus_lock_filter(response.id, EventFilter {
horizontal_arrows: should_respond_to_arrow_keys,
vertical_arrows: should_respond_to_arrow_keys,
tab: false,
escape: false
}));
}

let arrow_key_offset = if response.has_focus() && should_respond_to_arrow_keys {
Expand Down
12 changes: 8 additions & 4 deletions src/widgets/dock_area/show/window_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
.title(&mut tabs[active.0])
.color(ui.visuals().widgets.noninteractive.fg_stroke.color)
.into_galley(ui, Some(false), 0.0, TextStyle::Button)
.galley
};

// Fade window frame (if neccesary)
Expand Down Expand Up @@ -152,8 +151,11 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
ch_response.header_response.rect.height(),
),
);
ui.painter()
.galley(rect.center() - (title.size() * 0.5), title);
ui.painter().galley(
rect.center() - (title.size() * 0.5),
title,
ui.visuals().widgets.noninteractive.fg_stroke.color,
);
}
Some(ch_response)
} else {
Expand All @@ -177,7 +179,7 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
let rect = {
let (top_right, height) = match collapse_response {
Some(collapse) => (
egui::Rect::from_two_pos(
Rect::from_two_pos(
collapse.header_response.rect.right_top(),
ui.max_rect().right_top(),
)
Expand All @@ -199,9 +201,11 @@ impl<'tree, Tab> DockArea<'tree, Tab> {
});
}
}

fn min_window_width(title: &Galley, button_width: f32) -> f32 {
(button_width * 2.) + title.size().x
}

fn close_button(disabled: Option<&'static str>) -> impl Widget {
move |ui: &mut Ui| -> Response {
let sense = disabled.map_or(Sense::click(), |_disabled| Sense::hover());
Expand Down
Loading