diff --git a/app/src/onionskinwidget.cpp b/app/src/onionskinwidget.cpp index 8b7b8cac1c..154bfd7433 100644 --- a/app/src/onionskinwidget.cpp +++ b/app/src/onionskinwidget.cpp @@ -95,6 +95,7 @@ void OnionSkinWidget::makeConnections() connect(ui->onionSkinMode, &QCheckBox::stateChanged, this, &OnionSkinWidget::onionSkinModeChange); connect(ui->onionWhilePlayback, &QCheckBox::stateChanged, this, &OnionSkinWidget::playbackStateChanged); + connect(ui->onionSkinMultiLayer, &QCheckBox::stateChanged, this, &OnionSkinWidget::onionSkinMultipleLayersEnabled); PreferenceManager* prefs = editor()->preference(); connect(prefs, &PreferenceManager::optionChanged, this, &OnionSkinWidget::updateUI); @@ -123,8 +124,10 @@ void OnionSkinWidget::updateUI() ui->onionSkinMode->setChecked(prefs->getString(SETTING::ONION_TYPE) == "absolute"); QSignalBlocker b6(ui->onionWhilePlayback); - ui->onionWhilePlayback->setChecked(prefs->getInt(SETTING::ONION_WHILE_PLAYBACK)); + ui->onionWhilePlayback->setChecked(prefs->isOn(SETTING::ONION_WHILE_PLAYBACK)); + QSignalBlocker b7(ui->onionSkinMultiLayer); + ui->onionSkinMultiLayer->setChecked(prefs->isOn(SETTING::ONION_MUTLIPLE_LAYERS)); } void OnionSkinWidget::prevFramesGroupClicked(bool isOn) @@ -193,3 +196,9 @@ void OnionSkinWidget::playbackStateChanged(int value) PreferenceManager* prefs = editor()->preference(); prefs->set(SETTING::ONION_WHILE_PLAYBACK, value); } + +void OnionSkinWidget::onionSkinMultipleLayersEnabled(bool value) +{ + PreferenceManager* prefs = editor()->preference(); + prefs->set(SETTING::ONION_MUTLIPLE_LAYERS, value); +} diff --git a/app/src/onionskinwidget.h b/app/src/onionskinwidget.h index 711f249702..8d07ac53e8 100644 --- a/app/src/onionskinwidget.h +++ b/app/src/onionskinwidget.h @@ -50,6 +50,7 @@ private slots: void onionPrevFramesNumChange(int); void onionNextFramesNumChange(int); void onionSkinModeChange(int); + void onionSkinMultipleLayersEnabled(bool value); private: void makeConnections(); diff --git a/app/ui/onionskin.ui b/app/ui/onionskin.ui index 9694cfc12f..b895c1c6ca 100644 --- a/app/ui/onionskin.ui +++ b/app/ui/onionskin.ui @@ -444,6 +444,20 @@ 0 + + + + Show On All Layers + + + + + + + Qt::Horizontal + + + diff --git a/core_lib/src/canvaspainter.cpp b/core_lib/src/canvaspainter.cpp index 2920d5bce8..9b796f93e8 100644 --- a/core_lib/src/canvaspainter.cpp +++ b/core_lib/src/canvaspainter.cpp @@ -200,10 +200,8 @@ void CanvasPainter::paint(const QRect& blitRect) mPostLayersPixmapCacheValid = true; } -void CanvasPainter::paintOnionSkin(QPainter& painter, const QRect& blitRect) +void CanvasPainter::paintOnionSkinOnLayer(QPainter& painter, const QRect& blitRect, Layer* layer) { - Layer* layer = mObject->getLayer(mCurrentLayerIndex); - mOnionSkinSubPainter.paint(painter, layer, mOnionSkinPainterOptions, mFrameNumber, [&] (OnionSkinPaintState state, int onionFrameNumber) { if (state == OnionSkinPaintState::PREV) { switch (layer->type()) @@ -224,6 +222,21 @@ void CanvasPainter::paintOnionSkin(QPainter& painter, const QRect& blitRect) }); } +void CanvasPainter::paintOnionSkin(QPainter& painter, const QRect& blitRect) +{ + if (!mOptions.bOnionSkinMultiLayer || mOptions.eLayerVisibility == LayerVisibility::CURRENTONLY) { + Layer* layer = mObject->getLayer(mCurrentLayerIndex); + paintOnionSkinOnLayer(painter, blitRect, layer); + } else { + for (int i = 0; i < mObject->getLayerCount(); i++) { + Layer* layer = mObject->getLayer(i); + if (layer == nullptr) { continue; } + + paintOnionSkinOnLayer(painter, blitRect, layer); + } + } +} + void CanvasPainter::paintBitmapOnionSkinFrame(QPainter& painter, const QRect& blitRect, Layer* layer, int nFrame, bool colorize) { LayerBitmap* bitmapLayer = static_cast(layer); diff --git a/core_lib/src/canvaspainter.h b/core_lib/src/canvaspainter.h index 7f1d3c285a..e722f605c0 100644 --- a/core_lib/src/canvaspainter.h +++ b/core_lib/src/canvaspainter.h @@ -44,6 +44,7 @@ struct CanvasPainterOptions LayerVisibility eLayerVisibility = LayerVisibility::RELATED; float fLayerVisibilityThreshold = 0.f; + bool bOnionSkinMultiLayer = false; float scaling = 1.0f; QPainter::CompositionMode cmBufferBlendMode = QPainter::CompositionMode_SourceOver; OnionSkinPainterOptions mOnionSkinOptions; @@ -80,6 +81,7 @@ class CanvasPainter */ void initializePainter(QPainter& painter, QPaintDevice& device, const QRect& blitRect); + void paintOnionSkinOnLayer(QPainter& painter, const QRect& blitRect, Layer* layer); void paintOnionSkin(QPainter& painter, const QRect& blitRect); void renderPostLayers(QPainter& painter, const QRect& blitRect); diff --git a/core_lib/src/interface/scribblearea.cpp b/core_lib/src/interface/scribblearea.cpp index 26046470e9..6b9229040a 100644 --- a/core_lib/src/interface/scribblearea.cpp +++ b/core_lib/src/interface/scribblearea.cpp @@ -87,8 +87,6 @@ bool ScribbleArea::init() mMakeInvisible = false; - mMultiLayerOnionSkin = mPrefs->isOn(SETTING::MULTILAYER_ONION); - mLayerVisibility = static_cast(mPrefs->getInt(SETTING::LAYER_VISIBILITY)); mDeltaFactor = mEditor->preference()->isOn(SETTING::INVERT_SCROLL_ZOOM_DIRECTION) ? -1 : 1; @@ -148,8 +146,7 @@ void ScribbleArea::settingUpdated(SETTING setting) case SETTING::ONION_WHILE_PLAYBACK: invalidateAllCache(); break; - case SETTING::MULTILAYER_ONION: - mMultiLayerOnionSkin = mPrefs->isOn(SETTING::MULTILAYER_ONION); + case SETTING::ONION_MUTLIPLE_LAYERS: invalidateAllCache(); break; case SETTING::LAYER_VISIBILITY_THRESHOLD: @@ -1103,6 +1100,7 @@ void ScribbleArea::prepCanvas(int frame) Object* object = mEditor->object(); CanvasPainterOptions o; + o.bOnionSkinMultiLayer = mPrefs->isOn(SETTING::ONION_MUTLIPLE_LAYERS); o.bAntiAlias = mPrefs->isOn(SETTING::ANTIALIAS); o.bThinLines = mPrefs->isOn(SETTING::INVISIBLE_LINES); o.bOutlines = mPrefs->isOn(SETTING::OUTLINES); diff --git a/core_lib/src/interface/scribblearea.h b/core_lib/src/interface/scribblearea.h index 9cdac9b726..17f68bbe09 100644 --- a/core_lib/src/interface/scribblearea.h +++ b/core_lib/src/interface/scribblearea.h @@ -218,7 +218,6 @@ public slots: LayerVisibility mLayerVisibility = LayerVisibility::ALL; bool mMakeInvisible = false; qreal mCurveSmoothingLevel = 0.0; - bool mMultiLayerOnionSkin = false; // Future use. If required, just add a checkbox to update it. int mDeltaFactor = 1; /* Under certain circumstances a mouse press event will fire after a tablet release event. diff --git a/core_lib/src/managers/preferencemanager.cpp b/core_lib/src/managers/preferencemanager.cpp index b889f36868..f22b865f4d 100644 --- a/core_lib/src/managers/preferencemanager.cpp +++ b/core_lib/src/managers/preferencemanager.cpp @@ -119,7 +119,7 @@ void PreferenceManager::loadPrefs() // Onion Skin set(SETTING::PREV_ONION, settings.value(SETTING_PREV_ONION, false).toBool()); set(SETTING::NEXT_ONION, settings.value(SETTING_NEXT_ONION, false).toBool()); - set(SETTING::MULTILAYER_ONION, settings.value(SETTING_MULTILAYER_ONION, false).toBool()); + set(SETTING::ONION_MUTLIPLE_LAYERS, settings.value(SETTING_MULTILAYER_ONION, false).toBool()); set(SETTING::ONION_BLUE, settings.value(SETTING_ONION_BLUE, false).toBool()); set(SETTING::ONION_RED, settings.value(SETTING_ONION_RED, false).toBool()); @@ -403,7 +403,7 @@ void PreferenceManager::set(SETTING option, bool value) case SETTING::NEXT_ONION: settings.setValue(SETTING_NEXT_ONION, value); break; - case SETTING::MULTILAYER_ONION: + case SETTING::ONION_MUTLIPLE_LAYERS: settings.setValue(SETTING_MULTILAYER_ONION, value); break; case SETTING::INVISIBLE_LINES: diff --git a/core_lib/src/util/preferencesdef.h b/core_lib/src/util/preferencesdef.h index e8eb216057..9d9d4675cc 100644 --- a/core_lib/src/util/preferencesdef.h +++ b/core_lib/src/util/preferencesdef.h @@ -51,6 +51,7 @@ enum class SETTING ONION_PREV_FRAMES_NUM, ONION_NEXT_FRAMES_NUM, ONION_WHILE_PLAYBACK, + ONION_MUTLIPLE_LAYERS, ONION_TYPE, FLIP_ROLL_MSEC, FLIP_ROLL_DRAWINGS, @@ -78,7 +79,6 @@ enum class SETTING QUICK_SIZING, INVERT_DRAG_ZOOM_DIRECTION, INVERT_SCROLL_ZOOM_DIRECTION, - MULTILAYER_ONION, LANGUAGE, LAYOUT_LOCK, DRAW_ON_EMPTY_FRAME_ACTION,