| 2341 | } |
| 2342 | |
| 2343 | void SequencerUIManager::syncPipPreviewWindow(const ViewportLayout& viewport) { |
| 2344 | if (!overlay_) |
| 2345 | return; |
| 2346 | |
| 2347 | if (!ui_state_.show_pip_preview) { |
| 2348 | overlay_->hidePreviewWindow(); |
| 2349 | return; |
| 2350 | } |
| 2351 | |
| 2352 | const bool is_playing = !controller_.isStopped(); |
| 2353 | const auto selected = controller_.selectedKeyframe(); |
| 2354 | |
| 2355 | if (!pip_initialized_ || !pip_texture_.valid()) { |
| 2356 | overlay_->hidePreviewWindow(); |
| 2357 | return; |
| 2358 | } |
| 2359 | |
| 2360 | if (!is_playing && selected.has_value()) { |
| 2361 | const auto& timeline = controller_.timeline(); |
| 2362 | if (*selected >= timeline.size()) { |
| 2363 | overlay_->hidePreviewWindow(); |
| 2364 | return; |
| 2365 | } |
| 2366 | const auto* const kf = timeline.getKeyframe(*selected); |
| 2367 | if (!kf || kf->is_loop_point) { |
| 2368 | overlay_->hidePreviewWindow(); |
| 2369 | return; |
| 2370 | } |
| 2371 | } |
| 2372 | |
| 2373 | const float scale = ui_state_.pip_preview_scale; |
| 2374 | constexpr float MARGIN = 16.0f; |
| 2375 | constexpr float TITLE_HEIGHT = 18.0f; |
| 2376 | const float scaled_width = static_cast<float>(PREVIEW_WIDTH) * scale; |
| 2377 | const float scaled_height = static_cast<float>(PREVIEW_HEIGHT) * scale; |
| 2378 | const float total_height = scaled_height + TITLE_HEIGHT + 8.0f; |
| 2379 | |
| 2380 | const float left = viewport.pos.x + MARGIN; |
| 2381 | const float top = panel_->cachedPanelY() - total_height - MARGIN; |
| 2382 | |
| 2383 | const float playhead = controller_.playhead(); |
| 2384 | const std::string title = (is_playing || !selected.has_value()) |
| 2385 | ? std::vformat(LOC(lichtfeld::Strings::Sequencer::PLAYBACK_TIME), |
| 2386 | std::make_format_args(playhead)) |
| 2387 | : [&selected]() { |
| 2388 | const size_t kf_num = *selected + 1; |
| 2389 | return std::vformat(LOC(lichtfeld::Strings::Sequencer::KEYFRAME_PREVIEW), |
| 2390 | std::make_format_args(kf_num)); |
| 2391 | }(); |
| 2392 | |
| 2393 | overlay_->showPreviewWindow(left, top, scaled_width, scaled_height, |
| 2394 | title, is_playing, |
| 2395 | pip_texture_.rmlSrcUrl(PREVIEW_WIDTH, PREVIEW_HEIGHT)); |
| 2396 | } |
| 2397 | |
| 2398 | void SequencerUIManager::renderKeyframeEditOverlay(const ViewportLayout& viewport) { |
| 2399 | if (!viewport_keyframe_edit_snapshot_.has_value()) { |
nothing calls this directly
no test coverage detected