simplify Clear() in Window and its derivatives

it removes argument responsible for immediate refreshing.
since after all calls that were refreshing screen there was
call to Refresh() anyway, this switch doesn't make much sense.
This commit is contained in:
Andrzej Rybczak
2009-11-13 15:59:18 +01:00
parent b83adc01b9
commit 495ec25a0a
17 changed files with 53 additions and 62 deletions

View File

@@ -331,7 +331,7 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
if (w->at(i).type == itSong)
delete w->at(i).song;
w->Clear(0);
w->Clear();
if (dir != "/")
{

View File

@@ -125,7 +125,7 @@ void Info::GetSong()
myScreen = this;
RedrawHeader = 1;
itsTitle = "Song info";
w->Clear(0);
w->Clear();
PrepareSong(*s);
w->Window::Clear();
w->Flush();

View File

@@ -123,10 +123,10 @@ void MediaLibrary::SwitchTo()
{
hasTwoColumns = !hasTwoColumns;
hasToBeResized = 1;
Artists->Clear(0);
Albums->Clear(0);
Artists->Clear();
Albums->Clear();
Albums->Reset();
Songs->Clear(0);
Songs->Clear();
if (hasTwoColumns)
{
if (w == Artists)
@@ -161,8 +161,8 @@ void MediaLibrary::Update()
if (!hasTwoColumns && Artists->Empty())
{
TagList list;
Albums->Clear(0);
Songs->Clear(0);
Albums->Clear();
Songs->Clear();
Mpd.GetList(list, Config.media_lib_primary_tag);
sort(list.begin(), list.end(), CaseInsensitiveSorting());
for (TagList::iterator it = list.begin(); it != list.end(); ++it)
@@ -280,7 +280,7 @@ void MediaLibrary::Update()
Songs->Reset();
SongList list;
Songs->Clear(0);
Songs->Clear();
Mpd.StartSearch(1);
Mpd.AddSearch(Config.media_lib_primary_tag, hasTwoColumns ? Albums->Current().second.Artist : locale_to_utf_cpy(Artists->Current()));
if (Albums->Empty()) // left for compatibility with <mpd-0.14
@@ -351,8 +351,8 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
}
else
Screen<Window>::MouseButtonPressed(me);
Albums->Clear(0);
Songs->Clear(0);
Albums->Clear();
Songs->Clear();
}
else if (!Albums->Empty() && Albums->hasCoords(me.x, me.y))
{
@@ -371,7 +371,7 @@ void MediaLibrary::MouseButtonPressed(MEVENT me)
}
else
Screen<Window>::MouseButtonPressed(me);
Songs->Clear(0);
Songs->Clear();
}
else if (!Songs->Empty() && Songs->hasCoords(me.x, me.y))
{
@@ -507,11 +507,11 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
w->Scroll(wDown);
if (w == Artists)
{
Albums->Clear(0);
Songs->Clear(0);
Albums->Clear();
Songs->Clear();
}
else if (w == Albums)
Songs->Clear(0);
Songs->Clear();
}
}

View File

@@ -390,11 +390,9 @@ namespace NCurses
virtual void Scroll(Where where);
/// Cleares all options, used filters etc. It doesn't reset highlighted position though.
/// @param clear_screen indicates whether window has to be cleared imediately or not
/// @see Window::Clear()
/// @see Reset()
///
virtual void Clear(bool clear_screen = 1);
virtual void Clear();
/// Sets the highlighted position to 0
///
@@ -888,7 +886,7 @@ template <typename T> void NCurses::Menu<T>::ClearFiltered()
itsOptionsPtr = &itsOptions;
}
template <typename T> void NCurses::Menu<T>::Clear(bool clear_screen)
template <typename T> void NCurses::Menu<T>::Clear()
{
for (option_iterator it = itsOptions.begin(); it != itsOptions.end(); ++it)
delete *it;
@@ -897,8 +895,7 @@ template <typename T> void NCurses::Menu<T>::Clear(bool clear_screen)
itsFilter.clear();
ClearFiltered();
itsOptionsPtr = &itsOptions;
if (clear_screen)
Window::Clear();
Window::Clear();
}
template <typename T> bool NCurses::Menu<T>::isBold(int pos)

View File

@@ -161,7 +161,7 @@ void SelectedItemsAdder::EnterPressed()
if (myBrowser->Main() && !myBrowser->isLocal() && myBrowser->CurrentDir() == "/")
myBrowser->GetDirectory("/");
if (myPlaylistEditor->Main())
myPlaylistEditor->Playlists->Clear(0); // make playlist editor update itself
myPlaylistEditor->Playlists->Clear(); // make playlist editor update itself
}
MPD::FreeSongList(list);
SwitchTo();

View File

@@ -437,21 +437,21 @@ int main(int argc, char *argv[])
{
if (myScreen->ActiveWindow() == myLibrary->Artists)
{
myLibrary->Albums->Clear(0);
myLibrary->Songs->Clear(0);
myLibrary->Albums->Clear();
myLibrary->Songs->Clear();
}
else if (myScreen->ActiveWindow() == myLibrary->Albums)
{
myLibrary->Songs->Clear(0);
myLibrary->Songs->Clear();
}
else if (myScreen->ActiveWindow() == myPlaylistEditor->Playlists)
{
myPlaylistEditor->Content->Clear(0);
myPlaylistEditor->Content->Clear();
}
# ifdef HAVE_TAGLIB_H
else if (myScreen->ActiveWindow() == myTagEditor->LeftColumn)
{
myTagEditor->Tags->Clear(0);
myTagEditor->Tags->Clear();
myTagEditor->TagTypes->Refresh();
}
# endif // HAVE_TAGLIB_H
@@ -660,7 +660,7 @@ int main(int argc, char *argv[])
else
ShowMessage("Aborted!");
if (myPlaylistEditor->Main()) // check if initialized
myPlaylistEditor->Playlists->Clear(0); // make playlists list update itself
myPlaylistEditor->Playlists->Clear(); // make playlists list update itself
}
# ifndef WIN32
else if (myScreen == myBrowser && !myBrowser->Main()->Empty() && myBrowser->Main()->Current().type != itPlaylist)
@@ -802,7 +802,7 @@ int main(int argc, char *argv[])
{
ShowMessage("Playlist saved as: %s", playlist_name.c_str());
if (myPlaylistEditor->Main()) // check if initialized
myPlaylistEditor->Playlists->Clear(0); // make playlist's list update itself
myPlaylistEditor->Playlists->Clear(); // make playlist's list update itself
}
else
{
@@ -826,7 +826,7 @@ int main(int argc, char *argv[])
else
ShowMessage("Aborted!");
if (myPlaylistEditor->Main()) // check if initialized
myPlaylistEditor->Playlists->Clear(0); // make playlist's list update itself
myPlaylistEditor->Playlists->Clear(); // make playlist's list update itself
if (myScreen == myPlaylist)
myPlaylist->EnableHighlighting();
}
@@ -1156,7 +1156,7 @@ int main(int argc, char *argv[])
if (myScreen == myPlaylistEditor)
{
Mpd.AddToPlaylist(myPlaylistEditor->Playlists->Current(), path);
myPlaylistEditor->Content->Clear(0); // make it refetch content of playlist
myPlaylistEditor->Content->Clear(); // make it refetch content of playlist
}
else
Mpd.Add(path);
@@ -1561,7 +1561,7 @@ int main(int argc, char *argv[])
if (myBrowser->Main() && !myBrowser->isLocal())
myBrowser->GetDirectory("/");
if (myPlaylistEditor->Main())
myPlaylistEditor->Playlists->Clear(0);
myPlaylistEditor->Playlists->Clear();
}
}
}
@@ -1722,7 +1722,7 @@ int main(int argc, char *argv[])
if (myScreen->ActiveWindow() == myPlaylistEditor->Content)
{
Mpd.ClearPlaylist(locale_to_utf_cpy(myPlaylistEditor->Playlists->Current()));
myPlaylistEditor->Content->Clear(0);
myPlaylistEditor->Content->Clear();
}
else
{
@@ -1901,7 +1901,7 @@ int main(int argc, char *argv[])
ToLower(item_type);
if (myLibrary->Columns() == 2)
{
myLibrary->Songs->Clear(0);
myLibrary->Songs->Clear();
myLibrary->Albums->Reset();
myLibrary->Albums->Clear();
myLibrary->Albums->SetTitle("Albums (sorted by " + item_type + ")");
@@ -1909,7 +1909,7 @@ int main(int argc, char *argv[])
}
else
{
myLibrary->Artists->Clear(0);
myLibrary->Artists->Clear();
myLibrary->Artists->Display();
}
ShowMessage("Switched to list of %s tag", item_type.c_str());

View File

@@ -103,7 +103,7 @@ void Outputs::FetchList()
return;
MPD::OutputList ol;
Mpd.GetOutputs(ol);
w->Clear(0);
w->Clear();
for (MPD::OutputList::const_iterator it = ol.begin(); it != ol.end(); ++it)
w->AddOption(*it, it->second);
if (myScreen == this)

View File

@@ -112,7 +112,7 @@ void PlaylistEditor::Update()
{
if (Playlists->Empty())
{
Content->Clear(0);
Content->Clear();
TagList list;
Mpd.GetPlaylists(list);
sort(list.begin(), list.end(), CaseInsensitiveSorting());
@@ -237,7 +237,7 @@ void PlaylistEditor::MouseButtonPressed(MEVENT me)
}
else
Screen<Window>::MouseButtonPressed(me);
Content->Clear(0);
Content->Clear();
}
else if (!Content->Empty() && Content->hasCoords(me.x, me.y))
{

View File

@@ -181,7 +181,7 @@ void Scrollpad::Scroll(Where where)
}
}
void Scrollpad::Clear(bool clear_screen)
void Scrollpad::Clear()
{
itsRealHeight = itsHeight;
itsBuffer.Clear();
@@ -192,8 +192,6 @@ void Scrollpad::Clear(bool clear_screen)
SetColor(itsColor, itsBgColor);
ForgetFormatting();
keypad(itsWindow, 1);
if (clear_screen)
Refresh();
}
void Scrollpad::Reset()

