iconGrid: Add minRows/minColumns properties
When we adapt the grid to different display sizes, we don't want the number of displayed items to get too small. In the future we will scale down icons to make sure that the grid fits add least minRows x minColumns items, but for now we only take the properties into account when calculating the dynamic spacing. https://bugzilla.gnome.org/show_bug.cgi?id=706081
This commit is contained in:
parent
754ca7c8f2
commit
ae263bb4db
@ -30,6 +30,8 @@ const Util = imports.misc.util;
|
|||||||
const MAX_APPLICATION_WORK_MILLIS = 75;
|
const MAX_APPLICATION_WORK_MILLIS = 75;
|
||||||
const MENU_POPUP_TIMEOUT = 600;
|
const MENU_POPUP_TIMEOUT = 600;
|
||||||
const MAX_COLUMNS = 6;
|
const MAX_COLUMNS = 6;
|
||||||
|
const MIN_COLUMNS = 4;
|
||||||
|
const MIN_ROWS = 4;
|
||||||
|
|
||||||
const INACTIVE_GRID_OPACITY = 77;
|
const INACTIVE_GRID_OPACITY = 77;
|
||||||
const INACTIVE_GRID_OPACITY_ANIMATION_TIME = 0.15;
|
const INACTIVE_GRID_OPACITY_ANIMATION_TIME = 0.15;
|
||||||
@ -63,6 +65,8 @@ const BaseAppView = new Lang.Class({
|
|||||||
_init: function(params, gridParams) {
|
_init: function(params, gridParams) {
|
||||||
gridParams = Params.parse(gridParams, { xAlign: St.Align.MIDDLE,
|
gridParams = Params.parse(gridParams, { xAlign: St.Align.MIDDLE,
|
||||||
columnLimit: MAX_COLUMNS,
|
columnLimit: MAX_COLUMNS,
|
||||||
|
minRows: MIN_ROWS,
|
||||||
|
minColumns: MIN_COLUMNS,
|
||||||
fillParent: false });
|
fillParent: false });
|
||||||
params = Params.parse(params, { usePagination: false });
|
params = Params.parse(params, { usePagination: false });
|
||||||
|
|
||||||
|
@ -176,10 +176,14 @@ const IconGrid = new Lang.Class({
|
|||||||
_init: function(params) {
|
_init: function(params) {
|
||||||
params = Params.parse(params, { rowLimit: null,
|
params = Params.parse(params, { rowLimit: null,
|
||||||
columnLimit: null,
|
columnLimit: null,
|
||||||
|
minRows: 1,
|
||||||
|
minColumns: 1,
|
||||||
fillParent: false,
|
fillParent: false,
|
||||||
xAlign: St.Align.MIDDLE });
|
xAlign: St.Align.MIDDLE });
|
||||||
this._rowLimit = params.rowLimit;
|
this._rowLimit = params.rowLimit;
|
||||||
this._colLimit = params.columnLimit;
|
this._colLimit = params.columnLimit;
|
||||||
|
this._minRows = params.minRows;
|
||||||
|
this._minColumns = params.minColumns;
|
||||||
this._xAlign = params.xAlign;
|
this._xAlign = params.xAlign;
|
||||||
this._fillParent = params.fillParent;
|
this._fillParent = params.fillParent;
|
||||||
|
|
||||||
@ -393,17 +397,27 @@ const IconGrid = new Lang.Class({
|
|||||||
* This function must to be called before iconGrid allocation,
|
* This function must to be called before iconGrid allocation,
|
||||||
* to know how much spacing can the grid has
|
* to know how much spacing can the grid has
|
||||||
*/
|
*/
|
||||||
updateSpacingForSize: function(availWidth) {
|
updateSpacingForSize: function(availWidth, availHeight) {
|
||||||
let spacing = this._spacing;
|
let maxEmptyVArea = availHeight - this._minRows * this._vItemSize;
|
||||||
|
let maxEmptyHArea = availWidth - this._minColumns * this._hItemSize;
|
||||||
|
let maxHSpacing, maxVSpacing;
|
||||||
|
if (this._minRows <= 1)
|
||||||
|
maxVSpacing = maxEmptyVArea;
|
||||||
|
else
|
||||||
|
maxVSpacing = Math.floor(maxEmptyVArea / (this._minRows - 1));
|
||||||
|
|
||||||
if (this._colLimit) {
|
if (this._minColumns <= 1)
|
||||||
let itemWidth = this._hItemSize * this._colLimit;
|
maxHSpacing = maxEmptyHArea;
|
||||||
let emptyArea = availWidth - itemWidth;
|
else
|
||||||
spacing = Math.max(spacing, emptyArea / (2 * this._colLimit));
|
maxHSpacing = Math.floor(maxEmptyHArea / (this._minColumns - 1));
|
||||||
spacing = Math.round(spacing);
|
|
||||||
}
|
let maxSpacing = Math.min(maxHSpacing, maxVSpacing);
|
||||||
this.setSpacing(spacing);
|
// Limit spacing to the item size
|
||||||
},
|
maxSpacing = Math.min(maxSpacing, Math.min(this._vItemSize, this._hItemSize));
|
||||||
|
// The minimum spacing, regardless of whether it satisfies the row/column minima,
|
||||||
|
// is the spacing we get from CSS.
|
||||||
|
this.setSpacing(Math.max(this._spacing, maxSpacing));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const PaginatedIconGrid = new Lang.Class({
|
const PaginatedIconGrid = new Lang.Class({
|
||||||
|
Loading…
Reference in New Issue
Block a user