Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the overview-waveform darker for the played portion of the track #1203

Merged
merged 7 commits into from
Mar 12, 2017

Conversation

MK-42
Copy link
Contributor

@MK-42 MK-42 commented Mar 4, 2017

… as a stronger visual indicator of the current position

aiming to fix lp:1328748
Actually that change set is only one single line of code. I don't have any experience with qt painting and perfomance measures. So please feel free to comment.

I am thinking about making the color configurable for skin artists. What do you think about that?

… as a stronger visual indicator of the current position
@Be-ing
Copy link
Contributor

Be-ing commented Mar 4, 2017

Cool idea. Please post screenshots when proposing changes to the GUI.

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 4, 2017

Cool idea. Please post screenshots when proposing changes to the GUI.

sorry, forgot about that. There you are:
desaturate_deere
desaturate_latenight
desaturate_shade
desaturate_latenight_hsv

I chose black and opacity of 200 (in range 0-255). Looks good for me. But as said, maybe let the skin artists decide that?

Edit: Added view of hsv waveform at least for latenight

@Be-ing
Copy link
Contributor

Be-ing commented Mar 4, 2017

Yes, I think skin designers should be able to customize it. Does this make the playhead indicator redundant?

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 4, 2017

I would like to stick with the additional playhead indicator (so having both). For some skins it might be enough to use this overlay, but I think not every usecase will fit in that one.

My usecase for the overlay was to have a quick view how far the track is if I'm further away from the screen.
Having that sharp 'here we are' line may help to see the current position wrt to some change in the track (visible in the waveform) or sth like that.

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 4, 2017

Never looked into the skin stuff before. Any way to get a color with alpha from the skin xml to a QColor? Only saw usages of setNamedColor, that can handle alpha channels only since QT 5.2

We could use a default alpha value, or two Nodes in the skin xml, one for color, one for alpha?

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 4, 2017

I chose to parse the format that QT5.2 uses for RGBA colors in hex format, which is #AARRGGBB. Parsing that color is not really something that WaveformSignalColors should do, as its more a lowlevel helper function, but I don't know what would be an appropriate place for that function. Also I forgot to make it static... Any hints where to put that piece of code in the skin section is appreciated, I don't know the skin code well yet.

The Skin-Node is called PlayedOverlayColor as a first shot.

What do you think about that?

@@ -134,6 +140,30 @@ void WaveformSignalColors::fallBackDefaultColor() {
fallBackFromSignalColor();
}

