-
-
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
User Preference to Hide beat grid on waveform #1247
Conversation
modified: src/preferences/dialog/dlgprefwaveform.h modified: src/preferences/dialog/dlgprefwaveformdlg.ui modified: src/waveform/renderers/waveformrenderbeat.cpp modified: src/waveform/renderers/waveformwidgetrenderer.cpp modified: src/waveform/renderers/waveformwidgetrenderer.h modified: src/waveform/waveformwidgetfactory.cpp modified: src/waveform/waveformwidgetfactory.h Added functionality to hide beat grid lines on waveform.
@@ -274,6 +275,10 @@ void WaveformWidgetRenderer::setZoom(int zoom) { | |||
m_zoomFactor = math_clamp<double>(zoom, s_waveformMinZoom, s_waveformMaxZoom); | |||
} | |||
|
|||
void WaveformWidgetRenderer::setDisplayGrid(bool set){ | |||
m_renderGrid = set; |
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.
Render or display?
@@ -223,6 +224,13 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) { | |||
m_config->set(ConfigKey("[Waveform]","ZoomSynchronization"), ConfigValue(m_zoomSync)); | |||
} | |||
|
|||
int displayGrid = m_config->getValueString(ConfigKey("[Waveform]", "beatGridLinesCheckBox")).toInt(&ok); |
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.
Later we may use other controls, but the config key remains.
how about just "showBeatgrid"?
By the way, you can use here the m_config->getValue() template function.
@@ -432,6 +440,22 @@ void WaveformWidgetFactory::setZoomSync(bool sync) { | |||
} | |||
} | |||
|
|||
void WaveformWidgetFactory::setDisplayGrid(bool sync){ |
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.
Use BeatGrid, to be free to introduce other type of grids.
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.
Ok. I will update all the function to better reflect that we are referring to the Beat Grid.
Thank you for adopting this. I have just left some renaming suggestions. |
m_config->set(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), ConfigValue(m_beatGridEnabled)); | ||
} | ||
|
||
if(m_waveformWidgetHolders.size() == 0){ |
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.
nitpick: please use spaces around conditional expressions:
if (m_waveformWidgetHolders.size() == 0) {
Thanks for working on this. I tested it and it works until Mixxx is restarted. If the option is unchecked (beatgrid is hidden) on shutdown, when Mixxx starts again, the beatgrid will be back even though the option in the preferences is unchecked. |
<item row="12" column="1"> | ||
<widget class="QCheckBox" name="beatGridLinesCheckBox"> | ||
<property name="toolTip"> | ||
<string>Display beat grid lines on waveform</string> |
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.
Change this to just "Beat grid"
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 will make these changes, and look into why the preference is being ignored when mixxx is restarted.
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.
@Be-ing I've resolved the issue with the preference being ignored when starting Mixxx. Which lines am I changing to "Beat Grid" and "Show Beat Markers"? I'll push all the changes together.
<string>Display beat grid lines on waveform</string> | ||
</property> | ||
<property name="text"> | ||
<string>Enable Beat Grid Lines</string> |
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.
Change this to "Show beat markers"
Ping @williamlemus, have you continued work on this? I'd like to increase the maximum waveform zoom out level further after merging this. The reason I chose the limit I did in #1165 is because it started to look weird when zoomed out far and showing the beat markers. |
@Be-ing Hey I haven't had a chance to figure out how to get around the issue where it's defaulting. I'll try to take a look by mid week and reach out via IRC if I'm still stuck. |
@Be-ing I've made the updates requested. Please let me know if anything else needs to be corrected. |
@@ -223,6 +224,13 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) { | |||
m_config->set(ConfigKey("[Waveform]","ZoomSynchronization"), ConfigValue(m_zoomSync)); | |||
} | |||
|
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.
you can simplify the code passing the default value
int showBeatGrid = m_config->getValue("[Waveform]", "beatGridLinesCheckBox", m_showBeatGrid)
(not sure about the exact syntax though)
void WaveformWidgetFactory::setDisplayBeatGrid(bool sync) { | ||
m_beatGridEnabled = sync; | ||
if (m_config) { | ||
m_config->set(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), ConfigValue(m_beatGridEnabled)); |
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 normally do not set the value, if not required. We try to load the value and if it fails pick the default. Is it required 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.
The dlgprefwaveform calls this in order to update the Config
void DlgPrefWaveform::slotSetGridLines(bool displayGrid) { WaveformWidgetFactory::instance()->setDisplayBeatGrid(displayGrid); }
Would there be a better way to do this?
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 it would make more sense to set the ConfigKey in DlgPrefWaveform than 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.
Oh, I see the way you did it is consistent with the surrounding code. You don't have to clean this up if you don't have time, but it would be nice to move the setting of the ConfigKeys into DlgPrefWaveform.
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.
Should I do this just for the display grid preference?
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.
No, keep it consistent. Either leave it how it is or refactor how all the settings in this function are set.
I tested again and it works as expected. I think the UI in the Preferences could be improved. I think it would be difficult for users to discover on their own all the way at the bottom of the preference page. How about putting it between "End of track warning" and "Default zoom level"? Hopefully that will make it more obvious to users that the option exists if they choose to zoom the waveform out far and see the grid lines close together and cluttering the view. For the wording, I suggest changing it to "Beat grid" for the label in the left column and "Show beat markers" for the checkbox label in the right column. |
Thanks for adding the feature. If you plan to extend this any further, adding a |
@esbrandt That sounds like a good idea. Can I do the dimming functionality as a separate PR? I would like to get this PR as I'm not sure if I'll have time the next couple of weeks to extend it. |
Totally up to you. |
…d check box for easier discover
I've simplified the code as requested. @Be-ing I also moved up the beat grid option and changed the text. Please let me know if I missed anything. |
} else { | ||
m_config->set(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), ConfigValue(m_beatGridEnabled)); | ||
} | ||
int showBeatGrid = m_config->getValue(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), m_beatGridEnabled); |
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.
If you change this to a bool you don't need to do the static_cast on the next line.
Looks good to me! Thanks. |
Should I worry about the unsuccessful check? Also, I'll start working on the dimming, and will make a PR to adding dimming and move the set config into waveform preferences. |
No, we use the free plans for Travis and AppVeyor that have short time limits. Randomly builds will run out of time. AppVeyor passed, so it's okay.
Cool, thanks. |
Thank you, @williamlemus and all involved. :-) |
These changes are to enable the functionality requested in bug 1659888 : https://bugs.launchpad.net/mixxx/+bug/1659888 . I have done some testing on it and it is working. Please let me know if anything needs to be changed.
Added functionality to hide beat grid lines on waveform.