Skip to content

Commit b6ee338

Browse files
author
Joseph Atkins-Turkish
committed
SDK-dependant options and display
1 parent 2602ca2 commit b6ee338

File tree

8 files changed

+91
-51
lines changed

8 files changed

+91
-51
lines changed

ide/static/ide/css/ib.css

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,33 +160,54 @@
160160

161161
/* ActionBarLayer */
162162

163-
.ib-actionbarlayer {
163+
.ib-canvas-sdk2 .ib-actionbarlayer {
164164
border-top-left-radius: 3px;
165165
border-bottom-left-radius: 3px;
166166
}
167167

168168
.ib-actionbarlayer-icon {
169169
position: absolute;
170-
left: 1px;
171-
width: 18px;
172-
height: 18px;
173170
text-align: center;
174171
background-repeat: no-repeat;
175172
pointer-events: none;
176173
}
177174

178-
.ib-icon-up {
175+
.ib-canvas-sdk2 .ib-actionbarlayer-icon {
176+
left: 1px;
177+
width: 18px;
178+
height: 18px;
179+
}
180+
181+
.ib-canvas-sdk3 .ib-actionbarlayer-icon {
182+
left: 5px;
183+
width: 22px;
184+
height: 22px;
185+
}
186+
187+
.ib-canvas-sdk2 .ib-icon-up {
179188
top: calc(16% - 9px);
180189
}
181190

182-
.ib-icon-select {
191+
.ib-canvas-sdk2 .ib-icon-select {
183192
top: calc(50% - 9px);
184193
}
185194

186-
.ib-icon-down {
195+
.ib-canvas-sdk2 .ib-icon-down {
187196
top: calc(83% - 9px);
188197
}
189198

199+
.ib-canvas-sdk3 .ib-icon-up {
200+
top: calc(19% - 11px);
201+
}
202+
203+
.ib-canvas-sdk3 .ib-icon-select {
204+
top: calc(50% - 11px);
205+
}
206+
207+
.ib-canvas-sdk3 .ib-icon-down {
208+
top: calc(80% - 11px);
209+
}
210+
190211
/* MenuLayer */
191212

192213
.ib-menulayer {

ide/static/ide/js/ib/canvas.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
function init(parent) {
4545
mNode = $('<div class="ib-canvas">');
4646
mNode.on('mousedown', handleMouseDown);
47+
mNode.toggleClass('ib-canvas-sdk2', CloudPebble.ProjectInfo.sdk_version == "2");
48+
mNode.toggleClass('ib-canvas-sdk3', CloudPebble.ProjectInfo.sdk_version == "3");
4749
mNode.appendTo(parent);
4850

4951
render();

ide/static/ide/js/ib/ib.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
init();
9494
};
9595
if (!IB.colourMode) {
96+
IB.ColourEnabled = (CloudPebble.ProjectInfo.sdk_version == "3");
9697
IB.colourMode = (CloudPebble.ProjectInfo.sdk_version == "3" ? IB.ColourModes.Colour : IB.ColourModes.Monochrome);
9798
}
9899
init();

ide/static/ide/js/ib/layers/actionbarlayer.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@
3232
this._properties['icon_' + it].on('change', _.partial(this._handleIconChange, it), this);
3333
}, this);
3434

35-
this.setSize(20, 146);
36-
this.setPos(124, 3);
35+
if (CloudPebble.ProjectInfo.sdk_version == "3") {
36+
this.setSize(30, 168);
37+
this.setPos(114, 0);
38+
}
39+
else {
40+
this.setSize(20, 146);
41+
this.setPos(124, 3);
42+
}
43+
3744
this._size.lock();
3845
this._pos.lock();
3946
};

ide/static/ide/js/ib/properties.js

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@
197197
*/
198198
IB.Properties.Colour = function(name, value) {
199199
Property.call(this, name, this._makeColours(value));
200-
this._labelClass = 'ib-colour-label';
200+
if (IB.ColourEnabled) {
201+
this._labelClass = 'ib-colour-label';
202+
}
201203
};
202204
IB.Properties.Colour.prototype = Object.create(_super);
203205
IB.Properties.Colour.prototype.constructor = IB.Properties.Colour;
@@ -207,7 +209,7 @@
207209
value = IB.ColourMap[value];
208210
}
209211
if (_.isArray(value)) {
210-
if (value[0] == "COLOR_FALLBACK") {
212+
if (value[0] == "PBL_IF_COLOR_ELSE") {
211213
value = _.map(value.slice(1), function(c) {
212214
return IB.ColourMap[c];
213215
});
@@ -247,7 +249,7 @@
247249
if (_.uniq(this._value).length == 1) {
248250
return this._value[0].name;
249251
} else {
250-
return interpolate("COLOR_FALLBACK(%s, %s)", [this._value[0].name, this._value[1].name]);
252+
return interpolate("PBL_IF_COLOR_ELSE(%s, %s)", [this._value[0].name, this._value[1].name]);
251253
}
252254
},
253255
/**
@@ -263,39 +265,47 @@
263265
}
264266
},
265267
_generateNode: function() {
268+
var element;
266269
var mono_options = _.map(IB.MonochromeMap, this._createColour);
267-
var table = $(interpolate('<table class="ib-colours">' +
268-
'<thead><tr><th>%s</th><th>%s</th></tr></thead>' +
269-
'<tbody><tr></tr></tbody>' +
270-
'</table>', [gettext("Colour Watches"), gettext("B/W Watches")]));
271-
var tr = table.find('tbody tr');
272-
var td = $("<td></td>").appendTo(tr);
273-
var div = $('<div></div>').appendTo(td);
274-
this._colourNode = $('<input type="text" class="item-color item-color-normal" name="color-1">')
275-
.change(_.bind(this._handleChange, this))
276-
.val(this._value[IB.ColourModes.Colour].name)
277-
.appendTo(div);
278-
279270
this._bwNode = $('<select class="ib-property ib-colour">')
280271
.append(mono_options)
281272
.val(this._value[IB.ColourModes.Monochrome].name)
282273
.change(_.bind(this._handleChange, this));
283-
this._bwNode.appendTo("<td>").parent().appendTo(tr);
284-
var self = this;
285-
setTimeout(function() {
286-
self._colourNode.pebbleColourPicker({
287-
value_mapping: function(value) {
288-
if (value == "transparent") {
289-
return "GColorClear";
290-
}
291-
else {
292-
return _.findWhere(IB.ColourMap, {css: value});
274+
275+
if (IB.ColourEnabled) {
276+
element = $(interpolate('<table class="ib-colours">' +
277+
'<thead><tr><th>%s</th><th>%s</th></tr></thead>' +
278+
'<tbody><tr></tr></tbody>' +
279+
'</table>', [gettext("Colour Watches"), gettext("B/W Watches")]));
280+
var tr = element.find('tbody tr');
281+
var td = $("<td></td>").appendTo(tr);
282+
var div = $('<div></div>').appendTo(td);
283+
this._colourNode = $('<input type="text" class="item-color item-color-normal" name="color-1">')
284+
.change(_.bind(this._handleChange, this))
285+
.val(this._value[IB.ColourModes.Colour].name)
286+
.appendTo(div);
287+
this._bwNode.appendTo("<td>").parent().appendTo(tr);
288+
289+
var self = this;
290+
setTimeout(function() {
291+
self._colourNode.pebbleColourPicker({
292+
value_mapping: function(value) {
293+
if (value == "transparent") {
294+
return "GColorClear";
295+
}
296+
else {
297+
return _.findWhere(IB.ColourMap, {css: value});
298+
}
293299
}
294-
}
295-
});
296-
self._setColourCSS();
297-
}, 1);
298-
return table;
300+
});
301+
self._setColourCSS();
302+
}, 0);
303+
}
304+
else {
305+
this._colourNode = this._bwNode;
306+
element = this._bwNode;
307+
}
308+
return element;
299309
},
300310
_createColour: function(colour) {
301311
return $('<option>')

ide/static/ide/js/ib/settings.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
IB.Settings.ColourMode = {
55
name: gettext("Preview Mode"),
66
id: 'ib-setting-colourmode',
7+
isEnabled: function() {return IB.ColourEnabled;},
78
renderNode: function (parent) {
89
var isColour = IB.colourMode == IB.ColourModes.Colour;
9-
var node = $('<select>' +
10-
interpolate('<option value="0" %s>%s</option>', [(isColour ? 'selected' : ''), gettext("Colour")]) +
11-
interpolate('<option value="1" %s>%s</option>', [(isColour ? '' : 'selected'), gettext("Monochrome")]) +
12-
'</select>').attr('id', 'ib-setting-colourmode');
13-
node.change(_.bind(this.handleChange, parent));
14-
return node;
10+
console.log("makign mode setting");
11+
return $('<select>')
12+
.append(interpolate('<option value="0" %s>%s</option>', [(isColour ? 'selected' : ''), gettext("Colour")]))
13+
.append(interpolate('<option value="1" %s>%s</option>', [(isColour ? '' : 'selected'), gettext("Monochrome")]))
14+
.change(_.bind(this.handleChange, parent));
1515
},
1616
handleChange: function (evt) {
1717
IB.colourMode = parseInt(evt.target.value, 10);
@@ -43,10 +43,10 @@
4343

4444
var form = this._formNode;
4545
form.empty();
46-
47-
_.each(IB.Settings, function (setting, name) {
48-
form.append(this._generateControlGroup(setting));
49-
}, this);
46+
_.chain(IB.Settings)
47+
.filter(function(setting){return setting.isEnabled();})
48+
.map(function(setting) {return this._generateControlGroup(setting);}, this)
49+
.each(function(element){form.append(element);});
5050
},
5151
/**
5252
* Empties the contents of the parent node

ide/static/ide/js/ib/utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
};
3838
IB.colourMode = null;
3939

40-
4140
IB.ColourMap = {
4241
GColorClear: new IB.Colour('GColorClear', 'rgba(0, 0, 0, 0)', gettext('Transparent'))
4342
};

ide/static/ide/js/resources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ CloudPebble.Resources = (function() {
964964
return names;
965965
},
966966
GetBitmaps: function() {
967-
return _.filter(project_resources, function(item) { return /^png/.test(item.kind); });
967+
return _.filter(project_resources, function(item) { return /^(png|bitmap)/.test(item.kind); });
968968
},
969969
GetFonts: function() {
970970
return _.where(project_resources, {kind: 'font'});

0 commit comments

Comments
 (0)