Fixed bug with track folding

This commit is contained in:
Daniel Collin 2013-06-29 23:26:08 +02:00
parent 7319e6a8ca
commit 9f75f7e81f

View File

@ -194,57 +194,85 @@ static inline void setRowPos(int pos)
static int getNextTrack() static int getNextTrack()
{ {
Group* group;
TrackData* trackData = getTrackData(); TrackData* trackData = getTrackData();
int i, track_count = getTrackCount(); int groupIndex = 0;
int active_track = getActiveTrack(); int groupTrackCount = 0;
int currentTrack = getActiveTrack();
for (i = active_track + 1; i < track_count; ++i) // Get the group for the currentTrack
Track* track = &trackData->tracks[currentTrack];
group = track->group;
groupTrackCount = group->trackCount;
// Check If next track is within the group
if (!group->folded)
{ {
Track* t = &trackData->tracks[i]; if (track->groupIndex + 1 < group->trackCount)
return group->t.tracks[track->groupIndex + 1]->index;
// if track has no group its always safe to assume that can select the track
if (!t->group)
return i;
if (!t->group->folded)
return i;
// if the track is the first in the group (and group is folded) we use that as the display track
if (t->group->t.tracks[0] == t)
return i;
} }
return active_track; groupIndex = group->groupIndex;
// We are at the last track in the last group so just return the current one
if (groupIndex >= trackData->groupCount-1)
return currentTrack;
// Get the next group and select the first track in it
group = &trackData->groups[groupIndex + 1];
if (group->trackCount == 1)
return group->t.track->index;
else
return group->t.tracks[0]->index;
return 0;
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int getPrevTrack() static int getPrevTrack()
{ {
Group* group;
TrackData* trackData = getTrackData(); TrackData* trackData = getTrackData();
int i, active_track = getActiveTrack(); int trackIndex = 0;
int groupIndex = 0;
int groupTrackCount = 0;
int currentTrack = getActiveTrack();
for (i = active_track - 1; i >= 0; --i) // Get the group for the currentTrack
{
Track* t = &trackData->tracks[i];
// if track has no group its always safe to assume that can select the track Track* track = &trackData->tracks[currentTrack];
group = track->group;
groupTrackCount = group->trackCount;
if (!trackData->tracks[i].group) // Check If next track is within the group
return i;
if (!trackData->tracks[i].group->folded) if (track->groupIndex - 1 >= 0)
return i; return group->t.tracks[track->groupIndex - 1]->index;
// if the track is the first in the group (and group is folded) we use that as the display track groupIndex = group->groupIndex - 1;
if (t->group->t.tracks[0] == t) // We are at the last track in the last group so just return the current one
return i;
}
return active_track; if (groupIndex < 0)
return currentTrack;
// Get the next group and select the first track in it
group = &trackData->groups[groupIndex];
trackIndex = group->folded ? 0 : group->trackCount - 1;
if (group->trackCount == 1)
return group->t.track->index;
else
return group->t.tracks[trackIndex]->index;
return 0;
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////