Skip to content

Commit

Permalink
Merge pull request #117 from Multiplicom/feature/116/viewer_without_p…
Browse files Browse the repository at this point in the history
…opup_menu

Enable creating split track viewer without toolbox menu (#116)
  • Loading branch information
Bastiaan van den Berg committed Aug 11, 2021
2 parents e8c133f + 933bb5e commit e384e07
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions Panels/FrameTrackViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,9 @@ define([
/**
* Frame that uses the PanelSplitTrackViewer to show the two PanelTrackViewers.
*
* @param toolBoxWidth the width of the toolbox.
* @param toolBoxWidth the width of the toolbox. The toolbox menu button
* (hamburger button at the top left) and the corresponding popup
* toolbox is not included if the toolbox width is undefined or <= 0.
* @returns {*}
* @constructor
*/
Expand All @@ -1235,16 +1237,20 @@ define([
theLeftPanel._setFrame(theFrame);
theRightPanel._setFrame(theFrame);

theFrame.includesToolBox = toolBoxWidth > 0;
theFrame.trackControlsGroup = Controls.Compound.GroupVert({separator: 3});
theFrame._popupMenuExtraControlsGroup = Controls.Compound.GroupVert({separator: 3});

const toolBox = Frame.ToolBox.create(
Icon.createFA('fa-bars'),
Controls.Compound.FixedWidth(Controls.Compound.StandardMargin(
Controls.Compound.GroupVert({separator: 10}, [theFrame.trackControlsGroup, theFrame._popupMenuExtraControlsGroup])
), toolBoxWidth)
);
theFrame.setToolBox(toolBox);
if (theFrame.includesToolBox) {
const toolBox = Frame.ToolBox.create(
Icon.createFA('fa-bars'),
Controls.Compound.FixedWidth(Controls.Compound.StandardMargin(
Controls.Compound.GroupVert({separator: 10}, [theFrame.trackControlsGroup, theFrame._popupMenuExtraControlsGroup])
), toolBoxWidth)
);
theFrame.setToolBox(toolBox);
theFrame.addCommandSpacer(40);
}

theFrame.getLeftPanel = function() {
return theLeftPanel;
Expand All @@ -1254,8 +1260,6 @@ define([
return theRightPanel;
};

theFrame.addCommandSpacer(40);

theFrame.addCommand({
icon: Icon.createFA("fa-search-plus").addDecorator('fa-arrows-h', 'left', 0, 'bottom', -7, 0.6),
hint: _TRL("Zoom in")
Expand All @@ -1275,7 +1279,12 @@ define([
});

theFrame.addExtraPopupMenuControl = function(ctrl) {
theFrame._popupMenuExtraControlsGroup.add(ctrl);
if (theFrame.includesToolBox) {
theFrame._popupMenuExtraControlsGroup.add(ctrl);
}
else {
console.error('Trying to add control to non-existing popup menu.');
}
};

theFrame.addLeftTrack = function(track) {
Expand Down Expand Up @@ -1319,7 +1328,7 @@ define([
function addTrack(iFrame, iTrack, iPanel) {
const isLive = addTrackToPanel(iTrack, iPanel);

if (iTrack.canHide()) {
if (iFrame.includesToolBox && iTrack.canHide()) {
iTrack.__ctrl_visible = Controls.Check({text: iTrack.getName(), checked: iTrack.isVisible()});
iFrame.trackControlsGroup.add(iTrack.__ctrl_visible);
iFrame.trackControlsGroup.liveUpdate();
Expand Down Expand Up @@ -1357,17 +1366,19 @@ define([
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);
if (iFrame.includesToolBox) {
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});
}
});
hider.addNotificationHandler(function() {
for([iTrack, iPanel] of trackPanels) {
iTrack.setVisible(hider.getValue());
iPanel.rescale({resizing: false});
}
});
}
}

iPanels
Expand All @@ -1379,4 +1390,3 @@ define([
return Module;
})
;

0 comments on commit e384e07

Please sign in to comment.