global: remove RedrawHeader

This commit is contained in:
Andrzej Rybczak
2012-09-06 16:49:47 +02:00
parent f0cac617fa
commit c935dcf11a
20 changed files with 53 additions and 64 deletions

View File

@@ -127,7 +127,6 @@ void Action::SetResizeFlags()
void Action::ResizeScreen() void Action::ResizeScreen()
{ {
using Global::MainHeight; using Global::MainHeight;
using Global::RedrawHeader;
using Global::RedrawStatusbar; using Global::RedrawStatusbar;
using Global::wHeader; using Global::wHeader;
using Global::wFooter; using Global::wFooter;
@@ -152,7 +151,6 @@ void Action::ResizeScreen()
} }
# endif # endif
RedrawHeader = true;
MainHeight = LINES-(Config.new_design ? 7 : 4); MainHeight = LINES-(Config.new_design ? 7 : 4);
ValidateScreenSize(); ValidateScreenSize();
@@ -194,6 +192,7 @@ void Action::ResizeScreen()
DesignChanged = 0; DesignChanged = 0;
ShowMessage("User interface: %s", Config.new_design ? "Alternative" : "Classic"); ShowMessage("User interface: %s", Config.new_design ? "Alternative" : "Classic");
} }
DrawHeader();
wFooter->refresh(); wFooter->refresh();
refresh(); refresh();
} }
@@ -737,11 +736,10 @@ void MasterScreen::Run()
{ {
using Global::myInactiveScreen; using Global::myInactiveScreen;
using Global::myLockedScreen; using Global::myLockedScreen;
using Global::RedrawHeader;
myInactiveScreen = myScreen; myInactiveScreen = myScreen;
myScreen = myLockedScreen; myScreen = myLockedScreen;
RedrawHeader = true; DrawHeader();
} }
bool SlaveScreen::canBeRun() const bool SlaveScreen::canBeRun() const
@@ -759,11 +757,10 @@ void SlaveScreen::Run()
{ {
using Global::myInactiveScreen; using Global::myInactiveScreen;
using Global::myLockedScreen; using Global::myLockedScreen;
using Global::RedrawHeader;
myScreen = myInactiveScreen; myScreen = myInactiveScreen;
myInactiveScreen = myLockedScreen; myInactiveScreen = myLockedScreen;
RedrawHeader = true; DrawHeader();
} }
void VolumeUp::Run() void VolumeUp::Run()
@@ -1229,15 +1226,13 @@ bool JumpToPlayingSong::canBeRun() const
void JumpToPlayingSong::Run() void JumpToPlayingSong::Run()
{ {
using Global::RedrawHeader;
if (myScreen == myPlaylist) if (myScreen == myPlaylist)
myPlaylist->Items->highlight(myPlaylist->NowPlaying); myPlaylist->Items->highlight(myPlaylist->NowPlaying);
else if (myScreen == myBrowser) else if (myScreen == myBrowser)
{ {
const MPD::Song *s = myPlaylist->NowPlayingSong(); const MPD::Song *s = myPlaylist->NowPlayingSong();
myBrowser->LocateSong(*s); myBrowser->LocateSong(*s);
RedrawHeader = true; DrawHeader();
} }
else if (myScreen == myLibrary) else if (myScreen == myLibrary)
{ {
@@ -1882,7 +1877,6 @@ bool ApplyFilter::canBeRun() const
void ApplyFilter::Run() void ApplyFilter::Run()
{ {
using Global::RedrawHeader;
using Global::wFooter; using Global::wFooter;
Filterable *f = dynamic_cast<Filterable *>(myScreen); Filterable *f = dynamic_cast<Filterable *>(myScreen);
@@ -1908,7 +1902,7 @@ void ApplyFilter::Run()
{ {
myPlaylist->EnableHighlighting(); myPlaylist->EnableHighlighting();
Playlist::ReloadTotalLength = true; Playlist::ReloadTotalLength = true;
RedrawHeader = true; DrawHeader();
} }
ListsChangeFinisher(); ListsChangeFinisher();
} }

View File

@@ -40,7 +40,6 @@ using namespace std::placeholders;
using Global::MainHeight; using Global::MainHeight;
using Global::MainStartY; using Global::MainStartY;
using Global::myScreen; using Global::myScreen;
using Global::RedrawHeader;
using MPD::itDirectory; using MPD::itDirectory;
using MPD::itSong; using MPD::itSong;
@@ -116,7 +115,7 @@ void Browser::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
RedrawHeader = true; DrawHeader();
} }
std::basic_string<my_char_t> Browser::Title() std::basic_string<my_char_t> Browser::Title()
@@ -146,7 +145,7 @@ void Browser::EnterPressed()
} }
else else
GetDirectory(item.name, itsBrowsedDir); GetDirectory(item.name, itsBrowsedDir);
RedrawHeader = true; DrawHeader();
break; break;
} }
case itSong: case itSong:
@@ -236,7 +235,7 @@ void Browser::MouseButtonPressed(MEVENT me)
if (me.bstate & BUTTON1_PRESSED) if (me.bstate & BUTTON1_PRESSED)
{ {
GetDirectory(w->current().value().name); GetDirectory(w->current().value().name);
RedrawHeader = true; DrawHeader();
} }
else else
{ {
@@ -574,7 +573,7 @@ void Browser::ChangeBrowseMode()
itsBrowsedDir.resize(itsBrowsedDir.length()-1); itsBrowsedDir.resize(itsBrowsedDir.length()-1);
w->reset(); w->reset();
GetDirectory(itsBrowsedDir); GetDirectory(itsBrowsedDir);
RedrawHeader = true; DrawHeader();
} }
bool Browser::deleteItem(const MPD::Item &item) bool Browser::deleteItem(const MPD::Item &item)

