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:
@@ -58,93 +58,93 @@ SeekableWidget::SeekableWidget(QWidget *parent)
|
||||
text_height_ = fm.height();
|
||||
|
||||
// Set width of playhead marker
|
||||
playhead_width_ = QtUtils::QFontMetricsWidth(fm, "H");
|
||||
playhead_width_ = QtUtils::q_font_metrics_width(fm, "H");
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
setMouseTracking(true);
|
||||
|
||||
selection_manager_.SetSnapMask(TimeBasedWidget::kSnapAll);
|
||||
selection_manager_.set_snap_mask(TimeBasedWidget::k_snap_all);
|
||||
|
||||
SetIsTimelineAxes(true);
|
||||
set_is_timeline_axes(true);
|
||||
}
|
||||
|
||||
void SeekableWidget::SetMarkers(TimelineMarkerList *markers)
|
||||
void SeekableWidget::set_markers(TimelineMarkerList *markers)
|
||||
{
|
||||
if (markers_) {
|
||||
selection_manager_.ClearSelection();
|
||||
selection_manager_.clear_selection();
|
||||
|
||||
disconnect(markers_, &TimelineMarkerList::MarkerAdded, viewport(),
|
||||
disconnect(markers_, &TimelineMarkerList::marker_added, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
disconnect(markers_, &TimelineMarkerList::MarkerRemoved, viewport(),
|
||||
disconnect(markers_, &TimelineMarkerList::marker_removed, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
disconnect(markers_, &TimelineMarkerList::MarkerModified, viewport(),
|
||||
disconnect(markers_, &TimelineMarkerList::marker_modified, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
}
|
||||
|
||||
markers_ = markers;
|
||||
|
||||
if (markers_) {
|
||||
connect(markers_, &TimelineMarkerList::MarkerAdded, viewport(),
|
||||
connect(markers_, &TimelineMarkerList::marker_added, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
connect(markers_, &TimelineMarkerList::MarkerRemoved, viewport(),
|
||||
connect(markers_, &TimelineMarkerList::marker_removed, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
connect(markers_, &TimelineMarkerList::MarkerModified, viewport(),
|
||||
connect(markers_, &TimelineMarkerList::marker_modified, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
}
|
||||
|
||||
viewport()->update();
|
||||
}
|
||||
|
||||
void SeekableWidget::SetWorkArea(TimelineWorkArea *workarea)
|
||||
void SeekableWidget::set_work_area(TimelineWorkArea *workarea)
|
||||
{
|
||||
if (workarea_) {
|
||||
selection_manager_.ClearSelection();
|
||||
selection_manager_.clear_selection();
|
||||
|
||||
disconnect(workarea_, &TimelineWorkArea::RangeChanged, viewport(),
|
||||
disconnect(workarea_, &TimelineWorkArea::range_changed, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
disconnect(workarea_, &TimelineWorkArea::EnabledChanged, viewport(),
|
||||
disconnect(workarea_, &TimelineWorkArea::enabled_changed, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
}
|
||||
|
||||
workarea_ = workarea;
|
||||
|
||||
if (workarea_) {
|
||||
connect(workarea_, &TimelineWorkArea::RangeChanged, viewport(),
|
||||
connect(workarea_, &TimelineWorkArea::range_changed, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
connect(workarea_, &TimelineWorkArea::EnabledChanged, viewport(),
|
||||
connect(workarea_, &TimelineWorkArea::enabled_changed, viewport(),
|
||||
static_cast<void (QWidget::*)()>(&QWidget::update));
|
||||
}
|
||||
|
||||
viewport()->update();
|
||||
}
|
||||
|
||||
void SeekableWidget::DeleteSelected()
|
||||
void SeekableWidget::delete_selected()
|
||||
{
|
||||
if (!selection_manager_.IsDragging()) {
|
||||
if (!selection_manager_.is_dragging()) {
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
foreach (TimelineMarker *marker,
|
||||
selection_manager_.GetSelectedObjects()) {
|
||||
selection_manager_.get_selected_objects()) {
|
||||
command->add_child(new MarkerRemoveCommand(marker));
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Deleted %1 Marker(s)")
|
||||
.arg(selection_manager_.GetSelectedObjects().size()));
|
||||
.arg(selection_manager_.get_selected_objects().size()));
|
||||
}
|
||||
}
|
||||
|
||||
bool SeekableWidget::CopySelected(bool cut)
|
||||
bool SeekableWidget::copy_selected(bool cut)
|
||||
{
|
||||
if (!selection_manager_.GetSelectedObjects().empty()) {
|
||||
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyMarkers);
|
||||
sdata.SetOnlySerializeMarkers(selection_manager_.GetSelectedObjects());
|
||||
if (!selection_manager_.get_selected_objects().empty()) {
|
||||
ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_markers);
|
||||
sdata.set_only_serialize_markers(selection_manager_.get_selected_objects());
|
||||
|
||||
ProjectSerializer::Copy(sdata);
|
||||
ProjectSerializer::copy(sdata);
|
||||
|
||||
if (cut) {
|
||||
DeleteSelected();
|
||||
delete_selected();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -153,22 +153,22 @@ bool SeekableWidget::CopySelected(bool cut)
|
||||
}
|
||||
}
|
||||
|
||||
bool SeekableWidget::PasteMarkers()
|
||||
bool SeekableWidget::paste_markers()
|
||||
{
|
||||
ProjectSerializer::Result res =
|
||||
ProjectSerializer::Paste(ProjectSerializer::kOnlyMarkers);
|
||||
if (res == ProjectSerializer::kSuccess) {
|
||||
ProjectSerializer::paste(ProjectSerializer::k_only_markers);
|
||||
if (res == ProjectSerializer::k_success) {
|
||||
const std::vector<TimelineMarker *> &markers =
|
||||
res.GetLoadData().markers;
|
||||
res.get_load_data().markers;
|
||||
if (!markers.empty()) {
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
// Normalize markers to start at playhead
|
||||
rational min = RATIONAL_MAX;
|
||||
Rational min = RATIONAL_MAX;
|
||||
for (auto it = markers.cbegin(); it != markers.cend(); it++) {
|
||||
min = std::min(min, (*it)->time().in());
|
||||
}
|
||||
min -= GetViewerNode()->GetPlayhead();
|
||||
min -= get_viewer_node()->get_playhead();
|
||||
|
||||
for (auto it = markers.cbegin(); it != markers.cend(); it++) {
|
||||
TimelineMarker *m = *it;
|
||||
@@ -176,7 +176,7 @@ bool SeekableWidget::PasteMarkers()
|
||||
m->set_time(m->time().in() - min);
|
||||
|
||||
if (TimelineMarker *existing =
|
||||
markers_->GetMarkerAtTime(m->time().in())) {
|
||||
markers_->get_marker_at_time(m->time().in())) {
|
||||
command->add_child(new MarkerRemoveCommand(existing));
|
||||
}
|
||||
|
||||
@@ -196,106 +196,106 @@ void SeekableWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
TimelineMarker *initial;
|
||||
|
||||
if (HandPress(event)) {
|
||||
if (hand_press(event)) {
|
||||
return;
|
||||
} else if (event->modifiers() & Qt::ControlModifier) {
|
||||
selection_manager_.RubberBandStart(event);
|
||||
selection_manager_.rubber_band_start(event);
|
||||
} else if (marker_editing_enabled_ &&
|
||||
(initial = selection_manager_.MousePress(event))) {
|
||||
selection_manager_.DragStart(initial, event);
|
||||
(initial = selection_manager_.mouse_press(event))) {
|
||||
selection_manager_.drag_start(initial, event);
|
||||
} else if (resize_item_) {
|
||||
// Handle selection, even though we won't be using it for dragging
|
||||
if (!(event->modifiers() & Qt::ShiftModifier)) {
|
||||
selection_manager_.ClearSelection();
|
||||
selection_manager_.clear_selection();
|
||||
}
|
||||
if (TimelineMarker *m = dynamic_cast<TimelineMarker *>(resize_item_)) {
|
||||
selection_manager_.Select(m);
|
||||
selection_manager_.select(m);
|
||||
}
|
||||
dragging_ = true;
|
||||
resize_start_ = mapToScene(event->pos());
|
||||
} else if (!selection_manager_.GetObjectAtPoint(event->pos()) &&
|
||||
} else if (!selection_manager_.get_object_at_point(event->pos()) &&
|
||||
event->button() == Qt::LeftButton) {
|
||||
SeekToScenePoint(mapToScene(event->pos()).x());
|
||||
seek_to_scene_point(mapToScene(event->pos()).x());
|
||||
dragging_ = true;
|
||||
|
||||
DeselectAllMarkers();
|
||||
deselect_all_markers();
|
||||
}
|
||||
}
|
||||
|
||||
void SeekableWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (HandMove(event)) {
|
||||
if (hand_move(event)) {
|
||||
return;
|
||||
} else if (selection_manager_.IsRubberBanding()) {
|
||||
selection_manager_.RubberBandMove(event->pos());
|
||||
} else if (selection_manager_.is_rubber_banding()) {
|
||||
selection_manager_.rubber_band_move(event->pos());
|
||||
viewport()->update();
|
||||
} else if (selection_manager_.IsDragging()) {
|
||||
selection_manager_.DragMove(event->pos());
|
||||
} else if (selection_manager_.is_dragging()) {
|
||||
selection_manager_.drag_move(event->pos());
|
||||
} else if (dragging_) {
|
||||
QPointF scene = mapToScene(event->pos());
|
||||
if (resize_item_) {
|
||||
DragResizeHandle(scene);
|
||||
drag_resize_handle(scene);
|
||||
} else {
|
||||
SeekToScenePoint(scene.x());
|
||||
seek_to_scene_point(scene.x());
|
||||
}
|
||||
} else {
|
||||
// Look for resize points
|
||||
if (!last_playhead_shape_.containsPoint(event->pos(),
|
||||
Qt::OddEvenFill) &&
|
||||
!selection_manager_.GetObjectAtPoint(event->pos()) &&
|
||||
FindResizeHandle(event)) {
|
||||
!selection_manager_.get_object_at_point(event->pos()) &&
|
||||
find_resize_handle(event)) {
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
} else {
|
||||
unsetCursor();
|
||||
ClearResizeHandle();
|
||||
clear_resize_handle();
|
||||
}
|
||||
}
|
||||
|
||||
if (event->buttons()) {
|
||||
// Signal cursor pos in case we should scroll to catch up to it
|
||||
emit DragMoved(event->pos().x(), event->pos().y());
|
||||
emit drag_moved(event->pos().x(), event->pos().y());
|
||||
}
|
||||
}
|
||||
|
||||
void SeekableWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (HandRelease(event)) {
|
||||
if (hand_release(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection_manager_.IsRubberBanding()) {
|
||||
selection_manager_.RubberBandStop();
|
||||
if (selection_manager_.is_rubber_banding()) {
|
||||
selection_manager_.rubber_band_stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection_manager_.IsDragging()) {
|
||||
if (selection_manager_.is_dragging()) {
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
selection_manager_.DragStop(command);
|
||||
selection_manager_.drag_stop(command);
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Moved %1 Marker(s)")
|
||||
.arg(selection_manager_.GetSelectedObjects().size()));
|
||||
.arg(selection_manager_.get_selected_objects().size()));
|
||||
}
|
||||
|
||||
if (GetSnapService()) {
|
||||
GetSnapService()->HideSnaps();
|
||||
if (get_snap_service()) {
|
||||
get_snap_service()->hide_snaps();
|
||||
}
|
||||
|
||||
if (resize_item_) {
|
||||
CommitResizeHandle();
|
||||
commit_resize_handle();
|
||||
resize_item_ = nullptr;
|
||||
}
|
||||
|
||||
dragging_ = false;
|
||||
emit DragReleased();
|
||||
emit drag_released();
|
||||
}
|
||||
|
||||
void SeekableWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
super::mouseDoubleClickEvent(event);
|
||||
|
||||
if (selection_manager_.GetObjectAtPoint(event->pos()) &&
|
||||
!selection_manager_.GetSelectedObjects().empty()) {
|
||||
ShowMarkerProperties();
|
||||
if (selection_manager_.get_object_at_point(event->pos()) &&
|
||||
!selection_manager_.get_selected_objects().empty()) {
|
||||
show_marker_properties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,28 +307,28 @@ void SeekableWidget::focusOutEvent(QFocusEvent *event)
|
||||
ignore_next_focus_out_ = false;
|
||||
} else {
|
||||
// Deselect everything when we lose focus
|
||||
DeselectAllMarkers();
|
||||
deselect_all_markers();
|
||||
}
|
||||
}
|
||||
|
||||
void SeekableWidget::DrawMarkers(QPainter *p, int marker_bottom)
|
||||
void SeekableWidget::draw_markers(QPainter *p, int marker_bottom)
|
||||
{
|
||||
selection_manager_.ClearDrawnObjects();
|
||||
selection_manager_.clear_drawn_objects();
|
||||
|
||||
// Draw markers
|
||||
if (markers_ && !markers_->empty() && marker_bottom > 0) {
|
||||
int lim_left = GetLeftLimit();
|
||||
int lim_right = GetRightLimit();
|
||||
int lim_left = get_left_limit();
|
||||
int lim_right = get_right_limit();
|
||||
|
||||
for (auto it = markers_->cbegin(); it != markers_->cend(); it++) {
|
||||
TimelineMarker *marker = *it;
|
||||
|
||||
int marker_right = TimeToScene(marker->time().out());
|
||||
int marker_right = time_to_scene(marker->time().out());
|
||||
if (marker_right < lim_left) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int marker_left = TimeToScene(marker->time().in());
|
||||
int marker_left = time_to_scene(marker->time().in());
|
||||
if (marker_left >= lim_right) {
|
||||
break;
|
||||
}
|
||||
@@ -341,36 +341,36 @@ void SeekableWidget::DrawMarkers(QPainter *p, int marker_bottom)
|
||||
if (next != markers_->cend()) {
|
||||
max_marker_right =
|
||||
std::min(max_marker_right,
|
||||
int(TimeToScene((*next)->time().in())));
|
||||
int(time_to_scene((*next)->time().in())));
|
||||
}
|
||||
}
|
||||
|
||||
QRect marker_rect = marker->Draw(
|
||||
QRect marker_rect = marker->draw(
|
||||
p, QPoint(marker_left, marker_bottom), max_marker_right,
|
||||
GetScale(), selection_manager_.IsSelected(marker));
|
||||
get_scale(), selection_manager_.is_selected(marker));
|
||||
marker_top_ = marker_rect.top();
|
||||
selection_manager_.DeclareDrawnObject(marker, marker_rect);
|
||||
selection_manager_.declare_drawn_object(marker, marker_rect);
|
||||
}
|
||||
}
|
||||
|
||||
marker_bottom_ = marker_bottom;
|
||||
}
|
||||
|
||||
void SeekableWidget::DrawWorkArea(QPainter *p)
|
||||
void SeekableWidget::draw_work_area(QPainter *p)
|
||||
{
|
||||
// Draw in/out workarea
|
||||
if (workarea_ && workarea_->enabled()) {
|
||||
int lim_left = GetLeftLimit();
|
||||
int lim_right = GetRightLimit();
|
||||
int lim_left = get_left_limit();
|
||||
int lim_right = get_right_limit();
|
||||
|
||||
int workarea_left = qMax(qreal(lim_left), TimeToScene(workarea_->in()));
|
||||
int workarea_left = qMax(qreal(lim_left), time_to_scene(workarea_->in()));
|
||||
int workarea_right;
|
||||
|
||||
if (workarea_->out() == TimelineWorkArea::kResetOut) {
|
||||
if (workarea_->out() == TimelineWorkArea::k_reset_out) {
|
||||
workarea_right = lim_right;
|
||||
} else {
|
||||
workarea_right =
|
||||
qMin(qreal(lim_right), TimeToScene(workarea_->out()));
|
||||
qMin(qreal(lim_right), time_to_scene(workarea_->out()));
|
||||
}
|
||||
|
||||
QColor translucent_highlight = palette().highlight().color();
|
||||
@@ -380,62 +380,62 @@ void SeekableWidget::DrawWorkArea(QPainter *p)
|
||||
}
|
||||
}
|
||||
|
||||
void SeekableWidget::DeselectAllMarkers()
|
||||
void SeekableWidget::deselect_all_markers()
|
||||
{
|
||||
selection_manager_.ClearSelection();
|
||||
selection_manager_.clear_selection();
|
||||
|
||||
viewport()->update();
|
||||
}
|
||||
|
||||
void SeekableWidget::SetMarkerColor(int c)
|
||||
void SeekableWidget::set_marker_color(int c)
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
foreach (TimelineMarker *marker, selection_manager_.GetSelectedObjects()) {
|
||||
foreach (TimelineMarker *marker, selection_manager_.get_selected_objects()) {
|
||||
command->add_child(new MarkerChangeColorCommand(marker, c));
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Changed Color of %1 Marker(s)")
|
||||
.arg(selection_manager_.GetSelectedObjects().size()));
|
||||
.arg(selection_manager_.get_selected_objects().size()));
|
||||
}
|
||||
|
||||
void SeekableWidget::ShowMarkerProperties()
|
||||
void SeekableWidget::show_marker_properties()
|
||||
{
|
||||
MarkerPropertiesDialog mpd(selection_manager_.GetSelectedObjects(),
|
||||
MarkerPropertiesDialog mpd(selection_manager_.get_selected_objects(),
|
||||
timebase(), this);
|
||||
ignore_next_focus_out_ = true;
|
||||
mpd.exec();
|
||||
}
|
||||
|
||||
void SeekableWidget::TimebaseChangedEvent(const rational &t)
|
||||
void SeekableWidget::TimebaseChangedEvent(const Rational &t)
|
||||
{
|
||||
super::TimebaseChangedEvent(t);
|
||||
|
||||
selection_manager_.SetTimebase(t);
|
||||
selection_manager_.set_timebase(t);
|
||||
}
|
||||
|
||||
void SeekableWidget::SeekToScenePoint(qreal scene)
|
||||
void SeekableWidget::seek_to_scene_point(qreal scene)
|
||||
{
|
||||
if (timebase().isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
rational playhead_time = qMax(rational(0), SceneToTime(scene));
|
||||
Rational playhead_time = qMax(Rational(0), scene_to_time(scene));
|
||||
|
||||
if (Core::instance()->snapping() && GetSnapService()) {
|
||||
rational movement;
|
||||
if (Core::instance()->snapping() && get_snap_service()) {
|
||||
Rational movement;
|
||||
|
||||
GetSnapService()->SnapPoint({ playhead_time }, &movement,
|
||||
TimeBasedWidget::kSnapAll &
|
||||
~TimeBasedWidget::kSnapToPlayhead);
|
||||
get_snap_service()->snap_point({ playhead_time }, &movement,
|
||||
TimeBasedWidget::k_snap_all &
|
||||
~TimeBasedWidget::k_snap_to_playhead);
|
||||
|
||||
playhead_time += movement;
|
||||
}
|
||||
|
||||
ViewerOutput *viewer = GetViewerNode();
|
||||
if (viewer && playhead_time != viewer->GetPlayhead()) {
|
||||
viewer->SetPlayhead(playhead_time);
|
||||
ViewerOutput *viewer = get_viewer_node();
|
||||
if (viewer && playhead_time != viewer->get_playhead()) {
|
||||
viewer->set_playhead(playhead_time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,15 +457,15 @@ void SeekableWidget::CatchUpScrollEvent()
|
||||
{
|
||||
super::CatchUpScrollEvent();
|
||||
|
||||
this->selection_manager_.ForceDragUpdate();
|
||||
this->selection_manager_.force_drag_update();
|
||||
}
|
||||
|
||||
void SeekableWidget::DrawPlayhead(QPainter *p, int x, int y)
|
||||
void SeekableWidget::draw_playhead(QPainter *p, int x, int y)
|
||||
{
|
||||
int half_width = playhead_width_ / 2;
|
||||
|
||||
{
|
||||
int test = x - this->GetScroll();
|
||||
int test = x - this->get_scroll();
|
||||
if (test + half_width < 0 || test - half_width > width()) {
|
||||
return;
|
||||
}
|
||||
@@ -489,37 +489,37 @@ void SeekableWidget::DrawPlayhead(QPainter *p, int x, int y)
|
||||
p->setRenderHint(QPainter::Antialiasing, false);
|
||||
}
|
||||
|
||||
int SeekableWidget::GetLeftLimit() const
|
||||
int SeekableWidget::get_left_limit() const
|
||||
{
|
||||
return GetScroll();
|
||||
return get_scroll();
|
||||
}
|
||||
|
||||
int SeekableWidget::GetRightLimit() const
|
||||
int SeekableWidget::get_right_limit() const
|
||||
{
|
||||
return GetLeftLimit() + width();
|
||||
return get_left_limit() + width();
|
||||
}
|
||||
|
||||
bool SeekableWidget::ShowContextMenu(const QPoint &p)
|
||||
bool SeekableWidget::show_context_menu(const QPoint &p)
|
||||
{
|
||||
if (marker_editing_enabled_ && selection_manager_.GetObjectAtPoint(p) &&
|
||||
!selection_manager_.GetSelectedObjects().empty()) {
|
||||
if (marker_editing_enabled_ && selection_manager_.get_object_at_point(p) &&
|
||||
!selection_manager_.get_selected_objects().empty()) {
|
||||
// Show marker-specific menu
|
||||
Menu m;
|
||||
|
||||
ColorLabelMenu color_coding_menu;
|
||||
connect(&color_coding_menu, &ColorLabelMenu::ColorSelected, this,
|
||||
&SeekableWidget::SetMarkerColor);
|
||||
connect(&color_coding_menu, &ColorLabelMenu::color_selected, this,
|
||||
&SeekableWidget::set_marker_color);
|
||||
m.addMenu(&color_coding_menu);
|
||||
|
||||
m.addSeparator();
|
||||
|
||||
MenuShared::instance()->AddItemsForEditMenu(&m, false);
|
||||
MenuShared::instance()->add_items_for_edit_menu(&m, false);
|
||||
|
||||
m.addSeparator();
|
||||
|
||||
QAction *properties_action = m.addAction(tr("Properties"));
|
||||
connect(properties_action, &QAction::triggered, this,
|
||||
&SeekableWidget::ShowMarkerProperties);
|
||||
&SeekableWidget::show_marker_properties);
|
||||
|
||||
ignore_next_focus_out_ = true;
|
||||
m.exec(mapToGlobal(p));
|
||||
@@ -529,34 +529,34 @@ bool SeekableWidget::ShowContextMenu(const QPoint &p)
|
||||
}
|
||||
}
|
||||
|
||||
bool SeekableWidget::FindResizeHandle(QMouseEvent *event)
|
||||
bool SeekableWidget::find_resize_handle(QMouseEvent *event)
|
||||
{
|
||||
if (!marker_editing_enabled_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ClearResizeHandle();
|
||||
clear_resize_handle();
|
||||
|
||||
QPointF scene = mapToScene(event->pos());
|
||||
const int border = 10;
|
||||
rational min = SceneToTimeNoGrid(scene.x() - border);
|
||||
rational max = SceneToTimeNoGrid(scene.x() + border);
|
||||
Rational min = scene_to_time_no_grid(scene.x() - border);
|
||||
Rational max = scene_to_time_no_grid(scene.x() + border);
|
||||
|
||||
// Test for workarea
|
||||
if (workarea_ && workarea_->enabled()) {
|
||||
if (workarea_->in() >= min && workarea_->in() < max) {
|
||||
resize_mode_ = kResizeIn;
|
||||
resize_mode_ = k_resize_in;
|
||||
} else if (workarea_->out() >= min && workarea_->out() < max) {
|
||||
resize_mode_ = kResizeOut;
|
||||
resize_mode_ = k_resize_out;
|
||||
}
|
||||
}
|
||||
|
||||
if (resize_mode_ != kResizeNone) {
|
||||
if (resize_mode_ != k_resize_none) {
|
||||
if (workarea_) {
|
||||
resize_item_ = workarea_;
|
||||
resize_item_range_ = workarea_->range();
|
||||
resize_snap_mask_ = TimeBasedWidget::kSnapAll &
|
||||
~TimeBasedWidget::kSnapToWorkarea;
|
||||
resize_snap_mask_ = TimeBasedWidget::k_snap_all &
|
||||
~TimeBasedWidget::k_snap_to_workarea;
|
||||
}
|
||||
} else if (event->pos().y() >= marker_top_ &&
|
||||
event->pos().y() < marker_bottom_) {
|
||||
@@ -566,16 +566,16 @@ bool SeekableWidget::FindResizeHandle(QMouseEvent *event)
|
||||
TimelineMarker *m = *it;
|
||||
if (m->time().in() != m->time().out()) {
|
||||
if (m->time().in() >= min && m->time().in() < max) {
|
||||
resize_mode_ = kResizeIn;
|
||||
resize_mode_ = k_resize_in;
|
||||
} else if (m->time().out() >= min &&
|
||||
m->time().out() < max) {
|
||||
resize_mode_ = kResizeOut;
|
||||
resize_mode_ = k_resize_out;
|
||||
}
|
||||
|
||||
if (resize_mode_ != kResizeNone) {
|
||||
if (resize_mode_ != k_resize_none) {
|
||||
resize_item_ = m;
|
||||
resize_item_range_ = m->time();
|
||||
resize_snap_mask_ = TimeBasedWidget::kSnapAll;
|
||||
resize_snap_mask_ = TimeBasedWidget::k_snap_all;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -586,41 +586,41 @@ bool SeekableWidget::FindResizeHandle(QMouseEvent *event)
|
||||
return resize_item_;
|
||||
}
|
||||
|
||||
void SeekableWidget::ClearResizeHandle()
|
||||
void SeekableWidget::clear_resize_handle()
|
||||
{
|
||||
resize_item_ = nullptr;
|
||||
resize_mode_ = kResizeNone;
|
||||
resize_mode_ = k_resize_none;
|
||||
}
|
||||
|
||||
void SeekableWidget::DragResizeHandle(const QPointF &scene)
|
||||
void SeekableWidget::drag_resize_handle(const QPointF &scene)
|
||||
{
|
||||
qreal diff = scene.x() - resize_start_.x();
|
||||
|
||||
rational proposed_time;
|
||||
Rational proposed_time;
|
||||
|
||||
if (resize_mode_ == kResizeIn) {
|
||||
proposed_time = qMax(rational(0), qMin(resize_item_range_.out(),
|
||||
if (resize_mode_ == k_resize_in) {
|
||||
proposed_time = qMax(Rational(0), qMin(resize_item_range_.out(),
|
||||
resize_item_range_.in() +
|
||||
SceneToTimeNoGrid(diff)));
|
||||
scene_to_time_no_grid(diff)));
|
||||
} else {
|
||||
proposed_time =
|
||||
qMax(resize_item_range_.in(),
|
||||
resize_item_range_.out() + SceneToTimeNoGrid(diff));
|
||||
resize_item_range_.out() + scene_to_time_no_grid(diff));
|
||||
}
|
||||
|
||||
rational presnap_time = proposed_time;
|
||||
Rational presnap_time = proposed_time;
|
||||
|
||||
if (Core::instance()->snapping() && GetSnapService()) {
|
||||
rational movement;
|
||||
if (Core::instance()->snapping() && get_snap_service()) {
|
||||
Rational movement;
|
||||
|
||||
GetSnapService()->SnapPoint({ proposed_time }, &movement,
|
||||
get_snap_service()->snap_point({ proposed_time }, &movement,
|
||||
resize_snap_mask_);
|
||||
|
||||
proposed_time += movement;
|
||||
}
|
||||
|
||||
TimeRange new_range = resize_item_range_;
|
||||
if (resize_mode_ == kResizeIn) {
|
||||
if (resize_mode_ == k_resize_in) {
|
||||
// Markers should not have the same time as anything else
|
||||
// NOTE: This code is largely duplicated from TimeBasedViewSelectionManager::DragMove. Not ideal,
|
||||
// but I'm not sure if there's a good way to re-use that code
|
||||
@@ -629,13 +629,13 @@ void SeekableWidget::DragResizeHandle(const QPointF &scene)
|
||||
if (marker->has_sibling_at_time(proposed_time)) {
|
||||
proposed_time = presnap_time;
|
||||
|
||||
if (GetSnapService()) {
|
||||
GetSnapService()->HideSnaps();
|
||||
if (get_snap_service()) {
|
||||
get_snap_service()->hide_snaps();
|
||||
}
|
||||
}
|
||||
|
||||
while (marker->has_sibling_at_time(proposed_time)) {
|
||||
proposed_time += rational(1, 1000);
|
||||
proposed_time += Rational(1, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ void SeekableWidget::DragResizeHandle(const QPointF &scene)
|
||||
}
|
||||
}
|
||||
|
||||
void SeekableWidget::CommitResizeHandle()
|
||||
void SeekableWidget::commit_resize_handle()
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user