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

feat: static color coding for key column #13390

Merged
merged 23 commits into from
Jul 13, 2024

Conversation

danferns
Copy link
Contributor

@danferns danferns commented Jun 19, 2024

Hi! I just got the core of this feature working and I'm seeking feedback.

A small rectangle is drawn next to the Key label in the Library. The color of the rectangle is based on the Key of the track.

image


I'm concerned about the method used for finding the track's key. Right now, I'm using KeyUtils::guessKeyFromText on the Key string, but I don't think that'll work if the user sets custom Key Notation.

I want to use the value in ColumnCache::COLUMN_LIBRARYTABLE_KEY_ID. But I haven't been able to figure out how to access this column from the QModelIndex& index that is passed into KeyDelegate::paintItem. I'm not sure if the column is even available.

Is there a place where I can see how the index is structured?


Once complete, this will resolve #7810.

@Swiftb0y
Copy link
Member

Once complete, this will resolve #7810.

I don't think so. That issue requests to color the key depending on how compatible it is to the currently playing track.

src/library/tabledelegates/keydelegate.cpp Outdated Show resolved Hide resolved
src/library/tabledelegates/keydelegate.h Show resolved Hide resolved
src/library/tabledelegates/keydelegate.cpp Outdated Show resolved Hide resolved
src/library/tabledelegates/keydelegate.cpp Outdated Show resolved Hide resolved
Comment on lines +149 to +161
constexpr mixxx::RgbColor kMixxxKeyColor1(0xFC4949);
constexpr mixxx::RgbColor kMixxxKeyColor2(0xFE642D);
constexpr mixxx::RgbColor kMixxxKeyColor3(0xF98C27);
constexpr mixxx::RgbColor kMixxxKeyColor4(0xFED600);
constexpr mixxx::RgbColor kMixxxKeyColor5(0x99FE00);
constexpr mixxx::RgbColor kMixxxKeyColor6(0x42FE3E);
constexpr mixxx::RgbColor kMixxxKeyColor7(0x0AD58F);
constexpr mixxx::RgbColor kMixxxKeyColor8(0x0AE7E7);
constexpr mixxx::RgbColor kMixxxKeyColor9(0x04C9FE);
constexpr mixxx::RgbColor kMixxxKeyColor10(0x3D8AFD);
constexpr mixxx::RgbColor kMixxxKeyColor11(0xAC64FE);
constexpr mixxx::RgbColor kMixxxKeyColor12(0xFD3FEA);

Copy link
Member

Choose a reason for hiding this comment

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

as a follow up, it would be nice if the palette was customizable via the Color Preferences. similar to track colors.

Copy link
Member

Choose a reason for hiding this comment

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

Super nice to have, follow up²: set the colors in the notation table in Key preferences

Copy link
Member

@Swiftb0y Swiftb0y Jun 26, 2024

Choose a reason for hiding this comment

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

Yeah, Though I guess we'll have to decide on whether its better to put in the "Colors" or the "Key Detection" settings. The former would be more consistent IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's a little sketch:

image

Copy link
Member

Choose a reason for hiding this comment

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

I'd somehow try to put it in the same column. but I'm not a UI designer. Wdyt @ronso0?

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 think it looks more compact:

image

Copy link
Member

Choose a reason for hiding this comment

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

maybe swap the order of the text and the check box so its all still right aligned? idk, IIANA Designer.

@Swiftb0y
Copy link
Member

I'm concerned about the method used for finding the track's key. Right now, I'm using KeyUtils::guessKeyFromText on the Key string, but I don't think that'll work if the user sets custom Key Notation.

