X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fclip_list.h;h=5373ce03219cb9308c06f36664565ec8e0acd5dd;hb=refs%2Fheads%2Fmaster;hp=6fe30966a5e01a89ed68551d6b5c0119d0534299;hpb=6e3e839e23309b1214ff8d9954e97e6194db61a8;p=nageru diff --git a/futatabi/clip_list.h b/futatabi/clip_list.h index 6fe3096..5373ce0 100644 --- a/futatabi/clip_list.h +++ b/futatabi/clip_list.h @@ -5,16 +5,23 @@ #include "state.pb.h" #include -#include #include +#include #include #include struct Clip { int64_t pts_in = -1, pts_out = -1; // pts_in is inclusive, pts_out is exclusive. std::string descriptions[MAX_STREAMS]; - unsigned stream_idx = 0; // For the playlist only. - double fade_time_seconds = 0.5; // For the playlist only. + + // These are for the playlist only. + unsigned stream_idx = 0; + double fade_time_seconds = 0.5; + double speed = 0.5; +}; +struct ClipWithID { + Clip clip; + uint64_t id; // Used for progress callback only. Immutable. }; class DataChangedReceiver { @@ -76,12 +83,12 @@ public: ClipListProto serialize() const; - void change_num_cameras(size_t num_cameras); // Defaults to 1. Cannot decrease. + void change_num_cameras(size_t num_cameras); // Defaults to 2. Cannot decrease. void emit_data_changed(size_t row) override; bool is_camera_column(int column) const { - return (column >= int(Column::CAMERA_1) && column < int(Column::CAMERA_1) + num_cameras); + return (column >= int(Column::CAMERA_1) && column < int(Column::CAMERA_1) + int(num_cameras)); } signals: @@ -89,7 +96,7 @@ signals: private: std::vector clips; - size_t num_cameras = 1; + size_t num_cameras = 2; }; class PlayList : public QAbstractTableModel, public DataChangedReceiver { @@ -106,6 +113,7 @@ public: CAMERA, DESCRIPTION, FADE_TIME, + SPEED, NUM_COLUMNS }; @@ -127,21 +135,18 @@ public: size_t size() const { return clips.size(); } bool empty() const { return clips.empty(); } - ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index], this, index); } - const Clip *clip(size_t index) const { return &clips[index]; } + ClipProxy mutable_clip(size_t index) { return ClipProxy(clips[index].clip, this, index); } + const Clip *clip(size_t index) const { return &clips[index].clip; } + const ClipWithID *clip_with_id(size_t index) const { return &clips[index]; } ClipProxy mutable_back() { return mutable_clip(size() - 1); } const Clip *back() const { return clip(size() - 1); } - // TODO: Move these out of PlayList. - void set_currently_playing(int index, double progress); // -1 = none. - int get_currently_playing() const { return currently_playing_index; } - - void set_progress(const std::map &progress); + void set_progress(const std::map &progress); ClipListProto serialize() const; - void change_num_cameras(size_t num_cameras) // Defaults to 1. Cannot decrease. + void change_num_cameras(size_t num_cameras) // Defaults to 2. Cannot decrease. { this->num_cameras = num_cameras; } @@ -152,11 +157,11 @@ signals: void any_content_changed(); private: - std::vector clips; - int currently_playing_index = -1; + std::vector clips; double play_progress = 0.0; - std::map current_progress; - size_t num_cameras = 1; + std::map current_progress; + size_t num_cameras = 2; + uint64_t clip_counter = 1000000; // Used for generating IDs. Starting at a high number to avoid any kind of bugs treating IDs as rows. }; #endif // !defined (_CLIP_LIST_H)