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

User Preference to Hide beat grid on waveform #1247

Merged
merged 6 commits into from
Jul 23, 2017

Conversation

williamlemus
Copy link
Contributor

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.

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.

	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;
Copy link
Member

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);
Copy link
Member

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){
Copy link
Member

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.

Copy link
Contributor Author

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.

@daschuer
Copy link
Member

daschuer commented May 6, 2017

Thank you for adopting this. I have just left some renaming suggestions.
I hope I find time to test this soon.

m_config->set(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), ConfigValue(m_beatGridEnabled));
}

if(m_waveformWidgetHolders.size() == 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: please use spaces around conditional expressions:
if (m_waveformWidgetHolders.size() == 0) {

@Be-ing
Copy link
Contributor

Be-ing commented May 23, 2017

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>
Copy link
Contributor

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"

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 will make these changes, and look into why the preference is being ignored when mixxx is restarted.

Copy link
Contributor Author

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>
Copy link
Contributor

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"

@Be-ing
Copy link
Contributor

Be-ing commented Jun 25, 2017

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.

@williamlemus
Copy link
Contributor Author

@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.

@williamlemus
Copy link
Contributor Author

@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));
}

Copy link
Member

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));
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@Be-ing
Copy link
Contributor

Be-ing commented Jun 30, 2017

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.

@esbrandt
Copy link
Contributor

Thanks for adding the feature.

If you plan to extend this any further, adding a Dim mode can be an option.
The dimmed mode is basically the normal mode, just with lower alpha 0.3 instead of 0.9 for the beat grid lines.
Traktor has this option and it is really neat. Gives access to the bead grid without obstructing the view on the waveform/markers as much as with the default beatgrid.

@williamlemus
Copy link
Contributor Author

@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.

@esbrandt
Copy link
Contributor

esbrandt commented Jul 4, 2017

@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.
Just submit a new PR when you are ready.

@williamlemus
Copy link
Contributor Author

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);
Copy link
Contributor

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.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 17, 2017

The order of the items in the preferences looks odd because there are 3 checkboxes in the right column but only a label in the left column for the middle one. I think moving the new beatgrid line preference between "End of track warning" and "Default zoom level" would work better.
waveform-preferences

@Be-ing
Copy link
Contributor

Be-ing commented Jul 17, 2017

Looks good to me! Thanks.

@williamlemus
Copy link
Contributor Author

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.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2017

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.

Also, I'll start working on the dimming, and will make a PR to adding dimming and move the set config into waveform preferences.

Cool, thanks.

@daschuer
Copy link
Member

Thank you, @williamlemus and all involved. :-)

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.

4 participants