Add raster layers
This commit is contained in:
@@ -45,6 +45,8 @@ impl CustomCursor {
|
||||
Tool::Text => CustomCursor::Text,
|
||||
Tool::RegionSelect => CustomCursor::Select, // Reuse select cursor for now
|
||||
Tool::Split => CustomCursor::Select, // Reuse select cursor for now
|
||||
Tool::Erase => CustomCursor::Draw, // Reuse draw cursor for raster erase
|
||||
Tool::Smudge => CustomCursor::Draw, // Reuse draw cursor for raster smudge
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ pub enum AppAction {
|
||||
AddVideoLayer,
|
||||
AddAudioTrack,
|
||||
AddMidiTrack,
|
||||
AddRasterLayer,
|
||||
AddTestClip,
|
||||
DeleteLayer,
|
||||
ToggleLayerVisibility,
|
||||
@@ -124,7 +125,7 @@ impl AppAction {
|
||||
Self::BringToFront | Self::SplitClip | Self::DuplicateClip => "Modify",
|
||||
|
||||
Self::AddLayer | Self::AddVideoLayer | Self::AddAudioTrack |
|
||||
Self::AddMidiTrack | Self::AddTestClip | Self::DeleteLayer |
|
||||
Self::AddMidiTrack | Self::AddRasterLayer | Self::AddTestClip | Self::DeleteLayer |
|
||||
Self::ToggleLayerVisibility => "Layer",
|
||||
|
||||
Self::NewKeyframe | Self::NewBlankKeyframe | Self::DeleteFrame |
|
||||
@@ -199,6 +200,7 @@ impl AppAction {
|
||||
Self::AddVideoLayer => "Add Video Layer",
|
||||
Self::AddAudioTrack => "Add Audio Track",
|
||||
Self::AddMidiTrack => "Add MIDI Track",
|
||||
Self::AddRasterLayer => "Add Raster Layer",
|
||||
Self::AddTestClip => "Add Test Clip",
|
||||
Self::DeleteLayer => "Delete Layer",
|
||||
Self::ToggleLayerVisibility => "Toggle Layer Visibility",
|
||||
@@ -314,6 +316,7 @@ impl From<MenuAction> for AppAction {
|
||||
MenuAction::AddVideoLayer => Self::AddVideoLayer,
|
||||
MenuAction::AddAudioTrack => Self::AddAudioTrack,
|
||||
MenuAction::AddMidiTrack => Self::AddMidiTrack,
|
||||
MenuAction::AddRasterLayer => Self::AddRasterLayer,
|
||||
MenuAction::AddTestClip => Self::AddTestClip,
|
||||
MenuAction::DeleteLayer => Self::DeleteLayer,
|
||||
MenuAction::ToggleLayerVisibility => Self::ToggleLayerVisibility,
|
||||
@@ -373,6 +376,7 @@ impl TryFrom<AppAction> for MenuAction {
|
||||
AppAction::AddVideoLayer => MenuAction::AddVideoLayer,
|
||||
AppAction::AddAudioTrack => MenuAction::AddAudioTrack,
|
||||
AppAction::AddMidiTrack => MenuAction::AddMidiTrack,
|
||||
AppAction::AddRasterLayer => MenuAction::AddRasterLayer,
|
||||
AppAction::AddTestClip => MenuAction::AddTestClip,
|
||||
AppAction::DeleteLayer => MenuAction::DeleteLayer,
|
||||
AppAction::ToggleLayerVisibility => MenuAction::ToggleLayerVisibility,
|
||||
|
||||
@@ -321,6 +321,8 @@ mod tool_icons {
|
||||
pub static BEZIER_EDIT: &[u8] = include_bytes!("../../../src/assets/bezier_edit.svg");
|
||||
pub static TEXT: &[u8] = include_bytes!("../../../src/assets/text.svg");
|
||||
pub static SPLIT: &[u8] = include_bytes!("../../../src/assets/split.svg");
|
||||
pub static ERASE: &[u8] = include_bytes!("../../../src/assets/erase.svg");
|
||||
pub static SMUDGE: &[u8] = include_bytes!("../../../src/assets/smudge.svg");
|
||||
}
|
||||
|
||||
/// Embedded focus icon SVGs
|
||||
@@ -328,6 +330,7 @@ mod focus_icons {
|
||||
pub static ANIMATION: &[u8] = include_bytes!("../../../src/assets/focus-animation.svg");
|
||||
pub static MUSIC: &[u8] = include_bytes!("../../../src/assets/focus-music.svg");
|
||||
pub static VIDEO: &[u8] = include_bytes!("../../../src/assets/focus-video.svg");
|
||||
pub static PAINTING: &[u8] = include_bytes!("../../../src/assets/focus-painting.svg");
|
||||
}
|
||||
|
||||
/// Icon cache for pane type icons
|
||||
@@ -389,6 +392,8 @@ impl ToolIconCache {
|
||||
Tool::Text => tool_icons::TEXT,
|
||||
Tool::RegionSelect => tool_icons::SELECT, // Reuse select icon for now
|
||||
Tool::Split => tool_icons::SPLIT,
|
||||
Tool::Erase => tool_icons::ERASE,
|
||||
Tool::Smudge => tool_icons::SMUDGE,
|
||||
};
|
||||
if let Some(texture) = rasterize_svg(svg_data, tool.icon_file(), 180, ctx) {
|
||||
self.icons.insert(tool, texture);
|
||||
@@ -416,6 +421,7 @@ impl FocusIconCache {
|
||||
FocusIcon::Animation => (focus_icons::ANIMATION, "focus-animation.svg"),
|
||||
FocusIcon::Music => (focus_icons::MUSIC, "focus-music.svg"),
|
||||
FocusIcon::Video => (focus_icons::VIDEO, "focus-video.svg"),
|
||||
FocusIcon::Painting => (focus_icons::PAINTING, "focus-painting.svg"),
|
||||
};
|
||||
|
||||
// Replace currentColor with the actual color
|
||||
@@ -661,6 +667,7 @@ enum FocusIcon {
|
||||
Animation,
|
||||
Music,
|
||||
Video,
|
||||
Painting,
|
||||
}
|
||||
|
||||
/// Recording arm mode - determines how tracks are armed for recording
|
||||
@@ -1218,6 +1225,18 @@ impl EditorApp {
|
||||
if response.clicked() {
|
||||
self.create_new_project_with_focus(1);
|
||||
}
|
||||
|
||||
ui.add_space(card_spacing);
|
||||
|
||||
// Painting
|
||||
let (rect, response) = ui.allocate_exact_size(
|
||||
egui::vec2(card_size, card_size + 40.0),
|
||||
egui::Sense::click(),
|
||||
);
|
||||
self.render_focus_card_with_icon(ui, rect, response.hovered(), "Painting", FocusIcon::Painting);
|
||||
if response.clicked() {
|
||||
self.create_new_project_with_focus(5);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1355,7 +1374,7 @@ impl EditorApp {
|
||||
.with_framerate(self.config.framerate as f64);
|
||||
|
||||
// Add default layer based on focus type
|
||||
// Layout indices: 0 = Animation, 1 = Video editing, 2 = Music
|
||||
// Layout indices: 0 = Animation, 1 = Video editing, 2 = Music, 5 = Drawing/Painting
|
||||
let layer_id = match layout_index {
|
||||
0 => {
|
||||
// Animation focus -> VectorLayer
|
||||
@@ -1373,6 +1392,12 @@ impl EditorApp {
|
||||
let layer = AudioLayer::new_midi("MIDI 1");
|
||||
document.root.add_child(AnyLayer::Audio(layer))
|
||||
}
|
||||
5 => {
|
||||
// Painting focus -> RasterLayer
|
||||
use lightningbeam_core::raster_layer::RasterLayer;
|
||||
let layer = RasterLayer::new("Raster 1");
|
||||
document.root.add_child(AnyLayer::Raster(layer))
|
||||
}
|
||||
_ => {
|
||||
// Fallback to VectorLayer
|
||||
let layer = VectorLayer::new("Layer 1");
|
||||
@@ -1662,7 +1687,7 @@ impl EditorApp {
|
||||
AnyLayer::Audio(al) => find_splittable_clips(&al.clip_instances, split_time, document),
|
||||
AnyLayer::Video(vl) => find_splittable_clips(&vl.clip_instances, split_time, document),
|
||||
AnyLayer::Effect(el) => find_splittable_clips(&el.clip_instances, split_time, document),
|
||||
AnyLayer::Group(_) => vec![],
|
||||
AnyLayer::Group(_) | AnyLayer::Raster(_) => vec![],
|
||||
};
|
||||
|
||||
for instance_id in active_layer_clips {
|
||||
@@ -1680,7 +1705,7 @@ impl EditorApp {
|
||||
AnyLayer::Audio(al) => find_splittable_clips(&al.clip_instances, split_time, document),
|
||||
AnyLayer::Video(vl) => find_splittable_clips(&vl.clip_instances, split_time, document),
|
||||
AnyLayer::Effect(el) => find_splittable_clips(&el.clip_instances, split_time, document),
|
||||
AnyLayer::Group(_) => vec![],
|
||||
AnyLayer::Group(_) | AnyLayer::Raster(_) => vec![],
|
||||
};
|
||||
if member_splittable.contains(member_instance_id) {
|
||||
clips_to_split.push((*member_layer_id, *member_instance_id));
|
||||
@@ -1791,7 +1816,7 @@ impl EditorApp {
|
||||
AnyLayer::Audio(al) => &al.clip_instances,
|
||||
AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
AnyLayer::Effect(el) => &el.clip_instances,
|
||||
AnyLayer::Group(_) => &[],
|
||||
AnyLayer::Group(_) | AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
let instances: Vec<_> = clip_slice
|
||||
.iter()
|
||||
@@ -2089,7 +2114,7 @@ impl EditorApp {
|
||||
AnyLayer::Audio(al) => &al.clip_instances,
|
||||
AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
AnyLayer::Effect(el) => &el.clip_instances,
|
||||
AnyLayer::Group(_) => &[],
|
||||
AnyLayer::Group(_) | AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
instances.iter()
|
||||
.filter(|ci| selection.contains_clip_instance(&ci.id))
|
||||
@@ -2788,6 +2813,24 @@ impl EditorApp {
|
||||
}
|
||||
}
|
||||
}
|
||||
MenuAction::AddRasterLayer => {
|
||||
use lightningbeam_core::raster_layer::RasterLayer;
|
||||
let editing_clip_id = self.editing_context.current_clip_id();
|
||||
let context_layers = self.action_executor.document().context_layers(editing_clip_id.as_ref());
|
||||
let layer_number = context_layers.len() + 1;
|
||||
let layer_name = format!("Raster {}", layer_number);
|
||||
|
||||
let layer = RasterLayer::new(layer_name);
|
||||
let action = lightningbeam_core::actions::AddLayerAction::new(AnyLayer::Raster(layer))
|
||||
.with_target_clip(editing_clip_id);
|
||||
let _ = self.action_executor.execute(Box::new(action));
|
||||
|
||||
// Set newly created layer as active
|
||||
let context_layers = self.action_executor.document().context_layers(editing_clip_id.as_ref());
|
||||
if let Some(last_layer) = context_layers.last() {
|
||||
self.active_layer_id = Some(last_layer.id());
|
||||
}
|
||||
}
|
||||
MenuAction::AddTestClip => {
|
||||
// Create a test vector clip and add it to the library (not to timeline)
|
||||
use lightningbeam_core::clip::VectorClip;
|
||||
|
||||
@@ -320,6 +320,7 @@ pub enum MenuAction {
|
||||
AddVideoLayer,
|
||||
AddAudioTrack,
|
||||
AddMidiTrack,
|
||||
AddRasterLayer,
|
||||
AddTestClip, // For testing: adds a test clip to the asset library
|
||||
DeleteLayer,
|
||||
ToggleLayerVisibility,
|
||||
@@ -417,6 +418,7 @@ impl MenuItemDef {
|
||||
const ADD_VIDEO_LAYER: Self = Self { label: "Add Video Layer", action: MenuAction::AddVideoLayer, shortcut: None };
|
||||
const ADD_AUDIO_TRACK: Self = Self { label: "Add Audio Track", action: MenuAction::AddAudioTrack, shortcut: None };
|
||||
const ADD_MIDI_TRACK: Self = Self { label: "Add MIDI Track", action: MenuAction::AddMidiTrack, shortcut: None };
|
||||
const ADD_RASTER_LAYER: Self = Self { label: "Add Raster Layer", action: MenuAction::AddRasterLayer, shortcut: None };
|
||||
const ADD_TEST_CLIP: Self = Self { label: "Add Test Clip to Library", action: MenuAction::AddTestClip, shortcut: None };
|
||||
const DELETE_LAYER: Self = Self { label: "Delete Layer", action: MenuAction::DeleteLayer, shortcut: None };
|
||||
const TOGGLE_LAYER_VISIBILITY: Self = Self { label: "Hide/Show Layer", action: MenuAction::ToggleLayerVisibility, shortcut: None };
|
||||
@@ -534,6 +536,7 @@ impl MenuItemDef {
|
||||
MenuDef::Item(&Self::ADD_VIDEO_LAYER),
|
||||
MenuDef::Item(&Self::ADD_AUDIO_TRACK),
|
||||
MenuDef::Item(&Self::ADD_MIDI_TRACK),
|
||||
MenuDef::Item(&Self::ADD_RASTER_LAYER),
|
||||
MenuDef::Separator,
|
||||
MenuDef::Item(&Self::ADD_TEST_CLIP),
|
||||
MenuDef::Separator,
|
||||
|
||||
@@ -1265,6 +1265,9 @@ impl AssetLibraryPane {
|
||||
lightningbeam_core::layer::AnyLayer::Group(_) => {
|
||||
// Group layers don't have their own clip instances
|
||||
}
|
||||
lightningbeam_core::layer::AnyLayer::Raster(_) => {
|
||||
// Raster layers don't have their own clip instances
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
|
||||
@@ -535,6 +535,7 @@ impl InfopanelPane {
|
||||
AnyLayer::Video(_) => "Video",
|
||||
AnyLayer::Effect(_) => "Effect",
|
||||
AnyLayer::Group(_) => "Group",
|
||||
AnyLayer::Raster(_) => "Raster",
|
||||
};
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Type:");
|
||||
@@ -590,6 +591,7 @@ impl InfopanelPane {
|
||||
AnyLayer::Video(l) => &l.clip_instances,
|
||||
AnyLayer::Effect(l) => &l.clip_instances,
|
||||
AnyLayer::Group(_) => &[],
|
||||
AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
if let Some(ci) = instances.iter().find(|c| c.id == ci_id) {
|
||||
found = true;
|
||||
|
||||
@@ -2136,6 +2136,10 @@ pub struct StagePane {
|
||||
dcel_editing_cache: Option<DcelEditingCache>,
|
||||
// Current snap result (for visual feedback rendering)
|
||||
current_snap: Option<lightningbeam_core::snap::SnapResult>,
|
||||
// Raster stroke in progress: (layer_id, time, brush_state, buffer_before)
|
||||
raster_stroke_state: Option<(uuid::Uuid, f64, lightningbeam_core::brush_engine::StrokeState, Vec<u8>)>,
|
||||
// Last raster stroke point (for incremental segment painting)
|
||||
raster_last_point: Option<lightningbeam_core::raster_layer::StrokePoint>,
|
||||
/// Synthetic drag/click override for test mode replay (debug builds only)
|
||||
#[cfg(debug_assertions)]
|
||||
replay_override: Option<ReplayDragState>,
|
||||
@@ -2211,6 +2215,8 @@ impl StagePane {
|
||||
last_viewport_rect: None,
|
||||
dcel_editing_cache: None,
|
||||
current_snap: None,
|
||||
raster_stroke_state: None,
|
||||
raster_last_point: None,
|
||||
#[cfg(debug_assertions)]
|
||||
replay_override: None,
|
||||
}
|
||||
@@ -4175,6 +4181,155 @@ impl StagePane {
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle raster stroke tool input (Draw/Erase/Smudge on a raster layer).
|
||||
///
|
||||
/// Paints incrementally into `document_mut()` on every drag event so the
|
||||
/// result is visible immediately. On mouse-up the pre/post raw-pixel
|
||||
/// buffers are wrapped in a `RasterStrokeAction` for undo/redo.
|
||||
fn handle_raster_stroke_tool(
|
||||
&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
response: &egui::Response,
|
||||
world_pos: egui::Vec2,
|
||||
blend_mode: lightningbeam_core::raster_layer::RasterBlendMode,
|
||||
shared: &mut SharedPaneState,
|
||||
) {
|
||||
use lightningbeam_core::tool::ToolState;
|
||||
use lightningbeam_core::layer::AnyLayer;
|
||||
use lightningbeam_core::raster_layer::StrokePoint;
|
||||
use lightningbeam_core::brush_engine::{BrushEngine, StrokeState, image_from_raw};
|
||||
use lightningbeam_core::raster_layer::StrokeRecord;
|
||||
|
||||
let active_layer_id = match *shared.active_layer_id {
|
||||
Some(id) => id,
|
||||
None => return,
|
||||
};
|
||||
|
||||
// Only operate on raster layers
|
||||
let is_raster = shared.action_executor.document()
|
||||
.get_layer(&active_layer_id)
|
||||
.map_or(false, |l| matches!(l, AnyLayer::Raster(_)));
|
||||
if !is_raster {
|
||||
return;
|
||||
}
|
||||
|
||||
let brush = lightningbeam_core::brush_settings::BrushSettings::default_round_soft();
|
||||
|
||||
let color = if matches!(blend_mode, lightningbeam_core::raster_layer::RasterBlendMode::Erase) {
|
||||
[1.0f32, 1.0, 1.0, 1.0]
|
||||
} else {
|
||||
let c = *shared.stroke_color;
|
||||
[c.r() as f32 / 255.0, c.g() as f32 / 255.0, c.b() as f32 / 255.0, c.a() as f32 / 255.0]
|
||||
};
|
||||
|
||||
// Mouse down: snapshot buffer_before, init stroke state, paint first dab
|
||||
if self.rsp_drag_started(response) || self.rsp_clicked(response) {
|
||||
let (doc_width, doc_height, buffer_before) = {
|
||||
let doc = shared.action_executor.document();
|
||||
let buf = doc.get_layer(&active_layer_id)
|
||||
.and_then(|l| if let AnyLayer::Raster(rl) = l {
|
||||
rl.keyframe_at(*shared.playback_time).map(|kf| kf.raw_pixels.clone())
|
||||
} else { None })
|
||||
.unwrap_or_default();
|
||||
(doc.width as u32, doc.height as u32, buf)
|
||||
};
|
||||
|
||||
// Start a fresh stroke state; MAX distance ensures first point gets a dab
|
||||
let mut stroke_state = StrokeState::new();
|
||||
stroke_state.distance_since_last_dab = f32::MAX;
|
||||
|
||||
let first_pt = StrokePoint { x: world_pos.x, y: world_pos.y, pressure: 1.0, tilt_x: 0.0, tilt_y: 0.0, timestamp: 0.0 };
|
||||
|
||||
// Paint the first dab directly into the document
|
||||
{
|
||||
let doc = shared.action_executor.document_mut();
|
||||
if let Some(AnyLayer::Raster(rl)) = doc.get_layer_mut(&active_layer_id) {
|
||||
let kf = rl.ensure_keyframe_at(*shared.playback_time, doc_width, doc_height);
|
||||
let mut img = image_from_raw(std::mem::take(&mut kf.raw_pixels), kf.width, kf.height);
|
||||
let single = StrokeRecord {
|
||||
brush_settings: brush.clone(),
|
||||
color,
|
||||
blend_mode,
|
||||
points: vec![first_pt.clone()],
|
||||
};
|
||||
BrushEngine::apply_stroke_with_state(&mut img, &single, &mut stroke_state);
|
||||
kf.raw_pixels = img.into_raw();
|
||||
}
|
||||
}
|
||||
|
||||
self.raster_stroke_state = Some((active_layer_id, *shared.playback_time, stroke_state, buffer_before));
|
||||
self.raster_last_point = Some(first_pt);
|
||||
*shared.tool_state = ToolState::DrawingRasterStroke { points: vec![] };
|
||||
}
|
||||
|
||||
// Mouse drag: paint each new segment immediately
|
||||
if self.rsp_dragged(response) {
|
||||
if let Some((layer_id, time, ref mut stroke_state, _)) = self.raster_stroke_state {
|
||||
if let Some(prev_pt) = self.raster_last_point.take() {
|
||||
let curr_pt = StrokePoint { x: world_pos.x, y: world_pos.y, pressure: 1.0, tilt_x: 0.0, tilt_y: 0.0, timestamp: 0.0 };
|
||||
|
||||
// Skip if not moved enough
|
||||
const MIN_DIST_SQ: f32 = 1.5 * 1.5;
|
||||
let dx = curr_pt.x - prev_pt.x;
|
||||
let dy = curr_pt.y - prev_pt.y;
|
||||
let moved_pt = if dx * dx + dy * dy >= MIN_DIST_SQ { curr_pt.clone() } else { prev_pt.clone() };
|
||||
|
||||
if dx * dx + dy * dy >= MIN_DIST_SQ {
|
||||
let doc = shared.action_executor.document_mut();
|
||||
if let Some(AnyLayer::Raster(rl)) = doc.get_layer_mut(&layer_id) {
|
||||
if let Some(kf) = rl.keyframe_at_mut(time) {
|
||||
let mut img = image_from_raw(std::mem::take(&mut kf.raw_pixels), kf.width, kf.height);
|
||||
let seg = StrokeRecord {
|
||||
brush_settings: brush.clone(),
|
||||
color,
|
||||
blend_mode,
|
||||
points: vec![prev_pt, curr_pt],
|
||||
};
|
||||
BrushEngine::apply_stroke_with_state(&mut img, &seg, stroke_state);
|
||||
kf.raw_pixels = img.into_raw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.raster_last_point = Some(moved_pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse up: wrap the pre/post buffers in an undo action
|
||||
if self.rsp_drag_stopped(response)
|
||||
|| (self.rsp_any_released(ui) && matches!(*shared.tool_state, ToolState::DrawingRasterStroke { .. }))
|
||||
{
|
||||
if let Some((layer_id, time, _, buffer_before)) = self.raster_stroke_state.take() {
|
||||
use lightningbeam_core::actions::RasterStrokeAction;
|
||||
|
||||
let (doc_width, doc_height, buffer_after) = {
|
||||
let doc = shared.action_executor.document();
|
||||
let buf = doc.get_layer(&layer_id)
|
||||
.and_then(|l| if let AnyLayer::Raster(rl) = l {
|
||||
rl.keyframe_at(time).map(|kf| kf.raw_pixels.clone())
|
||||
} else { None })
|
||||
.unwrap_or_default();
|
||||
(doc.width as u32, doc.height as u32, buf)
|
||||
};
|
||||
|
||||
let action = RasterStrokeAction::new(
|
||||
layer_id,
|
||||
time,
|
||||
buffer_before,
|
||||
buffer_after,
|
||||
doc_width,
|
||||
doc_height,
|
||||
);
|
||||
// execute is a no-op for the first call (pixels already in document),
|
||||
// but registers the action in the undo stack
|
||||
let _ = shared.action_executor.execute(Box::new(action));
|
||||
}
|
||||
self.raster_last_point = None;
|
||||
*shared.tool_state = ToolState::Idle;
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_paint_bucket_tool(
|
||||
&mut self,
|
||||
response: &egui::Response,
|
||||
@@ -6187,7 +6342,21 @@ impl StagePane {
|
||||
self.handle_ellipse_tool(ui, &response, world_pos, shift_held, ctrl_held, shared);
|
||||
}
|
||||
Tool::Draw => {
|
||||
self.handle_draw_tool(ui, &response, world_pos, shared);
|
||||
// Dispatch to raster or vector draw handler based on active layer type
|
||||
let is_raster = shared.active_layer_id.and_then(|id| {
|
||||
shared.action_executor.document().get_layer(&id)
|
||||
}).map_or(false, |l| matches!(l, lightningbeam_core::layer::AnyLayer::Raster(_)));
|
||||
if is_raster {
|
||||
self.handle_raster_stroke_tool(ui, &response, world_pos, lightningbeam_core::raster_layer::RasterBlendMode::Normal, shared);
|
||||
} else {
|
||||
self.handle_draw_tool(ui, &response, world_pos, shared);
|
||||
}
|
||||
}
|
||||
Tool::Erase => {
|
||||
self.handle_raster_stroke_tool(ui, &response, world_pos, lightningbeam_core::raster_layer::RasterBlendMode::Erase, shared);
|
||||
}
|
||||
Tool::Smudge => {
|
||||
self.handle_raster_stroke_tool(ui, &response, world_pos, lightningbeam_core::raster_layer::RasterBlendMode::Smudge, shared);
|
||||
}
|
||||
Tool::Transform => {
|
||||
self.handle_transform_tool(ui, &response, world_pos, shared);
|
||||
|
||||
@@ -118,6 +118,7 @@ fn effective_clip_duration(
|
||||
AnyLayer::Video(_) => document.get_video_clip(&clip_instance.clip_id).map(|c| c.duration),
|
||||
AnyLayer::Effect(_) => Some(lightningbeam_core::effect::EFFECT_DURATION),
|
||||
AnyLayer::Group(_) => None,
|
||||
AnyLayer::Raster(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,6 +373,7 @@ fn collect_clip_instances<'a>(layer: &'a AnyLayer, result: &mut Vec<(&'a AnyLaye
|
||||
collect_clip_instances(child, result);
|
||||
}
|
||||
}
|
||||
AnyLayer::Raster(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,6 +686,7 @@ impl TimelinePane {
|
||||
lightningbeam_core::layer::AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Effect(el) => &el.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Group(_) => &[],
|
||||
lightningbeam_core::layer::AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
|
||||
// Check each clip instance
|
||||
@@ -1196,6 +1199,7 @@ impl TimelinePane {
|
||||
AnyLayer::Video(_) => ("Video", egui::Color32::from_rgb(180, 100, 255)),
|
||||
AnyLayer::Effect(_) => ("Effect", egui::Color32::from_rgb(255, 100, 180)),
|
||||
AnyLayer::Group(_) => ("Group", egui::Color32::from_rgb(0, 180, 180)),
|
||||
AnyLayer::Raster(_) => ("Raster", egui::Color32::from_rgb(160, 100, 200)),
|
||||
};
|
||||
(layer.id(), data.name.clone(), lt, tc)
|
||||
}
|
||||
@@ -1213,6 +1217,7 @@ impl TimelinePane {
|
||||
AnyLayer::Video(_) => ("Video", egui::Color32::from_rgb(180, 100, 255)),
|
||||
AnyLayer::Effect(_) => ("Effect", egui::Color32::from_rgb(255, 100, 180)),
|
||||
AnyLayer::Group(_) => ("Group", egui::Color32::from_rgb(0, 180, 180)),
|
||||
AnyLayer::Raster(_) => ("Raster", egui::Color32::from_rgb(160, 100, 200)),
|
||||
};
|
||||
(child.id(), data.name.clone(), lt, tc)
|
||||
}
|
||||
@@ -1972,6 +1977,7 @@ impl TimelinePane {
|
||||
lightningbeam_core::layer::AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Effect(el) => &el.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Group(_) => &[],
|
||||
lightningbeam_core::layer::AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
|
||||
// For moves, precompute the clamped offset so all selected clips move uniformly
|
||||
@@ -2278,6 +2284,10 @@ impl TimelinePane {
|
||||
egui::Color32::from_rgb(0, 150, 150), // Teal
|
||||
egui::Color32::from_rgb(100, 220, 220), // Bright teal
|
||||
),
|
||||
lightningbeam_core::layer::AnyLayer::Raster(_) => (
|
||||
egui::Color32::from_rgb(160, 100, 200), // Purple/violet
|
||||
egui::Color32::from_rgb(200, 160, 240), // Bright purple/violet
|
||||
),
|
||||
};
|
||||
|
||||
let (row, total_rows) = clip_stacking[clip_instance_index];
|
||||
@@ -2868,6 +2878,7 @@ impl TimelinePane {
|
||||
lightningbeam_core::layer::AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Effect(el) => &el.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Group(_) => &[],
|
||||
lightningbeam_core::layer::AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
|
||||
// Check if click is within any clip instance
|
||||
@@ -3722,6 +3733,7 @@ impl PaneRenderer for TimelinePane {
|
||||
lightningbeam_core::layer::AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Effect(el) => &el.clip_instances,
|
||||
lightningbeam_core::layer::AnyLayer::Group(_) => &[],
|
||||
lightningbeam_core::layer::AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
|
||||
for clip_instance in clip_instances {
|
||||
@@ -3860,6 +3872,7 @@ impl PaneRenderer for TimelinePane {
|
||||
AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
AnyLayer::Effect(el) => &el.clip_instances,
|
||||
AnyLayer::Group(_) => &[],
|
||||
AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
for inst in instances {
|
||||
if !shared.selection.contains_clip_instance(&inst.id) { continue; }
|
||||
@@ -3890,6 +3903,7 @@ impl PaneRenderer for TimelinePane {
|
||||
AnyLayer::Video(vl) => &vl.clip_instances,
|
||||
AnyLayer::Effect(el) => &el.clip_instances,
|
||||
AnyLayer::Group(_) => &[],
|
||||
AnyLayer::Raster(_) => &[],
|
||||
};
|
||||
// Check each selected clip
|
||||
enabled = instances.iter()
|
||||
|
||||
@@ -40,6 +40,7 @@ impl PaneRenderer for ToolbarPane {
|
||||
AnyLayer::Video(_) => LayerType::Video,
|
||||
AnyLayer::Effect(_) => LayerType::Effect,
|
||||
AnyLayer::Group(_) => LayerType::Group,
|
||||
AnyLayer::Raster(_) => LayerType::Raster,
|
||||
});
|
||||
|
||||
// Auto-switch to Select if the current tool isn't available for this layer type
|
||||
|
||||
Reference in New Issue
Block a user