From b6ee338e86f9f021f17a2a556507d3430caf5950 Mon Sep 17 00:00:00 2001 From: Joseph Atkins-Turkish Date: Mon, 11 Jan 2016 16:13:43 -0800 Subject: [PATCH] SDK-dependant options and display --- ide/static/ide/css/ib.css | 35 ++++++++-- ide/static/ide/js/ib/canvas.js | 2 + ide/static/ide/js/ib/ib.js | 1 + ide/static/ide/js/ib/layers/actionbarlayer.js | 11 ++- ide/static/ide/js/ib/properties.js | 70 +++++++++++-------- ide/static/ide/js/ib/settings.js | 20 +++--- ide/static/ide/js/ib/utils.js | 1 - ide/static/ide/js/resources.js | 2 +- 8 files changed, 91 insertions(+), 51 deletions(-) diff --git a/ide/static/ide/css/ib.css b/ide/static/ide/css/ib.css index 1d42b129..d6b7798b 100644 --- a/ide/static/ide/css/ib.css +++ b/ide/static/ide/css/ib.css @@ -160,33 +160,54 @@ /* ActionBarLayer */ -.ib-actionbarlayer { +.ib-canvas-sdk2 .ib-actionbarlayer { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } .ib-actionbarlayer-icon { position: absolute; - left: 1px; - width: 18px; - height: 18px; text-align: center; background-repeat: no-repeat; pointer-events: none; } -.ib-icon-up { +.ib-canvas-sdk2 .ib-actionbarlayer-icon { + left: 1px; + width: 18px; + height: 18px; +} + +.ib-canvas-sdk3 .ib-actionbarlayer-icon { + left: 5px; + width: 22px; + height: 22px; +} + +.ib-canvas-sdk2 .ib-icon-up { top: calc(16% - 9px); } -.ib-icon-select { +.ib-canvas-sdk2 .ib-icon-select { top: calc(50% - 9px); } -.ib-icon-down { +.ib-canvas-sdk2 .ib-icon-down { top: calc(83% - 9px); } +.ib-canvas-sdk3 .ib-icon-up { + top: calc(19% - 11px); +} + +.ib-canvas-sdk3 .ib-icon-select { + top: calc(50% - 11px); +} + +.ib-canvas-sdk3 .ib-icon-down { + top: calc(80% - 11px); +} + /* MenuLayer */ .ib-menulayer { diff --git a/ide/static/ide/js/ib/canvas.js b/ide/static/ide/js/ib/canvas.js index ff3afb54..fa4e24f7 100644 --- a/ide/static/ide/js/ib/canvas.js +++ b/ide/static/ide/js/ib/canvas.js @@ -44,6 +44,8 @@ function init(parent) { mNode = $('
'); mNode.on('mousedown', handleMouseDown); + mNode.toggleClass('ib-canvas-sdk2', CloudPebble.ProjectInfo.sdk_version == "2"); + mNode.toggleClass('ib-canvas-sdk3', CloudPebble.ProjectInfo.sdk_version == "3"); mNode.appendTo(parent); render(); diff --git a/ide/static/ide/js/ib/ib.js b/ide/static/ide/js/ib/ib.js index ee0b08e4..7df5c88d 100644 --- a/ide/static/ide/js/ib/ib.js +++ b/ide/static/ide/js/ib/ib.js @@ -93,6 +93,7 @@ init(); }; if (!IB.colourMode) { + IB.ColourEnabled = (CloudPebble.ProjectInfo.sdk_version == "3"); IB.colourMode = (CloudPebble.ProjectInfo.sdk_version == "3" ? IB.ColourModes.Colour : IB.ColourModes.Monochrome); } init(); diff --git a/ide/static/ide/js/ib/layers/actionbarlayer.js b/ide/static/ide/js/ib/layers/actionbarlayer.js index bde53919..87a120d1 100644 --- a/ide/static/ide/js/ib/layers/actionbarlayer.js +++ b/ide/static/ide/js/ib/layers/actionbarlayer.js @@ -32,8 +32,15 @@ this._properties['icon_' + it].on('change', _.partial(this._handleIconChange, it), this); }, this); - this.setSize(20, 146); - this.setPos(124, 3); + if (CloudPebble.ProjectInfo.sdk_version == "3") { + this.setSize(30, 168); + this.setPos(114, 0); + } + else { + this.setSize(20, 146); + this.setPos(124, 3); + } + this._size.lock(); this._pos.lock(); }; diff --git a/ide/static/ide/js/ib/properties.js b/ide/static/ide/js/ib/properties.js index a4a9cf8c..06ae134f 100644 --- a/ide/static/ide/js/ib/properties.js +++ b/ide/static/ide/js/ib/properties.js @@ -197,7 +197,9 @@ */ IB.Properties.Colour = function(name, value) { Property.call(this, name, this._makeColours(value)); - this._labelClass = 'ib-colour-label'; + if (IB.ColourEnabled) { + this._labelClass = 'ib-colour-label'; + } }; IB.Properties.Colour.prototype = Object.create(_super); IB.Properties.Colour.prototype.constructor = IB.Properties.Colour; @@ -207,7 +209,7 @@ value = IB.ColourMap[value]; } if (_.isArray(value)) { - if (value[0] == "COLOR_FALLBACK") { + if (value[0] == "PBL_IF_COLOR_ELSE") { value = _.map(value.slice(1), function(c) { return IB.ColourMap[c]; }); @@ -247,7 +249,7 @@ if (_.uniq(this._value).length == 1) { return this._value[0].name; } else { - return interpolate("COLOR_FALLBACK(%s, %s)", [this._value[0].name, this._value[1].name]); + return interpolate("PBL_IF_COLOR_ELSE(%s, %s)", [this._value[0].name, this._value[1].name]); } }, /** @@ -263,39 +265,47 @@ } }, _generateNode: function() { + var element; var mono_options = _.map(IB.MonochromeMap, this._createColour); - var table = $(interpolate('' + - '' + - '' + - '
%s%s
', [gettext("Colour Watches"), gettext("B/W Watches")])); - var tr = table.find('tbody tr'); - var td = $("").appendTo(tr); - var div = $('
').appendTo(td); - this._colourNode = $('') - .change(_.bind(this._handleChange, this)) - .val(this._value[IB.ColourModes.Colour].name) - .appendTo(div); - this._bwNode = $('') + .change(_.bind(this._handleChange, this)) + .val(this._value[IB.ColourModes.Colour].name) + .appendTo(div); + this._bwNode.appendTo("").parent().appendTo(tr); + + var self = this; + setTimeout(function() { + self._colourNode.pebbleColourPicker({ + value_mapping: function(value) { + if (value == "transparent") { + return "GColorClear"; + } + else { + return _.findWhere(IB.ColourMap, {css: value}); + } } - } - }); - self._setColourCSS(); - }, 1); - return table; + }); + self._setColourCSS(); + }, 0); + } + else { + this._colourNode = this._bwNode; + element = this._bwNode; + } + return element; }, _createColour: function(colour) { return $('