Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable creating split track viewer without toolbox menu (#116) #117

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 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 && toolBoxWidth > 0;
basvandenberg marked this conversation as resolved.
Show resolved Hide resolved
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 Down