Skip to content

Commit

Permalink
Fix resizing on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianoiam committed Apr 10, 2022
1 parent 9a7c07d commit 7568a0c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ include hiphop/Makefile.plugins.mk

TARGETS += lv2_sep vst vst3

LXHELPER_CPPFLAGS += -Isrc
BASE_FLAGS += -Isrc

# Required for soundpipe.h
Expand Down
2 changes: 1 addition & 1 deletion hiphop
5 changes: 5 additions & 0 deletions src/DistrhoPluginInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
Make room for growing the UI on Linux/GTK
*/
#define HIPHOP_UI_USER_RESIZABLE 1

/**
The plugin name.@n
This is used to identify your plugin before a Plugin instance can be created.
Expand Down
2 changes: 1 addition & 1 deletion src/ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body {
margin: 0;
background-color: #8c8c8c;
color: #000000;
position: relative; /* for the resize handle */
position: relative;
}

g-knob {
Expand Down
18 changes: 10 additions & 8 deletions src/ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class CastelloReverbUI extends DISTRHO.UI {
// Setting up resize handle needs calling async methods

(async () => {
const w = await this.getInitWidth(),
const w = await this.getInitWidth(), // CSS pixels
h = await this.getInitHeight();

resize.opt.minWidth = w;
resize.opt.minHeight = h;

this.sizeChanged(w, h);
this._sizeChanged();

document.body.style.visibility = 'visible';
}) ();
Expand Down Expand Up @@ -95,15 +95,17 @@ class CastelloReverbUI extends DISTRHO.UI {
}
}

sizeChanged(width, height) {
this._sizeChanged();
}

/* It is not currently possible to rely on vh/vw/vmin/vmax units on Linux
due to the GTK web view implementation on such platform */

sizeChanged(width, height) {
_sizeChanged() {
if (DISTRHO.env.noCSSViewportUnits) {
height /= window.devicePixelRatio;

document.querySelectorAll('g-knob').forEach(((el) => {
el.style.height = (0.3 * height) + 'px';
el.style.height = (0.3/*30vh*/ * document.body.clientHeight) + 'px';
el.style.width = el.style.height;
}));
}
Expand All @@ -114,9 +116,9 @@ class CastelloReverbUI extends DISTRHO.UI {
this.setParameterValue(parameterIndex, ev.target.value);
});

function updateLabel(value) {
const updateLabel = (value) => {
el.parentNode.children[2].innerText = labelFormatCallback(value);
}
};

el.addEventListener('setvalue', (ev) => updateLabel(ev.value));

Expand Down

0 comments on commit 7568a0c

Please sign in to comment.