Use cosmic::widgets
This commit is contained in:
parent
0c19ea7167
commit
94561b9ed1
1 changed files with 15 additions and 9 deletions
|
|
@ -1,5 +1,11 @@
|
|||
use cctk::wayland_client::protocol::wl_output;
|
||||
use cosmic::iced::{self, widget};
|
||||
use cosmic::{
|
||||
iced::{
|
||||
self,
|
||||
widget::{column, row},
|
||||
},
|
||||
widget,
|
||||
};
|
||||
|
||||
use crate::{wayland::CaptureImage, App, DragSurface, LayerSurface, Msg, Toplevel, Workspace};
|
||||
|
||||
|
|
@ -7,7 +13,7 @@ pub(crate) fn layer_surface<'a>(
|
|||
app: &'a App,
|
||||
surface: &'a LayerSurface,
|
||||
) -> cosmic::Element<'a, Msg> {
|
||||
widget::row![
|
||||
row![
|
||||
workspaces_sidebar(
|
||||
app.workspaces
|
||||
.iter()
|
||||
|
|
@ -32,7 +38,7 @@ pub(crate) fn layer_surface<'a>(
|
|||
}
|
||||
|
||||
fn close_button(on_press: Msg) -> cosmic::Element<'static, Msg> {
|
||||
cosmic::widget::button(cosmic::widget::icon::from_name("window-close-symbolic").size(16))
|
||||
widget::button(widget::icon::from_name("window-close-symbolic").size(16))
|
||||
.style(cosmic::theme::Button::Destructive)
|
||||
.on_press(on_press)
|
||||
.into()
|
||||
|
|
@ -48,9 +54,9 @@ pub(crate) fn workspace_item<'a>(
|
|||
} else {
|
||||
cosmic::theme::Button::Standard
|
||||
};
|
||||
widget::column![
|
||||
column![
|
||||
close_button(Msg::CloseWorkspace(workspace.handle.clone())),
|
||||
cosmic::widget::button(widget::column![
|
||||
widget::button(column![
|
||||
capture_image(workspace.img_for_output.get(output)),
|
||||
widget::text(&workspace.name)
|
||||
])
|
||||
|
|
@ -65,7 +71,7 @@ fn workspace_sidebar_entry<'a>(
|
|||
workspace: &'a Workspace,
|
||||
output: &'a wl_output::WlOutput,
|
||||
) -> cosmic::Element<'a, Msg> {
|
||||
widget::dnd_source(workspace_item(workspace, output))
|
||||
iced::widget::dnd_source(workspace_item(workspace, output))
|
||||
.on_drag(|size| {
|
||||
Msg::StartDrag(
|
||||
size,
|
||||
|
|
@ -85,7 +91,7 @@ fn workspaces_sidebar<'a>(
|
|||
output: &'a wl_output::WlOutput,
|
||||
) -> cosmic::Element<'a, Msg> {
|
||||
widget::container(
|
||||
widget::dnd_listener(widget::column(
|
||||
iced::widget::dnd_listener(column(
|
||||
workspaces
|
||||
.map(|w| workspace_sidebar_entry(w, output))
|
||||
.collect(),
|
||||
|
|
@ -103,7 +109,7 @@ fn workspaces_sidebar<'a>(
|
|||
}
|
||||
|
||||
fn toplevel_preview(toplevel: &Toplevel) -> cosmic::Element<Msg> {
|
||||
widget::column![
|
||||
column![
|
||||
close_button(Msg::CloseToplevel(toplevel.handle.clone())),
|
||||
widget::button(capture_image(toplevel.img.as_ref()))
|
||||
.on_press(Msg::ActivateToplevel(toplevel.handle.clone())),
|
||||
|
|
@ -117,7 +123,7 @@ fn toplevel_preview(toplevel: &Toplevel) -> cosmic::Element<Msg> {
|
|||
fn toplevel_previews<'a>(
|
||||
toplevels: impl Iterator<Item = &'a Toplevel>,
|
||||
) -> cosmic::Element<'a, Msg> {
|
||||
widget::row(toplevels.map(toplevel_preview).collect())
|
||||
row(toplevels.map(toplevel_preview).collect())
|
||||
.width(iced::Length::FillPortion(4))
|
||||
.height(iced::Length::Fill)
|
||||
.spacing(16)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue