mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 09:58:11 +08:00
Add a dropdown for resource selection and adopt it in the 'Image' node (#4543)
* Add a dropdown for resource selection and adopt it in the Image node * Route every image upload through a new ResourceUpload handler with desktop support and migrate wired 'Image' node inputs * Show each resource's user count in the resource picker dropdown * Send a picked resource file to the document that requested it, list every non-font resource in the picker, and link sibling message docs
This commit is contained in:
@@ -22,6 +22,11 @@ pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMess
|
||||
OpenFileDialogContext::Import => {
|
||||
dispatcher.queue_desktop_wrapper_message(DesktopWrapperMessage::ImportFile { path, content });
|
||||
}
|
||||
OpenFileDialogContext::UploadResource => {
|
||||
let name = path.file_name().map(|name| name.to_string_lossy().to_string());
|
||||
let message = ResourceUploadMessage::ReceiveUpload { name, data: content.into() };
|
||||
dispatcher.queue_editor_message(message);
|
||||
}
|
||||
},
|
||||
DesktopWrapperMessage::SaveFileDialogResult { path, context } => match context {
|
||||
SaveFileDialogContext::Document { document_id, content } => {
|
||||
|
||||
@@ -26,6 +26,14 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
|
||||
context: OpenFileDialogContext::Import,
|
||||
});
|
||||
}
|
||||
FrontendMessage::TriggerUploadResource { filters } => {
|
||||
dispatcher.respond(DesktopFrontendMessage::OpenFileDialog {
|
||||
title: "Select File".to_string(),
|
||||
filters,
|
||||
multiple: false,
|
||||
context: OpenFileDialogContext::UploadResource,
|
||||
});
|
||||
}
|
||||
FrontendMessage::TriggerSaveDocument {
|
||||
document_id,
|
||||
name,
|
||||
|
||||
@@ -107,6 +107,7 @@ pub enum DesktopWrapperMessage {
|
||||
pub enum OpenFileDialogContext {
|
||||
Open,
|
||||
Import,
|
||||
UploadResource,
|
||||
}
|
||||
|
||||
pub enum SaveFileDialogContext {
|
||||
|
||||
Reference in New Issue
Block a user