From 36dadcd27189f0a6fc3d4b5d981c227c1f4992e0 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Wed, 13 Feb 2013 17:52:07 +0000 Subject: dark theme --- muse2/ChangeLog | 2 + muse2/muse/appearance.cpp | 72 +++++++++++++++++++++++++++--------- muse2/muse/conf.cpp | 21 +++++++++-- muse2/muse/conf.h | 1 + muse2/muse/gconfig.cpp | 4 ++ muse2/muse/gconfig.h | 5 ++- muse2/muse/widgets/appearancebase.ui | 34 +++++++++++++++-- muse2/muse/widgets/mtscale.cpp | 24 ++++++++---- muse2/muse/widgets/mtscale.h | 1 + muse2/muse/widgets/mtscale_flo.cpp | 18 ++++++--- muse2/muse/widgets/mtscale_flo.h | 1 + muse2/share/CMakeLists.txt | 6 +-- muse2/share/darkbase.cfg | 57 ++++++++++++++++++++++++++++ muse2/share/darkbase.qss | 4 ++ muse2/share/lightbase.cfg | 57 ++++++++++++++++++++++++++++ 15 files changed, 265 insertions(+), 42 deletions(-) create mode 100644 muse2/share/darkbase.cfg create mode 100644 muse2/share/darkbase.qss create mode 100644 muse2/share/lightbase.cfg diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 38dd1a61..8cfe3cd2 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,5 @@ +13.02.2013: + * Added basic theme support selection, currently two themes selectable, light and dark (rj) 07.02.2013: * Feature: choice of new metronome with different sounds and adjustable volume. Also has additional ticks before each standard tick. The idea is to improve timing. diff --git a/muse2/muse/appearance.cpp b/muse2/muse/appearance.cpp index 0ae3bf6b..f148e752 100644 --- a/muse2/muse/appearance.cpp +++ b/muse2/muse/appearance.cpp @@ -177,6 +177,8 @@ Appearance::Appearance(Arranger* a, QWidget* parent) new IdListViewItem(0x400 + i, id, MusEGlobal::config.partColorNames[i]); new IdListViewItem(0x41c, aid, "part canvas background"); + new IdListViewItem(0x41f, aid, "Ruler background"); + new IdListViewItem(0x420, aid, "Ruler text"); id = new IdListViewItem(0, aid, "Track List"); new IdListViewItem(0x411, id, "background"); new IdListViewItem(0x412, id, "midi background"); @@ -190,7 +192,7 @@ Appearance::Appearance(Arranger* a, QWidget* parent) new IdListViewItem(0x419, id, "synth background"); new IdListViewItem(0x41a, id, "selected track background"); new IdListViewItem(0x41b, id, "selected track foreground"); - // 0x41e is already used (between 413 and 414) + // 0x41c - 0x420 is already used (see above) id = new IdListViewItem(0, itemList, "BigTime"); new IdListViewItem(0x100, id, "background"); new IdListViewItem(0x101, id, "foreground"); @@ -463,31 +465,63 @@ void Appearance::updateFonts() void Appearance::apply() { + + // Changing color themes overrides all other configurations + + if (colorSchemeComboBox->currentIndex()==1) // light theme + { + // load standard light theme + backgroundTree->reset(); + styleSheetPath->setText(""); + MusEGlobal::muse->loadStyleSheetFile(""); + MusEGlobal::config.styleSheetFile = ""; + QString configPath = MusEGlobal::museGlobalShare +"/lightbase.cfg"; + MusECore::readConfiguration(configPath.toLatin1().constData()); + colorSchemeComboBox->setCurrentIndex(0); + MusEGlobal::muse->changeConfig(true); + return; + + } + else if (colorSchemeComboBox->currentIndex()==2) // dark theme + { + // load standard dark theme + backgroundTree->reset(); + styleSheetPath->setText(MusEGlobal::museGlobalShare +"/darkbase.qss"); + MusEGlobal::config.styleSheetFile = styleSheetPath->text(); + QString configPath = MusEGlobal::museGlobalShare +"/darkbase.cfg"; + MusECore::readConfiguration(configPath.toLatin1().constData()); + colorSchemeComboBox->setCurrentIndex(0); + MusEGlobal::muse->changeConfig(true); + return; + } + +// +// int showPartEvent = 0; int showPartType = 0; - if (partShownames->isChecked()) + if (partShownames->isChecked()) showPartType |= 1; - if (partShowevents->isChecked()) + if (partShowevents->isChecked()) showPartType |= 2; - if (partCakeStretch->isChecked()) + if (partCakeStretch->isChecked()) showPartType |= 4; config->canvasShowPartType = showPartType; - if (eventNoteon->isChecked()) + if (eventNoteon->isChecked()) showPartEvent |= (1 << 0); - if (eventPolypressure->isChecked()) + if (eventPolypressure->isChecked()) showPartEvent |= (1 << 1); - if (eventController->isChecked()) + if (eventController->isChecked()) showPartEvent |= (1 << 2); - if (eventProgramchange->isChecked()) + if (eventProgramchange->isChecked()) showPartEvent |= (1 << 3); - if (eventAftertouch->isChecked()) + if (eventAftertouch->isChecked()) showPartEvent |= (1 << 4); - if (eventPitchbend->isChecked()) + if (eventPitchbend->isChecked()) showPartEvent |= (1 << 5); - if (eventSpecial->isChecked()) + if (eventSpecial->isChecked()) showPartEvent |= (1 << 6); config->canvasShowPartEvent = showPartEvent; @@ -502,11 +536,11 @@ void Appearance::apply() config->canvasCustomBgList = QStringList(); for (int i = 0; i < user_bg->childCount(); ++i) config->canvasCustomBgList << user_bg->child(i)->data(0, Qt::UserRole).toString(); - + config->styleSheetFile = styleSheetPath->text(); - + config->fonts[0].setFamily(fontName0->text()); - + config->fonts[0].setPointSize(fontSize0->value()); config->fonts[0].setItalic(italic0->isChecked()); config->fonts[0].setBold(bold0->isChecked()); @@ -543,15 +577,15 @@ void Appearance::apply() config->fonts[6].setBold(bold6->isChecked()); config->style = themeComboBox->currentIndex() == 0 ? QString() : themeComboBox->currentText(); - // setting up a new theme might change the fontsize, so re-read + // setting up a new theme might change the fontsize, so re-read fontSize0->setValue(QApplication::font().pointSize()); config->canvasShowGrid = arrGrid->isChecked(); - + config->globalAlphaBlend = globalAlphaVal->value(); - // set colors... MusEGlobal::config = *config; + MusEGlobal::muse->changeConfig(true); } @@ -706,8 +740,12 @@ void Appearance::colorItemSelectionChanged() case 0x41b: color = &config->selectTrackFg; break; case 0x41c: color = &config->partCanvasBg; break; case 0x41d: color = &config->ctrlGraphFg; break; + // 0x41e is already used (between 413 and 414) + case 0x41f: color = &config->rulerBg; break; + case 0x420: color = &config->rulerFg; break; + case 0x500: color = &config->mixerBg; break; case 0x501: color = &config->midiTrackLabelBg; break; case 0x502: color = &config->drumTrackLabelBg; break; diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp index cff98bdd..417345c0 100644 --- a/muse2/muse/conf.cpp +++ b/muse2/muse/conf.cpp @@ -859,6 +859,11 @@ void readConfiguration(Xml& xml, bool doReadMidiPortConfig, bool doReadGlobalCon MusEGlobal::config.transportHandleColor = readColor(xml); else if (tag == "waveEditBackgroundColor") MusEGlobal::config.waveEditBackgroundColor = readColor(xml); + else if (tag == "rulerBackgroundColor") + MusEGlobal::config.rulerBg = readColor(xml); + else if (tag == "rulerForegroundColor") + MusEGlobal::config.rulerFg = readColor(xml); + //else if (tag == "midiSyncInfo") // readConfigMidiSyncInfo(xml); /* Obsolete. done by song's toplevel list. arrangerview also handles arranger. @@ -1026,13 +1031,21 @@ void readConfiguration(Xml& xml, bool doReadMidiPortConfig, bool doReadGlobalCon //--------------------------------------------------------- // readConfiguration //--------------------------------------------------------- - bool readConfiguration() +{ + return readConfiguration(NULL); +} + +bool readConfiguration(const char *configFile) { - FILE* f = fopen(MusEGlobal::configName.toLatin1().constData(), "r"); + if (configFile == NULL) + configFile = MusEGlobal::configName.toLatin1().constData(); + + printf("Config File <%s>\n", configFile); + FILE* f = fopen(configFile, "r"); if (f == 0) { if (MusEGlobal::debugMsg || MusEGlobal::debugMode) - fprintf(stderr, "NO Config File <%s> found\n", MusEGlobal::configName.toLatin1().constData()); + fprintf(stderr, "NO Config File <%s> found\n", configFile); if (MusEGlobal::config.userInstrumentsDir.isEmpty()) MusEGlobal::config.userInstrumentsDir = MusEGlobal::configPath + "/instruments"; @@ -1398,6 +1411,8 @@ void MusE::writeGlobalConfiguration(int level, MusECore::Xml& xml) const xml.colorTag(level, "bigtimeForegroundcolor", MusEGlobal::config.bigTimeForegroundColor); xml.colorTag(level, "bigtimeBackgroundcolor", MusEGlobal::config.bigTimeBackgroundColor); xml.colorTag(level, "waveEditBackgroundColor", MusEGlobal::config.waveEditBackgroundColor); + xml.colorTag(level, "rulerBackgroundColor", MusEGlobal::config.rulerBg); + xml.colorTag(level, "rulerForegroundColor", MusEGlobal::config.rulerFg); MusEGlobal::writePluginGroupConfiguration(level, xml); diff --git a/muse2/muse/conf.h b/muse2/muse/conf.h index 0813ed3e..0b301829 100644 --- a/muse2/muse/conf.h +++ b/muse2/muse/conf.h @@ -54,6 +54,7 @@ class MidiFileConfig : public QDialog, public Ui::ConfigMidiFileBase { namespace MusECore { class Xml; extern bool readConfiguration(); +extern bool readConfiguration(const char *configFile); extern void readConfiguration(Xml&, bool doReadMidiPorts, bool doReadGlobalConfig); } diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp index ac7c50a6..0dc92c7a 100644 --- a/muse2/muse/gconfig.cpp +++ b/muse2/muse/gconfig.cpp @@ -125,6 +125,9 @@ GlobalConfigValues config = { QColor(255, 170, 0), // ctrlGraphFg; Medium orange QColor(0, 0, 0), // mixerBg; + QColor(0xe0, 0xe0, 0xe0), // Ruler background + QColor(0, 0, 0), // Ruler text + 384, // division; 1024, // rtcTicks true, // midiSendInit Send instrument initialization sequences @@ -207,6 +210,7 @@ GlobalConfigValues config = { MusEGlobal::PREFER_NEW, // drumTrackPreference true, // smartFocus 20, // trackHeight + }; } // namespace MusEGlobal diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h index d8e52e6e..52763032 100644 --- a/muse2/muse/gconfig.h +++ b/muse2/muse/gconfig.h @@ -24,7 +24,7 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ -#define NUM_PARTCOLORS 17 +#define NUM_PARTCOLORS 19 #define NUM_FONTS 7 #include @@ -134,6 +134,9 @@ struct GlobalConfigValues { QColor ctrlGraphFg; QColor mixerBg; + QColor rulerBg; + QColor rulerFg; + int division; int rtcTicks; bool midiSendInit; // Send instrument initialization sequences diff --git a/muse2/muse/widgets/appearancebase.ui b/muse2/muse/widgets/appearancebase.ui index 887f3834..3f270d36 100644 --- a/muse2/muse/widgets/appearancebase.ui +++ b/muse2/muse/widgets/appearancebase.ui @@ -23,7 +23,7 @@ - 0 + 2 @@ -189,9 +189,6 @@ false - - false - 1 @@ -1201,6 +1198,35 @@ + + + + MusE color scheme + + + Qt::AlignCenter + + + + + + + + current settings + + + + + light theme (changing overrides all other settings) + + + + + dark theme (changing overrides all other settings) + + + + diff --git a/muse2/muse/widgets/mtscale.cpp b/muse2/muse/widgets/mtscale.cpp index 00947f6f..e15d22fa 100644 --- a/muse2/muse/widgets/mtscale.cpp +++ b/muse2/muse/widgets/mtscale.cpp @@ -27,6 +27,7 @@ #include "mtscale.h" #include "song.h" +#include "app.h" #include "icons.h" #include "gconfig.h" @@ -60,9 +61,19 @@ MTScale::MTScale(int* r, QWidget* parent, int xs, bool _mode) connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool))); connect(MusEGlobal::song, SIGNAL(songChanged(MusECore::SongChangedFlags_t)), SLOT(songChanged(MusECore::SongChangedFlags_t))); connect(MusEGlobal::song, SIGNAL(markerChanged(int)), SLOT(redraw())); - + connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(configChanged())); + setFixedHeight(28); - setBg(QColor(0xe0, 0xe0, 0xe0)); + + setBg(MusEGlobal::config.rulerBg); + //setBg(QColor(0xe0, 0xe0, 0xe0)); + } + +void MTScale::configChanged() + { + setBg(MusEGlobal::config.rulerBg); + + } //--------------------------------------------------------- @@ -234,7 +245,7 @@ void MTScale::pdraw(QPainter& p, const QRect& r) //--------------------------------------------------- int y = 12; - p.setPen(Qt::black); + p.setPen(MusEGlobal::config.rulerFg); p.setFont(MusEGlobal::config.fonts[5]); p.drawLine(r.x(), y+1, r.x() + r.width(), y+1); QRect tr(r); @@ -270,8 +281,7 @@ void MTScale::pdraw(QPainter& p, const QRect& r) { if (m->second.current()) { - //p.fillRect(tr, white); - p.fillRect(wr, Qt::white); + p.fillRect(tr, Qt::white); } int x2; @@ -303,7 +313,7 @@ void MTScale::pdraw(QPainter& p, const QRect& r) if(xp >= -1023) { QRect r = QRect(xp+10, 0, x2-xp, 12); - p.setPen(Qt::black); + p.setPen(MusEGlobal::config.rulerFg); p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, m->second.name()); } @@ -343,7 +353,7 @@ void MTScale::pdraw(QPainter& p, const QRect& r) } } } - p.setPen(Qt::black); + p.setPen(MusEGlobal::config.rulerFg); if (pos[3] != INT_MAX) { int xp = mapx(pos[3]); if (xp >= x && xp < x+w) diff --git a/muse2/muse/widgets/mtscale.h b/muse2/muse/widgets/mtscale.h index 4f76dcc2..db873e7f 100644 --- a/muse2/muse/widgets/mtscale.h +++ b/muse2/muse/widgets/mtscale.h @@ -44,6 +44,7 @@ class MTScale : public View { private slots: void songChanged(MusECore::SongChangedFlags_t); + void configChanged(); protected: virtual void pdraw(QPainter&, const QRect&); diff --git a/muse2/muse/widgets/mtscale_flo.cpp b/muse2/muse/widgets/mtscale_flo.cpp index 9eb0253a..3b6ea502 100644 --- a/muse2/muse/widgets/mtscale_flo.cpp +++ b/muse2/muse/widgets/mtscale_flo.cpp @@ -27,6 +27,7 @@ #include "mtscale_flo.h" #include "song.h" +#include "app.h" #include "icons.h" #include "gconfig.h" #include "scoreedit.h" @@ -53,13 +54,20 @@ MTScaleFlo::MTScaleFlo(ScoreCanvas* parent_editor, QWidget* parent_widget) connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool))); connect(MusEGlobal::song, SIGNAL(songChanged(MusECore::SongChangedFlags_t)), SLOT(songChanged(MusECore::SongChangedFlags_t))); connect(MusEGlobal::song, SIGNAL(markerChanged(int)), SLOT(redraw())); - + connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(configChanged())); + parent=parent_editor; setFixedHeight(28); - setBg(QColor(0xe0, 0xe0, 0xe0)); + setBg(MusEGlobal::config.rulerBg); } +void MTScaleFlo::configChanged() + { + setBg(MusEGlobal::config.rulerBg); + + + } //--------------------------------------------------------- // songChanged //--------------------------------------------------------- @@ -193,7 +201,7 @@ void MTScaleFlo::draw(QPainter& p, const QRect& r) //--------------------------------------------------- int y = 12; - p.setPen(Qt::black); + p.setPen(MusEGlobal::config.rulerFg); p.setFont(MusEGlobal::config.fonts[5]); p.drawLine(r.x(), y+1, r.x() + r.width(), y+1); QRect tr(r); @@ -230,7 +238,7 @@ void MTScaleFlo::draw(QPainter& p, const QRect& r) if(xp >= -1023) { QRect r = QRect(xp+10, 0, x2-xp, 12); - p.setPen(Qt::black); + p.setPen(MusEGlobal::config.rulerFg); p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, m->second.name()); } @@ -262,7 +270,7 @@ void MTScaleFlo::draw(QPainter& p, const QRect& r) //--------------------------------------------------- - p.setPen(Qt::black); + p.setPen(MusEGlobal::config.rulerFg); unsigned ctick; int bar1, bar2, beat; diff --git a/muse2/muse/widgets/mtscale_flo.h b/muse2/muse/widgets/mtscale_flo.h index 4b089f5e..caadc994 100644 --- a/muse2/muse/widgets/mtscale_flo.h +++ b/muse2/muse/widgets/mtscale_flo.h @@ -46,6 +46,7 @@ class MTScaleFlo : public View { private slots: void songChanged(MusECore::SongChangedFlags_t); + void configChanged(); protected: virtual void draw(QPainter&, const QRect&); diff --git a/muse2/share/CMakeLists.txt b/muse2/share/CMakeLists.txt index 33b98821..3d05e10c 100644 --- a/muse2/share/CMakeLists.txt +++ b/muse2/share/CMakeLists.txt @@ -36,8 +36,4 @@ subdirs( locale ) -install (FILES didyouknow.txt DESTINATION ${MusE_SHARE_DIR} ) - -# We don't have a splash image for MusE2 yet. When we do, the -# following line can be uncommented: -install (FILES splash.png DESTINATION ${MusE_SHARE_DIR} ) +install (FILES didyouknow.txt splash.png darkbase.qss darkbase.cfg lightbase.cfg DESTINATION ${MusE_SHARE_DIR} ) diff --git a/muse2/share/darkbase.cfg b/muse2/share/darkbase.cfg new file mode 100644 index 00000000..bdf65cf8 --- /dev/null +++ b/muse2/share/darkbase.cfg @@ -0,0 +1,57 @@ + + + + 170 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/muse2/share/darkbase.qss b/muse2/share/darkbase.qss new file mode 100644 index 00000000..1d4a24b5 --- /dev/null +++ b/muse2/share/darkbase.qss @@ -0,0 +1,4 @@ +QWidget { + background-color: rgb(30,30,30); + color: rgb(120,120,120); +} diff --git a/muse2/share/lightbase.cfg b/muse2/share/lightbase.cfg new file mode 100644 index 00000000..d2070e9b --- /dev/null +++ b/muse2/share/lightbase.cfg @@ -0,0 +1,57 @@ + + + + 170 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3