Add responses in document for layer system (#91)

This commit is contained in:
TrueDoctor
2021-05-07 02:47:38 -07:00
committed by Keavon Chambers
parent 76a998dea4
commit 3ab5f6b7ef
22 changed files with 219 additions and 64 deletions
+47
View File
@@ -0,0 +1,47 @@
use crate::LayerId;
use std::fmt;
#[derive(Debug, Clone)]
pub struct LayerPanelEntry {
pub name: String,
pub visible: bool,
pub layer_type: LayerType,
}
#[derive(Debug, Clone)]
pub enum LayerType {
Folder,
Shape,
}
impl fmt::Display for LayerType {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let name = match self {
LayerType::Folder => "folder",
LayerType::Shape => "shape",
};
formatter.write_str(name)
}
}
#[derive(Debug, Clone)]
#[repr(C)]
// TODO - Make Copy when possible
pub enum DocumentResponse {
UpdateCanvas { document: String },
CollapseFolder { path: Vec<LayerId> },
ExpandFolder { path: Vec<LayerId>, children: Vec<LayerPanelEntry> },
}
impl fmt::Display for DocumentResponse {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let name = match self {
DocumentResponse::UpdateCanvas { .. } => "UpdateCanvas",
DocumentResponse::CollapseFolder { .. } => "CollapseFolder",
DocumentResponse::ExpandFolder { .. } => "ExpandFolder",
};
formatter.write_str(name)
}
}