Skip to content

Phase 2: Implement all indicator styles with animations #25

@poodle64

Description

@poodle64

Overview

Implement native window creation and feature parity with existing WebView indicator using platform-specific APIs (not winit).

Architectural Decision

After Phase 1, we discovered that winit 0.30 requires EventLoop on the main thread, conflicting with Tauri's architecture. Solution: Use platform-specific window APIs directly (industry standard for overlays like Discord, Zoom, OBS).

Tasks

macOS Implementation (Priority)

  • Create NSWindow using objc2-app-kit (borderless, always-on-top)
  • Implement window positioning (top-centre, cursor-dot, fixed)
  • Blit SoftwareRenderer pixmap to NSWindow graphics context
  • Add waveform animation with circular buffer (32 samples)
  • Implement all three indicator styles (pill, cursor-dot, fixed-float)
  • Add pulsing/glow effects based on audio level
  • Microphone icon rendering
  • Smooth audio level transitions
  • Window lifecycle management (show/hide/position updates)

Cross-Platform Strategy

  • macOS: NSWindow via objc2 (this phase)
  • Windows: Defer to Phase 3 or keep WebView fallback
  • Linux: Defer to Phase 3 or keep WebView fallback

Technical Approach

// No event loop needed - just create window and blit to it
unsafe {
    let window = NSWindow::alloc()
        .initWithContentRect_styleMask_backing_defer(
            rect,
            NSWindowStyleMask::Borderless,
            NSBackingStoreType::Buffered,
            false
        );
    window.setLevel(NSWindowLevel::ScreenSaver);
    window.setBackgroundColor(NSColor::clearColor());
    
    // Blit pixmap from SoftwareRenderer
    let context = window.graphicsContext();
    // ... render pixmap data to context
}

Acceptance Criteria

  • All three indicator styles work on macOS
  • Waveform animates smoothly at ~30fps
  • Cursor-dot follows mouse cursor
  • Pill positions at top-centre of active screen
  • Fixed-float respects configured position
  • Visual quality matches or exceeds current WebView version
  • <1% CPU usage
  • <50ms show latency

Dependencies

Estimated Effort

Large (12-16 hours) - increased due to platform-specific implementation

References

  • Existing WebView implementation: src/routes/(indicator)/recording-indicator/+page.svelte
  • SoftwareRenderer from Phase 1: src-tauri/src/recording_indicator/native.rs
  • macOS window APIs: objc2-app-kit NSWindow documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions