/
githubmirror
/
lapce
Обзор
Документация
Войти
/
githubmirror
/
lapce
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lapce-app/src/panel/position.rs
74 строки
2 KB
Dongdong Zhou
panel resize (#2593)
05 сен 2023, 22:58
Не верифицирован
05 сен 2023, 22:58
10c83e4
Код
Авторство
О чём код?
use serde::{Deserialize, Serialize}; #[derive(Eq, PartialEq, Hash, Clone, Copy, Debug, Serialize, Deserialize)] pub enum PanelPosition { LeftTop, LeftBottom, BottomLeft, BottomRight, RightTop, RightBottom, } impl PanelPosition { pub fn is_bottom(&self) -> bool { matches!(self, PanelPosition::BottomLeft | PanelPosition::BottomRight) } pub fn is_right(&self) -> bool { matches!(self, PanelPosition::RightTop | PanelPosition::RightBottom) } pub fn is_left(&self) -> bool { matches!(self, PanelPosition::LeftTop | PanelPosition::LeftBottom) } pub fn is_first(&self) -> bool { matches!( self, PanelPosition::LeftTop | PanelPosition::BottomLeft | PanelPosition::RightTop ) } pub fn peer(&self) -> PanelPosition { match &self { PanelPosition::LeftTop => PanelPosition::LeftBottom, PanelPosition::LeftBottom => PanelPosition::LeftTop, PanelPosition::BottomLeft => PanelPosition::BottomRight, PanelPosition::BottomRight => PanelPosition::BottomLeft, PanelPosition::RightTop => PanelPosition::RightBottom, PanelPosition::RightBottom => PanelPosition::RightTop, } } } #[derive(Eq, PartialEq, Hash, Clone, Copy, Debug)] pub enum PanelContainerPosition { Left, Bottom, Right, } impl PanelContainerPosition { pub fn is_bottom(&self) -> bool { matches!(self, PanelContainerPosition::Bottom) } pub fn first(&self) -> PanelPosition { match self { PanelContainerPosition::Left => PanelPosition::LeftTop, PanelContainerPosition::Bottom => PanelPosition::BottomLeft, PanelContainerPosition::Right => PanelPosition::RightTop, } } pub fn second(&self) -> PanelPosition { match self { PanelContainerPosition::Left => PanelPosition::LeftBottom, PanelContainerPosition::Bottom => PanelPosition::BottomRight, PanelContainerPosition::Right => PanelPosition::RightBottom, } } }