refactor(bar-core): move selected_frame.rs and ui.rs into komorebi-bar-core

Pure move of the two files of the bar that depend on nothing else in it, byte-identical in the Windows and macOS bars (selected_frame.rs since the previous revision). Each bar keeps its paths: main.rs re-exports the modules (pub use komorebi_bar_core::selected_frame / ui), so every crate::selected_frame::... and crate::ui::... in the widgets and bar.rs resolves as before. The crate takes eframe from the workspace; the macOS bar takes the crate by path.

Removed: 111 lines (89 + 22) from each of the two bars, 111 added once.

Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors (bar warnings 10 -> 6, the four strokes of the previous revision); native cargo test -p komorebi-bar-core 2 passed, 0 failed; harness schema regeneration (S/bar2/regen.sh): macOS byte-identical to its schema.bar.json (3,774 lines), Windows byte-identical to the regenerated schema.bar.json (9,090 lines). Not verified: rendering.
This commit is contained in:
LGUG2Z committed 2026-10-31 01:37:54 -07:00
1 parent a56a691d10
commit 8ad6213b04
12 files changed
+24 -115

No files matched your search

Generated
+4
View File
@@ -3404,6 +3404,7 @@ dependencies = [
"font-loader",
"hotwatch",
"image 0.25.10",
"komorebi-bar-core",
"komorebi-client",
"komorebi-themes",
"lazy_static",
@@ -3434,6 +3435,9 @@ dependencies = [
[[package]]
name = "komorebi-bar-core"
version = "0.1.42"
dependencies = [
"eframe",
]
[[package]]
name = "komorebi-client"
+3
View File
@@ -3,3 +3,6 @@ name = "komorebi-bar-core"
version = "0.1.42"
description = "The status bar shared by the Windows and macOS komorebi bars: configuration, widgets and the platform seam"
edition = "2024"
[dependencies]
eframe = { workspace = true }
+3
View File
@@ -4,3 +4,6 @@
//! oracle in `tests/schema_oracle.rs`: the checked-in `schema.bar.json` of both bars must not
//! change unless a reviewed revision says so.
#![warn(clippy::all)]
pub mod selected_frame;
pub mod ui;
File renamed without changes.
+1
View File
@@ -6,6 +6,7 @@ edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
komorebi-bar-core = { path = "../crates/komorebi-bar-core" }
komorebi-client = { path = "../komorebi-client", default-features = false }
komorebi-themes = { path = "../komorebi-themes", default-features = false }
+2 -2
View File
@@ -1,8 +1,8 @@
mod bar;
mod config;
mod render;
mod selected_frame;
mod ui;
pub use komorebi_bar_core::selected_frame;
pub use komorebi_bar_core::ui;
mod widgets;
use crate::bar::Komobar;
+8
View File
@@ -3217,6 +3217,7 @@ dependencies = [
"hotwatch",
"icns",
"image 0.25.10",
"komorebi-bar-core",
"komorebi-client",
"komorebi-themes",
"lazy_static",
@@ -3239,6 +3240,13 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "komorebi-bar-core"
version = "0.1.42"
dependencies = [
"eframe",
]
[[package]]
name = "komorebi-client"
version = "0.1.1"
+1
View File
@@ -6,6 +6,7 @@ edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
komorebi-bar-core = { path = "../../crates/komorebi-bar-core" }
komorebi-client = { path = "../komorebi-client", default-features = false }
komorebi-themes = { workspace = true }
+2 -2
View File
@@ -1,8 +1,8 @@
mod bar;
mod config;
mod render;
mod selected_frame;
mod ui;
pub use komorebi_bar_core::selected_frame;
pub use komorebi_bar_core::ui;
mod widgets;
use crate::bar::Komobar;
@@ -1,89 +0,0 @@
use eframe::egui::Color32;
use eframe::egui::CursorIcon;
use eframe::egui::Frame;
use eframe::egui::Margin;
use eframe::egui::Response;
use eframe::egui::Sense;
use eframe::egui::Stroke;
use eframe::egui::Ui;
/// Same as SelectableLabel, but supports all content
pub struct SelectableFrame {
selected: bool,
selected_fill: Option<Color32>,
}
impl SelectableFrame {
pub fn new(selected: bool) -> Self {
Self {
selected,
selected_fill: None,
}
}
pub fn new_auto(selected: bool, selected_fill: Option<Color32>) -> Self {
Self {
selected,
selected_fill,
}
}
pub fn show<R>(self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> Response {
let Self {
selected,
selected_fill,
} = self;
Frame::NONE
.show(ui, |ui| {
let response = ui.interact(ui.max_rect(), ui.unique_id(), Sense::click());
if ui.is_rect_visible(response.rect) {
// take into account the stroke width
let inner_margin = Margin::symmetric(
ui.style().spacing.button_padding.x as i8 - 1,
ui.style().spacing.button_padding.y as i8 - 1,
);
// since the stroke is drawn inside the frame, we always reserve space for it
if selected && response.hovered() {
let visuals = ui.style().interact_selectable(&response, selected);
Frame::NONE
.stroke(Stroke::new(1.0_f32, visuals.bg_stroke.color))
.corner_radius(visuals.corner_radius)
.fill(selected_fill.unwrap_or(visuals.bg_fill))
.inner_margin(inner_margin)
.show(ui, add_contents);
} else if response.hovered() || response.highlighted() || response.has_focus() {
let visuals = ui.style().interact_selectable(&response, selected);
Frame::NONE
.stroke(Stroke::new(1.0_f32, visuals.bg_stroke.color))
.corner_radius(visuals.corner_radius)
.fill(visuals.bg_fill)
.inner_margin(inner_margin)
.show(ui, add_contents);
} else if selected {
let visuals = ui.style().interact_selectable(&response, selected);
Frame::NONE
.stroke(Stroke::new(1.0_f32, visuals.bg_fill))
.corner_radius(visuals.corner_radius)
.fill(selected_fill.unwrap_or(visuals.bg_fill))
.inner_margin(inner_margin)
.show(ui, add_contents);
} else {
Frame::NONE
.stroke(Stroke::new(1.0_f32, Color32::TRANSPARENT))
.inner_margin(inner_margin)
.show(ui, add_contents);
}
}
response
})
.inner
.on_hover_cursor(CursorIcon::PointingHand)
}
}
-22
View File
@@ -1,22 +0,0 @@
use eframe::egui::Align;
use eframe::egui::Layout;
use eframe::egui::Response;
use eframe::egui::Ui;
use eframe::egui::Vec2;
use eframe::egui::Widget;
pub struct CustomUi<'ui>(pub &'ui mut Ui);
impl CustomUi<'_> {
pub fn add_sized_left_to_right(
&mut self,
max_size: impl Into<Vec2>,
widget: impl Widget,
) -> Response {
let layout =
Layout::from_main_dir_and_cross_align(self.0.layout().main_dir(), Align::Center);
self.0
.allocate_ui_with_layout(max_size.into(), layout, |ui| ui.add(widget))
.inner
}
}