mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 03:18:06 +08:00
Hook up layer tree structure with frontend (#372)
* Hook up layer tree structure with frontend (decoding and Vue are WIP) * Fix off by one error * Avoid leaking memory * Parse layer structure into list of layers * Fix thumbnail updates * Correctly popagate deletions * Fix selection state in layer tree * Respect expansion during root serialization * Allow expanding of subfolders * Fix arrow direction Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
@@ -22,8 +22,8 @@ impl<'a> MessageHandler<ToolMessage, ToolActionHandlerData<'a>> for Eyedropper {
|
||||
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
|
||||
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
|
||||
|
||||
if let Some(path) = data.0.document.intersects_quad_root(quad).last() {
|
||||
if let Ok(layer) = data.0.document.layer(path) {
|
||||
if let Some(path) = data.0.graphene_document.intersects_quad_root(quad).last() {
|
||||
if let Ok(layer) = data.0.graphene_document.layer(path) {
|
||||
if let LayerDataType::Shape(s) = &layer.data {
|
||||
s.style.fill().and_then(|fill| {
|
||||
fill.color().map(|color| match action {
|
||||
|
||||
@@ -20,7 +20,7 @@ impl<'a> MessageHandler<ToolMessage, ToolActionHandlerData<'a>> for Fill {
|
||||
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
|
||||
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
|
||||
|
||||
if let Some(path) = data.0.document.intersects_quad_root(quad).last() {
|
||||
if let Some(path) = data.0.graphene_document.intersects_quad_root(quad).last() {
|
||||
responses.push_back(
|
||||
Operation::SetLayerFill {
|
||||
path: path.to_vec(),
|
||||
|
||||
@@ -66,7 +66,7 @@ impl Fsm for PenToolFsmState {
|
||||
input: &InputPreprocessor,
|
||||
responses: &mut VecDeque<Message>,
|
||||
) -> Self {
|
||||
let transform = document.document.root.transform;
|
||||
let transform = document.graphene_document.root.transform;
|
||||
let pos = transform.inverse() * DAffine2::from_translation(input.mouse.position);
|
||||
|
||||
use PenMessage::*;
|
||||
|
||||
@@ -151,7 +151,7 @@ impl Fsm for SelectToolFsmState {
|
||||
let mut buffer = Vec::new();
|
||||
let mut selected: Vec<_> = document.selected_layers().map(|path| path.to_vec()).collect();
|
||||
let quad = data.selection_quad();
|
||||
let intersection = document.document.intersects_quad_root(quad);
|
||||
let intersection = document.graphene_document.intersects_quad_root(quad);
|
||||
// If no layer is currently selected and the user clicks on a shape, select that.
|
||||
if selected.is_empty() {
|
||||
if let Some(layer) = intersection.last() {
|
||||
@@ -214,7 +214,7 @@ impl Fsm for SelectToolFsmState {
|
||||
}
|
||||
(DrawingBox, DragStop) => {
|
||||
let quad = data.selection_quad();
|
||||
responses.push_front(DocumentMessage::AddSelectedLayers(document.document.intersects_quad_root(quad)).into());
|
||||
responses.push_front(DocumentMessage::AddSelectedLayers(document.graphene_document.intersects_quad_root(quad)).into());
|
||||
responses.push_front(
|
||||
Operation::DeleteLayer {
|
||||
path: data.drag_box_id.take().unwrap(),
|
||||
|
||||
Reference in New Issue
Block a user