more clean-ups

This commit is contained in:
unK
2008-09-02 04:39:56 +02:00
parent 2f4463080a
commit 0f0bf11652
4 changed files with 62 additions and 57 deletions

View File

@@ -281,7 +281,7 @@ void Menu::Display(bool redraw_whole_window)
void Menu::Refresh(bool redraw_whole_window) void Menu::Refresh(bool redraw_whole_window)
{ {
if (!itsOptions.empty() && is_static()) if (!itsOptions.empty() && is_static())
itsHighlight == 0 ? Go(DOWN) : Go(UP); itsHighlight == 0 ? Go(wDown) : Go(wUp);
int MaxBeginning = itsOptions.size() < itsHeight ? 0 : itsOptions.size()-itsHeight; int MaxBeginning = itsOptions.size() < itsHeight ? 0 : itsOptions.size()-itsHeight;
if (itsBeginning > MaxBeginning) if (itsBeginning > MaxBeginning)
@@ -397,7 +397,7 @@ void Menu::Go(Where where)
scrollok(itsWindow, 1); scrollok(itsWindow, 1);
switch (where) switch (where)
{ {
case UP: case wUp:
{ {
if (itsHighlight <= itsBeginning && itsHighlight > 0) if (itsHighlight <= itsBeginning && itsHighlight > 0)
{ {
@@ -414,13 +414,13 @@ void Menu::Go(Where where)
if (is_static()) if (is_static())
{ {
if (itsHighlight == 0) if (itsHighlight == 0)
Go(DOWN); Go(wDown);
else else
Go(UP); Go(wUp);
} }
break; break;
} }
case DOWN: case wDown:
{ {
if (itsHighlight >= MaxCurrentHighlight && itsHighlight < MaxHighlight) if (itsHighlight >= MaxCurrentHighlight && itsHighlight < MaxHighlight)
{ {
@@ -437,13 +437,13 @@ void Menu::Go(Where where)
if (is_static()) if (is_static())
{ {
if (itsHighlight == MaxHighlight) if (itsHighlight == MaxHighlight)
Go(UP); Go(wUp);
else else
Go(DOWN); Go(wDown);
} }
break; break;
} }
case PAGE_UP: case wPageUp:
{ {
itsHighlight -= itsHeight; itsHighlight -= itsHeight;
itsBeginning -= itsHeight; itsBeginning -= itsHeight;
@@ -455,14 +455,14 @@ void Menu::Go(Where where)
if (is_static()) if (is_static())
{ {
if (itsHighlight == 0) if (itsHighlight == 0)
Go(DOWN); Go(wDown);
else else
Go(UP); Go(wUp);
} }
redraw_screen(); redraw_screen();
break; break;
} }
case PAGE_DOWN: case wPageDown:
{ {
itsHighlight += itsHeight; itsHighlight += itsHeight;
itsBeginning += itsHeight; itsBeginning += itsHeight;
@@ -474,37 +474,37 @@ void Menu::Go(Where where)
if (is_static()) if (is_static())
{ {
if (itsHighlight == MaxHighlight) if (itsHighlight == MaxHighlight)
Go(UP); Go(wUp);
else else
Go(DOWN); Go(wDown);
} }
redraw_screen(); redraw_screen();
break; break;
} }
case HOME: case wHome:
{ {
itsHighlight = 0; itsHighlight = 0;
itsBeginning = 0; itsBeginning = 0;
if (is_static()) if (is_static())
{ {
if (itsHighlight == 0) if (itsHighlight == 0)
Go(DOWN); Go(wDown);
else else
Go(UP); Go(wUp);
} }
redraw_screen(); redraw_screen();
break; break;
} }
case END: case wEnd:
{ {
itsHighlight = MaxHighlight; itsHighlight = MaxHighlight;
itsBeginning = MaxBeginning; itsBeginning = MaxBeginning;
if (is_static()) if (is_static())
{ {
if (itsHighlight == MaxHighlight) if (itsHighlight == MaxHighlight)
Go(UP); Go(wUp);
else else
Go(DOWN); Go(wDown);
} }
redraw_screen(); redraw_screen();
break; break;

View File

@@ -330,7 +330,7 @@ int main(int argc, char *argv[])
int footer_height = Config.statusbar_visibility ? 2 : 1; int footer_height = Config.statusbar_visibility ? 2 : 1;
wFooter = new Window(0, footer_start_y, COLS, footer_height, "", Config.statusbar_color, brNone); wFooter = new Window(0, footer_start_y, COLS, footer_height, "", Config.statusbar_color, brNone);
wFooter->GetGetStringHelper(TraceMpdStatus); wFooter->SetGetStringHelper(TraceMpdStatus);
wFooter->Display(); wFooter->Display();
wCurrent = mPlaylist; wCurrent = mPlaylist;
@@ -658,14 +658,14 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.Up)) while (Keypressed(input, Key.Up))
{ {
TraceMpdStatus(); TraceMpdStatus();
wCurrent->Go(UP); wCurrent->Go(wUp);
wCurrent->Refresh(); wCurrent->Refresh();
wCurrent->ReadKey(input); wCurrent->ReadKey(input);
} }
wCurrent->Timeout(ncmpcpp_window_timeout); wCurrent->Timeout(ncmpcpp_window_timeout);
} }
else else
wCurrent->Go(UP); wCurrent->Go(wUp);
} }
else if (Keypressed(input, Key.Down)) else if (Keypressed(input, Key.Down))
{ {
@@ -675,30 +675,30 @@ int main(int argc, char *argv[])
while (Keypressed(input, Key.Down)) while (Keypressed(input, Key.Down))
{ {
TraceMpdStatus(); TraceMpdStatus();
wCurrent->Go(DOWN); wCurrent->Go(wDown);
wCurrent->Refresh(); wCurrent->Refresh();
wCurrent->ReadKey(input); wCurrent->ReadKey(input);
} }
wCurrent->Timeout(ncmpcpp_window_timeout); wCurrent->Timeout(ncmpcpp_window_timeout);
} }
else else
wCurrent->Go(DOWN); wCurrent->Go(wDown);
} }
else if (Keypressed(input, Key.PageUp)) else if (Keypressed(input, Key.PageUp))
{ {
wCurrent->Go(PAGE_UP); wCurrent->Go(wPageUp);
} }
else if (Keypressed(input, Key.PageDown)) else if (Keypressed(input, Key.PageDown))
{ {
wCurrent->Go(PAGE_DOWN); wCurrent->Go(wPageDown);
} }
else if (Keypressed(input, Key.Home)) else if (Keypressed(input, Key.Home))
{ {
wCurrent->Go(HOME); wCurrent->Go(wHome);
} }
else if (Keypressed(input, Key.End)) else if (Keypressed(input, Key.End))
{ {
wCurrent->Go(END); wCurrent->Go(wEnd);
} }
else if (input == KEY_RESIZE) else if (input == KEY_RESIZE)
{ {
@@ -1139,8 +1139,8 @@ int main(int argc, char *argv[])
for (int i = 1; i <=13; i++) for (int i = 1; i <=13; i++)
mSearcher->MakeStatic(i, 1); mSearcher->MakeStatic(i, 1);
mSearcher->Go(DOWN); mSearcher->Go(wDown);
mSearcher->Go(DOWN); mSearcher->Go(wDown);
} }
else else
ShowMessage("No results found"); ShowMessage("No results found");
@@ -1230,7 +1230,7 @@ int main(int argc, char *argv[])
} }
FreeSongList(list); FreeSongList(list);
if (Keypressed(input, Key.Space)) if (Keypressed(input, Key.Space))
wCurrent->Go(DOWN); wCurrent->Go(wDown);
break; break;
} }
case csPlaylistEditor: case csPlaylistEditor:
@@ -1274,7 +1274,7 @@ int main(int argc, char *argv[])
} }
FreeSongList(list); FreeSongList(list);
if (Keypressed(input, Key.Space)) if (Keypressed(input, Key.Space))
wCurrent->Go(DOWN); wCurrent->Go(wDown);
break; break;
} }
default: default:
@@ -1290,7 +1290,7 @@ int main(int argc, char *argv[])
Menu *mCurrent = static_cast<Menu *>(wCurrent); Menu *mCurrent = static_cast<Menu *>(wCurrent);
int i = mCurrent->GetChoice(); int i = mCurrent->GetChoice();
mCurrent->Select(i, !mCurrent->Selected(i)); mCurrent->Select(i, !mCurrent->Selected(i));
mCurrent->Go(DOWN); mCurrent->Go(wDown);
} }
} }
else else
@@ -1343,7 +1343,7 @@ int main(int argc, char *argv[])
break; break;
} }
} }
mBrowser->Go(DOWN); mBrowser->Go(wDown);
} }
else if (current_screen == csSearcher && !vSearched.empty()) else if (current_screen == csSearcher && !vSearched.empty())
{ {
@@ -1354,7 +1354,7 @@ int main(int argc, char *argv[])
Song &s = *vSearched[id]; Song &s = *vSearched[id];
if (Mpd->AddSong(s) != -1) if (Mpd->AddSong(s) != -1)
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s)));
mSearcher->Go(DOWN); mSearcher->Go(wDown);
} }
else if (current_screen == csLibrary) else if (current_screen == csLibrary)
goto ENTER_LIBRARY_SCREEN; // sorry, but that's stupid to copy the same code here. goto ENTER_LIBRARY_SCREEN; // sorry, but that's stupid to copy the same code here.
@@ -1598,14 +1598,14 @@ int main(int argc, char *argv[])
{ {
if (!MoveSongUp(*it-1)) if (!MoveSongUp(*it-1))
{ {
mPlaylist->Go(DOWN); mPlaylist->Go(wDown);
break; break;
} }
} }
} }
else else
if (MoveSongUp(mPlaylist->GetChoice()-1)) if (MoveSongUp(mPlaylist->GetChoice()-1))
mPlaylist->Go(UP); mPlaylist->Go(wUp);
} }
else if (wCurrent == mPlaylistEditor) else if (wCurrent == mPlaylistEditor)
{ {
@@ -1618,14 +1618,14 @@ int main(int argc, char *argv[])
{ {
if (!PlaylistMoveSongUp(mPlaylistList->GetCurrentOption(), *it-1)) if (!PlaylistMoveSongUp(mPlaylistList->GetCurrentOption(), *it-1))
{ {
mPlaylistEditor->Go(DOWN); mPlaylistEditor->Go(wDown);
break; break;
} }
} }
} }
else else
if (PlaylistMoveSongUp(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1)) if (PlaylistMoveSongUp(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1))
mPlaylistEditor->Go(UP); mPlaylistEditor->Go(wUp);
} }
} }
else if (Keypressed(input, Key.MvSongDown)) else if (Keypressed(input, Key.MvSongDown))
@@ -1642,14 +1642,14 @@ int main(int argc, char *argv[])
{ {
if (!MoveSongDown(*it-1)) if (!MoveSongDown(*it-1))
{ {
mPlaylist->Go(UP); mPlaylist->Go(wUp);
break; break;
} }
} }
} }
else else
if (MoveSongDown(mPlaylist->GetChoice()-1)) if (MoveSongDown(mPlaylist->GetChoice()-1))
mPlaylist->Go(DOWN); mPlaylist->Go(wDown);
} }
else if (wCurrent == mPlaylistEditor) else if (wCurrent == mPlaylistEditor)
{ {
@@ -1662,14 +1662,14 @@ int main(int argc, char *argv[])
{ {
if (!PlaylistMoveSongDown(mPlaylistList->GetCurrentOption(), *it-1)) if (!PlaylistMoveSongDown(mPlaylistList->GetCurrentOption(), *it-1))
{ {
mPlaylistEditor->Go(UP); mPlaylistEditor->Go(wUp);
break; break;
} }
} }
} }
else else
if (PlaylistMoveSongDown(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1)) if (PlaylistMoveSongDown(mPlaylistList->GetCurrentOption(), mPlaylistEditor->GetChoice()-1))
mPlaylistEditor->Go(DOWN); mPlaylistEditor->Go(wDown);
} }
} }
else if (Keypressed(input, Key.Add)) else if (Keypressed(input, Key.Add))
@@ -1843,8 +1843,13 @@ int main(int argc, char *argv[])
{ {
GetDirectory(vSearched[mSearcher->GetChoice()-search_engine_static_option-1]->GetDirectory()); GetDirectory(vSearched[mSearcher->GetChoice()-search_engine_static_option-1]->GetDirectory());
for (int i = 1; i < mBrowser->MaxChoice(); i++) for (int i = 1; i < mBrowser->MaxChoice(); i++)
{
if (mSearcher->GetCurrentOption() == mBrowser->GetOption(i)) if (mSearcher->GetCurrentOption() == mBrowser->GetOption(i))
{
mBrowser->Highlight(i); mBrowser->Highlight(i);
break;
}
}
goto SWITCHER_BROWSER_REDIRECT; goto SWITCHER_BROWSER_REDIRECT;
} }
} }
@@ -1986,17 +1991,17 @@ int main(int argc, char *argv[])
mDialog->ReadKey(input); mDialog->ReadKey(input);
if (Keypressed(input, Key.Up)) if (Keypressed(input, Key.Up))
mDialog->Go(UP); mDialog->Go(wUp);
else if (Keypressed(input, Key.Down)) else if (Keypressed(input, Key.Down))
mDialog->Go(DOWN); mDialog->Go(wDown);
else if (Keypressed(input, Key.PageUp)) else if (Keypressed(input, Key.PageUp))
mDialog->Go(PAGE_UP); mDialog->Go(wPageUp);
else if (Keypressed(input, Key.PageDown)) else if (Keypressed(input, Key.PageDown))
mDialog->Go(PAGE_DOWN); mDialog->Go(wPageDown);
else if (Keypressed(input, Key.Home)) else if (Keypressed(input, Key.Home))
mDialog->Go(HOME); mDialog->Go(wHome);
else if (Keypressed(input, Key.End)) else if (Keypressed(input, Key.End))
mDialog->Go(END); mDialog->Go(wEnd);
} }
int id = mDialog->GetChoice(); int id = mDialog->GetChoice();

View File

@@ -162,34 +162,34 @@ void Scrollpad::Go(Where where)
switch (where) switch (where)
{ {
case UP: case wUp:
{ {
if (itsBeginning > 0) itsBeginning--; // for scrolling if (itsBeginning > 0) itsBeginning--; // for scrolling
break; break;
} }
case DOWN: case wDown:
{ {
if (itsBeginning < MaxBeginning) itsBeginning++; // scroll if (itsBeginning < MaxBeginning) itsBeginning++; // scroll
break; break;
} }
case PAGE_UP: case wPageUp:
{ {
itsBeginning -= itsHeight; itsBeginning -= itsHeight;
if (itsBeginning < 0) itsBeginning = 0; if (itsBeginning < 0) itsBeginning = 0;
break; break;
} }
case PAGE_DOWN: case wPageDown:
{ {
itsBeginning += itsHeight; itsBeginning += itsHeight;
if (itsBeginning > MaxBeginning) itsBeginning = MaxBeginning; if (itsBeginning > MaxBeginning) itsBeginning = MaxBeginning;
break; break;
} }
case HOME: case wHome:
{ {
itsBeginning = 0; itsBeginning = 0;
break; break;
} }
case END: case wEnd:
{ {
itsBeginning = MaxBeginning; itsBeginning = MaxBeginning;
break; break;

View File

@@ -41,7 +41,7 @@ using std::vector;
enum Color { clDefault, clBlack, clRed, clGreen, clYellow, clBlue, clMagenta, clCyan, clWhite }; enum Color { clDefault, clBlack, clRed, clGreen, clYellow, clBlue, clMagenta, clCyan, clWhite };
enum Border { brNone, brBlack, brRed, brGreen, brYellow, brBlue, brMagenta, brCyan, brWhite }; enum Border { brNone, brBlack, brRed, brGreen, brYellow, brBlue, brMagenta, brCyan, brWhite };
enum Where { UP, DOWN, PAGE_UP, PAGE_DOWN, HOME, END }; enum Where { wUp, wDown, wPageUp, wPageDown, wHome, wEnd };
typedef void (*GetStringHelper)(); typedef void (*GetStringHelper)();
typedef std::pair<Color, Color> ColorPair; typedef std::pair<Color, Color> ColorPair;
@@ -63,7 +63,7 @@ class Window
Window(const Window &); Window(const Window &);
virtual ~Window(); virtual ~Window();
virtual WINDOW *RawWin() { return itsWindow; } virtual WINDOW *RawWin() { return itsWindow; }
virtual void GetGetStringHelper(GetStringHelper helper) { itsGetStringHelper = helper; } virtual void SetGetStringHelper(GetStringHelper helper) { itsGetStringHelper = helper; }
virtual void SetColor(Color, Color = clDefault); virtual void SetColor(Color, Color = clDefault);
virtual void SetBaseColor(Color, Color = clDefault); virtual void SetBaseColor(Color, Color = clDefault);
virtual void SetBorder(Border); virtual void SetBorder(Border);