element/stack: Style fixes

This commit is contained in:
Victoria Brekenfeld 2024-07-26 14:59:11 +02:00
parent 04b5c18a03
commit 61f11d1363
5 changed files with 27 additions and 15 deletions

View file

@ -21,7 +21,7 @@ use cosmic::{
iced_core::{border::Radius, Background, Border, Color, Length},
iced_runtime::Command,
iced_widget::scrollable::AbsoluteOffset,
theme, widget as cosmic_widget, Apply, Element as CosmicElement,
theme, widget as cosmic_widget, Apply, Element as CosmicElement, Theme,
};
use cosmic_settings_config::shortcuts;
use once_cell::sync::Lazy;
@ -969,6 +969,7 @@ impl Program for CosmicStackInternal {
pixels: &mut tiny_skia::PixmapMut<'_>,
damage: &[Rectangle<i32, Buffer>],
scale: f32,
theme: &Theme,
) {
if self.group_focused.load(Ordering::SeqCst) {
let border = Rectangle::from_loc_and_size(
@ -977,7 +978,7 @@ impl Program for CosmicStackInternal {
);
let mut paint = tiny_skia::Paint::default();
let (b, g, r, a) = theme::COSMIC_DARK.accent_color().into_components();
let (b, g, r, a) = theme.cosmic().accent_color().into_components();
paint.set_color(tiny_skia::Color::from_rgba(r, g, b, a).unwrap());
for rect in damage {

View file

@ -34,8 +34,8 @@ pub(super) fn primary_container_color(theme: &cosmic::cosmic_theme::Theme) -> Co
/// The background color for the selected stack tab.
pub(super) fn selected_state_color(theme: &cosmic::cosmic_theme::Theme) -> Color {
const SELECTED_STATE_DARK: Color = Color::from_rgba(0.302, 0.302, 0.302, 0.3);
const SELECTED_STATE_LIGHT: Color = Color::from_rgba(0.596, 0.596, 0.596, 0.2);
const SELECTED_STATE_DARK: Color = Color::from_rgba(0.195, 0.195, 0.195, 1.0);
const SELECTED_STATE_LIGHT: Color = Color::from_rgba(0.8344, 0.8344, 0.8344, 1.0);
if theme.is_dark {
SELECTED_STATE_DARK
@ -231,7 +231,7 @@ impl<Message: TabMessage + 'static> Tab<Message> {
.padding([2, 4])
.center_y()
.into(),
tab_text(self.title)
tab_text(self.title, self.active)
.font(self.font)
.font_size(14.0)
.height(Length::Fill)

View file

@ -14,8 +14,8 @@ use cosmic::{
};
/// Text in a stack tab with an overflow gradient.
pub fn tab_text(text: String) -> TabText {
TabText::new(text)
pub fn tab_text(text: String, selected: bool) -> TabText {
TabText::new(text, selected)
}
struct LocalState {
@ -29,17 +29,19 @@ pub struct TabText {
text: String,
font: cosmic::font::Font,
font_size: f32,
selected: bool,
height: Length,
width: Length,
}
impl TabText {
pub fn new(text: String) -> Self {
pub fn new(text: String, selected: bool) -> Self {
TabText {
width: Length::Shrink,
height: Length::Shrink,
font: cosmic::font::DEFAULT,
font_size: 14.0,
selected,
text,
}
}
@ -146,7 +148,11 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
});
if state.overflowed {
let background = super::tab::primary_container_color(theme.cosmic());
let background = if self.selected {
super::tab::selected_state_color(theme.cosmic())
} else {
super::tab::primary_container_color(theme.cosmic())
};
let transparent = Color {
a: 0.0,
..background

View file

@ -14,7 +14,7 @@ use crate::{
},
};
use calloop::LoopHandle;
use cosmic::{config::Density, iced::Command, widget::mouse_area, Apply};
use cosmic::{config::Density, iced::Command, widget::mouse_area, Apply, Theme};
use smithay::{
backend::{
input::KeyState,
@ -496,6 +496,7 @@ impl Program for CosmicWindowInternal {
pixels: &mut tiny_skia::PixmapMut<'_>,
_damage: &[Rectangle<i32, BufferCoords>],
scale: f32,
_theme: &Theme,
) {
let mut mask = self.mask.lock().unwrap();
if self.window.is_maximized(false) {

View file

@ -119,8 +119,9 @@ pub trait Program {
pixels: &mut tiny_skia::PixmapMut<'_>,
damage: &[Rectangle<i32, BufferCoords>],
scale: f32,
theme: &cosmic::Theme,
) {
let _ = (pixels, damage, scale);
let _ = (pixels, damage, scale, theme);
}
}
@ -881,6 +882,7 @@ where
let state_ref = &internal_ref.state;
let mut clip_mask = tiny_skia::Mask::new(size.w as u32, size.h as u32).unwrap();
let overlay = internal_ref.debug.overlay();
let theme = &internal_ref.theme;
buffer
.render()
@ -930,10 +932,12 @@ where
})
.collect::<Vec<_>>();
state_ref
.program()
.0
.foreground(&mut pixels, &damage, scale.x as f32);
state_ref.program().0.foreground(
&mut pixels,
&damage,
scale.x as f32,
theme,
);
Result::<_, ()>::Ok(damage)
})