View File

@@ -102,7 +102,7 @@ void Clock::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
Global::RedrawHeader = true; DrawHeader();
Prepare(); Prepare();
itsPane->refresh(); itsPane->refresh();
// clearing screen apparently fixes the problem with last digits being misrendered // clearing screen apparently fixes the problem with last digits being misrendered

View File

@@ -35,7 +35,6 @@ size_t Global::MainHeight;
bool Global::ShowMessages = false; bool Global::ShowMessages = false;
bool Global::SeekingInProgress = false; bool Global::SeekingInProgress = false;
bool Global::RedrawHeader = true;
bool Global::RedrawStatusbar = true; bool Global::RedrawStatusbar = true;
std::string Global::VolumeState; std::string Global::VolumeState;

View File

@@ -61,9 +61,6 @@ namespace Global
// indicates whether seeking action in currently in progress // indicates whether seeking action in currently in progress
extern bool SeekingInProgress; extern bool SeekingInProgress;
// indicates whether header should be immediately repainted
extern bool RedrawHeader;
// indicates whether statusbar should be immediately repainted // indicates whether statusbar should be immediately repainted
extern bool RedrawStatusbar; extern bool RedrawStatusbar;

View File

@@ -24,6 +24,7 @@
#include "global.h" #include "global.h"
#include "help.h" #include "help.h"
#include "settings.h" #include "settings.h"
#include "status.h"
using Global::MainHeight; using Global::MainHeight;
using Global::MainStartY; using Global::MainStartY;
@@ -129,8 +130,7 @@ void Help::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
Global::RedrawHeader = true; DrawHeader();
} }
std::basic_string<my_char_t> Help::Title() std::basic_string<my_char_t> Help::Title()

View File

@@ -105,8 +105,7 @@ void Lastfm::SwitchTo()
myOldScreen = myScreen; myOldScreen = myScreen;
myScreen = this; myScreen = this;
DrawHeader();
Global::RedrawHeader = true;
} }
void Lastfm::Load() void Lastfm::Load()

