-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improving movement inside workspace #7595
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
Conversation
sakertooth
left a comment
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.
Tested it and it works fine, just some code suggestions.
|
Hm, the build is failing (I'm guessing Carla isn't linked to lmms). Try moving the implementation of |
|
Should there be a cursor change associated with panning the workspace, perhaps? |
Sure! What type of cursor should be displayed? Maybe |
|
Probably |
|
I like it. Trying it out, I feel like if the scroll limits were removed/expanded, it would feel more natural to be able to drag the view "out of bounds", instead of being capped to the position of the min/max windows. You don't have to implement that though, I'm just thinking out loud. |
I don't know how to do this unfortunately, it seems like SubWindows resize the scroll bars when they are moved. An other method of moving exists for QMdiArea: |
I implemented |
|
Curious why |
|
I'm also thinking this feature should be opt-in. |
I felt that it is unnecessary and could be annoying because the workspace covers 80% of the screen and the default cursor looks better in that case, but I could implement it if needed.
I think users could opt out by not using this feature, I believe there is no point to make this optional if it is an improvement for all platforms and I believe it is. |
Okay. In my opinion, not having
Edit: Actually, I thought about it a bit more. I do agree that the feature can be opt out as well. |
I will implement this then. |
|
If you are not truly satisfied with the suggestion @szeli1, I think another option we can do is to keep the arrow cursor when the user is not pressing down on anything. Then, you could use the open hand cursor when the user initially presses down on the mouse, and when dragging, use the closed hand cursor. When they stop dragging but are still holding the mouse, switch back to the open hand cursor, and when the mouse is released, move back to the arrow cursor. You might not even need to add an opt-in/opt-out setting actually if you don't want to, as I think discovering the feature by pressing down on the workspace is enough if the cursor switches are implemented the way I described it above. I think this is somewhat subjective ultimately, but let me know what you think of this idea. |
This would require a timer, because Edit: please let me know if you approve this or you would rather like your idea implemented.
I think it was a good suggestion to add an opt out option, since it will enable users who really don't like the feature to turn it off, it will leave the decision to the user. |
IIRC this PR should be ready for merge. There are small things with the icons I wanted to change but nothing major and potentially unwanted. We need a more recent test, but I won't be able to test this unfortunately so I would recommend finding someone new to take on the testing torch for this PR. |
|
I tested this again after the last commit, and it's awesome. I love that the view is no longer bounded by the scroll bars. It feels so much more natural. |
src/gui/MainWindow.cpp
Outdated
| minX = minX > curWindow->x() ? curWindow->x() : minX; | ||
| maxX = maxX < curWindow->x() + curWindow->width() ? curWindow->x() + curWindow->width() : maxX; | ||
| minY = minY > curWindow->y() ? curWindow->y() : minY; | ||
| maxY = maxY < curWindow->y() + curWindow->height() ? curWindow->y() + curWindow->height() : maxY; |
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.
Is it better to do this or use std::min/std::max?
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 believe it is slower, since it is a function instead of this 1 line if statement (it is slower because the code after this kind of if statement is loaded in by the cpu, I believe the min max function would make the cpu jump to a different memory address, so it will load slower)
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 believe it is slower, since it is a function instead of this 1 line if statement (it is slower because the code after this kind of if statement is loaded in by the cpu, I believe the min max function would make the cpu jump to a different memory address, so it will load slower)
Is the function call overhead really that slow to matter? I think the readability benefits from using std::min and std::max in this case are worth it, and this isn't performance critical code.
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.
Wait, just checked the definition:
template<typename _Tp, typename _Compare>
_GLIBCXX_NODISCARD _GLIBCXX14_CONSTEXPR
inline const _Tp&
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
//return __comp(__b, __a) ? __b : __a;
if (__comp(__b, __a))
return __b;
return __a;
}There isn't even function call overhead because it's inlined (I would also expect most implementations of these functions in other compilers are also inlined). You also get the added benefit of being able to evaluate the calculation at compile time if the arguments passed in allow it.
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 the ternary operator will be faster than if, because as I've said there is not much branching. In assembly it will skip 1-2 line if false, this makes it so that the code is loaded in faster and maybe more predictable, so the cpu will optimize it. This is how I understand how the ternary operator works, I may be wrong tho
I will replace it with std min max
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.
A ternary operator is a branch. if-else is a branch. They are both branches, but different syntactically is all.
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 we didn't have to pay for branch mispredictions when using the ternary operator, this would be insanely overpowered.
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 we didn't have to pay for branch mispredictions when using the ternary operator, this would be insanely overpowered.
I mean it is a branch, a branch is essentially a subtraction and a change to maybe the program counter that decides what is the next executed line (in arm assembly). I believe ternary operators are faster because only 1 branching instruction is called after compare, so there is only 1 potential jump between where the code gets executed, and the program counter will stay on the same branch.
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.
Do you have any evidence that a ternary operator is faster than a regular if-else branch?
|
I replaced the ternary operator with |
sakertooth
left a comment
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.
Code looks fine, and its working as expected. However, do we want to remove the scrollbars? I'm not too sure if we should keep them or toss them personally.
Scroll bars don't work after this change. |
I was looking for reasons why it was removed, but I'm guessing it was removed because they got in the way, which is a fair justification 👍 |
This Pull Request adds the ability for users to move inside the workspace without using the scroll bars.
This change allows the user to click on the workspace (where the editors are located) without clicking on a
SubWindow, and move by mouse drag. I believe this improves the workflow significantly, because instead of needing to move the mouse over to the scroll bars, the user can simply click on the workspace background and move both vertically and horizontally.As far as I know there is no Issue open referencing this feature.