-
-
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
Add finer zoom, 12.5% #2517
Add finer zoom, 12.5% #2517
Conversation
@zonkmachine why is this closed? |
I couldn't stand the defeat... I'm back in the saddle though. |
The selected zoom and the real differs a bit and this becomes a bit brutal on 12% |
@unfa is one of the only artists here who makes tracks this long and maybe would like to have a say in this. |
Here's how the math goes:
zoom12 * 16 / 100 = 1.92 <-- Truncated to 1! |
bb7c5ff
to
5182485
Compare
The end result of13% is truncated to 2 which is equivalent to 12.5% and on target. |
This now works if people are cool with the odd value 13%. |
Could we use 12,5% or would that be too much of a problem? |
I don't think it would be a whole lot of problem. You would have to test explicitly for that string and substitute for 13 or something that works. I'll try it later... |
It looks better in the menu. The background grid in the Piano Roll is a bit too much on 12,5%. Like a haze. |
} | ||
int pixelsPerTact = zoom.toInt() * DEFAULT_PIXELS_PER_TACT / 100; | ||
|
||
assert( pixelsPerTact > 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.
I added the assert just to mirror the PianoRoll.cpp and AutomationEditor.cpp .
As the only variable is the zooming factor I think there is no risk of reaching 0 unless you go down to ~5% zoom.
Also, would it be possible to avoid hard-coding, comparing, and parsing strings? Something like... // in a header file somewhere
const int NUM_ZOOM_LEVELS = 7;
const float ZOOM_LEVELS[] = {
8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f
}; // in the constructor
for (int i = 0; i < NUM_ZOOM_LEVELS; ++i)
{
m_zoomingModel->addItem(QString("%1\%").arg(ZOOM_LEVELS[i] * 100));
} // in zoomingChanged()
setPixelsPerTact(ZOOM_LEVELS[m_zoomingModel->value()]); (Disclaimer: I have not tested the above snippets of code nor have any idea if they're correct, but the general idea should be there.) |
e2829db
to
4eb8858
Compare
I ninja'd it too... :( |
PS: about my comment above, I've edited the code snippets in it a couple of times for obvious logic errors (I really should be sleeping right now!), but I think I'm finished now... |
Nein! We go .toFloat() on all of them strings, calculate like hell and then back to int... |
I agree with @grejppi that using However, I would change the zoom levels data structure to an const std::vector<float> m_zoomLevels = { 8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f }; This way you would not need to adjust an extra variable like for (float const & zoomLevel : m_zoomLevels)
{
m_zoomingModel->addItem(QString("%1\%").arg(zoomLevel * 100));
} Last but not least I'd like to add that I think that 16 pixels per tact is too small anyway. In my opinion the default zoom level of the song editor does not really communicate "Here is a broad canvas to realize your musical ideas!". I also find it "unnatural" that the height of one tact is bigger than it's width. The reason is that musical notation expands from the left to the right so more space should be provided in that dimension. |
You're obviously right, both of you, and it cleans up the code like nothing else. Trying it out now. |
Got an ouchie!
|
@zonkmachine @michaelgregorius code in LMMS tends to prefer You might want to consider making the vector static: // Class.h
class Class {
// ...
static const QVector<float> s_zoomLevels;
// ...
}; // Class.cpp
const QVector<float> Class::s_zoomLevels({ 8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f });
// ... |
That was pretty much how I spent my night. ;-)
|
Well, that's quite a different message I think... In this case, |
No, it's after the signals outside of the class. |
Then we must be looking at different code. |
9ff261b
to
3695eba
Compare
There was a commented out initialisationtion statement in the class and there was a wrongly indented definition of
A secret society just got booked horribly wrong... |
@zonkmachine I tested it out, but noticed a bug: When +scrolling to zoom in/out in the song editor, it only goes down to 25%, but not on 12.5%. When I scroll over the combo box, this appeares not to be an issue. |
Thanks, so that's what the SongEditor::wheelEvent does! |
I stealthily copied over the solution from PianoRoll.cpp |
Mouse wheel zoom and combo box zoom now works in opposite directions... |
When you set zooming by scrolling the combo box or by Ctrl+Scrolling the track the wheel directions aren't the same. I thought I messed that one up but it's actually there in |
@zonkmachine could you please rebase so we get this PR merged? |
293fd03
to
5c945f8
Compare
Rebased and tested. |
Tested out, works perfectly, @grejppi gave the code an ok, code looks good to me as well. |
@Umcaruje Thanks for review, merge and keeping the spirit up... |
Add finer zoom, 12.5%
Closes issue #2
I added an extra 12% in front of the setup loop. I did this in three places for the Song Editor, Piano Roll and the Automation Editor. The Automation Editor has a second zoom model that I a. didn't grasp, b. failed to test even unmodified... the other (left) is changed though and works fine.