Skip to content

Commit

Permalink
Fix: Don't reset frame count upon click if there's only 1 frame group
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tetektoza authored and AJenbo committed Oct 22, 2023
1 parent e4127fd commit cb87ed0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/celview.cpp
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit cb87ed0

Please sign in to comment.