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

Release 0.10 #215

Merged
merged 5 commits into from
Jan 9, 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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# egui_dock changelog

## 0.10.0 - 2024-01-08

### Added
- From ([#211](https://github.com/Adanos020/egui_dock/pull/211)):
- Tabs, the close tab buttons and the add tab buttons are now focusable with the keyboard and interactable with the enter key and space bar.
- Separators are now focusable with the keyboard and movable using the arrow keys while control or shift is held.
- `TabStyle::active_with_kb_focus`, `TabStyle::inactive_with_kb_focus` and `TabStyle::focused_with_kb_focus` for style of tabs that are focused with the keyboard.
- Missing translation for the tooltip showing when you hover on a grayed out window close button. ([#216](https://github.com/Adanos020/egui_dock/pull/216))

### Fixed
- Widgets inside tabs are now focusable with the tab key on the keyboard. ([#211](https://github.com/Adanos020/egui_dock/pull/211))

### Breaking changes
- Upgraded to egui 0.25
- Replaced `Default` implementations for `{TabContextMenu,Window,}Translations` with associated functions called `english`. ([#216](https://github.com/Adanos020/egui_dock/pull/216))

## 0.9.1 - 2023-12-10

### Fixed
Expand Down
6 changes: 3 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.9.1"
version = "0.10.0"
edition = "2021"
rust-version = "1.72"
license = "MIT"
Expand All @@ -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",
] }
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.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 Expand Up @@ -32,8 +32,8 @@ Add `egui` and `egui_dock` to your project's dependencies.

```toml
[dependencies]
egui = "0.24"
egui_dock = "0.9"
egui = "0.25"
egui_dock = "0.10"
```

Then proceed by setting up `egui`, following its [quick start guide](https://github.com/emilk/egui#quick-start).
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 @@ -67,7 +67,7 @@ impl<Tab> DockState<Tab> {
Self {
surfaces: vec![Surface::Main(Tree::new(tabs))],
focused_surface: None,
translations: Translations::default(),
translations: Translations::english(),
}
}

Expand Down
31 changes: 26 additions & 5 deletions src/dock_state/translations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
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,
}

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

impl Default for Translations {
/// Specifies text in buttons displayed in the context menu displayed upon right-clicking on a tab.
#[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
/// containing non-closable tabs.
pub close_button_tooltip: String,
}

impl Translations {
/// Default English translations.
fn default() -> Self {
pub fn english() -> Self {
Self {
tab_context_menu: TabContextMenuTranslations::default(),
tab_context_menu: TabContextMenuTranslations::english(),
window: WindowTranslations::english(),
}
}
}

impl Default for TabContextMenuTranslations {
impl TabContextMenuTranslations {
/// Default English translations.
fn default() -> Self {
pub fn english() -> Self {
Self {
close_button: String::from("Close"),
eject_button: String::from("Eject"),
}
}
}

impl WindowTranslations {
/// Default English translations.
pub fn english() -> Self {
Self {
close_button_tooltip: String::from("This window contains non-closable tabs."),
}
}
}
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,24 @@
//! Example usage:
//!
//! ```rust
//! # use egui_dock::{DockState, TabContextMenuTranslations, Translations};
//! # use egui_dock::{DockState, TabContextMenuTranslations, Translations, WindowTranslations};
//! # type Tab = ();
//! let translations_pl = Translations {
//! tab_context_menu: TabContextMenuTranslations {
//! close_button: "Zamknij zakładkę".to_string(),
//! eject_button: "Przenieś zakładkę do nowego okna".to_string(),
//! },
//! window: WindowTranslations {
//! close_button_tooltip: "To okno zawiera zakładki, których nie można zamknąć.".to_string(),
//! }
//! };
//! let dock_state = DockState::<Tab>::new(vec![]).with_translations(translations_pl);
//!
//! // Alternatively:
//! let mut dock_state = DockState::<Tab>::new(vec![]);
//! dock_state.translations.tab_context_menu.close_button = "タブを閉じる".to_string();
//! dock_state.translations.tab_context_menu.eject_button = "タブを新しいウィンドウへ移動".to_string();
//! dock_state.translations.window.close_button_tooltip = "このウィンドウは閉じられないタブがある。".to_string();
//! ```

#![warn(missing_docs)]
Expand Down
66 changes: 66 additions & 0 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ pub struct TabStyle {
/// Style of the tab when it is hovered.
pub hovered: TabInteractionStyle,

/// Style of the tab when it is inactive and has keyboard focus.
pub inactive_with_kb_focus: TabInteractionStyle,

/// Style of the tab when it is active and has keyboard focus.
pub active_with_kb_focus: TabInteractionStyle,

/// Style of the tab when it is focused and has keyboard focus.
pub focused_with_kb_focus: TabInteractionStyle,

/// Style for the tab body.
pub tab_body: TabBodyStyle,

Expand Down Expand Up @@ -357,6 +366,15 @@ impl Default for TabStyle {
text_color: Color32::BLACK,
..Default::default()
},
active_with_kb_focus: TabInteractionStyle::default(),
inactive_with_kb_focus: TabInteractionStyle {
text_color: Color32::DARK_GRAY,
..Default::default()
},
focused_with_kb_focus: TabInteractionStyle {
text_color: Color32::BLACK,
..Default::default()
},
tab_body: TabBodyStyle::default(),
hline_below_active_tab_name: false,
minimum_width: None,
Expand Down Expand Up @@ -532,6 +550,9 @@ impl TabStyle {
inactive: TabInteractionStyle::from_egui_inactive(style),
focused: TabInteractionStyle::from_egui_focused(style),
hovered: TabInteractionStyle::from_egui_hovered(style),
active_with_kb_focus: TabInteractionStyle::from_egui_active_with_kb_focus(style),
inactive_with_kb_focus: TabInteractionStyle::from_egui_inactive_with_kb_focus(style),
focused_with_kb_focus: TabInteractionStyle::from_egui_focused_with_kb_focus(style),
tab_body: TabBodyStyle::from_egui(style),
..Default::default()
}
Expand Down Expand Up @@ -609,6 +630,51 @@ impl TabInteractionStyle {
..TabInteractionStyle::from_egui_inactive(style)
}
}

/// Derives relevant fields from `egui::Style` for an active tab with keyboard focus and sets the remaining fields to their default values.
///
/// Fields overwritten by [`egui::Style`] are:
/// - [`TabInteractionStyle::outline_color`]
/// - [`TabInteractionStyle::bg_fill`]
/// - [`TabInteractionStyle::text_color`]
/// - [`TabInteractionStyle::rounding`]
pub fn from_egui_active_with_kb_focus(style: &egui::Style) -> Self {
Self {
text_color: style.visuals.strong_text_color(),
outline_color: style.visuals.widgets.hovered.bg_stroke.color,
..TabInteractionStyle::from_egui_active(style)
}
}

/// Derives relevant fields from `egui::Style` for an inactive tab with keyboard focus and sets the remaining fields to their default values.
///
/// Fields overwritten by [`egui::Style`] are:
/// - [`TabInteractionStyle::outline_color`]
/// - [`TabInteractionStyle::bg_fill`]
/// - [`TabInteractionStyle::text_color`]
/// - [`TabInteractionStyle::rounding`]
pub fn from_egui_inactive_with_kb_focus(style: &egui::Style) -> Self {
Self {
text_color: style.visuals.strong_text_color(),
outline_color: style.visuals.widgets.hovered.bg_stroke.color,
..TabInteractionStyle::from_egui_inactive(style)
}
}

/// Derives relevant fields from `egui::Style` for a focused tab with keyboard focus and sets the remaining fields to their default values.
///
/// Fields overwritten by [`egui::Style`] are:
/// - [`TabInteractionStyle::outline_color`]
/// - [`TabInteractionStyle::bg_fill`]
/// - [`TabInteractionStyle::text_color`]
/// - [`TabInteractionStyle::rounding`]
pub fn from_egui_focused_with_kb_focus(style: &egui::Style) -> Self {
Self {
text_color: style.visuals.strong_text_color(),
outline_color: style.visuals.widgets.hovered.bg_stroke.color,
..TabInteractionStyle::from_egui_focused(style)
}
}
}

impl TabBodyStyle {
Expand Down
Loading
Loading