Skip to content

Commit

Permalink
Merge pull request #112 from Multiplicom/feature/111/splittrackviewer…
Browse files Browse the repository at this point in the history
…_checkbox

add function to add both left and right tracks closes #111
  • Loading branch information
Bastiaan van den Berg committed Aug 3, 2021
2 parents 389787c + b1bf1e6 commit 3972be7
Showing 1 changed file with 64 additions and 1 deletion.
65 changes: 64 additions & 1 deletion Panels/FrameTrackViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,10 +1260,24 @@ define([
addTrack(theFrame, track, theRightPanel);
};

/**
* Add left and right track that have the same functionality on left and right and are enabled/disabled
* add the same time
*/
theFrame.addLeftRightTrack = function (leftTrack, rightTrack) {
addTracks(
theFrame,
[
[leftTrack, theLeftPanel],
[rightTrack, theRightPanel]
]
);
};

return theFrame;
};

function addTrack(iFrame, iTrack, iPanel) {
function addTrackToPanel(iTrack, iPanel) {
const $El = $('#' + iPanel.getId() + '_content');
const isLive = iPanel._isrunning;
iPanel.addTrack(iTrack);
Expand All @@ -1272,6 +1286,12 @@ define([
$El.append(iTrack.render());
iTrack.attachEventHandlers();
}
return isLive

}

function addTrack(iFrame, iTrack, iPanel) {
const isLive = addTrackToPanel(iTrack, iPanel);

if (iTrack.canHide()) {
iTrack.__ctrl_visible = Controls.Check({text: iTrack.getName(), checked: iTrack.isVisible()});
Expand All @@ -1282,11 +1302,54 @@ define([
iPanel.rescale({resizing: false});
});
}

if (isLive) {
iPanel.rescale({resizing: false});
}
}

/**
* Add tracks to panels in the frame
* @param iFrame - the frame
* @param trackPanels - list of tuples. Each tuple is a track - panel combo
*/
function addTracks(iFrame, trackPanels) {

const iTracks = trackPanels.map(trackPanelTuple => trackPanelTuple[0]);
const iPanels = trackPanels.map(trackPanelTuple => trackPanelTuple[1]);

const livePanels = [];
for([iTrack, iPanel] of trackPanels) {
livePanels.push(addTrackToPanel(iTrack, iPanel));
}

const firstTrack = iTracks[0];
if (iTracks.length > 0 && firstTrack.canHide()) {

// Sanity check for equal track hidden feature, names and visibility
if(iTracks.some((iTrack) => iTrack.canHide() !== firstTrack.canHide() || iTrack.getName() !== firstTrack.getName())){
AXMUtils.Test.reportBug("Some tracks have different names or inconsistent hider properties");
}

const hider = Controls.Check({text: firstTrack.getName(), checked: firstTrack.isVisible()});
iFrame.trackControlsGroup.add(hider);
iFrame.trackControlsGroup.liveUpdate();
iTracks.forEach((iTrack) => iTrack.__ctrl_visible = hider);

hider.addNotificationHandler(function() {
for([iTrack, iPanel] of trackPanels) {
iTrack.setVisible(hider.getValue());
iPanel.rescale({resizing: false});
}
});
}

iPanels
.filter((iPanel, idx) => livePanels[idx])
.forEach((iPanel) => iPanel.rescale({resizing: false}));

}

return Module;
})
;
Expand Down

0 comments on commit 3972be7

Please sign in to comment.