Default cue color#2153
Conversation
|
How should we communicate to the controller scripts that the skin has been reloaded? Via a CO or shall we provide a method to register a callback without being tied to a CO? |
|
I am in favor of a simple CO. The infrastructure is already there and it's easy to integrate into JS. The CO should just contain the value of the current colorID for that skin. Controllers can then easily bind to it and adjust their color map accordingly. |
|
I've added a "[Skin] reloaded" CO that is triggered when the skin is reloaded (not triggered on mixxx startup). With this CO scripts can know when to check for a new default color for the cuepoints with NO COLOR. |
|
So how exactly is that new color getting communicated? Or how does the mapping retrieve it exactly? |
|
Yes, sorry I should have detailed this. You get the "No Color" color with the regular color js functions, this is with Before this PR, the "No Color" always returned the black color. Now, if the skin declares a default color for it with the So, unless you were treating the "No color" in a special way, you don't need to change anything. You will always get the appropriate color values for it. You only need to listen to the "[Skin] reloaded" CO, query the "No Color" again in case it changes and update your controller leds. Makes sense? Let me know if the explanation is still not clear enough. |
|
@Swiftb0y If you have an RGB controller I would appreciate if you could do a quick test of this. I don't have such a controller :( |
|
I think I know what you mean but I'm still not quite sure yet. The behavior of the |
With this, you get the color values for whatever PredefiendColor is set to hotcue_1. If hotcue_1 happens to be set to "No Color", the Additionally you need to add something like the snippet below to make sure you update the default color for "No Color" hotcues when the skin changes: |
|
The Issue is that we have to restrict the whole feature to the predefined color palette. Most controllers don't support or don't have a way documented to set arbitrary colors for their pads. So to keep it compatible with all controllers, the 'no color' color must be an 'alias' to a color from the palette. |
|
I see your point. I think we can add yet another skin option (not replacing |
|
I would add another CO |
|
New implementation. As @Swiftb0y suggested, there's a new Cases I tested:
In all cases I asserted that the All tests are ok except the last one, but it's because the script's init function is not called when changing mapping. This is an existing problem out of the scope of this PR. |
0fdbd3e to
624de1c
Compare
|
Looks good. I'm gonna try to test it with my controller in the following days. |
| m_predefinedColorsList = makePredefinedColorsList(defaultColor); | ||
| } | ||
|
|
||
| QScriptValue ColorJSProxy::jsColorFrom(PredefinedColorPointer predefinedColor) { |
There was a problem hiding this comment.
This function does not store the pointer, so it should take a const reference.
This is not part of this PR, but the change suits to simplify the using code.
| for (int i = 0; i < numColors; ++i) { | ||
| QScriptValue colorList = m_pScriptEngine->newArray(numColors); | ||
| PredefinedColorPointer predefinedDefaultColor = Color::kPredefinedColorsSet.noColor; | ||
| PredefinedColorPointer skinTunedDefaultColor = std::make_shared<PredefinedColor>( |
There was a problem hiding this comment.
this can live on stack after changing jsColorFrom()
| // Initialization order is important: m_predefinedColorsList is initialized | ||
| // with makePredefinedColorsList, which uses m_pScriptEngine. | ||
| QScriptEngine* m_pScriptEngine; | ||
| QScriptValue makePredefinedColorsList(QColor defaultColorRgba = Color::kPredefinedColorsSet.noColor->m_defaultRgba); |
There was a problem hiding this comment.
I would prefer to remove the default parameter here and set it explicit. It is only used in one place.
|
I am not sure if the ControllersDefaultCueColor node has any value. The in case of free programmable RGB leds, it is up to the mapping author to pick RGB codes for the whole palette that either look good and match somehow the screen colors. So if one than in turn uses the ControllersDefaultCueColor directly it may look foreign, is too dark or dazzling. So we may consider to remove this to not encourage a mapping author using it. |
|
Currently skins can set an arbitrary color to be used for cue points with NOCOLOR assigned (via DefaultMark). The situation we want to avoid is a cue point to be displayed with one color on screen and a different color on the controller. To avoid this I can think of three solutions:
@daschuer @Swiftb0y @ronso0 @Be-ing [1] Skins could set DefaultMark to red, and ControllersDefaultCueColor to blue and then we would still have the problem. Also, DefaultMark is defined per waveform widget, so skins could use a different color on each deck. Skin designers are responsible to avoid this pitfalls. [2] This color transformation must be generic because controller scripts do not know which color they will receive. Thus, this transformation won't be perfect, but can be good enough to avoid colors that look weird on the controller. [3] This means that NOCOLOR will be removed and replaced by a new regular color. Also, we will need to rethink the DefaultMark node. |
|
@daschuer The COs in SkinLoader are leaking. I see the skin loader is not destroyed in MixxxMainWindow::finalize() but in the destructor, why is that? |
|
Here is the commit where I have done the move: Are you sure that SkinLoader is the issue? It should not own any CO. |
|
Well it's the issue because I added COs there. What should own skin-related COs that outlive the currently loaded skin? |
|
I think you can try to delete it earlier to check, what as the issue. |
|
I moved the COs out of SkinLoader to a dedicated class. But when the COs are deleted, SkinLoader still has ControlProxies for those COs. Is this a problem? How does the CO system handle this? |
|
I might have time in the next couple of days to introduce this change into Components JS, but I wanna wait for #2030 to get merged first. |
This is handeled via a shared pointer: mixxx/src/control/controlproxy.h Line 188 in 4756186 I guess that you still receive the leaking COs warning because of that. |
|
Thank you for working on this, but I also doubt this is a good solution. How about we move away from letting hotcues not have colors? #2122 was a step towards this but it is an option that can be turned off. I think a better solution than both this and #2122 would be showing a 4x2 grid in the preferences for users to choose default colors per hotcue with a color selection menu. This could reuse the ColorMenu class I am introducing in #2238. |
|
I think you’re totally right. We can just have different strategies to assign colours To the newly created hotcues. We can let the user choose the preference they like the most in our preferences page. So the strategies can be:
|
This PR introduces a new skin node ControllersDefaultCueColor.
This node is used to let controllers use the same default color than skins for cue points with no assigned color.
TODO