adicionando instrumentos no editor de patterns
Deploy / Deploy (push) Successful in 1m54s Details

This commit is contained in:
JotaChina 2025-12-27 21:01:21 -03:00
parent 68101fab2e
commit f883ebfccf
1 changed files with 37 additions and 2 deletions

View File

@ -67,6 +67,19 @@ export function renderPatternEditor() {
title.innerHTML = `<i class="fa-solid ${titleIcon}" style="margin-right:8px"></i> <strong>${contextName}</strong>`;
navHeader.appendChild(title);
// não visualizar tracks nem instrumentos sem pattern selecionada
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
if (!isFocusedMode && !hasSelection) {
const msg = document.createElement("div");
msg.style.padding = "12px";
msg.style.color = "#bbb";
msg.textContent = "Selecione uma pattern para visualizar/editar.";
trackContainer.appendChild(msg);
updateGlobalPatternSelector();
return;
}
// Botão Voltar (Aparece apenas se estiver dentro de uma Bassline)
if (isFocusedMode) {
const backBtn = document.createElement("button");
@ -183,9 +196,31 @@ export function redrawSequencer() {
if (!trackData || !trackData.patterns || trackData.patterns.length === 0) return;
const isFocused = !!appState.pattern.focusedBasslineId;
const globalIdx = appState.pattern.activePatternIndex;
// ✅ Song Editor sem pattern selecionada: não mostra composição
if (!isFocused && !Number.isInteger(globalIdx)) {
// opcional: desenha uma grade "apagada" pra manter o layout
for (let i = 0; i < totalGridSteps; i++) {
const stepWrapper = document.createElement("div");
stepWrapper.className = "step-wrapper";
const stepElement = document.createElement("div");
stepElement.className = "step"; // sem .active
stepElement.style.opacity = "0.25";
stepElement.style.pointerEvents = "none";
stepWrapper.appendChild(stepElement);
sequencerContainer.appendChild(stepWrapper);
}
return;
}
// ✅ em foco: se não tiver globalIdx válido, cai no 0 (porque foco sempre edita algo)
const activePatternIndex = isFocused
? (appState.pattern.activePatternIndex || 0)
: (trackData.activePatternIndex || 0);
? (Number.isInteger(globalIdx) ? globalIdx : 0)
: globalIdx;
const activePattern = trackData.patterns[activePatternIndex];
if (!activePattern) return;