workspaceview: clean up scroll_event

This commit is contained in:
Rico Tzschichholz 2012-09-23 13:19:08 +02:00
parent 6380b27b7f
commit c830c38da1

View File

@ -22,6 +22,7 @@ namespace Gala
public class WorkspaceView : Clutter.Actor public class WorkspaceView : Clutter.Actor
{ {
static const float VIEW_HEIGHT = 140.0f; static const float VIEW_HEIGHT = 140.0f;
static const float SCROLL_SPEED = 30.0f;
Gala.Plugin plugin; Gala.Plugin plugin;
Screen screen; Screen screen;
@ -337,16 +338,23 @@ namespace Gala
return false; return false;
} }
const float scroll_speed = 30.0f;
public override bool scroll_event (Clutter.ScrollEvent event) public override bool scroll_event (Clutter.ScrollEvent event)
{ {
if ((event.direction == Clutter.ScrollDirection.DOWN || event.direction == Clutter.ScrollDirection.RIGHT) switch (event.direction) {
&& thumbnails.width + thumbnails.x > width) { //left case Clutter.ScrollDirection.DOWN:
thumbnails.x -= scroll_speed; case Clutter.ScrollDirection.RIGHT:
} else if ((event.direction == Clutter.ScrollDirection.UP || event.direction == Clutter.ScrollDirection.LEFT) if (thumbnails.width + thumbnails.x > width)
&& thumbnails.x < 0) { //right thumbnails.x -= SCROLL_SPEED;
thumbnails.x += scroll_speed; break;
case Clutter.ScrollDirection.UP:
case Clutter.ScrollDirection.LEFT:
if (thumbnails.x < 0)
thumbnails.x += SCROLL_SPEED;
break;
default:
return false;
} }
scroll.x = Math.floorf (width / thumbnails.width * -thumbnails.x); scroll.x = Math.floorf (width / thumbnails.width * -thumbnails.x);
return false; return false;