mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 04:52:16 +00:00
Add embedable images (#564)
* Add embedable bitmaps * Initial work on blob urls * Finish implementing data url * Fix some bugs * Rename bitmap to image * Fix loading image on document load * Add transform properties for image * Remove some logging * Add image dimensions * Implement system copy and paste * Fix pasting images * Fix test * Address code review Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
0ee492a857
commit
51c31f042b
23 changed files with 462 additions and 59 deletions
|
@ -16,6 +16,7 @@ use editor::viewport_tools::tools;
|
|||
use editor::Color;
|
||||
use editor::Editor;
|
||||
use editor::LayerId;
|
||||
use graphene::Operation;
|
||||
|
||||
use serde::Serialize;
|
||||
use serde_wasm_bindgen::{self, from_value};
|
||||
|
@ -384,19 +385,19 @@ impl JsEditorHandle {
|
|||
|
||||
/// Cut selected layers
|
||||
pub fn cut(&self) {
|
||||
let message = PortfolioMessage::Cut { clipboard: Clipboard::User };
|
||||
let message = PortfolioMessage::Cut { clipboard: Clipboard::Device };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Copy selected layers
|
||||
pub fn copy(&self) {
|
||||
let message = PortfolioMessage::Copy { clipboard: Clipboard::User };
|
||||
let message = PortfolioMessage::Copy { clipboard: Clipboard::Device };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Paste selected layers
|
||||
pub fn paste(&self) {
|
||||
let message = PortfolioMessage::Paste { clipboard: Clipboard::User };
|
||||
/// Paste layers from a serialized json representation
|
||||
pub fn paste_serialized_data(&self, data: String) {
|
||||
let message = PortfolioMessage::PasteSerializedData { data };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
|
@ -490,6 +491,20 @@ impl JsEditorHandle {
|
|||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Sends the blob url generated by js
|
||||
pub fn set_image_blob_url(&self, path: Vec<LayerId>, blob_url: String, width: f64, height: f64) {
|
||||
let dimensions = (width, height);
|
||||
let message = Operation::SetImageBlobUrl { path, blob_url, dimensions };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Pastes an image
|
||||
pub fn paste_image(&self, mime: String, image_data: Vec<u8>, mouse_x: Option<f64>, mouse_y: Option<f64>) {
|
||||
let mouse = mouse_x.and_then(|x| mouse_y.map(|y| (x, y)));
|
||||
let message = DocumentMessage::PasteImage { mime, image_data, mouse };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Toggle visibility of a layer from the layer list
|
||||
pub fn toggle_layer_visibility(&self, layer_path: Vec<LayerId>) {
|
||||
let message = DocumentMessage::ToggleLayerVisibility { layer_path };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue