From 25e6cfef7205d8286409000e4d065149bfbd9d8a Mon Sep 17 00:00:00 2001 From: manongjohn Date: Sep 22 2017 02:10:54 +0000 Subject: Correct Preview and Camera toggle for Sound columns (#1472) * Correct sound level's preview and camera toggle button behavior --- diff --git a/toonz/sources/toonz/comboviewerpane.cpp b/toonz/sources/toonz/comboviewerpane.cpp index 05bd8b7..480adaf 100644 --- a/toonz/sources/toonz/comboviewerpane.cpp +++ b/toonz/sources/toonz/comboviewerpane.cpp @@ -841,6 +841,7 @@ bool ComboViewerPanel::hasSoundtrack() { } TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet(); TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); + if(!m_sceneViewer->isPreviewEnabled()) prop->m_isPreview = true; m_sound = xsheetHandle->getXsheet()->makeSound(prop); if (m_sound == NULL) { m_hasSoundtrack = false; diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cpp index 43afba2..0cdc9db 100644 --- a/toonz/sources/toonz/viewerpane.cpp +++ b/toonz/sources/toonz/viewerpane.cpp @@ -716,6 +716,7 @@ bool SceneViewerPanel::hasSoundtrack() { } TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet(); TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); + if (!m_sceneViewer->isPreviewEnabled()) prop->m_isPreview = true; m_sound = xsheetHandle->getXsheet()->makeSound(prop); if (m_sound == NULL) { m_hasSoundtrack = false; diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp index a99a279..b50f5f0 100644 --- a/toonz/sources/toonz/xshcellviewer.cpp +++ b/toonz/sources/toonz/xshcellviewer.cpp @@ -1000,7 +1000,7 @@ void CellArea::drawCells(QPainter &p, const QRect toBeUpdated) { if (!isColumn) continue; // Cells appearance depending on the type of column if (isSoundColumn) - drawSoundCell(p, row, col); + drawSoundCell(p, row, col, isReference); else if (isPaletteColumn) drawPaletteCell(p, row, col, isReference); else if (isSoundTextColumn) @@ -1131,7 +1131,7 @@ void CellArea::drawExtenderHandles(QPainter &p) { //----------------------------------------------------------------------------- -void CellArea::drawSoundCell(QPainter &p, int row, int col) { +void CellArea::drawSoundCell(QPainter &p, int row, int col, bool isReference) { const Orientation *o = m_viewer->orientation(); TXshSoundColumn *soundColumn = m_viewer->getXsheet()->getColumn(col)->getSoundColumn(); @@ -1168,8 +1168,14 @@ void CellArea::drawSoundCell(QPainter &p, int row, int col) { // get cell colors QColor cellColor, sideColor; int levelType; - m_viewer->getCellTypeAndColors(levelType, cellColor, sideColor, cell, - isSelected); + if (isReference) { + cellColor = (isSelected) ? m_viewer->getSelectedReferenceColumnColor() + : m_viewer->getReferenceColumnColor(); + sideColor = m_viewer->getReferenceColumnBorderColor(); + } + else + m_viewer->getCellTypeAndColors(levelType, cellColor, sideColor, cell, + isSelected); // cells background p.fillRect(rect, QBrush(cellColor)); diff --git a/toonz/sources/toonz/xshcellviewer.h b/toonz/sources/toonz/xshcellviewer.h index 677c6e4..ed26fc5 100644 --- a/toonz/sources/toonz/xshcellviewer.h +++ b/toonz/sources/toonz/xshcellviewer.h @@ -86,7 +86,7 @@ class CellArea final : public QWidget { void drawLevelCell(QPainter &p, int row, int col, bool isReference = false); void drawSoundTextCell(QPainter &p, int row, int col); - void drawSoundCell(QPainter &p, int row, int col); + void drawSoundCell(QPainter &p, int row, int col, bool isReference = false); void drawPaletteCell(QPainter &p, int row, int col, bool isReference = false); void drawKeyframe(QPainter &p, const QRect toBeUpdated); diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index 383f186..acf9d46 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -618,7 +618,7 @@ void ColumnArea::DrawHeader::levelColors(QColor &columnColor, } void ColumnArea::DrawHeader::soundColors(QColor &columnColor, QColor &dragColor) const { - m_viewer->getColumnColor(columnColor, dragColor, col, xsh); + m_viewer->getColumnColor(columnColor, dragColor, col, xsh); } void ColumnArea::DrawHeader::paletteColors(QColor &columnColor, QColor &dragColor) const { @@ -1226,7 +1226,8 @@ void ColumnArea::drawSoundColumnHead(QPainter &p, int col) { // AREA DrawHeader drawHeader(this, p, col); drawHeader.prepare(); QColor columnColor, dragColor; - drawHeader.soundColors(columnColor, dragColor); +// drawHeader.soundColors(columnColor, dragColor); + drawHeader.levelColors(columnColor, dragColor); drawHeader.drawBaseFill(columnColor, dragColor); drawHeader.drawEye(); drawHeader.drawPreviewToggle(255); @@ -1868,7 +1869,7 @@ void ColumnArea::mouseReleaseEvent(QMouseEvent *event) { if (m_doOnRelease == ToggleTransparency && (!m_columnTransparencyPopup || m_columnTransparencyPopup->isHidden())) { column->setCamstandVisible(!column->isCamstandVisible()); - app->getCurrentXsheet()->notifyXsheetSoundChanged(); + if (column->getSoundColumn()) app->getCurrentXsheet()->notifyXsheetSoundChanged(); } else if (m_doOnRelease == TogglePreviewVisible) column->setPreviewVisible(!column->isPreviewVisible()); else if (m_doOnRelease == ToggleLock) diff --git a/toonz/sources/toonzlib/tframehandle.cpp b/toonz/sources/toonzlib/tframehandle.cpp index a5a2be1..6b6738c 100644 --- a/toonz/sources/toonzlib/tframehandle.cpp +++ b/toonz/sources/toonzlib/tframehandle.cpp @@ -338,7 +338,7 @@ bool TFrameHandle::scrub(int r0, int r1, double framePerSecond) { m_audioColumn->scrub(r0, r1); else if (m_xsheet) { int i; - for (i = r0; i <= r1; i++) m_xsheet->scrub(i); + for (i = r0; i <= r1; i++) m_xsheet->scrub(i, true); } if (onlyOneFrame) return false; diff --git a/toonz/sources/toonzlib/txshcolumn.cpp b/toonz/sources/toonzlib/txshcolumn.cpp index f954736..8f29b2d 100644 --- a/toonz/sources/toonzlib/txshcolumn.cpp +++ b/toonz/sources/toonzlib/txshcolumn.cpp @@ -475,10 +475,12 @@ TXshColumn::ColumnType TXshColumn::toColumnType(int levelType) { } //----------------------------------------------------------------------------- - bool TXshColumn::isRendered() const { - if (!getXsheet() || !getFx()) return false; - if (!isPreviewVisible()) return false; +// if (!getXsheet() || !getFx()) return false; +// if (!isPreviewVisible()) return false; + if (!getXsheet() || !isPreviewVisible()) return false; + if (getColumnType() == eSoundType) return true; + if (!getFx()) return false; return getXsheet()->getFxDag()->isRendered(getFx()); } diff --git a/toonz/sources/toonzlib/txsheet.cpp b/toonz/sources/toonzlib/txsheet.cpp index 4462812..54ff5b2 100644 --- a/toonz/sources/toonzlib/txsheet.cpp +++ b/toonz/sources/toonzlib/txsheet.cpp @@ -1395,8 +1395,8 @@ void searchAudioColumn(TXsheet *xsh, std::vector &sounds, TXshColumn *column = xsh->getColumn(i); if (column) { TXshSoundColumn *soundCol = column->getSoundColumn(); - if (soundCol && ((isPreview && soundCol->isPreviewVisible()) || - (!isPreview && soundCol->isCamstandVisible()))) { + if (soundCol && ((isPreview && soundCol->isCamstandVisible()) || + (!isPreview && soundCol->isPreviewVisible()))) { sounds.push_back(soundCol); continue; }