Clean up build warnings

Resolve all compiler warnings across daw-backend, lightningbeam-core, and
lightningbeam-editor:

- Delete dead code: the superseded CPU raster tools in raster_tool.rs
  (EffectBrush/Smudge/Gradient/Transform/Warp/Liquify/Selection — replaced by
  the GPU path), plus orphaned helpers and never-read struct fields.
- Mechanical fixes: drop unused imports/variables/mut, underscore unused params,
  `drop(&x)` -> `let _ = x`, deprecated egui::Rounding -> CornerRadius, snake_case
  rename, elided-lifetime Cow<'_, [u8]>.
- Keep the WIP CSS theming system (theme.rs/theme_render.rs) under
  #[allow(dead_code)] rather than deleting it.

Editor checks warning-free; 293 core tests pass.
This commit is contained in:
Skyler Lehmkuhl
2026-06-21 16:48:59 -04:00
parent 3c3a482e2e
commit 83057b754a
18 changed files with 30 additions and 715 deletions
@@ -238,7 +238,7 @@ pub fn gradient_stop_editor(
// ── Paint handles ─────────────────────────────────────────────────────
// handle_rects was built before any deletions this frame; guard against OOB.
for (i, h_rect) in handle_rects.iter().enumerate().take(gradient.stops.len()) {
let col = ShapeColor_to_Color32(gradient.stops[i].color);
let col = shape_color_to_color32(gradient.stops[i].color);
let is_selected = *selected_stop == Some(i);
let stroke = Stroke::new(
if is_selected { 2.0 } else { 1.0 },
@@ -308,7 +308,7 @@ pub fn gradient_stop_editor(
// ── Helpers ──────────────────────────────────────────────────────────────────
fn ShapeColor_to_Color32(c: ShapeColor) -> Color32 {
fn shape_color_to_color32(c: ShapeColor) -> Color32 {
Color32::from_rgba_unmultiplied(c.r, c.g, c.b, c.a)
}
@@ -11,7 +11,7 @@
/// - Document settings (when nothing is focused)
use eframe::egui::{self, DragValue, Ui};
use lightningbeam_core::brush_settings::{bundled_brushes, BrushSettings};
use lightningbeam_core::brush_settings::bundled_brushes;
use lightningbeam_core::actions::{SetDocumentPropertiesAction, SetShapePropertiesAction, SetFillPaintAction, SetImageFillAction};
use lightningbeam_core::gradient::ShapeGradient;
use lightningbeam_core::layer::{AnyLayer, LayerTrait};
@@ -1439,40 +1439,6 @@ impl InfopanelPane {
}
}
/// Draw a brush dab preview into `rect` approximating the brush falloff shape.
///
/// Renders N concentric filled circles from outermost to innermost. Because each
/// inner circle overwrites the pixels of all outer circles beneath it, the visible
/// alpha at distance `d` from the centre equals the alpha of the innermost circle
/// whose radius ≥ `d`. This step-approximates the actual brush falloff formula:
/// `opa = ((1 − r) / (1 − hardness))²` for `r > hardness`, 1 inside the hard core.
fn paint_brush_dab(painter: &egui::Painter, rect: egui::Rect, s: &BrushSettings) {
let center = rect.center();
let max_r = (rect.width().min(rect.height()) / 2.0 - 2.0).max(1.0);
let h = s.hardness;
let a = s.opaque;
const N: usize = 12;
for i in 0..N {
// t: normalized radial position of this ring, 1.0 = outermost edge
let t = 1.0 - i as f32 / N as f32;
let r = max_r * t;
let opa_weight = if h >= 1.0 || t <= h {
1.0f32
} else {
let x = (1.0 - t) / (1.0 - h).max(1e-4);
(x * x).min(1.0)
};
let alpha = (opa_weight * a * 220.0).min(220.0) as u8;
painter.circle_filled(
center, r,
egui::Color32::from_rgba_unmultiplied(200, 200, 220, alpha),
);
}
}
/// Convert MIDI note number to note name (e.g. 60 -> "C4")
fn midi_note_name(note: u8) -> String {
const NAMES: [&str; 12] = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
@@ -342,9 +342,6 @@ pub struct SharedPaneState<'a> {
pub clipboard_consumed: &'a mut bool,
/// Remappable keyboard shortcut manager
pub keymap: &'a crate::keymap::KeymapManager,
/// Set by raster selection tools when they need main to commit the floating
/// selection before starting a new interaction.
pub commit_raster_floating_if_any: &'a mut bool,
/// Set by MenuAction::Group when focus is Nodes — consumed by node graph pane
pub pending_node_group: &'a mut bool,
/// Set by MenuAction::Group (ungroup variant) when focus is Nodes — consumed by node graph pane
@@ -240,12 +240,6 @@ impl PianoRollPane {
matches!(note % 12, 1 | 3 | 6 | 8 | 10)
}
fn note_name(note: u8) -> String {
let names = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
let octave = (note / 12) as i32 - 1;
format!("{}{}", names[note as usize % 12], octave)
}
// ── Note resolution ──────────────────────────────────────────────────
fn resolve_notes(events: &[daw_backend::audio::midi::MidiEvent]) -> Vec<ResolvedNote> {
@@ -736,45 +730,6 @@ impl PianoRollPane {
}
}
/// Generate pitch bend MIDI events for a note based on the zone and target semitones.
fn generate_pitch_bend_events(
note_start: f64,
note_duration: f64,
zone: PitchBendZone,
semitones: f32,
channel: u8,
pitch_bend_range: f32,
) -> Vec<daw_backend::audio::midi::MidiEvent> {
use daw_backend::audio::midi::MidiEvent;
let num_steps: usize = 128;
let mut events = Vec::new();
let encode_bend = |normalized: f32| -> (u8, u8) {
let value_14 = (normalized * 8191.0 + 8192.0).clamp(0.0, 16383.0) as i16;
((value_14 & 0x7F) as u8, ((value_14 >> 7) & 0x7F) as u8)
};
// Use t directly (0..=1 across the full note) — same formula as the visual ghost.
// Start: peak → 0 (ramps down over full note)
// Middle: 0 → peak → 0 (sine arch, peaks at center)
// End: 0 → peak (ramps up over full note)
for i in 0..=num_steps {
let t = i as f64 / num_steps as f64;
let t_f32 = t as f32;
// Cosine ease curves: Start+End at equal value = perfectly flat (partition of unity).
// Start: (1+cos(πt))/2 — peaks at t=0, smooth decay to 0 at t=1
// End: (1-cos(πt))/2 — 0 at t=0, smooth rise to peak at t=1
// Middle: sin(πt) — arch peaking at t=0.5
let normalized = match zone {
PitchBendZone::Start => semitones / pitch_bend_range * (1.0 + (std::f32::consts::PI * t_f32).cos()) * 0.5,
PitchBendZone::Middle => semitones / pitch_bend_range * (std::f32::consts::PI * t_f32).sin(),
PitchBendZone::End => semitones / pitch_bend_range * (1.0 - (std::f32::consts::PI * t_f32).cos()) * 0.5,
};
let timestamp = note_start + t * note_duration;
let (lsb, msb) = encode_bend(normalized);
events.push(MidiEvent::new(daw_backend::Beats(timestamp), 0xE0 | channel, lsb, msb));
}
events
}
/// Find the lowest available MIDI channel (1–15) not already used by any note
/// overlapping [note_start, note_end], excluding the note being assigned itself.
/// Returns the note's current channel unchanged if it is already uniquely assigned (non-zero).
@@ -2408,7 +2363,7 @@ impl PaneRenderer for PianoRollPane {
let doc = shared.action_executor.document();
let is_measures = doc.timeline_mode == lightningbeam_core::document::TimelineMode::Measures;
let tempo_map = doc.tempo_map();
drop(doc);
let _ = doc;
if is_measures {
// Auto-detect grid when selection changes
@@ -682,17 +682,13 @@ impl egui_wgpu::CallbackTrait for VelloCallback {
if let Some(b_id) = self.ctx.pending_tool_readback_b {
if let Ok(mut gpu_brush) = shared.gpu_brush.lock() {
let dims = gpu_brush.canvases.get(&b_id).map(|c| (c.width, c.height));
if let Some((w, h)) = dims {
if let Some((_w, _h)) = dims {
if let Some(pixels) = gpu_brush.readback_canvas(device, queue, b_id) {
let results = RASTER_READBACK_RESULTS.get_or_init(|| {
Arc::new(Mutex::new(std::collections::HashMap::new()))
});
if let Ok(mut map) = results.lock() {
map.insert(self.ctx.instance_id_for_readback, RasterReadbackResult {
layer_id: uuid::Uuid::nil(), // unused; routing via pending_undo_before
time: 0.0,
canvas_width: w,
canvas_height: h,
pixels,
});
}
@@ -763,10 +759,6 @@ impl egui_wgpu::CallbackTrait for VelloCallback {
});
if let Ok(mut map) = results.lock() {
map.insert(self.ctx.instance_id_for_readback, RasterReadbackResult {
layer_id: pending.layer_id,
time: pending.time,
canvas_width: pending.canvas_width,
canvas_height: pending.canvas_height,
pixels,
});
}
@@ -3173,7 +3165,6 @@ enum PendingWarpOp {
disp_data: Option<Vec<[f32; 2]>>,
grid_cols: u32,
grid_rows: u32,
w: u32, h: u32,
final_commit: bool,
layer_id: uuid::Uuid,
time: f64,
@@ -3190,7 +3181,6 @@ enum PendingWarpOp {
anchor_canvas_id: uuid::Uuid,
disp_buf_id: uuid::Uuid,
display_canvas_id: uuid::Uuid,
w: u32, h: u32,
final_commit: bool,
layer_id: uuid::Uuid,
time: f64,
@@ -3251,10 +3241,6 @@ static EYEDROPPER_RESULTS: OnceLock<Arc<Mutex<std::collections::HashMap<u64, (eg
struct PendingRasterDabs {
/// Keyframe UUID — indexes the canvas texture pair in `GpuBrushEngine`.
keyframe_id: uuid::Uuid,
/// Layer UUID — used for the undo readback result.
layer_id: uuid::Uuid,
/// Playback time of the keyframe.
time: f64,
/// Canvas dimensions (pixels).
canvas_width: u32,
canvas_height: u32,
@@ -3379,10 +3365,6 @@ static TRANSFORM_READBACK_RESULTS: OnceLock<Arc<Mutex<std::collections::HashMap<
/// Result stored by `prepare()` after a stroke-end readback.
struct RasterReadbackResult {
layer_id: uuid::Uuid,
time: f64,
canvas_width: u32,
canvas_height: u32,
/// Raw RGBA pixels from the completed stroke.
pixels: Vec<u8>,
}
@@ -4201,7 +4183,7 @@ impl StagePane {
// Update connected edges: shift the adjacent control point by the same delta
for &edge_id in &connected_edges {
let [v0, v1] = graph.edge(edge_id).vertices;
let [v0, _v1] = graph.edge(edge_id).vertices;
let mut curve = graph.edge(edge_id).curve;
if v0 == vertex_id {
@@ -5609,58 +5591,6 @@ impl StagePane {
}
}
/// Lift the pixels enclosed by the current `raster_selection` into a
/// `RasterFloatingSelection`, punching a transparent hole in `raw_pixels`.
///
/// Call this immediately after a marquee / lasso selection is finalized so
/// that all downstream operations (drag-move, copy, cut, stroke-masking)
/// see a consistent `raster_floating` whenever a selection is active.
/// Build an R8 mask buffer (0 = outside, 255 = inside) from a selection.
fn build_selection_mask(
sel: &lightningbeam_core::selection::RasterSelection,
width: u32,
height: u32,
) -> Vec<u8> {
let mut mask = vec![0u8; (width * height) as usize];
let (x0, y0, x1, y1) = sel.bounding_rect();
let bx0 = x0.max(0) as u32;
let by0 = y0.max(0) as u32;
let bx1 = (x1 as u32).min(width);
let by1 = (y1 as u32).min(height);
for y in by0..by1 {
for x in bx0..bx1 {
if sel.contains_pixel(x as i32, y as i32) {
mask[(y * width + x) as usize] = 255;
}
}
}
mask
}
/// Build an R8 mask buffer for the float canvas (0 = outside selection, 255 = inside).
/// Coordinates are in float-local space: pixel (fx, fy) corresponds to document pixel
/// (float_x+fx, float_y+fy).
fn build_float_mask(
sel: &lightningbeam_core::selection::RasterSelection,
float_x: i32, float_y: i32,
float_w: u32, float_h: u32,
) -> Vec<u8> {
let mut mask = vec![0u8; (float_w * float_h) as usize];
let (x0, y0, x1, y1) = sel.bounding_rect();
let bx0 = (x0 - float_x).max(0) as u32;
let by0 = (y0 - float_y).max(0) as u32;
let bx1 = ((x1 - float_x) as u32).min(float_w);
let by1 = ((y1 - float_y) as u32).min(float_h);
for fy in by0..by1 {
for fx in bx0..bx1 {
if sel.contains_pixel(float_x + fx as i32, float_y + fy as i32) {
mask[(fy * float_w + fx) as usize] = 255;
}
}
}
mask
}
/// Allocate the three A/B/C GPU canvases and build a [`crate::raster_tool::RasterWorkspace`]
/// for a new raster tool operation.
///
@@ -5699,7 +5629,6 @@ impl StagePane {
a_canvas_id: a_id,
b_canvas_id: b_id,
c_canvas_id: c_id,
mask_texture: None,
width: w,
height: h,
x,
@@ -5724,7 +5653,7 @@ impl StagePane {
let layer_id = (*shared.active_layer_id)?;
let time = *shared.playback_time;
let (doc_w, doc_h) = {
let (_doc_w, _doc_h) = {
let doc = shared.action_executor.document();
(doc.width as u32, doc.height as u32)
};
@@ -5733,7 +5662,7 @@ impl StagePane {
// returns None (no workspace) if there's no active keyframe to lift from.
// Read keyframe id and pixels.
let (kf_id, w, h, pixels) = {
let (_kf_id, w, h, pixels) = {
let doc = shared.action_executor.document();
let AnyLayer::Raster(rl) = doc.get_layer(&layer_id)? else { return None };
let kf = rl.keyframe_at(time)?;
@@ -5753,7 +5682,6 @@ impl StagePane {
a_canvas_id: a_id,
b_canvas_id: b_id,
c_canvas_id: c_id,
mask_texture: None,
width: w,
height: h,
x: 0,
@@ -5761,9 +5689,6 @@ impl StagePane {
source: WorkspaceSource::Layer {
layer_id,
time,
kf_id,
canvas_w: doc_w,
canvas_h: doc_h,
},
before_pixels: pixels.clone(),
};
@@ -6135,8 +6060,6 @@ impl StagePane {
));
self.pending_raster_dabs = Some(PendingRasterDabs {
keyframe_id: canvas_id,
layer_id,
time,
canvas_width,
canvas_height,
initial_pixels: None, // canvas already initialized via lazy GPU init
@@ -6220,8 +6143,6 @@ impl StagePane {
));
self.pending_raster_dabs = Some(PendingRasterDabs {
keyframe_id,
layer_id: active_layer_id,
time: kf_time,
canvas_width,
canvas_height,
initial_pixels: Some(initial_pixels),
@@ -6299,8 +6220,6 @@ impl StagePane {
let (dabs, dab_bbox) = BrushEngine::compute_dabs(&seg, stroke_state, dt);
self.pending_raster_dabs = Some(PendingRasterDabs {
keyframe_id: canvas_id,
layer_id,
time,
canvas_width: cw,
canvas_height: ch,
initial_pixels: None,
@@ -6363,8 +6282,6 @@ impl StagePane {
if !dabs.is_empty() {
self.pending_raster_dabs = Some(PendingRasterDabs {
keyframe_id: canvas_id,
layer_id,
time,
canvas_width: cw,
canvas_height: ch,
initial_pixels: None,
@@ -6424,8 +6341,6 @@ impl StagePane {
if let Some(kf_id) = kf_id {
self.pending_raster_dabs = Some(PendingRasterDabs {
keyframe_id: kf_id,
layer_id: ub_layer,
time: ub_time,
canvas_width: ub_cw,
canvas_height: ub_ch,
initial_pixels: None,
@@ -6941,7 +6856,7 @@ impl StagePane {
fn handle_quick_select_tool(
&mut self,
ui: &mut egui::Ui,
_ui: &mut egui::Ui,
response: &egui::Response,
world_pos: egui::Vec2,
shared: &mut SharedPaneState,
@@ -8431,7 +8346,6 @@ impl StagePane {
world_pos: egui::Vec2,
shared: &mut SharedPaneState,
) {
use lightningbeam_core::tool::Tool;
use uuid::Uuid;
// Ensure we're on a raster layer.
@@ -8469,7 +8383,6 @@ impl StagePane {
disp_data: Some(disp_data),
grid_cols: ws.grid_cols,
grid_rows: ws.grid_rows,
w: ws.anchor_w, h: ws.anchor_h,
final_commit: true,
layer_id: ws.layer_id,
time: ws.time,
@@ -8695,7 +8608,6 @@ impl StagePane {
disp_data: Some(disp_data),
grid_cols: ws.grid_cols,
grid_rows: ws.grid_rows,
w: ws.anchor_w, h: ws.anchor_h,
final_commit: false,
layer_id: ws.layer_id,
time: ws.time,
@@ -8705,7 +8617,7 @@ impl StagePane {
None
};
let (ws_layer_id, ws_display_id, ws_float_offset) = (ws.layer_id, ws.display_canvas_id, ws.float_offset);
drop(ws); // release borrow of warp_state
let _ = ws; // release borrow of warp_state
// Display canvas is initialised by Init (zero-displacement apply), so it always
// has valid content. For full-layer warp, override the layer blit unconditionally.
@@ -8778,7 +8690,6 @@ impl StagePane {
anchor_canvas_id: ls.anchor_canvas_id,
disp_buf_id: ls.disp_buf_id,
display_canvas_id: ls.display_canvas_id,
w: ls.anchor_w, h: ls.anchor_h,
final_commit: true,
layer_id: ls.layer_id,
time: ls.time,
@@ -8950,7 +8861,6 @@ impl StagePane {
anchor_canvas_id: anchor_id,
disp_buf_id: disp_buf,
display_canvas_id: display_id,
w, h,
final_commit: false,
layer_id: ls_layer_id,
time,
@@ -9013,7 +8923,7 @@ impl StagePane {
} else { None }
} else { None }
} else { None };
drop(doc);
let _ = doc;
r
} else { None };
@@ -10706,7 +10616,6 @@ impl StagePane {
// Alt+click: set source point for clone/healing tools.
{
use lightningbeam_core::tool::Tool;
let tool_uses_alt = crate::tools::raster_tool_def(shared.selected_tool)
.map_or(false, |d| d.uses_alt_click());
if tool_uses_alt
@@ -11602,7 +11511,6 @@ impl PaneRenderer for StagePane {
disp_data: Some(disp_data),
grid_cols: ws.grid_cols,
grid_rows: ws.grid_rows,
w: ws.anchor_w, h: ws.anchor_h,
final_commit: true,
layer_id: ws.layer_id,
time: ws.time,
@@ -11623,7 +11531,6 @@ impl PaneRenderer for StagePane {
anchor_canvas_id: ls.anchor_canvas_id,
disp_buf_id: ls.disp_buf_id,
display_canvas_id: ls.display_canvas_id,
w: ls.anchor_w, h: ls.anchor_h,
final_commit: true,
layer_id: ls.layer_id,
time: ls.time,
@@ -483,7 +483,6 @@ struct AutomationLaneRender {
value_max: f32,
accent_color: egui::Color32,
playback_time: f64,
kind: AutomationLaneKind,
}
/// Pending automation keyframe edit action from curve lane interaction
@@ -1160,7 +1159,7 @@ impl TimelinePane {
*shared.recording_clips.get(&layer_id).unwrap_or(&0), daw_backend::Beats::ZERO);
let doc_clip_id = shared.action_executor.document_mut().add_audio_clip(doc_clip);
let mut clip_instance = ClipInstance::new(doc_clip_id)
let clip_instance = ClipInstance::new(doc_clip_id)
.with_timeline_start(start_time);
if let Some(layer) = shared.action_executor.document_mut().get_layer_mut(&layer_id) {
@@ -3230,7 +3229,6 @@ impl TimelinePane {
value_max: lane.value_max,
accent_color: lane_accent,
playback_time,
kind: lane.kind,
});
}
}
@@ -4054,7 +4052,6 @@ impl TimelinePane {
value_max: lane.value_max,
accent_color: lane_accent,
playback_time,
kind: lane.kind,
});
}
}
@@ -5409,12 +5406,10 @@ impl PaneRenderer for TimelinePane {
let editing_clip_id = shared.editing_clip_id;
let mut context_layers = document.context_layers(editing_clip_id.as_ref());
// Prepend master track as the first row when enabled (only at root context, not inside clips)
let master_any_layer;
let _master_any_layer;
if self.show_master_track && editing_clip_id.is_none() {
master_any_layer = Some(AnyLayer::Group(document.master_layer.clone()));
context_layers.insert(0, master_any_layer.as_ref().unwrap());
} else {
master_any_layer = None;
_master_any_layer = Some(AnyLayer::Group(document.master_layer.clone()));
context_layers.insert(0, _master_any_layer.as_ref().unwrap());
}
// Use virtual row count (includes expanded group children) for height calculations
let layer_count = build_timeline_rows(&context_layers).len();