@breakside/jskit 2021.37.0 → 2021.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Frameworks/DOM.jsframework/Info.json +2 -2
- package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
- package/Frameworks/FontKit.jsframework/Info.json +2 -2
- package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/Info.json +2 -2
- package/Frameworks/Foundation.jsframework/JS/JSColor+HTML.js +11 -2
- package/Frameworks/Foundation.jsframework/JS/JSColor.js +62 -26
- package/Frameworks/Foundation.jsframework/JS/JSColorSpace.js +209 -1
- package/Frameworks/Foundation.jsframework/JS/JSSpec.js +1 -1
- package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
- package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
- package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
- package/Info.json +2 -2
- package/Node/io.breakside.jskit-bundle.js +4 -4
- package/Resources/doc-default.css +86 -0
- package/Root/Frameworks/APIKit/Info.yaml +1 -1
- package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/AuthKit/Info.yaml +1 -1
- package/Root/Frameworks/CSSOM/Info.yaml +1 -1
- package/Root/Frameworks/ChartKit/Info.yaml +1 -1
- package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
- package/Root/Frameworks/DBKit/Info.yaml +1 -1
- package/Root/Frameworks/DOM/Info.yaml +1 -1
- package/Root/Frameworks/Dispatch/Info.yaml +1 -1
- package/Root/Frameworks/FontKit/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/JSColor+HTML.js +11 -2
- package/Root/Frameworks/Foundation/JSColor.js +62 -26
- package/Root/Frameworks/Foundation/JSColorSpace.js +209 -1
- package/Root/Frameworks/Foundation/JSSpec.js +1 -1
- package/Root/Frameworks/ImageKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
- package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
- package/Root/Frameworks/PDFKit/Info.yaml +1 -1
- package/Root/Frameworks/QRKit/Info.yaml +1 -1
- package/Root/Frameworks/SearchKit/Info.yaml +1 -1
- package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/TestKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/JSColor+UIKit.js +75 -0
- package/Root/Frameworks/UIKit/UIAccessibility.js +15 -0
- package/Root/Frameworks/UIKit/UIActivityIndicatorView.js +2 -1
- package/Root/Frameworks/UIKit/UIAlertController.js +4 -3
- package/Root/Frameworks/UIKit/UIAnimation.js +7 -13
- package/Root/Frameworks/UIKit/UIApplication.js +3 -0
- package/Root/Frameworks/UIKit/UIBasicAnimation.js +6 -0
- package/Root/Frameworks/UIKit/UIButton.js +17 -25
- package/Root/Frameworks/UIKit/UICheckbox.js +11 -22
- package/Root/Frameworks/UIKit/UIColorPanel.js +27 -15
- package/Root/Frameworks/UIKit/UIColorSpace.js +132 -0
- package/Root/Frameworks/UIKit/UIColorWell.js +18 -2
- package/Root/Frameworks/UIKit/UIHTMLDisplayServer.js +1 -5
- package/Root/Frameworks/UIKit/UIHTMLTextField.js +3 -15
- package/Root/Frameworks/UIKit/UIHTMLWindowServer.js +72 -1
- package/Root/Frameworks/UIKit/UIImageView.js +4 -0
- package/Root/Frameworks/UIKit/UIKit.js +2 -0
- package/Root/Frameworks/UIKit/UILabel.js +14 -2
- package/Root/Frameworks/UIKit/UILayer.js +29 -1
- package/Root/Frameworks/UIKit/UIListView.js +10 -9
- package/Root/Frameworks/UIKit/UIMenu.js +10 -9
- package/Root/Frameworks/UIKit/UIMenuBar.js +5 -4
- package/Root/Frameworks/UIKit/UIMenuView.js +8 -4
- package/Root/Frameworks/UIKit/UINavigationBar.js +8 -5
- package/Root/Frameworks/UIKit/UINavigationController.js +3 -2
- package/Root/Frameworks/UIKit/UIOutlineViewCell.js +2 -1
- package/Root/Frameworks/UIKit/UIPopupButton.js +13 -24
- package/Root/Frameworks/UIKit/UIPopupWindow.js +3 -2
- package/Root/Frameworks/UIKit/UIProgressIndicatorView.js +1 -1
- package/Root/Frameworks/UIKit/UIRadioGroup.js +11 -22
- package/Root/Frameworks/UIKit/UIScroller.js +4 -3
- package/Root/Frameworks/UIKit/UISegmentedControl.js +16 -15
- package/Root/Frameworks/UIKit/UISlider.js +20 -36
- package/Root/Frameworks/UIKit/UITabView.js +34 -31
- package/Root/Frameworks/UIKit/UITextEditor.js +2 -1
- package/Root/Frameworks/UIKit/UITextField.js +13 -14
- package/Root/Frameworks/UIKit/UITextLayer.js +5 -0
- package/Root/Frameworks/UIKit/UITokenField.js +3 -3
- package/Root/Frameworks/UIKit/UIToolbar.js +84 -38
- package/Root/Frameworks/UIKit/UIToolbarOverflow.svg +8 -0
- package/Root/Frameworks/UIKit/UITooltipWindow.js +5 -5
- package/Root/Frameworks/UIKit/UITraitCollection.js +21 -0
- package/Root/Frameworks/UIKit/UIUserInterface.js +6 -0
- package/Root/Frameworks/UIKit/UIWebView.js +3 -2
- package/Root/Frameworks/UIKit/UIWindow.js +18 -24
- package/Root/Frameworks/UIKit/UIWindowButtonCloseInactive.svg +1 -1
- package/Root/Frameworks/UIKit/UIWindowButtonCloseNormal.svg +1 -1
- package/Root/Frameworks/UIKit/UIWindowServer.js +53 -8
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/Root/Templates/html/${PROJECT_NAME}/www/index.html +24 -4
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
// #import "UILabel.js"
|
|
18
18
|
// #import "UIImageView.js"
|
|
19
19
|
// #import "UIEvent.js"
|
|
20
|
+
// #import "JSColor+UIKit.js"
|
|
20
21
|
'use strict';
|
|
21
22
|
|
|
22
23
|
(function(){
|
|
@@ -255,16 +256,16 @@ JSClass("UICheckboxDefaultStyler", UICheckboxStyler, {
|
|
|
255
256
|
shadowRadius: 1,
|
|
256
257
|
|
|
257
258
|
init: function(){
|
|
258
|
-
this.normalBackgroundColor =
|
|
259
|
-
this.disabledBackgroundColor =
|
|
260
|
-
this.activeBackgroundColor =
|
|
261
|
-
this.normalBorderColor =
|
|
262
|
-
this.disabledBorderColor =
|
|
263
|
-
this.activeBorderColor =
|
|
264
|
-
this.normalTitleColor =
|
|
265
|
-
this.disabledTitleColor =
|
|
266
|
-
this.activeTitleColor =
|
|
267
|
-
this.shadowColor = JSColor.
|
|
259
|
+
this.normalBackgroundColor = JSColor.controlBackground;
|
|
260
|
+
this.disabledBackgroundColor = JSColor.disabledControlBackground;
|
|
261
|
+
this.activeBackgroundColor = JSColor.activeControlBackground;
|
|
262
|
+
this.normalBorderColor = JSColor.controlBorder;
|
|
263
|
+
this.disabledBorderColor = JSColor.disabledControlBorder;
|
|
264
|
+
this.activeBorderColor = JSColor.activeControlBorder;
|
|
265
|
+
this.normalTitleColor = JSColor.controlTitle;
|
|
266
|
+
this.disabledTitleColor = JSColor.disabledControlTitle;
|
|
267
|
+
this.activeTitleColor = JSColor.activeControlTitle;
|
|
268
|
+
this.shadowColor = JSColor.controlShadow;
|
|
268
269
|
this.shadowOffset = JSPoint(0, 1);
|
|
269
270
|
},
|
|
270
271
|
|
|
@@ -344,18 +345,6 @@ JSClass("UICheckboxDefaultStyler", UICheckboxStyler, {
|
|
|
344
345
|
|
|
345
346
|
});
|
|
346
347
|
|
|
347
|
-
UICheckboxDefaultStyler.NormalBackgroundColor = JSColor.initWithRGBA(250/255,250/255,250/255);
|
|
348
|
-
UICheckboxDefaultStyler.ActiveBackgroundColor = JSColor.initWithRGBA(224/255,224/255,224/255);
|
|
349
|
-
UICheckboxDefaultStyler.DisabledBackgroundColor = JSColor.initWithRGBA(240/255,240/255,240/255);
|
|
350
|
-
|
|
351
|
-
UICheckboxDefaultStyler.NormalBorderColor = JSColor.initWithRGBA(204/255,204/255,204/255);
|
|
352
|
-
UICheckboxDefaultStyler.ActiveBorderColor = JSColor.initWithRGBA(192/255,192/255,192/255);
|
|
353
|
-
UICheckboxDefaultStyler.DisabledBorderColor = JSColor.initWithRGBA(224/255,224/255,224/255);
|
|
354
|
-
|
|
355
|
-
UICheckboxDefaultStyler.NormalTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
|
|
356
|
-
UICheckboxDefaultStyler.ActiveTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
|
|
357
|
-
UICheckboxDefaultStyler.DisabledTitleColor = JSColor.initWithRGBA(152/255,152/255,152/255);
|
|
358
|
-
|
|
359
348
|
var images = Object.create({}, {
|
|
360
349
|
|
|
361
350
|
bundle: {
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
// Copyright 2021 Breakside Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Breakside Public License, Version 1.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// If a copy of the License was not distributed with this file, you may
|
|
6
|
+
// obtain a copy at
|
|
7
|
+
//
|
|
8
|
+
// http://breakside.io/licenses/LICENSE-1.0.txt
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
//
|
|
1
16
|
// #import "UIPopupWindow.js"
|
|
2
17
|
// #import "UISlider.js"
|
|
3
18
|
// #import "UITextField.js"
|
|
@@ -153,16 +168,13 @@ JSClass("UIColorPanelViewController", UIViewController, {
|
|
|
153
168
|
wellStyler.disabledBorderWidth = 0;
|
|
154
169
|
wellStyler.cornerRadius = 3;
|
|
155
170
|
var componentStyler = UITextFieldCustomStyler.init();
|
|
156
|
-
componentStyler.backgroundColor = JSColor.white.colorWithAlpha(0.
|
|
157
|
-
componentStyler.activeBackgroundColor = JSColor.white.colorWithAlpha(0.8);
|
|
171
|
+
componentStyler.backgroundColor = JSColor.initWithUIStyles(JSColor.white, JSColor.white.colorWithAlpha(0.1));
|
|
158
172
|
componentStyler.cornerRadius = 3;
|
|
159
173
|
componentStyler.textInsets = JSInsets(3, 4);
|
|
160
|
-
componentStyler.textColor = JSColor.
|
|
161
|
-
componentStyler.placeholderColor = JSColor.
|
|
174
|
+
componentStyler.textColor = JSColor.text;
|
|
175
|
+
componentStyler.placeholderColor = JSColor.placeholderText;
|
|
162
176
|
componentStyler.borderWidth = 1;
|
|
163
|
-
componentStyler.borderColor = JSColor.black.colorWithAlpha(0.2);
|
|
164
|
-
componentStyler.activeBorderColor = JSColor.black.colorWithAlpha(0.4);
|
|
165
|
-
componentStyler.disabledBorderColor = JSColor.black.colorWithAlpha(0.2);
|
|
177
|
+
componentStyler.borderColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.black.colorWithAlpha(0.4));
|
|
166
178
|
this.saturationBrightnessControl = UIColorPanelTwoAxisSlider.init();
|
|
167
179
|
this.hueSlider = UISlider.initWithStyler(hueStyler);
|
|
168
180
|
this.alphaSlider = UISlider.initWithStyler(alphaStyler);
|
|
@@ -203,7 +215,7 @@ JSClass("UIColorPanelViewController", UIViewController, {
|
|
|
203
215
|
this.hexLabel.text = "Hex";
|
|
204
216
|
this._updateComponentLabels();
|
|
205
217
|
this.component4Label.text = "Alpha";
|
|
206
|
-
this.hexLabel.textColor = JSColor.
|
|
218
|
+
this.hexLabel.textColor = JSColor.text.colorWithAlpha(0.5);
|
|
207
219
|
this.component1Label.textColor = this.hexLabel.textColor;
|
|
208
220
|
this.component2Label.textColor = this.hexLabel.textColor;
|
|
209
221
|
this.component3Label.textColor = this.hexLabel.textColor;
|
|
@@ -216,7 +228,7 @@ JSClass("UIColorPanelViewController", UIViewController, {
|
|
|
216
228
|
|
|
217
229
|
var hashLabel = UILabel.init();
|
|
218
230
|
hashLabel.font = this.hexField.font;
|
|
219
|
-
hashLabel.textColor = JSColor.
|
|
231
|
+
hashLabel.textColor = JSColor.text.colorWithAlpha(0.4);
|
|
220
232
|
hashLabel.text = "#";
|
|
221
233
|
hashLabel.sizeToFit();
|
|
222
234
|
this.hexField.leftAccessoryView = hashLabel;
|
|
@@ -733,12 +745,12 @@ JSClass("UIColorPanelTwoAxisSlider", UIControl, {
|
|
|
733
745
|
this._maximumValue = JSPoint(1, 1);
|
|
734
746
|
this.knobSize = JSSize(16, 16);
|
|
735
747
|
this._value = JSPoint(0, 0);
|
|
736
|
-
this.normalKnobBackgroundColor = JSColor.
|
|
737
|
-
this.activeKnobBackgroundColor = JSColor.
|
|
738
|
-
this.disabledKnobBackgroundColor =
|
|
739
|
-
this.normalKnobBorderColor = JSColor.
|
|
740
|
-
this.activeKnobBorderColor = JSColor.
|
|
741
|
-
this.disabledKnobBorderColor = JSColor.
|
|
748
|
+
this.normalKnobBackgroundColor = JSColor.controlBackground;
|
|
749
|
+
this.activeKnobBackgroundColor = JSColor.activeControlBackground;
|
|
750
|
+
this.disabledKnobBackgroundColor = JSColor.disabledControlBackground;
|
|
751
|
+
this.normalKnobBorderColor = JSColor.controlBorder;
|
|
752
|
+
this.activeKnobBorderColor = JSColor.activeControlBorder;
|
|
753
|
+
this.disabledKnobBorderColor = JSColor.disabledControlBorder;
|
|
742
754
|
this.xLayer = UILayer.init();
|
|
743
755
|
this.yLayer = UILayer.init();
|
|
744
756
|
this.yLayer.backgroundGradient = JSGradient.initWithColors([JSColor.black, JSColor.black.colorWithAlpha(0)]);
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Copyright 2021 Breakside Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Breakside Public License, Version 1.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// If a copy of the License was not distributed with this file, you may
|
|
6
|
+
// obtain a copy at
|
|
7
|
+
//
|
|
8
|
+
// http://breakside.io/licenses/LICENSE-1.0.txt
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
//
|
|
16
|
+
// #import Foundation
|
|
17
|
+
// #import "UIUserInterface.js"
|
|
18
|
+
/* global UIApplication */
|
|
19
|
+
"use strict";
|
|
20
|
+
|
|
21
|
+
JSClass("UIColorSpace", JSMappedColorSpace, {
|
|
22
|
+
|
|
23
|
+
name: "ui",
|
|
24
|
+
numberOfComponents: 1,
|
|
25
|
+
componentNames: {},
|
|
26
|
+
colors: null,
|
|
27
|
+
|
|
28
|
+
initWithStyles: function(lightColor, darkColor, lightContrastColor, darkContrastColor){
|
|
29
|
+
if (darkColor === undefined){
|
|
30
|
+
darkColor = lightColor;
|
|
31
|
+
}
|
|
32
|
+
if (lightContrastColor === undefined){
|
|
33
|
+
lightContrastColor = lightColor;
|
|
34
|
+
}
|
|
35
|
+
if (darkContrastColor === undefined){
|
|
36
|
+
darkContrastColor = darkColor;
|
|
37
|
+
}
|
|
38
|
+
this.colors = [
|
|
39
|
+
lightColor,
|
|
40
|
+
darkColor,
|
|
41
|
+
lightContrastColor,
|
|
42
|
+
darkContrastColor
|
|
43
|
+
];
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
colorFromComponents: function(components){
|
|
47
|
+
var color = this.colors[UIColorSpace.colorIndex];
|
|
48
|
+
if (components[0] < 1){
|
|
49
|
+
color = color.colorDarkenedByPercentage(1 - components[0]);
|
|
50
|
+
}else if (components[0] > 1){
|
|
51
|
+
color = color.colorLightenedByPercentage(components[0] - 1);
|
|
52
|
+
}
|
|
53
|
+
return color;
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
componentsDarkenedByPercentage: function(components, percentage){
|
|
57
|
+
return [
|
|
58
|
+
components[0] * (1.0 - percentage)
|
|
59
|
+
];
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
componentsLightenedByPercentage: function(components, percentage){
|
|
63
|
+
return [
|
|
64
|
+
components[0] * (1.0 + percentage)
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
UIColorSpace.colorIndex = 0;
|
|
71
|
+
|
|
72
|
+
UIColorSpace.setTraitCollection = function(traitCollection){
|
|
73
|
+
if (traitCollection.accessibilityContrast === UIUserInterface.Contrast.high){
|
|
74
|
+
if (traitCollection.userInterfaceStyle === UIUserInterface.Style.dark){
|
|
75
|
+
UIColorSpace.colorIndex = 3;
|
|
76
|
+
}else{
|
|
77
|
+
UIColorSpace.colorIndex = 2;
|
|
78
|
+
}
|
|
79
|
+
}else{
|
|
80
|
+
if (traitCollection.userInterfaceStyle === UIUserInterface.Style.dark){
|
|
81
|
+
UIColorSpace.colorIndex = 1;
|
|
82
|
+
}else{
|
|
83
|
+
UIColorSpace.colorIndex = 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (JSColor.invalidateCSSCache){
|
|
87
|
+
JSColor.invalidateCSSCache();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
JSClass("UINamedColorSpace", JSNamedColorSpace, {
|
|
92
|
+
|
|
93
|
+
setColorForName: function(name, color){
|
|
94
|
+
var namedColor = UINamedColorSpace.$super.setColorForName.call(this, name, color);
|
|
95
|
+
if (JSGlobalObject.UIApplication && UIApplication.shared){
|
|
96
|
+
UIApplication.shared.windowServer.setNeedsRedisplay();
|
|
97
|
+
if (JSColor.invalidateCSSCache){
|
|
98
|
+
JSColor.invalidateCSSCache();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
var space = this;
|
|
102
|
+
Object.defineProperty(JSColor, name, {
|
|
103
|
+
configurable: true,
|
|
104
|
+
get: function(){
|
|
105
|
+
return namedColor;
|
|
106
|
+
},
|
|
107
|
+
set: function(color){
|
|
108
|
+
space.setColorForName(name, color);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return namedColor;
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
setStylesForName: function(name, lightColor, darkColor, lightContrastColor, darkContrastColor){
|
|
115
|
+
var color = JSColor.initWithUIStyles(lightColor, darkColor, lightContrastColor, darkContrastColor);
|
|
116
|
+
this.setColorForName(name, color);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
Object.defineProperties(JSColorSpace, {
|
|
122
|
+
|
|
123
|
+
ui: {
|
|
124
|
+
configurable: true,
|
|
125
|
+
get: function(){
|
|
126
|
+
var space = UINamedColorSpace.init();
|
|
127
|
+
Object.defineProperty(this, "ui", {value: space});
|
|
128
|
+
return space;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
});
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
// Copyright 2021 Breakside Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Breakside Public License, Version 1.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// If a copy of the License was not distributed with this file, you may
|
|
6
|
+
// obtain a copy at
|
|
7
|
+
//
|
|
8
|
+
// http://breakside.io/licenses/LICENSE-1.0.txt
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
//
|
|
1
16
|
// #import "UIControl.js"
|
|
2
17
|
// #import "UIPasteboard.js"
|
|
3
18
|
// #import "UIColorPanel.js"
|
|
@@ -12,11 +27,12 @@ JSClass("UIColorWell", UIControl, {
|
|
|
12
27
|
initWithSpec: function(spec){
|
|
13
28
|
UIColorWell.$super.initWithSpec.call(this, spec);
|
|
14
29
|
if (spec.containsKey("color")){
|
|
15
|
-
this._color = spec.valueForKey("color", JSColor);
|
|
30
|
+
this._color = spec.valueForKey("color", JSColor).rgbaColor();
|
|
16
31
|
}
|
|
17
32
|
if (spec.containsKey("allowsAlpha")){
|
|
18
33
|
this._allowsAlpha = spec.valueForKey("allowsAlpha", JSColor);
|
|
19
34
|
}
|
|
35
|
+
this.update();
|
|
20
36
|
},
|
|
21
37
|
|
|
22
38
|
commonUIControlInit: function(){
|
|
@@ -36,7 +52,7 @@ JSClass("UIColorWell", UIControl, {
|
|
|
36
52
|
color: JSDynamicProperty("_color", JSColor.black),
|
|
37
53
|
|
|
38
54
|
setColor: function(color){
|
|
39
|
-
this._color = color;
|
|
55
|
+
this._color = color.rgbaColor();
|
|
40
56
|
this.update();
|
|
41
57
|
},
|
|
42
58
|
|
|
@@ -216,7 +216,6 @@ JSClass("UIHTMLDisplayServer", UIDisplayServer, {
|
|
|
216
216
|
setLayerNeedsDisplay: function(layer){
|
|
217
217
|
var context = this.contextForLayer(layer);
|
|
218
218
|
context.needsCustomDisplay = true;
|
|
219
|
-
layer._UIHTMLDisplayServerCustomDrawing = true;
|
|
220
219
|
UIHTMLDisplayServer.$super.setLayerNeedsDisplay.call(this, layer);
|
|
221
220
|
},
|
|
222
221
|
|
|
@@ -433,10 +432,7 @@ JSClass("UIHTMLDisplayServer", UIDisplayServer, {
|
|
|
433
432
|
|
|
434
433
|
_removeLayerFromDOM: function(layer){
|
|
435
434
|
layer._displayServer = null;
|
|
436
|
-
|
|
437
|
-
// So the layer will redraw if it's ever re-added
|
|
438
|
-
layer.setNeedsDisplay();
|
|
439
|
-
}
|
|
435
|
+
layer.setNeedsRedisplay();
|
|
440
436
|
var context = this.contextsByObjectID[layer.objectID];
|
|
441
437
|
if (context){
|
|
442
438
|
if (context.element.isConnected){
|
|
@@ -153,7 +153,7 @@ JSClass("UIHTMLTextField", UIControl, {
|
|
|
153
153
|
// MARK: - Placeholder
|
|
154
154
|
|
|
155
155
|
placeholder: JSDynamicProperty("_placeholder", null),
|
|
156
|
-
placeholderColor: JSDynamicProperty("_placeholderColor",
|
|
156
|
+
placeholderColor: JSDynamicProperty("_placeholderColor", JSColor.placeholderText),
|
|
157
157
|
|
|
158
158
|
setPlaceholder: function(placeholder){
|
|
159
159
|
this._placeholder = placeholder;
|
|
@@ -169,15 +169,6 @@ JSClass("UIHTMLTextField", UIControl, {
|
|
|
169
169
|
this.setNeedsDisplay();
|
|
170
170
|
},
|
|
171
171
|
|
|
172
|
-
_createPlaceholderColor: function(){
|
|
173
|
-
var backgroundColor = this.backgroundColor;
|
|
174
|
-
if (backgroundColor === null){
|
|
175
|
-
backgroundColor = JSColor.white;
|
|
176
|
-
}
|
|
177
|
-
this._placeholderColor = backgroundColor.colorByBlendingColor(this.textColor, 0.3);
|
|
178
|
-
this._needsPlaceholderColor = true;
|
|
179
|
-
},
|
|
180
|
-
|
|
181
172
|
// --------------------------------------------------------------------
|
|
182
173
|
// MARK: - Secure Entry
|
|
183
174
|
|
|
@@ -205,8 +196,8 @@ JSClass("UIHTMLTextField", UIControl, {
|
|
|
205
196
|
// MARK: - Styling
|
|
206
197
|
|
|
207
198
|
textAlignment: JSDynamicProperty("_textAlignment", JSTextAlignment.left),
|
|
208
|
-
textColor: JSDynamicProperty("_textColor", JSColor.
|
|
209
|
-
localCursorColor: JSDynamicProperty("_localCursorColor", JSColor.
|
|
199
|
+
textColor: JSDynamicProperty("_textColor", JSColor.text),
|
|
200
|
+
localCursorColor: JSDynamicProperty("_localCursorColor", JSColor.highlight),
|
|
210
201
|
font: JSDynamicProperty("_font", null),
|
|
211
202
|
|
|
212
203
|
setTextAlignment: function(textAlignment){
|
|
@@ -291,9 +282,6 @@ JSClass("UIHTMLTextField", UIControl, {
|
|
|
291
282
|
UIHTMLTextField.sharedStyleElement.type = "text/css";
|
|
292
283
|
layer.element.ownerDocument.head.appendChild(UIHTMLTextField.sharedStyleElement);
|
|
293
284
|
}
|
|
294
|
-
if (this._placeholderColor === null){
|
|
295
|
-
this._createPlaceholderColor();
|
|
296
|
-
}
|
|
297
285
|
var stylesheet = UIHTMLTextField.sharedStyleElement.sheet;
|
|
298
286
|
var index = stylesheet.insertRule("#%s::selection { }".sprintf(this.inputElement.id));
|
|
299
287
|
this.selectionStyleRule = stylesheet.cssRules.item(index);
|
|
@@ -65,6 +65,7 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
|
|
|
65
65
|
rootElement: null,
|
|
66
66
|
domDocument: null,
|
|
67
67
|
domWindow: null,
|
|
68
|
+
themeColorElement: null,
|
|
68
69
|
_screenClientOrigin: null,
|
|
69
70
|
|
|
70
71
|
setupRenderingEnvironment: function(){
|
|
@@ -85,11 +86,24 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
|
|
|
85
86
|
body.style.overflow = 'hidden';
|
|
86
87
|
body.style.borderLeft = "env(safe-area-inset-left) solid black";
|
|
87
88
|
body.style.borderRight = "env(safe-area-inset-right) solid black";
|
|
89
|
+
var head = this.domDocument.head;
|
|
90
|
+
var child;
|
|
91
|
+
for (var i = head.childNodes.length - 1; i >= 0; --i){
|
|
92
|
+
child = head.childNodes[i];
|
|
93
|
+
if (child.nodeType == Node.ELEMENT_NODE){
|
|
94
|
+
if (child.tagName.toLowerCase() === "meta" && child.getAttribute("name") == "theme-color"){
|
|
95
|
+
head.removeChild(child);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.themeColorElement = head.appendChild(this.domDocument.createElement("meta"));
|
|
100
|
+
this.themeColorElement.setAttribute("name", "theme-color");
|
|
88
101
|
}else{
|
|
89
102
|
var style = this.domWindow.getComputedStyle(this.rootElement);
|
|
90
103
|
if (style.position != 'absolute' && style.position != 'relative' && style.position != 'fixed'){
|
|
91
104
|
this.rootElement.style.position = 'relative';
|
|
92
105
|
}
|
|
106
|
+
this.themeColorElement = null;
|
|
93
107
|
}
|
|
94
108
|
this.rootElement.style.userSelect = 'none';
|
|
95
109
|
this.rootElement.style.mozUserSelect = 'none';
|
|
@@ -267,16 +281,21 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
|
|
|
267
281
|
// --------------------------------------------------------------------
|
|
268
282
|
// MARK: - Media Queries
|
|
269
283
|
|
|
284
|
+
darkColorSchemeListener: null,
|
|
270
285
|
highContrastListener: null,
|
|
271
286
|
reducedMotionListener: null,
|
|
272
287
|
|
|
273
288
|
setupMediaListeners: function(){
|
|
289
|
+
this.darkColorSchemeListener = this.handleDarkColorSchemeChanged.bind(this);
|
|
290
|
+
this.darkColorSchemeQuery = this.domWindow.matchMedia("(prefers-color-scheme: dark)");
|
|
291
|
+
this.darkColorSchemeQuery.addListener(this.darkColorSchemeListener);
|
|
274
292
|
this.highContrastListener = this.handleHighContrastChanged.bind(this);
|
|
275
293
|
this.highContrastQuery = this.domWindow.matchMedia("(prefers-contrast: more)");
|
|
276
294
|
this.highContrastQuery.addListener(this.highContrastListener);
|
|
277
295
|
this.reducedMotionListener = this.handleReducedMotionChanged.bind(this);
|
|
278
296
|
this.reducedMotionQuery = this.domWindow.matchMedia("(prefers-reduced-motion)");
|
|
279
297
|
this.reducedMotionQuery.addListener(this.reducedMotionListener);
|
|
298
|
+
this.handleDarkColorSchemeChanged(this.darkColorSchemeQuery);
|
|
280
299
|
this.handleHighContrastChanged(this.highContrastQuery);
|
|
281
300
|
this.handleReducedMotionChanged(this.reducedMotionQuery);
|
|
282
301
|
},
|
|
@@ -286,8 +305,16 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
|
|
|
286
305
|
this.reducedMotionQuery.removeListener(this.reducedMotionListener);
|
|
287
306
|
},
|
|
288
307
|
|
|
308
|
+
handleDarkColorSchemeChanged: function(query){
|
|
309
|
+
var style = query.matches ? UIUserInterface.Style.dark : UIUserInterface.Style.light;
|
|
310
|
+
this.traitCollection = this._traitCollection.traitsWithUserInterfaceStyle(style);
|
|
311
|
+
this.updateThemeColorElement();
|
|
312
|
+
},
|
|
313
|
+
|
|
289
314
|
handleHighContrastChanged: function(query){
|
|
290
|
-
|
|
315
|
+
var contrast = query.matches ? UIUserInterface.Contrast.high : UIUserInterface.Contrast.normal;
|
|
316
|
+
this.traitCollection = this._traitCollection.traitsWithContrast(contrast);
|
|
317
|
+
this.updateThemeColorElement();
|
|
291
318
|
},
|
|
292
319
|
|
|
293
320
|
handleReducedMotionChanged: function(query){
|
|
@@ -872,6 +899,50 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
|
|
|
872
899
|
}
|
|
873
900
|
},
|
|
874
901
|
|
|
902
|
+
orderWindowFront: function(window){
|
|
903
|
+
UIHTMLWindowServer.$super.orderWindowFront.call(this, window);
|
|
904
|
+
if (window.subviewIndex === 0){
|
|
905
|
+
this.updateThemeColorElement();
|
|
906
|
+
}
|
|
907
|
+
},
|
|
908
|
+
|
|
909
|
+
// --------------------------------------------------------------------
|
|
910
|
+
// MARK: - Menu Bar
|
|
911
|
+
|
|
912
|
+
setMenuBar: function(menuBar){
|
|
913
|
+
UIHTMLWindowServer.$super.setMenuBar.call(this, menuBar);
|
|
914
|
+
this.updateThemeColorElement();
|
|
915
|
+
},
|
|
916
|
+
|
|
917
|
+
updateThemeColorElement: function(){
|
|
918
|
+
if (this.themeColorElement === null){
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
var window = this._menuBar;
|
|
922
|
+
var color = null;
|
|
923
|
+
if (window === null && this.windowStack.length > 0){
|
|
924
|
+
window = this.windowStack[0];
|
|
925
|
+
}
|
|
926
|
+
if (window !== null){
|
|
927
|
+
var vc = window.contentViewController;
|
|
928
|
+
if ((vc instanceof UISplitViewController) && vc.view.mainHidden){
|
|
929
|
+
vc = vc.leadingViewController;
|
|
930
|
+
}
|
|
931
|
+
if (vc instanceof UINavigationController){
|
|
932
|
+
color = vc.navigationBar.backgroundColor;
|
|
933
|
+
}else if (window.backgroundGradient !== null){
|
|
934
|
+
color = window.backgroundGradient.stops[0].color;
|
|
935
|
+
}else if (window.backgroundColor !== null){
|
|
936
|
+
color = window.backgroundColor;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (color !== null){
|
|
940
|
+
this.themeColorElement.setAttribute("content", color.cssString());
|
|
941
|
+
}else{
|
|
942
|
+
this.themeColorElement.setAttribute("content", JSColor.background);
|
|
943
|
+
}
|
|
944
|
+
},
|
|
945
|
+
|
|
875
946
|
// --------------------------------------------------------------------
|
|
876
947
|
// MARK: - Screen Updates
|
|
877
948
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
// #import "UIView.js"
|
|
17
17
|
// #import "UIImageLayer.js"
|
|
18
|
+
// #import "JSColor+UIKit.js"
|
|
18
19
|
'use strict';
|
|
19
20
|
|
|
20
21
|
JSClass("UIImageView", UIView, {
|
|
@@ -32,6 +33,7 @@ JSClass("UIImageView", UIView, {
|
|
|
32
33
|
initWithFrame: function(frame){
|
|
33
34
|
UIImageView.$super.initWithFrame.call(this, frame);
|
|
34
35
|
this._contentInsets = JSInsets.Zero;
|
|
36
|
+
this.templateColor = JSColor.text;
|
|
35
37
|
this._commonImageViewInit();
|
|
36
38
|
},
|
|
37
39
|
|
|
@@ -39,6 +41,8 @@ JSClass("UIImageView", UIView, {
|
|
|
39
41
|
UIImageView.$super.initWithSpec.call(this, spec);
|
|
40
42
|
if (spec.containsKey('templateColor')){
|
|
41
43
|
this.templateColor = spec.valueForKey("templateColor", JSColor);
|
|
44
|
+
}else{
|
|
45
|
+
this.templateColor = JSColor.text;
|
|
42
46
|
}
|
|
43
47
|
if (spec.containsKey("automaticRenderMode")){
|
|
44
48
|
this.automaticRenderMode = spec.valueForKey("automaticRenderMode", JSImage.RenderMode);
|
|
@@ -38,7 +38,8 @@ JSClass('UILabel', UIView, {
|
|
|
38
38
|
initWithFrame: function(frame){
|
|
39
39
|
UILabel.$super.initWithFrame.call(this, frame);
|
|
40
40
|
this.maximumNumberOfLines = 1;
|
|
41
|
-
this.
|
|
41
|
+
this.textColor = JSColor.text;
|
|
42
|
+
this._selectionColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.white.colorWithAlpha(0.2));
|
|
42
43
|
},
|
|
43
44
|
|
|
44
45
|
initWithSpec: function(spec){
|
|
@@ -51,6 +52,8 @@ JSClass('UILabel', UIView, {
|
|
|
51
52
|
}
|
|
52
53
|
if (spec.containsKey("textColor")){
|
|
53
54
|
this.textColor = spec.valueForKey("textColor", JSColor);
|
|
55
|
+
}else{
|
|
56
|
+
this.textColor = JSColor.text;
|
|
54
57
|
}
|
|
55
58
|
if (spec.containsKey("textAlignment")){
|
|
56
59
|
this.textAlignment = spec.valueForKey("textAlignment", JSTextAlignment);
|
|
@@ -72,7 +75,16 @@ JSClass('UILabel', UIView, {
|
|
|
72
75
|
if (spec.containsKey("selectionColor")){
|
|
73
76
|
this._selectionColor = spec.valueForKey("selectionColor");
|
|
74
77
|
}else{
|
|
75
|
-
this._selectionColor = JSColor.white.colorWithAlpha(0.2);
|
|
78
|
+
this._selectionColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.white.colorWithAlpha(0.2));
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
tooltip: JSDynamicProperty("_tooltip"),
|
|
83
|
+
|
|
84
|
+
setTooltip: function(tooltip){
|
|
85
|
+
this._tooltip = tooltip;
|
|
86
|
+
if (this._tooltip !== null){
|
|
87
|
+
this.userInteractionEnabled = true;
|
|
76
88
|
}
|
|
77
89
|
},
|
|
78
90
|
|
|
@@ -686,6 +686,16 @@ JSClass("UILayer", JSObject, {
|
|
|
686
686
|
}
|
|
687
687
|
},
|
|
688
688
|
|
|
689
|
+
setNeedsRedisplay: function(){
|
|
690
|
+
this.didChangeProperty("backgroundColor");
|
|
691
|
+
this.didChangeProperty("backgroundGradient");
|
|
692
|
+
this.didChangeProperty("borderColor");
|
|
693
|
+
this.didChangeProperty("shadowColor");
|
|
694
|
+
if (this.performsCustomDrawing){
|
|
695
|
+
this.setNeedsDisplay();
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
|
|
689
699
|
displayIfNeeded: function(){
|
|
690
700
|
if (this._displayServer !== null){
|
|
691
701
|
this._displayServer.displayLayerIfNeeded(this);
|
|
@@ -699,6 +709,15 @@ JSClass("UILayer", JSObject, {
|
|
|
699
709
|
}
|
|
700
710
|
},
|
|
701
711
|
|
|
712
|
+
performsCustomDrawing: JSReadOnlyProperty(),
|
|
713
|
+
|
|
714
|
+
getPerformsCustomDrawing: function(){
|
|
715
|
+
if (this.delegate && this.delegate.drawLayerInContext){
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
return this.drawInContext !== UILayer.prototype.drawInContext;
|
|
719
|
+
},
|
|
720
|
+
|
|
702
721
|
drawInContext: function(context){
|
|
703
722
|
},
|
|
704
723
|
|
|
@@ -714,7 +733,16 @@ JSClass("UILayer", JSObject, {
|
|
|
714
733
|
if (this._displayServer !== null){
|
|
715
734
|
var displayContext = this._displayServer.contextForLayer(this);
|
|
716
735
|
if (context === displayContext){
|
|
717
|
-
this
|
|
736
|
+
var layers = [this];
|
|
737
|
+
var layer;
|
|
738
|
+
var i, l;
|
|
739
|
+
while (layers.length > 0){
|
|
740
|
+
layer = layers.shift();
|
|
741
|
+
layer.setNeedsRedisplay();
|
|
742
|
+
for (i = 0, l = layer.sublayers.length; i < l; ++i){
|
|
743
|
+
layers.push(layer.sublayers[i]);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
718
746
|
return;
|
|
719
747
|
}
|
|
720
748
|
}
|