mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 11:28:30 +08:00
* WIP: NodeNetworkInterface * Organize ModifyInputsContext to use network interface * Improve ClickTarget and Position state * Rework ClickTarget state * Continue fixing NodeGraphMessageHandler * Restructure network_metadata * Final(?) NodeNetworkInterface struct * Final(??) NodeNetworkInterface * Final(???) NodeNetworkInterface. Separated persistent and transient data * Final NodeNetworkInterface data structure. Implemented all basic getters * Continue migrating functionality to network interface * Migrate all NodeGraphMessage's to use network interface * Fix all helper functions in NodeGraphMessageHandler * Move document metadata to network interface, remove various cached fields * Move all editor only NodeNetwork implementations to NodeNetworkInterface * Fix all DocumentNodeDefinitions * Rework and migrate GraphOperationMessages to network interface * Continue migration to NodeNetworkInterface * Save point before merging master * Fix all errors in network_interface * 850 -> 160 errors * Fix all errors :D * Render default document * Visualize click targets * merge conflicts * Cache transient metadata separately, store entire interface in document history * Start migration to storing selected nodes for each network * Remove selected nodes from document message handler * Move outward wires and all nodes bounding box to transient metadata * Fix connecting/disconnecting nodes * Layer stack organization for disconnecting/connecting nodes * Basic chain locking * Improve chain positioning * Add copy/pasting * Move upstream nodes on shift+drag * merge conflict fixes * Improve Graph.svelte code quality * Final improvements to Graph.svelte * Fix layer panel * Performance optimizations * Bug fixes and derived PTZ * Chain organization improvement and bug fixes * Bug fixes, remove all warnings * Automatic file upgrade * Final code review * Fix editor tests * Fix compile errors * Remove select tool intersection check when panning * WIP: Import/Exports * Fix JS issues * Finish simplified import/export UI * Import/Export viewport edge UI * Remove minimum y bound on import/export ports * Improve performance while panning graph * cargo fmt * Fix CI code build * Format the demo artwork graph with chains * Code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: dennis@kobert.dev <dennis@kobert.dev>
122 lines
4.7 KiB
Rust
122 lines
4.7 KiB
Rust
use super::simple_dialogs::{self, AboutGraphiteDialog, ComingSoonDialog, DemoArtworkDialog, LicensesDialog};
|
|
use crate::messages::layout::utility_types::widget_prelude::*;
|
|
use crate::messages::prelude::*;
|
|
|
|
pub struct DialogMessageData<'a> {
|
|
pub portfolio: &'a PortfolioMessageHandler,
|
|
pub preferences: &'a PreferencesMessageHandler,
|
|
}
|
|
|
|
/// Stores the dialogs which require state. These are the ones that have their own message handlers, and are not the ones defined in `simple_dialogs`.
|
|
#[derive(Debug, Default, Clone)]
|
|
pub struct DialogMessageHandler {
|
|
export_dialog: ExportDialogMessageHandler,
|
|
new_document_dialog: NewDocumentDialogMessageHandler,
|
|
preferences_dialog: PreferencesDialogMessageHandler,
|
|
}
|
|
|
|
impl MessageHandler<DialogMessage, DialogMessageData<'_>> for DialogMessageHandler {
|
|
fn process_message(&mut self, message: DialogMessage, responses: &mut VecDeque<Message>, data: DialogMessageData) {
|
|
let DialogMessageData { portfolio, preferences } = data;
|
|
|
|
match message {
|
|
DialogMessage::ExportDialog(message) => self.export_dialog.process_message(message, responses, ExportDialogMessageData { portfolio }),
|
|
DialogMessage::NewDocumentDialog(message) => self.new_document_dialog.process_message(message, responses, ()),
|
|
DialogMessage::PreferencesDialog(message) => self.preferences_dialog.process_message(message, responses, PreferencesDialogMessageData { preferences }),
|
|
|
|
DialogMessage::CloseAllDocumentsWithConfirmation => {
|
|
let dialog = simple_dialogs::CloseAllDocumentsDialog {
|
|
unsaved_document_names: portfolio.unsaved_document_names(),
|
|
};
|
|
dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
DialogMessage::CloseDialogAndThen { followups } => {
|
|
for message in followups.into_iter() {
|
|
responses.add(message);
|
|
}
|
|
|
|
// This come after followups, so that the followups (which can cause the dialog to open) happen first, then we close it afterwards.
|
|
// If it comes before, the dialog reopens (and appears to not close at all).
|
|
responses.add(FrontendMessage::DisplayDialogDismiss);
|
|
}
|
|
DialogMessage::DisplayDialogError { title, description } => {
|
|
let dialog = simple_dialogs::ErrorDialog { title, description };
|
|
dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
DialogMessage::RequestAboutGraphiteDialog => {
|
|
responses.add(FrontendMessage::TriggerAboutGraphiteLocalizedCommitDate {
|
|
commit_date: env!("GRAPHITE_GIT_COMMIT_DATE").into(),
|
|
});
|
|
}
|
|
DialogMessage::RequestAboutGraphiteDialogWithLocalizedCommitDate {
|
|
localized_commit_date,
|
|
localized_commit_year,
|
|
} => {
|
|
let dialog = AboutGraphiteDialog {
|
|
localized_commit_date,
|
|
localized_commit_year,
|
|
};
|
|
|
|
dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
DialogMessage::RequestComingSoonDialog { issue } => {
|
|
let dialog = ComingSoonDialog { issue };
|
|
dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
DialogMessage::RequestDemoArtworkDialog => {
|
|
let dialog = DemoArtworkDialog;
|
|
dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
DialogMessage::RequestExportDialog => {
|
|
if let Some(document) = portfolio.active_document() {
|
|
let artboards = document
|
|
.metadata()
|
|
.all_layers()
|
|
.filter(|&layer| document.network_interface.is_artboard(&layer.to_node(), &[]))
|
|
.map(|layer| {
|
|
let name = document
|
|
.network_interface
|
|
.node_metadata(&layer.to_node(), &[])
|
|
.map(|node| node.persistent_metadata.display_name.clone())
|
|
.and_then(|name| if name.is_empty() { None } else { Some(name) })
|
|
.unwrap_or_else(|| "Artboard".to_string());
|
|
(layer, name)
|
|
})
|
|
.collect();
|
|
|
|
self.export_dialog.artboards = artboards;
|
|
self.export_dialog.has_selection = document
|
|
.network_interface
|
|
.selected_nodes(&[])
|
|
.is_some_and(|selected_nodes| selected_nodes.selected_layers(document.metadata()).next().is_some());
|
|
self.export_dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
}
|
|
DialogMessage::RequestLicensesDialogWithLocalizedCommitDate { localized_commit_year } => {
|
|
let dialog = LicensesDialog { localized_commit_year };
|
|
|
|
dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
DialogMessage::RequestNewDocumentDialog => {
|
|
self.new_document_dialog = NewDocumentDialogMessageHandler {
|
|
name: portfolio.generate_new_document_name(),
|
|
infinite: false,
|
|
dimensions: glam::UVec2::new(1920, 1080),
|
|
};
|
|
self.new_document_dialog.send_dialog_to_frontend(responses);
|
|
}
|
|
DialogMessage::RequestPreferencesDialog => {
|
|
self.preferences_dialog = PreferencesDialogMessageHandler {};
|
|
self.preferences_dialog.send_dialog_to_frontend(responses, preferences);
|
|
}
|
|
}
|
|
}
|
|
|
|
advertise_actions!(DialogMessageDiscriminant;
|
|
CloseAllDocumentsWithConfirmation,
|
|
RequestExportDialog,
|
|
RequestNewDocumentDialog,
|
|
RequestPreferencesDialog,
|
|
);
|
|
}
|