Add very basic configuration for theming and a light theme
* Allow selecting between built-in themes via "View" menu * Add basic mechanism to apply color changes at runtime * Add a basic light theme (needs still tweaking)
This commit is contained in:
parent
35c01b9382
commit
04b4e3d56d
27
src/Cfg.cpp
27
src/Cfg.cpp
|
@ -46,4 +46,29 @@ int Cfg::tickRate;
|
|||
const int Cfg::m_playZoneEarly = 25; // Was 25
|
||||
const int Cfg::m_playZoneLate = 25;
|
||||
|
||||
ColorTheme Cfg::m_colorTheme = ColorTheme();
|
||||
ColorTheme Cfg::m_colorTheme;
|
||||
|
||||
void ColorTheme::load(BuiltInColorTheme builtInColorTheme)
|
||||
{
|
||||
switch (builtInColorTheme) {
|
||||
case BuiltInColorTheme::Light:
|
||||
menuColor = CColor(0.1, 0.6, 0.6);
|
||||
menuSelectedColor = CColor(0.7, 0.7, 0.1);
|
||||
staveColor = CColor(0.2, 0.2, 0.2);
|
||||
staveColorDim = CColor(0.25, 0.40, 0.25); // grey
|
||||
noteColor = CColor(0.0, 0.0, 0.0); // black
|
||||
noteColorDim = CColor(0.2, 0.2, 0.2); // green
|
||||
playedGoodColor = CColor(0.5, 0.6, 1.0); // purple
|
||||
playedBadColor = CColor(0.8, 0.3, 0.8); // orange
|
||||
playedStoppedColor = CColor(1.0, 0.8, 0.0); // bright orange
|
||||
backgroundColor = CColor(1.0, 1.0, 1.0); // white
|
||||
barMarkerColor = CColor(0.3, 0.25, 0.25); // grey
|
||||
beatMarkerColor = CColor(0.25, 0.2, 0.2); // grey
|
||||
pianoGoodColor = playedGoodColor;
|
||||
pianoBadColor = CColor(1.0, 0.0, 0.0);
|
||||
noteNameColor = CColor(0.0, 0.0, 0.0);
|
||||
break;
|
||||
default:
|
||||
*this = ColorTheme();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,16 @@ public:
|
|||
float red, green, blue;
|
||||
};
|
||||
|
||||
enum class BuiltInColorTheme {
|
||||
Default,
|
||||
Light,
|
||||
};
|
||||
|
||||
struct ColorTheme
|
||||
{
|
||||
constexpr ColorTheme() = default;
|
||||
constexpr ColorTheme &operator=(const ColorTheme &other) = default;
|
||||
void load(BuiltInColorTheme builtInColorTheme);
|
||||
|
||||
CColor menuColor = CColor(0.1, 0.6, 0.6);
|
||||
CColor menuSelectedColor = CColor(0.7, 0.7, 0.1);
|
||||
|
@ -120,6 +127,7 @@ public:
|
|||
static int chordMaxLength() {return 20;} // the max time between the start and end of a cord
|
||||
|
||||
static const ColorTheme &colorTheme() { return m_colorTheme; }
|
||||
static void loadColorTheme(BuiltInColorTheme builtInColorTheme) { m_colorTheme.load(builtInColorTheme); }
|
||||
|
||||
static void setDefaults() {
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -54,6 +54,7 @@ CGLView::CGLView(QtWindow* parent, CSettings* settings)
|
|||
m_settings = settings;
|
||||
m_rating = nullptr;
|
||||
m_fullRedrawFlag = true;
|
||||
m_themeChange = false;
|
||||
m_forcefullRedraw = 0;
|
||||
m_forceRatingRedraw = 0;
|
||||
m_forceBarRedraw = 0;
|
||||
|
@ -96,10 +97,32 @@ void CGLView::startTimerEvent()
|
|||
m_allowedTimerEvent=true;
|
||||
}
|
||||
|
||||
void CGLView::reportColorThemeChange()
|
||||
{
|
||||
const auto ¬eColor = Cfg::colorTheme().noteColor;
|
||||
m_themeChange = true;
|
||||
m_fullRedrawFlag = true;
|
||||
m_score->refreshNoteColor(noteColor);
|
||||
m_song->refreshScroll();
|
||||
m_score->refreshScroll();
|
||||
CDraw::forceCompileRedraw();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void CGLView::paintGL()
|
||||
{
|
||||
BENCHMARK(2, "enter");
|
||||
|
||||
if (m_themeChange) {
|
||||
auto *const ctx = context();
|
||||
auto *const funcs = ctx->functions();
|
||||
const auto &colorTheme = Cfg::colorTheme();
|
||||
const auto &backgroundColor = colorTheme.backgroundColor;
|
||||
funcs->glClearColor(backgroundColor.red, backgroundColor.green, backgroundColor.blue, 0.0);
|
||||
funcs->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
m_themeChange = false;
|
||||
}
|
||||
|
||||
m_displayUpdateTicks = 0;
|
||||
|
||||
if (m_fullRedrawFlag)
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
|
||||
void stopTimerEvent();
|
||||
void startTimerEvent();
|
||||
void reportColorThemeChange();
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
@ -89,6 +90,7 @@ private:
|
|||
QFont m_timeRatingFont;
|
||||
// TODO remove these as no longer required
|
||||
bool m_fullRedrawFlag;
|
||||
bool m_themeChange;
|
||||
int m_forcefullRedraw;
|
||||
int m_forceRatingRedraw;
|
||||
int m_forceBarRedraw;
|
||||
|
|
|
@ -379,3 +379,14 @@ void CNotation::reset()
|
|||
noteState.clear();
|
||||
setupNotationParamaters();
|
||||
}
|
||||
|
||||
void CNotation::resetNoteColor(CColor color)
|
||||
{
|
||||
m_currentSlot.setNoteColor(0, color);
|
||||
for (auto i = 0, len = m_slotQueue->length(); i != len; ++i) {
|
||||
m_slotQueue->indexPtr(i)->setNoteColor(0, color);
|
||||
}
|
||||
for (auto &slot : m_mergeSlots) {
|
||||
slot.setNoteColor(0, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,6 +185,7 @@ public:
|
|||
delete m_slotQueue;
|
||||
}
|
||||
void reset();
|
||||
void resetNoteColor(CColor color);
|
||||
|
||||
void setChannel(int channel) {m_displayChannel = channel;}
|
||||
|
||||
|
|
|
@ -422,11 +422,24 @@ void QtWindow::createMenus()
|
|||
m_fileMenu->addAction(m_exitAct);
|
||||
updateRecentFileActions();
|
||||
|
||||
m_colorThemeMenu = new QMenu(tr("Color theme"), this);
|
||||
m_colorThemeActGrp = new QActionGroup(this);
|
||||
m_colorThemeActGrp->setExclusive(true);
|
||||
m_colorThemeMenu->addAction(tr("Default"))->setActionGroup(m_colorThemeActGrp);
|
||||
m_colorThemeMenu->addAction(tr("Light"))->setActionGroup(m_colorThemeActGrp);
|
||||
const auto &actions = m_colorThemeActGrp->actions();
|
||||
for (auto *const action : actions) {
|
||||
action->setCheckable(true);
|
||||
}
|
||||
actions.front()->setChecked(true);
|
||||
connect(m_colorThemeActGrp, &QActionGroup::triggered, this, &QtWindow::changeColorTheme);
|
||||
|
||||
m_viewMenu = menuBar()->addMenu(tr("&View"));
|
||||
m_viewMenu->setToolTipsVisible(true);
|
||||
m_viewMenu->addAction(m_sidePanelStateAct);
|
||||
m_viewMenu->addAction(m_fullScreenStateAct);
|
||||
m_viewMenu->addAction(m_viewPianoKeyboard);
|
||||
m_viewMenu->addMenu(m_colorThemeMenu);
|
||||
|
||||
m_songMenu = menuBar()->addMenu(tr("&Song"));
|
||||
m_songMenu->setToolTipsVisible(true);
|
||||
|
@ -463,6 +476,12 @@ void QtWindow::openRecentFile()
|
|||
m_settings->openSongFile(action->data().toString());
|
||||
}
|
||||
|
||||
void QtWindow::changeColorTheme(QAction *triggeredAction)
|
||||
{
|
||||
Cfg::loadColorTheme(static_cast<BuiltInColorTheme>(m_colorThemeActGrp->actions().indexOf(triggeredAction)));
|
||||
m_glWidget->reportColorThemeChange();
|
||||
}
|
||||
|
||||
void QtWindow::showMidiSetup(){
|
||||
|
||||
m_topBar->stopMuiscPlaying();
|
||||
|
|
|
@ -84,6 +84,7 @@ private slots:
|
|||
void about();
|
||||
void keyboardShortcuts();
|
||||
void openRecentFile();
|
||||
void changeColorTheme(QAction *triggeredAction);
|
||||
|
||||
void showMidiSetup();
|
||||
|
||||
|
@ -220,6 +221,7 @@ private:
|
|||
|
||||
QMenu *m_fileMenu;
|
||||
QMenu *m_viewMenu;
|
||||
QMenu *m_colorThemeMenu;
|
||||
QMenu *m_songMenu;
|
||||
QMenu *m_setupMenu;
|
||||
QMenu *m_helpMenu;
|
||||
|
@ -229,6 +231,7 @@ private:
|
|||
QAction *m_separatorAct;
|
||||
|
||||
QAction *m_recentFileActs[maxRecentFiles()];
|
||||
QActionGroup *m_colorThemeActGrp;
|
||||
};
|
||||
|
||||
#endif // __QT_WINDOW_H__
|
||||
|
|
|
@ -102,6 +102,12 @@ public:
|
|||
m_scroll[m_activeScroll]->setPlayedNoteColor(note, color, wantedDelta, pianistTimming);
|
||||
}
|
||||
|
||||
void refreshNoteColor(CColor color)
|
||||
{
|
||||
for (auto *const scroll : m_scroll)
|
||||
scroll->refreshNoteColor(color);
|
||||
}
|
||||
|
||||
void setActiveChannel(int channel)
|
||||
{
|
||||
int newActiveSroll;
|
||||
|
|
|
@ -251,6 +251,15 @@ void CScroll::refresh()
|
|||
compileSlot(m_scrollQueue->index(i));
|
||||
}
|
||||
|
||||
void CScroll::refreshNoteColor(CColor color)
|
||||
{
|
||||
m_notation->resetNoteColor(color);
|
||||
m_headSlot.setNoteColor(0, color);
|
||||
for (auto i = 0, len = m_scrollQueue->length(); i != len; ++i) {
|
||||
m_scrollQueue->indexPtr(i)->setNoteColor(0, color);
|
||||
}
|
||||
}
|
||||
|
||||
bool CScroll::getKeyboardInfo(int *notes)
|
||||
{
|
||||
int stoppedScrollIdx = -1;
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
void scrollDeltaTime(qint64 ticks);
|
||||
void transpose(int transpose);
|
||||
void refresh();
|
||||
void refreshNoteColor(CColor color);
|
||||
void setPlayedNoteColor(int note, CColor color, qint64 wantedDelta, qint64 pianistTimming);
|
||||
void setChannel(int chan)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue