Skip to content

Commit

Permalink
fix(toplevel label): text contrast
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x committed Dec 23, 2024
1 parent e0c0f27 commit b9870f8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefix ?= /usr/local
prefix ?= /usr
bindir = $(prefix)/bin
libdir = $(prefix)/lib
includedir = $(prefix)/include
Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,6 @@ impl Application for App {
}

fn view_window(&self, id: iced::window::Id) -> cosmic::prelude::Element<Self::Message> {
use iced::widget::*;
if let Some(surface) = self.layer_surfaces.get(&id) {
return view::layer_surface(self, surface);
}
Expand All @@ -670,7 +669,7 @@ impl Application for App {
}
}
log::info!("NO VIEW");
text("workspaces").into()
widget::text("workspaces").into()
}

fn on_close_requested(&self, _id: SurfaceId) -> Option<Msg> {
Expand Down
41 changes: 31 additions & 10 deletions src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn workspace_item<'a>(
let is_active = workspace.is_active;
column![
// TODO editable name?
widget::button(column![image, widget::text(&workspace.name)])
widget::button(column![image, widget::text::body(&workspace.name)])
.selected(workspace.is_active)
.style(cosmic::theme::Button::Custom {
active: Box::new(move |_focused, theme| workspace_item_appearance(
Expand Down Expand Up @@ -231,7 +231,7 @@ fn workspaces_sidebar<'a>(
let new_workspace_button = widget::button(
widget::container(row![
widget::icon::from_name("list-add-symbolic").symbolic(true),
widget::text(fl!("new-workspace"))
widget::text::body(fl!("new-workspace"))
])
.width(iced::Length::Fill)
.align_x(iced::alignment::Horizontal::Center),
Expand Down Expand Up @@ -266,9 +266,14 @@ fn workspaces_sidebar<'a>(
icon_color: Some(theme.cosmic().on_bg_color().into()),
background: Some(iced::Color::from(theme.cosmic().background.base).into()),
border: Border {
radius: (12.0).into(),
width: 0.0,
color: iced::Color::TRANSPARENT,
color: theme.cosmic().bg_divider().into(),
width: 1.0,
radius: theme
.cosmic()
.radius_s()
// Increase radius by 1/2 of `sidebar_entries_container` padding
.map(|x| if x < 4.0 { x } else { x + 6.0 })
.into(),
},
shadow: Shadow::default(),
}
Expand All @@ -281,13 +286,14 @@ fn workspaces_sidebar<'a>(
}

fn toplevel_preview(toplevel: &Toplevel, is_being_dragged: bool) -> cosmic::Element<Msg> {
let label = widget::text(&toplevel.info.title);
let label = widget::text::body(&toplevel.info.title);
let label = if let Some(icon) = &toplevel.icon {
row![widget::icon(widget::icon::from_path(icon.clone())), label].spacing(4)
} else {
row![label]
}
.padding(4);
.align_items(iced::Alignment::Center)
.padding([4, 12]);
let alpha = if is_being_dragged { 0.5 } else { 1.0 };
crate::widgets::toplevel_item(
vec![
Expand All @@ -302,9 +308,24 @@ fn toplevel_preview(toplevel: &Toplevel, is_being_dragged: bool) -> cosmic::Elem
.style(cosmic::theme::Button::Image)
.on_press(Msg::ActivateToplevel(toplevel.handle.clone()))
.into(),
widget::button(label)
.on_press(Msg::ActivateToplevel(toplevel.handle.clone()))
.into(),
widget::container(
widget::button(label)
.on_press(Msg::ActivateToplevel(toplevel.handle.clone()))
.style(cosmic::theme::Button::Icon),
)
.style(cosmic::theme::Container::custom(|theme| {
let mut label_background = theme.cosmic().background.base;
label_background.alpha = 0.8;
cosmic::iced_style::container::Appearance {
background: Some(iced::Color::from(label_background).into()),
border: Border {
radius: theme.cosmic().radius_xl().into(),
..Default::default()
},
..Default::default()
}
}))
.into(),
],
Axis::Vertical,
)
Expand Down

0 comments on commit b9870f8

Please sign in to comment.