View File

@@ -102,10 +102,9 @@ namespace NCurses
virtual void Resize(size_t new_width, size_t new_height);
/// Cleares the content of scrollpad
/// @param clear_screen indicates whether window has to be cleared imediately or not
/// @see Window::Clear()
///
virtual void Clear(bool clear_screen = 1);
virtual void Clear();
/// Sets starting position to the beginning
///

View File

@@ -268,7 +268,7 @@ void SearchEngine::Prepare()
}
w->SetTitle("");
w->Clear(0);
w->Clear();
w->ResizeList(17);
w->IntoSeparator(10);

View File

@@ -96,7 +96,7 @@ void ServerInfo::Update()
time(&now);
Mpd.UpdateStats();
w->Clear(0);
w->Clear();
*w << fmtBold << U("Version: ") << fmtBoldEnd << U("0.") << std::fixed << std::setprecision(1) << Mpd.Version() << '\n';
*w << fmtBold << U("Uptime: ") << fmtBoldEnd;

View File

@@ -249,7 +249,7 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
if (myPlaylist->Items->Empty())
{
myPlaylist->Items->Reset();
myPlaylist->Items->Window::Clear(0);
myPlaylist->Items->Window::Clear();
ShowMessage("Cleared playlist!");
}
@@ -280,13 +280,13 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
if (myScreen == myBrowser)
myBrowser->GetDirectory(myBrowser->CurrentDir());
else
myBrowser->Main()->Clear(0);
myBrowser->Main()->Clear();
}
# ifdef HAVE_TAGLIB_H
if (myTagEditor->Main())
{
myTagEditor->Albums->Clear(0);
myTagEditor->Dirs->Clear(0);
myTagEditor->Albums->Clear();
myTagEditor->Dirs->Clear();
}
# endif // HAVE_TAGLIB_H
if (myLibrary->Main())
@@ -294,13 +294,13 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *)
if (myLibrary->Columns() == 2)
{
myLibrary->Albums->Clear();
myLibrary->Songs->Clear(0);
myLibrary->Songs->Clear();
}
else
myLibrary->Artists->Clear(0);
myLibrary->Artists->Clear();
}
if (myPlaylistEditor->Main())
myPlaylistEditor->Content->Clear(0);
myPlaylistEditor->Content->Clear();
}
if (changed.PlayerState)
{

View File

@@ -323,7 +323,7 @@ void TagEditor::EnterPressed()
{
itsHighlightedDir = itsBrowsedDir;
itsBrowsedDir = LeftColumn->Current().second;
LeftColumn->Clear(0);
LeftColumn->Clear();
LeftColumn->Reset();
}
else
@@ -600,7 +600,7 @@ void TagEditor::EnterPressed()
}
case 11: // reset
{
Tags->Clear(0);
Tags->Clear();
ShowMessage("Changes reset");
return;
}
@@ -630,7 +630,7 @@ void TagEditor::EnterPressed()
Mpd.UpdateDirectory(locale_to_utf_cpy(FindSharedDir(Tags)));
}
else
Tags->Clear(0);
Tags->Clear();
return;
}
case 13: // capitalize first letters
@@ -689,7 +689,7 @@ void TagEditor::SpacePressed()
w = LeftColumn = Config.albums_in_tag_editor ? Albums : Dirs;
ShowMessage("Switched to %s view", Config.albums_in_tag_editor ? "albums" : "directories");
LeftColumn->Display();
Tags->Clear(0);
Tags->Clear();
}
void TagEditor::MouseButtonPressed(MEVENT me)
@@ -747,7 +747,7 @@ void TagEditor::MouseButtonPressed(MEVENT me)
}
else
Screen<Window>::MouseButtonPressed(me);
Tags->Clear(0);
Tags->Clear();
}
else if (!TagTypes->Empty() && TagTypes->hasCoords(me.x, me.y))
{

View File

@@ -120,7 +120,7 @@ void Visualizer::Update()
if (data < 0) // no data available in fifo
return;
w->Clear(0);
w->Clear();
# ifdef HAVE_FFTW3_H
Config.visualizer_use_wave ? DrawSoundWave(buf, data) : DrawFrequencySpectrum(buf, data);
# else

View File

@@ -318,11 +318,9 @@ void Window::Refresh()
prefresh(itsWindow, 0, 0, itsStartY, itsStartX, itsStartY+itsHeight-1, itsStartX+itsWidth-1);
}
void Window::Clear(bool refresh)
void Window::Clear()
{
werase(itsWindow);
if (refresh)
Window::Refresh();
}
void Window::Hide(char ch) const

View File

@@ -343,9 +343,8 @@ namespace NCurses
virtual void Resize(size_t new_width, size_t new_height);
/// Cleares the window
/// @param refresh indicates whether window has to be refreshed immediately or not
///
virtual void Clear(bool refresh = 1);
virtual void Clear();
/// Adds given file descriptor to the list that will be polled in
/// ReadKey() along with stdin and callback that will be invoked