Skip to content

Commit

Permalink
Release 0.15 (#256)
Browse files Browse the repository at this point in the history
* Different design: more compact windows and collapsing/closing control on each tab bar (#237)

* Correct comment typos

* Add two buttons on tab bars

- Close all tabs: "×"
- Collapse all tabs: "▼"

* Add some utility for recursive node collapse checking

* Preliminary implementation of collapsing windows

* Handle tab collapsing layout

* Resize windows when subnodes collapsed

* Implements leaf close all button

* Update changelog

* Allow dragging to a collapsed leaf

* Fix collapsed state checking after dnd splits

* Update examples

* Update changelog

* Fix up changelog after rebase

* Fix failing test and rename `Translations::window` to `Translations::leaf`.

* Remove `Clone` bound on `map_tabs` and `filter_map_tabs` (#241)

* remove Clone bound on map_tabs and filter_map_tabs

* remove Clone bound from all functions with Clone + FnMut bounds

* Update changelog

* Add missing period in changelog

---------

Co-authored-by: Adanos020 <[email protected]>

* Update crate version and add MSRV change to changelog

* Fix heading type in changelog

* Fix tab bar scroll bar width on window surfaces

* Add close window button in context menu

* Add minimize window button

* Update CHANGELOG.md

* Fix cargo test

* Add tooltips to right-clickable tab bar buttons

* Add minimization activation with modifiers

* Add close window with modifiers

* Correct tooltip display conditions

* Upgrade to egui 0.29

* Add secondary button feature toggle

* Cleanup code

* Update examples

* Fix cursor icon logic

* Update examples

* Update changelog

* Make Japanese translations in the example more consistent with each other

---------

Co-authored-by: Adanos020 <[email protected]>
Co-authored-by: Ved_s <[email protected]>

* Egui 0.30 (#255)

* Egui 0.30

* Upgrade to egui 0.30.

* Update changelog and readme

* Update the crate version in Cargo.toml

* Fix winit compile error

* Make Clippy happy

---------

Co-authored-by: Adanos020 <[email protected]>

---------

Co-authored-by: Michael Zhang <[email protected]>
Co-authored-by: Ved_s <[email protected]>
Co-authored-by: Bryce Berger <[email protected]>
  • Loading branch information
4 people authored Dec 28, 2024
1 parent 179832d commit dc841ce
Show file tree
Hide file tree
Showing 20 changed files with 1,391 additions and 283 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/Cargo.lock
/.idea
/.vscode
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,70 @@
# egui_dock changelog

## 0.15.0 - Unreleased

### Changed

- From ([#237](https://github.com/Adanos020/egui_dock/pull/237)):
- Each leaf can now be collapsed / closed individually. They are introduced as additional tab bar controls.
- Undocked windows are now more compact. The original undocked window controls are now accessible as "secondary buttons" from the tab bar.
- By default, the secondary buttons are activated from primary buttons either by holding the <kbd>Shift</kbd> key while clicking on them, or from a context menu by right-clicking them.
- A number of tooltip hints are on by default as guides to the new behavior, but they can be disabled.
- There has been an overhaul to the internal codebase to support the new features.

### Added

- From ([#237](https://github.com/Adanos020/egui_dock/pull/237)):
- `DockArea::show_leaf_close_all_buttons` – shows a close all button which closes all open tabs in a leaf.
- `DockArea::show_leaf_collapse_buttons` – shows a collapsing button which collapses a leaf (no longer collapsing a window).
- `DockArea::show_secondary_button_hint` – sets whether tooltip hints are shown for secondary buttons on tab bars.
- `DockArea::show_leaf_collapse_buttons` – shows a collapsing button which collapses a leaf (no longer collapsing a window).
- `DockArea::secondary_button_on_modifier` – sets whether the secondary buttons on tab bars are activated by the modifier key.
- `DockArea::secondary_button_context_menu` – sets whether the secondary buttons on tab bars are activated from a context value by right-clicking primary buttons.
- Added the following translations:
- `LeafTranslations::close_all_button`
- `LeafTranslations::close_all_button_menu_hint`
- `LeafTranslations::close_all_button_modifier_hint`
- `LeafTranslations::close_all_button_modifier_menu_hint`
- `LeafTranslations::close_all_button_disabled_tooltip`
- `LeafTranslations::minimize_button`
- `LeafTranslations::minimize_button_menu_hint`
- `LeafTranslations::minimize_button_modifier_hint`
- `LeafTranslations::minimize_button_modifier_menu_hint`
- `Node::is_collapsed` – returns whether the `Node` is collapsed.
- `Node::collapsed_leaf_count` – returns the number of collapsed layers of leaf subnodes.
- `Node::set_collapsed` – set the collapsing state of the `Node`.
- `Node::set_collapsed_leaf_count` – sets the number of collapsed layers of leaf subnodes.
- `WindowState::minimized` field – records whether a window is minimized.
- `WindowState::expanded_height` field – records the height of the window before it was fully collapsed.
- Added style configuration for the two buttons:
- `ButtonsStyle::{close_all_tabs, collapse_tabs, minimize_window}_color`
- `ButtonsStyle::{close_all_tabs, collapse_tabs, minimize_window}_active_color`
- `ButtonsStyle::{close_all_tabs, collapse_tabs, minimize_window}_bg_fill`
- `ButtonsStyle::{close_all_tabs, collapse_tabs, minimize_window}_border_color`
- `ButtonsStyle::close_all_tabs_disabled_color`
- `Style::TAB_CLOSE_ALL_BUTTON_SIZE`
- `Style::TAB_CLOSE_ALL_SIZE`
- `Style::TAB_COLLAPSE_BUTTON_SIZE`
- `Style::TAB_COLLAPSE_ARROW_SIZE`
- `Style::TAB_EXPAND_BUTTON_SIZE`
- `Style::TAB_EXPAND_ARROW_SIZE`

### Breaking changes

- From ([#237](https://github.com/Adanos020/egui_dock/pull/237)):
- Renamed `Translations::WindowTranslations` to `Translations::LeafTranslations`.
- Renamed `WindowTranslations::close_button_tooltip` to `LeafTranslations::close_button_disabled_tooltip`.
- `Translations::LeafTranslations` now requires more fields to be constructed (see **Added** section).
- Upgraded to egui 0.30.

### Deprecated

- From ([#237](https://github.com/Adanos020/egui_dock/pull/237)):
- `DockArea::show_window_close_buttons` – no longer has any effect; consider using `DockArea::show_leaf_close_all_buttons`
instead.
- `DockArea::show_window_collapse_buttons` – no longer has any effect; consider using `DockArea::show_leaf_collapse_buttons`
instead.

## 0.14.0 - 2024-09-02

### Breaking changes
Expand Down
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "egui_dock"
description = "Docking system for egui - an immediate-mode GUI library for Rust"
authors = ["lain-dono", "Adam Gąsior (Adanos020)"]
version = "0.14.0"
version = "0.15.0"
edition = "2021"
rust-version = "1.76"
license = "MIT"
Expand All @@ -18,14 +18,15 @@ default = []
serde = ["dep:serde", "egui/serde"]

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

duplicate = "2.0"
paste = "1.0"

[dev-dependencies]
eframe = { version = "0.29", default-features = false, features = [
eframe = { version = "0.30", default-features = false, features = [
"default",
"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.29-blue)](https://github.com/emilk/egui)
[![egui_version](https://img.shields.io/badge/egui-0.30-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.29"
egui_dock = "0.14"
egui = "0.30"
egui_dock = "0.15"
```

Then proceed by setting up `egui`, following its [quick start guide](https://github.com/emilk/egui#quick-start).
Expand Down
42 changes: 33 additions & 9 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ struct MyContext {
draggable_tabs: bool,
show_tab_name_on_hover: bool,
allowed_splits: AllowedSplits,
show_window_close: bool,
show_window_collapse: bool,
show_leaf_close_all: bool,
show_leaf_collapse: bool,
show_secondary_button_hint: bool,
secondary_button_on_modifier: bool,
secondary_button_context_menu: bool,
}

struct MyApp {
Expand Down Expand Up @@ -156,10 +159,25 @@ impl MyContext {
ui.checkbox(&mut self.show_add_buttons, "Show add buttons");
ui.checkbox(&mut self.draggable_tabs, "Draggable tabs");
ui.checkbox(&mut self.show_tab_name_on_hover, "Show tab name on hover");
ui.checkbox(&mut self.show_window_close, "Show close button on windows");
ui.checkbox(
&mut self.show_window_collapse,
"Show collaspse button on windows",
&mut self.show_leaf_close_all,
"Show close all button on tab bars",
);
ui.checkbox(
&mut self.show_leaf_collapse,
"Show collaspse button on tab bars",
);
ui.checkbox(
&mut self.secondary_button_on_modifier,
"Enable secondary buttons when modifiers (Shift by default) are pressed",
);
ui.checkbox(
&mut self.secondary_button_context_menu,
"Enable secondary buttons in right-click context menus",
);
ui.checkbox(
&mut self.show_secondary_button_hint,
"Show tooltip hints for secondary buttons",
);
ComboBox::new("cbox:allowed_splits", "Split direction(s)")
.selected_text(format!("{:?}", self.allowed_splits))
Expand Down Expand Up @@ -540,8 +558,11 @@ impl Default for MyApp {
style: None,
open_tabs,

show_window_close: true,
show_window_collapse: true,
show_leaf_close_all: true,
show_leaf_collapse: true,
show_secondary_button_hint: true,
secondary_button_on_modifier: true,
secondary_button_context_menu: true,
show_close_buttons: true,
show_add_buttons: false,
draggable_tabs: true,
Expand Down Expand Up @@ -599,8 +620,11 @@ impl eframe::App for MyApp {
.draggable_tabs(self.context.draggable_tabs)
.show_tab_name_on_hover(self.context.show_tab_name_on_hover)
.allowed_splits(self.context.allowed_splits)
.show_window_close_buttons(self.context.show_window_close)
.show_window_collapse_buttons(self.context.show_window_collapse)
.show_leaf_close_all_buttons(self.context.show_leaf_close_all)
.show_leaf_collapse_buttons(self.context.show_leaf_collapse)
.show_secondary_button_hint(self.context.show_secondary_button_hint)
.secondary_button_on_modifier(self.context.secondary_button_on_modifier)
.secondary_button_context_menu(self.context.secondary_button_context_menu)
.show_inside(ui, &mut self.context);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/dock_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<Tab> DockState<Tab> {
pub fn is_surface_valid(&self, surface_index: SurfaceIndex) -> bool {
self.surfaces
.get(surface_index.0)
.map_or(false, |surface| !surface.is_empty())
.is_some_and(|surface| !surface.is_empty())
}

/// Returns a list of all valid [`SurfaceIndex`]es.
Expand Down
60 changes: 52 additions & 8 deletions src/dock_state/translations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub struct Translations {
/// Text overrides for buttons in tab context menus.
pub tab_context_menu: TabContextMenuTranslations,
/// Text overrides for buttons in windows.
pub window: WindowTranslations,
pub leaf: LeafTranslations,
}

/// Specifies text in buttons displayed in the context menu displayed upon right-clicking on a tab.
Expand All @@ -18,21 +18,46 @@ pub struct TabContextMenuTranslations {
pub eject_button: String,
}

/// Specifies text in buttons displayed in the context menu displayed upon right-clicking on a tab.
/// Specifies text displayed in the primary buttons on a tab bar.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct WindowTranslations {
/// Message in the tooltip shown while hovering over a grayed out X button of a window
pub struct LeafTranslations {
/// Message in the tooltip shown while hovering over a grayed out X button of a leaf
/// containing non-closable tabs.
pub close_button_disabled_tooltip: String,
/// Button that closes the entire window.
pub close_all_button: String,
/// Message in the tooltip shown while hovering over an X button of a window.
/// Used when the secondary buttons are accessible from the context menu.
pub close_all_button_menu_hint: String,
/// Message in the tooltip shown while hovering over an X button of a window.
/// Used when the secondary buttons are accessible using modifiers.
pub close_all_button_modifier_hint: String,
/// Message in the tooltip shown while hovering over an X button of a window.
/// Used when the secondary buttons are accessible using modifiers and from the context menu.
pub close_all_button_modifier_menu_hint: String,
/// Message in the tooltip shown while hovering over a grayed out close window button of a window
/// containing non-closable tabs.
pub close_button_tooltip: String,
pub close_all_button_disabled_tooltip: String,
/// Button that minimizes the window.
pub minimize_button: String,
/// Message in the tooltip shown while hovering over a collapse button of a leaf.
/// Used when the secondary buttons are accessible from the context menu.
pub minimize_button_menu_hint: String,
/// Message in the tooltip shown while hovering over a collapse button of a leaf.
/// Used when the secondary buttons are accessible using modifiers.
pub minimize_button_modifier_hint: String,
/// Message in the tooltip shown while hovering over a collapse button of a leaf.
/// Used when the secondary buttons are accessible using modifiers and from the context menu.
pub minimize_button_modifier_menu_hint: String,
}

impl Translations {
/// Default English translations.
pub fn english() -> Self {
Self {
tab_context_menu: TabContextMenuTranslations::english(),
window: WindowTranslations::english(),
leaf: LeafTranslations::english(),
}
}
}
Expand All @@ -47,11 +72,30 @@ impl TabContextMenuTranslations {
}
}

impl WindowTranslations {
impl LeafTranslations {
/// Default English translations.
pub fn english() -> Self {
Self {
close_button_tooltip: String::from("This window contains non-closable tabs."),
close_button_disabled_tooltip: String::from("This leaf contains non-closable tabs."),
close_all_button: String::from("Close window"),
close_all_button_menu_hint: String::from("Right click to close this window."),
close_all_button_modifier_hint: String::from(
"Press modifier keys (Shift by default) to close this window.",
),
close_all_button_modifier_menu_hint: String::from(
"Press modifier keys (Shift by default) or right click to close this window.",
),
close_all_button_disabled_tooltip: String::from(
"This window contains non-closable tabs.",
),
minimize_button: String::from("Minimize window"),
minimize_button_menu_hint: String::from("Right click to minimize this window."),
minimize_button_modifier_hint: String::from(
"Press modifier keys (Shift by default) to minimize this window.",
),
minimize_button_modifier_menu_hint: String::from(
"Press modifier keys (Shift by default) or right click to minimize this window.",
),
}
}
}
Loading

0 comments on commit dc841ce

Please sign in to comment.