diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index b489cd4..f3c5de6 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -324,6 +324,11 @@ public: return m_useNumpadForSwitchingStyles; } + void enableNewLevelSizeToCameraSize(bool on); + bool isNewLevelSizeToCameraSizeEnabled() const { + return m_newLevelSizeToCameraSizeEnabled; + } + void setVectorSnappingTarget(int target); int getVectorSnappingTarget() { return m_vectorSnappingTarget; } @@ -562,6 +567,10 @@ private: // whether to use numpad and tab key shortcut for selecting styles bool m_useNumpadForSwitchingStyles; + // whether to set the new level size to be the same as the camera size by + // default + bool m_newLevelSizeToCameraSizeEnabled; + // use arrow key to shift cel selection, ctrl + arrow key to resize the // selection range. bool m_useArrowKeyToShiftCellSelection; diff --git a/toonz/sources/toonz/levelcreatepopup.cpp b/toonz/sources/toonz/levelcreatepopup.cpp index ccfee44..7391097 100644 --- a/toonz/sources/toonz/levelcreatepopup.cpp +++ b/toonz/sources/toonz/levelcreatepopup.cpp @@ -598,10 +598,19 @@ bool LevelCreatePopup::apply() { void LevelCreatePopup::update() { updatePath(); Preferences *pref = Preferences::instance(); + if (pref->isNewLevelSizeToCameraSizeEnabled()) { + TCamera *currCamera = + TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera(); + TDimensionD camSize = currCamera->getSize(); + m_widthFld->setValue(camSize.lx); + m_heightFld->setValue(camSize.ly); + m_dpiFld->setValue(currCamera->getDpi().x); + } else { + m_widthFld->setValue(pref->getDefLevelWidth()); + m_heightFld->setValue(pref->getDefLevelHeight()); + m_dpiFld->setValue(pref->getDefLevelDpi()); + } - m_widthFld->setValue(pref->getDefLevelWidth()); - m_heightFld->setValue(pref->getDefLevelHeight()); - m_dpiFld->setValue(pref->getDefLevelDpi()); int levelType = pref->getDefLevelType(); int index = -1; switch (levelType) { diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index b3de6d1..0100623 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -832,7 +832,8 @@ void PreferencesPopup::onDefLevelTypeChanged(int index) { if (0 <= index && index < m_defLevelType->count()) { int levelType = m_defLevelType->itemData(index).toInt(); m_pref->setDefLevelType(levelType); - bool isRaster = levelType != PLI_XSHLEVEL; + bool isRaster = + levelType != PLI_XSHLEVEL && !m_newLevelToCameraSizeCB->isChecked(); m_defLevelWidth->setEnabled(isRaster); m_defLevelHeight->setEnabled(isRaster); if (!m_pixelsOnlyCB->isChecked()) m_defLevelDpi->setEnabled(isRaster); @@ -1004,6 +1005,13 @@ void PreferencesPopup::onUseNumpadForSwitchingStylesClicked(bool checked) { //----------------------------------------------------------------------------- +void PreferencesPopup::onNewLevelToCameraSizeChanged(bool checked) { + m_pref->enableNewLevelSizeToCameraSize(checked); + onDefLevelTypeChanged(m_defLevelType->currentIndex()); +} + +//----------------------------------------------------------------------------- + void PreferencesPopup::onShowXSheetToolbarClicked(bool checked) { m_pref->enableShowXSheetToolbar(checked); TApp::instance()->getCurrentScene()->notifyPreferenceChanged("XSheetToolbar"); @@ -1211,6 +1219,9 @@ PreferencesPopup::PreferencesPopup() m_autocreationType = new QComboBox(this); m_dpiLabel = new QLabel(tr("DPI:"), this); m_vectorSnappingTargetCB = new QComboBox(this); + m_newLevelToCameraSizeCB = + new CheckBox(tr("New Levels Default to the Current Camera Size"), this); + CheckBox *keepOriginalCleanedUpCB = new CheckBox(tr("Keep Original Cleaned Up Drawings As Backup"), this); CheckBox *multiLayerStylePickerCB = new CheckBox( @@ -1457,7 +1468,8 @@ PreferencesPopup::PreferencesPopup() useSaveboxToLimitFillingOpCB->setChecked(m_pref->getFillOnlySavebox()); m_useNumpadForSwitchingStyles->setChecked( m_pref->isUseNumpadForSwitchingStylesEnabled()); - + m_newLevelToCameraSizeCB->setChecked( + m_pref->isNewLevelSizeToCameraSizeEnabled()); QStringList scanLevelTypes; scanLevelTypes << "tif" << "png"; @@ -1921,21 +1933,21 @@ PreferencesPopup::PreferencesPopup() drawingTopLay->addWidget(new QLabel(tr("Default Level Type:")), 1, 0, Qt::AlignRight); drawingTopLay->addWidget(m_defLevelType, 1, 1, 1, 3); - - drawingTopLay->addWidget(new QLabel(tr("Width:")), 2, 0, + drawingTopLay->addWidget(m_newLevelToCameraSizeCB, 2, 0, 1, 3); + drawingTopLay->addWidget(new QLabel(tr("Width:")), 3, 0, Qt::AlignRight); - drawingTopLay->addWidget(m_defLevelWidth, 2, 1); - drawingTopLay->addWidget(new QLabel(tr(" Height:")), 2, 2, + drawingTopLay->addWidget(m_defLevelWidth, 3, 1); + drawingTopLay->addWidget(new QLabel(tr(" Height:")), 3, 2, Qt::AlignRight); - drawingTopLay->addWidget(m_defLevelHeight, 2, 3); - drawingTopLay->addWidget(m_dpiLabel, 3, 0, Qt::AlignRight); - drawingTopLay->addWidget(m_defLevelDpi, 3, 1); - drawingTopLay->addWidget(new QLabel(tr("Autocreation:")), 4, 0, + drawingTopLay->addWidget(m_defLevelHeight, 3, 3); + drawingTopLay->addWidget(m_dpiLabel, 4, 0, Qt::AlignRight); + drawingTopLay->addWidget(m_defLevelDpi, 4, 1); + drawingTopLay->addWidget(new QLabel(tr("Autocreation:")), 5, 0, Qt::AlignRight); - drawingTopLay->addWidget(m_autocreationType, 4, 1, 1, 3); - drawingTopLay->addWidget(new QLabel(tr("Vector Snapping:")), 5, 0, + drawingTopLay->addWidget(m_autocreationType, 5, 1, 1, 3); + drawingTopLay->addWidget(new QLabel(tr("Vector Snapping:")), 6, 0, Qt::AlignRight); - drawingTopLay->addWidget(m_vectorSnappingTargetCB, 5, 1, 1, 3); + drawingTopLay->addWidget(m_vectorSnappingTargetCB, 6, 1, 1, 3); } drawingFrameLay->addLayout(drawingTopLay, 0); @@ -2325,6 +2337,8 @@ PreferencesPopup::PreferencesPopup() SLOT(onDefLevelParameterChanged())); ret = ret && connect(m_useNumpadForSwitchingStyles, SIGNAL(clicked(bool)), SLOT(onUseNumpadForSwitchingStylesClicked(bool))); + ret = ret && connect(m_newLevelToCameraSizeCB, SIGNAL(clicked(bool)), + SLOT(onNewLevelToCameraSizeChanged(bool))); //--- Xsheet ---------------------- ret = ret && connect(xsheetAutopanDuringPlaybackCB, SIGNAL(stateChanged(int)), diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h index 9996df5..b607b68 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -74,7 +74,7 @@ private: *m_projectRootDesktop, *m_projectRootCustom, *m_projectRootStuff, *m_onionSkinDuringPlayback, *m_autoSaveSceneCB, *m_autoSaveOtherFilesCB, *m_useNumpadForSwitchingStyles, *m_expandFunctionHeader, - *m_ignoreImageDpiCB; + *m_newLevelToCameraSizeCB, *m_ignoreImageDpiCB; DVGui::FileField *m_customProjectRootFileField; @@ -147,6 +147,7 @@ private slots: void onRegionAntialiasChanged(int); void onImportPolicyChanged(int); void onImportPolicyExternallyChanged(int policy); + void onNewLevelToCameraSizeChanged(bool checked); void onVectorSnappingTargetChanged(int index); #ifdef LINETEST diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index 8bae1a6..c24fbdc 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -309,6 +309,7 @@ Preferences::Preferences() , m_ffmpegTimeout(60) , m_shortcutPreset("defopentoonz") , m_useNumpadForSwitchingStyles(true) + , m_newLevelSizeToCameraSizeEnabled(false) , m_showXSheetToolbar(false) , m_expandFunctionHeader(false) , m_showColumnNumbers(false) @@ -594,6 +595,8 @@ Preferences::Preferences() setShortcutPreset(m_shortcutPreset.toStdString()); getValue(*m_settings, "useNumpadForSwitchingStyles", m_useNumpadForSwitchingStyles); + getValue(*m_settings, "newLevelSizeToCameraSizeEnabled", + m_newLevelSizeToCameraSizeEnabled); getValue(*m_settings, "showXSheetToolbar", m_showXSheetToolbar); getValue(*m_settings, "expandFunctionHeader", m_expandFunctionHeader); getValue(*m_settings, "showColumnNumbers", m_showColumnNumbers); @@ -1424,6 +1427,13 @@ void Preferences::enableUseNumpadForSwitchingStyles(bool on) { //----------------------------------------------------------------- +void Preferences::enableNewLevelSizeToCameraSize(bool on) { + m_newLevelSizeToCameraSizeEnabled = on; + m_settings->setValue("newLevelSizeToCameraSizeEnabled", on ? "1" : "0"); +} + +//----------------------------------------------------------------- + void Preferences::enableShowXSheetToolbar(bool on) { m_showXSheetToolbar = on; m_settings->setValue("showXSheetToolbar", on ? "1" : "0"); diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cpp index 87d09e6..cc63006 100644 --- a/toonz/sources/toonzlib/toonzscene.cpp +++ b/toonz/sources/toonzlib/toonzscene.cpp @@ -903,18 +903,31 @@ TXshLevel *ToonzScene::createNewLevel(int type, std::wstring levelName, } if (type == TZP_XSHLEVEL || type == OVL_XSHLEVEL) { + double dpiY = dpi; sl->getProperties()->setDpiPolicy(LevelProperties::DP_ImageDpi); if (dim == TDimension()) { + double w, h; Preferences *pref = Preferences::instance(); - double w = pref->getDefLevelWidth(); - double h = pref->getDefLevelHeight(); - dpi = pref->getDefLevelDpi(); + if (pref->isNewLevelSizeToCameraSizeEnabled()) { + TDimensionD camSize = getCurrentCamera()->getSize(); + w = camSize.lx; + h = camSize.ly; + sl->getProperties()->setDpiPolicy(LevelProperties::DP_CustomDpi); + dpi = getCurrentCamera()->getDpi().x; + dpiY = getCurrentCamera()->getDpi().y; + } else { + w = pref->getDefLevelWidth(); + h = pref->getDefLevelHeight(); + dpi = pref->getDefLevelDpi(); + dpiY = dpi; + } + sl->getProperties()->setImageRes( - TDimension(tround(w * dpi), tround(h * dpi))); + TDimension(tround(w * dpi), tround(h * dpiY))); } else sl->getProperties()->setImageRes(dim); - sl->getProperties()->setImageDpi(TPointD(dpi, dpi)); + sl->getProperties()->setImageDpi(TPointD(dpi, dpiY)); sl->getProperties()->setDpi(dpi); }