mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 07:18:04 +08:00
Plumb layer panel (#107)
* WIP ExpandFolder handling * Implement response parsing in typescript * Update layer panel with list sent by wasm * Add events for layer interaction * Add proper default naming * Fix displaying of the eye icon * Attach path to LayerPanelEntry * Fix lint issues Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
parent
76d3e8cde4
commit
6adb984f2d
9
core/editor/src/dispatcher/document_event_handler.rs
Normal file
9
core/editor/src/dispatcher/document_event_handler.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use super::{Event, EventHandler, Operation, Response};
|
||||
use crate::tools::{DocumentToolData, ToolData};
|
||||
use crate::Document;
|
||||
|
||||
pub struct DocumentEventHandler {}
|
||||
|
||||
impl DocumentEventHandler {
|
||||
fn pre_process_event(&mut self, editor_state: &Document, tool_data: &mut DocumentToolData, events: &mut Vec<Event>, responses: &mut Vec<Response>, operations: &mut Vec<Operation>) {}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ use crate::tools::ToolType;
|
||||
use crate::Color;
|
||||
use bitflags::bitflags;
|
||||
|
||||
use document_core::LayerId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[doc(inline)]
|
||||
@@ -18,8 +19,16 @@ pub enum Event {
|
||||
SelectTool(ToolType),
|
||||
SelectPrimaryColor(Color),
|
||||
SelectSecondaryColor(Color),
|
||||
SelectLayer(Vec<LayerId>),
|
||||
ToggleLayerVisibility(Vec<LayerId>),
|
||||
ToggleLayerExpansion(Vec<LayerId>),
|
||||
DeleteLayer(Vec<LayerId>),
|
||||
AddLayer(Vec<LayerId>),
|
||||
RenameLayer(Vec<LayerId>, String),
|
||||
SwapColors,
|
||||
ResetColors,
|
||||
AmbiguousMouseDown(MouseState),
|
||||
AmbiguousMouseUp(MouseState),
|
||||
LmbDown(MouseState),
|
||||
RmbDown(MouseState),
|
||||
MmbDown(MouseState),
|
||||
@@ -34,6 +43,7 @@ pub enum Event {
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[repr(C)]
|
||||
pub enum ToolResponse {
|
||||
// These may not have the same names as any of the DocumentResponses
|
||||
SetActiveTool { tool_name: String },
|
||||
UpdateCanvas { document: String },
|
||||
}
|
||||
|
||||
15
core/editor/src/dispatcher/global_event_handler.rs
Normal file
15
core/editor/src/dispatcher/global_event_handler.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use super::{input_manager::InputManager, Event, EventHandler, Operation, Response};
|
||||
use crate::tools::{DocumentToolData, ToolData, ToolSettings};
|
||||
use document_core::document::Document;
|
||||
|
||||
pub struct GlobalEventHandler {}
|
||||
|
||||
impl GlobalEventHandler {
|
||||
fn new(tool_data: ToolData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
||||
fn pre_process_event(&mut self, input: &InputManager, events: &mut Vec<Event>, responses: &mut Vec<Response>, operations: &mut Vec<Operation>) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ impl Dispatcher {
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
_ => todo!("Implement layer handling"),
|
||||
}
|
||||
|
||||
let (mut tool_responses, operations) = editor_state
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
pub type PanelId = usize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub type PanelId = u32;
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Workspace {
|
||||
pub hovered_panel: PanelId,
|
||||
pub root: PanelGroup,
|
||||
@@ -15,14 +18,20 @@ impl Workspace {
|
||||
// add panel / panel group
|
||||
// delete panel / panel group
|
||||
// move panel / panel group
|
||||
// get_serialized_layout()
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PanelGroup {
|
||||
pub contents: Vec<Contents>,
|
||||
pub layout_direction: LayoutDirection,
|
||||
}
|
||||
|
||||
impl Default for PanelGroup {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl PanelGroup {
|
||||
fn new() -> PanelGroup {
|
||||
PanelGroup {
|
||||
@@ -32,16 +41,19 @@ impl PanelGroup {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum Contents {
|
||||
PanelArea(PanelArea),
|
||||
Group(PanelGroup),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PanelArea {
|
||||
pub panels: Vec<PanelId>,
|
||||
pub active: PanelId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum LayoutDirection {
|
||||
Horizontal,
|
||||
Vertical,
|
||||
|
||||
Reference in New Issue
Block a user