Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
96d6581
Enforce cache dirtification
TrueDoctor Jul 23, 2021
149a5c8
Test stuff out
TrueDoctor Jul 23, 2021
d9db870
Turn all shapes into one struct
TrueDoctor Jul 28, 2021
4997d11
Rework render function
TrueDoctor Jul 29, 2021
a42501d
Renaming stuff + debugging
TrueDoctor Jul 31, 2021
6edffbc
Remove working folder
TrueDoctor Jul 31, 2021
58c71e2
Remove old shapes
TrueDoctor Jul 31, 2021
20b2dfe
Fix layer tree
TrueDoctor Jul 31, 2021
74cd1d8
Major restructuring
TrueDoctor Aug 1, 2021
651ab80
Plumb up action flow
TrueDoctor Aug 1, 2021
b637b2b
Run cargo fix
TrueDoctor Aug 1, 2021
f569910
Make tests compile
TrueDoctor Aug 1, 2021
26035e2
Further lints
TrueDoctor Aug 1, 2021
a391d0b
Refactor Ellipse
TrueDoctor Aug 1, 2021
38cb362
Fix shape render function
TrueDoctor Aug 1, 2021
1e0d29c
Refactor Ellipse, Rectangle and ShapeTool
TrueDoctor Aug 2, 2021
a2d6efc
Simplify bounding box calculation for folder
TrueDoctor Aug 2, 2021
fc2ec3d
Fix aspect ratio calcualtion
TrueDoctor Aug 2, 2021
a86fd17
Cargo fix
TrueDoctor Aug 2, 2021
356a36f
Fix line tool
TrueDoctor Aug 2, 2021
57777b0
Fix Layerpanel
TrueDoctor Aug 2, 2021
691a171
Fix panic in select tool
TrueDoctor Aug 2, 2021
5d58b3b
Start refactoring the select tool
TrueDoctor Aug 3, 2021
b2571e2
Fix shape dragging selection
TrueDoctor Aug 3, 2021
bd6d7bd
Add dragging support
TrueDoctor Aug 3, 2021
dfca7fb
Refactor Align
TrueDoctor Aug 3, 2021
17088e6
Fix fill tool not updating layer thumbnail
TrueDoctor Aug 3, 2021
9027327
Implement flipping layers
TrueDoctor Aug 3, 2021
4ff6e0c
WIP Zoom to fit all
TrueDoctor Aug 4, 2021
6b8c20c
Fix Zoom to fit canvas
TrueDoctor Aug 4, 2021
ff76b5f
Remove duplicate scale matrix
TrueDoctor Aug 4, 2021
b48ae80
Fix format
TrueDoctor Aug 4, 2021
6cb986e
Fix tests
TrueDoctor Aug 4, 2021
b8b808f
Do less stupid stuff
TrueDoctor Aug 4, 2021
1fb1f56
Fix issue in scoped transform
TrueDoctor Aug 4, 2021
2245c65
Refactor tools to avoid state keeping
TrueDoctor Aug 4, 2021
a93ee8c
Refactor more tools to use state that is passed along
TrueDoctor Aug 4, 2021
8080c2c
Macro magic
TrueDoctor Aug 4, 2021
c2f7637
Add review fixes
TrueDoctor Aug 5, 2021
3ad5bb1
Apply further review suggestions
TrueDoctor Aug 5, 2021
d4b0c48
Update thumbnail on document rotation
TrueDoctor Aug 5, 2021
0a38058
Minor cleanups
TrueDoctor Aug 5, 2021
39628b3
Fix line tool behaviour
TrueDoctor Aug 6, 2021
9ee90b6
Fix whitespace + change selection box style
TrueDoctor Aug 6, 2021
cae5085
Fix line with locked angle
TrueDoctor Aug 6, 2021
37aa628
Fix rearranging layers not updating the thumbnail
TrueDoctor Aug 6, 2021
ab3c0cb
"Fixed" thumbnail rendering
TrueDoctor Aug 6, 2021
56eb004
Fix Line angle snapping
TrueDoctor Aug 6, 2021
5180a67
Remove unneded dirtification upon root rotation
TrueDoctor Aug 6, 2021
4896a05
Set viewbox of svg export based on the contents
TrueDoctor Aug 6, 2021
554ce05
Add margins for document export
TrueDoctor Aug 6, 2021
22437b0
Remove margins
TrueDoctor Aug 6, 2021
83a1a4b
final fix
TrueDoctor Aug 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion client/web/src/components/panels/LayerTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<script lang="ts">
import { defineComponent } from "vue";

import { ResponseType, registerResponseHandler, Response, BlendMode, ExpandFolder, LayerPanelEntry } from "@/utilities/response-handler";
import { ResponseType, registerResponseHandler, Response, BlendMode, ExpandFolder, UpdateLayer, LayerPanelEntry } from "@/utilities/response-handler";
import { SeparatorType } from "@/components/widgets/widgets";

