Skip to content

Commit

Permalink
Removed warnings. Added missing flush call.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewBlanchard authored and ctrlcctrlv committed Mar 13, 2024
1 parent bea4001 commit 9be5e25
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 96 deletions.
4 changes: 2 additions & 2 deletions src/editor/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ impl From<GpImage> for EditorImage {
);
let image_info = SkImageInfo::from_color_info((width as i32, height as i32), color_info);
let skdata = unsafe { SkData::new_bytes(&data) };
let img = SkImage::from_raster_data(&image_info, skdata, (width * 4) as usize).unwrap();

let img = skia_safe::images::raster_from_data(&image_info, skdata, (width * 4) as usize).unwrap();
Self {
img,
data,
Expand Down
16 changes: 4 additions & 12 deletions src/editor/util.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
// This file is mainly utilities that are common use cases for the editor, but don't necessarily need to be
// in Editor.

use std::collections::btree_set::Intersection;

use crate::{get_contour_len, get_point_mut};
use crate::{
get_point,
user_interface::{Interface, MouseInfo},
};
use egui::vec2;
use flo_curves::line::Line2D;
use crate::user_interface::Interface;
use flo_curves::{
bezier::{solve_curve_for_t_along_axis, Curve as FloCurve},
geo::Coord2,
line::Line,
};
use glifparser::{MFEKPointData, Point, WhichHandle};
use glifparser::WhichHandle;
use glifrenderer::constants::{POINT_RADIUS, POINT_STROKE_THICKNESS};
use skia_safe::Contains;
use skia_safe::Point as SkPoint;
use skia_safe::Rect as SkRect;
use MFEKmath::{subdivide::Subdivide, vec2};
use MFEKmath::{Bezier, Piecewise, Vector};
use MFEKmath::subdivide::Subdivide;
use MFEKmath::{Bezier, Piecewise};

use super::Editor;
use glifparser::glif::mfek::contour::MFEKContourCommon;
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![allow(incomplete_features)]
#![feature(
type_alias_impl_trait,
local_key_cell_methods,
trait_alias,
const_trait_impl,
generic_const_exprs,
Expand Down
14 changes: 5 additions & 9 deletions src/render/measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ use glifrenderer::constants::OUTLINE_STROKE_THICKNESS;
use skia_safe::{Canvas, Font, Matrix, Paint, Path, Point, Rect};
use MFEKmath::{vec2, Vector};

use crate::{
constants,
editor::Editor,
tools::cut::{Cut, Intersection},
user_interface::{Interface, MouseInfo},
};
use crate::editor::Editor;
use crate::tools::cut::{Cut, Intersection};
use crate::user_interface::Interface;
use glifrenderer::constants::MEASURE_STROKE;

pub struct Measure {
Expand Down Expand Up @@ -52,7 +49,6 @@ impl Measure {
canvas.draw_path(&path, &paint);

// Arc illustrating the angle
let radius = distance / 2.0; // This can be adjusted based on desired arc size.
path.rewind(); // Clear the path to reuse it
path.move_to(end_point_horizontal.to_skia_point());

Expand Down Expand Up @@ -98,7 +94,7 @@ impl Measure {
factor,
);

let intersections = Cut::find_intersections(&self.start_point, &self.end_point, v, true);
let intersections = Cut::find_intersections(&self.start_point, &self.end_point, v);
self.draw_intersection_distances(canvas, intersections.as_slice(), factor);

if intersections.len() > 1 {
Expand All @@ -112,7 +108,7 @@ impl Measure {
last_intersection.coords.0 as f32,
last_intersection.coords.1 as f32,
);
self.draw_bracket(canvas, fcoords, lcoords, -20.0, factor); // 20.0 is the offset from the main line, adjust as needed
self.draw_bracket(canvas, fcoords, lcoords, -20.0, factor);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/system_fonts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use font_kit::{
self as FKSelectionError, CannotAccessSource as FKSourceError, NotFound as FKNotFoundError,
},
handle::Handle as FKHandle,
properties::Properties,
source::SystemSource,
};

Expand Down Expand Up @@ -51,7 +50,6 @@ impl TryInto<SystemFont> for FKHandle {
fn load_font(family: &[&str]) -> Result<SystemFont, FKSelectionError> {
log::debug!("Looking for a UI font to satisfy request for {:?}", family);
let source = SystemSource::new();
let props = Properties::new();
let mut font: Option<SystemFont> = None;
let mut last_err = None;
let mut best_match;
Expand Down
3 changes: 0 additions & 3 deletions src/tool_behaviors/move_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pub struct MoveHandle {

// this handle did not previously exist but is being drawn by user for the first time
creating: bool,

warned_force_line: bool,
}

// Event handlers
Expand All @@ -28,7 +26,6 @@ impl MoveHandle {
wh,
mouse_info,
creating,
warned_force_line: false,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/tool_behaviors/move_tunni_line.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{get_point_mut, editor::tunni::{TunniLineInfo, construct_tunni_line, get_tunni_line_from_info}};
use crate::{get_point_mut, editor::tunni::{TunniLineInfo, get_tunni_line_from_info}};

use super::prelude::*;
use MFEKmath::Vector;
use glifparser::glif::{mfek::contour::MFEKContourCommon};
use glifparser::glif::mfek::contour::MFEKContourCommon;
#[derive(Clone, Debug)]
pub struct MoveTunniLine {
mouse_info: MouseInfo,
Expand Down Expand Up @@ -34,7 +34,7 @@ impl MoveTunniLine {
}
}

pub fn mouse_moved(&mut self, v: &mut Editor, i: &mut Interface, mouse_info: MouseInfo) {
pub fn mouse_moved(&mut self, v: &mut Editor, _: &mut Interface, mouse_info: MouseInfo) {
// we stop the drag when there's no longer a well formed tunni point/line
if get_tunni_line_from_info(v, &self.tunni_info).is_none() {
v.pop_behavior();
Expand Down
11 changes: 5 additions & 6 deletions src/tool_behaviors/move_tunni_point.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{get_point_mut, editor::tunni::{TunniLineInfo, construct_tunni_line, get_tunni_line_from_info}};
use crate::{get_point_mut, editor::tunni::{TunniLineInfo, get_tunni_line_from_info}};

use super::prelude::*;
use MFEKmath::Vector;
use glifparser::glif::{mfek::contour::MFEKContourCommon};
use glifparser::glif::mfek::contour::MFEKContourCommon;

#[derive(Clone, Debug)]
pub struct MoveTunniPoint {
mouse_info: MouseInfo,
tunni_info: TunniLineInfo
}

Expand All @@ -25,14 +25,13 @@ impl ToolBehavior for MoveTunniPoint {
}

impl MoveTunniPoint {
pub fn new(mouse_info: MouseInfo, tunni_info: TunniLineInfo) -> Self {
pub fn new(_: MouseInfo, tunni_info: TunniLineInfo) -> Self {
MoveTunniPoint {
mouse_info,
tunni_info
}
}

pub fn mouse_moved(&mut self, v: &mut Editor, i: &mut Interface, mouse_info: MouseInfo) {
pub fn mouse_moved(&mut self, v: &mut Editor, _: &mut Interface, mouse_info: MouseInfo) {
// we stop the drag when there's no longer a well formed tunni point/line
if get_tunni_line_from_info(v, &self.tunni_info).is_none() {
v.pop_behavior();
Expand Down
9 changes: 3 additions & 6 deletions src/tool_behaviors/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,22 @@ pub use crate::editor::util::*;
pub use crate::editor::Editor;

// Renderer
pub use glifrenderer::constants::*;
pub use glifrenderer::points::draw_point;
pub use glifrenderer::points::UIPointType;
pub use glifrenderer::viewport::Viewport;

// Input
pub use sdl2::mouse::MouseButton;

// Util + Macros
pub use crate::util::*;
pub use crate::{get_contour, get_contour_len, get_contour_mut, is_contour_open, get_point};
pub use crate::{get_contour, get_contour_mut, get_point};

// Skia/Winit stuff
pub use skia_safe::Contains as _;
pub use skia_safe::{
Canvas, IPoint as SkIPoint, Matrix, Path as SkPath, Point as SkPoint, Rect as SkRect,
Canvas, Matrix, Point as SkPoint, Rect as SkRect,
};

pub use glifparser::{glif::MFEKGlif, Contour, Handle, Outline, Point, PointType, WhichHandle};
pub use glifparser::{glif::MFEKGlif, Handle, WhichHandle};

//User interface
pub use crate::command::CommandMod;
Expand Down
8 changes: 4 additions & 4 deletions src/tools/cut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use glifparser::glif::contour::MFEKContourCommon;
use glifrenderer::constants::{self, OUTLINE_STROKE_THICKNESS};
use kurbo::{PathSeg, QuadBez, ParamCurve};
use skia_safe::{Canvas, Paint, Path, Point};
use MFEKmath::{Piecewise, Bezier, Evaluate};
use MFEKmath::{Piecewise, Bezier};

use crate::editor::Editor;
use crate::user_interface::Interface;
Expand Down Expand Up @@ -62,12 +62,12 @@ impl Cut {
}

fn mouse_released(&mut self, v: &mut Editor, mouse_info: MouseInfo) {
let intersections = Self::find_intersections(&self.start_point, &Some(mouse_info.position.into()), v, false);
let intersections = Self::find_intersections(&self.start_point, &Some(mouse_info.position.into()), v);
Self::split_at_intersections(v, &intersections);
self.start_point = None;
}

pub fn find_intersections(start_point: &Option<(f32, f32)>, end_point: &Option<(f32, f32)>, v: &Editor, non_cubic: bool) -> Vec<Intersection> {
pub fn find_intersections(start_point: &Option<(f32, f32)>, end_point: &Option<(f32, f32)>, v: &Editor) -> Vec<Intersection> {
let mut intersections = vec![];
if start_point.is_none() || end_point.is_none() { return intersections }

Expand Down Expand Up @@ -281,7 +281,7 @@ impl Cut {
canvas.draw_path(&path, &paint);

// Draw X's at the intersections
let intersections = Self::find_intersections(&start_point, &end_point, v, true); // Assuming you have access to the editor here
let intersections = Self::find_intersections(&start_point, &end_point, v); // Assuming you have access to the editor here
for intersection in intersections {
let intersection_point = Point::new(intersection.coords.0 as f32, intersection.coords.1 as f32);

Expand Down
8 changes: 4 additions & 4 deletions src/tools/guidelines/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ lazy_static! {

impl Guidelines {
pub fn tool_dialog(&mut self, v: &mut Editor, i: &mut Interface, ui: &mut egui::Ui) {
let (mut guidelines, _, local_guidelines_len, _) = SplitGuidelines::new(v).as_tuple();
let (mut guidelines, _, _, _) = SplitGuidelines::new(v).as_tuple();

for (gidx, (guideline, is_global)) in guidelines.iter_mut().enumerate() {
ui.vertical(|ui| {
ui.horizontal(|ui| {
let (
mut guidelines,
guidelines,
_guidelines_len,
local_guidelines_len,
_global_guidelines_len,
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Guidelines {
});

let guideline_display = guideline_name.clone();
let mut im_str = guideline_display;
let im_str = guideline_display;

if !(is_global && guideline.data.as_guideline().format) {
let rb = build_and_add_icon_button::<"icons_small">(v, ui, icons::_RENAME, "Rename guideline");
Expand Down Expand Up @@ -140,7 +140,7 @@ impl Guidelines {
return;
}

let (mut at, mut angle) = {
let (at, angle) = {
let at = guidelines[selected].0.at;
let angle = guidelines[selected].0.angle.into();

Expand Down
4 changes: 0 additions & 4 deletions src/tools/measure.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use glifrenderer::constants;
use skia_safe::{Point, Color4f, Typeface, Font};

use crate::editor::Editor;
use crate::tool_behaviors::zoom_scroll::ZoomScroll;
use crate::tools::cut::{Cut, Intersection};
use crate::user_interface::Interface;

use super::prelude::*;
Expand Down
8 changes: 4 additions & 4 deletions src/tools/pap/dialog.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::super::prelude::*;
use super::PAP;
use crate::user_interface::{Interface, gui::windows::egui_parsed_textfield};
use crate::user_interface::Interface;
use glifparser::glif::contour_operations::{pap::{PatternStretch, PatternCopies, PatternSubdivide, PAPContour, PatternCulling}, ContourOperations};
use egui::Ui;

Expand Down Expand Up @@ -63,15 +63,15 @@ impl PAP {
}

data.subdivide = match data.subdivide {
PatternSubdivide::Simple(mut times) => {
PatternSubdivide::Simple(times) => {
let mut times = times as i32;
ui.add(egui::Slider::new(&mut times, 1..=10)
.text("Times")
);
PatternSubdivide::Simple(times as usize)
}

PatternSubdivide::Angle(mut angle) => {
PatternSubdivide::Angle(angle) => {
let mut angle = angle as f32;
ui.add(egui::Slider::new(&mut angle, 0.0..=90.0)
.text("Angle")
Expand Down Expand Up @@ -108,7 +108,7 @@ impl PAP {
}

data.prevent_overdraw = match data.prevent_overdraw {
PatternCulling::EraseOverlapping(mut radius, mut cull_area_percent) => {
PatternCulling::EraseOverlapping(radius, mut cull_area_percent) => {
let mut radius = radius as f32;
ui.add(egui::Slider::new(&mut radius, 0.0..=20.0)
.text("Radius")
Expand Down
4 changes: 0 additions & 4 deletions src/tools/pap/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
mod dialog;

use std::collections::HashMap;

use super::prelude::*;
use crate::tool_behaviors::zoom_scroll::ZoomScroll;
use crate::tools::Select;
Expand All @@ -10,7 +8,6 @@ use crate::editor::Editor;
#[derive(Clone, Debug)]
pub struct PAP {
pattern_layer: Option<usize>,
edit_buf: HashMap<String, String>,
select_tool: Select
}

Expand Down Expand Up @@ -48,7 +45,6 @@ impl Tool for PAP {
impl PAP {
pub fn new() -> Self {
Self {
edit_buf: HashMap::new(),
pattern_layer: None,
select_tool: Select::new()
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/pen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl Pen {
let selected_open = is_contour_open!(v.get_active_layer_ref(), c_idx);
let target_open = is_contour_open!(v.get_active_layer_ref(), info_ci);
if end_is_active && start_is_clicked && selected_open && target_open {
let point = get_contour!(v.get_active_layer_ref(), info_ci).get_point(p_idx).unwrap().clone();
let point = get_contour!(v.get_active_layer_ref(), info_ci).get_point(p_idx).unwrap();
draw_point(
&i.viewport,
point,
Expand Down
16 changes: 4 additions & 12 deletions src/tools/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@ pub use crate::editor::util::*;
pub use crate::editor::Editor;

// Util + Macros
pub use crate::util::*;
pub use crate::{get_contour, get_contour_len, get_contour_mut, is_contour_open, get_point};
pub use crate::{get_contour, get_contour_len, get_contour_mut};

// Skia/Winit stuff
pub use skia_safe::Contains as _;
pub use skia_safe::{
Canvas, IPoint as SkIPoint, Matrix, Path as SkPath, Point as SkPoint, Rect as SkRect,
Canvas, Point as SkPoint, Rect as SkRect,
};
pub use skia_safe::{Paint, PaintStyle, Path, Rect};

pub use glifparser::{Contour, Handle, Outline, Point, PointType, WhichHandle};

// std
pub use std::cell::RefCell;
pub use std::mem;
pub use skia_safe::{Paint, PaintStyle};
pub use glifparser::WhichHandle;

//UI
pub use crate::command::CommandMod;
pub use crate::user_interface::gui;
pub use crate::user_interface::{Interface, MouseInfo};
pub use egui::Ui;
pub use sdl2::mouse::MouseButton;
4 changes: 2 additions & 2 deletions src/user_interface/gui/icons/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub const _GRID: &str = "\u{F029}";
pub const GUIDELINES: &str = "\u{F030}";
pub const HYPERBEZIER: &str = "\u{F031}";
pub const QUADRATIC: &str = "\u{F032}";
pub const BSPLINE: &str = "\u{F033}";
pub const SPIRO: &str = "\u{F034}";
//pub const BSPLINE: &str = "\u{F033}";
//pub const SPIRO: &str = "\u{F034}";
pub const DASH: &str = "\u{F035}";
pub const _GLOBE: &str = "\u{F036}";
pub const _UFO: &str = "\u{F037}";
Loading

0 comments on commit 9be5e25

Please sign in to comment.