Skip to content

Commit

Permalink
fix(interface): align closer to designs
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x committed Dec 23, 2024
1 parent e0c0f27 commit 27ecfb4
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 67 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
1 change: 1 addition & 0 deletions i18n/en/cosmic_workspaces.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
workspace = Workspace
new-workspace = New Workspace
1 change: 1 addition & 0 deletions i18n/sr-Cyrl/cosmic_workspaces.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
workspace = Радни простор
new-workspace = Нови радни простор
1 change: 1 addition & 0 deletions i18n/sr-Latn/cosmic_workspaces.ftl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
workspace = Radni prostor
new-workspace = Novi radni prostor
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
132 changes: 69 additions & 63 deletions src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn workspace_item_appearance(
let mut appearance = cosmic::widget::button::Appearance::new();
appearance.border_radius = cosmic.corner_radii.radius_s.into();
if is_active {
appearance.border_width = 2.0;
appearance.border_width = 4.0;
appearance.border_color = cosmic.accent.base.into();
}
if hovered {
Expand All @@ -144,28 +144,28 @@ fn workspace_item<'a>(
) -> cosmic::Element<'a, Msg> {
let image = capture_image(workspace.img_for_output.get(output), 1.0);
let is_active = workspace.is_active;
column![
// TODO editable name?
widget::button(column![image, widget::text(&workspace.name)])
.selected(workspace.is_active)
.style(cosmic::theme::Button::Custom {
active: Box::new(move |_focused, theme| workspace_item_appearance(
theme,
is_active,
is_drop_target
)),
disabled: Box::new(|_theme| { unreachable!() }),
hovered: Box::new(move |_focused, theme| workspace_item_appearance(
theme, is_active, true
)),
pressed: Box::new(move |_focused, theme| workspace_item_appearance(
theme, is_active, true
)),
})
.on_press(Msg::ActivateWorkspace(workspace.handle.clone())),
]
.spacing(4)
//.height(iced::Length::Fill)
// TODO editable name?
widget::button(
column![
image,
widget::text::body(format!("{} {}", fl!("workspace"), &workspace.name))
.width(iced::Length::Fill)
.horizontal_alignment(iced::alignment::Horizontal::Center)
]
.spacing(4),
)
.selected(workspace.is_active)
.style(cosmic::theme::Button::Custom {
active: Box::new(move |_focused, theme| {
workspace_item_appearance(theme, is_active, is_drop_target)
}),
disabled: Box::new(|_theme| unreachable!()),
hovered: Box::new(move |_focused, theme| workspace_item_appearance(theme, is_active, true)),
pressed: Box::new(move |_focused, theme| workspace_item_appearance(theme, is_active, true)),
})
.on_press(Msg::ActivateWorkspace(workspace.handle.clone()))
.padding(8)
.width(iced::Length::Fixed(240.0))
.into()
}

Expand Down Expand Up @@ -226,34 +226,10 @@ fn workspaces_sidebar<'a>(
WorkspaceLayout::Horizontal => Axis::Horizontal,
};
let sidebar_entries_container =
widget::container(crate::widgets::workspace_bar(sidebar_entries, axis)).padding(12.0);
/*
let new_workspace_button = widget::button(
widget::container(row![
widget::icon::from_name("list-add-symbolic").symbolic(true),
widget::text(fl!("new-workspace"))
])
.width(iced::Length::Fill)
.align_x(iced::alignment::Horizontal::Center),
)
.on_press(Msg::NewWorkspace)
.width(iced::Length::Fill);
let bar: cosmic::Element<_> = if amount != WorkspaceAmount::Dynamic {
match layout {
WorkspaceLayout::Vertical => {
column![sidebar_entries_container, new_workspace_button,].into()
}
WorkspaceLayout::Horizontal => {
row![sidebar_entries_container, new_workspace_button,].into()
}
}
} else {
sidebar_entries_container.into()
};
*/
// Shrink?
widget::container(crate::widgets::workspace_bar(sidebar_entries, axis)).padding(8.0);

let (width, height) = match layout {
WorkspaceLayout::Vertical => (iced::Length::Fill, iced::Length::Shrink),
WorkspaceLayout::Vertical => (iced::Length::Fixed(256.0), iced::Length::Shrink),
WorkspaceLayout::Horizontal => (iced::Length::Shrink, iced::Length::Fill),
};
widget::container(
Expand All @@ -266,32 +242,65 @@ 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,
radius: theme.cosmic().radius_m().into(),
..Default::default()
},
shadow: Shadow::default(),
}
})),
)
.width(width)
.height(height)
.padding(24.0)
.padding(8)
.into()
}

fn toplevel_preview(toplevel: &Toplevel, is_being_dragged: bool) -> cosmic::Element<Msg> {
let label = widget::text(&toplevel.info.title);
let cosmic::cosmic_theme::Spacing {
space_xxs, space_s, ..
} = cosmic::theme::active().cosmic().spacing;

let label = widget::text::body(if toplevel.info.title.len() > 40 {
format!("{:.38}...", &toplevel.info.title)
} else {
toplevel.info.title.clone()
});
let label = if let Some(icon) = &toplevel.icon {
row![widget::icon(widget::icon::from_path(icon.clone())), label].spacing(4)
row![
widget::icon(widget::icon::from_path(icon.clone())).size(24),
label
]
.spacing(4)
} else {
row![label]
}
.padding(4);
.align_items(iced::Alignment::Center)
.padding([space_xxs, space_s]);
let alpha = if is_being_dragged { 0.5 } else { 1.0 };
crate::widgets::toplevel_item(
vec![
close_button(Msg::CloseToplevel(toplevel.handle.clone())),
row![
widget::container(
widget::button(label)
.on_press(Msg::ActivateToplevel(toplevel.handle.clone()))
.style(cosmic::theme::Button::Icon)
.padding(0),
)
.style(cosmic::theme::Container::custom(|theme| {
cosmic::iced_style::container::Appearance {
background: Some(
iced::Color::from(theme.cosmic().background.component.base).into(),
),
border: Border {
color: theme.cosmic().bg_divider().into(),
width: 1.0,
radius: theme.cosmic().radius_xl().into(),
},
..Default::default()
}
})),
close_button(Msg::CloseToplevel(toplevel.handle.clone()))
]
.align_items(iced::Alignment::Center)
.into(),
widget::button(capture_image(toplevel.img.as_ref(), alpha))
.selected(
toplevel
Expand All @@ -302,9 +311,6 @@ 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(),
],
Axis::Vertical,
)
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/workspace_bar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Custom varian of row/column
// Gives each child widget a maximim size on main axis of total/n
// Gives each child widget a maximum size on main axis of total/n

use cosmic::iced::{
advanced::{
Expand Down

0 comments on commit 27ecfb4

Please sign in to comment.