Probably not. You should store the underlying mixxx::track::io::key::ChromaticKey in the cell when its text gets set. You can use a custom item role for that (I think, I'm not much into Qt MV programming tbh).

@danferns
Copy link
Contributor Author

Thank you so much @Swiftb0y for the feedback! Preferences for key color palettes is definitely in the plans. I will apply the requested changes and try the item role method.

ronso0
ronso0 previously requested changes Jun 19, 2024
Copy link
Member

@ronso0 ronso0 left a comment

Choose a reason for hiding this comment

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

Thank you, this looks nice!

src/library/tabledelegates/keydelegate.cpp Outdated Show resolved Hide resolved
src/library/basetracktablemodel.cpp Show resolved Hide resolved
src/library/tabledelegates/keydelegate.cpp Outdated Show resolved Hide resolved
src/library/tabledelegates/keydelegate.cpp Outdated Show resolved Hide resolved
src/track/keyutils.cpp Outdated Show resolved Hide resolved
src/track/keyutils.cpp Outdated Show resolved Hide resolved
@daschuer
Copy link
Member

daschuer commented Jul 1, 2024

Can you update the screenshot in the initial description of this PR? This way it is more significant if one is later following links from the Changelog.

@daschuer
Copy link
Member

daschuer commented Jul 1, 2024

Is the draft state still correct or is it ready for final review and tests?

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Just a minor comment. Rest LGTM, thank you.

src/library/basetracktablemodel.cpp Show resolved Hide resolved
@@ -144,6 +144,21 @@ constexpr mixxx::RgbColor kVirtualDJTrackColorBlue(0x0000FF);
constexpr mixxx::RgbColor kVirtualDJTrackColorFuchsia(0xFF00FF);
constexpr mixxx::RgbColor kVirtualDJTrackColorWhite(0xFFFFFF);

// Default Mixxx Key Color Palette
Copy link
Member

Choose a reason for hiding this comment

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

Please give also a hint as source code comment, how these colors have been generated

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 is a comon practice to follow the Hue circle to easily distinguish neighbors.
However there might be issues with all kind of eye issues.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@Swiftb0y Swiftb0y Jul 1, 2024

Choose a reason for hiding this comment

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

We could provide preset palettes optimized for the different types of colorblindness. I think gradients for those already exist online. This would be fairly straightforward to implement once the requested custom keypalettes are in place.

@danferns
Copy link
Contributor Author

danferns commented Jul 1, 2024

Is the draft state still correct or is it ready for final review and tests?

Yes, I am not done yet. I still have to read the Key Colors setting and only render the rectangle if it is enabled.

Also I'd like to squash a couple of commits before review, at least the one which was failing to build.

@danferns
Copy link
Contributor Author

danferns commented Jul 1, 2024

I want to read the setting using ConfigKey("[Config]", "KeyColorsEnabled") inside KeyUtils::keyToColor (if key colors are disabled, return an invalid color). But to do that, I would need access to the pConfig variable inside keyutils.cpp.

I see that the pConfig is passed around in class constructors. Is there a way to access it directly?

Should I go about this in some other way entirely?

@Swiftb0y
Copy link
Member

Swiftb0y commented Jul 1, 2024

I don't think accessing the config in the KeyUtils is a good idea. Can you share a little more insight on what you're trying to accomplish? Then we can brainstorm together.

@danferns
Copy link
Contributor Author

danferns commented Jul 1, 2024

Can you share a little more insight on what you're trying to accomplish?

I have added a preference setting to enable/disable Key Colors. It is called KeyColorsEnabled and I put it under the [Config] group. It is defined inside ColorPaletteSettings.

Now, I want to display the key colors only when this setting is on.

Initially, I was trying to do this preference check inside KeyDelegate. But then I noticed that the KeyUtils::keyToString function is already aware of the user's chosen notation (it doesn't need to be passed in explicitly). So I thought maybe KeyUtils::keyToColor should also do the same, and access the user settings on it's own.

Should the check instead be done inside KeyDelegate?

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you. Who wants to press the button? Did you want to rebase first?

@danferns
Copy link
Contributor Author

Thank you so much, this is very helpful. I'll discuss with Daniel for the next steps, and I'll keep these points in mind for future PRs. I am growing a lot thanks to this project. :)

I do want to rebase!

@daschuer
Copy link
Member

Thank you for the review. Yes, there is room for improvements. On the other hand we have tight plan for the remaining project. From this point of view I would rather see a beautiful Heat column instead of beautiful code.

We have already the green check marks so I will merge once @danferns gives a go.

If you feeling lucky to address some of @Swiftb0y points, go ahead and propose it in a separate PR.

danferns and others added 16 commits July 12, 2024 12:59
also check bounds for Open Key number inside it.

Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
This will allow for narrow column setups.
Co-authored-by: ronso0 <ronso0@mixxx.org>
Add a `KeyColorsEnabled` setting under the `[Config]` group. And render a checkbox for it in the Color preferences.
Co-authored-by: ronso0 <ronso0@mixxx.org>
Co-authored-by: ronso0 <ronso0@mixxx.org>
also add checkbox to <tabstops>

Co-authored-by: ronso0 <ronso0@mixxx.org>
@danferns
Copy link
Contributor Author

I'm done with the rebase! I squashed only a build error, and two commits involving indentation / comments. If anything else is needed then let me know, but otherwise I am ready for this PR to be merged!

@Swiftb0y
Copy link
Member

On the other hand we have tight plan for the remaining project. From this point of view I would rather see a beautiful Heat column instead of beautiful code.

I agree in this case.

@daschuer
Copy link
Member

Thank you very much! This looks really nice and works good.

@daschuer daschuer merged commit 1b9ebc1 into mixxxdj:main Jul 13, 2024
13 checks passed
@acolombier
Copy link
Contributor

After synching my dev branch, I just seen that eye candy appeared. It looks very good! Thanks for that feature!

@Eve00000
Copy link
Contributor

Eve00000 commented Jul 14, 2024

I tested this today, some remarks:

  • I don't have a key palette under 'Enable Key Colors' in Preferences -> Colors
    -Pushing 'Apply' after changing 'Enable Key Colors' does not work, changes only happen after push on 'OK'
  • Nice color bar in 'Key'-column but Key text is cut off on the left side (normally text is cut of on the right side) while my most important part is on the left side.
    afbeelding
    afbeelding

@ronso0
Copy link
Member

ronso0 commented Jul 14, 2024

  • I don't have a key palette under 'Enable Key Colors' in Preferences -> Colors

There is only one palette atm.

Repaint with/without colors only happens when the table is repainted after the preferences are closed.

@danferns
Copy link
Contributor Author

  • but Key text is cut off on the left side (normally text is cut of on the right side)

Thank you for reporting this. Just fixed it, a PR will come soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Color code key column in library
6 participants