[gnome-shell] iconGrid: Add alignment parameter
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] iconGrid: Add alignment parameter
- Date: Thu, 14 Oct 2010 15:46:48 +0000 (UTC)
commit 627f1cb59a9937b984bbce47c52ca0947e51ac46
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Oct 14 14:27:22 2010 +0200
iconGrid: Add alignment parameter
Currently the grid's content is centered, which is not appropriate
for all use cases. Add an optional parameter to control the alignment.
https://bugzilla.gnome.org/show_bug.cgi?id=632147
js/ui/iconGrid.js | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 05abe1b..3625316 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -135,9 +135,12 @@ function IconGrid(params) {
IconGrid.prototype = {
_init: function(params) {
- params = Params.parse(params, { rowLimit: null, columnLimit: null });
+ params = Params.parse(params, { rowLimit: null,
+ columnLimit: null,
+ xAlign: St.Align.MIDDLE });
this._rowLimit = params.rowLimit;
this._colLimit = params.columnLimit;
+ this._xAlign = params.xAlign;
this.actor = new St.BoxLayout({ style_class: 'icon-grid',
vertical: true });
@@ -189,9 +192,19 @@ IconGrid.prototype = {
let [nColumns, usedWidth] = this._computeLayout(availWidth);
- let overallPaddingX = Math.floor((availWidth - usedWidth) / 2);
+ let leftPadding;
+ switch(this._xAlign) {
+ case St.Align.START:
+ leftPadding = 0;
+ break;
+ case St.Align.MIDDLE:
+ leftPadding = Math.floor((availWidth - usedWidth) / 2);
+ break;
+ case St.Align.END:
+ leftPadding = availWidth - usedWidth;
+ }
- let x = box.x1 + overallPaddingX;
+ let x = box.x1 + leftPadding;
let y = box.y1;
let columnIndex = 0;
let rowIndex = 0;
@@ -231,7 +244,7 @@ IconGrid.prototype = {
if (columnIndex == 0) {
y += this._item_size + this._spacing;
- x = box.x1 + overallPaddingX;
+ x = box.x1 + leftPadding;
} else {
x += this._item_size + this._spacing;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]