adicionando instrumentos no editor de patterns
Deploy / Deploy (push) Successful in 1m58s
Details
Deploy / Deploy (push) Successful in 1m58s
Details
This commit is contained in:
parent
cca7ddd398
commit
14c2a3b658
|
|
@ -698,7 +698,11 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
(appState.audio.audioEditorSeekTime ?? 0) ||
|
||||
0;
|
||||
|
||||
const patternIndex = appState.pattern.activePatternIndex || 0;
|
||||
const patternIndex = appState.pattern.activePatternIndex;
|
||||
if (!Number.isInteger(patternIndex)) {
|
||||
showToast("Selecione uma pattern antes de enviar.", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
let posTicks = secondsToSongTicks(sec, bpm);
|
||||
posTicks = snapSongTicks(posTicks, LMMS_TICKS_PER_BAR); // snap por compasso (fica LMMS-like)
|
||||
|
|
@ -714,9 +718,13 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
|
||||
window.exitPatternFocus = function() {
|
||||
console.log("Saindo do foco da Bassline");
|
||||
appState.pattern.focusedBasslineId = null;
|
||||
renderAll();
|
||||
console.log("Saindo do foco da Bassline");
|
||||
appState.pattern.focusedBasslineId = null;
|
||||
|
||||
// ✅ sem pattern selecionada no Song Editor
|
||||
appState.pattern.activePatternIndex = null;
|
||||
|
||||
renderAll();
|
||||
}
|
||||
|
||||
loadAndRenderSampleBrowser();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export function initializePatternState() {
|
|||
|
||||
appState.pattern.tracks = [];
|
||||
appState.pattern.activeTrackId = null;
|
||||
appState.pattern.activePatternIndex = 0;
|
||||
appState.pattern.activePatternIndex = null;
|
||||
}
|
||||
|
||||
export async function loadAudioForTrack(track) {
|
||||
|
|
|
|||
|
|
@ -323,21 +323,30 @@ export function updateGlobalPatternSelector() {
|
|||
globalPatternSelector.innerHTML = '';
|
||||
|
||||
if (referenceTrack && referenceTrack.patterns && referenceTrack.patterns.length > 0) {
|
||||
referenceTrack.patterns.forEach((pattern, index) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = index;
|
||||
option.textContent = pattern.name;
|
||||
globalPatternSelector.appendChild(option);
|
||||
});
|
||||
const isFocused = !!appState.pattern.focusedBasslineId;
|
||||
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
|
||||
|
||||
if (isFocused) {
|
||||
globalPatternSelector.value = appState.pattern.activePatternIndex || 0;
|
||||
} else if (activeTrack) {
|
||||
globalPatternSelector.value = activeTrack.activePatternIndex || 0;
|
||||
} else {
|
||||
globalPatternSelector.value = 0;
|
||||
}
|
||||
globalPatternSelector.disabled = false;
|
||||
globalPatternSelector.innerHTML = '';
|
||||
|
||||
if (!isFocused && !hasSelection) {
|
||||
const ph = document.createElement('option');
|
||||
ph.value = '';
|
||||
ph.textContent = 'Selecione uma pattern…';
|
||||
ph.disabled = true;
|
||||
ph.selected = true;
|
||||
globalPatternSelector.appendChild(ph);
|
||||
}
|
||||
|
||||
referenceTrack.patterns.forEach((pattern, index) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = index;
|
||||
option.textContent = pattern.name;
|
||||
globalPatternSelector.appendChild(option);
|
||||
});
|
||||
|
||||
// ✅ em vez de forçar 0
|
||||
globalPatternSelector.value = hasSelection ? String(appState.pattern.activePatternIndex) : '';
|
||||
globalPatternSelector.disabled = false;
|
||||
} else {
|
||||
const option = document.createElement('option');
|
||||
option.textContent = 'Sem patterns';
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { DEFAULT_VOLUME, DEFAULT_PAN } from "./config.js";
|
|||
const patternState = {
|
||||
tracks: [],
|
||||
activeTrackId: null,
|
||||
activePatternIndex: 0,
|
||||
activePatternIndex: null,
|
||||
};
|
||||
|
||||
const globalState = {
|
||||
|
|
@ -164,7 +164,7 @@ export function resetProjectState() {
|
|||
Object.assign(appState.pattern, {
|
||||
tracks: [],
|
||||
activeTrackId: null,
|
||||
activePatternIndex: 0,
|
||||
activePatternIndex: null,
|
||||
focusedBasslineId: null,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue