mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
* Implement Path Tool * Draw a red rectangle where the first point on the shape is * Correctly render anchors, handles, and connecting lines * Fix drain() which can panic * Refactor frontend messages to work as return values not callbacks * Reduce the number of unnecessary frontend updates * Fix stack overflow by using a loop * Group Document Render calls and put them at the end * Speed hacks for dirtification * Add performance * Bunch folder changed updates * Add triggers to redraw overlays to movement_handler * Polish the pixel-perfect rendering of vector manipulators * Restore scrollbars that were disabled * Cleanup * WIP Add shape outline rendering * Fix compiling * Add outlines to selected shapes * Fix outlines rendering over handles and anchors * Fix dirtification * Add a comment * Address code review feedback * Formatting * Small tweaks Co-authored-by: Oliver Davies <oliver@psyfer.io> Co-authored-by: Dennis Kobert <dennis@kobert.dev>
35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
use crate::consts::SELECTION_TOLERANCE;
|
|
use crate::message_prelude::*;
|
|
use crate::tool::ToolActionHandlerData;
|
|
use glam::DVec2;
|
|
use graphene::{Operation, Quad};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Default)]
|
|
pub struct Fill;
|
|
|
|
#[impl_message(Message, ToolMessage, Fill)]
|
|
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
|
pub enum FillMessage {
|
|
MouseDown,
|
|
}
|
|
|
|
impl<'a> MessageHandler<ToolMessage, ToolActionHandlerData<'a>> for Fill {
|
|
fn process_action(&mut self, _action: ToolMessage, data: ToolActionHandlerData<'a>, responses: &mut VecDeque<Message>) {
|
|
let mouse_pos = data.2.mouse.position;
|
|
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
|
|
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
|
|
|
|
if let Some(path) = data.0.document.intersects_quad_root(quad).last() {
|
|
responses.push_back(
|
|
Operation::SetLayerFill {
|
|
path: path.to_vec(),
|
|
color: data.1.primary_color,
|
|
}
|
|
.into(),
|
|
);
|
|
}
|
|
}
|
|
advertise_actions!(FillMessageDiscriminant; MouseDown);
|
|
}
|