-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
off by default bugfixes settings rework
- Loading branch information
Showing
21 changed files
with
619 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @this {Settings} | ||
* @private | ||
*/ | ||
export function _toggleDarkMode() | ||
{ | ||
if(this.mode === "dark") | ||
{ | ||
this.mode = "light"; | ||
this.renderer.drawActiveNotes = false; | ||
} | ||
else | ||
{ | ||
this.renderer.drawActiveNotes = true; | ||
this.mode = "dark"; | ||
|
||
} | ||
this.renderer.toggleDarkMode(); | ||
this.synthui.toggleDarkMode(); | ||
this.sequi.toggleDarkMode() | ||
|
||
// top part | ||
document.getElementsByClassName("top_part")[0].classList.toggle("top_part_light"); | ||
|
||
// settings | ||
this.mainDiv.classList.toggle("settings_menu_light"); | ||
|
||
// rest | ||
// things get hacky here: change the global (*) --font-color to black: | ||
// find the star rule | ||
const rules = document.styleSheets[0].cssRules; | ||
for(let rule of rules) | ||
{ | ||
if(rule.selectorText === "*") | ||
{ | ||
rule.style.setProperty("--font-color", this.mode === "dark" ? "#eee" : "#333"); | ||
rule.style.setProperty("--top-buttons-color", this.mode === "dark" ? "linear-gradient(201deg, #222, #333)" : "linear-gradient(270deg, #ddd, #fff)"); | ||
break; | ||
} | ||
} | ||
document.body.style.background = this.mode === "dark" ? "black" : "white"; | ||
} | ||
|
||
/** | ||
* @this {Settings} | ||
* @private | ||
*/ | ||
export function _createInterfaceSettingsHandler() | ||
{ | ||
const button = this.htmlControls.interface.themeSelector; | ||
button.onclick = () => { | ||
this._toggleDarkMode(); | ||
this._saveSettings(); | ||
} | ||
const select = this.htmlControls.interface.languageSelector; | ||
// load up the languages | ||
for(const [code, locale] of Object.entries(this.locales)) | ||
{ | ||
const option = document.createElement("option"); | ||
option.value = code; | ||
option.textContent = locale.localeName | ||
select.appendChild(option); | ||
} | ||
select.onchange = () => { | ||
this.locale.changeGlobalLocale(this.locales[select.value]); | ||
this._saveSettings(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* The channel colors are taken from synthui | ||
* @param keyboard {MidiKeyboard} | ||
* @param synthui {SynthetizerUI} | ||
* @param renderer {Renderer} | ||
* @this {Settings} | ||
* @private | ||
*/ | ||
export function _createKeyboardHandler( keyboard, synthui, renderer) | ||
{ | ||
let channelNumber = 0; | ||
|
||
const keyboardControls = this.htmlControls.keyboard; | ||
|
||
const createChannel = () => | ||
{ | ||
const option = document.createElement("option"); | ||
|
||
option.value = channelNumber.toString(); | ||
// Channel: {0} gets formatred to channel number | ||
this.locale.bindObjectProperty(option, "textContent", "locale.settings.keyboardSettings.selectedChannel.channelOption", [channelNumber + 1]); | ||
|
||
option.style.background = synthui.channelColors[channelNumber % synthui.channelColors.length]; | ||
option.style.color = "rgb(0, 0, 0)"; | ||
|
||
keyboardControls.channelSelector.appendChild(option); | ||
channelNumber++; | ||
} | ||
|
||
// create the initial synth channels+ | ||
for (let i = 0; i <synthui.synth.channelsAmount; i++) | ||
{ | ||
createChannel(); | ||
} | ||
keyboardControls.channelSelector.onchange = () => { | ||
keyboard.selectChannel(parseInt(keyboardControls.channelSelector.value)); | ||
} | ||
|
||
keyboardControls.sizeSelector.onchange = () => { | ||
keyboard.keyRange = this.keyboardSizes[keyboardControls.sizeSelector.value]; | ||
renderer.keyRange = this.keyboardSizes[keyboardControls.sizeSelector.value]; | ||
this._saveSettings(); | ||
} | ||
|
||
// listen for new channels | ||
synthui.synth.eventHandler.addEvent("newchannel", "settings-new-channel", () => { | ||
createChannel(); | ||
}); | ||
|
||
// dark mode toggle | ||
keyboardControls.modeSelector.onclick = () => { | ||
keyboard.toggleMode(); | ||
this._saveSettings(); | ||
} | ||
} |
Oops, something went wrong.