diff --git a/toonz/sources/include/orientation.h b/toonz/sources/include/orientation.h index 77fcf7ce..5d231ffd 100644 --- a/toonz/sources/include/orientation.h +++ b/toonz/sources/include/orientation.h @@ -137,7 +137,13 @@ enum class PredefinedRect { // ADD_LEVEL_AREA, // ADD_LEVEL, FOOTER_NOTE_OBJ_AREA, - FOOTER_NOTE_AREA + FOOTER_NOTE_AREA, + AUTO_CREATE_AREA, + AUTO_CREATE, + CREATE_IN_HOLD_AREA, + CREATE_IN_HOLD, + AUTO_STRETCH_AREA, + AUTO_STRETCH }; enum class PredefinedLine { LOCKED, //! dotted vertical line when cell is locked diff --git a/toonz/sources/toonz/icons/dark/actions/16/auto_create.svg b/toonz/sources/toonz/icons/dark/actions/16/auto_create.svg new file mode 100644 index 00000000..1a42769b --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/auto_create.svg @@ -0,0 +1,88 @@ + +image/svg+xml + + + + + + + + \ No newline at end of file diff --git a/toonz/sources/toonz/icons/dark/actions/16/auto_create_on.svg b/toonz/sources/toonz/icons/dark/actions/16/auto_create_on.svg new file mode 100644 index 00000000..5aa2ae7d --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/auto_create_on.svg @@ -0,0 +1,86 @@ + +image/svg+xml + + + + + + + + \ No newline at end of file diff --git a/toonz/sources/toonz/icons/dark/actions/16/auto_stretch.svg b/toonz/sources/toonz/icons/dark/actions/16/auto_stretch.svg new file mode 100644 index 00000000..cd667203 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/auto_stretch.svg @@ -0,0 +1,88 @@ + +image/svg+xml + + + + + + + + \ No newline at end of file diff --git a/toonz/sources/toonz/icons/dark/actions/16/auto_stretch_on.svg b/toonz/sources/toonz/icons/dark/actions/16/auto_stretch_on.svg new file mode 100644 index 00000000..765e25ca --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/auto_stretch_on.svg @@ -0,0 +1,84 @@ + +image/svg+xml + + \ No newline at end of file diff --git a/toonz/sources/toonz/icons/dark/actions/16/create_in_hold.svg b/toonz/sources/toonz/icons/dark/actions/16/create_in_hold.svg new file mode 100644 index 00000000..927e2b5c --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/create_in_hold.svg @@ -0,0 +1,76 @@ + +image/svg+xml + + + + + + + + \ No newline at end of file diff --git a/toonz/sources/toonz/icons/dark/actions/16/create_in_hold_on.svg b/toonz/sources/toonz/icons/dark/actions/16/create_in_hold_on.svg new file mode 100644 index 00000000..f326aeaa --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/create_in_hold_on.svg @@ -0,0 +1,88 @@ + +image/svg+xml + + + + + + + + \ No newline at end of file diff --git a/toonz/sources/toonz/layerfooterpanel.cpp b/toonz/sources/toonz/layerfooterpanel.cpp index 8b2dccab..e1f85ae6 100644 --- a/toonz/sources/toonz/layerfooterpanel.cpp +++ b/toonz/sources/toonz/layerfooterpanel.cpp @@ -16,6 +16,8 @@ #include "toonzqt/gutil.h" +#include + using XsheetGUI::ColumnArea; LayerFooterPanel::LayerFooterPanel(XsheetViewer *viewer, QWidget *parent, @@ -37,8 +39,54 @@ LayerFooterPanel::LayerFooterPanel(XsheetViewer *viewer, QWidget *parent, m_frameZoomSlider->setValue(m_viewer->getFrameZoomFactor()); m_frameZoomSlider->setToolTip(tr("Zoom in/out of timeline")); + m_autoCreateButton = new QToolButton(this); + m_createInHoldButton = new QToolButton(this); + m_autoStretchButton = new QToolButton(this); + + m_autoCreateButton->setObjectName("ToolbarToolButton"); + m_autoCreateButton->setFixedSize(o->rect(PredefinedRect::AUTO_CREATE).size()); + m_autoCreateButton->setIconSize(QSize(15, 15)); + m_autoCreateButton->setIcon(createQIcon("auto_create")); + m_autoCreateButton->setToolTip( + tr("Toggles the auto-creation of frames when drawing in blank cells on " + "the timeline/xsheet.")); + m_autoCreateButton->setCheckable(true); + + m_createInHoldButton->setObjectName("ToolbarToolButton"); + m_createInHoldButton->setFixedSize( + o->rect(PredefinedRect::CREATE_IN_HOLD).size()); + m_createInHoldButton->setIconSize(QSize(15, 15)); + m_createInHoldButton->setIcon(createQIcon("create_in_hold")); + m_createInHoldButton->setToolTip( + tr("Toggles the auto-creation of frames when drawing in held cells on " + "the timeline/xsheet.")); + m_createInHoldButton->setCheckable(true); + + m_autoStretchButton->setObjectName("ToolbarToolButton"); + m_autoStretchButton->setFixedSize( + o->rect(PredefinedRect::AUTO_STRETCH).size()); + m_autoStretchButton->setIconSize(QSize(15, 15)); + m_autoStretchButton->setIcon(createQIcon("auto_stretch")); + m_autoStretchButton->setToolTip( + tr("Toggles the auto-stretch of a frame to the next frame.")); + m_autoStretchButton->setCheckable(true); + connect(m_frameZoomSlider, SIGNAL(valueChanged(int)), this, SLOT(onFrameZoomSliderValueChanged(int))); + + connect(m_autoCreateButton, &QToolButton::clicked, [=]() { + CommandManager::instance()->getAction("MI_ToggleAutoCreate")->trigger(); + }); + + connect(m_createInHoldButton, &QToolButton::clicked, [=]() { + CommandManager::instance() + ->getAction("MI_ToggleCreationInHoldCells") + ->trigger(); + }); + + connect(m_autoStretchButton, &QToolButton::clicked, [=]() { + CommandManager::instance()->getAction("MI_ToggleAutoStretch")->trigger(); + }); } LayerFooterPanel::~LayerFooterPanel() {} @@ -100,6 +148,22 @@ void LayerFooterPanel::paintEvent(QPaintEvent *event) { // svgToPixmap(":Resources/new_level_rollover.svg"); // const QRect addLevelImgRect = o->rect(PredefinedRect::ADD_LEVEL); + m_autoCreateButton->setGeometry(o->rect(PredefinedRect::AUTO_CREATE)); + m_autoCreateButton->setChecked(CommandManager::instance() + ->getAction("MI_ToggleAutoCreate") + ->isChecked()); + + m_createInHoldButton->setGeometry(o->rect(PredefinedRect::CREATE_IN_HOLD)); + m_createInHoldButton->setChecked( + CommandManager::instance() + ->getAction("MI_ToggleCreationInHoldCells") + ->isChecked()); + + m_autoStretchButton->setGeometry(o->rect(PredefinedRect::AUTO_STRETCH)); + m_autoStretchButton->setChecked(CommandManager::instance() + ->getAction("MI_ToggleAutoStretch") + ->isChecked()); + p.setRenderHint(QPainter::SmoothPixmapTransform, true); if (m_zoomInHighlighted) p.drawPixmap(zoomInImgRect, zoomInRollover); @@ -120,6 +184,8 @@ void LayerFooterPanel::paintEvent(QPaintEvent *event) { QLine line = {leftSide(shorter(zoomOutImgRect)).translated(-4, 0)}; p.drawLine(line); + QLine line2 = {leftSide(shorter(noteObjRect)).translated(-4, 0)}; + p.drawLine(line2); } void LayerFooterPanel::showOrHide(const Orientation *o) { diff --git a/toonz/sources/toonz/layerfooterpanel.h b/toonz/sources/toonz/layerfooterpanel.h index 90fb75b7..2b6b6bc9 100644 --- a/toonz/sources/toonz/layerfooterpanel.h +++ b/toonz/sources/toonz/layerfooterpanel.h @@ -28,6 +28,7 @@ class LayerFooterPanel final : public QWidget { bool m_zoomInHighlighted = false; bool m_zoomOutHighlighted = false; // bool m_addLevelHighlighted = false; + QToolButton *m_autoCreateButton, *m_createInHoldButton, *m_autoStretchButton; private: XsheetViewer *m_viewer; diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index 8e2bd73a..10d9d3b5 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -2460,6 +2460,21 @@ void MainWindow::defineActions() { QT_TR_NOOP("&Save As Default Palette"), "", "", tr("Save the current style palette as the default " "for new levels of the current level type.")); + createToggle(MI_ToggleAutoCreate, QT_TR_NOOP("Toggle Auto-Creation"), "", + Preferences::instance()->isAutoCreateEnabled(), + MiscCommandType, "auto_create", + tr("Toggles the auto-creation of frames when drawing in blank " + "cells on the timeline/xsheet.")); + createToggle(MI_ToggleCreationInHoldCells, + QT_TR_NOOP("Toggle Creation In Hold Cells"), "", + Preferences::instance()->isCreationInHoldCellsEnabled(), + MiscCommandType, "create_in_hold", + tr("Toggles the auto-creation of frames when drawing in held " + "cells on the timeline/xsheet.")); + createToggle(MI_ToggleAutoStretch, QT_TR_NOOP("Toggle Auto-Stretch"), "", + Preferences::instance()->isAutoStretchEnabled(), + MiscCommandType, "auto_stretch", + tr("Toggles the auto-stretch of a frame to the next frame")); // Tools diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h index 585d38bd..fe03e847 100644 --- a/toonz/sources/toonz/menubarcommandids.h +++ b/toonz/sources/toonz/menubarcommandids.h @@ -467,4 +467,9 @@ #define MI_FlipPrevGuideStroke "MI_FlipPrevGuideStroke" #define MI_ExportXDTS "MI_ExportXDTS" + +#define MI_ToggleAutoCreate "MI_ToggleAutoCreate" +#define MI_ToggleCreationInHoldCells "MI_ToggleCreationInHoldCells" +#define MI_ToggleAutoStretch "MI_ToggleAutoStretch" + #endif diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrc index 67990757..2aece31d 100644 --- a/toonz/sources/toonz/toonz.qrc +++ b/toonz/sources/toonz/toonz.qrc @@ -312,6 +312,12 @@ icons/dark/actions/16/save_all_levels.svg icons/dark/actions/16/replace_level.svg icons/dark/actions/16/export_level.svg + icons/dark/actions/16/auto_create.svg + icons/dark/actions/16/auto_create_on.svg + icons/dark/actions/16/auto_stretch.svg + icons/dark/actions/16/auto_stretch_on.svg + icons/dark/actions/16/create_in_hold.svg + icons/dark/actions/16/create_in_hold_on.svg icons/dark/actions/16/on_1s.svg icons/dark/actions/16/on_2s.svg diff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cpp index 07826aa4..00cc38e8 100644 --- a/toonz/sources/toonz/xsheetcmd.cpp +++ b/toonz/sources/toonz/xsheetcmd.cpp @@ -235,6 +235,58 @@ public: } } insertSceneFrameCommand; +//============================================================================= + +class ToggleAutoCreateCommand final : public MenuItemHandler { +public: + ToggleAutoCreateCommand() : MenuItemHandler(MI_ToggleAutoCreate) {} + void execute() override { + bool currentAutoCreateEnabled = + Preferences::instance()->isAutoCreateEnabled(); + if (CommandManager::instance() + ->getAction(MI_ToggleAutoCreate) + ->isChecked() == currentAutoCreateEnabled) + return; + Preferences::instance()->setValue(EnableAutocreation, + !currentAutoCreateEnabled); + } +} ToggleAutoCreateCommand; + +//============================================================================= + +class ToggleCreationInHoldCellsCommand final : public MenuItemHandler { +public: + ToggleCreationInHoldCellsCommand() + : MenuItemHandler(MI_ToggleCreationInHoldCells) {} + void execute() override { + bool currentCreationInHoldCells = + Preferences::instance()->isCreationInHoldCellsEnabled(); + if (CommandManager::instance() + ->getAction(MI_ToggleCreationInHoldCells) + ->isChecked() == currentCreationInHoldCells) + return; + Preferences::instance()->setValue(EnableCreationInHoldCells, + !currentCreationInHoldCells); + } +} ToggleCreationInHoldCellsCommand; + +//============================================================================= + +class ToggleAutoStretchCommand final : public MenuItemHandler { +public: + ToggleAutoStretchCommand() : MenuItemHandler(MI_ToggleAutoStretch) {} + void execute() override { + bool currentAutoStretchEnabled = + Preferences::instance()->isAutoStretchEnabled(); + if (CommandManager::instance() + ->getAction(MI_ToggleAutoStretch) + ->isChecked() == currentAutoStretchEnabled) + return; + Preferences::instance()->setValue(EnableAutoStretch, + !currentAutoStretchEnabled); + } +} ToggleAutoStretchCommand; + //***************************************************************************** // RemoveSceneFrame command //***************************************************************************** diff --git a/toonz/sources/toonz/xshnoteviewer.cpp b/toonz/sources/toonz/xshnoteviewer.cpp index 5ad12f3e..c3493e81 100644 --- a/toonz/sources/toonz/xshnoteviewer.cpp +++ b/toonz/sources/toonz/xshnoteviewer.cpp @@ -459,8 +459,12 @@ NoteArea::NoteArea(XsheetViewer *parent, Qt::WFlags flags) , m_noteButton(nullptr) , m_precNoteButton(nullptr) , m_nextNoteButton(nullptr) + , m_autoCreateButton(nullptr) + , m_createInHoldButton(nullptr) + , m_autoStretchButton(nullptr) , m_frameDisplayStyleCombo(nullptr) , m_layerHeaderPanel(nullptr) { + const Orientation *o = m_viewer->orientation(); setFrameStyle(QFrame::StyledPanel); setObjectName("cornerWidget"); @@ -470,6 +474,9 @@ NoteArea::NoteArea(XsheetViewer *parent, Qt::WFlags flags) m_precNoteButton = new QToolButton(this); m_nextNoteButton = new QToolButton(this); m_newLevelButton = new QToolButton(this); + m_autoCreateButton = new QToolButton(this); + m_createInHoldButton = new QToolButton(this); + m_autoStretchButton = new QToolButton(this); m_frameDisplayStyleCombo = new QComboBox(this); m_layerHeaderPanel = new LayerHeaderPanel(m_viewer, this); @@ -511,6 +518,34 @@ NoteArea::NoteArea(XsheetViewer *parent, Qt::WFlags flags) m_nextNoteButton->setIcon(createQIcon("nextkey")); m_nextNoteButton->setToolTip(tr("Next Memo")); + m_autoCreateButton->setObjectName("ToolbarToolButton"); + m_autoCreateButton->setFixedSize(o->rect(PredefinedRect::AUTO_CREATE).size()); + m_autoCreateButton->setIconSize(QSize(16, 16)); + m_autoCreateButton->setIcon(createQIcon("auto_create")); + m_autoCreateButton->setToolTip( + tr("Toggles the auto-creation of frames when drawing in blank cells on " + "the timeline/xsheet.")); + m_autoCreateButton->setCheckable(true); + + m_createInHoldButton->setObjectName("ToolbarToolButton"); + m_createInHoldButton->setFixedSize( + o->rect(PredefinedRect::CREATE_IN_HOLD).size()); + m_createInHoldButton->setIconSize(QSize(16, 16)); + m_createInHoldButton->setIcon(createQIcon("create_in_hold")); + m_createInHoldButton->setToolTip( + tr("Toggles the auto-creation of frames when drawing in held cells on " + "the timeline/xsheet.")); + m_createInHoldButton->setCheckable(true); + + m_autoStretchButton->setObjectName("ToolbarToolButton"); + m_autoStretchButton->setFixedSize( + o->rect(PredefinedRect::AUTO_STRETCH).size()); + m_autoStretchButton->setIconSize(QSize(16, 16)); + m_autoStretchButton->setIcon(createQIcon("auto_stretch")); + m_autoStretchButton->setToolTip( + tr("Toggles the auto-stretch of a frame to the next frame.")); + m_autoStretchButton->setCheckable(true); + QStringList frameDisplayStyles; frameDisplayStyles << tr("Frame") << tr("Sec Frame") << tr("6sec Sheet") << tr("3sec Sheet"); @@ -536,6 +571,21 @@ NoteArea::NoteArea(XsheetViewer *parent, Qt::WFlags flags) CommandManager::instance()->execute("MI_NewLevel"); }); + ret = + ret && connect(m_autoCreateButton, &QToolButton::clicked, [=]() { + CommandManager::instance()->getAction("MI_ToggleAutoCreate")->trigger(); + }); + ret = ret && connect(m_createInHoldButton, &QToolButton::clicked, [=]() { + CommandManager::instance() + ->getAction("MI_ToggleCreationInHoldCells") + ->trigger(); + }); + ret = ret && connect(m_autoStretchButton, &QToolButton::clicked, [=]() { + CommandManager::instance() + ->getAction("MI_ToggleAutoStretch") + ->trigger(); + }); + ret = ret && connect(m_frameDisplayStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onFrameDisplayStyleChanged(int))); @@ -559,6 +609,9 @@ void NoteArea::removeLayout() { currentLayout->removeWidget(m_precNoteButton); currentLayout->removeWidget(m_nextNoteButton); currentLayout->removeWidget(m_newLevelButton); + currentLayout->removeWidget(m_autoCreateButton); + currentLayout->removeWidget(m_createInHoldButton); + currentLayout->removeWidget(m_autoStretchButton); currentLayout->removeWidget(m_frameDisplayStyleCombo); currentLayout->removeWidget(m_layerHeaderPanel); delete currentLayout; @@ -588,6 +641,16 @@ void NoteArea::createLayout() { mainLayout->addStretch(1); + QHBoxLayout *AutoCreatebuttonsLayout = new QHBoxLayout(); + AutoCreatebuttonsLayout->setMargin(0); + AutoCreatebuttonsLayout->setSpacing(0); + { + AutoCreatebuttonsLayout->addWidget(m_autoCreateButton, 0); + AutoCreatebuttonsLayout->addWidget(m_createInHoldButton, 0); + AutoCreatebuttonsLayout->addWidget(m_autoStretchButton, 0); + } + mainLayout->addLayout(AutoCreatebuttonsLayout, 0); + QHBoxLayout *buttonsLayout = new QHBoxLayout(); buttonsLayout->setMargin(0); buttonsLayout->setSpacing(0); @@ -611,10 +674,16 @@ void NoteArea::createLayout() { m_precNoteButton->hide(); m_nextNoteButton->hide(); m_noteButton->hide(); + m_autoCreateButton->hide(); + m_createInHoldButton->hide(); + m_autoStretchButton->hide(); } else { m_precNoteButton->show(); m_nextNoteButton->show(); m_noteButton->show(); + m_autoCreateButton->show(); + m_createInHoldButton->show(); + m_autoStretchButton->show(); } } @@ -636,6 +705,19 @@ void NoteArea::updateButtons() { } } +void NoteArea::paintEvent(QPaintEvent *event) { + m_autoCreateButton->setChecked(CommandManager::instance() + ->getAction("MI_ToggleAutoCreate") + ->isChecked()); + m_createInHoldButton->setChecked( + CommandManager::instance() + ->getAction("MI_ToggleCreationInHoldCells") + ->isChecked()); + m_autoStretchButton->setChecked(CommandManager::instance() + ->getAction("MI_ToggleAutoStretch") + ->isChecked()); +} + //----------------------------------------------------------------------------- // void NoteArea::flipOrientation() { m_viewer->flipOrientation(); } diff --git a/toonz/sources/toonz/xshnoteviewer.h b/toonz/sources/toonz/xshnoteviewer.h index 47bcf63a..c2f28d38 100644 --- a/toonz/sources/toonz/xshnoteviewer.h +++ b/toonz/sources/toonz/xshnoteviewer.h @@ -126,6 +126,9 @@ class NoteArea final : public QFrame { QToolButton *m_nextNoteButton; QToolButton *m_precNoteButton; QToolButton *m_newLevelButton; + QToolButton *m_autoCreateButton; + QToolButton *m_createInHoldButton; + QToolButton *m_autoStretchButton; QComboBox *m_frameDisplayStyleCombo; @@ -151,6 +154,8 @@ protected slots: void onXsheetOrientationChanged(const Orientation *orientation); protected: + void paintEvent(QPaintEvent *event) override; + void removeLayout(); void createLayout(); }; diff --git a/toonz/sources/toonzlib/orientation.cpp b/toonz/sources/toonzlib/orientation.cpp index e2386422..55760d98 100644 --- a/toonz/sources/toonzlib/orientation.cpp +++ b/toonz/sources/toonzlib/orientation.cpp @@ -338,6 +338,20 @@ TopToBottomOrientation::TopToBottomOrientation() { addRect(PredefinedRect::NOTE_ICON, QRect(QPoint(0, 0), QSize(CELL_WIDTH - 2, CELL_HEIGHT - 2))); + QRect autoCreate, createInHold, autoStretch; + + autoCreate = QRect(0, 0, 17, 17); + addRect(PredefinedRect::AUTO_CREATE_AREA, autoCreate); + addRect(PredefinedRect::AUTO_CREATE, autoCreate.adjusted(1, 1, 0, 0)); + + createInHold = QRect(0, 0, 17, 17); + addRect(PredefinedRect::CREATE_IN_HOLD_AREA, createInHold); + addRect(PredefinedRect::CREATE_IN_HOLD, createInHold.adjusted(1, 1, 0, 0)); + + autoStretch = QRect(0, 0, 17, 17); + addRect(PredefinedRect::AUTO_STRETCH_AREA, autoStretch); + addRect(PredefinedRect::AUTO_STRETCH, autoStretch.adjusted(1, 1, 0, 0)); + // Layer header panel addRect(PredefinedRect::LAYER_HEADER_PANEL, QRect(0, 0, -1, -1)); // hide addRect(PredefinedRect::PANEL_EYE, QRect(0, 0, -1, -1)); // hide @@ -1115,7 +1129,22 @@ LeftToRightOrientation::LeftToRightOrientation() { QRect(0, 0, LAYER_HEADER_WIDTH + 2, LAYER_FOOTER_PANEL_HEIGHT)); addRect(PredefinedRect::LAYER_FOOTER_PANEL, layerFooterPanel); - QRect zoomSlider, zoomIn, zoomOut, noteArea; // addLevel, + QRect zoomSlider, zoomIn, zoomOut, noteArea, autoCreate, createInHold, + autoStretch; // addLevel, + + autoCreate = QRect(1, 0, 16, LAYER_FOOTER_PANEL_HEIGHT); + addRect(PredefinedRect::AUTO_CREATE_AREA, autoCreate); + addRect(PredefinedRect::AUTO_CREATE, autoCreate.adjusted(1, 1, 0, 0)); + + createInHold = + QRect(autoCreate.right() + 1, 0, 16, LAYER_FOOTER_PANEL_HEIGHT); + addRect(PredefinedRect::CREATE_IN_HOLD_AREA, createInHold); + addRect(PredefinedRect::CREATE_IN_HOLD, createInHold.adjusted(1, 1, 0, 0)); + + autoStretch = + QRect(createInHold.right() + 1, 0, 16, LAYER_FOOTER_PANEL_HEIGHT); + addRect(PredefinedRect::AUTO_STRETCH_AREA, autoStretch); + addRect(PredefinedRect::AUTO_STRETCH, autoStretch.adjusted(1, 1, 0, 0)); zoomSlider = QRect(layerFooterPanel.width() - 100, 0, 81, LAYER_FOOTER_PANEL_HEIGHT);