Skip to content

Commit

Permalink
Improve positioning of info tray and related controls
Browse files Browse the repository at this point in the history
Closes #202.
  • Loading branch information
phschaad committed Oct 18, 2022
1 parent 9ed4d3c commit 7f6daf5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion media/components/sdfv/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
</div>
</div>
</div>
<div id="expand-info-btn" title="Expand Tray">
<div id="expand-info-btn" title="Expand Tray" class="expand-info-btn-top">
<span><i class="material-icons">menu_open</i></span>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/sdfg_viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ export class SdfgViewerProvider
'offcanvas offcanvas-end',
'offcanvas offcanvas-bottom'
);
baseHtml = baseHtml.replace(
'expand-info-btn-top',
'expand-info-btn-bottom'
);
baseHtml = baseHtml.replace(
'id="layout-toggle-btn" class="vertical"',
'id="layout-toggle-btn" class="horizontal"'
Expand Down
10 changes: 9 additions & 1 deletion src/webclients/components/sdfv/vscode_sdfv.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,17 @@ pre.code {
#expand-info-btn {
cursor: pointer;
position: absolute;
margin: .4rem;
}

#expand-info-btn.expand-info-btn-top {
top: 0;
right: 0;
}

#expand-info-btn.expand-info-btn-bottom {
bottom: 0;
right: 0;
margin: .4rem;
}

#info-contents {
Expand Down
28 changes: 26 additions & 2 deletions src/webclients/components/sdfv/vscode_sdfv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ export class VSCodeSDFV extends SDFV {
* Show the info box and its necessary components.
*/
public infoBoxShow(overrideHidden: boolean = false): void {
if (!this.infoTrayExplicitlyHidden || overrideHidden)
$('#info-container').addClass('show');
if (!this.infoTrayExplicitlyHidden || overrideHidden) {
const infoBox = $('#info-container');
infoBoxCheckUncoverTopBar(infoBox, $('#top-bar'));
infoBox.addClass('show');
}
}

/**
Expand Down Expand Up @@ -856,12 +859,26 @@ export function vscodeHandleEvent(event: string, data: any): void {
}
}

function infoBoxCheckUncoverTopBar(
infoContainer: JQuery<HTMLElement>, topBar: JQuery<HTMLElement>
): void {
// If the info container is to the side, ensure it doesn't cover up the
// top bar when shown.
if (infoContainer.hasClass('offcanvas-end')) {
const topBarHeight = topBar.outerHeight(false);
infoContainer.css('top', topBarHeight + 'px');
} else {
infoContainer.css('top', '');
}
}

$(() => {
const infoContainer = $('#info-container');
const layoutToggleBtn = $('#layout-toggle-btn');
const infoDragBar = $('#info-drag-bar');
const expandInfoBtn = $('#expand-info-btn');
const infoCloseBtn = $('#info-close-btn');
const topBar = $('#top-bar');

// Set up resizing of the info drawer.
let draggingDragInfoBar = false;
Expand Down Expand Up @@ -912,17 +929,23 @@ $(() => {
if (oldDir === 'vertical') {
infoContainer.removeClass('offcanvas-end');
infoContainer.addClass('offcanvas-bottom');
infoBoxCheckUncoverTopBar(infoContainer, topBar);
infoDragBar.removeClass('gutter-vertical');
infoDragBar.addClass('gutter-horizontal');
expandInfoBtn.removeClass('expand-info-btn-top');
expandInfoBtn.addClass('expand-info-btn-bottom');
$(document).off('mousemove', infoChangeWidthHandler);
$(document).on('mousemove', infoChangeHeightHandler);
infoContainer.width('100%');
infoContainer.height(lastHorHeight);
} else {
infoContainer.removeClass('offcanvas-bottom');
infoContainer.addClass('offcanvas-end');
infoBoxCheckUncoverTopBar(infoContainer, topBar);
infoDragBar.removeClass('gutter-horizontal');
infoDragBar.addClass('gutter-vertical');
expandInfoBtn.removeClass('expand-info-btn-bottom');
expandInfoBtn.addClass('expand-info-btn-top');
$(document).off('mousemove', infoChangeHeightHandler);
$(document).on('mousemove', infoChangeWidthHandler);
infoContainer.height('100%');
Expand All @@ -942,6 +965,7 @@ $(() => {
});
expandInfoBtn.on('click', () => {
expandInfoBtn.hide();
infoBoxCheckUncoverTopBar(infoContainer, topBar);
infoContainer.addClass('show');
VSCodeSDFV.getInstance().infoTrayExplicitlyHidden = false;
});
Expand Down

0 comments on commit 7f6daf5

Please sign in to comment.