Graphite/editor/src/viewport_tools/tool_message.rs
0HyperCube 121a68ad3c Implement the Text Tool and text layer MVP (#492)
* Add text tool

* Double click with the select tool to edit text

* Fix (I think?) transitioning to select tool

* Commit and abort text editing

* Transition to a contenteditable div and autosize

* Fix right click blocking

* Cleanup hints

* Ctrl + enter leaves text edit mode

* Render indervidual bounding boxes for text

* Re-format space indents

* Reflect font size in the textarea

* Fix change tool behaviour

* Remove starting text

* Populate the cache (caused doc load bug)

* Remove console log

* Chrome display the flashing text entry cursor

* Update overlay on input

* Cleanup input.ts

* Fix bounding boxes

* Apply review feedback

* Remove manual test

* Remove svg from gitignore

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2022-01-30 15:10:10 +00:00

102 lines
1.9 KiB
Rust

use super::tool::ToolType;
use super::tool_options::ToolOptions;
use crate::message_prelude::*;
use graphene::color::Color;
use serde::{Deserialize, Serialize};
#[remain::sorted]
#[impl_message(Message, Tool)]
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub enum ToolMessage {
// Sub-messages
#[remain::unsorted]
#[child]
Select(SelectMessage),
#[remain::unsorted]
#[child]
Crop(CropMessage),
#[remain::unsorted]
#[child]
Navigate(NavigateMessage),
#[remain::unsorted]
#[child]
Eyedropper(EyedropperMessage),
// #[remain::unsorted]
// #[child]
// Text(TextMessage),
#[remain::unsorted]
#[child]
Text(TextMessage),
#[remain::unsorted]
#[child]
Fill(FillMessage),
// #[remain::unsorted]
// #[child]
// Gradient(GradientMessage),
// #[remain::unsorted]
// #[child]
// Brush(BrushMessage),
// #[remain::unsorted]
// #[child]
// Heal(HealMessage),
// #[remain::unsorted]
// #[child]
// Clone(CloneMessage),
// #[remain::unsorted]
// #[child]
// Patch(PatchMessage),
// #[remain::unsorted]
// #[child]
// Detail(DetailMessage),
// #[remain::unsorted]
// #[child]
// Relight(RelightMessage),
#[remain::unsorted]
#[child]
Path(PathMessage),
#[remain::unsorted]
#[child]
Pen(PenMessage),
#[remain::unsorted]
#[child]
Freehand(FreehandMessage),
// #[remain::unsorted]
// #[child]
// Spline(SplineMessage),
#[remain::unsorted]
#[child]
Line(LineMessage),
#[remain::unsorted]
#[child]
Rectangle(RectangleMessage),
#[remain::unsorted]
#[child]
Ellipse(EllipseMessage),
#[remain::unsorted]
#[child]
Shape(ShapeMessage),
// Messages
#[remain::unsorted]
NoOp,
ActivateTool {
tool_type: ToolType,
},
DocumentIsDirty,
ResetColors,
SelectPrimaryColor {
color: Color,
},
SelectSecondaryColor {
color: Color,
},
SetToolOptions {
tool_type: ToolType,
tool_options: ToolOptions,
},
SwapColors,
UpdateCursor,
UpdateHints,
}