mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 10:58: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
@@ -1,7 +1,7 @@
|
||||
use crate::shims::Error;
|
||||
use crate::wrappers::{translate_key, translate_tool, Color};
|
||||
use crate::EDITOR_STATE;
|
||||
use editor_core::events;
|
||||
use editor_core::{events, LayerId};
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
fn convert_error(err: editor_core::EditorError) -> JsValue {
|
||||
@@ -32,7 +32,14 @@ mod mouse_state {
|
||||
(false, 1) => Event::LmbUp(state),
|
||||
(false, 2) => Event::RmbUp(state),
|
||||
(false, 4) => Event::MmbUp(state),
|
||||
_ => panic!("two buttons where modified at the same time. modification: {:#010b}", diff),
|
||||
(down, _) => {
|
||||
log::warn!("two buttons where modified at the same time. Modification: {:#010b}", diff);
|
||||
if down {
|
||||
Event::AmbiguousMouseDown(state)
|
||||
} else {
|
||||
Event::AmbiguousMouseUp(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,3 +125,45 @@ pub fn swap_colors() -> Result<(), JsValue> {
|
||||
pub fn reset_colors() -> Result<(), JsValue> {
|
||||
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_event(events::Event::ResetColors)).map_err(convert_error)
|
||||
}
|
||||
|
||||
/// Select a layer from the layer list
|
||||
#[wasm_bindgen]
|
||||
pub fn select_layer(path: Vec<LayerId>) -> Result<(), JsValue> {
|
||||
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_event(events::Event::SelectLayer(path))).map_err(convert_error)
|
||||
}
|
||||
|
||||
/// Toggle visibility of a layer from the layer list
|
||||
#[wasm_bindgen]
|
||||
pub fn toggle_layer_visibility(path: Vec<LayerId>) -> Result<(), JsValue> {
|
||||
EDITOR_STATE
|
||||
.with(|editor| editor.borrow_mut().handle_event(events::Event::ToggleLayerVisibility(path)))
|
||||
.map_err(convert_error)
|
||||
}
|
||||
|
||||
/// Toggle expansions state of a layer from the layer list
|
||||
#[wasm_bindgen]
|
||||
pub fn toggle_layer_expansion(path: Vec<LayerId>) -> Result<(), JsValue> {
|
||||
EDITOR_STATE
|
||||
.with(|editor| editor.borrow_mut().handle_event(events::Event::ToggleLayerExpansion(path)))
|
||||
.map_err(convert_error)
|
||||
}
|
||||
|
||||
/// Renames a layer from the layer list
|
||||
#[wasm_bindgen]
|
||||
pub fn rename_layer(path: Vec<LayerId>, new_name: String) -> Result<(), JsValue> {
|
||||
EDITOR_STATE
|
||||
.with(|editor| editor.borrow_mut().handle_event(events::Event::RenameLayer(path, new_name)))
|
||||
.map_err(convert_error)
|
||||
}
|
||||
|
||||
/// Deletes a layer from the layer list
|
||||
#[wasm_bindgen]
|
||||
pub fn delete_layer(path: Vec<LayerId>) -> Result<(), JsValue> {
|
||||
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_event(events::Event::DeleteLayer(path))).map_err(convert_error)
|
||||
}
|
||||
|
||||
/// Requests the backend to add a layer to the layer list
|
||||
#[wasm_bindgen]
|
||||
pub fn add_layer(path: Vec<LayerId>) -> Result<(), JsValue> {
|
||||
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_event(events::Event::AddLayer(path))).map_err(convert_error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user