mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Polish a few things (#81)
* Implement/suppress various compiler/clippy lints * Change `tool_init` to take `ToolType` by value * Factor out error conversion into a function * Consume parameters with `todo` * Make `workspace` stuff public Making them public also removes the warnings without having to suppress them. Also, this commit removes the unused import of `EditorError` * Remove allow(unused_variables), use vars in `todo` Also implements `Debug` on `DocumentToolData`
This commit is contained in:
committed by
Keavon Chambers
parent
87ed3a1bbd
commit
b556dd6bfd
@@ -17,7 +17,7 @@ impl ShapePoints {
|
||||
ShapePoints {
|
||||
center: center.into(),
|
||||
extent: extent.into(),
|
||||
sides: sides,
|
||||
sides,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ impl ShapePoints {
|
||||
// Gets the length of one side
|
||||
#[inline]
|
||||
pub fn side_length(&self) -> f64 {
|
||||
self.apothem_offset_angle().sin() * (self.sides as f64) * (2 as f64)
|
||||
self.apothem_offset_angle().sin() * (self.sides as f64) * 2f64
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ impl std::fmt::Display for ShapePoints {
|
||||
fn rotate(v: &Vec2, theta: f64) -> Vec2 {
|
||||
let cosine = theta.cos();
|
||||
let sine = theta.sin();
|
||||
return Vec2::new(v.x * cosine - v.y * sine, v.x * sine + v.y * cosine);
|
||||
Vec2::new(v.x * cosine - v.y * sine, v.x * sine + v.y * cosine)
|
||||
}
|
||||
info!("sides{}", self.sides);
|
||||
for i in 0..self.sides {
|
||||
@@ -72,7 +72,7 @@ impl Iterator for ShapePathIter {
|
||||
fn rotate(v: &Vec2, theta: f64) -> Vec2 {
|
||||
let cosine = theta.cos();
|
||||
let sine = theta.sin();
|
||||
return Vec2::new(v.x * cosine - v.y * sine, v.x * sine + v.y * cosine);
|
||||
Vec2::new(v.x * cosine - v.y * sine, v.x * sine + v.y * cosine)
|
||||
}
|
||||
self.ix += 1;
|
||||
match self.ix {
|
||||
@@ -102,9 +102,9 @@ impl Add<Vec2> for ShapePoints {
|
||||
|
||||
impl kurbo::Shape for ShapePoints {
|
||||
type PathElementsIter = ShapePathIter;
|
||||
#[inline]
|
||||
fn perimeter(&self, _accuracy: f64) -> f64 {
|
||||
self.side_length() * (self.sides as f64)
|
||||
|
||||
fn path_elements(&self, _tolerance: f64) -> Self::PathElementsIter {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -112,8 +112,9 @@ impl kurbo::Shape for ShapePoints {
|
||||
self.apothem() * self.perimeter(2.1)
|
||||
}
|
||||
|
||||
fn path_elements(&self, _tolerance: f64) -> Self::PathElementsIter {
|
||||
todo!()
|
||||
#[inline]
|
||||
fn perimeter(&self, _accuracy: f64) -> f64 {
|
||||
self.side_length() * (self.sides as f64)
|
||||
}
|
||||
|
||||
fn winding(&self, _pt: Point) -> i32 {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// since our policy is tabs, we want to stop clippy from warning about that
|
||||
#![allow(clippy::tabs_in_doc_comments)]
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
|
||||
@@ -10,6 +10,6 @@ pub struct Crop;
|
||||
|
||||
impl Tool for Crop {
|
||||
fn handle_input(&mut self, event: &Event, document: &Document, tool_data: &DocumentToolData) -> (Vec<Response>, Vec<Operation>) {
|
||||
todo!();
|
||||
todo!("{}::handle_input {:?} {:?} {:?}", module_path!(), event, document, tool_data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,14 @@ pub trait Fsm {
|
||||
fn transition(self, event: &Event, document: &Document, tool_data: &DocumentToolData, data: &mut Self::ToolData, responses: &mut Vec<Response>, operations: &mut Vec<Operation>) -> Self;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DocumentToolData {
|
||||
pub mouse_state: MouseState,
|
||||
pub mod_keys: ModKeys,
|
||||
pub primary_color: Color,
|
||||
pub secondary_color: Color,
|
||||
}
|
||||
|
||||
pub struct ToolData {
|
||||
pub active_tool_type: ToolType,
|
||||
pub tools: HashMap<ToolType, Box<dyn Tool>>,
|
||||
@@ -97,11 +99,11 @@ impl ToolFsmState {
|
||||
}
|
||||
|
||||
fn default_tool_settings() -> HashMap<ToolType, ToolSettings> {
|
||||
let tool_init = |tool: &ToolType| (*tool, tool.default_settings());
|
||||
let tool_init = |tool: ToolType| (tool, tool.default_settings());
|
||||
std::array::IntoIter::new([
|
||||
tool_init(&ToolType::Select),
|
||||
tool_init(&ToolType::Ellipse),
|
||||
tool_init(&ToolType::Shape), // TODO: Add more tool defaults
|
||||
tool_init(ToolType::Select),
|
||||
tool_init(ToolType::Ellipse),
|
||||
tool_init(ToolType::Shape), // TODO: Add more tool defaults
|
||||
])
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ pub struct Navigate;
|
||||
|
||||
impl Tool for Navigate {
|
||||
fn handle_input(&mut self, event: &Event, document: &Document, tool_data: &DocumentToolData) -> (Vec<Response>, Vec<Operation>) {
|
||||
todo!();
|
||||
todo!("{}::handle_input {:?} {:?} {:?}", module_path!(), event, document, tool_data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ pub struct Path;
|
||||
|
||||
impl Tool for Path {
|
||||
fn handle_input(&mut self, event: &Event, document: &Document, tool_data: &DocumentToolData) -> (Vec<Response>, Vec<Operation>) {
|
||||
todo!();
|
||||
todo!("{}::handle_input {:?} {:?} {:?}", module_path!(), event, document, tool_data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ pub struct Pen;
|
||||
|
||||
impl Tool for Pen {
|
||||
fn handle_input(&mut self, event: &Event, document: &Document, tool_data: &DocumentToolData) -> (Vec<Response>, Vec<Operation>) {
|
||||
todo!();
|
||||
todo!("{}::handle_input {:?} {:?} {:?}", module_path!(), event, document, tool_data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ pub struct Sample;
|
||||
|
||||
impl Tool for Sample {
|
||||
fn handle_input(&mut self, event: &Event, document: &Document, tool_data: &DocumentToolData) -> (Vec<Response>, Vec<Operation>) {
|
||||
todo!();
|
||||
todo!("{}::handle_input {:?} {:?} {:?}", module_path!(), event, document, tool_data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::EditorError;
|
||||
pub type PanelId = usize;
|
||||
|
||||
pub struct Workspace {
|
||||
hovered_panel: PanelId,
|
||||
root: PanelGroup,
|
||||
pub hovered_panel: PanelId,
|
||||
pub root: PanelGroup,
|
||||
}
|
||||
|
||||
impl Workspace {
|
||||
@@ -19,9 +18,9 @@ impl Workspace {
|
||||
// get_serialized_layout()
|
||||
}
|
||||
|
||||
struct PanelGroup {
|
||||
contents: Vec<Contents>,
|
||||
layout_direction: LayoutDirection,
|
||||
pub struct PanelGroup {
|
||||
pub contents: Vec<Contents>,
|
||||
pub layout_direction: LayoutDirection,
|
||||
}
|
||||
|
||||
impl PanelGroup {
|
||||
@@ -33,17 +32,17 @@ impl PanelGroup {
|
||||
}
|
||||
}
|
||||
|
||||
enum Contents {
|
||||
pub enum Contents {
|
||||
PanelArea(PanelArea),
|
||||
Group(PanelGroup),
|
||||
}
|
||||
|
||||
struct PanelArea {
|
||||
panels: Vec<PanelId>,
|
||||
active: PanelId,
|
||||
pub struct PanelArea {
|
||||
pub panels: Vec<PanelId>,
|
||||
pub active: PanelId,
|
||||
}
|
||||
|
||||
enum LayoutDirection {
|
||||
pub enum LayoutDirection {
|
||||
Horizontal,
|
||||
Vertical,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user