[gnome-boxes] Add collection view scrolling
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Add collection view scrolling
- Date: Mon, 10 Oct 2011 16:54:23 +0000 (UTC)
commit 672dbbff8560497d97c9f2df5f7dc72c895e4236
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Mon Oct 10 18:53:45 2011 +0200
Add collection view scrolling
src/collection-view.vala | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 5c8b0ed..dd243e6 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -102,6 +102,7 @@ private class Boxes.CollectionView: Boxes.UI {
layout = new Clutter.FlowLayout (Clutter.FlowOrientation.HORIZONTAL);
margin = new Clutter.Group ();
margin.set_clip_to_allocation (true);
+ margin.set_reactive (true);
/* this helps to keep the app table inside the window, otherwise, it allocated large */
margin.set_size (1f, 1f);
@@ -111,10 +112,33 @@ private class Boxes.CollectionView: Boxes.UI {
margin.add (boxes);
app.box.pack (margin, "column", 1, "row", 1, "x-expand", true, "y-expand", true);
+ margin.scroll_event.connect ((event) => {
+ float scrollable_height = boxes.get_height ();
+
+ boxes.get_preferred_height (boxes.get_width (), null, out scrollable_height);
+ var viewport_height = margin.get_height ();
+
+ message ("foo %f %f", scrollable_height, viewport_height);
+ if (scrollable_height < viewport_height)
+ return true;
+ var y = boxes.get_y ();
+ switch (event.direction) {
+ case ScrollDirection.UP:
+ y += 50f;
+ break;
+ case ScrollDirection.DOWN:
+ y -= 50f;
+ break;
+ default:
+ break;
+ }
+ y = y.clamp (viewport_height - scrollable_height, 0.0f);
+ boxes.animate (AnimationMode.LINEAR, 50, "y", y);
+ return true;
+ });
+
boxes.add_constraint_with_name ("boxes-width",
new Clutter.BindConstraint (margin, BindCoordinate.WIDTH, -25f));
- boxes.add_constraint_with_name ("boxes-height",
- new Clutter.BindConstraint (margin, BindCoordinate.HEIGHT, -25f));
over_boxes = new Clutter.Box (new Clutter.BinLayout (Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL));
over_boxes.add_constraint_with_name ("top-box-size",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]