Skip to content

Commit

Permalink
feat: Annotation Support 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
decipher3114 committed Oct 1, 2024
1 parent 8ec929a commit 088fa3b
Show file tree
Hide file tree
Showing 28 changed files with 831 additions and 606 deletions.
245 changes: 7 additions & 238 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ build = "build.rs"
active-win-pos-rs = "0.8"
arboard = { version = "3.4", features = ["wayland-data-control", "wl-clipboard-rs"] }
chrono = "0.4"
display-info = { version = "0.5"}
iced = { version = "0.13", features = ["advanced", "canvas", "multi-window", "image", "tokio", "svg"] }
iced = { version = "0.13", features = ["advanced", "canvas", "multi-window", "image", "tokio"] }
iced_anim = { version = "0.1", features = ["derive", "serde"] }
interprocess = { version = "2.2", features = ["tokio"] }
rdev = { git = "https://github.com/rustdesk-org/rdev", branch = "master"}
rfd = { version = "0.14", features = ["gtk3", "tokio"], default-features = false }
serde = { version = "1.0", features = ["derive"] }
tiny-skia = "0.11"
tokio = { version = "1.39", features = ["full", "rt"] }
toml = "0.8"
tray-icon = "0.17"
Expand Down
Binary file added assets/fonts/icons.ttf
Binary file not shown.
1 change: 0 additions & 1 deletion assets/icons/folder-open.svg

This file was deleted.

28 changes: 26 additions & 2 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pub const FONT_MEDIUM: &[u8; 86616] = include_bytes!("../assets/fonts/SpaceGrote

pub const FONT_BOLD: &[u8; 86520] = include_bytes!("../assets/fonts/SpaceGrotesk-Bold.ttf");

pub const ICON: &[u8; 1358] = include_bytes!("../assets/icons/icon.png");
pub const FONT_ICONS: &[u8; 2168] = include_bytes!("../assets/fonts/icons.ttf");

pub const SVG_FOLDER_OPEN: &[u8; 653] = include_bytes!("../assets/icons/folder-open.svg");
pub const APPICON: &[u8; 1358] = include_bytes!("../assets/icons/icon.png");

use iced::Font;

Expand All @@ -23,3 +23,27 @@ pub const BOLD: Font = Font {
stretch: iced::font::Stretch::Normal,
style: iced::font::Style::Normal,
};

pub const ICON: Font = Font::with_name("icomoon");

pub const FOLDER_ICON: char = '\u{E901}';

pub const CANCEL: char = '\u{E902}';

pub const DONE: char = '\u{E903}';

pub const RECT_FILLED: char = '\u{E904}';

pub const RECT_STROKE: char = '\u{E905}';

pub const ELLIPSE_FILLED: char = '\u{E906}';

pub const ELLIPSE_STROKE: char = '\u{E907}';

pub const LINE: char = '\u{E908}';

pub const STROKE_THIN: char = '\u{E909}';

pub const STROKE_MEDIUM: char = '\u{E910}';

pub const STROKE_BROAD: char = '\u{E911}';
7 changes: 5 additions & 2 deletions src/entities/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use iced::window::Id;
use tray_icon::TrayIcon;

use crate::entities::{
config::{Config, ConfigEvent},
capture::CaptureEvent,
config::{Config, ConfigEvent},
window::WindowType,
};

Expand All @@ -20,10 +20,13 @@ pub enum AppEvent {
OpenConfigureWindow,
OpenDirectory,
UpdateDirectory(Id),
GetScaleFactor(Id, f32),
OpenCaptureWindow,
CaptureFullscreen,
CaptureWindow,
CloseWindow,
Done,
Cancel,
RequestClose,
WindowClosed(Id),
ExitApp,
Config(Id, ConfigEvent),
Expand Down
22 changes: 0 additions & 22 deletions src/entities/capture.rs

This file was deleted.

41 changes: 41 additions & 0 deletions src/entities/capture/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use iced::{widget::canvas, Point};
use shape::{Shape, ShapeColor, ShapeStroke, ShapeType};
use xcap::image::RgbaImage;

pub mod shape;

pub struct CaptureWindow {
pub cursor_position: Point,
pub image: RgbaImage,
pub scale_factor: f32,
pub mode: Mode,
pub shape: Shape,
pub endpoints: Endpoints,
pub shapes: Vec<Shape>,
pub cache: canvas::Cache,
}

#[derive(Debug, Clone)]
pub enum CaptureEvent {
Cancel,
Done,
ChooseShapeType(ShapeType, bool),
ChangeStroke(ShapeStroke),
ChangeColor(ShapeColor),
SetInitialPoint,
UpdateCurrentPosition(Point),
SetFinalPoint,
}

#[derive(Debug, Default, Clone, Copy)]
pub struct Endpoints {
pub initial_pt: Option<Point>,
pub final_pt: Option<Point>,
}

#[derive(Debug, Default, PartialEq)]
pub enum Mode {
Draw,
#[default]
Crop,
}
37 changes: 37 additions & 0 deletions src/entities/capture/shape.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use super::Endpoints;

#[derive(Debug, Default, Clone, Copy)]
pub struct Shape {
pub shape_type: ShapeType,
pub endpoints: Endpoints,
pub color: ShapeColor,
pub is_filled: bool,
pub stroke_width: ShapeStroke,
}

#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub enum ShapeType {
#[default]
Rectangle,
Ellipse,
Line,
}

#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub enum ShapeColor {
#[default]
Red,
Green,
Blue,
Yellow,
Black,
White,
}

#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub enum ShapeStroke {
Thin,
#[default]
Medium,
Broad,
}
2 changes: 1 addition & 1 deletion src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod app;
pub mod config;
pub mod capture;
pub mod config;
pub mod style;
pub mod theme;
pub mod window;
10 changes: 7 additions & 3 deletions src/entities/style.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use iced::Color;

pub struct ContainerClass;

pub enum ButtonClass {
Default,
Danger,
Selected,
}

pub struct TextClass;

pub struct SvgClass;
pub enum TextClass {
Default,
Custom(Color),
}
2 changes: 2 additions & 0 deletions src/entities/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct Palette {
pub text: Color,
pub primary: Color,
pub secondary: Color,
pub active_primary: Color,
pub active_secondary: Color,
pub danger_primary: Color,
pub danger_secondary: Color,
}
3 changes: 1 addition & 2 deletions src/entities/window.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::entities::{config::ConfigureWindow, capture::CaptureWindow};
use crate::entities::{capture::CaptureWindow, config::ConfigureWindow};

#[derive(Debug)]
pub enum WindowType {
Configure(ConfigureWindow),
Capture(CaptureWindow),
Expand Down
Loading

0 comments on commit 088fa3b

Please sign in to comment.