import LayoutRow from "@/components/layout/LayoutRow.vue";
Expand Down Expand Up @@ -324,6 +324,22 @@ export default defineComponent({
registerResponseHandler(ResponseType.CollapseFolder, (responseData) => {
console.log("CollapseFolder: ", responseData);
});
registerResponseHandler(ResponseType.UpdateLayer, (responseData) => {
const updateData = responseData as UpdateLayer;
if (updateData) {
const responsePath = updateData.path;
const responseLayer = updateData.data;

const index = this.layers.findIndex((layer: LayerPanelEntry) => {
const pathLengthsEqual = responsePath.length === layer.path.length;
return pathLengthsEqual && responsePath.every((layer_id, i) => layer_id === layer.path[i]);
});
if (index >= 0) this.layers[index] = responseLayer;

this.setBlendModeForSelectedLayers();
this.setOpacityForSelectedLayers();
}
});
},
data() {
return {
Expand Down
26 changes: 23 additions & 3 deletions client/web/src/utilities/response-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum ResponseType {
SetActiveDocument = "SetActiveDocument",
UpdateOpenDocumentsList = "UpdateOpenDocumentsList",
UpdateWorkingColors = "UpdateWorkingColors",
UpdateLayer = "UpdateLayer",
SetCanvasZoom = "SetCanvasZoom",
SetCanvasRotation = "SetCanvasRotation",
DisplayConfirmationToCloseDocument = "DisplayConfirmationToCloseDocument",
Expand Down Expand Up @@ -61,6 +62,8 @@ function parseResponse(responseType: string, data: any): Response {
return newUpdateOpenDocumentsList(data.UpdateOpenDocumentsList);
case "UpdateCanvas":
return newUpdateCanvas(data.UpdateCanvas);
case "UpdateLayer":
return newUpdateLayer(data.UpdateLayer);
case "SetCanvasZoom":
return newSetCanvasZoom(data.SetCanvasZoom);
case "SetCanvasRotation":
Expand Down Expand Up @@ -168,7 +171,18 @@ export interface CollapseFolder {
}
function newCollapseFolder(input: any): CollapseFolder {
return {
path: new BigUint64Array(input.path.map((n: number) => BigInt(n))),
path: newPath(input.path),
};
}

export interface UpdateLayer {
path: BigUint64Array;
data: LayerPanelEntry;
}
function newUpdateLayer(input: any): UpdateLayer {
return {
path: newPath(input.data.path),
data: newLayerPanelEntry(input.data),
};
}

Expand All @@ -178,7 +192,7 @@ export interface ExpandFolder {
}
function newExpandFolder(input: any): ExpandFolder {
return {
path: new BigUint64Array(input.path.map((n: number) => BigInt(n))),
path: newPath(input.path),
children: input.children.map((child: any) => newLayerPanelEntry(child)),
};
}
Expand All @@ -201,6 +215,12 @@ function newSetCanvasRotation(input: any): SetCanvasRotation {
};
}

function newPath(input: any): BigUint64Array {
// eslint-disable-next-line
const u32CombinedPairs = input.map((n: Array<bigint>) => BigInt((BigInt(n[0]) << BigInt(32)) | BigInt(n[1])));
return new BigUint64Array(u32CombinedPairs);
}

export enum BlendMode {
Normal = "normal",
Multiply = "multiply",
Expand Down Expand Up @@ -266,7 +286,7 @@ function newLayerPanelEntry(input: any): LayerPanelEntry {
opacity: newOpacity(input.opacity),
layer_type: newLayerType(input.layer_type),
layer_data: newLayerData(input.layer_data),
path: new BigUint64Array(input.path.map((n: number) => BigInt(n))),
path: newPath(input.path),
thumbnail: input.thumbnail,
};
}
Expand Down
33 changes: 14 additions & 19 deletions client/web/wasm/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use editor_core::input::mouse::ScrollDelta;
use editor_core::message_prelude::*;
use editor_core::misc::EditorError;
use editor_core::tool::{tool_options::ToolOptions, tools, ToolType};
use editor_core::{
input::mouse::{MouseState, ViewportPosition},
LayerId,
};
use editor_core::{input::mouse::MouseState, LayerId};
use wasm_bindgen::prelude::*;

fn convert_error(err: editor_core::EditorError) -> JsValue {
Expand Down Expand Up @@ -59,44 +56,44 @@ pub fn send_tool_message(tool: String, message: &JsValue) -> Result<(), JsValue>

#[wasm_bindgen]
pub fn select_document(document: usize) -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::SelectDocument(document)).map_err(convert_error))
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentsMessage::SelectDocument(document)).map_err(convert_error))
}

#[wasm_bindgen]
pub fn get_open_documents_list() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::GetOpenDocumentsList).map_err(convert_error))
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentsMessage::GetOpenDocumentsList).map_err(convert_error))
}

