Preliminary support for display indicator of composition a_track in timeline

parent 615efca4
......@@ -69,6 +69,11 @@ int CompositionModel::getPosition() const
return m_position;
}
int CompositionModel::getTargetTrack() const
{
return transition()->get_a_track();
}
int CompositionModel::getPlaytime() const
{
return transition()->get_length();
......
......@@ -63,6 +63,10 @@ public:
*/
int getCurrentTrackId() const;
/* @brief returns the target track for this compositon (a_track)
*/
int getTargetTrack() const;
/* @brief returns the current position of the composition (-1 if not inserted)
*/
int getPosition() const;
......
......@@ -193,6 +193,7 @@ QHash<int, QByteArray> TimelineItemModel::roleNames() const
roles[SpeedRole] = "speed";
roles[HeightRole] = "trackHeight";
roles[ItemIdRole] = "item";
roles[ItemATrack] = "a_track";
return roles;
}
......@@ -318,6 +319,9 @@ QVariant TimelineItemModel::data(const QModelIndex &index, int role) const
return 100;
case BinIdRole:
return 5;
case ItemATrack:
return 2;
//return compo->getTargetTrack();
case MarkersRole: {
QVariantList markersList;
return markersList;
......
......@@ -87,6 +87,7 @@ public:
IsCompositionRole,/// clip only
FileHashRole, /// clip only
SpeedRole, /// clip only
ItemATrack, /// composition only
ItemIdRole
};
......
......@@ -145,9 +145,9 @@ public:
*/
Q_INVOKABLE bool requestCompositionMove(int compoId, int trackId, int position, bool updateView = true, bool logUndo = true);
int getCompositionTrackId(int compoId) const;
int getCompositionPosition(int compoId) const;
int getCompositionPlaytime(int compoId) const;
Q_INVOKABLE int getCompositionTrackId(int compoId) const;
Q_INVOKABLE int getCompositionPosition(int compoId) const;
Q_INVOKABLE int getCompositionPlaytime(int compoId) const;
Q_INVOKABLE int suggestCompositionMove(int compoId, int trackId, int position);
protected:
......
......@@ -43,12 +43,14 @@ Rectangle {
property int binId: 0
property int trackIndex //Index in track repeater
property int trackId: -42 //Id in the model
property int a_track: -1
property int clipId //Id of the clip in the model
property int originalTrackId: trackId
property int originalX: x
property int originalDuration: clipDuration
property int lastValidDuration: clipDuration
property int draggedX: x
property int a_trackPos: -1
property bool selected: false
property double speed: 1.0
property color borderColor: 'black'
......@@ -78,7 +80,7 @@ Rectangle {
border.color: selected? 'red' : borderColor
border.width: 1.5
clip: true
clip: false
Drag.active: mouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
opacity: Drag.active? 0.5 : 1.0
......@@ -113,7 +115,7 @@ Rectangle {
anchors.topMargin: parent.border.width
anchors.leftMargin: parent.border.width
// + ((isAudio || !settings.timelineShowThumbnails) ? 0 : inThumbnail.width)
width: label.width + 2
width: Math.min(label.width + 2, parent.width - 2)
height: label.height
}
......@@ -121,6 +123,8 @@ Rectangle {
id: label
text: clipName
font.pixelSize: root.baseUnit
width: parent.width - 2
clip: true
anchors {
top: parent.top
left: parent.left
......@@ -131,6 +135,19 @@ Rectangle {
color: 'black'
}
// target track
Rectangle {
width: parent.width
height: 5
color: 'red'
y: a_trackPos
}
onA_trackChanged: {
console.log('+++++++++++++++++++++\na_tk: ', a_trackPos, ' : ', a_track)
a_trackPos = root.getTrackYFromId(a_track)
}
states: [
State {
name: 'normal'
......
......@@ -48,6 +48,13 @@ function getTrackIdFromPos(pos) {
return -1
}
function getTrackYFromId(id) {
if (id >= 0 && id < tracksRepeater.count) {
return trackHeaderRepeater.itemAt(id).y - scrollView.flickableItem.contentY
}
return -1
}
function acceptDrop(xml) {
var position = Math.round((dropTarget.x + scrollView.flickableItem.contentX - headerWidth) / timeline.scaleFactor)
timeline.insertClip(currentTrack, position, xml)
......
......@@ -69,6 +69,12 @@ Column{
value: trackRoot.selection.indexOf(loader.item.clipId) !== -1
when: loader.status == Loader.Ready
}
Binding {
target: loader.item
property: "a_track"
value: loader.item.a_track
when: loader.item.isComposition && loader.status == Loader.Ready
}
sourceComponent: {
if (model.isComposition) {
return compositionDelegate
......@@ -93,6 +99,8 @@ Column{
item.markers= model.markers
item.fadeIn= 0 //model.fadeIn
item.fadeOut= 0 //model.fadeOut
} else {
item.a_track = model.a_track
}
item.width= model.duration * timeScale
item.modelStart= model.start
......
......@@ -49,6 +49,9 @@ Rectangle {
}
}
function getTrackYFromId(a_track) {
return Logic.getTrackYFromId(a_track)
}
function getTrackColor(audio, header) {
var col = activePalette.alternateBase
......@@ -135,7 +138,7 @@ Rectangle {
var frame = controller.getCompositionPosition(clipBeingDroppedId)
var track = controller.getCompositionTrackId(clipBeingDroppedId)
// we simulate insertion at the final position so that stored undo has correct value
controller.requestCompositionDeletion(clipBeingDroppedId, false)
controller.requestItemDeletion(clipBeingDroppedId, false)
timeline.insertComposition(track, frame, clipBeingDroppedData, true)
}
clipBeingDroppedId = -1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment