Skip to content

Commit

Permalink
removed parts and reference APP_CONFIG directly
Browse files Browse the repository at this point in the history
  • Loading branch information
schaumtier committed Dec 19, 2024
1 parent 37f002a commit fba26a1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
9 changes: 0 additions & 9 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ pub struct Style {
pub fill: bool,
}

#[derive(Clone, Copy, Debug, Default)]
pub struct Properties {}

#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Color {
pub r: u8,
Expand Down Expand Up @@ -179,12 +176,6 @@ impl FromVariant for Size {
}
}

impl Properties {
pub fn corner_roundness() -> f32 {
return APP_CONFIG.read().corner_roundness();
}
}

impl Size {
pub fn to_text_size(self) -> i32 {
let size_factor = APP_CONFIG.read().annotation_size_factor();
Expand Down
13 changes: 10 additions & 3 deletions src/tools/blur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use femtovg::{imgref::Img, Color, ImageFilter, ImageFlags, ImageId, Paint, Path}
use relm4::gtk::gdk::Key;

use crate::{
configuration::APP_CONFIG,
math::{self, Vec2D},
sketch_board::{MouseEventMsg, MouseEventType},
style::{Properties, Size, Style},
style::{Size, Style},
};

use super::{Drawable, DrawableClone, Tool, ToolUpdateResult};
Expand Down Expand Up @@ -84,7 +85,7 @@ impl Drawable for Blur {
self.top_left.y,
size.x,
size.y,
Properties::corner_roundness(),
APP_CONFIG.read().corner_roundness(),
);

// draw
Expand All @@ -103,7 +104,13 @@ impl Drawable for Blur {
}

let mut path = Path::new();
path.rounded_rect(pos.x, pos.y, size.x, size.y, Properties::corner_roundness());
path.rounded_rect(
pos.x,
pos.y,
size.x,
size.y,
APP_CONFIG.read().corner_roundness(),
);

canvas.fill_path(
&path,
Expand Down
10 changes: 8 additions & 2 deletions src/tools/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
configuration::APP_CONFIG,
math::{self, Vec2D},
sketch_board::{MouseEventMsg, MouseEventType},
style::{Properties, Style},
style::Style,
tools::DrawableClone,
};

Expand Down Expand Up @@ -99,7 +99,13 @@ impl Highlight for Highlighter<BlockHighlight> {
let (pos, size) = math::rect_ensure_positive_size(self.data.top_left, size);

let mut shadow_path = Path::new();
shadow_path.rounded_rect(pos.x, pos.y, size.x, size.y, Properties::corner_roundness());
shadow_path.rounded_rect(
pos.x,
pos.y,
size.x,
size.y,
APP_CONFIG.read().corner_roundness(),
);

let shadow_paint = Paint::color(femtovg::Color::rgba(
self.style.color.r,
Expand Down
5 changes: 3 additions & 2 deletions src/tools/rectangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use femtovg::{FontId, Path};
use relm4::gtk::gdk::{Key, ModifierType};

use crate::{
configuration::APP_CONFIG,
math::Vec2D,
sketch_board::{MouseEventMsg, MouseEventType},
style::{Properties, Style},
style::Style,
};

use super::{Drawable, DrawableClone, Tool, ToolUpdateResult};
Expand Down Expand Up @@ -35,7 +36,7 @@ impl Drawable for Rectangle {
self.top_left.y,
size.x,
size.y,
Properties::corner_roundness(),
APP_CONFIG.read().corner_roundness(),
);

if self.style.fill {
Expand Down

0 comments on commit fba26a1

Please sign in to comment.