Skip to content

Commit cd728cc

Browse files
committed
add select button
1 parent d856b26 commit cd728cc

File tree

8 files changed

+50
-15
lines changed

8 files changed

+50
-15
lines changed

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,21 @@
44
> Building from source requires Rust 1.85+.
55
> Quick start: [set it up in four steps](#quick-start).
66
7-
<details>
8-
<summary>📹 Demo Video (Click to expand)</summary>
7+
## Gallery
8+
9+
![Demo Poster](https://wayscriber.com/demo-poster-4.png)
10+
11+
![Demo Poster](https://wayscriber.com/demo-poster-2.png)
12+
13+
## Demo
914

1015
<video controls width="720" poster="https://wayscriber.com/demo-poster-4.png">
1116
<source src="https://wayscriber.com/demo.mp4" type="video/mp4">
1217
Your browser does not support the video tag. Watch here: https://wayscriber.com/demo.mp4
1318
</video>
1419

15-
</details>
16-
17-
<details>
18-
<summary>🖼️ Demo GIF (Click to expand)</summary>
19-
2020
![Demo GIF](https://wayscriber.com/demo.gif)
2121

22-
<img src="https://wayscriber.com/demo-poster-2.png" alt="Demo Poster" width="720" />
23-
24-
</details>
25-
2622
![License](https://img.shields.io/badge/license-MIT-blue.svg)
2723
![Rust](https://img.shields.io/badge/rust-1.85%2B-orange.svg)
2824

src/backend/wayland/toolbar.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,10 @@ impl ToolbarSurfaceManager {
511511
// Create top toolbar if visible
512512
if self.is_top_visible() {
513513
// Dynamic size based on mode:
514-
// - Icon mode: 580px wide (5 tools + text + clear + highlight + icons checkbox + pin/close)
514+
// - Icon mode: 610px wide (6 tools + text + clear + highlight + icons checkbox + pin/close)
515515
// 80px tall (42px buttons at y=6, fill toggle below, tooltip space)
516-
// - Text mode: 680px wide (text labels need more space), 56px tall (no tooltips)
517-
let target_size = if use_icons { (580, 80) } else { (680, 56) };
516+
// - Text mode: 720px wide (text labels need more space), 56px tall (no tooltips)
517+
let target_size = if use_icons { (610, 80) } else { (720, 56) };
518518

519519
// Recreate if size changed
520520
if self.top.logical_size != (0, 0) && self.top.logical_size != target_size {
@@ -692,6 +692,7 @@ fn render_top_strip(
692692
// Tool definitions with icons and labels
693693
type IconFn = fn(&cairo::Context, f64, f64, f64);
694694
let buttons: &[(Tool, IconFn, &str)] = &[
695+
(Tool::Select, toolbar_icons::draw_icon_select as IconFn, "Select"),
695696
(Tool::Pen, toolbar_icons::draw_icon_pen as IconFn, "Pen"),
696697
(Tool::Line, toolbar_icons::draw_icon_line as IconFn, "Line"),
697698
(Tool::Rect, toolbar_icons::draw_icon_rect as IconFn, "Rect"),

src/backend/wayland/toolbar_icons.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@
55
use cairo::Context;
66
use std::f64::consts::PI;
77

8+
/// Draw a cursor/select icon (arrow pointer)
9+
pub fn draw_icon_select(ctx: &Context, x: f64, y: f64, size: f64) {
10+
let s = size;
11+
let stroke = (s * 0.08).max(1.5);
12+
ctx.set_line_width(stroke);
13+
ctx.set_line_cap(cairo::LineCap::Round);
14+
ctx.set_line_join(cairo::LineJoin::Round);
15+
16+
// Classic cursor arrow shape
17+
let start_x = x + s * 0.2;
18+
let start_y = y + s * 0.15;
19+
let height = s * 0.65;
20+
let mid_y = start_y + height * 0.6;
21+
22+
// Outer path (filled)
23+
ctx.move_to(start_x, start_y);
24+
ctx.line_to(start_x, start_y + height);
25+
ctx.line_to(start_x + s * 0.2, mid_y);
26+
ctx.line_to(start_x + s * 0.35, start_y + height * 0.85);
27+
ctx.line_to(start_x + s * 0.45, start_y + height * 0.75);
28+
ctx.line_to(start_x + s * 0.3, mid_y - s * 0.1);
29+
ctx.line_to(start_x + s * 0.5, start_y + s * 0.1);
30+
ctx.close_path();
31+
32+
let _ = ctx.fill_preserve();
33+
let _ = ctx.stroke();
34+
}
35+
836
/// Draw a pen/freehand icon (pencil with wavy stroke)
937
pub fn draw_icon_pen(ctx: &Context, x: f64, y: f64, size: f64) {
1038
let s = size;

src/input/state/core/dirty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ impl InputState {
7878
self.arrow_angle,
7979
),
8080
Tool::Highlight => None,
81+
Tool::Select => None,
8182
}
8283
} else {
8384
None

src/input/state/mouse.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl InputState {
108108
}
109109

110110
let tool = self.active_tool();
111-
if tool != Tool::Highlight {
111+
if tool != Tool::Highlight && tool != Tool::Select {
112112
self.state = DrawingState::Drawing {
113113
tool,
114114
start_x: x,
@@ -300,6 +300,10 @@ impl InputState {
300300
self.clear_provisional_dirty();
301301
return;
302302
}
303+
Tool::Select => {
304+
self.clear_provisional_dirty();
305+
return;
306+
}
303307
};
304308

305309
let bounds = shape.bounding_box();

src/input/state/render.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl InputState {
9090
arrow_angle: self.arrow_angle,
9191
}),
9292
Tool::Highlight => None,
93+
Tool::Select => None,
9394
// No provisional shape for other tools
9495
}
9596
} else {

src/input/tool.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
/// Tools are selected by holding modifier keys (Shift, Ctrl, Tab) while dragging.
77
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
88
pub enum Tool {
9+
/// Select/cursor tool - interact with UI without drawing
10+
Select,
911
/// Freehand drawing - follows mouse path (default, no modifiers)
1012
Pen,
1113
/// Straight line - between start and end points (Shift)

src/ui.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub fn render_status_bar(
7575
let tool_name = match &input_state.state {
7676
DrawingState::TextInput { .. } => "Text",
7777
DrawingState::Drawing { tool, .. } => match tool {
78+
Tool::Select => "Select",
7879
Tool::Pen => "Pen",
7980
Tool::Line => "Line",
8081
Tool::Rect => "Rectangle",
@@ -84,6 +85,7 @@ pub fn render_status_bar(
8485
},
8586
DrawingState::MovingSelection { .. } => "Move",
8687
DrawingState::Idle => match tool {
88+
Tool::Select => "Select",
8789
Tool::Pen => "Pen",
8890
Tool::Line => "Line",
8991
Tool::Rect => "Rectangle",

0 commit comments

Comments
 (0)