Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1211 from autarkper/scale-tuning
[Scale; 1.8] Fine-tune some aspects of Scale
- Loading branch information
Showing
13 changed files
with
933 additions
and
1,882 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- | ||
const Lang = imports.lang; | ||
const Clutter = imports.gi.Clutter; | ||
|
||
function nextIndex(itemCount, numCols, currentIndex, symbol) { | ||
let result = -1; | ||
if (itemCount > 3 // grid navigation is not suited for a low item count | ||
&& (symbol === Clutter.Down || symbol === Clutter.Up)) | ||
{ | ||
let numRows = Math.ceil(itemCount/numCols); | ||
|
||
let curRow = Math.floor(currentIndex/numCols); | ||
let curCol = currentIndex % numCols; | ||
|
||
let calcNewIndex = function(rowDelta) { | ||
let newIndex = (curRow + rowDelta) * numCols + curCol; | ||
if (rowDelta >= 0) { // down | ||
return newIndex < itemCount ? | ||
newIndex : | ||
curCol < numCols - 1 ? | ||
// wrap to top row, one column to the right: | ||
curCol + 1 : | ||
// wrap to top row, left-most column: | ||
0; | ||
} | ||
else { // up | ||
let numFullRows = Math.floor(itemCount/numCols); | ||
let numIOILR = itemCount % numCols; //num Items on Incompl. Last Row | ||
return newIndex >= 0 ? | ||
newIndex : | ||
curCol === 0 ? | ||
// Wrap to the bottom of the right-most column, may not be on last row: | ||
(numFullRows * numCols) - 1 : | ||
/* If we're on the | ||
top row but not in the first column, we want to move to the bottom of the | ||
column to the left, even though that may not be the bottom of the grid. | ||
*/ | ||
numIOILR && curCol > numIOILR ? | ||
((numFullRows - 1) * numCols) + curCol - 1: | ||
((numRows - 1) * numCols) + curCol - 1; | ||
} | ||
}; | ||
|
||
if (symbol === Clutter.Down) { | ||
result = calcNewIndex(1); | ||
} | ||
if (symbol === Clutter.Up) { | ||
result = calcNewIndex(-1); | ||
} | ||
} | ||
else if (symbol === Clutter.Left || symbol === Clutter.Up) { | ||
result = (currentIndex < 1 ? itemCount : currentIndex) - 1; | ||
} | ||
else if (symbol === Clutter.Right || symbol === Clutter.Down) { | ||
result = (currentIndex + 1) % itemCount; | ||
} | ||
else if (symbol === Clutter.Home) { | ||
result = 0; | ||
} | ||
else if (symbol === Clutter.End) { | ||
result = itemCount - 1; | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- | ||
const Lang = imports.lang; | ||
const Gdk = imports.gi.Gdk; | ||
|
||
const PointerTracker = new Lang.Class({ | ||
Name: 'PointerTracker', | ||
_init: function() { | ||
let display = Gdk.Display.get_default(); | ||
let deviceManager = display.get_device_manager(); | ||
let pointer = deviceManager.get_client_pointer(); | ||
let [lastScreen, lastPointerX, lastPointerY] = pointer.get_position(); | ||
this.hasMoved = function() { | ||
let [screen, pointerX, pointerY] = pointer.get_position(); | ||
try { | ||
return !(screen == lastScreen && pointerX == lastPointerX && pointerY == lastPointerY); | ||
} finally { | ||
[lastScreen, lastPointerX, lastPointerY] = [screen, pointerX, pointerY]; | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.