QColor WaveformSignalColors::rgbaColorFromString(QString sColorString) {
// Takes a string with format #AARRGGBBAA and returns the corresponding QColor with alpha-channel set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra AA at the end

@@ -134,6 +140,30 @@ void WaveformSignalColors::fallBackDefaultColor() {
fallBackFromSignalColor();
}

QColor WaveformSignalColors::rgbaColorFromString(QString sColorString) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be straight forward to move this function to skincontext.h similar to
hasNodeSelectString()

something like

hasNodeSelectColor()

This way all color strings in the skin can benefit from the #AARRGGBB syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go with selectColor() alone, I think the presence-info is not required in that place, falling back to transparent makes most sense for backwards-compat. And an empty string will be converted to fully transparent by QT.

@@ -55,6 +55,12 @@ bool WaveformSignalColors::setup(const QDomNode &node, const SkinContext& contex
m_playPosColor = m_axesColor;
}

m_playedOverlayColor = rgbaColorFromString(context.selectString(node, "PlayedOverlayColor"));
if (!m_playedOverlayColor.isValid()) {
m_playedOverlayColor = QColor(0,0,0,200);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment what this color is.
This should also become a const in th anonymous namesace on to of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be using Qt::transparent for backwards-compat.

@@ -338,6 +338,8 @@ void WOverview::paintEvent(QPaintEvent * /*unused*/) {
}

painter.drawImage(rect(), m_waveformImageScaled);
// desaturate the scaled waveform-image up to the current play-position by overdrawing semi-transparent black
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the color is now customizable the comment is outdated.
Please skip this line if the color is fully transparent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and we "try" to break lines before column 80.

@Be-ing
Copy link
Contributor

Be-ing commented Mar 5, 2017

Never looked into the skin stuff before. Any way to get a color with alpha from the skin xml to a QColor? Only saw usages of setNamedColor, that can handle alpha channels only since QT 5.2

Then we cannot rely on setNamedColor alone because Mixxx 2.1 will still be using Qt 4. Qt4 does support transparency but it will take a little more code than just calling setNamedColor.

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 5, 2017

Then we cannot rely on setNamedColor alone because Mixxx 2.1 will still be using Qt 4. Qt4 does support transparency but it will take a little more code than just calling setNamedColor.

For that reason I already implemented that parsing logic by hand, using the QT5.2 #AARRGGBB Syntax.

Thanks @daschuer for reviewing, will address those comments asap.

@@ -338,6 +338,8 @@ void WOverview::paintEvent(QPaintEvent * /*unused*/) {
}

painter.drawImage(rect(), m_waveformImageScaled);
// desaturate the scaled waveform-image up to the current play-position by overdrawing semi-transparent black
painter.fillRect(0, 0, m_iPos, m_waveformImageScaled.height(), m_signalColors.getPlayedOverlayColor());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work with horizontal waveform. Please handle the vertical waveform case also. You can use https://github.com/ninomp/mixxx/tree/verticalwaveform_skin for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that hint!

m_playedOverlayColor = QColor(0,0,0,200);
}
m_playedOverlayColor = WSkinColor::getCorrectColor(m_playedOverlayColor).toRgb();

m_bgColor.setNamedColor(context.selectString(node, "BgColor"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, could you use the new rgbaColorFromString function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Y)

@Be-ing Be-ing mentioned this pull request Mar 7, 2017
@MK-42
Copy link
Contributor Author

MK-42 commented Mar 8, 2017

Now working for vertical and horizontal waveforms. Moved color-parsing logic into skincontext.h, made some more colors 'alpha-capable'.
I didn't chose rgba colors for the waveform signal colors, because I don't know what that would mean performance wise. Is there a usecase for that?

@Be-ing
Copy link
Contributor

Be-ing commented Mar 8, 2017

I didn't chose rgba colors for the waveform signal colors, because I don't know what that would mean performance wise. Is there a usecase for that?

I can't think of a use case for that.

Copy link
Contributor

@Be-ing Be-ing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, just a few small changes.


QColor color;
QString sColorString = nodeToString(selectElement(node, nodeName));
if (sColorString.startsWith('#') && sColorString.length() == 9){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: space between ) and {


// Overlay the played part of the overview-waveform with a skin defined color
QColor playedOverlayColor = m_signalColors.getPlayedOverlayColor();
if (playedOverlayColor.alpha() > 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: space between ) and {

// Overlay the played part of the overview-waveform with a skin defined color
QColor playedOverlayColor = m_signalColors.getPlayedOverlayColor();
if (playedOverlayColor.alpha() > 0){
if (m_orientation == Qt::Vertical){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: space between ) and {

m_playedOverlayColor = Qt::transparent;
}

m_bgColor = context.selectColor(node, "BgColor");
if (!m_bgColor.isValid()) {
m_bgColor = QColor(0, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have changed this in #1208, but could you change this from QColor(0, 0, 0) to Qt::transparent to restore backwards compatibility with old skins?

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 9, 2017

should be fixed now

@Be-ing
Copy link
Contributor

Be-ing commented Mar 9, 2017

LGTM! 👍 @daschuer, ready for merge?

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 10, 2017

failing travis is a timeout I think. ready to merge from my perspective

@ronso0
Copy link
Member

ronso0 commented Mar 10, 2017

I can see the Cue mark in the screens, but just to be sure: HotCue marks are layed on top of this, right?

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 10, 2017

I can see the Cue mark in the screens, but just to be sure: HotCue marks are layed on top of this, right?

The overlay is drawed directly on top of the waveform, before (under) everything else:
cuesOnTop

@ronso0
Copy link
Member

ronso0 commented Mar 10, 2017

Cooooool! nice skin you have there ;)

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 10, 2017

It was your amazing work in Tango that made me implement that ;) Its nice to have that small Deck section without (for me) unneeded stuff. But the play pos wasnt that clear I thought. Would really like to see that in Tango therefore.

@ronso0
Copy link
Member

ronso0 commented Mar 10, 2017

It was your amazing work in Tango that made me implement that ;) Its nice to have that small Deck section without (for me) unneeded stuff.

My pleasure! Very nice to feel that it works out as intended.

But the play pos wasnt that clear I thought.

Wasn't 100% happy with that either. Once this is merged I am -like billions of mixxxers I suppose

@ronso0
Copy link
Member

ronso0 commented Mar 10, 2017

So <PlayedOverlayColor>#AARRGGBB<.. will be the new tag to work with. Anything else?

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 10, 2017

Yes, thats it.
New color is called PlayedOverlayColor.
And Alpha also works for AxesColor PlayPosColor and BgColor ;-)

@ronso0
Copy link
Member

ronso0 commented Mar 10, 2017

Bamm!!

@daschuer
Copy link
Member

Thank you for this PR. It LGTM.

Before merge wee need your permission
Please sign https://docs.google.com/a/mixxx.org/spreadsheet/viewform?formkey=dEpYN2NkVEFnWWQzbkFfM0ZYYUZ5X2c6MQ
and comment here when done. Thank you.

@MK-42
Copy link
Contributor Author

MK-42 commented Mar 12, 2017

Already did that Back in #587 :)

@daschuer
Copy link
Member

Ah sorry, of cause you did.

@daschuer daschuer merged commit 0b34263 into mixxxdj:master Mar 12, 2017
@MK-42 MK-42 deleted the desaturate_waveforms branch March 13, 2017 14:18
@esbrandt esbrandt mentioned this pull request Jun 24, 2017
37 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants