diff --git a/toonz/sources/common/expressions/ttokenizer.cpp b/toonz/sources/common/expressions/ttokenizer.cpp index 1c39fe1..dc20cda 100644 --- a/toonz/sources/common/expressions/ttokenizer.cpp +++ b/toonz/sources/common/expressions/ttokenizer.cpp @@ -101,8 +101,7 @@ void Tokenizer::setBuffer(std::string buffer) { const std::string ss[] = {"==", "!=", ">=", "<=", "||", "&&"}; - const int m = tArrayCount(ss); - if (std::find(ss, ss + m, token) != ss + m) + if (std::find(std::begin(ss), std::end(ss), token) != std::end(ss)) i += 2; else token = std::string(1, s[i++]); diff --git a/toonz/sources/common/tparam/tspectrumparam.cpp b/toonz/sources/common/tparam/tspectrumparam.cpp index b3f0a82..e4de9d1 100644 --- a/toonz/sources/common/tparam/tspectrumparam.cpp +++ b/toonz/sources/common/tparam/tspectrumparam.cpp @@ -126,11 +126,11 @@ void TSpectrumParam::removeObserver(TParamObserver *obs) { //--------------------------------------------------------- -TSpectrumParam::TSpectrumParam(int keyCount, TSpectrum::ColorKey keys[]) +TSpectrumParam::TSpectrumParam(std::vector const &keys) : m_imp(new TSpectrumParamImp(this)) { - for (int i = 0; i < keyCount; i++) { - double v = keys[i].first; - TPixel32 pix = keys[i].second; + for (auto const & key : keys) { + double v = key.first; + TPixel32 pix = key.second; TDoubleParamP dp(v); TPixelParamP pp(pix); pp->enableMatte(m_imp->m_isMatteEnabled); diff --git a/toonz/sources/include/tcommon.h b/toonz/sources/include/tcommon.h index a5dec3d..162f3b8 100644 --- a/toonz/sources/include/tcommon.h +++ b/toonz/sources/include/tcommon.h @@ -174,8 +174,6 @@ inline std::ostream &operator<<(std::ostream &out, const std::string &s) { return out << s.c_str(); } -#define tArrayCount(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0])) - const std::string styleNameEasyInputWordsFileName = "stylename_easyinput.ini"; #endif //__T_COMMON_INCLUDED diff --git a/toonz/sources/include/toonzqt/functionsegmentviewer.h b/toonz/sources/include/toonzqt/functionsegmentviewer.h index 59afd79..64ea158 100644 --- a/toonz/sources/include/toonzqt/functionsegmentviewer.h +++ b/toonz/sources/include/toonzqt/functionsegmentviewer.h @@ -3,6 +3,7 @@ #ifndef FUNCTION_SEGMENT_VIEWER_H #define FUNCTION_SEGMENT_VIEWER_H +#include #include #include @@ -51,8 +52,8 @@ class FunctionSegmentViewer final : public QFrame, public TParamObserver { DVGui::LineEdit *m_stepFld; QStackedWidget *m_parametersPanel; - FunctionSegmentPage *m_pages[9]; - int m_typeId[9]; + std::array m_pages; + std::array m_typeId; FunctionSheet *m_sheet; TXsheetHandle *m_xshHandle; diff --git a/toonz/sources/include/tspectrumparam.h b/toonz/sources/include/tspectrumparam.h index 3cac6df..8eed363 100644 --- a/toonz/sources/include/tspectrumparam.h +++ b/toonz/sources/include/tspectrumparam.h @@ -42,7 +42,7 @@ class DVAPI TSpectrumParam final : public TParam { public: TSpectrumParam(); - TSpectrumParam(int keyCount, TSpectrum::ColorKey keys[]); + TSpectrumParam(std::vector const &keys); TSpectrumParam(const TSpectrumParam &); ~TSpectrumParam(); @@ -102,9 +102,9 @@ class DVAPI TSpectrumParamP final : public TDerivedSmartPointerT { public: TSpectrumParamP() {} - TSpectrumParamP(int keyCount, TSpectrum::ColorKey keys[]) + TSpectrumParamP(std::vector const &keys) : TDerivedSmartPointerT( - new TSpectrumParam(keyCount, keys)) {} + new TSpectrumParam(keys)) {} TSpectrumParamP(TSpectrumParam *p) : TDerivedSmartPointerT(p) {} TSpectrumParamP(const TParamP &p) diff --git a/toonz/sources/stdfx/cloudsfx.cpp b/toonz/sources/stdfx/cloudsfx.cpp index 3196622..3474d20 100644 --- a/toonz/sources/stdfx/cloudsfx.cpp +++ b/toonz/sources/stdfx/cloudsfx.cpp @@ -28,10 +28,10 @@ public: bindParam(this, "min", m_min); bindParam(this, "max", m_max); bindParam(this, "evolution", m_evol); - TSpectrum::ColorKey colors[] = { + std::vector colors = { TSpectrum::ColorKey(0, TPixel32::White), TSpectrum::ColorKey(1, TPixel32::Transparent)}; - m_colors = TSpectrumParamP(tArrayCount(colors), colors); + m_colors = TSpectrumParamP(colors); bindParam(this, "colors", m_colors); m_size->setValueRange(0, 200); m_min->setValueRange(0, 1.0); diff --git a/toonz/sources/stdfx/diamondgradientfx.cpp b/toonz/sources/stdfx/diamondgradientfx.cpp index 03d544c..72f4f71 100644 --- a/toonz/sources/stdfx/diamondgradientfx.cpp +++ b/toonz/sources/stdfx/diamondgradientfx.cpp @@ -13,13 +13,14 @@ class DiamondGradientFx final : public TStandardZeraryFx { public: DiamondGradientFx() : m_size(100.0) { - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(0.2, TPixel32::Yellow), - TSpectrum::ColorKey(0.4, TPixel32::Blue), - TSpectrum::ColorKey(0.6, TPixel32::Green), - TSpectrum::ColorKey(0.8, TPixel32::Magenta), - TSpectrum::ColorKey(1, TPixel32::Red)}; - m_colors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(0.2, TPixel32::Yellow), + TSpectrum::ColorKey(0.4, TPixel32::Blue), + TSpectrum::ColorKey(0.6, TPixel32::Green), + TSpectrum::ColorKey(0.8, TPixel32::Magenta), + TSpectrum::ColorKey(1, TPixel32::Red)}; + m_colors = TSpectrumParamP(colors); m_size->setMeasureName("fxLength"); bindParam(this, "colors", m_colors); bindParam(this, "size", m_size); diff --git a/toonz/sources/stdfx/iwa_particlesfx.cpp b/toonz/sources/stdfx/iwa_particlesfx.cpp index 0db33d9..c217ed0 100644 --- a/toonz/sources/stdfx/iwa_particlesfx.cpp +++ b/toonz/sources/stdfx/iwa_particlesfx.cpp @@ -250,18 +250,20 @@ Iwa_TiledParticlesFx::Iwa_TiledParticlesFx() animation_val->addItem(ANIM_SR_CYCLE, "Column Swing - Random Start"); bindParam(this, "step", step_val); step_val->setValueRange(1, (std::numeric_limits::max)()); - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::Red), - TSpectrum::ColorKey(1, TPixel32::Red)}; - gencol_val = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::Red), + TSpectrum::ColorKey(1, TPixel32::Red)}; + gencol_val = TSpectrumParamP(colors); bindParam(this, "birth_color", gencol_val); bindParam(this, "birth_color_ctrl", gencol_ctrl_val); bindParam(this, "birth_color_spread", gencol_spread_val); gencol_spread_val->setValueRange(0.0, (std::numeric_limits::max)()); bindParam(this, "birth_color_fade", genfadecol_val); genfadecol_val->setValueRange(0.0, 100.0); - TSpectrum::ColorKey colors1[] = {TSpectrum::ColorKey(0, TPixel32::Green), - TSpectrum::ColorKey(1, TPixel32::Green)}; - fincol_val = TSpectrumParamP(tArrayCount(colors1), colors1); + std::vector colors1 = { + TSpectrum::ColorKey(0, TPixel32::Green), + TSpectrum::ColorKey(1, TPixel32::Green)}; + fincol_val = TSpectrumParamP(colors1); bindParam(this, "fadein_color", fincol_val); bindParam(this, "fadein_color_ctrl", fincol_ctrl_val); bindParam(this, "fadein_color_spread", fincol_spread_val); @@ -270,9 +272,10 @@ Iwa_TiledParticlesFx::Iwa_TiledParticlesFx() finrangecol_val->setValueRange(0.0, (std::numeric_limits::max)()); bindParam(this, "fadein_color_fade", finfadecol_val); finfadecol_val->setValueRange(0.0, 100.0); - TSpectrum::ColorKey colors2[] = {TSpectrum::ColorKey(0, TPixel32::Blue), - TSpectrum::ColorKey(1, TPixel32::Blue)}; - foutcol_val = TSpectrumParamP(tArrayCount(colors2), colors2); + std::vector colors2 = { + TSpectrum::ColorKey(0, TPixel32::Blue), + TSpectrum::ColorKey(1, TPixel32::Blue)}; + foutcol_val = TSpectrumParamP(colors2); bindParam(this, "fadeout_color", foutcol_val); bindParam(this, "fadeout_color_ctrl", foutcol_ctrl_val); bindParam(this, "fadeout_color_spread", foutcol_spread_val); diff --git a/toonz/sources/stdfx/linearwavefx.cpp b/toonz/sources/stdfx/linearwavefx.cpp index 0fbba0c..2d801c1 100644 --- a/toonz/sources/stdfx/linearwavefx.cpp +++ b/toonz/sources/stdfx/linearwavefx.cpp @@ -195,11 +195,11 @@ public: TRasterP rasIn = tileIn.getRaster(); // Compute the warper tile - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(0.5, TPixel32::Black), - TSpectrum::ColorKey(1, TPixel32::White)}; - - TSpectrumParamP wavecolors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(0.5, TPixel32::Black), + TSpectrum::ColorKey(1, TPixel32::White)}; + TSpectrumParamP wavecolors = TSpectrumParamP(colors); // Build the multiradial warperInfo.m_affine = warperInfo.m_affine * TRotation(angle); diff --git a/toonz/sources/stdfx/multitonefx.cpp b/toonz/sources/stdfx/multitonefx.cpp index 89202f4..185ee14 100644 --- a/toonz/sources/stdfx/multitonefx.cpp +++ b/toonz/sources/stdfx/multitonefx.cpp @@ -12,10 +12,11 @@ class MultiToneFx final : public TStandardRasterFx { public: MultiToneFx() { - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(0.5, TPixel32::Yellow), - TSpectrum::ColorKey(1, TPixel32::Red)}; - m_colors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(0.5, TPixel32::Yellow), + TSpectrum::ColorKey(1, TPixel32::Red)}; + m_colors = TSpectrumParamP(colors); bool ret = m_colors->isKeyframe(0); bindParam(this, "colors", m_colors); diff --git a/toonz/sources/stdfx/particlesfx.cpp b/toonz/sources/stdfx/particlesfx.cpp index b12c692..a7ca4e6 100644 --- a/toonz/sources/stdfx/particlesfx.cpp +++ b/toonz/sources/stdfx/particlesfx.cpp @@ -228,18 +228,20 @@ ParticlesFx::ParticlesFx() animation_val->addItem(ANIM_SR_CYCLE, "Column Swing - Random Start"); bindParam(this, "step", step_val); step_val->setValueRange(1, (std::numeric_limits::max)()); - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::Red), - TSpectrum::ColorKey(1, TPixel32::Red)}; - gencol_val = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::Red), + TSpectrum::ColorKey(1, TPixel32::Red)}; + gencol_val = TSpectrumParamP(colors); bindParam(this, "birth_color", gencol_val); bindParam(this, "birth_color_ctrl", gencol_ctrl_val); bindParam(this, "birth_color_spread", gencol_spread_val); gencol_spread_val->setValueRange(0.0, (std::numeric_limits::max)()); bindParam(this, "birth_color_fade", genfadecol_val); genfadecol_val->setValueRange(0.0, 100.0); - TSpectrum::ColorKey colors1[] = {TSpectrum::ColorKey(0, TPixel32::Green), - TSpectrum::ColorKey(1, TPixel32::Green)}; - fincol_val = TSpectrumParamP(tArrayCount(colors1), colors1); + std::vector colors1 = { + TSpectrum::ColorKey(0, TPixel32::Green), + TSpectrum::ColorKey(1, TPixel32::Green)}; + fincol_val = TSpectrumParamP(colors1); bindParam(this, "fadein_color", fincol_val); bindParam(this, "fadein_color_ctrl", fincol_ctrl_val); bindParam(this, "fadein_color_spread", fincol_spread_val); @@ -248,9 +250,10 @@ ParticlesFx::ParticlesFx() finrangecol_val->setValueRange(0.0, (std::numeric_limits::max)()); bindParam(this, "fadein_color_fade", finfadecol_val); finfadecol_val->setValueRange(0.0, 100.0); - TSpectrum::ColorKey colors2[] = {TSpectrum::ColorKey(0, TPixel32::Blue), - TSpectrum::ColorKey(1, TPixel32::Blue)}; - foutcol_val = TSpectrumParamP(tArrayCount(colors2), colors2); + std::vector colors2 = { + TSpectrum::ColorKey(0, TPixel32::Blue), + TSpectrum::ColorKey(1, TPixel32::Blue)}; + foutcol_val = TSpectrumParamP(colors2); bindParam(this, "fadeout_color", foutcol_val); bindParam(this, "fadeout_color_ctrl", foutcol_ctrl_val); bindParam(this, "fadeout_color_spread", foutcol_spread_val); diff --git a/toonz/sources/stdfx/randomwavefx.cpp b/toonz/sources/stdfx/randomwavefx.cpp index 37e8c90..1f6fdef 100644 --- a/toonz/sources/stdfx/randomwavefx.cpp +++ b/toonz/sources/stdfx/randomwavefx.cpp @@ -191,10 +191,10 @@ public: TRasterP rasIn = tileIn.getRaster(); // Compute the warper tile - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(1, TPixel32::Black)}; - - TSpectrumParamP cloudscolors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(1, TPixel32::Black)}; + TSpectrumParamP cloudscolors = TSpectrumParamP(colors); // Build the warper warperInfo.m_affine = warperInfo.m_affine; diff --git a/toonz/sources/stdfx/ripplefx.cpp b/toonz/sources/stdfx/ripplefx.cpp index 126503d..843281b 100644 --- a/toonz/sources/stdfx/ripplefx.cpp +++ b/toonz/sources/stdfx/ripplefx.cpp @@ -197,11 +197,11 @@ public: TRasterP rasIn = tileIn.getRaster(); // Compute the warper tile - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(0.5, TPixel32::Black), - TSpectrum::ColorKey(1, TPixel32::White)}; - - TSpectrumParamP ripplecolors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(0.5, TPixel32::Black), + TSpectrum::ColorKey(1, TPixel32::White)}; + TSpectrumParamP ripplecolors = TSpectrumParamP(colors); // Build the multiradial warperInfo.m_affine = warperInfo.m_affine * TTranslation(center) * diff --git a/toonz/sources/stdfx/squaregradientfx.cpp b/toonz/sources/stdfx/squaregradientfx.cpp index be4bd48..e40f6f5 100644 --- a/toonz/sources/stdfx/squaregradientfx.cpp +++ b/toonz/sources/stdfx/squaregradientfx.cpp @@ -17,11 +17,11 @@ class SquareGradientFx final : public TStandardZeraryFx { public: SquareGradientFx() : m_size(200.0) { m_size->setMeasureName("fxLength"); - TSpectrum::ColorKey colors[] = { + std::vector colors = { TSpectrum::ColorKey(0, TPixel32::White), // TSpectrum::ColorKey(0.5,TPixel32::Yellow), TSpectrum::ColorKey(1, TPixel32::Red)}; - m_colors = TSpectrumParamP(tArrayCount(colors), colors); + m_colors = TSpectrumParamP(colors); bindParam(this, "colors", m_colors); bindParam(this, "size", m_size); m_size->setValueRange(0, std::numeric_limits::max()); diff --git a/toonz/sources/stdfx/stdfx.cpp b/toonz/sources/stdfx/stdfx.cpp index 343d676..5495e92 100644 --- a/toonz/sources/stdfx/stdfx.cpp +++ b/toonz/sources/stdfx/stdfx.cpp @@ -89,13 +89,13 @@ TPixel32 colors[] = { TPixel32::Yellow, transparent}; */ - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::Magenta), - TSpectrum::ColorKey(0.25, TPixel32::Black), - TSpectrum::ColorKey(0.5, TPixel32::Red), - TSpectrum::ColorKey(0.75, TPixel32::Yellow), - TSpectrum::ColorKey(1, transparent)}; - - m_spectrum = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::Magenta), + TSpectrum::ColorKey(0.25, TPixel32::Black), + TSpectrum::ColorKey(0.5, TPixel32::Red), + TSpectrum::ColorKey(0.75, TPixel32::Yellow), + TSpectrum::ColorKey(1, transparent)}; + m_spectrum = TSpectrumParamP(colors); bindParam(this, "colors", m_spectrum); bindParam(this, "freq", m_freq); @@ -184,11 +184,12 @@ public: , m_wave_phase(0.0) // args, "Cycle") // , m_colors (0) //args, "Colors") { - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(0.33, TPixel32::Yellow), - TSpectrum::ColorKey(0.66, TPixel32::Red), - TSpectrum::ColorKey(1, TPixel32::White)}; - m_colors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(0.33, TPixel32::Yellow), + TSpectrum::ColorKey(0.66, TPixel32::Red), + TSpectrum::ColorKey(1, TPixel32::White)}; + m_colors = TSpectrumParamP(colors); bindParam(this, "period", m_period); bindParam(this, "count", m_count); @@ -337,10 +338,10 @@ void LinearGradientFx::doCompute(TTile &tile, double frame, double w_phase = m_wave_phase->getValue(frame); w_freq *= 0.01 * M_PI_180; - TSpectrum::ColorKey colors[] = { + std::vector colors = { TSpectrum::ColorKey(0, m_color1->getValue(frame)), TSpectrum::ColorKey(1, m_color2->getValue(frame))}; - TSpectrumParamP m_colors = TSpectrumParamP(tArrayCount(colors), colors); + TSpectrumParamP m_colors = TSpectrumParamP(colors); TAffine aff = ri.m_affine.inv(); TPointD posTrasf = aff * tile.m_pos; @@ -465,12 +466,12 @@ public: // , m_colors (0) //args, "Colors") { m_period->setMeasureName("fxLength"); - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(0.33, TPixel32::Yellow), - TSpectrum::ColorKey(0.66, TPixel32::Red), - TSpectrum::ColorKey(1, TPixel32::White)}; - - m_colors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(0.33, TPixel32::Yellow), + TSpectrum::ColorKey(0.66, TPixel32::Red), + TSpectrum::ColorKey(1, TPixel32::White)}; + m_colors = TSpectrumParamP(colors); bindParam(this, "period", m_period); bindParam(this, "count", m_count); @@ -533,11 +534,11 @@ void RadialGradientFx::doCompute(TTile &tile, double frame, inner = innerperiod / period; else inner = 1 - TConsts::epsilon; - TSpectrum::ColorKey colors[] = { + std::vector colors = { TSpectrum::ColorKey(0, m_color1->getValue(frame)), TSpectrum::ColorKey(inner, m_color1->getValue(frame)), TSpectrum::ColorKey(1, m_color2->getValue(frame))}; - TSpectrumParamP m_colors = TSpectrumParamP(tArrayCount(colors), colors); + TSpectrumParamP m_colors = TSpectrumParamP(colors); TAffine aff = ri.m_affine.inv(); TPointD posTrasf = aff * tile.m_pos; multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff, diff --git a/toonz/sources/stdfx/test_boxfx.cpp b/toonz/sources/stdfx/test_boxfx.cpp index 2ef9607..2a40e09 100644 --- a/toonz/sources/stdfx/test_boxfx.cpp +++ b/toonz/sources/stdfx/test_boxfx.cpp @@ -43,10 +43,11 @@ public: bindParam(this, "int", m_int); bindParam(this, "range", m_range); bindParam(this, "bool", m_bool); - TSpectrum::ColorKey colors[] = {TSpectrum::ColorKey(0, TPixel32::White), - TSpectrum::ColorKey(0.5, TPixel32::Yellow), - TSpectrum::ColorKey(1, TPixel32::Red)}; - m_colors = TSpectrumParamP(tArrayCount(colors), colors); + std::vector colors = { + TSpectrum::ColorKey(0, TPixel32::White), + TSpectrum::ColorKey(0.5, TPixel32::Yellow), + TSpectrum::ColorKey(1, TPixel32::Red)}; + m_colors = TSpectrumParamP(colors); bindParam(this, "spectrum", m_colors); bindParam(this, "string", m_string); addInputPort("Source", m_input); diff --git a/toonz/sources/toonz/projectpopup.cpp b/toonz/sources/toonz/projectpopup.cpp index d861571..2df3429 100644 --- a/toonz/sources/toonz/projectpopup.cpp +++ b/toonz/sources/toonz/projectpopup.cpp @@ -321,19 +321,19 @@ ProjectPopup::ProjectPopup(bool isModal) Qt::AlignRight | Qt::AlignVCenter); upperLayout->addWidget(ff, i + 2, 1); } - struct { - QString name; - std::string folderName; - } cbs[] = {{tr("Append $scenepath to +drawings"), TProject::Drawings}, - {tr("Append $scenepath to +inputs"), TProject::Inputs}, - {tr("Append $scenepath to +extras"), TProject::Extras}}; + std::vector> cbs = { + std::make_tuple(tr("Append $scenepath to +drawings"), TProject::Drawings), + std::make_tuple(tr("Append $scenepath to +inputs"), TProject::Inputs), + std::make_tuple(tr("Append $scenepath to +extras"), TProject::Extras)}; int currentRow = upperLayout->rowCount(); - for (i = 0; i < tArrayCount(cbs); i++) { - CheckBox *cb = new CheckBox(cbs[i].name); + for (int i = 0; i < cbs.size(); ++i) { + auto const &name = std::get<0>(cbs[i]); + auto const &folderName = std::get<1>(cbs[i]); + CheckBox *cb = new CheckBox(name); cb->setMaximumHeight(WidgetHeight); upperLayout->addWidget(cb, currentRow + i, 1); - m_useScenePathCbs.append(qMakePair(cbs[i].folderName, cb)); + m_useScenePathCbs.append(qMakePair(folderName, cb)); } m_topLayout->addLayout(upperLayout); } diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp index 734a30f..12c9a90 100644 --- a/toonz/sources/toonz/sceneviewer.cpp +++ b/toonz/sources/toonz/sceneviewer.cpp @@ -511,7 +511,7 @@ SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent) this->setTabletTracking(true); #endif - for (int i = 0; i < tArrayCount(m_viewAff); i++) + for (int i = 0; i < m_viewAff.size(); ++i) setViewMatrix(getNormalZoomScale(), i); m_3DSideR = rasterFromQPixmap(svgToPixmap(":Resources/3Dside_r.svg")); @@ -2109,7 +2109,7 @@ void SceneViewer::resetSceneViewer() { m_visualSettings.m_sceneProperties = TApp::instance()->getCurrentScene()->getScene()->getProperties(); - for (int i = 0; i < tArrayCount(m_viewAff); i++) + for (int i = 0; i < m_viewAff.size(); ++i) setViewMatrix(getNormalZoomScale(), i); m_pos = QPoint(0, 0); @@ -2155,7 +2155,7 @@ void SceneViewer::setActualPixelSize() { TPointD tempScale = dpi; if (m_isFlippedX) tempScale.x = -tempScale.x; if (m_isFlippedY) tempScale.y = -tempScale.y; - for (int i = 0; i < tArrayCount(m_viewAff); i++) + for (int i = 0; i < m_viewAff.size(); ++i) setViewMatrix(dpi == TPointD(0, 0) ? tempAff : TScale(tempScale.x / inch, tempScale.y / inch), i); @@ -2260,8 +2260,8 @@ int SceneViewer::pick(const TPointD &point) { assert(glGetError() == GL_NO_ERROR); GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); - GLuint selectBuffer[512]; - glSelectBuffer(tArrayCount(selectBuffer), selectBuffer); + std::array selectBuffer; + glSelectBuffer(selectBuffer.size(), selectBuffer.data()); glRenderMode(GL_SELECT); // definisco la matrice di proiezione @@ -2320,7 +2320,7 @@ int SceneViewer::pick(const TPointD &point) { // conto gli hits int ret = -1; int hitCount = glRenderMode(GL_RENDER); - GLuint *p = selectBuffer; + GLuint *p = selectBuffer.data(); for (int i = 0; i < hitCount; ++i) { GLuint nameCount = *p++; GLuint zmin = *p++; diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h index d6139f1..39404dd 100644 --- a/toonz/sources/toonz/sceneviewer.h +++ b/toonz/sources/toonz/sceneviewer.h @@ -22,6 +22,7 @@ #include "pane.h" #include "previewer.h" +#include #include #include @@ -124,7 +125,7 @@ class SceneViewer final : public GLWidgetForHighDpi, // current pan/zoom matrix (two different matrices are used for editing scenes // and leves) - TAffine m_viewAff[2]; + std::array m_viewAff; int m_viewMode; TPointD m_dpiScale; diff --git a/toonz/sources/toonzlib/tproject.cpp b/toonz/sources/toonzlib/tproject.cpp index 4c270d4..aadb17b 100644 --- a/toonz/sources/toonzlib/tproject.cpp +++ b/toonz/sources/toonzlib/tproject.cpp @@ -885,8 +885,7 @@ void TProjectManager::getFolderNames(std::vector &names) { const std::string stdNames[] = {TProject::Inputs, TProject::Drawings, TProject::Scenes, TProject::Extras, TProject::Outputs, TProject::Scripts}; - for (int i = 0; i < (int)tArrayCount(stdNames); i++) { - string name = stdNames[i]; + for (auto const &name : stdNames) { // se il nome non e' gia' stato inserito lo aggiungo if (std::find(names.begin(), names.end(), name) == names.end()) names.push_back(name); diff --git a/toonz/sources/toonzlib/txsheetexpr.cpp b/toonz/sources/toonzlib/txsheetexpr.cpp index 66a0f27..2d76ce1 100644 --- a/toonz/sources/toonzlib/txsheetexpr.cpp +++ b/toonz/sources/toonzlib/txsheetexpr.cpp @@ -256,9 +256,8 @@ public: void getAcceptableKeywords( std::vector &keywords) const override { - const std::string ks[] = {"table", "tab", "col", "cam", - "camera", "peg", "pegbar"}; - for (int i = 0; i < tArrayCount(ks); i++) keywords.push_back(ks[i]); + keywords.insert(keywords.end(), + {"table", "tab", "col", "cam", "camera", "peg", "pegbar"}); } void createNode(Calculator *calc, std::vector &stack, diff --git a/toonz/sources/toonzqt/functionsegmentviewer.cpp b/toonz/sources/toonzqt/functionsegmentviewer.cpp index ba8d158..95e8ea4 100644 --- a/toonz/sources/toonzqt/functionsegmentviewer.cpp +++ b/toonz/sources/toonzqt/functionsegmentviewer.cpp @@ -929,8 +929,8 @@ FunctionSegmentViewer::FunctionSegmentViewer(QWidget *parent, m_parametersPanel = new QStackedWidget; m_parametersPanel->setObjectName("FunctionParametersPanel"); - for (int i = 0; i < tArrayCount(m_pages); i++) - m_parametersPanel->addWidget(m_pages[i]); + for (auto const & page : m_pages) + m_parametersPanel->addWidget(page); m_parametersPanel->setCurrentIndex(0); // buttons @@ -1149,7 +1149,7 @@ void FunctionSegmentViewer::refresh() { int pageIndex = typeToIndex(kf.m_type); m_typeCombo->setEnabled(true); m_typeCombo->setCurrentIndex(pageIndex); - if (0 <= pageIndex && pageIndex < tArrayCount(m_pages)) { + if (0 <= pageIndex && pageIndex < m_pages.size()) { m_parametersPanel->setCurrentIndex(pageIndex); m_pages[pageIndex]->refresh(); } @@ -1262,7 +1262,7 @@ Segmentが選ばれていない場合 void FunctionSegmentViewer::onCurveChanged() { int pageIndex = m_typeCombo->currentIndex(); - if (0 <= pageIndex && pageIndex < tArrayCount(m_pages)) + if (0 <= pageIndex && pageIndex < m_pages.size()) m_pages[pageIndex]->refresh(); update(); } @@ -1277,7 +1277,7 @@ void FunctionSegmentViewer::onStepFieldChanged(const QString &text) { } int FunctionSegmentViewer::typeToIndex(int typeId) const { - for (int i = 0; i < tArrayCount(m_typeId); i++) + for (int i = 0; i < m_typeId.size(); ++i) if (m_typeId[i] == typeId) return i; return -1; } @@ -1400,7 +1400,7 @@ void FunctionSegmentViewer::onApplyButtonPressed() { // for displaying the types of neighbor segments QString FunctionSegmentViewer::typeToString(int typeId) const { int i; - for (i = 0; i < tArrayCount(m_typeId); i++) + for (i = 0; i < m_typeId.size(); ++i) if (m_typeId[i] == typeId) break; switch (i) { diff --git a/toonz/sources/toonzqt/plugin_param_traits.h b/toonz/sources/toonzqt/plugin_param_traits.h index beb1387..e59ed45 100644 --- a/toonz/sources/toonzqt/plugin_param_traits.h +++ b/toonz/sources/toonzqt/plugin_param_traits.h @@ -420,7 +420,7 @@ inline TSpectrumParam *param_factory_(const toonz_param_desc_t *desc) { keys[i].second = toPixel32( TPixelD(t.array[i].c0, t.array[i].c1, t.array[i].c2, t.array[i].m)); } - return new TSpectrumParam(t.points, keys.data()); + return new TSpectrumParam(keys); } else { return new TSpectrumParam(); /* use default constructor: デフォルトでは [black:white] の単純なものが設定される */