app: migrate all engine access to the C ABI facade (nm U _ZN5olive = 0)

Every app module now reaches liboakengine exclusively through
oakengine_* C calls, EngineEventBridge subscriptions and app-side
handle headers (cliphandle/keyframehandle/nodevaluehandle/oakvaluehelper).
Direct C++ command construction, engine signal connect()s, and engine
type usage in MOC-visible signatures are gone: 557 -> 0 undefined
olive:: symbols in oak-editor.
This commit is contained in:
2026-07-26 22:43:21 +08:00
parent f95590e924
commit 0aa5879f35
256 changed files with 12357 additions and 4044 deletions
+209
View File
@@ -0,0 +1,209 @@
/***
Oak - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef OAK_KEYFRAMEHANDLE_H
#define OAK_KEYFRAMEHANDLE_H
#include <olive/core/core.h>
#include <QPointF>
#include <QString>
#include "oakengine/node.h"
namespace olive
{
class Node;
class NodeKeyframe;
using olive::core::Rational;
/**
* @brief Facade accessors for keyframe pointers held by the keyframe
* views.
*
* The keyframe/curve views keep olive::NodeKeyframe* as opaque identity
* pointers (selection, drawing, hit-testing). All engine data and
* mutations go through the liboakengine C ABI (oakengine/node.h); the
* pointer itself is only a handle. Easing types use the facade order:
* 0 = linear, 1 = bezier, 2 = hold.
*/
inline OakEngineKeyframe *keyhandle(NodeKeyframe *key)
{
return reinterpret_cast<OakEngineKeyframe *>(key);
}
inline const OakEngineKeyframe *keyhandle(const NodeKeyframe *key)
{
return reinterpret_cast<const OakEngineKeyframe *>(key);
}
inline NodeKeyframe *keyhandle(OakEngineKeyframe *key)
{
return reinterpret_cast<NodeKeyframe *>(key);
}
inline OakEngineNode *nodehandle(Node *node)
{
return reinterpret_cast<OakEngineNode *>(node);
}
inline const OakEngineNode *nodehandle(const Node *node)
{
return reinterpret_cast<const OakEngineNode *>(node);
}
inline Node *key_node(const NodeKeyframe *key)
{
return reinterpret_cast<Node *>(
oakengine_keyframe_get_node(keyhandle(key)));
}
inline Rational key_time(const NodeKeyframe *key)
{
int64_t num = 0, den = 1;
oakengine_keyframe_get_time(keyhandle(key), &num, &den);
return Rational(int(num), int(den));
}
inline int key_easing(const NodeKeyframe *key)
{
return oakengine_keyframe_get_type(keyhandle(key));
}
inline oak_node_value key_value(const NodeKeyframe *key)
{
oak_node_value v;
memset(&v, 0, sizeof(v));
oakengine_keyframe_get_value(keyhandle(key), &v);
return v;
}
inline double key_value_as_double(const NodeKeyframe *key)
{
const oak_node_value v = key_value(key);
switch (v.type) {
case OAK_NODE_VALUE_INT:
case OAK_NODE_VALUE_COMBO:
case OAK_NODE_VALUE_BOOL:
return double(v.num);
case OAK_NODE_VALUE_RATIONAL:
return v.den ? double(v.num) / double(v.den) : 0.0;
default:
return v.f[0];
}
}
inline void key_set_value_live(NodeKeyframe *key, const oak_node_value &v)
{
oakengine_keyframe_set_value_live(keyhandle(key), &v);
}
inline QPointF key_bezier_point(const NodeKeyframe *key, int point_index)
{
double x = 0, y = 0;
oakengine_keyframe_get_bezier_point(keyhandle(key), point_index, &x, &y);
return QPointF(x, y);
}
inline QPointF key_valid_bezier_point(const NodeKeyframe *key,
int point_index)
{
double x = 0, y = 0;
oakengine_keyframe_get_valid_bezier_point(keyhandle(key), point_index,
&x, &y);
return QPointF(x, y);
}
inline void key_set_bezier_point_live(NodeKeyframe *key, int point_index,
const QPointF &point)
{
oakengine_keyframe_set_bezier_point_live(keyhandle(key), point_index,
point.x(), point.y());
}
inline void key_set_time_live(NodeKeyframe *key, const Rational &time)
{
oakengine_keyframe_set_time_live(keyhandle(key), time.numerator(),
time.denominator());
}
inline bool key_has_sibling_at_time(const NodeKeyframe *key,
const Rational &time)
{
return oakengine_keyframe_has_sibling_at_time(
keyhandle(key), time.numerator(), time.denominator()) != 0;
}
inline QString key_input_id(const NodeKeyframe *key)
{
const int size =
oakengine_keyframe_get_input_id(keyhandle(key), nullptr, 0);
QByteArray buf(size + 1, '\0');
oakengine_keyframe_get_input_id(keyhandle(key), buf.data(),
int(buf.size()));
return QString::fromUtf8(buf.constData());
}
inline int key_track(const NodeKeyframe *key)
{
return oakengine_keyframe_get_track(keyhandle(key));
}
inline int key_element(const NodeKeyframe *key)
{
return oakengine_keyframe_get_element(keyhandle(key));
}
/**
* @brief ADL customization points for
* TimeBasedViewSelectionManager<NodeKeyframe>.
*
* The selection manager template calls these unqualified; the generic
* member-forwarding templates in timebasedviewselectionmanager.h cover
* other object types (e.g. TimelineMarker), while these overloads route
* keyframe access through the facade.
*/
inline Rational selection_time(NodeKeyframe *key)
{
return key_time(key);
}
inline void selection_set_time(NodeKeyframe *key, const Rational &time)
{
key_set_time_live(key, time);
}
inline bool selection_has_sibling_at_time(NodeKeyframe *key,
const Rational &time)
{
return key_has_sibling_at_time(key, time);
}
inline Node *selection_time_target_parent(NodeKeyframe *key)
{
return key_node(key);
}
} // namespace olive
#endif // OAK_KEYFRAMEHANDLE_H
+142 -53
View File
@@ -25,13 +25,16 @@
#include <QToolTip>
#include <QVBoxLayout>
#include "common/nodevaluehandle.h"
#include "common/oakvaluehelper.h"
#include "common/qtutils.h"
#include "dialog/keyframeproperties/keyframeproperties.h"
#include "node/group/group.h"
#include "keyframehandle.h"
#include "node/node.h"
#include "node/nodeundo.h"
#include "node/project/serializer/serializer.h"
#include "node/value.h"
#include "oakengine/node.h"
#include "oakengine/serializer.h"
#include "oakengine/undo.h"
#include "widget/menu/menu.h"
#include "widget/menu/menushared.h"
@@ -40,6 +43,26 @@ namespace olive
#define super TimeBasedView
static bool KeyframeToOakNodeValue(Node *node, NodeKeyframe *key,
oak_node_value *out)
{
const NodeValue::Type type = node->get_input_data_type(key->input());
QVector<QVariant> split = node->get_split_value_at_time(
NodeInput(node, key->input(), key->element()), key->time());
if (key->track() >= 0 && key->track() < split.size()) {
split[key->track()] = key->value();
}
QVector<oak_node_value> tracks(split.size());
for (int i = 0; i < split.size(); i++) {
if (!NodeTrackComponentToOakNodeValue(type, split.at(i), &tracks[i])) {
return false;
}
}
return oakengine_node_value_combine_tracks(
node_value_type_to_c(type), tracks.constData(), tracks.size(),
out) == OAKENGINE_OK;
}
KeyframeView::KeyframeView(QWidget *parent)
: super(parent)
, selection_manager_(this)
@@ -58,15 +81,16 @@ KeyframeView::KeyframeView(QWidget *parent)
void KeyframeView::delete_selected()
{
if (!selection_manager_.is_dragging()) {
MultiUndoCommand *command = new MultiUndoCommand();
QVector<OakEngineKeyframe *> keys;
foreach (NodeKeyframe *key, get_selected_keyframes()) {
command->add_child(new NodeParamRemoveKeyframeCommand(key));
keys.append(reinterpret_cast<OakEngineKeyframe *>(key));
}
Core::instance()->undo_stack()->push(
command,
tr("Deleted %1 Keyframe(s)").arg(get_selected_keyframes().size()));
oakengine_keyframes_remove_many(
keys.data(), keys.size(),
tr("Deleted %1 Keyframe(s)")
.arg(keys.size())
.toUtf8()
.constData());
}
}
@@ -86,7 +110,15 @@ KeyframeView::add_keyframes_of_input(Node *on, const QString &oinput)
{
InputConnections vec;
NodeInput resolved = NodeGroup::resolve_input(NodeInput(on, oinput));
OakEngineNode *resolved_node = nullptr;
char resolved_input[256];
int resolved_element = 0;
oakengine_group_resolve_input(
reinterpret_cast<OakEngineNode *>(on), oinput.toUtf8().constData(), -1,
&resolved_node, resolved_input, sizeof(resolved_input),
&resolved_element);
NodeInput resolved(reinterpret_cast<Node *>(resolved_node),
QString::fromUtf8(resolved_input), resolved_element);
Node *n = resolved.node();
const QString &input = resolved.input();
@@ -202,11 +234,17 @@ void KeyframeView::SelectionManagerDeselectEvent(void *obj)
bool KeyframeView::copy_selected(bool cut)
{
if (!selection_manager_.get_selected_objects().empty()) {
ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_keyframes);
sdata.set_only_serialize_keyframes(
selection_manager_.get_selected_objects());
ProjectSerializer::copy(sdata);
const auto &keys = selection_manager_.get_selected_objects();
OakEngineClipboard *cb =
oakengine_clipboard_create(OAKENGINE_CLIPBOARD_KEYFRAMES,
nullptr, nullptr);
oakengine_clipboard_set_keyframes(
cb,
reinterpret_cast<const OakEngineKeyframe *const *>(
keys.data()),
static_cast<int>(keys.size()));
oakengine_clipboard_copy(cb);
oakengine_clipboard_free(cb);
if (cut) {
delete_selected();
@@ -225,57 +263,108 @@ bool KeyframeView::paste(
return false;
}
ProjectSerializer::Result res =
ProjectSerializer::paste(ProjectSerializer::k_only_keyframes);
if (res == ProjectSerializer::k_success) {
const ProjectSerializer::SerializedKeyframes &keys =
res.get_load_data().keyframes;
OakEngineClipboard *cb = oakengine_clipboard_create(
OAKENGINE_CLIPBOARD_KEYFRAMES, nullptr, nullptr);
int result_code = OAKENGINE_SERIALIZER_NO_DATA;
oakengine_clipboard_paste(cb, OAKENGINE_CLIPBOARD_KEYFRAMES, nullptr,
&result_code, nullptr, 0);
MultiUndoCommand *command = new MultiUndoCommand();
if (result_code == OAKENGINE_SERIALIZER_OK) {
struct PasteCtx {
KeyframeView *self;
void *find_fn;
void *command;
Rational min;
int total;
};
Rational min = RATIONAL_MAX;
for (auto it = keys.cbegin(); it != keys.cend(); it++) {
for (NodeKeyframe *key : it.value()) {
min = std::min(min, key->time());
}
}
min -= get_viewer_node()->get_playhead();
PasteCtx ctx;
ctx.self = this;
ctx.find_fn = &find_node_function;
ctx.command = oakengine_undo_command_create_multi();
ctx.min = RATIONAL_MAX;
ctx.total = 0;
for (auto it = keys.cbegin(); it != keys.cend(); it++) {
const QString &paste_id = it.key();
// First pass: find minimum time
oakengine_clipboard_foreach_keyframe(
cb,
[](const char *, OakEngineKeyframe *kf, void *userdata) -> int {
auto *ctx = static_cast<PasteCtx *>(userdata);
NodeKeyframe *key = reinterpret_cast<NodeKeyframe *>(kf);
ctx->min = std::min(ctx->min, key->time());
ctx->total++;
return 0;
},
&ctx);
// Find a node with this ID
Node *node_with_id = find_node_function(paste_id);
ctx.min -= ctx.self->get_viewer_node()->get_playhead();
if (node_with_id) {
for (NodeKeyframe *key : it.value()) {
// Adjust sequence time to node's time
Rational t = key->time() - min;
t = get_adjusted_time(get_time_target(), node_with_id, t,
Node::k_transform_towards_input);
key->set_time(t);
// Second pass: process keyframes
oakengine_clipboard_foreach_keyframe(
cb,
[](const char *node_id, OakEngineKeyframe *kf,
void *userdata) -> int {
auto *ctx = static_cast<PasteCtx *>(userdata);
NodeKeyframe *key = reinterpret_cast<NodeKeyframe *>(kf);
auto &find_fn =
*static_cast<std::function<Node *(const QString &)> *>(
ctx->find_fn);
Node *node_with_id =
find_fn(QString::fromUtf8(node_id));
if (node_with_id) {
Rational t = key->time() - ctx->min;
t = ctx->self->get_adjusted_time(
ctx->self->get_time_target(), node_with_id, t,
Node::k_transform_towards_input);
key_set_time_live(key, t);
if (NodeKeyframe *existing =
node_with_id->get_keyframe_at_time_on_track(
key->input(), key->time(), key->track(),
key->element())) {
command->add_child(
new NodeParamRemoveKeyframeCommand(existing));
void *rm = oakengine_node_remove_keyframe_command(
reinterpret_cast<OakEngineKeyframe *>(existing));
oakengine_undo_command_multi_add_child(
ctx->command, rm);
}
command->add_child(
new NodeParamInsertKeyframeCommand(node_with_id, key));
oak_node_value v;
KeyframeToOakNodeValue(node_with_id, key, &v);
int tbn = 0, tbd = 0;
oakengine_node_frame_time_base(
reinterpret_cast<OakEngineNode *>(node_with_id),
&tbn, &tbd);
const int64_t time_ts = Timecode::time_to_timestamp(
key->time(), Rational(tbn, tbd), Timecode::k_round);
void *cmd = oakengine_node_insert_keyframe_command(
reinterpret_cast<OakEngineNode *>(node_with_id),
key->input().toUtf8().constData(),
key->element(), key->track(), time_ts, &v,
NodeKeyframeTypeToFacade(key->type()),
static_cast<float>(key->bezier_control_in().x()),
static_cast<float>(key->bezier_control_in().y()),
static_cast<float>(key->bezier_control_out().x()),
static_cast<float>(key->bezier_control_out().y()));
oakengine_undo_command_multi_add_child(ctx->command, cmd);
} else {
delete key;
}
} else {
qDeleteAll(it.value());
}
}
Core::instance()->undo_stack()->push(
command, tr("Pasted %1 Keyframe(s)").arg(keys.size()));
return 0;
},
&ctx);
oakengine_undo_push(ctx.command,
tr("Pasted %1 Keyframe(s)")
.arg(ctx.total)
.toUtf8()
.constData());
oakengine_clipboard_free(cb);
return true;
}
oakengine_clipboard_free(cb);
return false;
}
@@ -343,12 +432,12 @@ void KeyframeView::mouseReleaseEvent(QMouseEvent *event)
first_chance_mouse_release(event);
first_chance_mouse_event_ = false;
} else if (selection_manager_.is_dragging()) {
MultiUndoCommand *command = new MultiUndoCommand();
void *command = oakengine_undo_command_create_multi();
selection_manager_.drag_stop(command);
keyframe_drag_release(event, command);
Core::instance()->undo_stack()->push(
oakengine_undo_push(
command, tr("Moved %1 Keyframe(s)")
.arg(selection_manager_.get_selected_objects().size()));
.arg(selection_manager_.get_selected_objects().size()).toUtf8().constData());
} else if (selection_manager_.is_rubber_banding()) {
selection_manager_.rubber_band_stop();
redraw();
+1 -1
View File
@@ -131,7 +131,7 @@ protected:
{
}
virtual void keyframe_drag_release(QMouseEvent *event,
MultiUndoCommand *command)
void *command)
{
}
@@ -34,21 +34,47 @@ KeyframeViewInputConnection::KeyframeViewInputConnection(
, y_(0)
, y_behavior_(k_single_row)
, brush_(Qt::white)
, bridge_(new EngineEventBridge(this))
{
Node *n = input.input().node();
connect(n, &Node::keyframe_added, this,
&KeyframeViewInputConnection::add_keyframe);
connect(n, &Node::keyframe_removed, this,
&KeyframeViewInputConnection::remove_keyframe);
connect(n, &Node::keyframe_time_changed, this,
&KeyframeViewInputConnection::keyframe_changed);
connect(n, &Node::keyframe_type_changed, this,
&KeyframeViewInputConnection::keyframe_changed);
connect(n, &Node::keyframe_type_changed, this,
&KeyframeViewInputConnection::keyframe_type_changed);
connect(n, &Node::keyframe_value_changed, this,
&KeyframeViewInputConnection::keyframe_changed);
bridge_->subscribe(reinterpret_cast<void *>(n),
OAKENGINE_EVENT_NODE_KEYFRAME_ADDED);
bridge_->subscribe(reinterpret_cast<void *>(n),
OAKENGINE_EVENT_NODE_KEYFRAME_REMOVED);
bridge_->subscribe(reinterpret_cast<void *>(n),
OAKENGINE_EVENT_NODE_KEYFRAME_TIME_CHANGED);
bridge_->subscribe(reinterpret_cast<void *>(n),
OAKENGINE_EVENT_NODE_KEYFRAME_TYPE_CHANGED);
bridge_->subscribe(reinterpret_cast<void *>(n),
OAKENGINE_EVENT_NODE_KEYFRAME_VALUE_CHANGED);
connect(bridge_, &EngineEventBridge::node_keyframe_added, this,
[this](OakEngineNode *, OakEngineKeyframe *key,
const QString &, int, int) {
add_keyframe(key);
});
connect(bridge_, &EngineEventBridge::node_keyframe_removed, this,
[this](OakEngineNode *, OakEngineKeyframe *key,
const QString &, int, int) {
remove_keyframe(key);
});
connect(bridge_, &EngineEventBridge::node_keyframe_time_changed, this,
[this](OakEngineNode *, OakEngineKeyframe *key) {
keyframe_changed(key);
});
connect(bridge_, &EngineEventBridge::node_keyframe_type_changed, this,
[this](OakEngineNode *, OakEngineKeyframe *key) {
keyframe_changed(key);
});
connect(bridge_, &EngineEventBridge::node_keyframe_type_changed, this,
[this](OakEngineNode *, OakEngineKeyframe *key) {
keyframe_type_changed(key);
});
connect(bridge_, &EngineEventBridge::node_keyframe_value_changed, this,
[this](OakEngineNode *, OakEngineKeyframe *key) {
keyframe_changed(key);
});
}
void KeyframeViewInputConnection::set_keyframe_y(int y)
@@ -78,30 +104,34 @@ void KeyframeViewInputConnection::set_brush(const QBrush &brush)
}
}
void KeyframeViewInputConnection::add_keyframe(NodeKeyframe *key)
void KeyframeViewInputConnection::add_keyframe(OakEngineKeyframe *key)
{
if (key->key_track_ref() == input_) {
NodeKeyframe *nk = reinterpret_cast<NodeKeyframe *>(key);
if (nk->key_track_ref() == input_) {
emit require_update();
}
}
void KeyframeViewInputConnection::remove_keyframe(NodeKeyframe *key)
void KeyframeViewInputConnection::remove_keyframe(OakEngineKeyframe *key)
{
if (key->key_track_ref() == input_) {
NodeKeyframe *nk = reinterpret_cast<NodeKeyframe *>(key);
if (nk->key_track_ref() == input_) {
emit require_update();
}
}
void KeyframeViewInputConnection::keyframe_changed(NodeKeyframe *key)
void KeyframeViewInputConnection::keyframe_changed(OakEngineKeyframe *key)
{
if (key->key_track_ref() == input_) {
NodeKeyframe *nk = reinterpret_cast<NodeKeyframe *>(key);
if (nk->key_track_ref() == input_) {
emit require_update();
}
}
void KeyframeViewInputConnection::keyframe_type_changed(NodeKeyframe *key)
void KeyframeViewInputConnection::keyframe_type_changed(OakEngineKeyframe *key)
{
if (key->key_track_ref() == input_) {
NodeKeyframe *nk = reinterpret_cast<NodeKeyframe *>(key);
if (nk->key_track_ref() == input_) {
emit type_changed();
}
}
@@ -24,9 +24,12 @@
#include <QObject>
#include "engineeventbridge.h"
#include "node/node.h"
#include "node/param.h"
struct OakEngineKeyframe;
namespace olive
{
@@ -85,14 +88,16 @@ private:
QBrush brush_;
EngineEventBridge *bridge_ = nullptr;
private slots:
void add_keyframe(NodeKeyframe *key);
void add_keyframe(OakEngineKeyframe *key);
void remove_keyframe(NodeKeyframe *key);
void remove_keyframe(OakEngineKeyframe *key);
void keyframe_changed(NodeKeyframe *key);
void keyframe_changed(OakEngineKeyframe *key);
void keyframe_type_changed(NodeKeyframe *key);
void keyframe_type_changed(OakEngineKeyframe *key);
};
}