From 96cca005b7a4367d3b35a1644583f91f181cfbd2 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 25 Apr 2024 14:17:43 -0700 Subject: [PATCH] Rename inaccurately named widget --- src/view/mod.rs | 2 +- src/widgets/mod.rs | 4 ++-- .../{workspace_item.rs => toplevel_item.rs} | 15 +++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) rename src/widgets/{workspace_item.rs => toplevel_item.rs} (93%) diff --git a/src/view/mod.rs b/src/view/mod.rs index e2b5ee5..3a4b322 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -250,7 +250,7 @@ pub(crate) fn toplevel_preview(toplevel: &Toplevel) -> cosmic::Element { row![label] } .padding(4); - crate::widgets::workspace_item( + crate::widgets::toplevel_item( vec![ close_button(Msg::CloseToplevel(toplevel.handle.clone())), widget::button(capture_image(toplevel.img.as_ref())) diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs index b5ad66a..e90b70b 100644 --- a/src/widgets/mod.rs +++ b/src/widgets/mod.rs @@ -13,8 +13,8 @@ mod image_bg; pub use image_bg::image_bg; mod workspace_bar; pub use workspace_bar::workspace_bar; -mod workspace_item; -pub use workspace_item::workspace_item; +mod toplevel_item; +pub use toplevel_item::toplevel_item; mod mouse_interaction_wrapper; pub use mouse_interaction_wrapper::mouse_interaction_wrapper; mod toplevels; diff --git a/src/widgets/workspace_item.rs b/src/widgets/toplevel_item.rs similarity index 93% rename from src/widgets/workspace_item.rs rename to src/widgets/toplevel_item.rs index 41f60cd..d7445cd 100644 --- a/src/widgets/workspace_item.rs +++ b/src/widgets/toplevel_item.rs @@ -1,4 +1,3 @@ -// TODO rename // combine widgets // Hack: this widget defines it's width as the second child's width // So the width of the image will be the overall width. @@ -45,26 +44,26 @@ impl AxisExt for Axis { } } -pub fn workspace_item(children: Vec>, axis: Axis) -> WorkspaceItem { - WorkspaceItem { +pub fn toplevel_item(children: Vec>, axis: Axis) -> ToplevelItem { + ToplevelItem { axis, children, _msg: PhantomData, } } -pub struct WorkspaceItem<'a, Msg> { +pub struct ToplevelItem<'a, Msg> { axis: Axis, children: Vec>, _msg: PhantomData, } -impl<'a, Msg> Widget for WorkspaceItem<'a, Msg> { +impl<'a, Msg> Widget for ToplevelItem<'a, Msg> { fn size(&self) -> Size { Size { // width: Length::Fill // XXX doesn't work when used in standard `row` widget - // But fixes allocation of `dnd_source` wrapping this, within `Workspaces` row + // But fixes allocation of `dnd_source` wrapping this, within `Toplevels` row width: Length::Shrink, // TODO Make depend on orientation or drop that option height: Length::Shrink, @@ -220,8 +219,8 @@ impl<'a, Msg> Widget for WorkspaceItem<'a, } } -impl<'a, Msg: 'static> From> for cosmic::Element<'a, Msg> { - fn from(widget: WorkspaceItem<'a, Msg>) -> Self { +impl<'a, Msg: 'static> From> for cosmic::Element<'a, Msg> { + fn from(widget: ToplevelItem<'a, Msg>) -> Self { cosmic::Element::new(widget) } }