Skip to content

Commit

Permalink
Initial commit (v0.3b)
Browse files Browse the repository at this point in the history
  • Loading branch information
bclennox committed Nov 9, 2009
0 parents commit 485c81c
Show file tree
Hide file tree
Showing 54 changed files with 2,341 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assets/*
Binary file added HSLider.dcproj/CustomImages/copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added HSLider.dcproj/CustomImages/hue-gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions HSLider.dcproj/brandan.wdgtuser
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Breakpoints</key>
<dict/>
<key>CYBreakOnException</key>
<false/>
<key>CYLastWindowPosition</key>
<string>{596, 273}</string>
<key>ContentSplitViewGeometry</key>
<dict>
<key>ContentSplitViewConfig</key>
<integer>8</integer>
<key>SplitViewConfig</key>
<integer>3</integer>
<key>_indexOfCollapsedView</key>
<integer>0</integer>
<key>sizes</key>
<array>
<string>{{0, 0}, {844, 404}}</string>
<string>{{0, 414}, {844, 363}}</string>
</array>
</dict>
<key>ContentViewType</key>
<integer>0</integer>
<key>DeploymentOptions</key>
<dict>
<key>Destination</key>
<string>localhost.default</string>
<key>EmailToNotifyAddress</key>
<string>bclennox@gmail.com</string>
<key>Path</key>
<string>ColorPicker</string>
<key>SavePath</key>
<string>/Users/brandan/Desktop</string>
<key>enableSimulation</key>
<true/>
<key>simulatedHost</key>
<string>bmacpro.local</string>
</dict>
<key>Design time language</key>
<string>en.lproj</string>
<key>EvaluatorFrame</key>
<string>441 398 479 226 0 0 1440 878 </string>
<key>MainSplitViewGeometry</key>
<dict>
<key>_indexOfCollapsedView</key>
<integer>0</integer>
<key>sizes</key>
<array>
<string>{{0, 0}, {244, 798}}</string>
<string>{{245, 0}, {845, 798}}</string>
</array>
</dict>
<key>MainWindowFrame</key>
<string>325 59 1089 819 0 0 1440 878 </string>
<key>NavigatorSplitViewGeometry</key>
<dict>
<key>ContentSplitViewConfig</key>
<integer>5</integer>
<key>SplitViewConfig</key>
<integer>3</integer>
<key>_indexOfCollapsedView</key>
<integer>0</integer>
<key>sizes</key>
<array>
<string>{{0, 0}, {246, 403}}</string>
<string>{{0, 413}, {246, 364}}</string>
</array>
</dict>
<key>Widget</key>
<dict>
<key>Objects view expanded items</key>
<array>
<array>
<integer>0</integer>
<integer>0</integer>
<integer>9</integer>
</array>
<array>
<integer>0</integer>
<integer>0</integer>
<integer>9</integer>
<integer>0</integer>
</array>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>4</integer>
</array>
<array>
<integer>0</integer>
</array>
<array>
<integer>0</integer>
<integer>0</integer>
</array>
<array>
<integer>0</integer>
<integer>1</integer>
</array>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
</array>
</array>
<key>Objects view last selections</key>
<array/>
<key>Opened Steps</key>
<array/>
<key>Visible StackLayout Views</key>
<array>
<string>back</string>
</array>
</dict>
</dict>
</plist>
Binary file not shown.
99 changes: 99 additions & 0 deletions HSLider.dcproj/project/widget.wdgt/Adjustor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
var Adjustor = {};

Adjustor.UP = 38;
Adjustor.DOWN = 40;

Adjustor.nudge = function (input, event, format){

// when replacing the nudged value, tells us where to start and
// how far to go (like substr(repl.start, repl.length))
var repl = { start: 0, length: 0 };

// record the original position of the cursor
var cursor = input.selectionStart;

// determine which direction we're nudging
var direction = event.keyCode;
if (direction != Adjustor.UP && direction != Adjustor.DOWN){
return;
}

// since we'll sometimes prevent the cursor from moving, we
// should always prevent the cursor from moving
event.preventDefault();

function parse(){
var value = input.value,
p = cursor,
start;

function isNumeric(value){
return !isNaN(parseInt(value));
}

while (start == undefined){

var left = isNumeric(value[p - 1]),
right = isNumeric(value[p]);

// if there's no digit left or right, bail
if (!left && !right){
return;
}

// if there's no digit left but a digit right, we've found our start
else if (!left && right){
start = p;
}

// if there's a digit left, regardless of a digit right, move left
else if (left){
p--;
}
}

var parsed = parseInt(value.substr(start));

// record the start and the length to replace this value later
repl.start = start;
repl.length = parsed.toString().length;

return parsed;
}

function replace(value){
var min = 0, max;

if (format == Color.RGB){
max = 255;
} else {

// if we're looking at hue, then there will be no digits to the
// left of the start position
max = /\d/.test(input.value.substr(0, repl.start)) ? 100 : 359;
}

value = Math.max(min, Math.min(max, value));

var chunks = input.value.split("");
chunks.splice(repl.start, repl.length, value);
return chunks.join("");
}

function adjustment(){
return (direction == Adjustor.UP ? 1 : -1) * (event.altKey ? 10 : 1);
}

var parsed = parse();

if (parsed == undefined){
return;
}

input.value = replace(parsed + adjustment());

// put the cursor in the right spot
input.selectionStart = input.selectionEnd = cursor;

return input.value;
};
Loading

0 comments on commit 485c81c

Please sign in to comment.