adicionando instrumentos no editor de patterns
Deploy / Deploy (push) Successful in 1m56s
Details
Deploy / Deploy (push) Successful in 1m56s
Details
This commit is contained in:
parent
14c2a3b658
commit
68101fab2e
|
|
@ -660,7 +660,7 @@ export async function parseMmpContent(xmlString) {
|
|||
|
||||
const firstInst = newTracks.find((t) => t.type !== "bassline");
|
||||
appState.pattern.activeTrackId = firstInst ? firstInst.id : null;
|
||||
appState.pattern.activePatternIndex = 0;
|
||||
appState.pattern.activePatternIndex = null;
|
||||
|
||||
loadStateFromSession();
|
||||
|
||||
|
|
|
|||
|
|
@ -308,49 +308,52 @@ export function updateStepUI(trackIndex, patternIndex, stepIndex, isActive) {
|
|||
|
||||
// Atualiza o dropdown de patterns na toolbar
|
||||
export function updateGlobalPatternSelector() {
|
||||
const globalPatternSelector = document.getElementById('global-pattern-selector');
|
||||
if (!globalPatternSelector) return;
|
||||
const sel = document.getElementById("global-pattern-selector");
|
||||
if (!sel) return;
|
||||
|
||||
const activeTrackId = appState.pattern.activeTrackId;
|
||||
const activeTrack = appState.pattern.tracks.find(t => t.id === activeTrackId);
|
||||
|
||||
// Tenta pegar a track ativa ou a primeira visível como referência de patterns
|
||||
const isFocused = !!appState.pattern.focusedBasslineId;
|
||||
const referenceTrack = isFocused
|
||||
? appState.pattern.tracks.find(t => t.type !== "bassline" && t.parentBasslineId !== null)
|
||||
: (activeTrack || appState.pattern.tracks.find(t => !t.isMuted && t.type !== "bassline"));
|
||||
const isFocused = !!appState.pattern.focusedBasslineId;
|
||||
|
||||
globalPatternSelector.innerHTML = '';
|
||||
// track de referência que tenha patterns
|
||||
const referenceTrack = (appState.pattern.tracks || []).find(
|
||||
(t) => t.type !== "bassline" && Array.isArray(t.patterns) && t.patterns.length > 0
|
||||
);
|
||||
|
||||
if (referenceTrack && referenceTrack.patterns && referenceTrack.patterns.length > 0) {
|
||||
const isFocused = !!appState.pattern.focusedBasslineId;
|
||||
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
|
||||
sel.innerHTML = "";
|
||||
|
||||
globalPatternSelector.innerHTML = '';
|
||||
if (!referenceTrack) {
|
||||
const opt = document.createElement("option");
|
||||
opt.textContent = "Sem patterns";
|
||||
sel.appendChild(opt);
|
||||
sel.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isFocused && !hasSelection) {
|
||||
const ph = document.createElement('option');
|
||||
ph.value = '';
|
||||
ph.textContent = 'Selecione uma pattern…';
|
||||
ph.disabled = true;
|
||||
ph.selected = true;
|
||||
globalPatternSelector.appendChild(ph);
|
||||
}
|
||||
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
|
||||
|
||||
referenceTrack.patterns.forEach((pattern, index) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = index;
|
||||
option.textContent = pattern.name;
|
||||
globalPatternSelector.appendChild(option);
|
||||
});
|
||||
// ✅ placeholder só quando NÃO está focado e NÃO tem seleção
|
||||
if (!isFocused && !hasSelection) {
|
||||
const ph = document.createElement("option");
|
||||
ph.value = "";
|
||||
ph.textContent = "Selecione uma pattern";
|
||||
ph.disabled = true;
|
||||
ph.selected = true;
|
||||
sel.appendChild(ph);
|
||||
}
|
||||
|
||||
// ✅ 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';
|
||||
globalPatternSelector.appendChild(option);
|
||||
globalPatternSelector.disabled = true;
|
||||
}
|
||||
}
|
||||
referenceTrack.patterns.forEach((p, idx) => {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = String(idx);
|
||||
opt.textContent = p.name || `Pattern ${idx + 1}`;
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
|
||||
if (isFocused) {
|
||||
// em foco: se não tiver índice ainda, cai pra 0
|
||||
sel.value = String(appState.pattern.activePatternIndex ?? 0);
|
||||
} else {
|
||||
// fora de foco: só seta valor se realmente existir seleção
|
||||
sel.value = hasSelection ? String(appState.pattern.activePatternIndex) : "";
|
||||
}
|
||||
|
||||
sel.disabled = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue