feat(bar): use phosphor icons for uniformity

This commit is contained in:
LGUG2Z
2024-09-08 12:38:51 -07:00
parent 9f78739c3f
commit a4ef85859e
10 changed files with 53 additions and 29 deletions

10
Cargo.lock generated
View File

@@ -1406,6 +1406,15 @@ dependencies = [
"serde",
]
[[package]]
name = "egui-phosphor"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7198d3a35fbe756a3daa10a98942159f70dce10d5f2f9ccdb11d242d3bf2fa47"
dependencies = [
"egui",
]
[[package]]
name = "egui-wgpu"
version = "0.28.1"
@@ -2657,6 +2666,7 @@ dependencies = [
"chrono",
"crossbeam-channel",
"eframe",
"egui-phosphor",
"font-loader",
"image",
"komorebi-client",

View File

@@ -20,4 +20,5 @@ serde_json = "1"
starship-battery = "0.10"
sysinfo = "0.31"
windows = { workspace = true }
windows-icons = "0.1"
windows-icons = "0.1"
egui-phosphor = "0.6.0"

View File

@@ -91,8 +91,8 @@ impl BarWidget for Battery {
if !output.is_empty() {
for battery in output {
let emoji = match self.state {
BatteryState::Charging => "⚡️",
BatteryState::Discharging => "🔋",
BatteryState::Charging => egui_phosphor::regular::BATTERY_CHARGING,
BatteryState::Discharging => egui_phosphor::regular::BATTERY_FULL,
};
ui.add(

View File

@@ -67,9 +67,13 @@ impl BarWidget for Date {
for output in self.output() {
if ui
.add(
Label::new(format!("📅 {}", output))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {}",
egui_phosphor::regular::CALENDAR_DOTS,
output
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{

View File

@@ -139,7 +139,7 @@ fn main() -> eframe::Result<()> {
enable: true,
hide_empty_workspaces: true,
},
layout: KomorebiLayoutConfig { enable: false },
layout: KomorebiLayoutConfig { enable: true },
focused_window: KomorebiFocusedWindowConfig {
enable: true,
show_icon: true,
@@ -325,8 +325,9 @@ impl KomorebiNotificationState {
}
}
fn add_custom_font(ctx: &egui::Context, name: &str) {
fn add_custom_font(ctx: &Context, name: &str) {
let mut fonts = egui::FontDefinitions::default();
egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular);
let property = FontPropertyBuilder::new().family(name).build();
@@ -430,14 +431,10 @@ impl eframe::App for Komobar {
.handle_notification(self.rx_gui.clone());
egui::CentralPanel::default()
.frame(
egui::Frame::none()
// TODO: make this configurable
.outer_margin(egui::Margin::symmetric(
self.config.outer_margin.x,
self.config.outer_margin.y,
)),
)
.frame(egui::Frame::none().outer_margin(egui::Margin::symmetric(
self.config.outer_margin.x,
self.config.outer_margin.y,
)))
.show(ctx, |ui| {
ui.horizontal_centered(|ui| {
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
@@ -446,7 +443,6 @@ impl eframe::App for Komobar {
}
});
// TODO: make the order configurable
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
for w in &mut self.right_widgets {
w.render(ctx, ui);

View File

@@ -70,7 +70,7 @@ impl BarWidget for Media {
for output in self.output() {
if ui
.add(
Label::new(format!("🎧 {output}"))
Label::new(format!("{} {output}", egui_phosphor::regular::HEADPHONES))
.selectable(false)
.sense(Sense::click()),
)

View File

@@ -55,7 +55,7 @@ impl BarWidget for Memory {
for output in self.output() {
if ui
.add(
Label::new(format!("🐏 {}", output))
Label::new(format!("{} {}", egui_phosphor::regular::MEMORY, output))
.selectable(false)
.sense(Sense::click()),
)

View File

@@ -101,9 +101,13 @@ impl BarWidget for Network {
1 => {
if ui
.add(
Label::new(format!("📶 {}", output[0]))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {}",
egui_phosphor::regular::WIFI_HIGH,
output[0]
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{
@@ -116,9 +120,14 @@ impl BarWidget for Network {
2 => {
if ui
.add(
Label::new(format!("📶 {} - {}", output[0], output[1]))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {} - {}",
egui_phosphor::regular::WIFI_HIGH,
output[0],
output[1]
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{

View File

@@ -65,9 +65,13 @@ impl BarWidget for Storage {
for output in self.output() {
if ui
.add(
Label::new(format!("🖴 {}", output))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {}",
egui_phosphor::regular::HARD_DRIVES,
output
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{

View File

@@ -61,7 +61,7 @@ impl BarWidget for Time {
for output in self.output() {
if ui
.add(
Label::new(format!("🕐 {}", output))
Label::new(format!("{} {}", egui_phosphor::regular::CLOCK, output))
.selectable(false)
.sense(Sense::click()),
)