Skip to content

Commit

Permalink
Merge remote-tracking branch 'pencil2d/master' into undo-redo-manager-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
MrStevns committed Aug 1, 2024
2 parents ae65a13 + 7d1847e commit a10d2da
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 135 deletions.
2 changes: 0 additions & 2 deletions app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion app/src/filedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
Expand Down
27 changes: 24 additions & 3 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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"
Expand Down Expand Up @@ -1180,21 +1179,27 @@ 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));
ui->actionSave_as->setShortcut(cmdKeySeq(CMD_SAVE_AS));

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
Expand All @@ -1209,10 +1214,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));
Expand All @@ -1229,14 +1236,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));
Expand All @@ -1252,6 +1267,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));
Expand All @@ -1265,6 +1281,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);
Expand All @@ -1279,11 +1296,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));
Expand Down
46 changes: 0 additions & 46 deletions app/src/preview.cpp

This file was deleted.

54 changes: 0 additions & 54 deletions app/src/preview.h

This file was deleted.

25 changes: 23 additions & 2 deletions app/src/shortcutspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
Expand All @@ -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")},
Expand All @@ -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")},
Expand Down Expand Up @@ -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")},
Expand Down
36 changes: 34 additions & 2 deletions app/src/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ GNU General Public License for more details.
#include <QLabel>
#include <QWheelEvent>
#include <QSlider>
#include <QTimer>

#include "editor.h"
#include "layermanager.h"
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
Loading

0 comments on commit a10d2da

Please sign in to comment.