From cb87ed0722ddad1ed3156589704626b3fa13c970 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Sun, 22 Oct 2023 14:52:30 +0200 Subject: [PATCH] Fix: Don't reset frame count upon click if there's only 1 frame group This patch fixes a behaviour when user clicks one of these buttons: - previous frame group button - next frame group button - last frame group button - first frame group button And there is only one frame group available. Currently if someone presses those buttons frame count will be reseted, this patch fixes it by basically returning from function immediately if there's only 1 frame group available. --- source/celview.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/celview.cpp b/source/celview.cpp index 4564469d..e56ed2c1 100644 --- a/source/celview.cpp +++ b/source/celview.cpp @@ -388,11 +388,19 @@ void CelView::on_frameIndexEdit_returnPressed() void CelView::on_firstGroupButton_clicked() { + // don't do anything if there's only one group + if (this->gfx->getGroupCount() == 1) + return; + this->on_firstFrameButton_clicked(); } void CelView::on_previousGroupButton_clicked() { + // don't do anything if there's only one group + if (this->gfx->getGroupCount() == 1) + return; + if (this->currentGroupIndex >= 1) this->currentGroupIndex--; else @@ -415,6 +423,10 @@ void CelView::on_groupIndexEdit_returnPressed() void CelView::on_nextGroupButton_clicked() { + // don't do anything if there's only one group + if (this->gfx->getGroupCount() == 1) + return; + if (this->currentGroupIndex < (this->gfx->getGroupCount() - 1)) this->currentGroupIndex++; else @@ -426,6 +438,10 @@ void CelView::on_nextGroupButton_clicked() void CelView::on_lastGroupButton_clicked() { + // don't do anything if there's only one group + if (this->gfx->getGroupCount() == 1) + return; + this->currentGroupIndex = std::max(0, this->gfx->getGroupCount() - 1); this->currentFrameIndex = this->gfx->getGroupFrameIndices(this->currentGroupIndex).first; this->displayFrame();