Skip to content

Commit

Permalink
widgets/meter - enhancements to fullscreen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ksraj123 authored and meganindya committed Jan 26, 2021
1 parent ed7aeac commit 2462d31
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
21 changes: 19 additions & 2 deletions js/widgets/meterwidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
PREVIEWVOLUME, TONEBPM
*/

// eslint-disable-next-line no-unused-vars
/*exported MeterWidget*/
class MeterWidget {
// A pie menu is used to show the meter and strong beats
static BUTTONDIVWIDTH = 535;
Expand Down Expand Up @@ -69,6 +69,8 @@ class MeterWidget {
widgetWindow.destroy();
};

widgetWindow.onmaximize = this._scale;

this._click_lock = false;
const playBtn = widgetWindow.addButton("play-button.svg", MeterWidget.ICONSIZE, _("Play"));
playBtn.onclick = () => {
Expand Down Expand Up @@ -188,6 +190,20 @@ class MeterWidget {

logo.textMsg(_("Click in the circle to select strong beats for the meter."));
widgetWindow.sendToCenter();
this._scale.call(this.widgetWindow);
}

_scale() {
const windowHeight =
this.getWidgetFrame().offsetHeight - this.getDragElement().offsetHeight;
const svg = this.getWidgetBody().getElementsByTagName("svg")[0];
const scale = this.isMaximized() ? windowHeight / 400 : 1;
svg.style.pointerEvents = "none";
svg.setAttribute("height", `${400 * scale}px`);
svg.setAttribute("width", `${400 * scale}px`);
setTimeout(() => {
svg.style.pointerEvents = "auto";
}, 100);
}

/**
Expand Down Expand Up @@ -363,7 +379,8 @@ class MeterWidget {
_piemenuMeter(numberOfBeats, beatValue) {
// pie menu for strong beat selection

docById("meterWheelDiv").style.display = "";
docById("meterWheelDiv").style.display = "flex";
docById("meterWheelDiv").style.justifyContent = "center";

// Use advanced constructor for multiple wheelnavs in the same div.
// The meterWheel is used to hold the strong beats.
Expand Down
22 changes: 19 additions & 3 deletions js/widgets/widgetWindows.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class WidgetWindow {
}
});

document.addEventListener("mouseup", (e) => {
document.addEventListener("mouseup", () => {
this._dragging = false;
});

Expand Down Expand Up @@ -173,7 +173,7 @@ class WidgetWindow {
window.onscroll = () => {
window.scrollTo(scrollLeft, scrollTop);
};
}
};

this._widget = this._create("div", "wfbWidget", this._body);
this._widget.addEventListener("wheel", disableScroll, false);
Expand All @@ -190,7 +190,7 @@ class WidgetWindow {
language = navigator.language;
}

console.debug("language setting is " + language);
// console.debug("language setting is " + language);
// For Japanese, put the toolbar on the top.
if (language === "ja") {
this._body.style.flexDirection = "column";
Expand Down Expand Up @@ -413,6 +413,14 @@ class WidgetWindow {
return this._widget;
}

/**
* @public
* @returns {HTMLElement}
*/
getWidgetFrame() {
return this._frame;
}

/**
* @deprecated
*/
Expand Down Expand Up @@ -445,6 +453,14 @@ class WidgetWindow {
return this;
}

/**
* @public
* @returns {boolean}
*/
isMaximized() {
return this._maximized;
}

/**
* @returns {void}
*/
Expand Down

0 comments on commit 2462d31

Please sign in to comment.