style: unify identifier naming per updated conventions

Automated with clang-tidy readability-identifier-naming (config added to
.clang-tidy) plus scripted passes, per the updated rules now documented
in CONTRIBUTING.md:

- types (class/struct/enum/alias/template params): PascalCase
- functions, variables, members: snake_case (incl. rational -> Rational)
- private/protected members: trailing underscore; static member
  variables likewise (instance_, available_themes_)
- constants and enum values: snake_case (kLinear -> k_linear,
  F32P -> f32p); ALL_CAPS reserved for macros
- macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG ->
  OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE,
  include guards -> OAK_*)
- file names: all lowercase (Current/Plugin/OliveHost/OliveClip/
  OlivePluginInstance -> current/plugin/olivehost/oliveclip/
  oliveplugininstance)
- getters share the member name sans underscore, setters set_foo()
- Qt and third-party (OpenFX) virtual overrides and framework callbacks
  keep their original names (exempt in .clang-tidy)

Manual follow-ups required where automation could not reach:
- string-based QMetaObject/SIGNAL/SLOT references updated to renamed
  methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...)
- macro bodies referencing renamed methods (OLIVE_CONFIG,
  NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*)
- self-shadowing locals renamed where signals/methods became same-named
  (size_changed, worker_count, selected_items, import param, filters)
- third_party OFX member/namespace usages restored (OFX::Host::*,
  _created, _clipPrefsDirty, createInstance, clearPersistentMessage)
