Add mute button and tweak range inputs

This commit is contained in:
Essem 2023-07-03 12:04:06 -05:00
parent 7a75d8af55
commit 0b020dbdf8
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
2 changed files with 33 additions and 15 deletions

View file

@ -52,10 +52,13 @@
ref="progress" ref="progress"
:background="false" :background="false"
:tooltips="false" :tooltips="false"
:instant="true"
@update:modelValue="performSeek()" @update:modelValue="performSeek()"
@mousedown="initSeek()"
@mouseup="finishSeek()"
></FormRange> ></FormRange>
<button class="mute" @click="toggleMute()">
<i class="ph-speaker-simple-x ph-fill ph-lg" v-if="muted"></i>
<i class="ph-speaker-simple-high ph-fill ph-lg" v-else></i>
</button>
<FormRange <FormRange
:min="0" :min="0"
:max="1" :max="1"
@ -63,6 +66,8 @@
:step="0.1" :step="0.1"
:background="false" :background="false"
:tooltips="false" :tooltips="false"
:instant="true"
@update:modelValue="updateMute()"
></FormRange> ></FormRange>
<a <a
class="download" class="download"
@ -78,13 +83,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { import { ref, shallowRef, nextTick, onDeactivated, onMounted } from "vue";
ref,
shallowRef,
nextTick,
onDeactivated,
onMounted,
} from "vue";
import * as calckey from "calckey-js"; import * as calckey from "calckey-js";
import FormRange from "./form/range.vue"; import FormRange from "./form/range.vue";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
@ -120,6 +119,7 @@ let patData = shallowRef([] as ModRow[][]);
let currentPattern = ref(0); let currentPattern = ref(0);
let nbChannels = ref(0); let nbChannels = ref(0);
let length = ref(1); let length = ref(1);
let muted = ref(false);
const loaded = !!window.libopenmpt; const loaded = !!window.libopenmpt;
@ -227,12 +227,22 @@ function stop(noDisplayUpdate = false) {
player.value.clearHandlers(); player.value.clearHandlers();
} }
function initSeek() { let savedVolume = 0;
isSeeking = true;
function toggleMute() {
if (muted.value) {
player.value.context.gain.value = savedVolume;
savedVolume = 0;
} else {
savedVolume = player.value.context.gain.value;
player.value.context.gain.value = 0;
}
muted.value = !muted.value;
} }
function finishSeek() { function updateMute() {
isSeeking = false; muted.value = false;
savedVolume = 0;
} }
function performSeek() { function performSeek() {

View file

@ -19,7 +19,12 @@
@touchend="tooltipHide" @touchend="tooltipHide"
@mouseenter="tooltipShow" @mouseenter="tooltipShow"
@mouseleave="tooltipHide" @mouseleave="tooltipHide"
@input="(x) => (inputVal = x.target.value)" @input="
(x) => {
inputVal = x.target.value;
if (instant) onChange(x);
}
"
/> />
<datalist v-if="showTicks && steps" :id="id"> <datalist v-if="showTicks && steps" :id="id">
<option <option
@ -52,6 +57,7 @@ const props = withDefaults(
easing?: boolean; easing?: boolean;
background?: boolean; background?: boolean;
tooltips?: boolean; tooltips?: boolean;
instant?: boolean;
}>(), }>(),
{ {
step: 1, step: 1,
@ -59,6 +65,7 @@ const props = withDefaults(
easing: false, easing: false,
background: true, background: true,
tooltips: true, tooltips: true,
instant: false,
} }
); );
@ -134,12 +141,13 @@ function tooltipHide() {
$thumbWidth: 20px; $thumbWidth: 20px;
> .body { > .body {
padding: 10px 12px; padding: 10px 0;
background: none; background: none;
border: none; border: none;
border-radius: 6px; border-radius: 6px;
&.background { &.background {
padding: 10px 12px;
background: var(--panel); background: var(--panel);
border: solid 1px var(--panel); border: solid 1px var(--panel);
} }