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:
0HyperCube
2022-03-27 11:43:41 +01:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 0ee492a857
commit 51c31f042b
23 changed files with 462 additions and 59 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
use super::utility_types::{FrontendDocumentDetails, MouseCursorIcon};
use super::utility_types::{FrontendDocumentDetails, FrontendImageData, MouseCursorIcon};
use crate::document::layer_panel::{LayerPanelEntry, RawBuffer};
use crate::layout::layout_message::LayoutTarget;
use crate::layout::widgets::SubLayout;
@@ -29,6 +29,7 @@ pub enum FrontendMessage {
TriggerIndexedDbRemoveDocument { document_id: u64 },
TriggerIndexedDbWriteDocument { document: String, details: FrontendDocumentDetails, version: String },
TriggerTextCommit,
TriggerTextCopy { copy_text: String },
TriggerViewportResize,
// Update prefix: give the frontend a new value or state for it to use
@@ -43,6 +44,7 @@ pub enum FrontendMessage {
UpdateDocumentOverlays { svg: String },
UpdateDocumentRulers { origin: (f64, f64), spacing: f64, interval: f64 },
UpdateDocumentScrollbars { position: (f64, f64), size: (f64, f64), multiplier: (f64, f64) },
UpdateImageData { image_data: Vec<FrontendImageData> },
UpdateInputHints { hint_data: HintData },
UpdateMouseCursor { cursor: MouseCursorIcon },
UpdateOpenDocumentsList { open_documents: Vec<FrontendDocumentDetails> },
+8
View File
@@ -1,3 +1,4 @@
use graphene::LayerId;
use serde::{Deserialize, Serialize};
#[derive(PartialEq, Clone, Deserialize, Serialize, Debug)]
@@ -7,6 +8,13 @@ pub struct FrontendDocumentDetails {
pub id: u64,
}
#[derive(PartialEq, Clone, Deserialize, Serialize, Debug)]
pub struct FrontendImageData {
pub path: Vec<LayerId>,
pub mime: String,
pub image_data: Vec<u8>,
}
#[derive(Clone, Copy, Debug, Eq, Deserialize, PartialEq, Serialize)]
pub enum MouseCursorIcon {
Default,