#[wasm_bindgen]
pub fn new_document() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::NewDocument).map_err(convert_error))
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentsMessage::NewDocument).map_err(convert_error))
}

#[wasm_bindgen]
pub fn close_document(document: usize) -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::CloseDocument(document)).map_err(convert_error))
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentsMessage::CloseDocument(document)).map_err(convert_error))
}

#[wasm_bindgen]
pub fn close_all_documents() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::CloseAllDocuments).map_err(convert_error))
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentsMessage::CloseAllDocuments).map_err(convert_error))
}

#[wasm_bindgen]
pub fn close_active_document_with_confirmation() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::CloseActiveDocumentWithConfirmation).map_err(convert_error))
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentsMessage::CloseActiveDocumentWithConfirmation).map_err(convert_error))
}

#[wasm_bindgen]
pub fn close_all_documents_with_confirmation() -> Result<(), JsValue> {
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentMessage::CloseAllDocumentsWithConfirmation).map_err(convert_error))
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(DocumentsMessage::CloseAllDocumentsWithConfirmation).map_err(convert_error))
}

// TODO: Call event when the panels are resized
/// Viewport resized
#[wasm_bindgen]
pub fn viewport_resize(new_width: u32, new_height: u32) -> Result<(), JsValue> {
let ev = InputPreprocessorMessage::ViewportResize(ViewportPosition { x: new_width, y: new_height });
let ev = InputPreprocessorMessage::ViewportResize((new_width, new_height).into());
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}

Expand All @@ -106,7 +103,7 @@ pub fn viewport_resize(new_width: u32, new_height: u32) -> Result<(), JsValue> {
pub fn on_mouse_move(x: u32, y: u32, modifiers: u8) -> Result<(), JsValue> {
let mods = ModifierKeys::from_bits(modifiers).expect("invalid modifier keys");
// TODO: Convert these screenspace viewport coordinates to canvas coordinates based on the current zoom and pan
let ev = InputPreprocessorMessage::MouseMove(ViewportPosition { x, y }, mods);
let ev = InputPreprocessorMessage::MouseMove((x, y).into(), mods);
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}

Expand All @@ -122,18 +119,16 @@ pub fn on_mouse_scroll(delta_x: i32, delta_y: i32, delta_z: i32, modifiers: u8)
/// A mouse button depressed within screenspace the bounds of the viewport
#[wasm_bindgen]
pub fn on_mouse_down(x: u32, y: u32, mouse_keys: u8, modifiers: u8) -> Result<(), JsValue> {
let pos = ViewportPosition { x, y };
let mods = ModifierKeys::from_bits(modifiers).expect("invalid modifier keys");
let ev = InputPreprocessorMessage::MouseDown(MouseState::from_u8_pos(mouse_keys, pos), mods);
let ev = InputPreprocessorMessage::MouseDown(MouseState::from_u8_pos(mouse_keys, (x, y).into()), mods);
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}

/// A mouse button released
#[wasm_bindgen]
pub fn on_mouse_up(x: u32, y: u32, mouse_keys: u8, modifiers: u8) -> Result<(), JsValue> {
let pos = ViewportPosition { x, y };
let mods = ModifierKeys::from_bits(modifiers).expect("invalid modifier keys");
let ev = InputPreprocessorMessage::MouseUp(MouseState::from_u8_pos(mouse_keys, pos), mods);
let ev = InputPreprocessorMessage::MouseUp(MouseState::from_u8_pos(mouse_keys, (x, y).into()), mods);
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}

Expand Down Expand Up @@ -259,14 +254,14 @@ pub fn export_document() -> Result<(), JsValue> {
/// Sets the zoom to the value
#[wasm_bindgen]
pub fn set_zoom(new_zoom: f64) -> Result<(), JsValue> {
let ev = DocumentMessage::SetCanvasZoom(new_zoom);
let ev = MovementMessage::SetCanvasZoom(new_zoom);
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}

/// Sets the rotation to the new value (in radians)
#[wasm_bindgen]
pub fn set_rotation(new_radians: f64) -> Result<(), JsValue> {
let ev = DocumentMessage::SetCanvasRotation(new_radians);
let ev = MovementMessage::SetCanvasRotation(new_radians);
EDITOR_STATE.with(|editor| editor.borrow_mut().handle_message(ev)).map_err(convert_error)
}

Expand Down
4 changes: 2 additions & 2 deletions core/document/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ license = "Apache-2.0"
[dependencies]
log = "0.4"

kurbo = {version="0.8", features = ["serde"]}
kurbo = {git="https://github.com/linebender/kurbo", features = ["serde"]}
serde = { version = "1.0", features = ["derive"] }
glam = { version = "0.16", features = ["serde"] }
glam = { version = "0.17", features = ["serde"] }
Loading