working top bar

This commit is contained in:
Daniel Bulant 2025-01-07 23:14:14 +01:00
parent a337d3f470
commit 63e00e8271
No known key found for this signature in database
3 changed files with 35 additions and 14 deletions

View file

@ -1,19 +1,36 @@
use cushy::{kludgine::app::winit::window::WindowLevel, widget::MakeWidget, Application, Open};
use cushy::{
figures::{units::Px, Point},
kludgine::app::winit::{platform::wayland::Anchor, window::WindowLevel},
value::{Destination, Dynamic, Source},
widget::MakeWidget,
Application, Open,
};
mod spotify;
pub fn start_bar(app: &mut impl Application) -> cushy::Result {
let pos = Dynamic::default();
let mut window = spotify::spotify_controls()
.pad()
.centered()
.expand_horizontally()
.into_window()
.transparent()
.app_name("rshell")
.decorated(false)
// .resizable(false)
.outer_position(pos.clone(), false)
.window_level(WindowLevel::AlwaysOnTop);
window.sans_serif_font_family.push(cushy::styles::FamilyOwned::Name("Iosevka NF".into()));
window
.open(app).map(|_| ())
}
.sans_serif_font_family
.push(cushy::styles::FamilyOwned::Name("Iosevka NF".into()));
window.open(app).map(|handle| {
handle.execute(|ctx| {
// safe unwrap: we just created the window
let winit = ctx.winit().unwrap();
winit.set_exclusive_zone(40);
winit.set_anchor(Anchor::LEFT | Anchor::TOP | Anchor::RIGHT);
});
})
}

View file

@ -5,14 +5,14 @@ use std::{
};
use crate::{
theme::{BG_DEFAULT, TEXT_SPOTIFY},
theme::{BG_DEFAULT, CORNER_RADIUS, TEXT_SPOTIFY},
vibrancy::Vibrancy,
};
use cushy::{
figures::{units::Lp, Size, Zero},
kludgine::{AnyTexture, LazyTexture},
styles::{
components::{FontWeight, TextColor, WidgetBackground},
components::{FontWeight, LineHeight, TextColor, TextSize, WidgetBackground},
Color, CornerRadii, Dimension, DimensionRange, Weight,
},
value::{Destination, Dynamic, Source},
@ -45,9 +45,8 @@ pub fn spotify_controls() -> impl MakeWidget {
let (progress, track) = get_track_dynamics();
let (texture, vibrancy) = get_texture_dynamic(track.clone());
const IMAGE_SIDE: i32 = 16 /* lineheight */ + 2 * 6 /* padding */;
const IMAGE_SIDE: i32 = 10 /* lineheight */ + 2 * 6 /* padding */;
let image_size = Size::squared(DimensionRange::from(Dimension::Lp(Lp::points(IMAGE_SIDE))));
const CORNER_RADIUS: Dimension = Dimension::Lp(Lp::points(6));
Image::new(texture)
.aspect_fit()
@ -73,7 +72,9 @@ pub fn spotify_controls() -> impl MakeWidget {
})
.into_label()
.with(&TextColor, TEXT_SPOTIFY)
.with(&FontWeight, Weight::BOLD)
// .with(&FontWeight, Weight::BOLD)
.with(&TextSize, Dimension::Lp(Lp::points(10)))
.with(&LineHeight, Dimension::Lp(Lp::points(10)))
.centered()
.pad(),
)

View file

@ -1,5 +1,8 @@
use cushy::styles::Color;
use cushy::{
figures::units::Lp,
styles::{Color, Dimension},
};
pub const TEXT_SPOTIFY: Color = Color(0x1DB954FF);
pub const BG_DEFAULT: Color = Color(0x191724FF);
pub const BG_DEFAULT: Color = Color(0x191724FF);
pub const CORNER_RADIUS: Dimension = Dimension::Lp(Lp::points(6));