Flicking around

Software

For KDE 4.4, we’re giving a bit of touchscreen friendliness around Plasma, a thing common on touchscreen based uis is the so called flick lists and scroll views. They can be web browsers, simle item views, image explorers and so on.

You just touch (or drag with the mouse, it’s not limited to touchscreens of course) a random point of the view, drag it a bit, release and the contents will be launched with a neat animaton effect, with a resembrance of something real.

In Plasma, if you use the ScrollView widget you’ll get that for free, and if the item view contains some sub widget that wants to listend to mouse clicks as well, is sufficient to call the function ScrollView::registerAsDragHandle(QGraphicsWidget *), with some eventfilter magic, the element registered will still react to mouse click, but will pass them to the view as well. An example of this is the icon view of the Plasma netbook shell: if you click on an application icon it will launch the application, but if you press the mouse over one, move it and release, the application pointed from that icon won’t be launched, instead all the icon view will scroll and will still scroll for a while if the mouse moved over a certain speed.

There is a small video that show this behaviour over several plasmoids: the web browser, the microblog, the OpenDesktop knowledge base client and the Search and Launch interface of the netbook shell.


Ogg version

The WebView widget will behave like that as well, and if you implement a custom one and you want that behaviour -for free-, you just have to call Plasma::Animator::self()->registerScrollingManager(yourwidget), and provided you gave the proper Q_PROPERTY to your widget, all the magic will be done behind the scenes. The properties you’ll need are:

  • scrollPosition: the position in pixels of the contents relative to the viewport
  • contentsSize: the size of the contents: for instance an image could be 1680×1050 pixels big, even if the widget that is vieweing it is just 200×200
  • viewportGeometry: the actual viewport of the contents could be the bounfingRect() of the main widget or could even be something smaller: for instance excluding the area taken up by the scrollbars, if present.

2 thoughts on “Flicking around

  1. Tobias

    This looks really nice: thanks for working on it. I personally would prefer if the page would only flick vertical if there is no horizontal scrollbar. Currently it seems to be possible to flick it a little bit to the left and the right.

Comments are closed.