Add Brush tool warning; move font list loading to document creation time

This commit is contained in:
Keavon Chambers
2024-11-09 12:27:09 -08:00
parent 457619794b
commit de366f9514
13 changed files with 99 additions and 82 deletions
@@ -1676,7 +1676,7 @@ impl DocumentMessageHandler {
}
}
for font in fonts {
responses.add_front(FrontendMessage::TriggerFontLoad { font, is_default: false });
responses.add_front(FrontendMessage::TriggerFontLoad { font });
}
}
@@ -51,7 +51,6 @@ pub enum PortfolioMessage {
font_style: String,
preview_url: String,
data: Vec<u8>,
is_default: bool,
},
ImaginateCheckServerStatus,
ImaginatePollServerStatus,
@@ -63,7 +62,6 @@ pub enum PortfolioMessage {
},
LoadFont {
font: Font,
is_default: bool,
},
NewDocumentWithName {
name: String,
@@ -278,11 +278,10 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
font_style,
preview_url,
data,
is_default,
} => {
let font = Font::new(font_family, font_style);
self.persistent_data.font_cache.insert(font, preview_url, data, is_default);
self.persistent_data.font_cache.insert(font, preview_url, data);
self.executor.update_font_cache(self.persistent_data.font_cache.clone());
for document_id in self.document_ids.iter() {
let _ = self.executor.submit_node_graph_evaluation(
@@ -334,9 +333,9 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
document.load_layer_resources(responses);
}
}
PortfolioMessage::LoadFont { font, is_default } => {
PortfolioMessage::LoadFont { font } => {
if !self.persistent_data.font_cache.loaded_font(&font) {
responses.add_front(FrontendMessage::TriggerFontLoad { font, is_default });
responses.add_front(FrontendMessage::TriggerFontLoad { font });
}
}
PortfolioMessage::NewDocumentWithName { name } => {
@@ -939,6 +938,10 @@ impl PortfolioMessageHandler {
if self.active_document().is_some() {
responses.add(BroadcastEvent::ToolAbort);
responses.add(ToolMessage::DeactivateTools);
} else {
// Load the default font upon creating the first document
let font = Font::new(graphene_core::consts::DEFAULT_FONT_FAMILY.into(), graphene_core::consts::DEFAULT_FONT_STYLE.into());
responses.add(FrontendMessage::TriggerFontLoad { font });
}
// TODO: Remove this and find a way to fix the issue where creating a new document when the node graph is open causes the transform in the new document to be incorrect