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");
|
const firstInst = newTracks.find((t) => t.type !== "bassline");
|
||||||
appState.pattern.activeTrackId = firstInst ? firstInst.id : null;
|
appState.pattern.activeTrackId = firstInst ? firstInst.id : null;
|
||||||
appState.pattern.activePatternIndex = 0;
|
appState.pattern.activePatternIndex = null;
|
||||||
|
|
||||||
loadStateFromSession();
|
loadStateFromSession();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,49 +308,52 @@ export function updateStepUI(trackIndex, patternIndex, stepIndex, isActive) {
|
||||||
|
|
||||||
// Atualiza o dropdown de patterns na toolbar
|
// Atualiza o dropdown de patterns na toolbar
|
||||||
export function updateGlobalPatternSelector() {
|
export function updateGlobalPatternSelector() {
|
||||||
const globalPatternSelector = document.getElementById('global-pattern-selector');
|
const sel = document.getElementById("global-pattern-selector");
|
||||||
if (!globalPatternSelector) return;
|
if (!sel) return;
|
||||||
|
|
||||||
const activeTrackId = appState.pattern.activeTrackId;
|
const isFocused = !!appState.pattern.focusedBasslineId;
|
||||||
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"));
|
|
||||||
|
|
||||||
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) {
|
sel.innerHTML = "";
|
||||||
const isFocused = !!appState.pattern.focusedBasslineId;
|
|
||||||
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
|
|
||||||
|
|
||||||
globalPatternSelector.innerHTML = '';
|
if (!referenceTrack) {
|
||||||
|
const opt = document.createElement("option");
|
||||||
|
opt.textContent = "Sem patterns";
|
||||||
|
sel.appendChild(opt);
|
||||||
|
sel.disabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isFocused && !hasSelection) {
|
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
|
||||||
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) => {
|
// ✅ placeholder só quando NÃO está focado e NÃO tem seleção
|
||||||
const option = document.createElement('option');
|
if (!isFocused && !hasSelection) {
|
||||||
option.value = index;
|
const ph = document.createElement("option");
|
||||||
option.textContent = pattern.name;
|
ph.value = "";
|
||||||
globalPatternSelector.appendChild(option);
|
ph.textContent = "Selecione uma pattern";
|
||||||
});
|
ph.disabled = true;
|
||||||
|
ph.selected = true;
|
||||||
|
sel.appendChild(ph);
|
||||||
|
}
|
||||||
|
|
||||||
// ✅ em vez de forçar 0
|
referenceTrack.patterns.forEach((p, idx) => {
|
||||||
globalPatternSelector.value = hasSelection ? String(appState.pattern.activePatternIndex) : '';
|
const opt = document.createElement("option");
|
||||||
globalPatternSelector.disabled = false;
|
opt.value = String(idx);
|
||||||
} else {
|
opt.textContent = p.name || `Pattern ${idx + 1}`;
|
||||||
const option = document.createElement('option');
|
sel.appendChild(opt);
|
||||||
option.textContent = 'Sem patterns';
|
});
|
||||||
globalPatternSelector.appendChild(option);
|
|
||||||
globalPatternSelector.disabled = true;
|
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