mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-09-14 05:41:59 +02:00
refactor(layouts): extract independent komorebi-layouts crate
This commit moves layout-related code into a new workspace crate komorebi-layouts, with the intention of re-using it all in komorebi for Mac instead of maintaining two separate implementations.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::Arrangement;
|
||||
use super::CustomLayout;
|
||||
use super::DefaultLayout;
|
||||
use super::Direction;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub enum Layout {
|
||||
Default(DefaultLayout),
|
||||
Custom(CustomLayout),
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
#[must_use]
|
||||
pub fn as_boxed_direction(&self) -> Box<dyn Direction> {
|
||||
match self {
|
||||
Layout::Default(layout) => Box::new(*layout),
|
||||
Layout::Custom(layout) => Box::new(layout.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn as_boxed_arrangement(&self) -> Box<dyn Arrangement> {
|
||||
match self {
|
||||
Layout::Default(layout) => Box::new(*layout),
|
||||
Layout::Custom(layout) => Box::new(layout.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user