Left-click mini-map to jump to clicked area
ClosedPublic

Authored by sars on Jun 4 2017, 7:43 AM.

Details

Summary

This patch implements the jump to clicked position in "show-minimap" mode for the scrollbar.

Diff Detail

Repository
R39 KTextEditor
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sars created this revision.Jun 4 2017, 7:43 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 4 2017, 7:43 AM
Restricted Application added subscribers: Frameworks, kwrite-devel. · View Herald Transcript
broulik added a subscriber: broulik.Jun 4 2017, 7:45 AM

Shouldn't left click scroll up and down a bit with middle click jumping to position - that's the behavior of Qt's scroll bars.

sars added a comment.Jun 4 2017, 8:23 AM

Reasoning behind the change of behavior:

  • With mini-map it is seems a bit more logical to jump to the clicked place in stead of "searching your way there". (You already know where you want to go).
  • Page Up/Down and mouse scroll can still be used.
  • The middle click action is not very well known.
  • On Windows middle-click does nothing.
  • At least VisualStudio and Sublime does it like this.

Fair enough, +1

kfunk accepted this revision.Jun 4 2017, 10:11 AM
kfunk added a subscriber: kfunk.

+1 on the behavior change, this is a much desired change :)

src/view/kateviewhelpers.cpp
204

Style: ((a - b)) / ...

205

Use qBound(...)?

This revision is now accepted and ready to land.Jun 4 2017, 10:11 AM
sars updated this revision to Diff 15180.Jun 5 2017, 3:27 PM

Use qBound() + remove one set of unneeded parenthesis

This revision was automatically updated to reflect the committed changes.
kfunk added a comment.Jun 6 2017, 2:21 PM

There are a couple of problems with the new behavior -- though I can't tell precisely when they're caused. And not sure they're new or not either.

Things I'm seeing while mini map is enabled, only in some documents though:

  • When the slider is position at the bottom: clicking repeatedly on the same position causes flickering in the view port of the editor
  • Sometimes the scroll bar preview is shown while dragging the slider -- we should probably disable it while dragging altogether
  • Sometimes the slider is 'jumpy', when e.g. moving the slider from bottom to top. The jump distance is the size of the "slider" height.
  • Sometimes just fails to drag completely, or stops moving the slider in the middle of the drag move.

Might wanna have another look?

dhaumann edited edge metadata.Jun 6 2017, 8:01 PM

Hi, I'm sorry I am a bit late to the game: I once also tried to implement this, but the result was a messy patch that did not always get the location right. So I would not be surprised if there are corner cases that do not work.
In any case, either we stabilize this until the next tag (afaik, the last tag was 5 days ago?), or we need to revert.

But also: Cool that you are working on this!

sars added a comment.Jun 6 2017, 8:33 PM

I think I fixed it.
The comment about the dragging was only partially correct. The press must be inside the slider for dragging, so when the initial press is outside or not translated from the mini-map coordinates, the dragging does not start.

My solution is to first move to the desired place then forward the translated click to the QScrollBar.

kfunk added a comment.Jun 7 2017, 6:35 AM

Works perfectly fine for me now, great! I don't see anything wrong with it now from a behavioral point of view.

@dhaumann Maybe you want to check once more?