- STL protocol aliases restored (const_iterator) with .clang-tidy
  ignore rules; qHash overloads restored

Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
2026-07-19 16:10:54 +08:00
parent cb1718a103
commit bb40b4923e
1014 changed files with 44257 additions and 44220 deletions
+44 -44
View File
@@ -46,14 +46,14 @@ TimeBasedView::TimeBasedView(QWidget *parent)
setScene(&scene_);
// Set default scale (ensures non-zero scale from beginning)
SetScale(1.0);
set_scale(1.0);
// Default to no default drag mode
SetDefaultDragMode(NoDrag);
set_default_drag_mode(NoDrag);
// Signal to update bounding rect when the scene changes
connect(&scene_, &QGraphicsScene::changed, this,
&TimeBasedView::UpdateSceneRect);
&TimeBasedView::update_scene_rect);
// Workaround for Qt drawing issues with the default MinimalViewportUpdate. While this might be
// slower (Qt documentation says it may actually be faster in some situations),
@@ -61,13 +61,13 @@ TimeBasedView::TimeBasedView(QWidget *parent)
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
}
void TimeBasedView::TimebaseChangedEvent(const rational &)
void TimeBasedView::TimebaseChangedEvent(const Rational &)
{
// Timebase influences position/visibility of playhead
viewport()->update();
}
void TimeBasedView::EnableSnap(const std::vector<rational> &points)
void TimeBasedView::enable_snap(const std::vector<Rational> &points)
{
snapped_ = true;
snap_time_ = points;
@@ -75,14 +75,14 @@ void TimeBasedView::EnableSnap(const std::vector<rational> &points)
viewport()->update();
}
void TimeBasedView::DisableSnap()
void TimeBasedView::disable_snap()
{
snapped_ = false;
viewport()->update();
}
const double &TimeBasedView::GetYScale() const
const double &TimeBasedView::get_y_scale() const
{
return y_scale_;
}
@@ -91,7 +91,7 @@ void TimeBasedView::VerticalScaleChangedEvent(double)
{
}
void TimeBasedView::ZoomIntoCursorPosition(QWheelEvent *event,
void TimeBasedView::zoom_into_cursor_position(QWheelEvent *event,
double scale_multiplier,
const QPointF &cursor_pos)
{
@@ -116,12 +116,12 @@ void TimeBasedView::ZoomIntoCursorPosition(QWheelEvent *event,
if (!only_vertical) {
double old_scroll = horizontalScrollBar()->value();
double old_scale = GetScale();
emit ScaleChanged(old_scale * scale_multiplier);
double old_scale = get_scale();
emit scale_changed(old_scale * scale_multiplier);
// Use GetScale so that if this value was clamped, we don't erroneously use an unclamped value
int new_x_scroll =
qRound((cursor_pos.x() + old_scroll) / old_scale * GetScale() -
qRound((cursor_pos.x() + old_scroll) / old_scale * get_scale() -
cursor_pos.x());
horizontalScrollBar()->setValue(new_x_scroll);
}
@@ -129,18 +129,18 @@ void TimeBasedView::ZoomIntoCursorPosition(QWheelEvent *event,
if (!only_horizontal) {
double old_y_scroll = verticalScrollBar()->value();
double old_y_scale = GetYScale();
SetYScale(old_y_scale * scale_multiplier);
double old_y_scale = get_y_scale();
set_y_scale(old_y_scale * scale_multiplier);
// Use GetYScale so that if this value was clamped, we don't erroneously use an unclamped value
int new_y_scroll =
qRound((cursor_pos.y() + old_y_scroll) / old_y_scale * GetYScale() -
qRound((cursor_pos.y() + old_y_scroll) / old_y_scale * get_y_scale() -
cursor_pos.y());
verticalScrollBar()->setValue(new_y_scroll);
}
}
void TimeBasedView::SetYScale(const double &y_scale)
void TimeBasedView::set_y_scale(const double &y_scale)
{
Q_ASSERT(y_scale > 0);
@@ -153,29 +153,29 @@ void TimeBasedView::SetYScale(const double &y_scale)
}
}
void TimeBasedView::SetViewerNode(ViewerOutput *v)
void TimeBasedView::set_viewer_node(ViewerOutput *v)
{
if (viewer_) {
disconnect(viewer_, &ViewerOutput::PlayheadChanged, viewport(),
disconnect(viewer_, &ViewerOutput::playhead_changed, viewport(),
static_cast<void (QWidget::*)()>(&TimeBasedView::update));
}
viewer_ = v;
if (viewer_) {
connect(viewer_, &ViewerOutput::PlayheadChanged, viewport(),
connect(viewer_, &ViewerOutput::playhead_changed, viewport(),
static_cast<void (QWidget::*)()>(&TimeBasedView::update));
}
}
QPointF TimeBasedView::ScalePoint(const QPointF &p) const
QPointF TimeBasedView::scale_point(const QPointF &p) const
{
return QPointF(p.x() * GetScale(), p.y() * GetYScale());
return QPointF(p.x() * get_scale(), p.y() * get_y_scale());
}
QPointF TimeBasedView::UnscalePoint(const QPointF &p) const
QPointF TimeBasedView::unscale_point(const QPointF &p) const
{
return QPointF(p.x() / GetScale(), p.y() / GetYScale());
return QPointF(p.x() / get_scale(), p.y() / get_y_scale());
}
void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect)
@@ -183,9 +183,9 @@ void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect)
QGraphicsView::drawForeground(painter, rect);
if (!timebase().isNull()) {
double width = TimeToScene(timebase());
double width = time_to_scene(timebase());
playhead_scene_left_ = GetPlayheadX();
playhead_scene_left_ = get_playhead_x();
playhead_scene_right_ = playhead_scene_left_ + width;
QRectF playhead_rect(playhead_scene_left_, rect.top(), width,
@@ -208,15 +208,15 @@ void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect)
if (snapped_) {
painter->setPen(palette().text().color());
foreach (const rational &r, snap_time_) {
double x = TimeToScene(r);
foreach (const Rational &r, snap_time_) {
double x = time_to_scene(r);
painter->drawLine(x, rect.top(), x, rect.height());
}
}
}
bool TimeBasedView::PlayheadPress(QMouseEvent *event)
bool TimeBasedView::playhead_press(QMouseEvent *event)
{
QPointF scene_pos = mapToScene(event->pos());
@@ -227,7 +227,7 @@ bool TimeBasedView::PlayheadPress(QMouseEvent *event)
return dragging_playhead_;
}
bool TimeBasedView::PlayheadMove(QMouseEvent *event)
bool TimeBasedView::playhead_move(QMouseEvent *event)
{
if (!dragging_playhead_) {
return false;
@@ -235,31 +235,31 @@ bool TimeBasedView::PlayheadMove(QMouseEvent *event)
if (viewer_) {
QPointF scene_pos = mapToScene(event->pos());
rational mouse_time = qMax(rational(0), SceneToTime(scene_pos.x()));
Rational mouse_time = qMax(Rational(0), scene_to_time(scene_pos.x()));
if (Core::instance()->snapping() && snap_service_) {
rational movement;
Rational movement;
snap_service_->SnapPoint({ mouse_time }, &movement,
TimeBasedWidget::kSnapAll &
~TimeBasedWidget::kSnapToPlayhead);
snap_service_->snap_point({ mouse_time }, &movement,
TimeBasedWidget::k_snap_all &
~TimeBasedWidget::k_snap_to_playhead);
mouse_time += movement;
}
viewer_->SetPlayhead(mouse_time);
viewer_->set_playhead(mouse_time);
}
return true;
}
bool TimeBasedView::PlayheadRelease(QMouseEvent *)
bool TimeBasedView::playhead_release(QMouseEvent *)
{
if (dragging_playhead_) {
dragging_playhead_ = false;
if (snap_service_) {
snap_service_->HideSnaps();
snap_service_->hide_snaps();
}
return true;
@@ -268,23 +268,23 @@ bool TimeBasedView::PlayheadRelease(QMouseEvent *)
return false;
}
qreal TimeBasedView::GetPlayheadX()
qreal TimeBasedView::get_playhead_x()
{
if (viewer_) {
return TimeToScene(viewer_->GetPlayhead());
return time_to_scene(viewer_->get_playhead());
} else {
return 0;
}
}
void TimeBasedView::SetEndTime(const rational &length)
void TimeBasedView::set_end_time(const Rational &length)
{
end_time_ = length;
UpdateSceneRect();
update_scene_rect();
}
void TimeBasedView::UpdateSceneRect()
void TimeBasedView::update_scene_rect()
{
QRectF bounding_rect = scene_.itemsBoundingRect();
@@ -292,7 +292,7 @@ void TimeBasedView::UpdateSceneRect()
bounding_rect.setLeft(0);
// Ensure the scene is always the full length of the timeline with a gap at the end to work with
bounding_rect.setRight(TimeToScene(end_time_) + width());
bounding_rect.setRight(time_to_scene(end_time_) + width());
// Any further rect processing from derivatives can be done here
SceneRectUpdateEvent(bounding_rect);
@@ -307,7 +307,7 @@ void TimeBasedView::resizeEvent(QResizeEvent *event)
{
QGraphicsView::resizeEvent(event);
UpdateSceneRect();
update_scene_rect();
}
void TimeBasedView::ScaleChangedEvent(const double &scale)
@@ -315,7 +315,7 @@ void TimeBasedView::ScaleChangedEvent(const double &scale)
TimeScaledObject::ScaleChangedEvent(scale);
// Update scene rect
UpdateSceneRect();
update_scene_rect();
// Force redraw for playhead if the above function didn't do it
viewport()->update();
+28 -28
View File
@@ -19,8 +19,8 @@
***/
#ifndef TIMELINEVIEWBASE_H
#define TIMELINEVIEWBASE_H
#ifndef OAK_TIMELINEVIEWBASE_H
#define OAK_TIMELINEVIEWBASE_H
#include <QGraphicsView>
#include <vector>
@@ -39,26 +39,26 @@ class TimeBasedView : public HandMovableView, public TimeScaledObject {
public:
TimeBasedView(QWidget *parent = nullptr);
void EnableSnap(const std::vector<rational> &points);
void DisableSnap();
bool IsSnapped() const
void enable_snap(const std::vector<Rational> &points);
void disable_snap();
bool is_snapped() const
{
return snapped_;
}
TimeBasedWidget *GetSnapService() const
TimeBasedWidget *get_snap_service() const
{
return snap_service_;
}
void SetSnapService(TimeBasedWidget *service)
void set_snap_service(TimeBasedWidget *service)
{
snap_service_ = service;
}
const double &GetYScale() const;
void SetYScale(const double &y_scale);
const double &get_y_scale() const;
void set_y_scale(const double &y_scale);
virtual bool IsDraggingPlayhead() const
virtual bool is_dragging_playhead() const
{
return dragging_playhead_;
}
@@ -71,26 +71,26 @@ public:
{
}
ViewerOutput *GetViewerNode() const
ViewerOutput *get_viewer_node() const
{
return viewer_;
}
void SetViewerNode(ViewerOutput *v);
void set_viewer_node(ViewerOutput *v);
QPointF ScalePoint(const QPointF &p) const;
QPointF UnscalePoint(const QPointF &p) const;
QPointF scale_point(const QPointF &p) const;
QPointF unscale_point(const QPointF &p) const;
public slots:
void SetEndTime(const rational &length);
void set_end_time(const Rational &length);
/**
* @brief Slot called whenever the view resizes or the scene contents change to enforce minimum scene sizes
*/
void UpdateSceneRect();
void update_scene_rect();
signals:
void ScaleChanged(double scale);
void scale_changed(double scale);
protected:
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
@@ -105,27 +105,27 @@ protected:
virtual void VerticalScaleChangedEvent(double scale);
virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier,
virtual void zoom_into_cursor_position(QWheelEvent *event, double multiplier,
const QPointF &cursor_pos) override;
bool PlayheadPress(QMouseEvent *event);
bool PlayheadMove(QMouseEvent *event);
bool PlayheadRelease(QMouseEvent *event);
bool playhead_press(QMouseEvent *event);
bool playhead_move(QMouseEvent *event);
bool playhead_release(QMouseEvent *event);
virtual void TimebaseChangedEvent(const rational &) override;
virtual void TimebaseChangedEvent(const Rational &) override;
bool IsYAxisEnabled() const
bool is_y_axis_enabled() const
{
return y_axis_enabled_;
}
void SetYAxisEnabled(bool e)
void set_y_axis_enabled(bool e)
{
y_axis_enabled_ = e;
}
private:
qreal GetPlayheadX();
qreal get_playhead_x();
double playhead_scene_left_;
double playhead_scene_right_;
@@ -135,9 +135,9 @@ private:
QGraphicsScene scene_;
bool snapped_;
std::vector<rational> snap_time_;
std::vector<Rational> snap_time_;
rational end_time_;
Rational end_time_;
TimeBasedWidget *snap_service_;
@@ -150,4 +150,4 @@ private:
}
#endif // TIMELINEVIEWBASE_H
#endif // OAK_TIMELINEVIEWBASE_H
@@ -19,8 +19,8 @@
***/
#ifndef TIMEBASEDVIEWSELECTIONMANAGER_H
#define TIMEBASEDVIEWSELECTIONMANAGER_H
#ifndef OAK_TIMEBASEDVIEWSELECTIONMANAGER_H
#define OAK_TIMEBASEDVIEWSELECTIONMANAGER_H
#include <QGraphicsView>
#include <QMouseEvent>
@@ -40,32 +40,32 @@ public:
TimeBasedViewSelectionManager(TimeBasedView *view)
: view_(view)
, rubberband_(nullptr)
, snap_mask_(TimeBasedWidget::kSnapAll)
, snap_mask_(TimeBasedWidget::k_snap_all)
{
}
void SetSnapMask(TimeBasedWidget::SnapMask e)
void set_snap_mask(TimeBasedWidget::SnapMask e)
{
snap_mask_ = e;
}
void ClearDrawnObjects()
void clear_drawn_objects()
{
drawn_objects_.clear();
}
void DeclareDrawnObject(T *object, const QRectF &rect)
void declare_drawn_object(T *object, const QRectF &rect)
{
QRectF r(view_->UnscalePoint(rect.topLeft()),
view_->UnscalePoint(rect.bottomRight()));
QRectF r(view_->unscale_point(rect.topLeft()),
view_->unscale_point(rect.bottomRight()));
drawn_objects_.push_back({ object, r });
}
bool Select(T *key)
bool select(T *key)
{
Q_ASSERT(key);
if (!IsSelected(key)) {
if (!is_selected(key)) {
selected_.push_back(key);
return true;
}
@@ -73,7 +73,7 @@ public:
return false;
}
bool Deselect(T *key)
bool deselect(T *key)
{
Q_ASSERT(key);
@@ -86,31 +86,31 @@ public:
}
}
void ClearSelection()
void clear_selection()
{
selected_.clear();
}
bool IsSelected(T *key) const
bool is_selected(T *key) const
{
return std::find(selected_.cbegin(), selected_.cend(), key) !=
selected_.cend();
}
const std::vector<T *> &GetSelectedObjects() const
const std::vector<T *> &get_selected_objects() const
{
return selected_;
}
void SetTimebase(const rational &tb)
void set_timebase(const Rational &tb)
{
timebase_ = tb;
}
T *GetObjectAtPoint(const QPointF &scene_pt)
T *get_object_at_point(const QPointF &scene_pt)
{
// Iterate in reverse order because the objects drawn later will appear on top to the user
QPointF unscaled = view_->UnscalePoint(scene_pt);
QPointF unscaled = view_->unscale_point(scene_pt);
for (auto it = drawn_objects_.crbegin(); it != drawn_objects_.crend();
it++) {
const DrawnObject &kp = *it;
@@ -122,36 +122,36 @@ public:
return nullptr;
}
T *GetObjectAtPoint(const QPoint &pt)
T *get_object_at_point(const QPoint &pt)
{
return GetObjectAtPoint(view_->mapToScene(pt));
return get_object_at_point(view_->mapToScene(pt));
}
T *MousePress(QMouseEvent *event)
T *mouse_press(QMouseEvent *event)
{
T *key_under_cursor = nullptr;
if (event->button() == Qt::LeftButton ||
event->button() == Qt::RightButton) {
// See if there's a keyframe in this position
key_under_cursor = GetObjectAtPoint(event->pos());
key_under_cursor = get_object_at_point(event->pos());
bool holding_shift = event->modifiers() & Qt::ShiftModifier;
if (!key_under_cursor || !IsSelected(key_under_cursor)) {
if (!key_under_cursor || !is_selected(key_under_cursor)) {
if (!holding_shift) {
// If not already selecting and not holding shift, clear the current selection
ClearSelection();
clear_selection();
}
// Add item to selection, either nothing if shift wasn't held, or the existing selection
if (key_under_cursor) {
Select(key_under_cursor);
select(key_under_cursor);
view_->SelectionManagerSelectEvent(key_under_cursor);
}
} else if (holding_shift) {
// If selected and holding shift, de-select this item but do nothing else
Deselect(key_under_cursor);
deselect(key_under_cursor);
view_->SelectionManagerDeselectEvent(key_under_cursor);
key_under_cursor = nullptr;
}
@@ -160,12 +160,12 @@ public:
return key_under_cursor;
}
bool IsDragging() const
bool is_dragging() const
{
return !dragging_.empty();
}
void DragStart(T *initial_item, QMouseEvent *event,
void drag_start(T *initial_item, QMouseEvent *event,
TimeTargetObject *target = nullptr)
{
if (event->button() != Qt::LeftButton) {
@@ -202,70 +202,70 @@ public:
if (target) {
time_targets_[i] = time_targets_[i + selected_.size()] =
QtUtils::GetParentOfType<Node>(obj);
QtUtils::get_parent_of_type<Node>(obj);
}
} else {
dragging_[i] = obj->time();
snap_points_[i] = obj->time();
if (target) {
time_targets_[i] = QtUtils::GetParentOfType<Node>(obj);
time_targets_[i] = QtUtils::get_parent_of_type<Node>(obj);
}
}
}
drag_mouse_start_ =
view_->UnscalePoint(view_->mapToScene(event->pos()));
view_->unscale_point(view_->mapToScene(event->pos()));
}
void SnapPoints(rational *movement)
void snap_points(Rational *movement)
{
std::vector<rational> copy = snap_points_;
std::vector<Rational> copy = snap_points_;
if (time_target_) {
for (size_t i = 0; i < copy.size(); i++) {
if (Node *parent = time_targets_[i]) {
copy[i] = time_target_->GetAdjustedTime(
parent, time_target_->GetTimeTarget(), copy[i],
Node::kTransformTowardsOutput);
copy[i] = time_target_->get_adjusted_time(
parent, time_target_->get_time_target(), copy[i],
Node::k_transform_towards_output);
}
}
}
if (Core::instance()->snapping() && view_->GetSnapService()) {
view_->GetSnapService()->SnapPoint(copy, movement, snap_mask_);
if (Core::instance()->snapping() && view_->get_snap_service()) {
view_->get_snap_service()->snap_point(copy, movement, snap_mask_);
}
}
void Unsnap()
void unsnap()
{
if (view_->GetSnapService()) {
view_->GetSnapService()->HideSnaps();
if (view_->get_snap_service()) {
view_->get_snap_service()->hide_snaps();
}
}
void DragMove(const QPoint &local_pos,
void drag_move(const QPoint &local_pos,
const QString &tip_format = QString())
{
rational time_diff =
view_->SceneToTimeNoGrid(view_->mapToScene(local_pos).x() -
view_->ScalePoint(drag_mouse_start_).x());
Rational time_diff =
view_->scene_to_time_no_grid(view_->mapToScene(local_pos).x() -
view_->scale_point(drag_mouse_start_).x());
// Snap points
rational presnap_time_diff = time_diff;
SnapPoints(&time_diff);
Rational presnap_time_diff = time_diff;
snap_points(&time_diff);
// Validate snapping
if (Core::instance()->snapping() && view_->GetSnapService()) {
if (Core::instance()->snapping() && view_->get_snap_service()) {
for (size_t i = 0; i < selected_.size(); i++) {
rational proposed_time = dragging_.at(i) + time_diff;
Rational proposed_time = dragging_.at(i) + time_diff;
T *sel = selected_.at(i);
if (sel->has_sibling_at_time(proposed_time)) {
// Unsnap
time_diff = presnap_time_diff;
if (view_->GetSnapService()) {
view_->GetSnapService()->HideSnaps();
if (view_->get_snap_service()) {
view_->get_snap_service()->hide_snaps();
}
break;
}
@@ -274,11 +274,11 @@ public:
// Validate movement
for (size_t i = 0; i < selected_.size(); i++) {
rational proposed_time = dragging_.at(i) + time_diff;
Rational proposed_time = dragging_.at(i) + time_diff;
T *sel = selected_.at(i);
// Magic number: use interval of 1ms to avoid collisions
rational adj(1, 1000);
Rational adj(1, 1000);
if (dragging_.at(i) < proposed_time) {
// Negate adjustment value if origin is less than proposed time
adj = -adj;
@@ -289,13 +289,13 @@ public:
loop = false;
while (sel->has_sibling_at_time(proposed_time)) {
proposed_time += adj;
Unsnap();
unsnap();
}
if (proposed_time < 0) {
// Prevent any object from going below zero
proposed_time = 0;
Unsnap();
unsnap();
// Setting our proposed time to zero may (re)introduce a conflict that we just avoided
// with the sibling check above, so we request it to happen again. To avoid a negative
@@ -315,7 +315,7 @@ public:
}
// Show information about this keyframe
rational display_time;
Rational display_time;
if constexpr (std::is_same_v<T, TimelineMarker>) {
display_time = initial_drag_item_->time().in();
@@ -324,7 +324,7 @@ public:
}
QString tip = QString::fromStdString(Timecode::time_to_timecode(
display_time, timebase_, Core::instance()->GetTimecodeDisplay(),
display_time, timebase_, Core::instance()->get_timecode_display(),
false));
last_used_tip_format_ = tip_format;
@@ -336,12 +336,12 @@ public:
QToolTip::showText(QCursor::pos(), tip);
}
void DragStop(MultiUndoCommand *command)
void drag_stop(MultiUndoCommand *command)
{
QToolTip::hideText();
for (size_t i = 0; i < selected_.size(); i++) {
rational current;
Rational current;
if constexpr (std::is_same_v<T, TimelineMarker>) {
current = selected_.at(i)->time().in();
} else {
@@ -352,15 +352,15 @@ public:
}
dragging_.clear();
Unsnap();
unsnap();
}
void RubberBandStart(QMouseEvent *event)
void rubber_band_start(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton ||
event->button() == Qt::RightButton) {
rubberband_scene_start_ =
view_->UnscalePoint(view_->mapToScene(event->pos()));
view_->unscale_point(view_->mapToScene(event->pos()));
rubberband_ = new QRubberBand(QRubberBand::Rectangle, view_);
rubberband_->setGeometry(
@@ -371,49 +371,49 @@ public:
}
}
void RubberBandMove(const QPoint &pos)
void rubber_band_move(const QPoint &pos)
{
if (IsRubberBanding()) {
QRectF band_rect = QRectF(view_->mapFromScene(view_->ScalePoint(
if (is_rubber_banding()) {
QRectF band_rect = QRectF(view_->mapFromScene(view_->scale_point(
rubberband_scene_start_)),
pos)
.normalized();
rubberband_->setGeometry(band_rect.toRect());
QPointF current = view_->UnscalePoint(view_->mapToScene(pos));
QPointF current = view_->unscale_point(view_->mapToScene(pos));
QRectF scene_rect =
QRectF(rubberband_scene_start_, current).normalized();
selected_ = rubberband_preselected_;
foreach (const DrawnObject &kp, drawn_objects_) {
if (scene_rect.intersects(kp.second)) {
Select(kp.first);
select(kp.first);
}
}
}
}
void RubberBandStop()
void rubber_band_stop()
{
if (IsRubberBanding()) {
if (is_rubber_banding()) {
delete rubberband_;
rubberband_ = nullptr;
}
}
bool IsRubberBanding() const
bool is_rubber_banding() const
{
return rubberband_;
}
void ForceDragUpdate()
void force_drag_update()
{
if (IsRubberBanding() || IsDragging()) {
if (is_rubber_banding() || is_dragging()) {
QPoint local_pos = view_->viewport()->mapFromGlobal(QCursor::pos());
if (IsRubberBanding()) {
RubberBandMove(local_pos);
if (is_rubber_banding()) {
rubber_band_move(local_pos);
} else {
DragMove(local_pos, last_used_tip_format_);
drag_move(local_pos, last_used_tip_format_);
}
}
}
@@ -421,24 +421,24 @@ public:
private:
class SetTimeCommand : public UndoCommand {
public:
SetTimeCommand(T *key, const rational &time)
SetTimeCommand(T *key, const Rational &time)
{
key_ = key;
new_time_ = time;
old_time_ = key_->time();
}
SetTimeCommand(T *key, const rational &new_time,
const rational &old_time)
SetTimeCommand(T *key, const Rational &new_time,
const Rational &old_time)
{
key_ = key;
new_time_ = new_time;
old_time_ = old_time;
}
virtual Project *GetRelevantProject() const override
virtual Project *get_relevant_project() const override
{
return Project::GetProjectFromObject(key_);
return Project::get_project_from_object(key_);
}
protected:
@@ -455,8 +455,8 @@ private:
private:
T *key_;
rational old_time_;
rational new_time_;
Rational old_time_;
Rational new_time_;
};
TimeBasedView *view_;
@@ -466,15 +466,15 @@ private:
std::vector<T *> selected_;
std::vector<rational> dragging_;
std::vector<rational> snap_points_;
std::vector<Rational> dragging_;
std::vector<Rational> snap_points_;
std::vector<Node *> time_targets_;
T *initial_drag_item_;
QPointF drag_mouse_start_;
rational timebase_;
Rational timebase_;
QRubberBand *rubberband_;
QPointF rubberband_scene_start_;
@@ -489,4 +489,4 @@ private:
}
#endif // TIMEBASEDVIEWSELECTIONMANAGER_H
#endif // OAK_TIMEBASEDVIEWSELECTIONMANAGER_H
File diff suppressed because it is too large Load Diff
+74 -74
View File
@@ -19,8 +19,8 @@
***/
#ifndef TIMEBASEDWIDGET_H
#define TIMEBASEDWIDGET_H
#ifndef OAK_TIMEBASEDWIDGET_H
#define OAK_TIMEBASEDWIDGET_H
#include <QPointer>
#include <QWidget>
@@ -45,94 +45,94 @@ public:
bool ruler_cache_status_visible = false,
QWidget *parent = nullptr);
void ZoomIn();
void zoom_in();
void ZoomOut();
void zoom_out();
ViewerOutput *GetConnectedNode() const;
ViewerOutput *get_connected_node() const;
void ConnectViewerNode(ViewerOutput *node);
void connect_viewer_node(ViewerOutput *node);
TimelineWorkArea *GetConnectedWorkArea() const
TimelineWorkArea *get_connected_work_area() const
{
return workarea_;
}
TimelineMarkerList *GetConnectedMarkers() const
TimelineMarkerList *get_connected_markers() const
{
return markers_;
}
void ConnectWorkArea(TimelineWorkArea *workarea);
void ConnectMarkers(TimelineMarkerList *markers);
void connect_work_area(TimelineWorkArea *workarea);
void connect_markers(TimelineMarkerList *markers);
void SetScaleAndCenterOnPlayhead(const double &scale);
void set_scale_and_center_on_playhead(const double &scale);
TimeRuler *ruler() const;
using SnapMask = uint32_t;
enum SnapPoints {
kSnapToClips = 0x1,
kSnapToPlayhead = 0x2,
kSnapToMarkers = 0x4,
kSnapToKeyframes = 0x8,
kSnapToWorkarea = 0x10,
kSnapAll = UINT32_MAX
k_snap_to_clips = 0x1,
k_snap_to_playhead = 0x2,
k_snap_to_markers = 0x4,
k_snap_to_keyframes = 0x8,
k_snap_to_workarea = 0x10,
k_snap_all = UINT32_MAX
};
/**
* @brief Snaps point `start_point` that is moving by `movement` to currently existing clips
*/
bool SnapPoint(const std::vector<rational> &start_times, rational *movement,
SnapMask snap_points = kSnapAll);
void ShowSnaps(const std::vector<rational> &times);
void HideSnaps();
bool snap_point(const std::vector<Rational> &start_times, Rational *movement,
SnapMask snap_points = k_snap_all);
void show_snaps(const std::vector<Rational> &times);
void hide_snaps();
virtual bool CopySelected(bool cut);
virtual bool copy_selected(bool cut);
virtual bool Paste();
virtual bool paste();
public slots:
void SetTimebase(const rational &timebase);
void SetTimebase(const Rational &timebase);
void SetScale(const double &scale);
void GoToStart();
void go_to_start();
void PrevFrame();
void prev_frame();
void NextFrame();
void next_frame();
void GoToEnd();
void go_to_end();
void GoToPrevCut();
void go_to_prev_cut();
void GoToNextCut();
void go_to_next_cut();
void SetInAtPlayhead();
void set_in_at_playhead();
void SetOutAtPlayhead();
void set_out_at_playhead();
void ResetIn();
void reset_in();
void ResetOut();
void reset_out();
void ClearInOutPoints();
void clear_in_out_points();
void SetMarker();
void set_marker();
void ToggleShowAll();
void toggle_show_all();
void GoToIn();
void go_to_in();
void GoToOut();
void go_to_out();
void DeleteSelected();
void delete_selected();
protected:
ResizableTimelineScrollBar *scrollbar() const;
virtual void TimebaseChangedEvent(const rational &) override;
virtual void TimebaseChangedEvent(const Rational &) override;
virtual void TimeChangedEvent(const rational &)
virtual void TimeChangedEvent(const Rational &)
{
}
@@ -157,33 +157,33 @@ protected:
{
}
void SetAutoMaxScrollBar(bool e);
void set_auto_max_scroll_bar(bool e);
virtual void resizeEvent(QResizeEvent *event) override;
void ConnectTimelineView(TimeBasedView *base);
void connect_timeline_view(TimeBasedView *base);
void SetCatchUpScrollValue(QScrollBar *b, int v, int maximum);
void StopCatchUpScrollTimer(QScrollBar *b);
void set_catch_up_scroll_value(QScrollBar *b, int v, int maximum);
void stop_catch_up_scroll_timer(QScrollBar *b);
virtual const QVector<Block *> *GetSnapBlocks() const
virtual const QVector<Block *> *get_snap_blocks() const
{
return nullptr;
}
virtual const QVector<KeyframeViewInputConnection *> *
GetSnapKeyframes() const
get_snap_keyframes() const
{
return nullptr;
}
virtual const TimeTargetObject *GetKeyframeTimeTarget() const
virtual const TimeTargetObject *get_keyframe_time_target() const
{
return nullptr;
}
virtual const std::vector<NodeKeyframe *> *GetSnapIgnoreKeyframes() const
virtual const std::vector<NodeKeyframe *> *get_snap_ignore_keyframes() const
{
return nullptr;
}
virtual const std::vector<TimelineMarker *> *GetSnapIgnoreMarkers() const
virtual const std::vector<TimelineMarker *> *get_snap_ignore_markers() const
{
return nullptr;
}
@@ -192,28 +192,28 @@ protected slots:
/**
* @brief Slot to center the horizontal scroll bar on the playhead's current position
*/
void CenterScrollOnPlayhead();
void center_scroll_on_playhead();
/**
* @brief By default, TimeBasedWidget will set the timebase to the viewer node's video timebase.
* Set this to false if you want to set your own timebase.
*/
void SetAutoSetTimebase(bool e);
void set_auto_set_timebase(bool e);
static void PageScrollInternal(QScrollBar *bar, int maximum,
static void page_scroll_internal(QScrollBar *bar, int maximum,
int screen_position, bool whole_page_scroll);
void StopCatchUpScrollTimer()
void stop_catch_up_scroll_timer()
{
StopCatchUpScrollTimer(scrollbar_);
stop_catch_up_scroll_timer(scrollbar_);
}
void SetCatchUpScrollValue(int v);
void set_catch_up_scroll_value(int v);
signals:
void TimebaseChanged(const rational &);
void timebase_changed(const Rational &);
void ConnectedNodeChanged(ViewerOutput *old, ViewerOutput *now);
void connected_node_changed(ViewerOutput *old, ViewerOutput *now);
protected slots:
virtual void SendCatchUpScrollEvent();
@@ -226,7 +226,7 @@ private:
*
* Set to kTrimIn or kTrimOut for setting the in point or out point respectively.
*/
void SetPoint(Timeline::MovementMode m, const rational &time);
void set_point(Timeline::MovementMode m, const Rational &time);
/**
* @brief Reset either the in or out point
@@ -237,11 +237,11 @@ private:
*
* Set to kTrimIn or kTrimOut for setting the in point or out point respectively.
*/
void ResetPoint(Timeline::MovementMode m);
void reset_point(Timeline::MovementMode m);
void PageScrollInternal(int screen_position, bool whole_page_scroll);
void page_scroll_internal(int screen_position, bool whole_page_scroll);
bool UserIsDraggingPlayhead() const;
bool user_is_dragging_playhead() const;
QPointer<ViewerOutput> viewer_node_;
@@ -277,11 +277,11 @@ private:
QMap<QScrollBar *, CatchUpScrollData> catchup_scroll_values_;
private slots:
void UpdateMaximumScroll();
void update_maximum_scroll();
void ScrollBarResizeBegan(int current_bar_width, bool top_handle);
void scroll_bar_resize_began(int current_bar_width, bool top_handle);
void ScrollBarResizeMoved(int new_bar_width);
void scroll_bar_resize_moved(int new_bar_width);
/**
* @brief Slot to handle page scrolling of the playhead
@@ -289,21 +289,21 @@ private slots:
* If the playhead is outside the current scroll bounds, this function will scroll to where it is. Otherwise it will
* do nothing.
*/
void PageScrollToPlayhead();
void page_scroll_to_playhead();
void CatchUpScrollToPlayhead();
void catch_up_scroll_to_playhead();
void CatchUpScrollToPoint(int point);
void catch_up_scroll_to_point(int point);
void CatchUpTimerTimeout();
void catch_up_timer_timeout();
void AutoUpdateTimebase();
void auto_update_timebase();
void ConnectedNodeRemovedFromGraph();
void connected_node_removed_from_graph();
void PlayheadTimeChanged(const rational &time);
void playhead_time_changed(const Rational &time);
};
}
#endif // TIMEBASEDWIDGET_H
#endif // OAK_TIMEBASEDWIDGET_H
+35 -35
View File
@@ -29,24 +29,24 @@
namespace olive
{
const int TimeScaledObject::kCalculateDimensionsPadding = 10;
const int TimeScaledObject::k_calculate_dimensions_padding = 10;
TimeScaledObject::TimeScaledObject()
: scale_(1.0)
, min_scale_(0)
, max_scale_(AudioVisualWaveform::kMaximumSampleRate.toDouble())
, max_scale_(AudioVisualWaveform::k_maximum_sample_rate.to_double())
{
}
void TimeScaledObject::SetTimebase(const rational &timebase)
void TimeScaledObject::set_timebase(const Rational &timebase)
{
timebase_ = timebase;
timebase_dbl_ = timebase_.toDouble();
timebase_dbl_ = timebase_.to_double();
TimebaseChangedEvent(timebase);
}
const rational &TimeScaledObject::timebase() const
const Rational &TimeScaledObject::timebase() const
{
return timebase_;
}
@@ -56,13 +56,13 @@ const double &TimeScaledObject::timebase_dbl() const
return timebase_dbl_;
}
rational TimeScaledObject::SceneToTime(const double &x, const double &x_scale,
const rational &timebase, bool round)
Rational TimeScaledObject::scene_to_time(const double &x, const double &x_scale,
const Rational &timebase, bool round)
{
if (timebase.isNull()) {
return rational();
return Rational();
}
double unscaled_time = x / x_scale / timebase.toDouble();
double unscaled_time = x / x_scale / timebase.to_double();
// Adjust screen point by scale and timebase
qint64 rounded_x_mvmt;
@@ -77,66 +77,66 @@ rational TimeScaledObject::SceneToTime(const double &x, const double &x_scale,
}
// Return a time in the timebase
return rational(rounded_x_mvmt * timebase.numerator(),
return Rational(rounded_x_mvmt * timebase.numerator(),
timebase.denominator());
}
rational TimeScaledObject::SceneToTimeNoGrid(const double &x,
Rational TimeScaledObject::scene_to_time_no_grid(const double &x,
const double &x_scale)
{
double unscaled_time = x / x_scale;
return rational::fromDouble(unscaled_time);
return Rational::from_double(unscaled_time);
}
double TimeScaledObject::TimeToScene(const rational &time) const
double TimeScaledObject::time_to_scene(const Rational &time) const
{
if (timebase_.isNull()) {
return 0.0;
}
return time.toDouble() * scale_;
return time.to_double() * scale_;
}
rational TimeScaledObject::SceneToTime(const double &x, bool round) const
Rational TimeScaledObject::scene_to_time(const double &x, bool round) const
{
if (timebase_.isNull()) {
return rational();
return Rational();
}
return SceneToTime(x, scale_, timebase_, round);
return scene_to_time(x, scale_, timebase_, round);
}
rational TimeScaledObject::SceneToTimeNoGrid(const double &x) const
Rational TimeScaledObject::scene_to_time_no_grid(const double &x) const
{
if (timebase_.isNull()) {
return rational::fromDouble(x / scale_);
return Rational::from_double(x / scale_);
}
return SceneToTimeNoGrid(x, scale_);
return scene_to_time_no_grid(x, scale_);
}
void TimeScaledObject::SetMaximumScale(const double &max)
void TimeScaledObject::set_maximum_scale(const double &max)
{
max_scale_ = max;
if (GetScale() > max_scale_) {
SetScale(max_scale_);
if (get_scale() > max_scale_) {
set_scale(max_scale_);
}
}
void TimeScaledObject::SetMinimumScale(const double &min)
void TimeScaledObject::set_minimum_scale(const double &min)
{
min_scale_ = min;
if (GetScale() < min_scale_) {
SetScale(min_scale_);
if (get_scale() < min_scale_) {
set_scale(min_scale_);
}
}
const double &TimeScaledObject::GetScale() const
const double &TimeScaledObject::get_scale() const
{
return scale_;
}
void TimeScaledObject::SetScale(const double &scale)
void TimeScaledObject::set_scale(const double &scale)
{
Q_ASSERT(scale > 0);
@@ -145,23 +145,23 @@ void TimeScaledObject::SetScale(const double &scale)
ScaleChangedEvent(scale_);
}
void TimeScaledObject::SetScaleFromDimensions(double viewport_width,
void TimeScaledObject::set_scale_from_dimensions(double viewport_width,
double content_width)
{
SetScale(CalculateScaleFromDimensions(viewport_width, content_width));
set_scale(calculate_scale_from_dimensions(viewport_width, content_width));
}
double TimeScaledObject::CalculateScaleFromDimensions(double viewport_sz,
double TimeScaledObject::calculate_scale_from_dimensions(double viewport_sz,
double content_sz)
{
return static_cast<double>(viewport_sz / kCalculateDimensionsPadding *
(kCalculateDimensionsPadding - 1)) /
return static_cast<double>(viewport_sz / k_calculate_dimensions_padding *
(k_calculate_dimensions_padding - 1)) /
static_cast<double>(content_sz);
}
double TimeScaledObject::CalculatePaddingFromDimensionScale(double viewport_sz)
double TimeScaledObject::calculate_padding_from_dimension_scale(double viewport_sz)
{
return (viewport_sz / (kCalculateDimensionsPadding * 2));
return (viewport_sz / (k_calculate_dimensions_padding * 2));
}
TimelineScaledWidget::TimelineScaledWidget(QWidget *parent)
+22 -22
View File
@@ -19,8 +19,8 @@
***/
#ifndef TIMELINESCALEDOBJECT_H
#define TIMELINESCALEDOBJECT_H
#ifndef OAK_TIMELINESCALEDOBJECT_H
#define OAK_TIMELINESCALEDOBJECT_H
#include <olive/core/core.h>
#include <QWidget>
@@ -38,34 +38,34 @@ public:
TimeScaledObject();
virtual ~TimeScaledObject() = default;
void SetTimebase(const rational &timebase);
void set_timebase(const Rational &timebase);
const rational &timebase() const;
const Rational &timebase() const;
const double &timebase_dbl() const;
static rational SceneToTime(const double &x, const double &x_scale,
const rational &timebase, bool round = false);
static rational SceneToTimeNoGrid(const double &x, const double &x_scale);
static Rational scene_to_time(const double &x, const double &x_scale,
const Rational &timebase, bool round = false);
static Rational scene_to_time_no_grid(const double &x, const double &x_scale);
const double &GetScale() const;
const double &GetMaximumScale() const
const double &get_scale() const;
const double &get_maximum_scale() const
{
return max_scale_;
}
void SetScale(const double &scale);
void set_scale(const double &scale);
void SetScaleFromDimensions(double viewport_width, double content_width);
static double CalculateScaleFromDimensions(double viewport_sz,
void set_scale_from_dimensions(double viewport_width, double content_width);
static double calculate_scale_from_dimensions(double viewport_sz,
double content_sz);
static double CalculatePaddingFromDimensionScale(double viewport_sz);
static double calculate_padding_from_dimension_scale(double viewport_sz);
double TimeToScene(const rational &time) const;
rational SceneToTime(const double &x, bool round = false) const;
rational SceneToTimeNoGrid(const double &x) const;
double time_to_scene(const Rational &time) const;
Rational scene_to_time(const double &x, bool round = false) const;
Rational scene_to_time_no_grid(const double &x) const;
protected:
virtual void TimebaseChangedEvent(const rational &)
virtual void TimebaseChangedEvent(const Rational &)
{
}
@@ -73,12 +73,12 @@ protected:
{
}
void SetMaximumScale(const double &max);
void set_maximum_scale(const double &max);
void SetMinimumScale(const double &min);
void set_minimum_scale(const double &min);
private:
rational timebase_;
Rational timebase_;
double timebase_dbl_;
@@ -88,7 +88,7 @@ private:
double max_scale_;
static const int kCalculateDimensionsPadding;
static const int k_calculate_dimensions_padding;
};
class TimelineScaledWidget : public QWidget, public TimeScaledObject {
@@ -99,4 +99,4 @@ public:
}
#endif // TIMELINESCALEDOBJECT_H
#endif // OAK_TIMELINESCALEDOBJECT_H