Add two-way tool option messaging system between frontend/backend (#361)

* Add two-way tool option messaging system

* Rename tool option functions

* Move repeated frontend messaging code to function

* Address style comments

* Rename variable to be more descriptive

* Move tool options update to SetActiveTool message

* Refactor record of all tool options

* Only pass active tool options to bar

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Henry Sloan
2021-08-29 00:43:27 -04:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 05ac4ac9b8
commit 9e73cce281
7 changed files with 59 additions and 32 deletions
+4
View File
@@ -117,6 +117,8 @@ fn default_tool_options() -> HashMap<ToolType, ToolOptions> {
let tool_init = |tool: ToolType| (tool, tool.default_options());
std::array::IntoIter::new([
tool_init(ToolType::Select),
tool_init(ToolType::Pen),
tool_init(ToolType::Line),
tool_init(ToolType::Ellipse),
tool_init(ToolType::Shape), // TODO: Add more tool defaults
])
@@ -185,6 +187,8 @@ impl ToolType {
fn default_options(&self) -> ToolOptions {
match self {
ToolType::Select => ToolOptions::Select { append_mode: SelectAppendMode::New },
ToolType::Pen => ToolOptions::Pen { weight: 5 },
ToolType::Line => ToolOptions::Line { weight: 5 },
ToolType::Ellipse => ToolOptions::Ellipse,
ToolType::Shape => ToolOptions::Shape {
shape_type: ShapeType::Polygon { vertices: 6 },