[gnome-shell/wip/paging] Some clean-up
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/paging] Some clean-up
- Date: Wed, 19 Jun 2013 18:54:20 +0000 (UTC)
commit a198078c569b1821e100cfd906c4702ef8dc076e
Author: Carlos Soriano <carlos soriano89 gmail com>
Date: Wed Jun 19 20:54:00 2013 +0200
Some clean-up
js/ui/appDisplay.js | 144 ++++++++-------------------------------------------
js/ui/iconGrid.js | 67 ++++++++----------------
2 files changed, 44 insertions(+), 167 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index e1eeb4d..8c68c70 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -191,10 +191,6 @@ const AppPage = new Lang.Class({
_init: function() {
this.parent();
-
- //this._grid.actor.y_align = St.Align.START;
- //this._grid.actor.y_expand = false;
- this._grid._fillParentV2 = true;
this.actor = this._grid.actor;
},
@@ -234,21 +230,13 @@ const PaginationScrollActor = new Lang.Class({
_init: function() {
this.parent();
- this._box = new St.BoxLayout({vertical: true, x_align: St.Align.MIDDLE, y_align: St.Align.MIDDLE});
+ this.expand_x = true;
+ this._box = new St.BoxLayout({vertical: true});
this._page = new AppPage();
-
this._box.add_actor(this._page.actor);
this.add_actor(this._box);
- this.set_reactive(true);
- this.connect('scroll-event', Lang.bind(this, function(actor, event) {
- global.log("scroll! "+event.get_scroll_direction());
- let direction = event.get_scroll_direction();
- if (direction == Clutter.ScrollDirection.UP)
- this.goToPreviousPage();
- if (direction == Clutter.ScrollDirection.DOWN)
- this.goToNextPage();
- }));
-
+
+ this.connect('scroll-event', Lang.bind(this, this._onScroll));
},
vfunc_get_preferred_height: function (container, forWidht) {
@@ -260,32 +248,25 @@ const PaginationScrollActor = new Lang.Class({
},
vfunc_allocate: function(box, flags) {
- let originalBox = box;
- //Retrieve parent size
box = this.get_parent().allocation;
- this.set_allocation(box, flags);
- //this.set_allocation(box, flags);
-
+ this.set_allocation(box, flags);
let availWidth = box.x2 - box.x1;
let availHeight = box.y2 - box.y1;
let childBox = new Clutter.ActorBox();
+ //Get the boxLayout inside scrollView
let child = this.get_children()[2];
let childWidth = child.get_preferred_width(availHeight)[1];
- let childHeight = child.get_preferred_height(availWidth)[1];
- childBox.x1 = (availWidth - childWidth)/2;
+
+ childBox.x1 = 0;
childBox.y1 = 0;
- childBox.x2 = childBox.x1 + childWidth;
+ childBox.x2 = availWidth;
childBox.y2 = availHeight;
//Put parentSize in grid
this._page._grid._parentHeight = availHeight;
-
- global.log("PAGES!!!" + this._page._grid.nPages());
- global.log("ADJUSTMENT before" + this.vscroll.adjustment.get_values());
- //this.vscroll.adjustment= new St.Adjustment({lower:0, upper:3000, value:1900, step_increment:145,
page_increment:726, page_size:872});
+
child.allocate(childBox, flags);
- global.log("ADJUSTMENT " + this.vscroll.adjustment.get_values());
},
goToNextPage: function() {
@@ -293,94 +274,23 @@ const PaginationScrollActor = new Lang.Class({
},
goToPreviousPage: function() {
this.vscroll.adjustment.set_value(this._page._grid.goToPreviousPage());
+ },
+
+ _onScroll: function(actor, event) {
+ let direction = event.get_scroll_direction();
+ if (direction == Clutter.ScrollDirection.UP)
+ this.goToPreviousPage();
+ if (direction == Clutter.ScrollDirection.DOWN)
+ this.goToNextPage();
}
});
const AllView = new Lang.Class({
Name: 'AllView',
- _init: function() {
-
- this.actor = new PaginationScrollActor();
-
-
-
- /*this._actorLayoutManager = new AllViewLayout();
- global.log(" SERAAA?? " + this.actor.scroll_to_point);
- this._box = new St.BoxLayout({vertical: true});
- this._widgetLayoutManager = new AllViewLayout();
-
-
- this._widgetForLayout = new St.Widget({ layout_manager: this._widgetLayoutManager });
-
- this._widgetForLayout.add_actor(this._page.actor);
- this._box.add_actor(this._widgetForLayout);*/
- /*this._box = new St.Widget({ style_class: 'frequent-apps',
- x_expand: true, y_expand: true });*/
-
-
- //this.actor.connect('allocate', Lang.bind(this, this._allocate));
- //this.clip_to_allocation = true;
- //this.actor.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
- /*let box = new St.BoxLayout({ vertical: true });
- this._stack = new St.Widget();*/
-
- /*this._stack.add_actor(this._page.actor);
- this._eventBlocker = new St.Widget({ x_expand: true, y_expand: true });
- this._stack.add_actor(this._eventBlocker);
- box.add(this._stack, { y_align: St.Align.START, expand: true });*/
-
- /*this.actor = new St.ScrollView({ x_fill: true,
- y_fill: false,
- y_align: St.Align.START,
- x_expand: true,
- y_expand: true,
- overlay_scrollbars: true,
- style_class: 'all-apps vfade' });*/
-
- /*this._widgetForLayout2 = new St.Widget({ layout_manager: new AllViewLayout() });
- this._widgetForLayout2.add_actor(this._page2.actor);
- this._textLabel = new St.Label({text: "HOLAAA"});
- this._textLabel2 = new St.Label({text: "HOLAAA"});
- this._box.add_actor(this._textLabel);
- this._box.add_actor(this._widgetForLayout);
-
-
- this._box.add(this._textLabel2);
- this._box.add(this._widgetForLayout2);*/
-
-
- /*this.actor = new St.Bin({ style_class: 'all-apps vfade',
- x_fill: true,
- y_fill: false,
- y_align: St.Align.START, x_expand: true, y_expand: true});
-
- this.actor.add_actor(this._page.actor);*/
- //this.actor.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
-
-
- this._pageControl = new St.Widget();
-
- /*this.actor = new St.Widget({ style_class: 'frequent-apps',
- x_expand: true, y_expand: true });*/
-
-
- /* let action = new Clutter.PanAction({ interpolate: true });
- action.connect('pan', Lang.bind(this, this._onPan));
- this.actor.add_action(action);
-
- this._clickAction = new Clutter.ClickAction();
- this._clickAction.connect('clicked', Lang.bind(this, function() {
- if (!this._currentPopup)
- return;
-
- let [x, y] = this._clickAction.get_coords();
- let actor = global.stage.get_actor_at_pos(Clutter.PickMode.ALL, x, y);
- if (!this._currentPopup.actor.contains(actor))
- this._currentPopup.popdown();
- }));
- this._eventBlocker.add_action(this._clickAction);*/
- //global.log("PPP visible items after init " + this._page._grid.visibleItemsCount());
+ _init: function() {
+ this.actor = new PaginationScrollActor();
+ this._pageControl = new St.Widget();
},
_onKeyRelease: function(actor, event) {
@@ -436,10 +346,6 @@ const AllView = new Lang.Class({
}));*/
},
- /*_ensureIconVisible: function(icon) {
- Util.ensureActorVisibleInScrollView(this.actor, icon);
- },*/
-
_updateIconOpacities: function(folderOpen) {
for (let id in this._items) {
if (folderOpen && !this._items[id].actor.checked)
@@ -455,7 +361,6 @@ const AllView = new Lang.Class({
loadGrid: function() {
this.actor._page.loadGrid();
- //global.log("ZZZ visible items after load grid " + this._page._grid.visibleItemsCount());
}
});
@@ -469,8 +374,6 @@ const FrequentView = new Lang.Class({
this.actor = new St.Widget({ style_class: 'frequent-apps',
x_expand: true, y_expand: true });
this.actor.add_actor(this._grid.actor);
-
- //global.log("Frequent visible items " + this._grid.visibleItemsCount());
this._usage = Shell.AppUsage.get_default();
},
@@ -486,10 +389,7 @@ const FrequentView = new Lang.Class({
continue;
let appIcon = new AppIcon(mostUsed[i]);
this._grid.addItem(appIcon.actor, -1);
- }
- global.log("Frequent visible items after " + this._grid.visibleItemsCount());
- //global.log("Current frequent apps number "+mostUsed.length);
- }
+ } }
});
const Views = {
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index ce8eaac..11a4bcf 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -227,6 +227,7 @@ const IconGrid = new Lang.Class({
},
_getPreferredHeight: function (grid, forWidth, alloc) {
+
if (this._fillParent)
// Ignore all size requests of children and request a size of 0;
// later we'll allocate as many children as fit the parent
@@ -241,6 +242,7 @@ const IconGrid = new Lang.Class({
} else {
[nColumns, , spacing] = this._computeLayout(forWidth);
}
+ this._spacePerRow = this._vItemSize + spacing;
let nRows;
if (nColumns > 0)
@@ -251,14 +253,16 @@ const IconGrid = new Lang.Class({
nRows = Math.min(nRows, this._rowLimit);
let totalSpacing = Math.max(0, nRows - 1) * spacing;
let height = nRows * this._vItemSize + totalSpacing;
+
if(this._parentHeight) {
- let rowsPerPage = Math.floor(this._parentHeight / (this._vItemSize + spacing));
- let spacePerRow = this._vItemSize + spacing;
+
+ let rowsPerPage = Math.floor(this._parentHeight / this._spacePerRow);
this._nPages = Math.ceil(nRows / rowsPerPage);
this._spaceBetweenPages = this._parentHeight - (rowsPerPage * (this._vItemSize + spacing));
- let spaceBetweenPagesTotal = this._spaceBetweenPages * (this._nPages);
- alloc.min_size = rowsPerPage* spacePerRow * this._nPages + spaceBetweenPagesTotal;
- alloc.natural_size = rowsPerPage* spacePerRow * this._nPages + spaceBetweenPagesTotal;
+ let spaceBetweenPagesTotal = this._spaceBetweenPages * (this._nPages);
+ this._childrenPerPage = nColumns * rowsPerPage;
+ alloc.min_size = rowsPerPage * this._spacePerRow * this._nPages + spaceBetweenPagesTotal;
+ alloc.natural_size = rowsPerPage * this._spacePerRow * this._nPages + spaceBetweenPagesTotal;
return;
}
alloc.min_size = height;
@@ -266,10 +270,7 @@ const IconGrid = new Lang.Class({
},
_allocate: function (grid, box, flags) {
-
- let firstTime = true;
- let maxChildsPerPage = 0;
- if (this._fillParent) {
+ if(this._fillParent) {
// Reset the passed in box to fill the parent
let parentBox = this.actor.get_parent().allocation;
let gridBox = this.actor.get_theme_node().get_content_box(parentBox);
@@ -277,16 +278,11 @@ const IconGrid = new Lang.Class({
}
let children = this._getVisibleChildren();
- //global.log("Allocate visible children " + children.length);
let availWidth = box.x2 - box.x1;
let availHeight = box.y2 - box.y1;
- global.log("Box allocation "+ [availWidth, availHeight]);
- global.log("Total apps " + children.length);
- //global.log("Allocate availHeigth " + availHeight);
- //global.log("Allocate availWidth " + availWidth);
+
let [nColumns, usedWidth, spacing] = this._computeLayout(availWidth);
- //global.log("Allocate nColumnds " + nColumns);
- //global.log("Allocate usedWidth " + nColumns);
+
let leftPadding;
switch(this._xAlign) {
case St.Align.START:
@@ -303,40 +299,22 @@ const IconGrid = new Lang.Class({
let y = box.y1;
let columnIndex = 0;
let rowIndex = 0;
- let count1 = 0;
- let count2 = 0;
-
- global.log("IconGrid allocation, parent box "+ this._parentHeight);
+
if(children.length > 0) {
this._firstPagesItems = [children[0]];
}
for (let i = 0; i < children.length; i++) {
let childBox = this._calculateChildrenBox(children[i], x, y);
-
if (this._rowLimit && rowIndex >= this._rowLimit ||
- childBox.y2 > availHeight || this._parentHeight && (childBox.y2 > this._parentHeight) ) {
- if(firstTime) {
- maxChildsPerPage = count2;
- global.log("MAx children per page " + maxChildsPerPage);
- firstTime = false;
- spacingBetweenPages = this._parentHeight - ( children[i-1].y +
children[i-1].size.height);
- if(i < children.length) {
- this._firstPagesItems.push(children[i]);
- }
- y+= this._spaceBetweenPages;
- global.log("Spacing between pages " + this._spaceBetweenPages);
- // Recalculate child box
- childBox = this._calculateChildrenBox(children[i], x, y);
+ this._fillParent && childBox.y2 > availHeight) {
+ this._grid.set_skip_paint(children[i], true);
+ } else {
+ children[i].allocate(childBox, flags);
+ this._grid.set_skip_paint(children[i], false);
}
-
- count1 += 1;
- children[i].allocate(childBox, flags);
- this._grid.set_skip_paint(children[i], false);
- } else {
- children[i].allocate(childBox, flags);
- count2 += 1;
- this._grid.set_skip_paint(children[i], false);
- }
+
+
+ //children[i].allocate(childBox, flags);
columnIndex++;
if (columnIndex == nColumns) {
@@ -346,7 +324,7 @@ const IconGrid = new Lang.Class({
if (columnIndex == 0) {
y += this._vItemSize + spacing;
- if(!firstTime && count1 % maxChildsPerPage == 0) {
+ if((i + 1) % this._childrenPerPage == 0) {
y+= this._spaceBetweenPages;
if(i < children.length) {
this._firstPagesItems.push(children[i+1]);
@@ -357,7 +335,6 @@ const IconGrid = new Lang.Class({
x += this._hItemSize + spacing;
}
}
- global.log("WE NEED N PAGES " + this.nPages());
},
_calculateChildrenBox: function(child, x, y) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]