Compare commits
1 Commits
fdb92fbd0e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c63babb599 |
@ -27,7 +27,7 @@ use zerocopy::{FromBytes, IntoBytes};
|
|||||||
use crate::{custom_code_block::try_from_custom_code_block, rasterizer};
|
use crate::{custom_code_block::try_from_custom_code_block, rasterizer};
|
||||||
use crate::{custom_code_block::write_custom_code_block, util::random_id};
|
use crate::{custom_code_block::write_custom_code_block, util::random_id};
|
||||||
|
|
||||||
use self::tool::{ToolEvent, Tool};
|
use self::tool::{Tool, ToolEvent};
|
||||||
|
|
||||||
const HANDWRITING_MIN_HEIGHT: f32 = 100.0;
|
const HANDWRITING_MIN_HEIGHT: f32 = 100.0;
|
||||||
const HANDWRITING_BOTTOM_PADDING: f32 = 80.0;
|
const HANDWRITING_BOTTOM_PADDING: f32 = 80.0;
|
||||||
@ -139,7 +139,7 @@ impl Default for Ephemeral {
|
|||||||
Self {
|
Self {
|
||||||
id: random_id(),
|
id: random_id(),
|
||||||
canvas_rasterizer: Default::default(),
|
canvas_rasterizer: Default::default(),
|
||||||
tool: Tool::Eraser,
|
tool: Tool::Pencil,
|
||||||
tool_position: None,
|
tool_position: None,
|
||||||
last_tool_position: None,
|
last_tool_position: None,
|
||||||
current_stroke: Default::default(),
|
current_stroke: Default::default(),
|
||||||
@ -299,9 +299,7 @@ impl Handwriting {
|
|||||||
self.e.tool_position = tool_event.position();
|
self.e.tool_position = tool_event.position();
|
||||||
match self.e.tool {
|
match self.e.tool {
|
||||||
Tool::Pencil => {
|
Tool::Pencil => {
|
||||||
hw_response.changed |=
|
hw_response.changed |= tool::pencil::on_tool_event(self, tool_event);
|
||||||
tool::pencil::on_tool_event(self, tool_event);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Tool::Eraser => {
|
Tool::Eraser => {
|
||||||
if tool::eraser::on_tool_event(self, tool_event) {
|
if tool::eraser::on_tool_event(self, tool_event) {
|
||||||
@ -367,7 +365,9 @@ impl Handwriting {
|
|||||||
// Draw the texture
|
// Draw the texture
|
||||||
self.e.canvas_rasterizer.show(ui.ctx(), &painter, mesh_rect);
|
self.e.canvas_rasterizer.show(ui.ctx(), &painter, mesh_rect);
|
||||||
|
|
||||||
if let Some(tool_position) = self.e.tool_position && let Tool::Eraser = self.e.tool {
|
if let Some(tool_position) = self.e.tool_position
|
||||||
|
&& let Tool::Eraser = self.e.tool
|
||||||
|
{
|
||||||
let pos = to_screen * tool_position;
|
let pos = to_screen * tool_position;
|
||||||
let shape = Shape::circle_stroke(pos, tool::eraser::RADIUS, style.stroke);
|
let shape = Shape::circle_stroke(pos, tool::eraser::RADIUS, style.stroke);
|
||||||
painter.add(shape);
|
painter.add(shape);
|
||||||
|
|||||||
Reference in New Issue
Block a user