check properly in MouseButtonPressed if switching columns is allowed

This commit is contained in:
Andrzej Rybczak
2012-09-13 17:46:35 +02:00
parent 382e4c0177
commit 31b06470d1
3 changed files with 93 additions and 25 deletions

View File

@@ -410,13 +410,32 @@ void MediaLibrary::SpacePressed()
void MediaLibrary::MouseButtonPressed(MEVENT me)
{
if (!Tags->empty() && Tags->hasCoords(me.x, me.y))
auto tryNextColumn = [this]() -> bool {
bool result = true;
if (w != Songs)
{
if (isNextColumnAvailable())
NextColumn();
else
result = false;
}
return result;
};
auto tryPreviousColumn = [this]() -> bool {
bool result = true;
if (w != Tags)
{
if (isPrevColumnAvailable())
PrevColumn();
PrevColumn();
else
result = false;
}
return result;
};
if (!Tags->empty() && Tags->hasCoords(me.x, me.y))
{
if (!tryPreviousColumn() || !tryPreviousColumn())
return;
if (size_t(me.y) < Tags->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
Tags->Goto(me.y);
@@ -436,7 +455,15 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
else if (!Albums->empty() && Albums->hasCoords(me.x, me.y))
{
if (w != Albums)
w == Tags ? NextColumn() : PrevColumn();
{
bool success;
if (w == Tags)
success = tryNextColumn();
else
success = tryPreviousColumn();
if (!success)
return;
}
if (size_t(me.y) < Albums->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
Albums->Goto(me.y);
@@ -454,11 +481,8 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
}
else if (!Songs->empty() && Songs->hasCoords(me.x, me.y))
{
if (w != Songs)
{
NextColumn();
NextColumn();
}
if (!tryNextColumn() || !tryNextColumn())
return;
if (size_t(me.y) < Songs->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
Songs->Goto(me.y);

View File

@@ -327,7 +327,12 @@ void PlaylistEditor::MouseButtonPressed(MEVENT me)
if (!Playlists->empty() && Playlists->hasCoords(me.x, me.y))
{
if (w != Playlists)
{
if (isPrevColumnAvailable())
PrevColumn();
else
return;
}
if (size_t(me.y) < Playlists->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
Playlists->Goto(me.y);
@@ -346,7 +351,12 @@ void PlaylistEditor::MouseButtonPressed(MEVENT me)
else if (!Content->empty() && Content->hasCoords(me.x, me.y))
{
if (w != Content)
{
if (isNextColumnAvailable())
NextColumn();
else
return;
}
if (size_t(me.y) < Content->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
Content->Goto(me.y);

View File

@@ -642,6 +642,28 @@ void TagEditor::SpacePressed()
void TagEditor::MouseButtonPressed(MEVENT me)
{
auto tryPreviousColumn = [this]() -> bool {
bool result = true;
if (w != Dirs)
{
if (isPrevColumnAvailable())
PrevColumn();
else
result = false;
}
return result;
};
auto tryNextColumn = [this]() -> bool {
bool result = true;
if (w != Tags)
{
if (isNextColumnAvailable())
NextColumn();
else
result = false;
}
return result;
};
if (w == FParserDialog)
{
if (FParserDialog->hasCoords(me.x, me.y))
@@ -661,7 +683,12 @@ void TagEditor::MouseButtonPressed(MEVENT me)
if (FParser->hasCoords(me.x, me.y))
{
if (w != FParser)
{
if (isPrevColumnAvailable())
PrevColumn();
else
return;
}
if (size_t(me.y) < FParser->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
FParser->Goto(me.y);
@@ -674,17 +701,19 @@ void TagEditor::MouseButtonPressed(MEVENT me)
else if (FParserHelper->hasCoords(me.x, me.y))
{
if (w != FParserHelper)
{
if (isNextColumnAvailable())
NextColumn();
else
return;
}
ScrollpadMouseButtonPressed(FParserHelper, me);
}
}
else if (!Dirs->empty() && Dirs->hasCoords(me.x, me.y))
{
if (w != Dirs)
{
PrevColumn();
PrevColumn();
}
if (!tryPreviousColumn() || !tryPreviousColumn())
return;
if (size_t(me.y) < Dirs->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
Dirs->Goto(me.y);
@@ -700,7 +729,15 @@ void TagEditor::MouseButtonPressed(MEVENT me)
else if (!TagTypes->empty() && TagTypes->hasCoords(me.x, me.y))
{
if (w != TagTypes)
w == Dirs ? NextColumn() : PrevColumn();
{
bool success;
if (w == Dirs)
success = tryNextColumn();
else
success = tryPreviousColumn();
if (!success)
return;
}
if (size_t(me.y) < TagTypes->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
if (!TagTypes->Goto(me.y))
@@ -715,11 +752,8 @@ void TagEditor::MouseButtonPressed(MEVENT me)
}
else if (!Tags->empty() && Tags->hasCoords(me.x, me.y))
{
if (w != Tags)
{
NextColumn();
NextColumn();
}
if (!tryNextColumn() || !tryNextColumn())
return;
if (size_t(me.y) < Tags->size() && (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED)))
{
Tags->Goto(me.y);