-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Library controls color selector #13077
base: main
Are you sure you want to change the base?
Conversation
src/library/librarycontrol.cpp
Outdated
while (steps != 0) { | ||
if (steps > 0) { | ||
pActiveView->assignNextTrackColor(); | ||
steps--; | ||
} else { | ||
pActiveView->assignPreviousTrackColor(); | ||
steps++; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this possible without the while
? It's not very efficient and could cause visual artifacts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review.
colorPalette.nextColor() only handles color codes, the actual QT event is thrown with track->setColor().
So I think no visual artifacts or performance issue can be caused by this.
Another code using this have been push last week (see #13066)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @Swiftb0y is referring to the Track::colorUpdated(color) signal that is fired for each color change whic causes repaint calls everywhere that track (or many tracks) is loaded (tracks view, decks), and with the selector
color changes can indeed occur at high rates.
Didn't think of that during my previous review 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ideally the color selector would be moved to the track itself, find the desired color and assign it right away.
IIUC that only refers to the situation when we have select steps buffered, e.g. from MIDI, and LibraryControl is going to do one by one. Because 'quick' color switch may also happen when triggering color_next/_prev quickly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
causes repaint calls everywhere that track (or many tracks)
okay, WTrackTableView::assignNextTrackColor
acts only on the first selected track.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ideally the color selector would be moved to the track itself
nope, to ColorPalette::nextColor
: find the Nth next/prev color (incl. palette wrap-around), return, apply to track.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
causes repaint calls everywhere
Yes. thats what I was referring to.
IIUC that only refers to the situation when we have select steps buffered,
That seems like an ugly workaround. Ideally the API would just be changed so you can just set n'th next color directly.
from MIDI, and LibraryControl is going to do one by one.
If the user quickly cycles through colors by pressing the next/prev button quickly, thats fine. Especially since there is quite a lot of delay between the individual presses (which is not true for a programmed loop).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify:
"IIUC that only refers to the situation when we have select steps buffered"
was meant like
"IIUC that only affects the situation when we have select steps buffered" ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I was looking at the wrong patch when I first replied (the one in basetrackplayer)
So I updated this one following your advice, what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test result :
With this version, setting [library], track_color_selector to 5 display one time this message :
"debug [Main] BaseTrackCache(0x562e25698fb0) updateIndexWithQuery took 0 ms"
With the old version (while loop in librarycontrol), the same manipulation triggers it once too.
Both are functionally the same.
Is there any other debug message I could use to check the repaint call ?
src/widget/wtracktableview.cpp
Outdated
while (steps != 0) { | ||
if (steps > 0) { | ||
color = colorPalette.nextColor(color); | ||
steps--; | ||
} else { | ||
color = colorPalette.previousColor(color); | ||
steps++; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this solution still does a lot of searching. we can go one step further
while (steps != 0) { | |
if (steps > 0) { | |
color = colorPalette.nextColor(color); | |
steps--; | |
} else { | |
color = colorPalette.previousColor(color); | |
steps++; | |
} | |
} | |
const int currentColorIdx = colorPalette.indexOf(color); | |
const int newColorIndex = rem_euclid(currentColorIdx + steps, colorPalette.size()); | |
color = colorPalette.at(newColorIndex); |
rem_euclid
is a euclidean remainder/modulo which you'll have to implement in util/math.h
. There are plenty of solutions to this online that are reasonably fast (remember %
is terribly slow, solutions using three modulos in a row are likely suboptimal).
You might also want to consider to implement this as nextNthColor
in ColorPalette
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion !
But i'm not sure the modulo efficiency is relevant here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here probably not, no, but if we add it as a general function to math, we should still make sure its within reasonable limits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about simply moving this to colorpalette so it is available elsewhere?
ColorPalette::getNthColor()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simply moved the while loop to getNthColor
, as suggested by @ronso0 because there are too many individual cases that are already handled in nextColor
and previousColor
(for example index -1 is no color, and you need to cycle through it too).
I felt that trying to be overefficient here would damage readability and not gain execution time given the nature of the color change (only manual changes of a few steps can happen).
I called this function in the per deck track_color_selector
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test results:
The steps maximum value is 99, min is -99. (is it hardcoded in the control definition ?)
It takes 0ms to execute and there are no visual artifacts.
I made sure we really cycle through the palette, even with big values.
Works for Library and Channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, the visual artifact problem should be solved, 0ms doesn't mean its very efficient though (milliseconds is wayy too large of a timescale). At least add a TODO at the loop location please.
src/library/librarycontrol.cpp
Outdated
LibraryView* pActiveView = m_pLibraryWidget->getActiveView(); | ||
if (!pActiveView) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I have a WIP branch that makes use of WLibrary::getCurrentTrackTableView()
. This allows to remove many virtual methods from libraryview.h and library features (DlgMissing etc.) which essentially just redirect calls to their own WTrackTableView (which you didn't do here, which means the color controls don't work in AutoDJ, Missing and Hidden?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, my knowledge of the codebase is clearly insufficient to understand this comment.
I cannot find the getCurrentTrackTableView
method anywhere.
Why would AutoDJ need these features ?
How does he access them ?
Can you clarify or point me to the relevant files ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I was knee-deep into it when I wrote this.
Like the color select slots, many control slots in LibraryControl call methods of the 'active view'. This can be anything that inherits LibraryView: a pure WTrackTableView, a html root view (top-level item of Crates and Playlists), or some controls row + table view (Auto DJ, Recording, Analysis).
So, until now, a virtual function in libraryview.h needs to be overriden not just in WTrackTableView but in every view/feature where a certain control should be availble. "Until now" because I opened #13335 earlier today which makes use of WLibrary::getCurrentTrackTableView() to get rid of all the virtuals and overrides (see what I removed there).
That's why AutoDJ doesn't need it, but you probably want the color controls to work in the AutoDJ and Recording table, too.
I cannot find the
getCurrentTrackTableView
method anywhere.
Probably because your branch is based on an older version of main that doesn't have it, yet, not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I've been using the Github code search a ot lately, very handy:
https://github.com/search?q=repo%3Amixxxdj%2Fmixxx%20%22searchterm%22&type=code
I have a search accelerator (shortcut) and I wrap the term in quotes " (%22) so I use search terms with whitespaces.
23ad535
to
7bd68a8
Compare
#13335 has been merged, please fix the conflicts (switch to getCurrentTrackTableView()) |
This PR is marked as stale because it has been open 90 days with no activity. |
Also unified other color controls implementation with deck track color controls
added the last control : selector
7bd68a8
to
6d46304
Compare
6d46304
to
561ab07
Compare
src/library/librarycontrol.cpp
Outdated
|
||
void LibraryControl::slotTrackColorNext(double v) { | ||
if (!m_pLibraryWidget || v <= 0) { | ||
LibraryView* pActiveView = m_pLibraryWidget->getCurrentTrackTableView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to WTrackTableView
LibraryView* pActiveView = m_pLibraryWidget->getCurrentTrackTableView(); | |
WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView(); |
and use pTrackTableView
below.
Switch to ptracktableview
Please resolve the merge conflict, otherwise the CI builds will not start. |
@aqw42 Please ammend the last fixup commit in to the 'merge branch main' commits. So please also check all the previous commits build. |
Co-authored-by: ronso0 <ronso0@mixxx.org>
cd29890
to
e70da63
Compare
// TODO : Use rem_euclid modulo function instead of a loop | ||
while (steps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should address this in this PR IMO. The repeated calls to nextColor
/previousColor
which in turn call indexOf
are highly suboptimal (in terms of wasted computations).
@Swiftb0y these comments are mostly unimportant or details that we already discussed 4 month ago. |
@aqw42 I don't think this is the appropriate tone, considering the delay of 4 months stems from the fact that you missed my reminder in June. (and none of the contributors, me included, gave this high prio considering more important 2.4/2.5 fixes that had to be done). Let's fix/polish this and get it merged soonish. |
sure these comments are certainly nitpicks to a degree, but I feel like they're important enough to raise. The fact that I brought them up even though we've already discussed them should emphasize their importance as well as the fact that they have not yet been addressed. Trust me, I want to do anything but to waste your time, but largescale software development requires careful consideration of each change, otherwise the result will become a large mess that nobody wants to work on anymore. So please bear with me when I ask for a little bit of polish. It helps you to improve your code and us all to improve mixxx. Thank you. |
Just some cleanup.. |
@Swiftb0y Have your concerns all been addressed? |
Add
[Library], track_color_selector
Follows #13066 and #2541
Tested on Debian :
-> Using developer mode, messing with the controls values
-> Using a MIDI controller, mapping each of the controls to a push button or a rotary encoder
Everything worked fine.
New controls list (note to myself for the future manual addition)