-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
WIP: Piano Roll mouse refactor + extras #6063
base: master
Are you sure you want to change the base?
Conversation
Changes variable names from PianoRoll::mousePressEvent to camelCase and changes 2 comments.
Removes a loop that removed every note except one and replaced it with a clear() call plus appending the note. Removes a magic number used for finding the closest note.
* Changes mousePressEvent variables to camelCase Changes variable names from PianoRoll::mousePressEvent to camelCase and changes 2 comments. * Style fixes on mouseDoubleClickEvent * Removes magic number and costy loop Removes a loop that removed every note except one and replaced it with a clear() call plus appending the note. Removes a magic number used for finding the closest note. * Small fixes + Code style Fixes small bug with the vertical selection mode scrolling. Improves logic on the cursor selection of ActionNone. Adds update() + return statements for the actions that didn't have them, and removed the update() from outside the switch. Fixes the code style.
* Changes mousePressEvent variables to camelCase Changes variable names from PianoRoll::mousePressEvent to camelCase and changes 2 comments. * Style fixes on mouseDoubleClickEvent * Removes magic number and costy loop Removes a loop that removed every note except one and replaced it with a clear() call plus appending the note. Removes a magic number used for finding the closest note. * Small fixes + Code style Fixes small bug with the vertical selection mode scrolling. Improves logic on the cursor selection of ActionNone. Adds update() + return statements for the actions that didn't have them, and removed the update() from outside the switch. Fixes the code style. * Adds Remove Note action Adds a action to remove notes on the PianoRoll, and remove an unnecessary member variable that was only being used to handle that action (m_mouseDownRight). Also removes unnecessary handling of the play key action on the ActionNone case switch from the mouseMoveEvent. Adds a update() call on the ActionPlayKeys (so it updates the cursor) and a break; statement for consistency. Also fixes the calculation of the velocity.
🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩
Linux
Windows
macOS🤖{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://14048-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.132%2Bg6ea5ae0-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/14048?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://14049-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.132%2Bg6ea5ae036-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/14049?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://14050-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.132%2Bg6ea5ae036-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/14050?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/u78yqfavievs41po/artifacts/build/lmms-1.3.0-alpha-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/39669311"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/f7c0x8st2rj88220/artifacts/build/lmms-1.3.0-alpha-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/39669311"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://14046-15778896-gh.circle-artifacts.com/0/lmms-1.3.0-alpha.1.132%2Bg6ea5ae036-mac10.14.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/14046?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "231e38d742551e739411613e88748c014af672fb"} |
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 is not a complete review yet. I have to read the remaining part later.
const int visible_space = keyAreaBottom() - keyAreaTop(); | ||
m_totalKeysToScroll = qMax(0, NumKeys - 1 - visible_space / m_keyLineHeight); | ||
|
||
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.
@@ -449,6 +447,8 @@ PianoRoll::PianoRoll() : | |||
this, SLOT(changeSnapMode())); | |||
|
|||
m_stepRecorder.initialize(); | |||
|
|||
m_lastChord = nullptr; |
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.
Why do you have this here instead of the member initializer list?
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.
That's a good question. I don't know what I was thinking!
PR_TOP_MARGIN, | ||
width() - m_whiteKeyWidth, | ||
keyAreaBottom() - PR_TOP_MARGIN); | ||
noteAreaWidth(), | ||
keyAreaBottom() - keyAreaTop()); |
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.
Why are you still using PR_TOP_MARGIN
instead of keyAreaTop()
?
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 am using keyAreaTop()
?
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 nevermind you're talking about the line above the change. I just missed it is all.
} | ||
|
||
if( m_editMode == ModeEditDetuning && noteUnderMouse() ) | ||
PianoRoll::PianoRollArea PianoRoll::getPianoRollAreaIn(const int x, const int y) |
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 would name it like coordToArea
or pointToArea
, but I'll leave the naming stuff up to you.
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.
Hmm, yeah I think pointToPianoArea
could work?
// ticks per pixel = ticks per bar / pixels per bar | ||
// const int tpp = static_cast<int>(static_cast<float>(TimePos::ticksPerBar()) / m_ppb); | ||
// pixels per tick = pixels per bar / ticks per bar | ||
const int ppt = static_cast<int>(static_cast<float>(m_ppb) / TimePos::ticksPerBar()); |
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 will truncate the decimal part and affect ticks to position calculation.
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.
For some reason that just didn't click in my head. 😂 I'll change to float.
const int ppt = static_cast<int>(static_cast<float>(m_ppb) / TimePos::ticksPerBar()); | ||
|
||
// Area mouse clicked in | ||
const PianoRollArea pra = getPianoRollAreaIn(mex, mey); |
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 prefer using this directly in switch
statements. The same for the other occurrences.
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.
That can be done. 👍
This is part of my continued effort to clean up the Piano Roll code to make it easier to maintain and read (and be faster), with help from @IanCaio. I wanted to open this now since most of the major work is done, and I'd like to start getting some testing and reviews. I'm certain there are some edge cases from the refactor that myself and Ian haven't found. Also if there are any suggestions for duplicated code that we can pull out into their own function would be helpful.
Quick summary of changes:
My known issues: