make remaining single-windowed screens' main windows non-pointer
This commit is contained in:
@@ -1282,7 +1282,7 @@ void SaveTagChanges::Run()
|
|||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
if (myScreen == myTinyTagEditor)
|
if (myScreen == myTinyTagEditor)
|
||||||
{
|
{
|
||||||
myTinyTagEditor->main()->highlight(myTinyTagEditor->main()->size()-2); // Save
|
myTinyTagEditor->main().highlight(myTinyTagEditor->main().size()-2); // Save
|
||||||
myTinyTagEditor->enterPressed();
|
myTinyTagEditor->enterPressed();
|
||||||
}
|
}
|
||||||
else if (myScreen->activeWindow() == myTagEditor->TagTypes)
|
else if (myScreen->activeWindow() == myTagEditor->TagTypes)
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ Clock::Clock()
|
|||||||
{
|
{
|
||||||
Width = Config.clock_display_seconds ? 60 : 40;
|
Width = Config.clock_display_seconds ? 60 : 40;
|
||||||
|
|
||||||
itsPane = new NC::Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
m_pane = NC::Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||||
w = new NC::Window((COLS-Width)/2, (MainHeight-Height)/2+MainStartY, Width, Height-1, "", Config.main_color, NC::Border(Config.main_color));
|
w = NC::Window((COLS-Width)/2, (MainHeight-Height)/2+MainStartY, Width, Height-1, "", Config.main_color, NC::Border(Config.main_color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clock::resize()
|
void Clock::resize()
|
||||||
@@ -66,12 +66,12 @@ void Clock::resize()
|
|||||||
getWindowResizeParams(x_offset, width);
|
getWindowResizeParams(x_offset, width);
|
||||||
|
|
||||||
// used for clearing area out of clock window while resizing terminal
|
// used for clearing area out of clock window while resizing terminal
|
||||||
itsPane->resize(width, MainHeight);
|
m_pane.resize(width, MainHeight);
|
||||||
itsPane->moveTo(x_offset, MainStartY);
|
m_pane.moveTo(x_offset, MainStartY);
|
||||||
itsPane->refresh();
|
m_pane.refresh();
|
||||||
|
|
||||||
if (Width <= width && Height <= MainHeight)
|
if (Width <= width && Height <= MainHeight)
|
||||||
w->moveTo(x_offset+(width-Width)/2, MainStartY+(MainHeight-Height)/2);
|
w.moveTo(x_offset+(width-Width)/2, MainStartY+(MainHeight-Height)/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clock::switchTo()
|
void Clock::switchTo()
|
||||||
@@ -102,10 +102,10 @@ void Clock::switchTo()
|
|||||||
myScreen = this;
|
myScreen = this;
|
||||||
drawHeader();
|
drawHeader();
|
||||||
Prepare();
|
Prepare();
|
||||||
itsPane->refresh();
|
m_pane.refresh();
|
||||||
// clearing screen apparently fixes the problem with last digits being misrendered
|
// clearing screen apparently fixes the problem with last digits being misrendered
|
||||||
w->clear();
|
w.clear();
|
||||||
w->display();
|
w.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring Clock::title()
|
std::wstring Clock::title()
|
||||||
@@ -115,7 +115,7 @@ std::wstring Clock::title()
|
|||||||
|
|
||||||
void Clock::update()
|
void Clock::update()
|
||||||
{
|
{
|
||||||
if (Width > itsPane->getWidth() || Height > MainHeight)
|
if (Width > m_pane.getWidth() || Height > MainHeight)
|
||||||
{
|
{
|
||||||
using Global::myLockedScreen;
|
using Global::myLockedScreen;
|
||||||
using Global::myInactiveScreen;
|
using Global::myInactiveScreen;
|
||||||
@@ -145,7 +145,7 @@ void Clock::update()
|
|||||||
char buf[64];
|
char buf[64];
|
||||||
strftime(buf, 64, "%x", time);
|
strftime(buf, 64, "%x", time);
|
||||||
attron(COLOR_PAIR(Config.main_color));
|
attron(COLOR_PAIR(Config.main_color));
|
||||||
mvprintw(w->getStarty()+w->getHeight(), w->getStartX()+(w->getWidth()-strlen(buf))/2, "%s", buf);
|
mvprintw(w.getStarty()+w.getHeight(), w.getStartX()+(w.getWidth()-strlen(buf))/2, "%s", buf);
|
||||||
attroff(COLOR_PAIR(Config.main_color));
|
attroff(COLOR_PAIR(Config.main_color));
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ void Clock::update()
|
|||||||
next[k] = 0;
|
next[k] = 0;
|
||||||
for (int s = 1; s >= 0; --s)
|
for (int s = 1; s >= 0; --s)
|
||||||
{
|
{
|
||||||
*w << (s ? NC::fmtReverse : NC::fmtReverseEnd);
|
w << (s ? NC::fmtReverse : NC::fmtReverseEnd);
|
||||||
for (int i = 0; i < 6; ++i)
|
for (int i = 0; i < 6; ++i)
|
||||||
{
|
{
|
||||||
long a = (newer[i] ^ older[i]) & (s ? newer : older)[i];
|
long a = (newer[i] ^ older[i]) & (s ? newer : older)[i];
|
||||||
@@ -168,10 +168,10 @@ void Clock::update()
|
|||||||
{
|
{
|
||||||
if (!(a & (t << 1)))
|
if (!(a & (t << 1)))
|
||||||
{
|
{
|
||||||
w->goToXY(2*j+2, i);
|
w.goToXY(2*j+2, i);
|
||||||
}
|
}
|
||||||
if (Config.clock_display_seconds || j < 18)
|
if (Config.clock_display_seconds || j < 18)
|
||||||
*w << " ";
|
w << " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ void Clock::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w->refresh();
|
w.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clock::Prepare()
|
void Clock::Prepare()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
struct Clock : public Screen<NC::Window *>
|
struct Clock : public Screen<NC::Window>
|
||||||
{
|
{
|
||||||
Clock();
|
Clock();
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ protected:
|
|||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NC::Window *itsPane;
|
NC::Window m_pane;
|
||||||
|
|
||||||
static void Prepare();
|
static void Prepare();
|
||||||
static void Set(int, int);
|
static void Set(int, int);
|
||||||
|
|||||||
@@ -36,13 +36,12 @@ using Global::myScreen;
|
|||||||
Outputs *myOutputs;
|
Outputs *myOutputs;
|
||||||
|
|
||||||
Outputs::Outputs()
|
Outputs::Outputs()
|
||||||
|
: Screen(NC::Menu<MPD::Output>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
|
||||||
{
|
{
|
||||||
w = new NC::Menu<MPD::Output>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
w.cyclicScrolling(Config.use_cyclic_scrolling);
|
||||||
w->cyclicScrolling(Config.use_cyclic_scrolling);
|
w.centeredCursor(Config.centered_cursor);
|
||||||
w->centeredCursor(Config.centered_cursor);
|
w.setHighlightColor(Config.main_highlight_color);
|
||||||
w->setHighlightColor(Config.main_highlight_color);
|
w.setItemDisplayer(Display::Outputs);
|
||||||
w->setItemDisplayer(Display::Outputs);
|
|
||||||
|
|
||||||
FetchList();
|
FetchList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ void Outputs::switchTo()
|
|||||||
if (myScreen != this && myScreen->isTabbable())
|
if (myScreen != this && myScreen->isTabbable())
|
||||||
Global::myPrevScreen = myScreen;
|
Global::myPrevScreen = myScreen;
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
w->Window::clear();
|
w.Window::clear();
|
||||||
drawHeader();
|
drawHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,8 +69,8 @@ void Outputs::resize()
|
|||||||
{
|
{
|
||||||
size_t x_offset, width;
|
size_t x_offset, width;
|
||||||
getWindowResizeParams(x_offset, width);
|
getWindowResizeParams(x_offset, width);
|
||||||
w->resize(width, MainHeight);
|
w.resize(width, MainHeight);
|
||||||
w->moveTo(x_offset, MainStartY);
|
w.moveTo(x_offset, MainStartY);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,15 +81,15 @@ std::wstring Outputs::title()
|
|||||||
|
|
||||||
void Outputs::enterPressed()
|
void Outputs::enterPressed()
|
||||||
{
|
{
|
||||||
if (w->current().value().isEnabled())
|
if (w.current().value().isEnabled())
|
||||||
{
|
{
|
||||||
if (Mpd.DisableOutput(w->choice()))
|
if (Mpd.DisableOutput(w.choice()))
|
||||||
Statusbar::msg("Output \"%s\" disabled", w->current().value().name().c_str());
|
Statusbar::msg("Output \"%s\" disabled", w.current().value().name().c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Mpd.EnableOutput(w->choice()))
|
if (Mpd.EnableOutput(w.choice()))
|
||||||
Statusbar::msg("Output \"%s\" enabled", w->current().value().name().c_str());
|
Statusbar::msg("Output \"%s\" enabled", w.current().value().name().c_str());
|
||||||
}
|
}
|
||||||
if (!Mpd.SupportsIdle())
|
if (!Mpd.SupportsIdle())
|
||||||
FetchList();
|
FetchList();
|
||||||
@@ -98,11 +97,11 @@ void Outputs::enterPressed()
|
|||||||
|
|
||||||
void Outputs::mouseButtonPressed(MEVENT me)
|
void Outputs::mouseButtonPressed(MEVENT me)
|
||||||
{
|
{
|
||||||
if (w->empty() || !w->hasCoords(me.x, me.y) || size_t(me.y) >= w->size())
|
if (w.empty() || !w.hasCoords(me.x, me.y) || size_t(me.y) >= w.size())
|
||||||
return;
|
return;
|
||||||
if (me.bstate & BUTTON1_PRESSED || me.bstate & BUTTON3_PRESSED)
|
if (me.bstate & BUTTON1_PRESSED || me.bstate & BUTTON3_PRESSED)
|
||||||
{
|
{
|
||||||
w->Goto(me.y);
|
w.Goto(me.y);
|
||||||
if (me.bstate & BUTTON3_PRESSED)
|
if (me.bstate & BUTTON3_PRESSED)
|
||||||
enterPressed();
|
enterPressed();
|
||||||
}
|
}
|
||||||
@@ -112,12 +111,12 @@ void Outputs::mouseButtonPressed(MEVENT me)
|
|||||||
|
|
||||||
void Outputs::FetchList()
|
void Outputs::FetchList()
|
||||||
{
|
{
|
||||||
w->clear();
|
w.clear();
|
||||||
auto outputs = Mpd.GetOutputs();
|
auto outputs = Mpd.GetOutputs();
|
||||||
for (auto o = outputs.begin(); o != outputs.end(); ++o)
|
for (auto o = outputs.begin(); o != outputs.end(); ++o)
|
||||||
w->addItem(*o, o->isEnabled());
|
w.addItem(*o, o->isEnabled());
|
||||||
if (myScreen == this)
|
if (myScreen == this)
|
||||||
w->refresh();
|
w.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_OUTPUTS
|
#endif // ENABLE_OUTPUTS
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "mpdpp.h"
|
#include "mpdpp.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
struct Outputs : public Screen<NC::Menu<MPD::Output> *>
|
struct Outputs : public Screen<NC::Menu<MPD::Output>>
|
||||||
{
|
{
|
||||||
Outputs();
|
Outputs();
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void Status::Changes::playerState()
|
|||||||
player_state.clear();
|
player_state.clear();
|
||||||
# ifdef ENABLE_VISUALIZER
|
# ifdef ENABLE_VISUALIZER
|
||||||
if (isVisible(myVisualizer))
|
if (isVisible(myVisualizer))
|
||||||
myVisualizer->main()->clear();
|
myVisualizer->main().clear();
|
||||||
# endif // ENABLE_VISUALIZER
|
# endif // ENABLE_VISUALIZER
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,20 +46,20 @@ using Global::myOldScreen;
|
|||||||
TinyTagEditor *myTinyTagEditor;
|
TinyTagEditor *myTinyTagEditor;
|
||||||
|
|
||||||
TinyTagEditor::TinyTagEditor()
|
TinyTagEditor::TinyTagEditor()
|
||||||
|
: Screen(NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone))
|
||||||
{
|
{
|
||||||
w = new NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
w.setHighlightColor(Config.main_highlight_color);
|
||||||
w->setHighlightColor(Config.main_highlight_color);
|
w.cyclicScrolling(Config.use_cyclic_scrolling);
|
||||||
w->cyclicScrolling(Config.use_cyclic_scrolling);
|
w.centeredCursor(Config.centered_cursor);
|
||||||
w->centeredCursor(Config.centered_cursor);
|
w.setItemDisplayer(Display::Default<NC::Buffer>);
|
||||||
w->setItemDisplayer(Display::Default<NC::Buffer>);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TinyTagEditor::resize()
|
void TinyTagEditor::resize()
|
||||||
{
|
{
|
||||||
size_t x_offset, width;
|
size_t x_offset, width;
|
||||||
getWindowResizeParams(x_offset, width);
|
getWindowResizeParams(x_offset, width);
|
||||||
w->resize(width, MainHeight);
|
w.resize(width, MainHeight);
|
||||||
w->moveTo(x_offset, MainStartY);
|
w.moveTo(x_offset, MainStartY);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ std::wstring TinyTagEditor::title()
|
|||||||
|
|
||||||
void TinyTagEditor::enterPressed()
|
void TinyTagEditor::enterPressed()
|
||||||
{
|
{
|
||||||
size_t option = w->choice();
|
size_t option = w.choice();
|
||||||
Statusbar::lock();
|
Statusbar::lock();
|
||||||
if (option < 19) // separator after comment
|
if (option < 19) // separator after comment
|
||||||
{
|
{
|
||||||
@@ -111,9 +111,9 @@ void TinyTagEditor::enterPressed()
|
|||||||
Statusbar::put() << NC::fmtBold << SongInfo::Tags[pos].Name << ": " << NC::fmtBoldEnd;
|
Statusbar::put() << NC::fmtBold << SongInfo::Tags[pos].Name << ": " << NC::fmtBoldEnd;
|
||||||
itsEdited.setTags(SongInfo::Tags[pos].Set, Global::wFooter->getString(
|
itsEdited.setTags(SongInfo::Tags[pos].Set, Global::wFooter->getString(
|
||||||
itsEdited.getTags(SongInfo::Tags[pos].Get, Config.tags_separator)), Config.tags_separator);
|
itsEdited.getTags(SongInfo::Tags[pos].Get, Config.tags_separator)), Config.tags_separator);
|
||||||
w->at(option).value().clear();
|
w.at(option).value().clear();
|
||||||
w->at(option).value() << NC::fmtBold << SongInfo::Tags[pos].Name << ':' << NC::fmtBoldEnd << ' ';
|
w.at(option).value() << NC::fmtBold << SongInfo::Tags[pos].Name << ':' << NC::fmtBoldEnd << ' ';
|
||||||
ShowTag(w->at(option).value(), itsEdited.getTags(SongInfo::Tags[pos].Get, Config.tags_separator));
|
ShowTag(w.at(option).value(), itsEdited.getTags(SongInfo::Tags[pos].Get, Config.tags_separator));
|
||||||
}
|
}
|
||||||
else if (option == 20)
|
else if (option == 20)
|
||||||
{
|
{
|
||||||
@@ -124,8 +124,8 @@ void TinyTagEditor::enterPressed()
|
|||||||
filename = filename.substr(0, dot);
|
filename = filename.substr(0, dot);
|
||||||
std::string new_name = Global::wFooter->getString(filename);
|
std::string new_name = Global::wFooter->getString(filename);
|
||||||
itsEdited.setNewURI(new_name + extension);
|
itsEdited.setNewURI(new_name + extension);
|
||||||
w->at(option).value().clear();
|
w.at(option).value().clear();
|
||||||
w->at(option).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << (itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI());
|
w.at(option).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << (itsEdited.getNewURI().empty() ? itsEdited.getName() : itsEdited.getNewURI());
|
||||||
}
|
}
|
||||||
Statusbar::unlock();
|
Statusbar::unlock();
|
||||||
|
|
||||||
@@ -154,15 +154,15 @@ void TinyTagEditor::enterPressed()
|
|||||||
|
|
||||||
void TinyTagEditor::mouseButtonPressed(MEVENT me)
|
void TinyTagEditor::mouseButtonPressed(MEVENT me)
|
||||||
{
|
{
|
||||||
if (w->empty() || !w->hasCoords(me.x, me.y) || size_t(me.y) >= w->size())
|
if (w.empty() || !w.hasCoords(me.x, me.y) || size_t(me.y) >= w.size())
|
||||||
return;
|
return;
|
||||||
if (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED))
|
if (me.bstate & (BUTTON1_PRESSED | BUTTON3_PRESSED))
|
||||||
{
|
{
|
||||||
if (!w->Goto(me.y))
|
if (!w.Goto(me.y))
|
||||||
return;
|
return;
|
||||||
if (me.bstate & BUTTON3_PRESSED)
|
if (me.bstate & BUTTON3_PRESSED)
|
||||||
{
|
{
|
||||||
w->refresh();
|
w.refresh();
|
||||||
enterPressed();
|
enterPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,47 +190,47 @@ bool TinyTagEditor::getTags()
|
|||||||
std::string ext = itsEdited.getURI();
|
std::string ext = itsEdited.getURI();
|
||||||
ext = lowercase(ext.substr(ext.rfind(".")+1));
|
ext = lowercase(ext.substr(ext.rfind(".")+1));
|
||||||
|
|
||||||
w->clear();
|
w.clear();
|
||||||
w->reset();
|
w.reset();
|
||||||
|
|
||||||
w->resizeList(24);
|
w.resizeList(24);
|
||||||
|
|
||||||
for (size_t i = 0; i < 7; ++i)
|
for (size_t i = 0; i < 7; ++i)
|
||||||
w->at(i).setInactive(true);
|
w.at(i).setInactive(true);
|
||||||
|
|
||||||
w->at(7).setSeparator(true);
|
w.at(7).setSeparator(true);
|
||||||
w->at(19).setSeparator(true);
|
w.at(19).setSeparator(true);
|
||||||
w->at(21).setSeparator(true);
|
w.at(21).setSeparator(true);
|
||||||
|
|
||||||
if (!Tags::extendedSetSupported(f.file()))
|
if (!Tags::extendedSetSupported(f.file()))
|
||||||
{
|
{
|
||||||
w->at(10).setInactive(true);
|
w.at(10).setInactive(true);
|
||||||
for (size_t i = 15; i <= 17; ++i)
|
for (size_t i = 15; i <= 17; ++i)
|
||||||
w->at(i).setInactive(true);
|
w.at(i).setInactive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->highlight(8);
|
w.highlight(8);
|
||||||
|
|
||||||
w->at(0).value() << NC::fmtBold << Config.color1 << "Song name: " << NC::fmtBoldEnd << Config.color2 << itsEdited.getName() << NC::clEnd;
|
w.at(0).value() << NC::fmtBold << Config.color1 << "Song name: " << NC::fmtBoldEnd << Config.color2 << itsEdited.getName() << NC::clEnd;
|
||||||
w->at(1).value() << NC::fmtBold << Config.color1 << "Location in DB: " << NC::fmtBoldEnd << Config.color2;
|
w.at(1).value() << NC::fmtBold << Config.color1 << "Location in DB: " << NC::fmtBoldEnd << Config.color2;
|
||||||
ShowTag(w->at(1).value(), itsEdited.getDirectory());
|
ShowTag(w.at(1).value(), itsEdited.getDirectory());
|
||||||
w->at(1).value() << NC::clEnd;
|
w.at(1).value() << NC::clEnd;
|
||||||
w->at(3).value() << NC::fmtBold << Config.color1 << "Length: " << NC::fmtBoldEnd << Config.color2 << itsEdited.getLength() << NC::clEnd;
|
w.at(3).value() << NC::fmtBold << Config.color1 << "Length: " << NC::fmtBoldEnd << Config.color2 << itsEdited.getLength() << NC::clEnd;
|
||||||
w->at(4).value() << NC::fmtBold << Config.color1 << "Bitrate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps" << NC::clEnd;
|
w.at(4).value() << NC::fmtBold << Config.color1 << "Bitrate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->bitrate() << " kbps" << NC::clEnd;
|
||||||
w->at(5).value() << NC::fmtBold << Config.color1 << "Sample rate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz" << NC::clEnd;
|
w.at(5).value() << NC::fmtBold << Config.color1 << "Sample rate: " << NC::fmtBoldEnd << Config.color2 << f.audioProperties()->sampleRate() << " Hz" << NC::clEnd;
|
||||||
w->at(6).value() << NC::fmtBold << Config.color1 << "Channels: " << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << NC::clDefault;
|
w.at(6).value() << NC::fmtBold << Config.color1 << "Channels: " << NC::fmtBoldEnd << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << NC::clDefault;
|
||||||
|
|
||||||
unsigned pos = 8;
|
unsigned pos = 8;
|
||||||
for (const SongInfo::Metadata *m = SongInfo::Tags; m->Name; ++m, ++pos)
|
for (const SongInfo::Metadata *m = SongInfo::Tags; m->Name; ++m, ++pos)
|
||||||
{
|
{
|
||||||
w->at(pos).value() << NC::fmtBold << m->Name << ":" << NC::fmtBoldEnd << ' ';
|
w.at(pos).value() << NC::fmtBold << m->Name << ":" << NC::fmtBoldEnd << ' ';
|
||||||
ShowTag(w->at(pos).value(), itsEdited.getTags(m->Get, Config.tags_separator));
|
ShowTag(w.at(pos).value(), itsEdited.getTags(m->Get, Config.tags_separator));
|
||||||
}
|
}
|
||||||
|
|
||||||
w->at(20).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << itsEdited.getName();
|
w.at(20).value() << NC::fmtBold << "Filename:" << NC::fmtBoldEnd << ' ' << itsEdited.getName();
|
||||||
|
|
||||||
w->at(22).value() << "Save";
|
w.at(22).value() << "Save";
|
||||||
w->at(23).value() << "Cancel";
|
w.at(23).value() << "Cancel";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "mutable_song.h"
|
#include "mutable_song.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
struct TinyTagEditor : public Screen<NC::Menu<NC::Buffer> *>
|
struct TinyTagEditor : public Screen<NC::Menu<NC::Buffer>>
|
||||||
{
|
{
|
||||||
TinyTagEditor();
|
TinyTagEditor();
|
||||||
|
|
||||||
|
|||||||
@@ -45,17 +45,16 @@ Visualizer *myVisualizer;
|
|||||||
const int Visualizer::WindowTimeout = 1000/25; /* 25 fps */
|
const int Visualizer::WindowTimeout = 1000/25; /* 25 fps */
|
||||||
|
|
||||||
Visualizer::Visualizer()
|
Visualizer::Visualizer()
|
||||||
|
: Screen(NC::Window(0, MainStartY, COLS, MainHeight, "", Config.visualizer_color, NC::brNone))
|
||||||
{
|
{
|
||||||
w = new NC::Window(0, MainStartY, COLS, MainHeight, "", Config.visualizer_color, NC::brNone);
|
|
||||||
|
|
||||||
ResetFD();
|
ResetFD();
|
||||||
itsSamples = Config.visualizer_in_stereo ? 4096 : 2048;
|
m_samples = Config.visualizer_in_stereo ? 4096 : 2048;
|
||||||
# ifdef HAVE_FFTW3_H
|
# ifdef HAVE_FFTW3_H
|
||||||
itsFFTResults = itsSamples/2+1;
|
m_fftw_results = m_samples/2+1;
|
||||||
itsFreqsMagnitude = new unsigned[itsFFTResults];
|
m_freq_magnitudes = new unsigned[m_fftw_results];
|
||||||
itsInput = static_cast<double *>(fftw_malloc(sizeof(double)*itsSamples));
|
m_fftw_input = static_cast<double *>(fftw_malloc(sizeof(double)*m_samples));
|
||||||
itsOutput = static_cast<fftw_complex *>(fftw_malloc(sizeof(fftw_complex)*itsFFTResults));
|
m_fftw_output = static_cast<fftw_complex *>(fftw_malloc(sizeof(fftw_complex)*m_fftw_results));
|
||||||
itsPlan = fftw_plan_dft_r2c_1d(itsSamples, itsInput, itsOutput, FFTW_ESTIMATE);
|
m_fftw_plan = fftw_plan_dft_r2c_1d(m_samples, m_fftw_input, m_fftw_output, FFTW_ESTIMATE);
|
||||||
# endif // HAVE_FFTW3_H
|
# endif // HAVE_FFTW3_H
|
||||||
|
|
||||||
FindOutputID();
|
FindOutputID();
|
||||||
@@ -79,14 +78,14 @@ void Visualizer::switchTo()
|
|||||||
Global::myPrevScreen = myScreen;
|
Global::myPrevScreen = myScreen;
|
||||||
myScreen = this;
|
myScreen = this;
|
||||||
drawHeader();
|
drawHeader();
|
||||||
w->clear();
|
w.clear();
|
||||||
|
|
||||||
SetFD();
|
SetFD();
|
||||||
|
|
||||||
itsTimer.tv_sec = 0;
|
m_timer.tv_sec = 0;
|
||||||
itsTimer.tv_usec = 0;
|
m_timer.tv_usec = 0;
|
||||||
|
|
||||||
if (itsFifo >= 0)
|
if (m_fifo >= 0)
|
||||||
Global::wFooter->setTimeout(WindowTimeout);
|
Global::wFooter->setTimeout(WindowTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +93,8 @@ void Visualizer::resize()
|
|||||||
{
|
{
|
||||||
size_t x_offset, width;
|
size_t x_offset, width;
|
||||||
getWindowResizeParams(x_offset, width);
|
getWindowResizeParams(x_offset, width);
|
||||||
w->resize(width, MainHeight);
|
w.resize(width, MainHeight);
|
||||||
w->moveTo(x_offset, MainStartY);
|
w.moveTo(x_offset, MainStartY);
|
||||||
hasToBeResized = 0;
|
hasToBeResized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,21 +105,21 @@ std::wstring Visualizer::title()
|
|||||||
|
|
||||||
void Visualizer::update()
|
void Visualizer::update()
|
||||||
{
|
{
|
||||||
if (itsFifo < 0)
|
if (m_fifo < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// PCM in format 44100:16:1 (for mono visualization) and 44100:16:2 (for stereo visualization) is supported
|
// PCM in format 44100:16:1 (for mono visualization) and 44100:16:2 (for stereo visualization) is supported
|
||||||
int16_t buf[itsSamples];
|
int16_t buf[m_samples];
|
||||||
ssize_t data = read(itsFifo, buf, sizeof(buf));
|
ssize_t data = read(m_fifo, buf, sizeof(buf));
|
||||||
if (data < 0) // no data available in fifo
|
if (data < 0) // no data available in fifo
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (itsOutputID != -1 && Global::Timer.tv_sec > itsTimer.tv_sec+Config.visualizer_sync_interval)
|
if (m_output_id != -1 && Global::Timer.tv_sec > m_timer.tv_sec+Config.visualizer_sync_interval)
|
||||||
{
|
{
|
||||||
Mpd.DisableOutput(itsOutputID);
|
Mpd.DisableOutput(m_output_id);
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
Mpd.EnableOutput(itsOutputID);
|
Mpd.EnableOutput(m_output_id);
|
||||||
itsTimer = Global::Timer;
|
m_timer = Global::Timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void (Visualizer::*draw)(int16_t *, ssize_t, size_t, size_t);
|
void (Visualizer::*draw)(int16_t *, ssize_t, size_t, size_t);
|
||||||
@@ -131,7 +130,7 @@ void Visualizer::update()
|
|||||||
# endif // HAVE_FFTW3_H
|
# endif // HAVE_FFTW3_H
|
||||||
draw = &Visualizer::DrawSoundWave;
|
draw = &Visualizer::DrawSoundWave;
|
||||||
|
|
||||||
w->clear();
|
w.clear();
|
||||||
ssize_t samples_read = data/sizeof(int16_t);
|
ssize_t samples_read = data/sizeof(int16_t);
|
||||||
if (Config.visualizer_in_stereo)
|
if (Config.visualizer_in_stereo)
|
||||||
{
|
{
|
||||||
@@ -147,7 +146,7 @@ void Visualizer::update()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
(this->*draw)(buf, samples_read, 0, MainHeight);
|
(this->*draw)(buf, samples_read, 0, MainHeight);
|
||||||
w->refresh();
|
w.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visualizer::spacePressed()
|
void Visualizer::spacePressed()
|
||||||
@@ -160,10 +159,10 @@ void Visualizer::spacePressed()
|
|||||||
|
|
||||||
void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, size_t height)
|
void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, size_t height)
|
||||||
{
|
{
|
||||||
const int samples_per_col = samples/w->getWidth();
|
const int samples_per_col = samples/w.getWidth();
|
||||||
const int half_height = height/2;
|
const int half_height = height/2;
|
||||||
double prev_point_pos = 0;
|
double prev_point_pos = 0;
|
||||||
const size_t win_width = w->getWidth();
|
const size_t win_width = w.getWidth();
|
||||||
for (size_t i = 0; i < win_width; ++i)
|
for (size_t i = 0; i < win_width; ++i)
|
||||||
{
|
{
|
||||||
double point_pos = 0;
|
double point_pos = 0;
|
||||||
@@ -172,7 +171,7 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
|||||||
point_pos /= samples_per_col;
|
point_pos /= samples_per_col;
|
||||||
point_pos /= std::numeric_limits<int16_t>::max();
|
point_pos /= std::numeric_limits<int16_t>::max();
|
||||||
point_pos *= half_height;
|
point_pos *= half_height;
|
||||||
*w << NC::XY(i, y_offset+half_height+point_pos) << Config.visualizer_chars[0];
|
w << NC::XY(i, y_offset+half_height+point_pos) << Config.visualizer_chars[0];
|
||||||
if (i && abs(prev_point_pos-point_pos) > 2)
|
if (i && abs(prev_point_pos-point_pos) > 2)
|
||||||
{
|
{
|
||||||
// if gap is too big. intermediate values are needed
|
// if gap is too big. intermediate values are needed
|
||||||
@@ -180,7 +179,7 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
|||||||
const int breakpoint = std::max(prev_point_pos, point_pos);
|
const int breakpoint = std::max(prev_point_pos, point_pos);
|
||||||
const int half = (prev_point_pos+point_pos)/2;
|
const int half = (prev_point_pos+point_pos)/2;
|
||||||
for (int k = std::min(prev_point_pos, point_pos)+1; k < breakpoint; k += 2)
|
for (int k = std::min(prev_point_pos, point_pos)+1; k < breakpoint; k += 2)
|
||||||
*w << NC::XY(i-(k < half), y_offset+half_height+k) << Config.visualizer_chars[0];
|
w << NC::XY(i-(k < half), y_offset+half_height+k) << Config.visualizer_chars[0];
|
||||||
}
|
}
|
||||||
prev_point_pos = point_pos;
|
prev_point_pos = point_pos;
|
||||||
}
|
}
|
||||||
@@ -189,58 +188,58 @@ void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, s
|
|||||||
#ifdef HAVE_FFTW3_H
|
#ifdef HAVE_FFTW3_H
|
||||||
void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t samples, size_t y_offset, size_t height)
|
void Visualizer::DrawFrequencySpectrum(int16_t *buf, ssize_t samples, size_t y_offset, size_t height)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0, j = 0; i < itsSamples; ++i)
|
for (unsigned i = 0, j = 0; i < m_samples; ++i)
|
||||||
{
|
{
|
||||||
if (j < samples)
|
if (j < samples)
|
||||||
itsInput[i] = buf[j++];
|
m_fftw_input[i] = buf[j++];
|
||||||
else
|
else
|
||||||
itsInput[i] = 0;
|
m_fftw_input[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fftw_execute(itsPlan);
|
fftw_execute(m_fftw_plan);
|
||||||
|
|
||||||
// count magnitude of each frequency and scale it to fit the screen
|
// count magnitude of each frequency and scale it to fit the screen
|
||||||
for (unsigned i = 0; i < itsFFTResults; ++i)
|
for (unsigned i = 0; i < m_fftw_results; ++i)
|
||||||
itsFreqsMagnitude[i] = sqrt(itsOutput[i][0]*itsOutput[i][0] + itsOutput[i][1]*itsOutput[i][1])/1e5*height/5;
|
m_freq_magnitudes[i] = sqrt(m_fftw_output[i][0]*m_fftw_output[i][0] + m_fftw_output[i][1]*m_fftw_output[i][1])/1e5*height/5;
|
||||||
|
|
||||||
const size_t win_width = w->getWidth();
|
const size_t win_width = w.getWidth();
|
||||||
const int freqs_per_col = itsFFTResults/win_width /* cut bandwidth a little to achieve better look */ * 7/10;
|
const int freqs_per_col = m_fftw_results/win_width /* cut bandwidth a little to achieve better look */ * 7/10;
|
||||||
for (size_t i = 0; i < win_width; ++i)
|
for (size_t i = 0; i < win_width; ++i)
|
||||||
{
|
{
|
||||||
size_t bar_height = 0;
|
size_t bar_height = 0;
|
||||||
for (int j = 0; j < freqs_per_col; ++j)
|
for (int j = 0; j < freqs_per_col; ++j)
|
||||||
bar_height += itsFreqsMagnitude[i*freqs_per_col+j];
|
bar_height += m_freq_magnitudes[i*freqs_per_col+j];
|
||||||
bar_height = std::min(bar_height/freqs_per_col, height);
|
bar_height = std::min(bar_height/freqs_per_col, height);
|
||||||
const size_t start_y = y_offset > 0 ? y_offset : height-bar_height;
|
const size_t start_y = y_offset > 0 ? y_offset : height-bar_height;
|
||||||
const size_t stop_y = std::min(bar_height+start_y, w->getHeight());
|
const size_t stop_y = std::min(bar_height+start_y, w.getHeight());
|
||||||
for (size_t j = start_y; j < stop_y; ++j)
|
for (size_t j = start_y; j < stop_y; ++j)
|
||||||
*w << NC::XY(i, j) << Config.visualizer_chars[1];
|
w << NC::XY(i, j) << Config.visualizer_chars[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_FFTW3_H
|
#endif // HAVE_FFTW3_H
|
||||||
|
|
||||||
void Visualizer::SetFD()
|
void Visualizer::SetFD()
|
||||||
{
|
{
|
||||||
if (itsFifo < 0 && (itsFifo = open(Config.visualizer_fifo_path.c_str(), O_RDONLY | O_NONBLOCK)) < 0)
|
if (m_fifo < 0 && (m_fifo = open(Config.visualizer_fifo_path.c_str(), O_RDONLY | O_NONBLOCK)) < 0)
|
||||||
Statusbar::msg("Couldn't open \"%s\" for reading PCM data: %s", Config.visualizer_fifo_path.c_str(), strerror(errno));
|
Statusbar::msg("Couldn't open \"%s\" for reading PCM data: %s", Config.visualizer_fifo_path.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visualizer::ResetFD()
|
void Visualizer::ResetFD()
|
||||||
{
|
{
|
||||||
itsFifo = -1;
|
m_fifo = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visualizer::FindOutputID()
|
void Visualizer::FindOutputID()
|
||||||
{
|
{
|
||||||
itsOutputID = -1;
|
m_output_id = -1;
|
||||||
if (!Config.visualizer_output_name.empty())
|
if (!Config.visualizer_output_name.empty())
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
auto outputs = Mpd.GetOutputs();
|
auto outputs = Mpd.GetOutputs();
|
||||||
for (auto o = outputs.begin(); o != outputs.end(); ++o, ++i)
|
for (auto o = outputs.begin(); o != outputs.end(); ++o, ++i)
|
||||||
if (o->name() == Config.visualizer_output_name)
|
if (o->name() == Config.visualizer_output_name)
|
||||||
itsOutputID = i;
|
m_output_id = i;
|
||||||
if (itsOutputID == -1)
|
if (m_output_id == -1)
|
||||||
Statusbar::msg("There is no output named \"%s\"", Config.visualizer_output_name.c_str());
|
Statusbar::msg("There is no output named \"%s\"", Config.visualizer_output_name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
# include <fftw3.h>
|
# include <fftw3.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Visualizer : public Screen<NC::Window *>
|
struct Visualizer : public Screen<NC::Window>
|
||||||
{
|
{
|
||||||
Visualizer();
|
Visualizer();
|
||||||
|
|
||||||
@@ -67,17 +67,17 @@ private:
|
|||||||
void DrawFrequencySpectrum(int16_t *, ssize_t, size_t, size_t);
|
void DrawFrequencySpectrum(int16_t *, ssize_t, size_t, size_t);
|
||||||
# endif // HAVE_FFTW3_H
|
# endif // HAVE_FFTW3_H
|
||||||
|
|
||||||
int itsOutputID;
|
int m_output_id;
|
||||||
timeval itsTimer;
|
timeval m_timer;
|
||||||
|
|
||||||
int itsFifo;
|
int m_fifo;
|
||||||
unsigned itsSamples;
|
unsigned m_samples;
|
||||||
# ifdef HAVE_FFTW3_H
|
# ifdef HAVE_FFTW3_H
|
||||||
unsigned itsFFTResults;
|
unsigned m_fftw_results;
|
||||||
unsigned *itsFreqsMagnitude;
|
unsigned *m_freq_magnitudes;
|
||||||
double *itsInput;
|
double *m_fftw_input;
|
||||||
fftw_complex *itsOutput;
|
fftw_complex *m_fftw_output;
|
||||||
fftw_plan itsPlan;
|
fftw_plan m_fftw_plan;
|
||||||
# endif // HAVE_FFTW3_H
|
# endif // HAVE_FFTW3_H
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user