mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 14:58:05 +08:00
Add Brush tool warning; move font list loading to document creation time
This commit is contained in:
@@ -3,8 +3,6 @@ use crate::messages::dialog::DialogMessageData;
|
||||
use crate::messages::portfolio::document::node_graph::document_node_definitions;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use graphene_core::text::Font;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Dispatcher {
|
||||
buffered_queue: Option<Vec<VecDeque<Message>>>,
|
||||
@@ -135,10 +133,6 @@ impl Dispatcher {
|
||||
// Display the menu bar at the top of the window
|
||||
queue.add(MenuBarMessage::SendLayout);
|
||||
|
||||
// Load the default font
|
||||
let font = Font::new(graphene_core::consts::DEFAULT_FONT_FAMILY.into(), graphene_core::consts::DEFAULT_FONT_STYLE.into());
|
||||
queue.add(FrontendMessage::TriggerFontLoad { font, is_default: true });
|
||||
|
||||
// Send the information for tooltips and categories for each node/input.
|
||||
queue.add(FrontendMessage::SendUIMetadata {
|
||||
input_type_descriptions: Vec::new(),
|
||||
|
||||
@@ -61,34 +61,34 @@ impl PreferencesDialogMessageHandler {
|
||||
.widget_holder(),
|
||||
];
|
||||
|
||||
let imaginate_server_hostname = vec![
|
||||
TextLabel::new("Imaginate").min_width(60).italic(true).widget_holder(),
|
||||
TextLabel::new("Server Hostname").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
TextInput::new(&preferences.imaginate_server_hostname)
|
||||
.min_width(200)
|
||||
.on_update(|text_input: &TextInput| PreferencesMessage::ImaginateServerHostname { hostname: text_input.value.clone() }.into())
|
||||
.widget_holder(),
|
||||
];
|
||||
|
||||
let imaginate_refresh_frequency = vec![
|
||||
TextLabel::new("").min_width(60).widget_holder(),
|
||||
TextLabel::new("Refresh Frequency").table_align(true).widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
NumberInput::new(Some(preferences.imaginate_refresh_frequency))
|
||||
.unit(" seconds")
|
||||
.min(0.)
|
||||
.max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||
.min_width(200)
|
||||
.on_update(|number_input: &NumberInput| PreferencesMessage::ImaginateRefreshFrequency { seconds: number_input.value.unwrap() }.into())
|
||||
.widget_holder(),
|
||||
];
|
||||
// TODO: Reenable when Imaginate is restored
|
||||
// let imaginate_server_hostname = vec![
|
||||
// TextLabel::new("Imaginate").min_width(60).italic(true).widget_holder(),
|
||||
// TextLabel::new("Server Hostname").table_align(true).widget_holder(),
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// TextInput::new(&preferences.imaginate_server_hostname)
|
||||
// .min_width(200)
|
||||
// .on_update(|text_input: &TextInput| PreferencesMessage::ImaginateServerHostname { hostname: text_input.value.clone() }.into())
|
||||
// .widget_holder(),
|
||||
// ];
|
||||
// let imaginate_refresh_frequency = vec![
|
||||
// TextLabel::new("").min_width(60).widget_holder(),
|
||||
// TextLabel::new("Refresh Frequency").table_align(true).widget_holder(),
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// NumberInput::new(Some(preferences.imaginate_refresh_frequency))
|
||||
// .unit(" seconds")
|
||||
// .min(0.)
|
||||
// .max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||
// .min_width(200)
|
||||
// .on_update(|number_input: &NumberInput| PreferencesMessage::ImaginateRefreshFrequency { seconds: number_input.value.unwrap() }.into())
|
||||
// .widget_holder(),
|
||||
// ];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
LayoutGroup::Row { widgets: zoom_with_scroll },
|
||||
LayoutGroup::Row { widgets: use_vello },
|
||||
LayoutGroup::Row { widgets: imaginate_server_hostname },
|
||||
LayoutGroup::Row { widgets: imaginate_refresh_frequency },
|
||||
// LayoutGroup::Row { widgets: imaginate_server_hostname },
|
||||
// LayoutGroup::Row { widgets: imaginate_refresh_frequency },
|
||||
]))
|
||||
}
|
||||
|
||||
|
||||
@@ -81,8 +81,6 @@ pub enum FrontendMessage {
|
||||
},
|
||||
TriggerFontLoad {
|
||||
font: Font,
|
||||
#[serde(rename = "isDefault")]
|
||||
is_default: bool,
|
||||
},
|
||||
TriggerImport,
|
||||
TriggerIndexedDbRemoveDocument {
|
||||
|
||||
@@ -189,7 +189,6 @@ impl LayoutMessageHandler {
|
||||
|
||||
responses.add(PortfolioMessage::LoadFont {
|
||||
font: Font::new(font_family.into(), font_style.into()),
|
||||
is_default: false,
|
||||
});
|
||||
(font_input.on_update.callback)(font_input)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -45,8 +45,10 @@ impl MessageHandler<PreferencesMessage, ()> for PreferencesMessageHandler {
|
||||
if let Ok(deserialized_preferences) = serde_json::from_str::<PreferencesMessageHandler>(&preferences) {
|
||||
*self = deserialized_preferences;
|
||||
|
||||
responses.add(PortfolioMessage::ImaginateServerHostname);
|
||||
responses.add(PortfolioMessage::ImaginateCheckServerStatus);
|
||||
// TODO: Reenable when Imaginate is restored
|
||||
// responses.add(PortfolioMessage::ImaginateServerHostname);
|
||||
// responses.add(PortfolioMessage::ImaginateCheckServerStatus);
|
||||
|
||||
responses.add(PortfolioMessage::EditorPreferences);
|
||||
responses.add(PortfolioMessage::UpdateVelloPreference);
|
||||
responses.add(PreferencesMessage::ModifyLayout {
|
||||
|
||||
@@ -29,6 +29,7 @@ pub struct BrushTool {
|
||||
}
|
||||
|
||||
pub struct BrushOptions {
|
||||
legacy_warning_was_shown: bool,
|
||||
diameter: f64,
|
||||
hardness: f64,
|
||||
flow: f64,
|
||||
@@ -41,6 +42,7 @@ pub struct BrushOptions {
|
||||
impl Default for BrushOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
legacy_warning_was_shown: false,
|
||||
diameter: DEFAULT_BRUSH_SIZE,
|
||||
hardness: 0.,
|
||||
flow: 100.,
|
||||
@@ -78,6 +80,7 @@ pub enum BrushToolMessageOptionsUpdate {
|
||||
Hardness(f64),
|
||||
Spacing(f64),
|
||||
WorkingColors(Option<Color>, Option<Color>),
|
||||
NoDisplayLegacyWarning,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
@@ -217,6 +220,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for BrushTo
|
||||
self.options.color.primary_working_color = primary;
|
||||
self.options.color.secondary_working_color = secondary;
|
||||
}
|
||||
BrushToolMessageOptionsUpdate::NoDisplayLegacyWarning => self.options.legacy_warning_was_shown = true,
|
||||
}
|
||||
|
||||
self.send_layout(responses, LayoutTarget::ToolOptions);
|
||||
@@ -308,6 +312,20 @@ impl Fsm for BrushToolFsmState {
|
||||
document, global_tool_data, input, ..
|
||||
} = tool_action_data;
|
||||
|
||||
if !tool_options.legacy_warning_was_shown {
|
||||
responses.add(DialogMessage::DisplayDialogError {
|
||||
title: "Unsupported tool".into(),
|
||||
description: "
|
||||
The current Brush tool is a legacy feature with\n\
|
||||
significant quality and performance limitations.\n\
|
||||
It will be replaced soon by a new implementation.\n\
|
||||
"
|
||||
.trim()
|
||||
.into(),
|
||||
});
|
||||
responses.add(BrushToolMessage::UpdateOptions(BrushToolMessageOptionsUpdate::NoDisplayLegacyWarning));
|
||||
}
|
||||
|
||||
let ToolMessage::Brush(event) = event else {
|
||||
return self;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user