From cb7c70f69e64d43cd938f91075c6d4c04fea0248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20Corr=C3=AAa?= <75134774+HeCorr@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:52:30 -0300 Subject: [PATCH 1/3] Maintain active layer track in view (#1867) * maintain current layer track in view automatically scroll the layer UI vertically in order to maintain the current layer visible, so that selecting layers with the Up and Down arrows doesn't end up with the active one being out of view if you have many layers. * emit new signal in LayerManager goto methods... ...and listen to it in timeline.cpp instead of the old signal. this fixes an issue with the current layer scrolling implementation where clicking a barely-visible layer would move it due to the scrolling happening while the pointer was still being pressed. now clicking layers no longer triggers the scrolling, only the Up and Down arrow keys do. note that I didn't remove the original signal emission from the goto methods not to break anything else. * Revert "emit new signal in LayerManager goto methods..." This reverts commit 662ba4fa1d9a15fd429f9413e0bb827a1cd6de9d. * Introduce property to check if timeline is scrolled vertically This prevents the timeline cells from swapping layers while the scrollbar emits changes. * Introduce timer to notify when we stop scrolling So we can reset the 'mScrollingVertically' properly. * Move currentLayerChanged logic into existing onLayerChanged --------- Co-authored-by: MrStevns --- app/src/timeline.cpp | 36 ++++++++++++++++++++++++++++++++++-- app/src/timeline.h | 9 ++++++++- app/src/timelinecells.cpp | 8 +++++++- app/src/timelinecells.h | 3 +++ 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/app/src/timeline.cpp b/app/src/timeline.cpp index dcb26b28f..92a5544e9 100644 --- a/app/src/timeline.cpp +++ b/app/src/timeline.cpp @@ -27,6 +27,7 @@ GNU General Public License for more details. #include #include #include +#include #include "editor.h" #include "layermanager.h" @@ -191,12 +192,17 @@ void TimeLine::initUI() timeLineContent->setLayout(lay); setWidget(timeLineContent); + mScrollingStoppedTimer = new QTimer(); + mScrollingStoppedTimer->setSingleShot(true); + setWindowFlags(Qt::WindowStaysOnTopHint); connect(mHScrollbar, &QScrollBar::valueChanged, mTracks, &TimeLineCells::hScrollChange); connect(mTracks, &TimeLineCells::offsetChanged, mHScrollbar, &QScrollBar::setValue); connect(mVScrollbar, &QScrollBar::valueChanged, mTracks, &TimeLineCells::vScrollChange); connect(mVScrollbar, &QScrollBar::valueChanged, mLayerList, &TimeLineCells::vScrollChange); + connect(mVScrollbar, &QScrollBar::valueChanged, this, &TimeLine::onScrollbarValueChanged); + connect(mScrollingStoppedTimer, &QTimer::timeout, mLayerList, &TimeLineCells::onScrollingVerticallyStopped); connect(splitter, &QSplitter::splitterMoved, this, &TimeLine::updateLength); @@ -232,7 +238,7 @@ void TimeLine::initUI() LayerManager* layer = editor()->layers(); connect(layer, &LayerManager::layerCountChanged, this, &TimeLine::updateLayerNumber); - connect(layer, &LayerManager::currentLayerChanged, this, &TimeLine::onLayerChanged); + connect(layer, &LayerManager::currentLayerChanged, this, &TimeLine::onCurrentLayerChanged); mNumLayers = layer->count(); scrubbing = false; @@ -285,6 +291,12 @@ void TimeLine::wheelEvent(QWheelEvent* event) } } +void TimeLine::onScrollbarValueChanged() +{ + // After the scrollbar has been updated, prepare to trigger stopped event + mScrollingStoppedTimer->start(150); +} + void TimeLine::updateFrame(int frameNumber) { Q_ASSERT(mTracks); @@ -358,7 +370,27 @@ void TimeLine::onObjectLoaded() updateLayerNumber(editor()->layers()->count()); } -void TimeLine::onLayerChanged() +void TimeLine::onCurrentLayerChanged() { + updateVerticalScrollbarPosition(); mLayerDeleteButton->setEnabled(editor()->layers()->canDeleteLayer(editor()->currentLayerIndex())); } + +void TimeLine::updateVerticalScrollbarPosition() +{ + // invert index so 0 is at the top + int idx = mNumLayers - editor()->currentLayerIndex() - 1; + // number of visible layers + int height = mNumLayers - mVScrollbar->maximum(); + // scroll bar position/offset + int pos = mVScrollbar->value(); + + if (idx < pos) // above visible area + { + mVScrollbar->setValue(idx); + } + else if (idx >= pos + height) // below visible area + { + mVScrollbar->setValue(idx - height + 1); + } +} diff --git a/app/src/timeline.h b/app/src/timeline.h index f5f019177..ec25eff0d 100644 --- a/app/src/timeline.h +++ b/app/src/timeline.h @@ -25,6 +25,7 @@ class TimeLineCells; class TimeControls; class QToolButton; +class QWheelEvent; class TimeLine : public BaseDockWidget @@ -53,7 +54,8 @@ class TimeLine : public BaseDockWidget int getRangeUpper(); void onObjectLoaded(); - void onLayerChanged(); + void onCurrentLayerChanged(); + void onScrollbarValueChanged(); signals: void selectionChanged(); @@ -76,6 +78,7 @@ class TimeLine : public BaseDockWidget void onionPrevClick(); void onionNextClick(); void playButtonTriggered(); + public: bool scrubbing = false; @@ -84,12 +87,16 @@ class TimeLine : public BaseDockWidget void wheelEvent( QWheelEvent* ) override; private: + void updateVerticalScrollbarPosition(); + QScrollBar* mHScrollbar = nullptr; QScrollBar* mVScrollbar = nullptr; TimeLineCells* mTracks = nullptr; TimeLineCells* mLayerList = nullptr; TimeControls* mTimeControls = nullptr; + QTimer* mScrollingStoppedTimer = nullptr; + QToolButton* mLayerDeleteButton = nullptr; int mNumLayers = 0; int mLastUpdatedFrame = 0; diff --git a/app/src/timelinecells.cpp b/app/src/timelinecells.cpp index f3fab5915..720108a42 100644 --- a/app/src/timelinecells.cpp +++ b/app/src/timelinecells.cpp @@ -1083,7 +1083,7 @@ void TimeLineCells::mouseReleaseEvent(QMouseEvent* event) updateContent(); } } - if (mType == TIMELINE_CELL_TYPE::Layers && layerNumber != mStartLayerNumber && mStartLayerNumber != -1 && layerNumber != -1) + if (mType == TIMELINE_CELL_TYPE::Layers && !mScrollingVertically && layerNumber != mStartLayerNumber && mStartLayerNumber != -1 && layerNumber != -1) { mToLayer = getInbetweenLayerNumber(event->pos().y()); if (mToLayer != mFromLayer && mToLayer > -1 && mToLayer < mEditor->layers()->count()) @@ -1210,9 +1210,15 @@ void TimeLineCells::hScrollChange(int x) void TimeLineCells::vScrollChange(int x) { mLayerOffset = x; + mScrollingVertically = true; updateContent(); } +void TimeLineCells::onScrollingVerticallyStopped() +{ + mScrollingVertically = false; +} + void TimeLineCells::setMouseMoveY(int x) { mMouseMoveY = x; diff --git a/app/src/timelinecells.h b/app/src/timelinecells.h index 33d5d929c..aa42d9ca3 100644 --- a/app/src/timelinecells.h +++ b/app/src/timelinecells.h @@ -75,6 +75,7 @@ public slots: void updateFrame(int frameNumber); void hScrollChange(int); void vScrollChange(int); + void onScrollingVerticallyStopped(); void setMouseMoveY(int x); protected: @@ -152,6 +153,8 @@ private slots: int mLayerOffset = 0; Qt::MouseButton primaryButton = Qt::NoButton; + bool mScrollingVertically = false; + bool mCanMoveFrame = false; bool mMovingFrames = false; From cfeeed89a1b01c512e31ecab1e49f7e0ddd4acd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrique=20Corr=C3=AAa?= <75134774+HeCorr@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:53:03 -0300 Subject: [PATCH 2/3] Updated shortcuts (#1866) * remove legacy Export Sound shortcut * add some missing keyboard shortcuts - Export Animated GIF - Playback range - Peg bar Alignment - Import Image Predefined Set - Import Movie Video - Import Movie Audio - Import Animated Image - Import Layers from project file - Import Palette (Append) - Reset all tools to default - Change Line Color (Current keyframe) - Change Line Color (All keyframes on layer) - Toggle Center Overlay - Toggle Thirds Overlay - Toggle Golden Ratio Overlay - Toggle Safe Areas Overlay - Toggle One Point Perspective Overlay - Toggle Two Point Perspective Overlay - Toggle Three Point Perspective Overlay * better shortcut name for CMD_LOOP_CONTROL * setup shortcut for Import Palette (Replace) * fix warnings of missing enum arm regression introduced by 2c5891dcfa10e274986878665c313b39ca6769a1 * remove code related to incomplete Preview feature - preview.h - preview.cpp - actionPreview - CMD_PREVIEW - CmdPreview * add two more missing shortcuts - Selection: Reposition Frames - Change Layer / Keyframe Opacity --- app/app.pro | 2 -- app/src/filedialog.cpp | 2 +- app/src/mainwindow2.cpp | 27 +++++++++++++++-- app/src/preview.cpp | 46 ----------------------------- app/src/preview.h | 54 ---------------------------------- app/src/shortcutspage.cpp | 25 ++++++++++++++-- app/ui/mainwindow2.ui | 9 ------ core_lib/data/resources/kb.ini | 25 ++++++++++++++-- core_lib/src/util/pencildef.h | 24 +++++++++++++-- 9 files changed, 92 insertions(+), 122 deletions(-) delete mode 100644 app/src/preview.cpp delete mode 100644 app/src/preview.h diff --git a/app/app.pro b/app/app.pro index cbb4e86bd..3cb337fb8 100644 --- a/app/app.pro +++ b/app/app.pro @@ -88,7 +88,6 @@ HEADERS += \ src/shortcutspage.h \ src/timelinepage.h \ src/toolspage.h \ - src/preview.h \ src/basedockwidget.h \ src/colorbox.h \ src/colorinspector.h \ @@ -140,7 +139,6 @@ SOURCES += \ src/shortcutspage.cpp \ src/timelinepage.cpp \ src/toolspage.cpp \ - src/preview.cpp \ src/basedockwidget.cpp \ src/colorbox.cpp \ src/colorinspector.cpp \ diff --git a/app/src/filedialog.cpp b/app/src/filedialog.cpp index 42ee65db2..7499b3815 100644 --- a/app/src/filedialog.cpp +++ b/app/src/filedialog.cpp @@ -186,7 +186,7 @@ QString FileDialog::saveDialogCaption(FileType fileType) case FileType::GIF: return tr("Export Animated GIF"); case FileType::ANIMATED_IMAGE: return tr("Export animated image"); case FileType::MOVIE: return tr("Export movie"); - case FileType::SOUND: return tr("Export sound"); + case FileType::SOUND: return ""; case FileType::PALETTE: return tr("Export palette"); } return ""; diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp index 0426ebe9f..2932ef6ad 100644 --- a/app/src/mainwindow2.cpp +++ b/app/src/mainwindow2.cpp @@ -68,7 +68,6 @@ GNU General Public License for more details. #include "pegbaralignmentdialog.h" #include "repositionframesdialog.h" -//#include "preview.h" #include "errordialog.h" #include "filedialog.h" #include "importimageseqdialog.h" @@ -1165,6 +1164,7 @@ void MainWindow2::setupKeyboardShortcuts() return keySequence; }; + // File menu ui->actionNew->setShortcut(cmdKeySeq(CMD_NEW_FILE)); ui->actionOpen->setShortcut(cmdKeySeq(CMD_OPEN_FILE)); ui->actionSave->setShortcut(cmdKeySeq(CMD_SAVE_FILE)); @@ -1172,14 +1172,19 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionImport_Image->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE)); ui->actionImport_ImageSeq->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE_SEQ)); + ui->actionImport_ImageSeqNum->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE_PREDEFINED_SET)); ui->actionImport_MovieVideo->setShortcut(cmdKeySeq(CMD_IMPORT_MOVIE_VIDEO)); + ui->actionImport_AnimatedImage->setShortcut(cmdKeySeq(CMD_IMPORT_ANIMATED_IMAGE)); + ui->actionImportLayers_from_pclx->setShortcut(cmdKeySeq(CMD_IMPORT_LAYERS)); + ui->actionImport_Sound->setShortcut(cmdKeySeq(CMD_IMPORT_SOUND)); ui->actionImport_MovieAudio->setShortcut(cmdKeySeq(CMD_IMPORT_MOVIE_AUDIO)); ui->actionImport_Append_Palette->setShortcut(cmdKeySeq(CMD_IMPORT_PALETTE)); - ui->actionImport_Sound->setShortcut(cmdKeySeq(CMD_IMPORT_SOUND)); + ui->actionImport_Replace_Palette->setShortcut(cmdKeySeq(CMD_IMPORT_PALETTE_REPLACE)); ui->actionExport_Image->setShortcut(cmdKeySeq(CMD_EXPORT_IMAGE)); ui->actionExport_ImageSeq->setShortcut(cmdKeySeq(CMD_EXPORT_IMAGE_SEQ)); ui->actionExport_Movie->setShortcut(cmdKeySeq(CMD_EXPORT_MOVIE)); + ui->actionExport_Animated_GIF->setShortcut(cmdKeySeq(CMD_EXPORT_GIF)); ui->actionExport_Palette->setShortcut(cmdKeySeq(CMD_EXPORT_PALETTE)); // edit menu @@ -1194,10 +1199,12 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionFlip_Y->setShortcut(cmdKeySeq(CMD_SELECTION_FLIP_VERTICAL)); ui->actionSelect_All->setShortcut(cmdKeySeq(CMD_SELECT_ALL)); ui->actionDeselect_All->setShortcut(cmdKeySeq(CMD_DESELECT_ALL)); + ui->actionPegbarAlignment->setShortcut(cmdKeySeq(CMD_PEGBAR_ALIGNMENT)); ui->actionPreference->setShortcut(cmdKeySeq(CMD_PREFERENCE)); // View menu ui->actionResetWindows->setShortcut(cmdKeySeq(CMD_RESET_WINDOWS)); + ui->actionLockWindows->setShortcut(cmdKeySeq(CMD_LOCK_WINDOWS)); ui->actionReset_View->setShortcut(cmdKeySeq(CMD_RESET_ZOOM_ROTATE)); ui->actionCenter_View->setShortcut(cmdKeySeq(CMD_CENTER_VIEW)); ui->actionZoom_In->setShortcut(cmdKeySeq(CMD_ZOOM_IN)); @@ -1214,14 +1221,22 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionReset_Rotation->setShortcut(cmdKeySeq(CMD_RESET_ROTATION)); ui->actionHorizontal_Flip->setShortcut(cmdKeySeq(CMD_FLIP_HORIZONTAL)); ui->actionVertical_Flip->setShortcut(cmdKeySeq(CMD_FLIP_VERTICAL)); - ui->actionPreview->setShortcut(cmdKeySeq(CMD_PREVIEW)); ui->actionGrid->setShortcut(cmdKeySeq(CMD_GRID)); + ui->actionCenter->setShortcut(cmdKeySeq(CMD_OVERLAY_CENTER)); + ui->actionThirds->setShortcut(cmdKeySeq(CMD_OVERLAY_THIRDS)); + ui->actionGoldenRatio->setShortcut(cmdKeySeq(CMD_OVERLAY_GOLDEN_RATIO)); + ui->actionSafeAreas->setShortcut(cmdKeySeq(CMD_OVERLAY_SAFE_AREAS)); + ui->actionOnePointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_ONE_POINT_PERSPECTIVE)); + ui->actionTwoPointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_TWO_POINT_PERSPECTIVE)); + ui->actionThreePointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_THREE_POINT_PERSPECTIVE)); ui->actionOnionPrev->setShortcut(cmdKeySeq(CMD_ONIONSKIN_PREV)); ui->actionOnionNext->setShortcut(cmdKeySeq(CMD_ONIONSKIN_NEXT)); ui->actionStatusBar->setShortcut(cmdKeySeq(CMD_TOGGLE_STATUS_BAR)); + // Animation menu ui->actionPlay->setShortcut(cmdKeySeq(CMD_PLAY)); ui->actionLoop->setShortcut(cmdKeySeq(CMD_LOOP)); + ui->actionLoopControl->setShortcut(cmdKeySeq(CMD_LOOP_CONTROL)); ui->actionPrevious_Frame->setShortcut(cmdKeySeq(CMD_GOTO_PREV_FRAME)); ui->actionNext_Frame->setShortcut(cmdKeySeq(CMD_GOTO_NEXT_FRAME)); ui->actionPrev_KeyFrame->setShortcut(cmdKeySeq(CMD_GOTO_PREV_KEY_FRAME)); @@ -1237,6 +1252,7 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionMove_Frame_Forward->setShortcut(cmdKeySeq(CMD_MOVE_FRAME_FORWARD)); ui->actionFlip_inbetween->setShortcut(cmdKeySeq(CMD_FLIP_INBETWEEN)); ui->actionFlip_rolling->setShortcut(cmdKeySeq(CMD_FLIP_ROLLING)); + ui->actionReposition_Selected_Frames->setShortcut(cmdKeySeq(CMD_SELECTION_REPOSITION_FRAMES)); ShortcutFilter* shortcutFilter = new ShortcutFilter(ui->scribbleArea, this); ui->actionMove->setShortcut(cmdKeySeq(CMD_TOOL_MOVE)); @@ -1250,6 +1266,7 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionBucket->setShortcut(cmdKeySeq(CMD_TOOL_BUCKET)); ui->actionEyedropper->setShortcut(cmdKeySeq(CMD_TOOL_EYEDROPPER)); ui->actionEraser->setShortcut(cmdKeySeq(CMD_TOOL_ERASER)); + ui->actionResetToolsDefault->setShortcut(cmdKeySeq(CMD_RESET_ALL_TOOLS)); ui->actionMove->installEventFilter(shortcutFilter); ui->actionMove->installEventFilter(shortcutFilter); @@ -1264,11 +1281,15 @@ void MainWindow2::setupKeyboardShortcuts() ui->actionEyedropper->installEventFilter(shortcutFilter); ui->actionEraser->installEventFilter(shortcutFilter); + // Layer menu ui->actionNew_Bitmap_Layer->setShortcut(cmdKeySeq(CMD_NEW_BITMAP_LAYER)); ui->actionNew_Vector_Layer->setShortcut(cmdKeySeq(CMD_NEW_VECTOR_LAYER)); ui->actionNew_Camera_Layer->setShortcut(cmdKeySeq(CMD_NEW_CAMERA_LAYER)); ui->actionNew_Sound_Layer->setShortcut(cmdKeySeq(CMD_NEW_SOUND_LAYER)); ui->actionDelete_Current_Layer->setShortcut(cmdKeySeq(CMD_DELETE_CUR_LAYER)); + ui->actionChangeLineColorCurrent_keyframe->setShortcut(cmdKeySeq(CMD_CHANGE_LINE_COLOR_KEYFRAME)); + ui->actionChangeLineColorAll_keyframes_on_layer->setShortcut(cmdKeySeq(CMD_CHANGE_LINE_COLOR_LAYER)); + ui->actionChangeLayerOpacity->setShortcut(cmdKeySeq(CMD_CHANGE_LAYER_OPACITY)); ui->actionVisibilityCurrentLayerOnly->setShortcut(cmdKeySeq(CMD_CURRENT_LAYER_VISIBILITY)); ui->actionVisibilityRelative->setShortcut(cmdKeySeq(CMD_RELATIVE_LAYER_VISIBILITY)); diff --git a/app/src/preview.cpp b/app/src/preview.cpp deleted file mode 100644 index 6b1ad5f9f..000000000 --- a/app/src/preview.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - -Pencil2D - Traditional Animation Software -Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon -Copyright (C) 2012-2020 Matthew Chiawen Chang - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -*/ - -#include "preview.h" -#include - - -PreviewCanvas::PreviewCanvas( QWidget* parent ) : QWidget( parent ) -{ - setFixedSize( 200, 200 ); -} - -void PreviewCanvas::paintEvent( QPaintEvent* ) -{ - QPainter painter( this ); - if ( mBitmapImage ) - { - painter.drawImage( rect( ), *( mBitmapImage->image() ) ); - } - painter.end( ); -} - -PreviewWidget::PreviewWidget( QWidget* parent ) : QDockWidget( parent ) -{ - mCanvas = new PreviewCanvas( this ); - setWidget( mCanvas ); -} - -void PreviewWidget::updateImage() -{ - mCanvas->update(); -} diff --git a/app/src/preview.h b/app/src/preview.h deleted file mode 100644 index 006a0c5a4..000000000 --- a/app/src/preview.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - -Pencil2D - Traditional Animation Software -Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon -Copyright (C) 2012-2020 Matthew Chiawen Chang - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -*/ - -#ifndef PREVIEW_H -#define PREVIEW_H - -#include -#include "bitmapimage.h" - -class PreviewCanvas : public QWidget -{ - Q_OBJECT - -public: - PreviewCanvas( QWidget* ); - void setImage( BitmapImage* img ) { mBitmapImage = img; } - -protected: - void paintEvent( QPaintEvent* ) override; - -private: - BitmapImage* mBitmapImage = nullptr; -}; - - - -class PreviewWidget : public QDockWidget -{ - Q_OBJECT -public: - PreviewWidget(QWidget *parent = nullptr); - void setImage( BitmapImage* img ) { mCanvas->setImage( img ); } - void updateImage(); - -private: - PreviewCanvas* mCanvas = nullptr; - -}; - -#endif // PREVIEW_H diff --git a/app/src/shortcutspage.cpp b/app/src/shortcutspage.cpp index 74fd65818..36e887b6a 100644 --- a/app/src/shortcutspage.cpp +++ b/app/src/shortcutspage.cpp @@ -310,8 +310,8 @@ static QString getHumanReadableShortcutName(const QString& cmdName) {CMD_EXPORT_IMAGE, ShortcutsPage::tr("Export Image", "Shortcut")}, {CMD_EXPORT_IMAGE_SEQ, ShortcutsPage::tr("Export Image Sequence", "Shortcut")}, {CMD_EXPORT_MOVIE, ShortcutsPage::tr("Export Movie", "Shortcut")}, + {CMD_EXPORT_GIF, ShortcutsPage::tr("Export Animated GIF", "Shortcut")}, {CMD_EXPORT_PALETTE, ShortcutsPage::tr("Export Palette", "Shortcut")}, - {CMD_EXPORT_SOUND, ShortcutsPage::tr("Export Sound", "Shortcut")}, {CMD_FLIP_HORIZONTAL, ShortcutsPage::tr("View: Horizontal Flip", "Shortcut")}, {CMD_FLIP_VERTICAL, ShortcutsPage::tr("View: Vertical Flip", "Shortcut")}, {CMD_FLIP_INBETWEEN, ShortcutsPage::tr("Flip In-Between", "Shortcut")}, @@ -322,18 +322,34 @@ static QString getHumanReadableShortcutName(const QString& cmdName) {CMD_SELECTION_FLIP_HORIZONTAL, ShortcutsPage::tr("Selection: Horizontal Flip", "Shortcut")}, {CMD_SELECTION_FLIP_VERTICAL, ShortcutsPage::tr("Selection: Vertical Flip", "Shortcut")}, {CMD_GOTO_PREV_KEY_FRAME, ShortcutsPage::tr("Previous Keyframe", "Shortcut")}, + {CMD_SELECTION_REPOSITION_FRAMES, ShortcutsPage::tr("Selection: Reposition Frames", "Shortcut")}, {CMD_SELECTION_ADD_FRAME_EXPOSURE, ShortcutsPage::tr("Selection: Add Frame Exposure", "Shortcut")}, {CMD_SELECTION_SUBTRACT_FRAME_EXPOSURE, ShortcutsPage::tr("Selection: Subtract Frame Exposure", "Shortcut")}, {CMD_REVERSE_SELECTED_FRAMES, ShortcutsPage::tr("Selection: Reverse Keyframes", "Shortcut")}, {CMD_REMOVE_SELECTED_FRAMES, ShortcutsPage::tr("Selection: Remove Keyframes", "Shortcut")}, {CMD_GRID, ShortcutsPage::tr("Toggle Grid", "Shortcut")}, + {CMD_OVERLAY_CENTER, ShortcutsPage::tr("Toggle Center Overlay", "Shortcut")}, + {CMD_OVERLAY_THIRDS, ShortcutsPage::tr("Toggle Thirds Overlay", "Shortcut")}, + {CMD_OVERLAY_GOLDEN_RATIO, ShortcutsPage::tr("Toggle Golden Ratio Overlay", "Shortcut")}, + {CMD_OVERLAY_SAFE_AREAS, ShortcutsPage::tr("Toggle Safe Areas Overlay", "Shortcut")}, + {CMD_OVERLAY_ONE_POINT_PERSPECTIVE, ShortcutsPage::tr("Toggle One Point Perspective Overlay", "Shortcut")}, + {CMD_OVERLAY_TWO_POINT_PERSPECTIVE, ShortcutsPage::tr("Toggle Two Point Perspective Overlay", "Shortcut")}, + {CMD_OVERLAY_THREE_POINT_PERSPECTIVE, ShortcutsPage::tr("Toggle Three Point Perspective Overlay", "Shortcut")}, {CMD_IMPORT_IMAGE, ShortcutsPage::tr("Import Image", "Shortcut")}, {CMD_IMPORT_IMAGE_SEQ, ShortcutsPage::tr("Import Image Sequence", "Shortcut")}, + {CMD_IMPORT_IMAGE_PREDEFINED_SET, ShortcutsPage::tr("Import Image Predefined Set", "Shortcut")}, + {CMD_IMPORT_MOVIE_VIDEO, ShortcutsPage::tr("Import Movie Video", "Shortcut")}, + {CMD_IMPORT_MOVIE_AUDIO, ShortcutsPage::tr("Import Movie Audio", "Shortcut")}, + {CMD_IMPORT_ANIMATED_IMAGE, ShortcutsPage::tr("Import Animated Image", "Shortcut")}, + {CMD_IMPORT_LAYERS, ShortcutsPage::tr("Import Layers from project file", "Shortcut")}, + {CMD_IMPORT_PALETTE, ShortcutsPage::tr("Import Palette (Append)", "Shortcut")}, + {CMD_IMPORT_PALETTE_REPLACE, ShortcutsPage::tr("Import Palette (Replace)", "Shortcut")}, {CMD_IMPORT_SOUND, ShortcutsPage::tr("Import Sound", "Shortcut")}, {CMD_ALL_LAYER_VISIBILITY, ShortcutsPage::tr("Show All Layers", "Shortcut")}, {CMD_CURRENT_LAYER_VISIBILITY, ShortcutsPage::tr("Show Current Layer Only", "Shortcut")}, {CMD_RELATIVE_LAYER_VISIBILITY, ShortcutsPage::tr("Show Layers Relative to Current Layer", "Shortcut")}, {CMD_LOOP, ShortcutsPage::tr("Toggle Loop", "Shortcut")}, + {CMD_LOOP_CONTROL, ShortcutsPage::tr("Toggle Range Playback", "Shortcut")}, {CMD_MOVE_FRAME_BACKWARD, ShortcutsPage::tr("Move Frame Backward", "Shortcut")}, {CMD_MOVE_FRAME_FORWARD, ShortcutsPage::tr("Move Frame Forward", "Shortcut")}, {CMD_NEW_BITMAP_LAYER, ShortcutsPage::tr("New Bitmap Layer", "Shortcut")}, @@ -346,11 +362,12 @@ static QString getHumanReadableShortcutName(const QString& cmdName) {CMD_OPEN_FILE, ShortcutsPage::tr("Open File", "Shortcut")}, {CMD_PASTE, ShortcutsPage::tr("Paste", "Shortcut")}, {CMD_PLAY, ShortcutsPage::tr("Play/Stop", "Shortcut")}, + {CMD_PEGBAR_ALIGNMENT, ShortcutsPage::tr("Peg bar Alignment", "Shortcut")}, {CMD_PREFERENCE, ShortcutsPage::tr("Preferences", "Shortcut")}, - {CMD_PREVIEW, ShortcutsPage::tr("Preview", "Shortcut")}, {CMD_REDO, ShortcutsPage::tr("Redo", "Shortcut")}, {CMD_REMOVE_FRAME, ShortcutsPage::tr("Remove Frame", "Shortcut")}, {CMD_RESET_WINDOWS, ShortcutsPage::tr("Reset Windows", "Shortcut")}, + {CMD_LOCK_WINDOWS, ShortcutsPage::tr("Lock Windows", "Shortcut")}, {CMD_RESET_ZOOM_ROTATE, ShortcutsPage::tr("Reset View", "Shortcut")}, {CMD_CENTER_VIEW, ShortcutsPage::tr("Center View", "Shortcut")}, {CMD_ROTATE_ANTI_CLOCK, ShortcutsPage::tr("Rotate Anticlockwise", "Shortcut")}, @@ -378,6 +395,10 @@ static QString getHumanReadableShortcutName(const QString& cmdName) {CMD_TOOL_POLYLINE, ShortcutsPage::tr("Polyline Tool", "Shortcut")}, {CMD_TOOL_SELECT, ShortcutsPage::tr("Select Tool", "Shortcut")}, {CMD_TOOL_SMUDGE, ShortcutsPage::tr("Smudge Tool", "Shortcut")}, + {CMD_RESET_ALL_TOOLS, ShortcutsPage::tr("Reset all tools to default", "Shortcut")}, + {CMD_CHANGE_LINE_COLOR_KEYFRAME, ShortcutsPage::tr("Change Line Color (Current keyframe)", "Shortcut")}, + {CMD_CHANGE_LINE_COLOR_LAYER, ShortcutsPage::tr("Change Line Color (All keyframes on layer)", "Shortcut")}, + {CMD_CHANGE_LAYER_OPACITY, ShortcutsPage::tr("Change Layer / Keyframe Opacity", "Shortcut")}, {CMD_UNDO, ShortcutsPage::tr("Undo", "Shortcut")}, {CMD_ZOOM_100, ShortcutsPage::tr("Set Zoom to 100%", "Shortcut")}, {CMD_ZOOM_200, ShortcutsPage::tr("Set Zoom to 200%", "Shortcut")}, diff --git a/app/ui/mainwindow2.ui b/app/ui/mainwindow2.ui index 337b6f42b..39773e41a 100644 --- a/app/ui/mainwindow2.ui +++ b/app/ui/mainwindow2.ui @@ -209,7 +209,6 @@ - @@ -564,14 +563,6 @@ Vertical Flip - - - false - - - Preview - - true diff --git a/core_lib/data/resources/kb.ini b/core_lib/data/resources/kb.ini index d48613335..310431e1b 100644 --- a/core_lib/data/resources/kb.ini +++ b/core_lib/data/resources/kb.ini @@ -6,12 +6,19 @@ CmdSaveAs=Ctrl+Shift+S CmdExit=Ctrl+Q CmdImportImage= CmdImportImageSequence= +CmdImportImagePredefinedSet= +CmdImportMovieVideo= +CmdImportAnimatedImage= +CmdImportLayers= CmdImportSound= +CmdImportMovieAudio= +CmdImportPalette= +CmdImportPaletteReplace= CmdExportImageSequence=Ctrl+R CmdExportImage=Ctrl+Shift+R CmdExportMovie= +CmdExportGIF=Ctrl+G CmdExportPalette= -CmdExportSound=Ctrl+I CmdUndo=Ctrl+Z CmdRedo=Ctrl+Shift+Z CmdCut=Ctrl+X @@ -21,8 +28,10 @@ CmdPaste=Ctrl+V CmdSelectAll=Ctrl+A CmdDeselectAll=Ctrl+D CmdClearFrame= +CmdPegBarAlignment= CmdPreferences= CmdResetWindows= +CmdLockWindows= CmdZoomIn=Ctrl+Up CmdZoomOut=Ctrl+Down CmdZoom400=4 @@ -39,13 +48,20 @@ CmdResetZoomRotate=Ctrl+H CmdCenterView=Ctrl+Shift+H CmdFlipHorizontal=Shift+H CmdFlipVertical=Shift+V -CmdPreview=Alt+P CmdGrid=G +CmdOverlayCenter= +CmdOverlayThirds= +CmdOverlayGoldenRatio= +CmdOverlaySafeAreas= +CmdOverlayOnePointPerspective= +CmdOverlayTwoPointPerspective= +CmdOverlayThreePointPerspective= CmdOnionSkinPrevious=O CmdOnionSkinNext=Alt+O CmdToggleStatusBar= CmdPlay=Ctrl+Return CmdLoop=Ctrl+L +CmdLoopControl= CmdFlipInBetween=Alt+Z CmdFlipRolling=Alt+X CmdGotoNextFrame=. @@ -60,6 +76,7 @@ CmdSelectionFlipHorizontal= CmdSelectionFlipVertical= CmdSelectionAddFrameExposure=Ctrl+"+" CmdSelectionSubtractFrameExposure=Ctrl+"-" +CmdSelectionRepositionFrames= CmdReverseSelectedFrames= CmdRemoveSelectedFrames= CmdRemoveFrame=Shift+F5 @@ -74,6 +91,7 @@ CmdToolPencil=N CmdToolBucket=K CmdToolEyedropper=I CmdToolEraser=E +CmdResetAllTools= CmdNewBitmapLayer=Ctrl+Alt+B CmdNewVectorLayer=Ctrl+Alt+V CmdNewSoundLayer=Ctrl+Alt+W @@ -82,6 +100,9 @@ CmdLayerVisibilityCurrentOnly=Alt+1 CmdLayerVisibilityRelative=Alt+2 CmdLayerVisibilityAll=Alt+3 CmdDeleteCurrentLayer= +CmdChangeLineColorKeyframe= +CmdChangeLineColorLayer= +CmdChangeLayerOpacity= CmdToggleToolBox=Ctrl+1 CmdToggleToolOptions=Ctrl+2 CmdToggleColorWheel=Ctrl+3 diff --git a/core_lib/src/util/pencildef.h b/core_lib/src/util/pencildef.h index b2dbdfbc7..d69ffe879 100644 --- a/core_lib/src/util/pencildef.h +++ b/core_lib/src/util/pencildef.h @@ -125,15 +125,19 @@ const static int MaxFramesBound = 9999; #define CMD_SAVE_AS "CmdSaveAs" #define CMD_IMPORT_IMAGE "CmdImportImage" #define CMD_IMPORT_IMAGE_SEQ "CmdImportImageSequence" +#define CMD_IMPORT_IMAGE_PREDEFINED_SET "CmdImportImagePredefinedSet" #define CMD_IMPORT_MOVIE_VIDEO "CmdImportMovieVideo" +#define CMD_IMPORT_ANIMATED_IMAGE "CmdImportAnimatedImage" +#define CMD_IMPORT_LAYERS "CmdImportLayers" +#define CMD_IMPORT_SOUND "CmdImportSound" #define CMD_IMPORT_MOVIE_AUDIO "CmdImportMovieAudio" #define CMD_IMPORT_PALETTE "CmdImportPalette" -#define CMD_IMPORT_SOUND "CmdImportSound" +#define CMD_IMPORT_PALETTE_REPLACE "CmdImportPaletteReplace" #define CMD_EXPORT_IMAGE_SEQ "CmdExportImageSequence" #define CMD_EXPORT_IMAGE "CmdExportImage" #define CMD_EXPORT_MOVIE "CmdExportMovie" +#define CMD_EXPORT_GIF "CmdExportGIF" #define CMD_EXPORT_PALETTE "CmdExportPalette" -#define CMD_EXPORT_SOUND "CmdExportSound" #define CMD_UNDO "CmdUndo" #define CMD_REDO "CmdRedo" #define CMD_CUT "CmdCut" @@ -143,8 +147,10 @@ const static int MaxFramesBound = 9999; #define CMD_SELECT_ALL "CmdSelectAll" #define CMD_DESELECT_ALL "CmdDeselectAll" #define CMD_CLEAR_FRAME "CmdClearFrame" +#define CMD_PEGBAR_ALIGNMENT "CmdPegBarAlignment" #define CMD_PREFERENCE "CmdPreferences" #define CMD_RESET_WINDOWS "CmdResetWindows" +#define CMD_LOCK_WINDOWS "CmdLockWindows" #define CMD_ZOOM_IN "CmdZoomIn" #define CMD_ZOOM_OUT "CmdZoomOut" #define CMD_ROTATE_CLOCK "CmdRotateClockwise" @@ -161,13 +167,20 @@ const static int MaxFramesBound = 9999; #define CMD_ZOOM_25 "CmdZoom25" #define CMD_FLIP_HORIZONTAL "CmdFlipHorizontal" #define CMD_FLIP_VERTICAL "CmdFlipVertical" -#define CMD_PREVIEW "CmdPreview" #define CMD_GRID "CmdGrid" +#define CMD_OVERLAY_CENTER "CmdOverlayCenter" +#define CMD_OVERLAY_THIRDS "CmdOverlayThirds" +#define CMD_OVERLAY_GOLDEN_RATIO "CmdOverlayGoldenRatio" +#define CMD_OVERLAY_SAFE_AREAS "CmdOverlaySafeAreas" +#define CMD_OVERLAY_ONE_POINT_PERSPECTIVE "CmdOverlayOnePointPerspective" +#define CMD_OVERLAY_TWO_POINT_PERSPECTIVE "CmdOverlayTwoPointPerspective" +#define CMD_OVERLAY_THREE_POINT_PERSPECTIVE "CmdOverlayThreePointPerspective" #define CMD_ONIONSKIN_PREV "CmdOnionSkinPrevious" #define CMD_ONIONSKIN_NEXT "CmdOnionSkinNext" #define CMD_TOGGLE_STATUS_BAR "CmdToggleStatusBar" #define CMD_PLAY "CmdPlay" #define CMD_LOOP "CmdLoop" +#define CMD_LOOP_CONTROL "CmdLoopControl" #define CMD_FLIP_INBETWEEN "CmdFlipInBetween" #define CMD_FLIP_ROLLING "CmdFlipRolling" #define CMD_GOTO_NEXT_FRAME "CmdGotoNextFrame" @@ -179,6 +192,7 @@ const static int MaxFramesBound = 9999; #define CMD_REMOVE_FRAME "CmdRemoveFrame" #define CMD_REVERSE_SELECTED_FRAMES "CmdReverseSelectedFrames" #define CMD_REMOVE_SELECTED_FRAMES "CmdRemoveSelectedFrames" +#define CMD_SELECTION_REPOSITION_FRAMES "CmdSelectionRepositionFrames" #define CMD_SELECTION_ADD_FRAME_EXPOSURE "CmdSelectionAddFrameExposure" #define CMD_SELECTION_SUBTRACT_FRAME_EXPOSURE "CmdSelectionSubtractFrameExposure" #define CMD_SELECTION_FLIP_HORIZONTAL "CmdSelectionFlipHorizontal" @@ -196,11 +210,15 @@ const static int MaxFramesBound = 9999; #define CMD_TOOL_BUCKET "CmdToolBucket" #define CMD_TOOL_EYEDROPPER "CmdToolEyedropper" #define CMD_TOOL_ERASER "CmdToolEraser" +#define CMD_RESET_ALL_TOOLS "CmdResetAllTools" #define CMD_NEW_BITMAP_LAYER "CmdNewBitmapLayer" #define CMD_NEW_VECTOR_LAYER "CmdNewVectorLayer" #define CMD_NEW_SOUND_LAYER "CmdNewSoundLayer" #define CMD_NEW_CAMERA_LAYER "CmdNewCameraLayer" #define CMD_DELETE_CUR_LAYER "CmdDeleteCurrentLayer" +#define CMD_CHANGE_LINE_COLOR_KEYFRAME "CmdChangeLineColorKeyframe" +#define CMD_CHANGE_LINE_COLOR_LAYER "CmdChangeLineColorLayer" +#define CMD_CHANGE_LAYER_OPACITY "CmdChangeLayerOpacity" #define CMD_CURRENT_LAYER_VISIBILITY "CmdLayerVisibilityCurrentOnly" #define CMD_RELATIVE_LAYER_VISIBILITY "CmdLayerVisibilityRelative" #define CMD_ALL_LAYER_VISIBILITY "CmdLayerVisibilityAll" From 7d1847e4a3fc4aefe9efff601d4da085bb84c9f4 Mon Sep 17 00:00:00 2001 From: Pascal <81458575+khoidauminh@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:57:21 +0700 Subject: [PATCH 3/3] Temporarily modify width and feather during Quick Sizing (#1853) * Temporarily modify width and feather during Quick Sizing * Make sure only stroke tool is aware of the new temporary call We don't need to expose quick sizing behaviour to the ToolManager, since the value itself is not important, we just need to notify the UI, so the slider updates. --------- Co-authored-by: MrStevns --- core_lib/src/managers/toolmanager.cpp | 3 --- core_lib/src/managers/toolmanager.h | 5 +---- core_lib/src/tool/basetool.h | 1 + core_lib/src/tool/stroketool.cpp | 30 +++++++++++++++++++++++++-- core_lib/src/tool/stroketool.h | 6 ++++++ 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/core_lib/src/managers/toolmanager.cpp b/core_lib/src/managers/toolmanager.cpp index 827033cb2..3ebc508e9 100644 --- a/core_lib/src/managers/toolmanager.cpp +++ b/core_lib/src/managers/toolmanager.cpp @@ -153,7 +153,6 @@ void ToolManager::setWidth(float newWidth) } currentTool()->setWidth(static_cast(newWidth)); - emit penWidthValueChanged(newWidth); emit toolPropertyChanged(currentTool()->type(), WIDTH); } @@ -165,7 +164,6 @@ void ToolManager::setFeather(float newFeather) } currentTool()->setFeather(static_cast(newFeather)); - emit penFeatherValueChanged(newFeather); emit toolPropertyChanged(currentTool()->type(), FEATHER); } @@ -239,7 +237,6 @@ void ToolManager::setTolerance(int newTolerance) newTolerance = qMax(0, newTolerance); currentTool()->setTolerance(newTolerance); - emit toleranceValueChanged(newTolerance); emit toolPropertyChanged(currentTool()->type(), TOLERANCE); } diff --git a/core_lib/src/managers/toolmanager.h b/core_lib/src/managers/toolmanager.h index 31cae86fc..c6d6227e7 100644 --- a/core_lib/src/managers/toolmanager.h +++ b/core_lib/src/managers/toolmanager.h @@ -53,10 +53,6 @@ class ToolManager : public BaseManager int propertySwitch(bool condition, int property); signals: - void penWidthValueChanged(float); - void penFeatherValueChanged(float); - void toleranceValueChanged(qreal); - void toolChanged(ToolType); void toolPropertyChanged(ToolType, ToolPropertyType); @@ -65,6 +61,7 @@ public slots: void setWidth(float); void setFeather(float); + void setUseFeather(bool); void setInvisibility(bool); void setPreserveAlpha(bool); diff --git a/core_lib/src/tool/basetool.h b/core_lib/src/tool/basetool.h index f26270745..1c773bf6f 100644 --- a/core_lib/src/tool/basetool.h +++ b/core_lib/src/tool/basetool.h @@ -108,6 +108,7 @@ class BaseTool : public QObject virtual void setWidth(const qreal width); virtual void setFeather(const qreal feather); + virtual void setInvisibility(const bool invisibility); virtual void setBezier(const bool bezier_state); virtual void setClosedPath(const bool closed); diff --git a/core_lib/src/tool/stroketool.cpp b/core_lib/src/tool/stroketool.cpp index b3cfa6894..4ff0c29e4 100644 --- a/core_lib/src/tool/stroketool.cpp +++ b/core_lib/src/tool/stroketool.cpp @@ -331,6 +331,10 @@ void StrokeTool::stopAdjusting() { msIsAdjusting = false; mAdjustPosition = QPointF(); + + mEditor->tools()->setWidth(properties.width); + mEditor->tools()->setFeather(properties.feather); + updateCanvasCursor(); } @@ -343,7 +347,7 @@ void StrokeTool::adjustCursor(Qt::KeyboardModifiers modifiers) // map it back to its original value, we can multiply by the factor we divided with const qreal newValue = QLineF(mAdjustPosition, getCurrentPoint()).length() * 2.0; - mEditor->tools()->setWidth(qBound(WIDTH_MIN, newValue, WIDTH_MAX)); + setTemporaryWidth(qBound(WIDTH_MIN, newValue, WIDTH_MAX)); break; } case FEATHER: { @@ -357,7 +361,7 @@ void StrokeTool::adjustCursor(Qt::KeyboardModifiers modifiers) // We flip min and max here in order to get the inverted value for the UI const qreal mappedValue = MathUtils::map(distance, inputMin, inputMax, outputMax, outputMin); - mEditor->tools()->setFeather(qBound(FEATHER_MIN, mappedValue, FEATHER_MAX)); + setTemporaryFeather(qBound(FEATHER_MIN, mappedValue, FEATHER_MAX)); break; } default: @@ -371,3 +375,25 @@ void StrokeTool::paint(QPainter& painter, const QRect& blitRect) { mCanvasCursorPainter.paint(painter, blitRect); } + +void StrokeTool::setTemporaryWidth(qreal width) +{ + if (std::isnan(width) || width < 0) + { + width = 1.f; + } + + properties.width = width; + emit mEditor->tools()->toolPropertyChanged(this->type(), WIDTH); +} + +void StrokeTool::setTemporaryFeather(qreal feather) +{ + if (std::isnan(feather) || feather < 0) + { + feather = 0.f; + } + + properties.feather = feather; + emit mEditor->tools()->toolPropertyChanged(this->type(), FEATHER); +} diff --git a/core_lib/src/tool/stroketool.h b/core_lib/src/tool/stroketool.h index 63ad63f0a..8d21fa709 100644 --- a/core_lib/src/tool/stroketool.h +++ b/core_lib/src/tool/stroketool.h @@ -110,6 +110,12 @@ public slots: CanvasCursorPainter mCanvasCursorPainter; StrokeInterpolator mInterpolator; + +private: + /// Sets the width value without calling settings to store the state + void setTemporaryWidth(qreal width); + /// Sets the feather value, without calling settings to store the state + void setTemporaryFeather(qreal feather); }; #endif // STROKETOOL_H