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
@@ -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;
};