Skip to content

Commit 688ee52

Browse files
committed
gsuiOscillator: handle 'source' or 'wave'
1 parent 7217056 commit 688ee52

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

gsuiOscillator/gsuiOscillator.css

+20
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ gsui-oscillator[ type="noise" ] .gsuiOscillator-detune .gsuiOscillator-sliderVal
8080
/* .......................................................................... */
8181
.gsuiOscillator-waveWrap {
8282
position: relative;
83+
overflow: hidden;
8384
grid-area: wave;
8485
display: flex;
8586
border-radius: 3px;
@@ -89,9 +90,11 @@ gsui-oscillator[ type="noise" ] .gsuiOscillator-detune .gsuiOscillator-sliderVal
8990
flex: 1;
9091
display: flex;
9192
flex-direction: column;
93+
overflow: hidden;
9294
}
9395
.gsuiOscillator-waveWrap-top {
9496
display: flex;
97+
height: 18px;
9598
}
9699
.gsuiOscillator-wave {
97100
flex: 1;
@@ -119,11 +122,23 @@ gsui-oscillator[ type="noise" ] .gsuiOscillator-detune .gsuiOscillator-sliderVal
119122
opacity: .5;
120123
transition: .1s opacity;
121124
}
125+
gsui-oscillator[ source ] .gsuiOscillator-waveBtn,
126+
gsui-oscillator[ source ] .gsuiOscillator-waveSelect,
127+
gsui-oscillator[ wave ] .gsuiOscillator-sourceIcon,
128+
gsui-oscillator[ wave ] .gsuiOscillator-sourceName {
129+
display: none;
130+
}
131+
.gsuiOscillator-sourceIcon,
122132
.gsuiOscillator-waveBtn {
123133
width: 14px;
124134
font-size: 16px;
125135
text-align: center;
126136
}
137+
.gsuiOscillator-sourceIcon {
138+
margin-left: 6px;
139+
font-size: 12px;
140+
opacity: .5;
141+
}
127142
.gsuiOscillator-remove {
128143
position: absolute;
129144
inset: 0 2px auto auto;
@@ -141,13 +156,18 @@ gsui-oscillator[ type="noise" ] .gsuiOscillator-detune .gsuiOscillator-sliderVal
141156
}
142157

143158
/* .......................................................................... */
159+
.gsuiOscillator-sourceName,
144160
.gsuiOscillator-waveSelect {
145161
flex: 1;
146162
padding-left: 6px;
147163
font-size: 12px;
148164
font-family: inherit;
165+
overflow: hidden;
166+
white-space: nowrap;
167+
text-overflow: ellipsis;
149168
-moz-appearance: none;
150169
-webkit-appearance: none;
170+
opacity: .5;
151171
}
152172
.gsuiOscillator-waveOpt {
153173
background-color: var( --gsuiOscillator-wave-option );

gsuiOscillator/gsuiOscillator.html.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ GSUsetTemplate( "gsui-oscillator", waves => {
1212
GSUcreateSelect( { class: "gsuiOscillator-waveSelect" },
1313
waves.map( w => GSUcreateOption( { class: "gsuiOscillator-waveOptNative", value: w } ) )
1414
),
15+
GSUcreateI( { class: "gsuiOscillator-sourceIcon gsuiIcon", "data-icon": "waveform" } ),
16+
GSUcreateSpan( { class: "gsuiOscillator-sourceName" } ),
1517
),
1618
GSUcreateDiv( { class: "gsuiOscillator-wave" },
1719
GSUcreateElement( "gsui-periodicwave" ),

gsuiOscillator/gsuiOscillator.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class gsuiOscillator extends HTMLElement {
2020
waveSelect: ".gsuiOscillator-waveSelect",
2121
wavePrev: ".gsuiOscillator-wavePrev",
2222
waveNext: ".gsuiOscillator-waveNext",
23+
sourceName: ".gsuiOscillator-sourceName",
2324
waves: [
2425
"gsui-periodicwave:first-child",
2526
"gsui-periodicwave:last-child",
@@ -90,7 +91,8 @@ class gsuiOscillator extends HTMLElement {
9091
this.#elements.waves[ 1 ].$nbLines( 1 );
9192
GSUrecallAttributes( this, {
9293
order: 0,
93-
wave: "sine",
94+
wave: undefined,
95+
source: undefined,
9496
detune: 0,
9597
detunefine: 0,
9698
gain: 1,
@@ -103,7 +105,7 @@ class gsuiOscillator extends HTMLElement {
103105
}
104106
}
105107
static get observedAttributes() {
106-
return [ "order", "wave", "detune", "detunefine", "gain", "pan", "unisonvoices", "unisondetune", "unisonblend" ];
108+
return [ "order", "wave", "source", "detune", "detunefine", "gain", "pan", "unisonvoices", "unisondetune", "unisonblend" ];
107109
}
108110
attributeChangedCallback( prop, prev, val ) {
109111
if ( !this.#children && prev !== val ) {
@@ -112,6 +114,7 @@ class gsuiOscillator extends HTMLElement {
112114
switch ( prop ) {
113115
case "order": this.#changeOrder( num ); break;
114116
case "wave": this.#changeWave( val ); break;
117+
case "source": this.#changeSource( val ); break;
115118
case "unisonvoices":
116119
this.#updateUnisonGraphVoices( num );
117120
this.#changePropSlider( "unisonvoices", num );
@@ -169,6 +172,10 @@ class gsuiOscillator extends HTMLElement {
169172
#changeOrder( n ) {
170173
this.dataset.order = n;
171174
}
175+
#changeSource( src ) {
176+
this.#elements.sourceName.textContent = src;
177+
GSUsetAttribute( this, "wave", false );
178+
}
172179
#changeWave( w ) {
173180
const noise = w === "noise";
174181

@@ -178,6 +185,7 @@ class gsuiOscillator extends HTMLElement {
178185
GSUsetAttribute( this.#elements.sliders.unisonvoices[ 0 ], "disabled", noise );
179186
GSUsetAttribute( this.#elements.sliders.unisondetune[ 0 ], "disabled", noise );
180187
GSUsetAttribute( this.#elements.sliders.unisonblend[ 0 ], "disabled", noise );
188+
GSUsetAttribute( this, "source", false );
181189
}
182190
#changePropSlider( prop, val ) {
183191
const [ sli, span ] = this.#elements.sliders[ prop ];

gsuiOscillator/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
GSUsetAttribute( elOsc, "wave", "square" );
6767
GSUsetAttribute( elOsc, "wave", "sawtooth" );
6868
GSUsetAttribute( elOsc, "gain", .5 );
69+
// GSUsetAttribute( elOsc, "source", "A buffer instead of a wave" );
70+
// GSUsetAttribute( elOsc, "wave", "noise" );
6971
</script>
7072
</body>
7173
</html>

0 commit comments

Comments
 (0)