View File

@@ -80,7 +80,7 @@ void Lyrics::Update()
const MPD::Song *s = myPlaylist->NowPlayingSong(); const MPD::Song *s = myPlaylist->NowPlayingSong();
if (s && !s->getArtist().empty() && !s->getTitle().empty()) if (s && !s->getArtist().empty() && !s->getTitle().empty())
{ {
Global::RedrawHeader = true; DrawHeader();
itsScrollBegin = 0; itsScrollBegin = 0;
itsSong = *s; itsSong = *s;
Load(); Load();
@@ -129,7 +129,7 @@ void Lyrics::SwitchTo()
itsSong = *s; itsSong = *s;
Load(); Load();
Global::RedrawHeader = true; DrawHeader();
} }
else else
{ {

View File

@@ -205,7 +205,7 @@ void MediaLibrary::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
Global::RedrawHeader = true; DrawHeader();
markSongsInPlaylist(songsProxyList()); markSongsInPlaylist(songsProxyList());
Refresh(); Refresh();
} }

View File

@@ -84,7 +84,6 @@ int main(int argc, char **argv)
using Global::wHeader; using Global::wHeader;
using Global::wFooter; using Global::wFooter;
using Global::RedrawHeader;
using Global::ShowMessages; using Global::ShowMessages;
using Global::VolumeState; using Global::VolumeState;
using Global::Timer; using Global::Timer;
@@ -237,32 +236,10 @@ int main(int argc, char **argv)
&& (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics) && (myScreen == myPlaylist || myScreen == myBrowser || myScreen == myLyrics)
) )
{ {
RedrawHeader = true; DrawHeader();
gettimeofday(&past, 0); gettimeofday(&past, 0);
} }
if (Config.header_visibility && RedrawHeader)
{
if (Config.new_design)
{
std::basic_string<my_char_t> title = myScreen->Title();
*wHeader << NC::XY(0, 3) << wclrtoeol;
*wHeader << NC::fmtBold << Config.alternative_ui_separator_color;
mvwhline(wHeader->raw(), 2, 0, 0, COLS);
mvwhline(wHeader->raw(), 4, 0, 0, COLS);
*wHeader << NC::XY((COLS-NC::Window::length(title))/2, 3);
*wHeader << Config.header_color << title << NC::clEnd;
*wHeader << NC::clEnd << NC::fmtBoldEnd;
}
else
{
*wHeader << NC::XY(0, 0) << wclrtoeol << NC::fmtBold << myScreen->Title() << NC::fmtBoldEnd;
*wHeader << Config.volume_color;
*wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << VolumeState;
*wHeader << NC::clEnd;
}
wHeader->refresh();
RedrawHeader = false;
}
// header stuff end // header stuff end
if (input != Key::noOp) if (input != Key::noOp)

View File

@@ -65,8 +65,7 @@ void Outputs::SwitchTo()
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
w->Window::clear(); w->Window::clear();
DrawHeader();
Global::RedrawHeader = true;
} }
void Outputs::Resize() void Outputs::Resize()

View File

@@ -121,7 +121,7 @@ void Playlist::SwitchTo()
EnableHighlighting(); EnableHighlighting();
if (w != Items) // even if sorting window is active, background has to be refreshed anyway if (w != Items) // even if sorting window is active, background has to be refreshed anyway
Items->display(); Items->display();
Global::RedrawHeader = true; DrawHeader();
} }
void Playlist::Resize() void Playlist::Resize()

View File

@@ -132,7 +132,7 @@ void PlaylistEditor::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
Global::RedrawHeader = true; DrawHeader();
markSongsInPlaylist(contentProxyList()); markSongsInPlaylist(contentProxyList());
Refresh(); Refresh();
} }

View File

