File indexing completed on 2024-04-28 04:52:26
0001 /* 0002 SPDX-FileCopyrightText: 2019 Jean-Baptiste Mardelle 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 0008 #include "snapmodel.hpp" 0009 0010 #include <map> 0011 #include <memory> 0012 #include <unordered_set> 0013 0014 class MarkerListModel; 0015 0016 /** @class ClipSnapModel 0017 @brief This class represents the snap points of a clip of the timeline. 0018 Basically, one can add or remove snap points 0019 */ 0020 class ClipSnapModel : public virtual SnapInterface, public std::enable_shared_from_this<SnapInterface> 0021 { 0022 public: 0023 ClipSnapModel(); 0024 0025 /** @brief Adds a snappoint at given position */ 0026 void addPoint(int position) override; 0027 0028 /** @brief Removes a snappoint from given position */ 0029 void removePoint(int position) override; 0030 0031 void registerSnapModel(const std::weak_ptr<SnapModel> &snapModel, int position, int in, int out, double speed = 1.); 0032 void deregisterSnapModel(); 0033 0034 void setReferenceModel(const std::weak_ptr<MarkerListModel> &markerModel, double speed); 0035 0036 void updateSnapModelPos(int newPos); 0037 void updateSnapModelInOut(std::vector<int> borderSnaps); 0038 void updateSnapMixPosition(int mixPos); 0039 /** @brief Retrieve all snap points */ 0040 void allSnaps(std::vector<int> &snaps, int offset = 0) const; 0041 0042 private: 0043 std::weak_ptr<SnapModel> m_registeredSnap; 0044 std::weak_ptr<MarkerListModel> m_parentModel; 0045 std::unordered_set<int> m_snapPoints; 0046 int m_inPoint; 0047 int m_outPoint; 0048 int m_mixPoint{0}; 0049 int m_position; 0050 double m_speed{1.}; 0051 void addAllSnaps(); 0052 void removeAllSnaps(); 0053 };