Files
wayscriber/src/toolbar_icons/controls.rs
T
devmobasa 90f37754d7 chore: delete dead code and correct stale dead_code annotations
Review-verified deletions, each confirmed unreferenced by grep and by a
clean warning-free build of both feature sets:

- assets/icons/*.svg: leftovers from the embedded-SVG era, referenced
  nowhere since the switch to procedural painters
- five toolbar_icons wrappers whose "referenced by the toolbar-gtk
  frontend only" comments were false - the GTK frontend uses
  draw_icon_pin/draw_icon_unpin directly
- the capture status channel: an Arc<Mutex<CaptureStatus>> plus
  get_status() with zero production consumers - the UI reads
  CapturePoll exclusively, and every test assertion on it duplicated
  an outcome assertion the same test already made
- is_clipboard_available ("Phase 2" scaffolding with no callers),
  resolve_damage_regions (only its own tests called it),
  invalidate_help_overlay_cache (dead, and redundant - the cache key
  already includes the style), invalidate_text_cache (exported, never
  called)

Stale annotations corrected so the compiler can resume catching real
rot: pointer-constraints fields were annotated "kept for potential
future pointer lock support" while pointer lock uses them today;
manager_available, log_dir, save_snapshot, load_snapshot, and
AUTOSAVE_HISTORY_FALLBACK_DEPTH carried allows despite live callers;
pointer press named a parameter _conn and used it four times.
2026-07-31 15:55:31 +02:00

225 lines
6.8 KiB
Rust

use cairo::Context;
use std::f64::consts::PI;
/// Draw a minus icon
pub fn draw_icon_minus(ctx: &Context, x: f64, y: f64, size: f64) {
let s = size;
let stroke = (s * 0.15).max(2.0);
ctx.set_line_width(stroke);
ctx.set_line_cap(cairo::LineCap::Round);
ctx.move_to(x + s * 0.25, y + s * 0.5);
ctx.line_to(x + s * 0.75, y + s * 0.5);
let _ = ctx.stroke();
}
/// Draw a plus icon
pub fn draw_icon_plus(ctx: &Context, x: f64, y: f64, size: f64) {
let s = size;
let stroke = (s * 0.15).max(2.0);
ctx.set_line_width(stroke);
ctx.set_line_cap(cairo::LineCap::Round);
ctx.move_to(x + s * 0.25, y + s * 0.5);
ctx.line_to(x + s * 0.75, y + s * 0.5);
let _ = ctx.stroke();
ctx.move_to(x + s * 0.5, y + s * 0.25);
ctx.line_to(x + s * 0.5, y + s * 0.75);
let _ = ctx.stroke();
}
/// Draw a "more" (three dots) icon
pub fn draw_icon_more(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_more(ctx, x, y, size);
}
/// Draw an information icon.
pub fn draw_icon_info(ctx: &Context, x: f64, y: f64, size: f64) {
let s = size;
let stroke = (s * 0.1).max(1.4);
let cx = x + s * 0.5;
let cy = y + s * 0.5;
ctx.set_line_width(stroke);
ctx.set_line_cap(cairo::LineCap::Round);
ctx.arc(cx, cy, s * 0.38, 0.0, PI * 2.0);
let _ = ctx.stroke();
ctx.arc(cx, y + s * 0.32, (s * 0.055).max(1.0), 0.0, PI * 2.0);
let _ = ctx.fill();
ctx.move_to(cx, y + s * 0.45);
ctx.line_to(cx, y + s * 0.68);
let _ = ctx.stroke();
}
/// Draw an eyedropper/color picker icon.
pub fn draw_icon_eyedropper(ctx: &Context, x: f64, y: f64, size: f64) {
let s = size;
let stroke = (s * 0.12).max(1.5);
ctx.set_line_width(stroke);
ctx.set_line_cap(cairo::LineCap::Round);
ctx.set_line_join(cairo::LineJoin::Round);
let tip_x = x + s * 0.2;
let tip_y = y + s * 0.8;
let bulb_x = x + s * 0.75;
let bulb_y = y + s * 0.25;
ctx.move_to(tip_x + s * 0.1, tip_y - s * 0.1);
ctx.line_to(bulb_x - s * 0.1, bulb_y + s * 0.1);
let _ = ctx.stroke();
ctx.move_to(tip_x, tip_y);
ctx.line_to(tip_x + s * 0.15, tip_y - s * 0.05);
ctx.line_to(tip_x + s * 0.05, tip_y - s * 0.15);
ctx.close_path();
let _ = ctx.fill();
ctx.arc(bulb_x, bulb_y, s * 0.12, 0.0, PI * 2.0);
let _ = ctx.stroke();
}
/// Draw a paste/clipboard icon
pub fn draw_icon_paste(ctx: &Context, x: f64, y: f64, size: f64) {
let s = size;
let stroke = (s * 0.1).max(1.2);
ctx.set_line_width(stroke);
ctx.set_line_cap(cairo::LineCap::Round);
ctx.set_line_join(cairo::LineJoin::Round);
// Draw clipboard outline (rounded rectangle)
let clip_x = x + s * 0.2;
let clip_y = y + s * 0.15;
let clip_w = s * 0.6;
let clip_h = s * 0.7;
let r = s * 0.08;
// Clipboard body
ctx.new_path();
ctx.arc(clip_x + clip_w - r, clip_y + r, r, -PI * 0.5, 0.0);
ctx.arc(clip_x + clip_w - r, clip_y + clip_h - r, r, 0.0, PI * 0.5);
ctx.arc(clip_x + r, clip_y + clip_h - r, r, PI * 0.5, PI);
ctx.arc(clip_x + r, clip_y + r, r, PI, PI * 1.5);
ctx.close_path();
let _ = ctx.stroke();
// Draw clip at top (small rectangle)
let tab_w = s * 0.25;
let tab_h = s * 0.12;
let tab_x = x + (s - tab_w) / 2.0;
let tab_y = y + s * 0.08;
ctx.rectangle(tab_x, tab_y, tab_w, tab_h);
let _ = ctx.fill();
// Draw lines on clipboard (content)
ctx.set_line_width(stroke * 0.8);
let line_y1 = clip_y + clip_h * 0.35;
let line_y2 = clip_y + clip_h * 0.55;
let line_y3 = clip_y + clip_h * 0.75;
let line_x1 = clip_x + s * 0.1;
let line_x2 = clip_x + clip_w - s * 0.1;
ctx.move_to(line_x1, line_y1);
ctx.line_to(line_x2, line_y1);
let _ = ctx.stroke();
ctx.move_to(line_x1, line_y2);
ctx.line_to(line_x2 - s * 0.1, line_y2);
let _ = ctx.stroke();
ctx.move_to(line_x1, line_y3);
ctx.line_to(line_x2 - s * 0.2, line_y3);
let _ = ctx.stroke();
}
/// Draw a simple board/grid icon
pub fn draw_icon_board(ctx: &Context, x: f64, y: f64, size: f64) {
let s = size;
let stroke = (s * 0.1).max(1.2);
ctx.set_line_width(stroke);
ctx.set_line_cap(cairo::LineCap::Round);
ctx.set_line_join(cairo::LineJoin::Round);
let inset = s * 0.18;
let x0 = x + inset;
let y0 = y + inset;
let w = s - inset * 2.0;
let h = s - inset * 2.0;
ctx.rectangle(x0, y0, w, h);
let _ = ctx.stroke();
ctx.move_to(x0 + w * 0.5, y0);
ctx.line_to(x0 + w * 0.5, y0 + h);
let _ = ctx.stroke();
ctx.move_to(x0, y0 + h * 0.5);
ctx.line_to(x0 + w, y0 + h * 0.5);
let _ = ctx.stroke();
}
/// Draw the toolbar drag handle.
pub fn draw_icon_drag(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_drag(ctx, x, y, size);
}
/// Draw `count` centered horizontal density bars, the layout-cycle glyph
/// family's shared geometry. The stroke is thinner than the lone minus so
/// the three-bar variant still reads at the 18px compact chrome size.
fn draw_layout_density_bars(ctx: &Context, x: f64, y: f64, size: f64, count: usize) {
let s = size;
let stroke = (s * 0.12).max(1.6);
ctx.set_line_width(stroke);
ctx.set_line_cap(cairo::LineCap::Round);
let spacing = s * 0.22;
for index in 0..count {
let offset = index as f64 - (count as f64 - 1.0) / 2.0;
let bar_y = y + s * 0.5 + offset * spacing;
ctx.move_to(x + s * 0.25, bar_y);
ctx.line_to(x + s * 0.75, bar_y);
let _ = ctx.stroke();
}
}
/// Draw the layout-cycle glyph for the Simple preset (one density bar).
pub fn draw_icon_layout_simple(ctx: &Context, x: f64, y: f64, size: f64) {
draw_layout_density_bars(ctx, x, y, size, 1);
}
/// Draw the layout-cycle glyph for the Regular preset (two density bars).
pub fn draw_icon_layout_regular(ctx: &Context, x: f64, y: f64, size: f64) {
draw_layout_density_bars(ctx, x, y, size, 2);
}
/// Draw the layout-cycle glyph for the Advanced preset (three density bars).
pub fn draw_icon_layout_advanced(ctx: &Context, x: f64, y: f64, size: f64) {
draw_layout_density_bars(ctx, x, y, size, 3);
}
pub fn draw_icon_pin(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_pin(ctx, x, y, size);
}
pub fn draw_icon_unpin(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_unpin(ctx, x, y, size);
}
pub fn draw_icon_minimize(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_minimize(ctx, x, y, size);
}
pub fn draw_icon_side_minimize(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_side_minimize(ctx, x, y, size);
}
pub fn draw_icon_restore(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_restore(ctx, x, y, size);
}
#[allow(dead_code)] // part of the complete icon family; no close action today
pub fn draw_icon_close(ctx: &Context, x: f64, y: f64, size: f64) {
super::svg::render_close(ctx, x, y, size);
}