@@ -148,8 +148,7 @@ void SearchEngine::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
Global::RedrawHeader = true; DrawHeader();
markSongsInPlaylist(getProxySongList()); markSongsInPlaylist(getProxySongList());
} }

View File

@@ -93,8 +93,7 @@ void SongInfo::SwitchTo()
myOldScreen = myScreen; myOldScreen = myScreen;
myScreen = this; myScreen = this;
DrawHeader();
Global::RedrawHeader = true;
w->clear(); w->clear();
w->reset(); w->reset();

View File

@@ -643,6 +643,31 @@ void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges changed, void *)
ApplyToVisibleWindows(&BasicScreen::RefreshWindow); ApplyToVisibleWindows(&BasicScreen::RefreshWindow);
} }
void DrawHeader()
{
if (!Config.header_visibility)
return;
if (Config.new_design)
{
std::basic_string<my_char_t> title = myScreen->Title();
*wHeader << NC::XY(0, 3) << wclrtoeol;
*wHeader << NC::fmtBold << Config.alternative_ui_separator_color;
mvwhline(wHeader->raw(), 2, 0, 0, COLS);
mvwhline(wHeader->raw(), 4, 0, 0, COLS);
*wHeader << NC::XY((COLS-NC::Window::length(title))/2, 3);
*wHeader << Config.header_color << title << NC::clEnd;
*wHeader << NC::clEnd << NC::fmtBoldEnd;
}
else
{
*wHeader << NC::XY(0, 0) << wclrtoeol << NC::fmtBold << myScreen->Title() << NC::fmtBoldEnd;
*wHeader << Config.volume_color;
*wHeader << NC::XY(wHeader->getWidth()-VolumeState.length(), 0) << VolumeState;
*wHeader << NC::clEnd;
}
wHeader->refresh();
}
NC::Window &Statusbar() NC::Window &Statusbar()
{ {
*wFooter << NC::XY(0, Config.statusbar_visibility) << wclrtoeol; *wFooter << NC::XY(0, Config.statusbar_visibility) << wclrtoeol;

View File

@@ -40,6 +40,8 @@ void TraceMpdStatus();
void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges, void *); void NcmpcppStatusChanged(MPD::Connection *, MPD::StatusChanges, void *);
void NcmpcppErrorCallback(MPD::Connection *, int, const char *, void *); void NcmpcppErrorCallback(MPD::Connection *, int, const char *, void *);
void DrawHeader();
NC::Window &Statusbar(); NC::Window &Statusbar();
void DrawProgressbar(unsigned elapsed, unsigned time); void DrawProgressbar(unsigned elapsed, unsigned time);
void ShowMessage(const char *, ...) GNUC_PRINTF(1, 2); void ShowMessage(const char *, ...) GNUC_PRINTF(1, 2);

View File

@@ -225,7 +225,7 @@ void TagEditor::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
Global::RedrawHeader = true; DrawHeader();
Refresh(); Refresh();
} }

View File

@@ -82,7 +82,7 @@ void TinyTagEditor::SwitchTo()
myOldScreen = myScreen; myOldScreen = myScreen;
myScreen = this; myScreen = this;
Global::RedrawHeader = true; DrawHeader();
} }
else else
{ {

View File

@@ -81,6 +81,7 @@ void Visualizer::SwitchTo()
if (myScreen != this && myScreen->isTabbable()) if (myScreen != this && myScreen->isTabbable())
Global::myPrevScreen = myScreen; Global::myPrevScreen = myScreen;
myScreen = this; myScreen = this;
DrawHeader();
w->clear(); w->clear();
SetFD(); SetFD();
@@ -90,7 +91,6 @@ void Visualizer::SwitchTo()
if (itsFifo >= 0) if (itsFifo >= 0)
Global::wFooter->setTimeout(WindowTimeout); Global::wFooter->setTimeout(WindowTimeout);
Global::RedrawHeader = true;
} }
void Visualizer::Resize() void Visualizer::Resize()