Skip to content

Commit

Permalink
Improve the visibility of tied notes and the caret when in dark mode
Browse files Browse the repository at this point in the history
Bug #357
  • Loading branch information
cameronwhite committed Jan 28, 2022
1 parent 03dae22 commit c3d2709
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Thanks to the following contributors who worked on this release:
- Added French translation (#355).

### Changed
- Improved the visibility of some colors in the dark score theme (#357)

### Fixed
- Fixed various playback issues with alternate endings (#306, #353, #354)
Expand Down
4 changes: 2 additions & 2 deletions source/app/scorearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void ScoreArea::renderDocument(const Document &document)

auto start = std::chrono::high_resolution_clock::now();

myCaretPainter =
new CaretPainter(document.getCaret(), document.getViewOptions());
myCaretPainter = new CaretPainter(
document.getCaret(), document.getViewOptions(), *myActivePalette);
myCaretPainter->subscribeToMovement([=]() {
adjustScroll();
});
Expand Down
18 changes: 10 additions & 8 deletions source/painters/caretpainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
const double CaretPainter::PEN_WIDTH = 0.75;
const double CaretPainter::CARET_NOTE_SPACING = 6;

CaretPainter::CaretPainter(const Caret &caret, const ViewOptions &view_options)
CaretPainter::CaretPainter(const Caret &caret, const ViewOptions &view_options,
const QPalette &palette)
: myCaret(caret),
myViewOptions(view_options),
myCaretConnection(caret.subscribeToChanges([=]() {
onLocationChanged();
}))
myPalette(palette),
myCaretConnection(
caret.subscribeToChanges([=]() { onLocationChanged(); }))
{
}

Expand All @@ -55,12 +56,13 @@ void CaretPainter::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
const bool hasFocus = scene()->views().first()->hasFocus();

// Set color.
QColor color = myPalette.link().color();
if (!hasFocus)
painter->setPen(QPen(Qt::darkGray, PEN_WIDTH));
color.setAlpha(128);
else if (myCaret.isInPlaybackMode())
painter->setPen(QPen(Qt::red, PEN_WIDTH));
else
painter->setPen(QPen(Qt::blue, PEN_WIDTH));
color = myPalette.linkVisited().color();

painter->setPen(QPen(color, PEN_WIDTH));

double left = myLayout->getPositionX(location.getPositionIndex());
const double y1 = 0;
Expand Down
4 changes: 3 additions & 1 deletion source/painters/caretpainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class ViewOptions;
class CaretPainter : public QGraphicsItem
{
public:
CaretPainter(const Caret &caret, const ViewOptions &view_options);
CaretPainter(const Caret &caret, const ViewOptions &view_options,
const QPalette &palette);

virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *,
QWidget *) override;
Expand All @@ -53,6 +54,7 @@ class CaretPainter : public QGraphicsItem

const Caret &myCaret;
const ViewOptions &myViewOptions;
const QPalette &myPalette;
std::unique_ptr<LayoutInfo> myLayout;
std::vector<QRectF> mySystemRects;
boost::signals2::scoped_connection myCaretConnection;
Expand Down
10 changes: 7 additions & 3 deletions source/painters/systemrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,14 @@ void SystemRenderer::drawTabNotes(const Staff &staff,
const QString text =
QString::fromStdString(Util::toString(note));

QColor color = myPalette.text().color();
// Similar to myPalette.placeholderText(), but with alpha=64
// instead of 128 to be more faded.
if (note.hasProperty(Note::Tied))
color.setAlpha(64);

auto tabNote = new SimpleTextItem(
text, myPlainTextFont, TextAlignment::Top,
QPen(note.hasProperty(Note::Tied) ? myPalette.dark().color()
: myPalette.text().color()),
text, myPlainTextFont, TextAlignment::Top, QPen(color),
QBrush(myPalette.light().color()));

centerHorizontally(*tabNote, location,
Expand Down

0 comments on commit c3d2709

Please sign in to comment.