sugarcube 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -7
- data/lib/osx/sugarcube-ui/frameable.rb +44 -0
- data/lib/sugarcube-classic.rb +2 -4
- data/lib/sugarcube-common.rb +2 -4
- data/lib/version.rb +1 -1
- data/spec/osx/frameable_spec.rb +178 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aaf20dd0e772b47482d112bfb0131e6cfe44410
|
4
|
+
data.tar.gz: 6bd4d9153cdf28966eee328052bf624b43651227
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49f32218fe441b022c377be7b976c671b215ef6836b96c5f7ccd5eb58e7f0af85bfb25ae82f89c2a087f218c48b0f583d0b886146242bfaafa8fca63557dd871
|
7
|
+
data.tar.gz: 17721bd1e7e82e06bb1692e68b409c5493b33e2160ea6a95818bbfd2f285cebd2fe6c61fe5395905729385b34c0ed75fb59e1806e1fff0019f4ff0a282917699
|
data/README.md
CHANGED
@@ -86,7 +86,7 @@ the packages you need:
|
|
86
86
|
###### Gemfile
|
87
87
|
```ruby
|
88
88
|
gem 'sugarcube', :require => [
|
89
|
-
'sugarcube-
|
89
|
+
'sugarcube-ui',
|
90
90
|
'sugarcube-events',
|
91
91
|
'sugarcube-gestures',
|
92
92
|
'sugarcube-568',
|
@@ -103,7 +103,7 @@ require 'motion/project/template/ios'
|
|
103
103
|
require 'bundler'
|
104
104
|
Bundler.require
|
105
105
|
|
106
|
-
require 'sugarcube-
|
106
|
+
require 'sugarcube-ui'
|
107
107
|
require 'sugarcube-events'
|
108
108
|
require 'sugarcube-gestures'
|
109
109
|
require 'sugarcube-568'
|
@@ -192,19 +192,19 @@ Be sure to read more in the [REPL Additions][REPL Wiki] Wiki page.
|
|
192
192
|
|
193
193
|
[REPL Wiki]: https://github.com/rubymotion/sugarcube/wiki/REPL-Additions
|
194
194
|
|
195
|
-
UIKit ([wiki][UIKit Wiki])
|
195
|
+
UI on iOS: UIKit extensions ([wiki][UIKit Wiki])
|
196
196
|
-----
|
197
197
|
|
198
198
|
A big package chock full of methods to make working in UIKit a joy.
|
199
199
|
|
200
|
-
> `require 'sugarcube-
|
200
|
+
> `require 'sugarcube-ui'`
|
201
201
|
|
202
202
|
A few varieties of methods are in this package:
|
203
203
|
|
204
|
-
* Conversions: `'string-to'.uiimage`, `image.uiimageview`
|
204
|
+
* Conversions: `'string-to'.uiimage`, `image.uiimageview`, `'string-to'.uilabel(font)`
|
205
205
|
* Helpers: shorthands for common operations, like `a_view << a_subview`, `a_subview.convert_frame_to(a_view)`
|
206
206
|
* Symbols: `:system.uifont(20)`, `:label.uifontsize`
|
207
|
-
* Frame accessors: `a_view.x`, `a_view.x = 100`
|
207
|
+
* Frame accessors: `a_view.x`, `a_view.x = 100` (on `UIView` and `CALayer`)
|
208
208
|
|
209
209
|
There are too many methods to define here. Instead: a complete list of methods
|
210
210
|
is available in the [documentation][], and the [wiki page][UIKit Wiki] is a
|
@@ -212,6 +212,24 @@ great source as well.
|
|
212
212
|
|
213
213
|
[UIKit Wiki]: https://github.com/rubymotion/sugarcube/wiki/UIKit
|
214
214
|
|
215
|
+
UI on OS X: AppKit extensions
|
216
|
+
-----
|
217
|
+
|
218
|
+
Similar extensions as the iOS version, but using the `ns` prefix on method names:
|
219
|
+
|
220
|
+
* Conversions: `'string-to'.nsimage`, `image.nsimageview`, `'string-to'.nslabel(font)`
|
221
|
+
* Helpers: `view << subview`
|
222
|
+
* Symbols: `:white.nscolor`, `:system.nsfont`
|
223
|
+
* Frame accessors: `a_view.x`, `a_view.x = 100` (on `UIView`, `CALayer`, `NSWindow`, and `NSScreen`)
|
224
|
+
|
225
|
+
UI on Android
|
226
|
+
-----
|
227
|
+
|
228
|
+
*(warning: extending built-in classes is not reliable in RubyMotion on Android)*
|
229
|
+
|
230
|
+
ViewGroup gets the same `<<` method that you see in UIView and NSView.
|
231
|
+
|
232
|
+
|
215
233
|
Constants
|
216
234
|
-----
|
217
235
|
|
@@ -1256,7 +1274,7 @@ issues with missing constants).
|
|
1256
1274
|
```
|
1257
1275
|
|
1258
1276
|
And you can easily turn an attributed string into a label, if you include the
|
1259
|
-
`sugarcube-
|
1277
|
+
`sugarcube-ui` package.
|
1260
1278
|
|
1261
1279
|
```ruby
|
1262
1280
|
view << (("We just met\n".attrd +
|
@@ -9,3 +9,47 @@ end
|
|
9
9
|
class NSScreen
|
10
10
|
include SugarCube::Frameable
|
11
11
|
end
|
12
|
+
|
13
|
+
class NSWindow
|
14
|
+
|
15
|
+
def x
|
16
|
+
self.frame.origin.x
|
17
|
+
end
|
18
|
+
|
19
|
+
def setX(newX)
|
20
|
+
new_frame = self.frame
|
21
|
+
new_frame.origin.x = newX
|
22
|
+
self.setFrame(new_frame, display: false)
|
23
|
+
end
|
24
|
+
|
25
|
+
def y
|
26
|
+
self.frame.origin.y
|
27
|
+
end
|
28
|
+
|
29
|
+
def setY(newY)
|
30
|
+
new_frame = self.frame
|
31
|
+
new_frame.origin.y = newY
|
32
|
+
self.setFrame(new_frame, display: false)
|
33
|
+
end
|
34
|
+
|
35
|
+
def height
|
36
|
+
self.frame.size.height
|
37
|
+
end
|
38
|
+
|
39
|
+
def setHeight(newHeight)
|
40
|
+
new_frame = self.frame
|
41
|
+
new_frame.size.height = newHeight
|
42
|
+
self.setFrame(new_frame, display: false)
|
43
|
+
end
|
44
|
+
|
45
|
+
def width
|
46
|
+
self.frame.size.width
|
47
|
+
end
|
48
|
+
|
49
|
+
def setWidth(newWidth)
|
50
|
+
new_frame = self.frame
|
51
|
+
new_frame.size.width = newWidth
|
52
|
+
self.setFrame(new_frame, display: false)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/lib/sugarcube-classic.rb
CHANGED
@@ -5,8 +5,6 @@ exclude = [
|
|
5
5
|
'sugarcube-common.rb',
|
6
6
|
'sugarcube-classic.rb',
|
7
7
|
'sugarcube-legacy.rb',
|
8
|
-
'sugarcube-uicolor.rb',
|
9
|
-
'sugarcube-uiimage.rb',
|
10
8
|
'sugarcube-spritekit.rb',
|
11
9
|
|
12
10
|
'sugarcube-568.rb',
|
@@ -17,16 +15,16 @@ exclude = [
|
|
17
15
|
'sugarcube-pipes.rb',
|
18
16
|
'sugarcube-repl.rb',
|
19
17
|
'sugarcube-unholy.rb',
|
18
|
+
'sugarcube-appkit.rb',
|
19
|
+
'sugarcube-uikit.rb',
|
20
20
|
]
|
21
21
|
|
22
22
|
if SugarCube.ios?
|
23
23
|
exclude += [
|
24
|
-
'sugarcube-appkit.rb',
|
25
24
|
]
|
26
25
|
elsif SugarCube.osx?
|
27
26
|
exclude += [
|
28
27
|
'sugarcube-modal.rb',
|
29
|
-
'sugarcube-uikit.rb',
|
30
28
|
]
|
31
29
|
end
|
32
30
|
|
data/lib/sugarcube-common.rb
CHANGED
@@ -5,25 +5,23 @@ exclude = [
|
|
5
5
|
'sugarcube-common.rb',
|
6
6
|
'sugarcube-classic.rb',
|
7
7
|
'sugarcube-legacy.rb',
|
8
|
-
'sugarcube-uicolor.rb',
|
9
|
-
'sugarcube-uiimage.rb',
|
10
8
|
|
11
9
|
'sugarcube-anonymous.rb',
|
12
10
|
'sugarcube-awesome.rb',
|
13
11
|
'sugarcube-pipes.rb',
|
14
12
|
'sugarcube-unholy.rb',
|
13
|
+
'sugarcube-appkit.rb',
|
14
|
+
'sugarcube-uikit.rb',
|
15
15
|
]
|
16
16
|
|
17
17
|
if SugarCube.ios?
|
18
18
|
exclude += [
|
19
|
-
'sugarcube-appkit.rb',
|
20
19
|
]
|
21
20
|
elsif SugarCube.osx?
|
22
21
|
exclude += [
|
23
22
|
'sugarcube-568.rb',
|
24
23
|
'sugarcube-gestures.rb',
|
25
24
|
'sugarcube-modal.rb',
|
26
|
-
'sugarcube-uikit.rb',
|
27
25
|
]
|
28
26
|
end
|
29
27
|
|
data/lib/version.rb
CHANGED
@@ -0,0 +1,178 @@
|
|
1
|
+
describe SugarCube::Frameable do
|
2
|
+
|
3
|
+
describe NSView do
|
4
|
+
|
5
|
+
it 'should return x' do
|
6
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
7
|
+
view.x.should == view.frame.origin.x
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should set x' do
|
11
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
12
|
+
view.x = 500
|
13
|
+
view.x.should == 500
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return y' do
|
17
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
18
|
+
view.y.should == view.frame.origin.y
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should set y' do
|
22
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
23
|
+
view.y = 500
|
24
|
+
view.y.should == 500
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return width' do
|
28
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
29
|
+
view.width.should == view.frame.size.width
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should set width' do
|
33
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
34
|
+
view.width = 500
|
35
|
+
view.width.should == 500
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should return height' do
|
39
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
40
|
+
view.height.should == view.frame.size.height
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should set height' do
|
44
|
+
view = NSView.alloc.initWithFrame([[100, 200], [300, 400]])
|
45
|
+
view.height = 500
|
46
|
+
view.height.should == 500
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe CALayer do
|
52
|
+
|
53
|
+
it 'should return x' do
|
54
|
+
layer = CALayer.layer
|
55
|
+
layer.frame = [[100, 200], [300, 400]]
|
56
|
+
layer.x.should == layer.frame.origin.x
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should set x' do
|
60
|
+
layer = CALayer.layer
|
61
|
+
layer.frame = [[100, 200], [300, 400]]
|
62
|
+
layer.x = 500
|
63
|
+
layer.x.should == 500
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should return y' do
|
67
|
+
layer = CALayer.layer
|
68
|
+
layer.frame = [[100, 200], [300, 400]]
|
69
|
+
layer.y.should == layer.frame.origin.y
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should set y' do
|
73
|
+
layer = CALayer.layer
|
74
|
+
layer.frame = [[100, 200], [300, 400]]
|
75
|
+
layer.y = 500
|
76
|
+
layer.y.should == 500
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should return width' do
|
80
|
+
layer = CALayer.layer
|
81
|
+
layer.frame = [[100, 200], [300, 400]]
|
82
|
+
layer.width.should == layer.frame.size.width
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should set width' do
|
86
|
+
layer = CALayer.layer
|
87
|
+
layer.frame = [[100, 200], [300, 400]]
|
88
|
+
layer.width = 500
|
89
|
+
layer.width.should == 500
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should return height' do
|
93
|
+
layer = CALayer.layer
|
94
|
+
layer.frame = [[100, 200], [300, 400]]
|
95
|
+
layer.height.should == layer.frame.size.height
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should set height' do
|
99
|
+
layer = CALayer.layer
|
100
|
+
layer.frame = [[100, 200], [300, 400]]
|
101
|
+
layer.height = 500
|
102
|
+
layer.height.should == 500
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe NSWindow do
|
108
|
+
|
109
|
+
before do
|
110
|
+
@window = NSWindow.alloc.initWithContentRect([[240, 180], [480, 360]],
|
111
|
+
styleMask: NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
|
112
|
+
backing: NSBackingStoreBuffered,
|
113
|
+
defer: false)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should return x' do
|
117
|
+
@window.x.should == @window.frame.origin.x
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should set x' do
|
121
|
+
@window.x = 500
|
122
|
+
@window.x.should == 500
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should return y' do
|
126
|
+
@window.y.should == @window.frame.origin.y
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should set y' do
|
130
|
+
@window.y = 500
|
131
|
+
@window.y.should == 500
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should return width' do
|
135
|
+
@window.width.should == @window.frame.size.width
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should set width' do
|
139
|
+
@window.width = 500
|
140
|
+
@window.width.should == 500
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should return height' do
|
144
|
+
@window.height.should == @window.frame.size.height
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should set height' do
|
148
|
+
@window.height = 500
|
149
|
+
@window.height.should == 500
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
describe NSScreen do
|
155
|
+
|
156
|
+
it 'should return x' do
|
157
|
+
view = NSScreen.alloc.initWithFrame([[100, 200], [300, 400]])
|
158
|
+
view.x.should == view.frame.origin.x
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should return y' do
|
162
|
+
view = NSScreen.alloc.initWithFrame([[100, 200], [300, 400]])
|
163
|
+
view.y.should == view.frame.origin.y
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'should return width' do
|
167
|
+
view = NSScreen.alloc.initWithFrame([[100, 200], [300, 400]])
|
168
|
+
view.width.should == view.frame.size.width
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should return height' do
|
172
|
+
view = NSScreen.alloc.initWithFrame([[100, 200], [300, 400]])
|
173
|
+
view.height.should == view.frame.size.height
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin T.A. Gray
|
@@ -285,6 +285,7 @@ files:
|
|
285
285
|
- spec/osx/color_components_spec.rb
|
286
286
|
- spec/osx/color_other_representations_spec.rb
|
287
287
|
- spec/osx/color_spec.rb
|
288
|
+
- spec/osx/frameable_spec.rb
|
288
289
|
- spec/osx/nsattributedstring_spec.rb
|
289
290
|
- spec/osx/nsview_spec.rb
|
290
291
|
- spec/osx/symbol_constants_spec.rb
|
@@ -383,6 +384,7 @@ test_files:
|
|
383
384
|
- spec/osx/color_components_spec.rb
|
384
385
|
- spec/osx/color_other_representations_spec.rb
|
385
386
|
- spec/osx/color_spec.rb
|
387
|
+
- spec/osx/frameable_spec.rb
|
386
388
|
- spec/osx/nsattributedstring_spec.rb
|
387
389
|
- spec/osx/nsview_spec.rb
|
388
390
|
- spec/osx/symbol_constants_spec.rb
|