Merge pull request #56 from Mike-Solar/main

app: PlaybackController + playhead subscription migration (issues 0c,…
This commit is contained in:
2026-08-05 00:13:06 +08:00
committed by GitHub
20 changed files with 184 additions and 101 deletions
+2
View File
@@ -24,6 +24,8 @@ set(OLIVE_SOURCES
common/colorcodingapp.h common/colorcodingapp.h
common/colorcodingapp.cpp common/colorcodingapp.cpp
common/nodevaluehandle.h common/nodevaluehandle.h
playback/playbackcontroller.h
playback/playbackcontroller.cpp
) )
#set(OLIVE_RESOURCES) #set(OLIVE_RESOURCES)
+2 -1
View File
@@ -47,6 +47,7 @@
#include "oakengine/encoding.h" #include "oakengine/encoding.h"
#include "oakengine/timeline.h" #include "oakengine/timeline.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "ui/icons/icons.h" #include "ui/icons/icons.h"
#include "widget/timeruler/timeruler.h" #include "widget/timeruler/timeruler.h"
#include "common/configwrapper.h" #include "common/configwrapper.h"
@@ -319,7 +320,7 @@ ExportDialog::ExportDialog(OakEngineNode *viewer_node, bool stills_only_mode,
this); this);
connect(video_tab_, &ExportVideoTab::time_changed, this, connect(video_tab_, &ExportVideoTab::time_changed, this,
[viewer_node](const Rational &time) { [viewer_node](const Rational &time) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
viewer_node, viewer_node,
time.numerator(), time.denominator()); time.numerator(), time.denominator());
}); });
+38
View File
@@ -0,0 +1,38 @@
#include "playbackcontroller.h"
namespace olive
{
PlaybackController *PlaybackController::instance_ = nullptr;
PlaybackController *PlaybackController::instance()
{
if (!instance_) {
instance_ = new PlaybackController();
}
return instance_;
}
PlaybackController::PlaybackController(QObject *parent)
: QObject(parent)
{
}
void PlaybackController::set_playhead(OakEngineNode *viewer,
const core::Rational &time)
{
if (!viewer) {
return;
}
oakengine_viewer_set_playhead(viewer, time.numerator(),
time.denominator());
emit playhead_changed(viewer, time);
}
void PlaybackController::set_playhead(OakEngineNode *viewer, int64_t num,
int64_t den)
{
set_playhead(viewer, core::Rational(num, den));
}
}
+50
View File
@@ -0,0 +1,50 @@
#ifndef OAK_PLAYBACKCONTROLLER_H
#define OAK_PLAYBACKCONTROLLER_H
#include <QObject>
#include "oakengine/viewer.h"
#include "olive/core/util/rational.h"
namespace olive
{
/**
* @brief App-internal hub for playhead changes (issue 0c of the
* EventBridge elimination plan).
*
* Every app-side `oakengine_viewer_set_playhead` call site goes through
* set_playhead(), which forwards to the engine and re-broadcasts
* playhead_changed as a plain Qt signal. Widgets subscribe to that signal
* instead of OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED via EngineEventBridge
* or raw oakengine_event_subscribe callbacks.
*/
class PlaybackController : public QObject {
Q_OBJECT
public:
/**
* @brief Lazily created process-wide instance (leaked at exit, like
* Core). Widget tests construct widgets without Core::Start(), so the
* instance must not depend on explicit startup.
*/
static PlaybackController *instance();
/**
* @brief Move the playhead and notify app subscribers.
*/
void set_playhead(OakEngineNode *viewer, const core::Rational &time);
void set_playhead(OakEngineNode *viewer, int64_t num, int64_t den);
signals:
void playhead_changed(OakEngineNode *viewer,
const olive::core::Rational &time);
private:
explicit PlaybackController(QObject *parent = nullptr);
static PlaybackController *instance_;
};
}
#endif // OAK_PLAYBACKCONTROLLER_H
@@ -21,6 +21,8 @@
#include "nodeparamviewconnectedlabel.h" #include "nodeparamviewconnectedlabel.h"
#include "playback/playbackcontroller.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include "oakutil/qtutils.h" #include "oakutil/qtutils.h"
@@ -112,30 +114,26 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const oak::Input &input
NodeParamViewConnectedLabel::~NodeParamViewConnectedLabel() NodeParamViewConnectedLabel::~NodeParamViewConnectedLabel()
{ {
// Raw C-API subscription carries `this` as userdata; not covered by // Drop the PlaybackController connection (Qt would auto-disconnect
// Qt's auto-disconnect. Unsubscribe or the next playhead event calls // anyway, but keep the symmetric teardown).
// into a dead object.
set_viewer_node(nullptr); set_viewer_node(nullptr);
} }
void NodeParamViewConnectedLabel::set_viewer_node(OakEngineNode *viewer) void NodeParamViewConnectedLabel::set_viewer_node(OakEngineNode *viewer)
{ {
if (viewer_) { disconnect(viewer_conn_);
oakengine_event_unsubscribe(viewer_sub_);
viewer_sub_ = 0;
}
viewer_ = viewer; viewer_ = viewer;
if (viewer_) { if (viewer_) {
viewer_sub_ = oakengine_event_subscribe( viewer_conn_ = connect(
viewer_, PlaybackController::instance(),
OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED, &PlaybackController::playhead_changed, this,
[](const oakengine_event *, void *userdata) { [this](OakEngineNode *n, const core::Rational &) {
static_cast<NodeParamViewConnectedLabel *>(userdata) if (n == viewer_) {
->update_value_tree(); update_value_tree();
}, }
this); });
update_value_tree(); update_value_tree();
} }
} }
@@ -72,7 +72,7 @@ private:
EngineEventBridge *bridge_ = nullptr; EngineEventBridge *bridge_ = nullptr;
int64_t viewer_sub_ = 0; QMetaObject::Connection viewer_conn_;
private slots: private slots:
void set_value_tree_visible(bool e); void set_value_tree_visible(bool e);
@@ -28,6 +28,7 @@
#include "oakengine/events.h" #include "oakengine/events.h"
#include "oakengine/undo.h" #include "oakengine/undo.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "oakengine/node.h" #include "oakengine/node.h"
#include "ui/icons/icons.h" #include "ui/icons/icons.h"
@@ -159,13 +160,9 @@ NodeParamViewKeyframeControl::NodeParamViewKeyframeControl(bool right_align,
NodeParamViewKeyframeControl::~NodeParamViewKeyframeControl() NodeParamViewKeyframeControl::~NodeParamViewKeyframeControl()
{ {
// Raw C-API subscription carries `this` as userdata; it is not covered // Qt auto-disconnect covers the PlaybackController connection; make it
// by Qt's auto-disconnect. Without this, a playhead event delivered // explicit for symmetry with TimeTargetDisconnectEvent.
// after destruction calls update_state() on a dead object. disconnect(viewer_conn_);
if (viewer_sub_ > 0) {
oakengine_event_unsubscribe(viewer_sub_);
viewer_sub_ = 0;
}
// Drop the keyframe_* bridge subscriptions too (same raw-userdata // Drop the keyframe_* bridge subscriptions too (same raw-userdata
// mechanism underneath). // mechanism underneath).
set_input(oak::Input()); set_input(oak::Input());
@@ -211,22 +208,18 @@ void NodeParamViewKeyframeControl::set_input(const oak::Input &input)
void NodeParamViewKeyframeControl::TimeTargetDisconnectEvent(OakEngineNode *v) void NodeParamViewKeyframeControl::TimeTargetDisconnectEvent(OakEngineNode *v)
{ {
if (viewer_sub_ > 0) { disconnect(viewer_conn_);
oakengine_event_unsubscribe(viewer_sub_);
viewer_sub_ = 0;
}
} }
void NodeParamViewKeyframeControl::TimeTargetConnectEvent(OakEngineNode *v) void NodeParamViewKeyframeControl::TimeTargetConnectEvent(OakEngineNode *v)
{ {
viewer_sub_ = oakengine_event_subscribe( viewer_conn_ = connect(
v, PlaybackController::instance(), &PlaybackController::playhead_changed,
OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED, this, [this, v](OakEngineNode *n, const core::Rational &) {
[](const oakengine_event *, void *userdata) { if (n == v) {
static_cast<NodeParamViewKeyframeControl *>(userdata) update_state();
->update_state(); }
}, });
this);
update_state(); update_state();
} }
@@ -391,7 +384,7 @@ void NodeParamViewKeyframeControl::go_to_previous_key()
&previous_time) && &previous_time) &&
get_time_target()) { get_time_target()) {
Rational key_time = convert_to_viewer_time(previous_time); Rational key_time = convert_to_viewer_time(previous_time);
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(get_time_target()), reinterpret_cast<OakEngineNode *>(get_time_target()),
key_time.numerator(), key_time.denominator()); key_time.numerator(), key_time.denominator());
} }
@@ -408,7 +401,7 @@ void NodeParamViewKeyframeControl::go_to_next_key()
&next_time) && &next_time) &&
get_time_target()) { get_time_target()) {
Rational key_time = convert_to_viewer_time(next_time); Rational key_time = convert_to_viewer_time(next_time);
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(get_time_target()), reinterpret_cast<OakEngineNode *>(get_time_target()),
key_time.numerator(), key_time.denominator()); key_time.numerator(), key_time.denominator());
} }
@@ -77,7 +77,7 @@ private:
int64_t keyframe_removed_sub_ = 0; int64_t keyframe_removed_sub_ = 0;
int64_t keyframe_time_sub_ = 0; int64_t keyframe_time_sub_ = 0;
int64_t viewer_sub_ = 0; QMetaObject::Connection viewer_conn_;
private slots: private slots:
void show_buttons_from_keyframe_enable(bool e); void show_buttons_from_keyframe_enable(bool e);
@@ -21,6 +21,8 @@
#include "nodeparamviewwidgetbridge.h" #include "nodeparamviewwidgetbridge.h"
#include "playback/playbackcontroller.h"
#include <QCheckBox> #include <QCheckBox>
#include <QFontComboBox> #include <QFontComboBox>
#include <QUrl> #include <QUrl>
@@ -192,10 +194,7 @@ NodeParamViewWidgetBridge::~NodeParamViewWidgetBridge()
{ {
// oakengine_dragger_create() ownership is ours (no-op on NULL) // oakengine_dragger_create() ownership is ours (no-op on NULL)
oakengine_dragger_free(dragger_); oakengine_dragger_free(dragger_);
// Raw viewer subscription carries `this` as userdata disconnect(viewer_conn_);
if (viewer_sub_ > 0) {
oakengine_event_unsubscribe(viewer_sub_);
}
} }
int get_slider_count(NodeValueType::Type type) int get_slider_count(NodeValueType::Type type)
@@ -1131,22 +1130,18 @@ void NodeParamViewWidgetBridge::set_timebase(const Rational &timebase)
void NodeParamViewWidgetBridge::TimeTargetDisconnectEvent(OakEngineNode *v) void NodeParamViewWidgetBridge::TimeTargetDisconnectEvent(OakEngineNode *v)
{ {
if (viewer_sub_ > 0) { disconnect(viewer_conn_);
oakengine_event_unsubscribe(viewer_sub_);
viewer_sub_ = 0;
}
} }
void NodeParamViewWidgetBridge::TimeTargetConnectEvent(OakEngineNode *v) void NodeParamViewWidgetBridge::TimeTargetConnectEvent(OakEngineNode *v)
{ {
viewer_sub_ = oakengine_event_subscribe( viewer_conn_ = connect(
v, PlaybackController::instance(), &PlaybackController::playhead_changed,
OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED, this, [this, v](OakEngineNode *n, const core::Rational &) {
[](const oakengine_event *, void *userdata) { if (n == v) {
static_cast<NodeParamViewWidgetBridge *>(userdata) update_widget_values();
->update_widget_values(); }
}, });
this);
} }
void NodeParamViewWidgetBridge::input_value_changed(OakEngineNode *source, void NodeParamViewWidgetBridge::input_value_changed(OakEngineNode *source,
@@ -121,7 +121,7 @@ private:
EngineEventBridge *bridge_ = nullptr; EngineEventBridge *bridge_ = nullptr;
int64_t viewer_sub_ = 0; QMetaObject::Connection viewer_conn_;
private slots: private slots:
void widget_callback(); void widget_callback();
+11 -11
View File
@@ -21,6 +21,8 @@
#include "timebasedview.h" #include "timebasedview.h"
#include "playback/playbackcontroller.h"
#include <QGraphicsRectItem> #include <QGraphicsRectItem>
#include <QMouseEvent> #include <QMouseEvent>
#include <QScrollBar> #include <QScrollBar>
@@ -157,21 +159,19 @@ void TimeBasedView::set_y_scale(const double &y_scale)
void TimeBasedView::set_viewer_node(OakEngineNode *v) void TimeBasedView::set_viewer_node(OakEngineNode *v)
{ {
if (viewer_) { disconnect(viewer_conn_);
oakengine_event_unsubscribe(viewer_sub_);
viewer_sub_ = 0;
}
viewer_ = v; viewer_ = v;
if (viewer_) { if (viewer_) {
viewer_sub_ = oakengine_event_subscribe( viewer_conn_ = connect(
viewer_, PlaybackController::instance(),
OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED, &PlaybackController::playhead_changed, this,
[](const oakengine_event *, void *userdata) { [this](OakEngineNode *n, const core::Rational &) {
static_cast<TimeBasedView *>(userdata)->viewport()->update(); if (n == viewer_) {
}, viewport()->update();
this); }
});
} }
} }
+1 -1
View File
@@ -148,7 +148,7 @@ private:
OakEngineNode *viewer_; OakEngineNode *viewer_;
int64_t viewer_sub_ = 0; QMetaObject::Connection viewer_conn_;
}; };
} }
+9 -8
View File
@@ -34,6 +34,7 @@
#include "oakengine/node.h" #include "oakengine/node.h"
#include "oakengine/timeline.h" #include "oakengine/timeline.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "oakengine/timeline.h" #include "oakengine/timeline.h"
#include "oakengine/undo.h" #include "oakengine/undo.h"
#include "widget/keyframeview/keyframehandle.h" #include "widget/keyframeview/keyframehandle.h"
@@ -552,7 +553,7 @@ void TimeBasedWidget::go_to_prev_cut()
} }
} }
oakengine_viewer_set_playhead(sequence_node, PlaybackController::instance()->set_playhead(sequence_node,
closest_cut.numerator(), closest_cut.denominator()); closest_cut.numerator(), closest_cut.denominator());
} }
@@ -619,7 +620,7 @@ void TimeBasedWidget::go_to_next_cut()
} }
if (closest_cut < RATIONAL_MAX) { if (closest_cut < RATIONAL_MAX) {
oakengine_viewer_set_playhead(sequence_node, PlaybackController::instance()->set_playhead(sequence_node,
closest_cut.numerator(), closest_cut.denominator()); closest_cut.numerator(), closest_cut.denominator());
} }
} }
@@ -627,7 +628,7 @@ void TimeBasedWidget::go_to_next_cut()
void TimeBasedWidget::go_to_start() void TimeBasedWidget::go_to_start()
{ {
if (viewer_node_) { if (viewer_node_) {
oakengine_viewer_set_playhead(get_connected_node(), 0, 1); PlaybackController::instance()->set_playhead(get_connected_node(), 0, 1);
} }
} }
@@ -643,7 +644,7 @@ void TimeBasedWidget::prev_frame()
} }
{ {
Rational _pt = qMax(Rational(0), proposed_time); Rational _pt = qMax(Rational(0), proposed_time);
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
_pt.numerator(), _pt.denominator()); _pt.numerator(), _pt.denominator());
} }
} }
@@ -659,7 +660,7 @@ void TimeBasedWidget::next_frame()
// Catch rounding error, assume this time is snapped and just add a timebase // Catch rounding error, assume this time is snapped and just add a timebase
proposed_time += timebase(); proposed_time += timebase();
} }
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
proposed_time.numerator(), proposed_time.denominator()); proposed_time.numerator(), proposed_time.denominator());
} }
} }
@@ -668,7 +669,7 @@ void TimeBasedWidget::go_to_end()
{ {
if (viewer_node_) { if (viewer_node_) {
const Rational length = viewer_output_length(viewer_node_.data()); const Rational length = viewer_output_length(viewer_node_.data());
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
length.numerator(), length.denominator()); length.numerator(), length.denominator());
} }
} }
@@ -1006,7 +1007,7 @@ void TimeBasedWidget::go_to_in()
oakengine_viewer_workarea wa; oakengine_viewer_workarea wa;
oakengine_viewer_get_workarea(get_connected_node(), &wa); oakengine_viewer_get_workarea(get_connected_node(), &wa);
if (wa.enabled) { if (wa.enabled) {
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
wa.in_num, wa.in_den); wa.in_num, wa.in_den);
} else { } else {
go_to_start(); go_to_start();
@@ -1020,7 +1021,7 @@ void TimeBasedWidget::go_to_out()
oakengine_viewer_workarea wa; oakengine_viewer_workarea wa;
oakengine_viewer_get_workarea(get_connected_node(), &wa); oakengine_viewer_get_workarea(get_connected_node(), &wa);
if (wa.enabled) { if (wa.enabled) {
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
wa.out_num, wa.out_den); wa.out_num, wa.out_den);
} else { } else {
go_to_end(); go_to_end();
+7 -6
View File
@@ -56,6 +56,7 @@
#include "oakengine/proxy.h" #include "oakengine/proxy.h"
#include "oakengine/timeline.h" #include "oakengine/timeline.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "common/configwrapper.h" #include "common/configwrapper.h"
#include "tool/add.h" #include "tool/add.h"
#include "tool/beam.h" #include "tool/beam.h"
@@ -555,7 +556,7 @@ TimelineWidget::TimelineWidget(QWidget *parent)
start = std::min(start, block_in(b)); start = std::min(start, block_in(b));
} }
if (start != RATIONAL_MAX) { if (start != RATIONAL_MAX) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(get_connected_node()), reinterpret_cast<OakEngineNode *>(get_connected_node()),
start.numerator(), start.denominator()); start.numerator(), start.denominator());
} }
@@ -758,7 +759,7 @@ void TimelineWidget::ConnectNodeEvent(OakEngineNode *n)
connect(timecode_label_, &RationalSlider::value_changed, this, connect(timecode_label_, &RationalSlider::value_changed, this,
[handle](const Rational &time) { [handle](const Rational &time) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
handle, time.numerator(), time.denominator()); handle, time.numerator(), time.denominator());
}); });
{ {
@@ -1076,7 +1077,7 @@ void TimelineWidget::DeleteSelected(bool ripple)
clear_ghosts(); clear_ghosts();
if (ripple && rippled && new_playhead != RATIONAL_MAX) { if (ripple && rippled && new_playhead != RATIONAL_MAX) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(get_connected_node()), reinterpret_cast<OakEngineNode *>(get_connected_node()),
new_playhead.numerator(), new_playhead.denominator()); new_playhead.numerator(), new_playhead.denominator());
} }
@@ -1308,7 +1309,7 @@ void TimelineWidget::delete_in_to_out(bool ripple)
// Playhead move is not undoable and stays here (same as before). // Playhead move is not undoable and stays here (same as before).
if (ripple) { if (ripple) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(get_connected_node()), reinterpret_cast<OakEngineNode *>(get_connected_node()),
wa_in.numerator(), wa_in.denominator()); wa_in.numerator(), wa_in.denominator());
} }
@@ -3196,14 +3197,14 @@ void TimelineWidget::ripple_to(TimelineApp::MovementMode mode)
// If we rippled, ump to where new cut is if applicable // If we rippled, ump to where new cut is if applicable
if (mode == TimelineApp::k_trim_in) { if (mode == TimelineApp::k_trim_in) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(get_connected_node()), reinterpret_cast<OakEngineNode *>(get_connected_node()),
closest_point_to_playhead.numerator(), closest_point_to_playhead.numerator(),
closest_point_to_playhead.denominator()); closest_point_to_playhead.denominator());
} else if (mode == TimelineApp::k_trim_out && } else if (mode == TimelineApp::k_trim_out &&
closest_point_to_playhead == closest_point_to_playhead ==
viewer_playhead(reinterpret_cast<OakEngineNode *>(get_connected_node()))) { viewer_playhead(reinterpret_cast<OakEngineNode *>(get_connected_node()))) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(get_connected_node()), reinterpret_cast<OakEngineNode *>(get_connected_node()),
playhead_time.numerator(), playhead_time.denominator()); playhead_time.numerator(), playhead_time.denominator());
} }
+2 -1
View File
@@ -36,6 +36,7 @@
#include "oakengine/timeline.h" #include "oakengine/timeline.h"
#include "oakengine/undo.h" #include "oakengine/undo.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "oakengine/project.h" #include "oakengine/project.h"
#include "widget/timelinewidget/cliphandle.h" #include "widget/timelinewidget/cliphandle.h"
#include "window/mainwindow/mainwindow.h" #include "window/mainwindow/mainwindow.h"
@@ -252,7 +253,7 @@ void ImportTool::place_at(const DraggedFootageData &footage,
drop_ghosts(insert, command); drop_ghosts(insert, command);
if (jump_to_end) { if (jump_to_end) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
reinterpret_cast<OakEngineNode *>(this->sequence()), reinterpret_cast<OakEngineNode *>(this->sequence()),
max.numerator(), max.denominator()); max.numerator(), max.denominator());
} }
@@ -35,6 +35,7 @@
#include "oakengine/preview.h" #include "oakengine/preview.h"
#include "oakengine/timeline.h" #include "oakengine/timeline.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "panel/panelmanager.h" #include "panel/panelmanager.h"
#include "panel/timeline/timeline.h" #include "panel/timeline/timeline.h"
#include "widget/timelinewidget/cliphandle.h" #include "widget/timelinewidget/cliphandle.h"
@@ -268,7 +269,7 @@ void TimelineView::mousePressEvent(QMouseEvent *event)
it++) { it++) {
if (it.value().contains(scene_pos)) { if (it.value().contains(scene_pos)) {
const Rational marker_in = marker_time_range(it.key()).in(); const Rational marker_in = marker_time_range(it.key()).in();
oakengine_viewer_set_playhead(get_viewer_node(), PlaybackController::instance()->set_playhead(get_viewer_node(),
marker_in.numerator(), marker_in.numerator(),
marker_in.denominator()); marker_in.denominator());
break; break;
+7 -6
View File
@@ -47,6 +47,7 @@
#include "oakengine/display.h" #include "oakengine/display.h"
#include "widget/viewer/displaybuffer.h" #include "widget/viewer/displaybuffer.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "oakengine/videoparams.h" #include "oakengine/videoparams.h"
#include "panel/multicam/multicampanel.h" #include "panel/multicam/multicampanel.h"
#include "panel/panelmanager.h" #include "panel/panelmanager.h"
@@ -402,7 +403,7 @@ void ViewerWidget::ConnectNodeEvent(OakEngineNode *handle)
// Connect controls to set_playhead via facade // Connect controls to set_playhead via facade
connect(controls_, &PlaybackControls::time_changed, this, connect(controls_, &PlaybackControls::time_changed, this,
[handle](const Rational &time) { [handle](const Rational &time) {
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
handle, time.numerator(), time.denominator()); handle, time.numerator(), time.denominator());
}); });
@@ -649,7 +650,7 @@ void ViewerWidget::set_gizmos(OakEngineNode *node)
void ViewerWidget::start_capture(TimelineWidget *source, const TimeRange &time, void ViewerWidget::start_capture(TimelineWidget *source, const TimeRange &time,
const TrackReference &track) const TrackReference &track)
{ {
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
time.in().numerator(), time.in().denominator()); time.in().numerator(), time.in().denominator());
arm_for_recording(); arm_for_recording();
@@ -1349,10 +1350,10 @@ void ViewerWidget::play_internal(int speed, bool in_to_out_only)
if (!in_to_out_only && if (!in_to_out_only &&
viewer_output_playhead(get_connected_node()) >= last_frame) { viewer_output_playhead(get_connected_node()) >= last_frame) {
if (speed > 0) { if (speed > 0) {
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
0, 1); 0, 1);
} else { } else {
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
last_frame.numerator(), last_frame.denominator()); last_frame.numerator(), last_frame.denominator());
} }
} }
@@ -2118,7 +2119,7 @@ void ViewerWidget::play(bool in_to_out_only)
OAKENGINE_OK && OAKENGINE_OK &&
wa.enabled) { wa.enabled) {
// Jump to in point // Jump to in point
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
wa.in_num, wa.in_den); wa.in_num, wa.in_den);
} else { } else {
in_to_out_only = false; in_to_out_only = false;
@@ -2347,7 +2348,7 @@ void ViewerWidget::playback_timer_update()
// pausing. Even if we pause it later with `end_of_line`, we prefer pausing after setting the time // pausing. Even if we pause it later with `end_of_line`, we prefer pausing after setting the time
// so that an audio scrub event, etc. isn't sent. // so that an audio scrub event, etc. isn't sent.
time_changed_from_timer_ = true; time_changed_from_timer_ = true;
oakengine_viewer_set_playhead(get_connected_node(), PlaybackController::instance()->set_playhead(get_connected_node(),
time_to_set.numerator(), time_to_set.denominator()); time_to_set.numerator(), time_to_set.denominator());
time_changed_from_timer_ = false; time_changed_from_timer_ = false;
if (end_of_line) { if (end_of_line) {
+2 -1
View File
@@ -40,6 +40,7 @@
#include "common/configwrapper.h" #include "common/configwrapper.h"
#include "oakengine/project.h" #include "oakengine/project.h"
#include "oakengine/viewer.h" #include "oakengine/viewer.h"
#include "playback/playbackcontroller.h"
#include "oakengine/undo.h" #include "oakengine/undo.h"
#include "widget/viewer/vieweroutpututils.h" #include "widget/viewer/vieweroutpututils.h"
@@ -619,7 +620,7 @@ void MainWindow::reveal_viewer_in_footage_viewer(OakEngineNode *r,
} }
oakengine_undo_push(command, tr("Set Footage Workarea").toUtf8().constData()); oakengine_undo_push(command, tr("Set Footage Workarea").toUtf8().constData());
oakengine_viewer_set_playhead( PlaybackController::instance()->set_playhead(
r, r,
range.in().numerator(), range.in().denominator()); range.in().numerator(), range.in().denominator());
} }
+5 -5
View File
@@ -64,7 +64,7 @@ C callbacks just queue to the GUI thread and re-emit typed Qt signals.
later (b) migrations must use it instead of their own subscriptions. later (b) migrations must use it instead of their own subscriptions.
- **Required: build + ctest all green.** - **Required: build + ctest all green.**
### issue 0c — App-internal PlaybackController (1 day) ### issue 0c ✅ (done) — App-internal PlaybackController (1 day)
Create `app/playback/playbackcontroller.{h,cpp}` with a Create `app/playback/playbackcontroller.{h,cpp}` with a
`playhead_changed(oak::Node viewer, Rational)` signal. Route every `playhead_changed(oak::Node viewer, Rational)` signal. Route every
`oakengine_viewer_set_playhead` call site in the app (ViewerWidget playback `oakengine_viewer_set_playhead` call site in the app (ViewerWidget playback
@@ -82,26 +82,26 @@ In other words: one app-side controller that every
## Playhead migrations (pattern A, about half a day each) ## Playhead migrations (pattern A, about half a day each)
### issue 1 — timebasedview playhead subscription ### issue 1 ✅ (done) — timebasedview playhead subscription
`app/widget/timebased/timebasedview.cpp:168` (raw C callback). Reconnect to `app/widget/timebased/timebasedview.cpp:168` (raw C callback). Reconnect to
`PlaybackController::playhead_changed`. `PlaybackController::playhead_changed`.
- Acceptance: the ruler playhead line moves during playback; no raw C - Acceptance: the ruler playhead line moves during playback; no raw C
subscription remains. subscription remains.
- **Required: build + ctest all green.** - **Required: build + ctest all green.**
### issue 2 — NodeParamViewWidgetBridge playhead ### issue 2 ✅ (done) — NodeParamViewWidgetBridge playhead
`app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp:1140` (raw C). `app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp:1140` (raw C).
- Acceptance: keyframe-interpolated slider values follow the playhead - Acceptance: keyframe-interpolated slider values follow the playhead
during playback. during playback.
- **Required: build + ctest all green.** - **Required: build + ctest all green.**
### issue 3 — NodeParamViewKeyframeControl playhead ### issue 3 ✅ (done) — NodeParamViewKeyframeControl playhead
`app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp:222` (raw C). `app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp:222` (raw C).
- Acceptance: prev/next/toggle keyframe buttons have the correct state as - Acceptance: prev/next/toggle keyframe buttons have the correct state as
the playhead moves. the playhead moves.
- **Required: build + ctest all green.** - **Required: build + ctest all green.**
### issue 4 — NodeParamViewConnectedLabel playhead ### issue 4 ✅ (done) — NodeParamViewConnectedLabel playhead
`app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp:131` (raw C). `app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp:131` (raw C).
- Acceptance: the value tree refreshes with the playhead. - Acceptance: the value tree refreshes with the playhead.
- **Required: build + ctest all green.** - **Required: build + ctest all green.**
@@ -67,7 +67,7 @@ events; C callbacks just queue to the GUI thread and re-emit typed Qt signals.
must use it instead of their own subscriptions. must use it instead of their own subscriptions.
- **必做 / Requiredbuild + ctest 全绿。** - **必做 / Requiredbuild + ctest 全绿。**
### issue 0c — 建 app 内 PlaybackController1 天) ### issue 0c ✅ (done) — 建 app 内 PlaybackController1 天)
新建 `app/playback/playbackcontroller.{h,cpp}`,信号 新建 `app/playback/playbackcontroller.{h,cpp}`,信号
`playhead_changed(oak::Node viewer, Rational)` `playhead_changed(oak::Node viewer, Rational)`
把 app 内所有 `oakengine_viewer_set_playhead` 调用点(ViewerWidget 播放循环、 把 app 内所有 `oakengine_viewer_set_playhead` 调用点(ViewerWidget 播放循环、
@@ -83,23 +83,23 @@ goes through; it re-broadcasts `playhead_changed` as an app-internal Qt signal.
## playhead 族迁移 / Playhead migrations(模式 A,约半天/个) ## playhead 族迁移 / Playhead migrations(模式 A,约半天/个)
### issue 1 — timebasedview 的 playhead 订阅 ### issue 1 ✅ (done) — timebasedview 的 playhead 订阅
`app/widget/timebased/timebasedview.cpp:168`(裸 C 回调)。改连 `app/widget/timebased/timebasedview.cpp:168`(裸 C 回调)。改连
PlaybackController::playhead_changed。 PlaybackController::playhead_changed。
- 验收 / Acceptance:播放时 ruler 播放头线正常移动;无裸 C 订阅残留。 - 验收 / Acceptance:播放时 ruler 播放头线正常移动;无裸 C 订阅残留。
- **必做 / Requiredbuild + ctest 全绿。** - **必做 / Requiredbuild + ctest 全绿。**
### issue 2 — NodeParamViewWidgetBridge playhead ### issue 2 ✅ (done) — NodeParamViewWidgetBridge playhead
`app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp:1140`(裸 C)。 `app/widget/nodeparamview/nodeparamviewwidgetbridge.cpp:1140`(裸 C)。
- 验收 / Acceptance:播放时关键帧插值滑条值随播放头更新。 - 验收 / Acceptance:播放时关键帧插值滑条值随播放头更新。
- **必做 / Requiredbuild + ctest 全绿。** - **必做 / Requiredbuild + ctest 全绿。**
### issue 3 — NodeParamViewKeyframeControl playhead ### issue 3 ✅ (done) — NodeParamViewKeyframeControl playhead
`app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp:222`(裸 C)。 `app/widget/nodeparamview/nodeparamviewkeyframecontrol.cpp:222`(裸 C)。
- 验收 / Acceptance:播放头移动时 prev/next/toggle 关键帧按钮状态正确。 - 验收 / Acceptance:播放头移动时 prev/next/toggle 关键帧按钮状态正确。
- **必做 / Requiredbuild + ctest 全绿。** - **必做 / Requiredbuild + ctest 全绿。**
### issue 4 — NodeParamViewConnectedLabel playhead ### issue 4 ✅ (done) — NodeParamViewConnectedLabel playhead
`app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp:131`(裸 C)。 `app/widget/nodeparamview/nodeparamviewconnectedlabel.cpp:131`(裸 C)。
- 验收 / Acceptance:值树随播放头刷新。 - 验收 / Acceptance:值树随播放头刷新。
- **必做 / Requiredbuild + ctest 全绿。** - **必做 / Requiredbuild + ctest 全绿。**