Files
oak-editor/include/timeline/marker.h
T
Mike-Solar 81431d180d refactor(node,timeline): route oaknode->oaktimeline calls through the C ABI
- ViewerOutput owns timeline markers/work area via refcounted
  OakTimeline* value handles (oaktimeline_*_create) instead of C++
  objects
- oaktimeline C API: add marker_list_create/marker_add/
  workarea_create/workarea_set_enabled; handle boxes gain an optional
  deleter for owning handles
- oaknode_node_get_markers/get_work_area return addref'd OakTimeline*
  handles via out params (named-struct forward declarations avoid the
  public header cycle); drop OakNodeMarkerList/OakNodeWorkArea
- serializers 210528-230220 load/save markers and work areas through
  the oaktimeline C API; SerializedMarker POD replaces
  std::vector<TimelineMarker*> in the serializer interface
- Sequence::add_default_nodes uses oaktimeline_add_track_command
- clip.cpp display-mode enums come from the new neutral
  include/timeline/displaymode.h; delete src/node/transition/timeline
- oakcommon xml: add oakcommon_xml_reader/writer_wrap_native borrowed
  wrappers (C++ adapter use)
- liboaknode now has zero C++ symbol references into liboaktimeline

Tests: new owning-handle and wrap_native cases; all standalone trees
green (common 196, codec 22, audio 40, task 110, render 49,
timeline 123, node 96, plugin 100).
2026-08-07 22:53:44 +08:00

139 lines
4.6 KiB
C

/***
Oak Video Editor - 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_EDITOR_TIMELINE_MARKER_H
#define OAK_EDITOR_TIMELINE_MARKER_H
#include "common/xmlutils.h"
#include "node/node.h"
#include "timeline/error.h"
#include "undo/undocommand.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief By-value handle to a timeline marker list
* (olive::TimelineMarkerList).
*
* Borrowed handles are obtained via oaktimeline_marker_list_of() and box
* a reference into the owning node; owning handles are created by
* oaktimeline_marker_list_create(). Either way, release with
* oaktimeline_marker_list_free() (or handle.release(handle.ctx)) when
* done — release destroys the list only for owning handles.
*/
typedef struct OakTimelineMarkerList {
void *ctx; /**< Opaque pointer to the object's box. */
void (*addref)(void *ctx); /**< Atomically increments the box count. */
void (*release)(void *ctx); /**< Decrements the count, frees the box. */
uint32_t abi_version; /**< OAKTIMELINE_ABI_VERSION. */
} OakTimelineMarkerList;
/**
* @brief Create an owning handle to a new, empty marker list. Empty
* handle (ctx == NULL) on allocation failure.
*/
OakTimelineMarkerList oaktimeline_marker_list_create(void);
/**
* @brief Borrowed marker list of a viewer node (sequence). Empty handle
* (ctx == NULL) for an empty node handle or when the node is not a
* viewer.
*/
OakTimelineMarkerList oaktimeline_marker_list_of(OakNodeNode owner);
/**
* @brief Release a marker list handle (destroys the list itself only
* for owning handles). NULL / empty-handle no-op; clears
* list->ctx after releasing.
*/
void oaktimeline_marker_list_free(OakTimelineMarkerList *list);
/**
* @brief Append a marker directly (no undo command). name may be NULL
* for an empty name.
*/
int oaktimeline_marker_add(OakTimelineMarkerList list, int in_num,
int in_den, int out_num, int out_den,
const char *name, int color);
/**
* @brief Number of markers. Out-param convention; OAKTIMELINE_E_INVALID
* for empty/NULL arguments.
*/
int oaktimeline_marker_count(OakTimelineMarkerList list, int *out_count);
/**
* @brief Marker at index: time as num/den pairs, color and name
* (two-stage string). OAKTIMELINE_E_NOT_FOUND when out of range.
*/
int oaktimeline_marker_at(OakTimelineMarkerList list, int index,
int *in_num, int *in_den, int *out_num, int *out_den,
int *color, char *name_buf, int buf_size);
/**
* @brief Create a command that adds a marker (olive::MarkerAddCommand).
*
* Owned command; free with oakundo_command_free(). Redo it directly or
* push it on an undo stack. Empty handle on failure.
*/
OakUndoCommand oaktimeline_marker_add_command(
OakTimelineMarkerList list, int in_num, int in_den, int out_num,
int out_den, const char *name, int color);
/**
* @brief Create a command that removes the marker at `index`.
* OAKTIMELINE_E_NOT_FOUND (as an empty result documented by error) is
* reported by returning an empty handle.
*/
OakUndoCommand oaktimeline_marker_remove_at_command(
OakTimelineMarkerList list, int index);
/**
* @brief Create a command that sets a marker's time range.
*/
OakUndoCommand oaktimeline_marker_set_time_command(
OakTimelineMarkerList list, int index, int in_num, int in_den,
int out_num, int out_den);
/**
* @brief Create a command that sets a marker's color and/or name.
* `name` may be NULL to leave the name unchanged (color still applies
* when >= 0; both NULL-name and color < 0 is a no-op error).
*/
OakUndoCommand oaktimeline_marker_set_props_command(
OakTimelineMarkerList list, int index, int color, const char *name);
/**
* @brief Load/save the list through oakcommon XML handles. The reader
* must be positioned on the wrapping element (e.g. "markers").
*/
int oaktimeline_marker_list_load(OakTimelineMarkerList list,
OakXmlReader reader);
int oaktimeline_marker_list_save(OakTimelineMarkerList list,
OakXmlWriter writer);
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_TIMELINE_MARKER_H