ruby_motion_query 0.8.0 → 0.9.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.
- checksums.yaml +4 -4
- data/bin/rmq +10 -3
- data/motion/ruby_motion_query/animations.rb +7 -7
- data/motion/ruby_motion_query/base.rb +20 -22
- data/motion/ruby_motion_query/data.rb +31 -6
- data/motion/ruby_motion_query/device.rb +0 -4
- data/motion/ruby_motion_query/enumerablish.rb +4 -2
- data/motion/ruby_motion_query/font.rb +2 -3
- data/motion/ruby_motion_query/grid.rb +2 -4
- data/motion/ruby_motion_query/image.rb +8 -4
- data/motion/ruby_motion_query/inspector.rb +22 -23
- data/motion/ruby_motion_query/rect.rb +1 -1
- data/motion/ruby_motion_query/selectors.rb +4 -4
- data/motion/ruby_motion_query/stylers/ui_control_styler.rb +36 -1
- data/motion/ruby_motion_query/stylers/ui_table_view_cell_styler.rb +11 -3
- data/motion/ruby_motion_query/stylers/ui_text_view_styler.rb +18 -0
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +13 -2
- data/motion/ruby_motion_query/stylesheet.rb +47 -6
- data/motion/ruby_motion_query/validation.rb +6 -14
- data/motion/ruby_motion_query/version.rb +1 -1
- data/templates/view/app/views/name.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78e17a1432f6e663df4fbde26aa5b7d065ab3e13
|
4
|
+
data.tar.gz: a8aaddbde4902152465378ed69229d9acab88ccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a919b4152a20dae5566681fef722abc79ac12d04ecb8c1e7bea191b491d61c8daf642647f5d426c4938d0324e85895b92d225e92733530b8772ee7fccacfd96
|
7
|
+
data.tar.gz: 2ca7cf6db4c949637aca82f39316374dc53d4aa45d52debe3cbedf983fc3ed133cbbe71a4f62a3f1520b997c8f0a4d2fe6204105af914d194d162c535332cac4
|
data/bin/rmq
CHANGED
@@ -68,10 +68,17 @@ class RmqCommandLine
|
|
68
68
|
(main)> exit
|
69
69
|
|
70
70
|
Then try these:
|
71
|
+
> rake device_name='iPhone 4s'
|
72
|
+
> rake device_name='iPhone 5s'
|
73
|
+
> rake device_name='iPhone 5s' target=7.1
|
74
|
+
> rake device_name='iPhone 6 Plus'
|
75
|
+
> rake device_name='iPad Retina'
|
76
|
+
> rake device
|
77
|
+
|
78
|
+
Or for XCode 5.1
|
71
79
|
> rake retina=3.5
|
72
|
-
> rake retina=4
|
73
|
-
> rake device_family=ipad
|
74
|
-
> rake device }
|
80
|
+
> rake retina=4
|
81
|
+
> rake device_family=ipad}
|
75
82
|
|
76
83
|
end
|
77
84
|
|
@@ -277,8 +277,8 @@ module RubyMotionQuery
|
|
277
277
|
end
|
278
278
|
|
279
279
|
# @return [RMQ]
|
280
|
-
def start_spinner(style = UIActivityIndicatorViewStyleGray)
|
281
|
-
spinner = Animations.window_spinner(style)
|
280
|
+
def start_spinner(style = UIActivityIndicatorViewStyleGray, opts = {})
|
281
|
+
spinner = Animations.window_spinner({ style: style }.merge(opts))
|
282
282
|
spinner.startAnimating
|
283
283
|
@rmq.create_rmq_in_context(spinner)
|
284
284
|
end
|
@@ -292,14 +292,14 @@ module RubyMotionQuery
|
|
292
292
|
|
293
293
|
protected
|
294
294
|
|
295
|
-
def self.window_spinner(
|
295
|
+
def self.window_spinner(opts={})
|
296
296
|
@_window_spinner ||= begin
|
297
|
-
|
298
|
-
UIActivityIndicatorView.alloc.initWithActivityIndicatorStyle(style).tap do |o|
|
299
|
-
o.center = window.center
|
297
|
+
parent = opts.fetch(:parent, RMQ.app.window)
|
298
|
+
UIActivityIndicatorView.alloc.initWithActivityIndicatorStyle(opts.fetch(:style, UIActivityIndicatorViewStyleGray)).tap do |o|
|
300
299
|
o.hidesWhenStopped = true
|
300
|
+
o.center = opts.fetch(:center, RMQ.app.window.center)
|
301
301
|
o.layer.zPosition = NSIntegerMax
|
302
|
-
|
302
|
+
parent.addSubview(o)
|
303
303
|
end
|
304
304
|
end
|
305
305
|
end
|
@@ -5,7 +5,7 @@ module RubyMotionQuery
|
|
5
5
|
# What's an rmq instance?
|
6
6
|
# - an rmq instance is an array-like object containing UIViews
|
7
7
|
# - rmq() never returns nil. If nothing is selected, it's an empty [ ] array-like
|
8
|
-
# object
|
8
|
+
# object
|
9
9
|
# - an rmq object always (almost always) returns either itself or a new
|
10
10
|
# rmq object. This is how chaining works. You do not need to worry if
|
11
11
|
# an rmq is blank or not, everything always works without throwing a
|
@@ -25,7 +25,7 @@ module RubyMotionQuery
|
|
25
25
|
#
|
26
26
|
# If rmq was called in a view, context will be that view. If it was called
|
27
27
|
# in a UIViewController, it will be that controller. If it is called in another
|
28
|
-
# object, it will be current controller's rmq instance and thus context will be
|
28
|
+
# object, it will be current controller's rmq instance and thus context will be
|
29
29
|
# that controller
|
30
30
|
def context=(value)
|
31
31
|
if value
|
@@ -87,7 +87,7 @@ module RubyMotionQuery
|
|
87
87
|
|
88
88
|
# Wraps 1 or more views in an rmq instance.
|
89
89
|
#
|
90
|
-
# Normally you select a view or views using rmq(my_view). Which doesn't
|
90
|
+
# Normally you select a view or views using rmq(my_view). Which doesn't
|
91
91
|
# work if you have an instance of a RMQ, in which case it isn't a method.
|
92
92
|
# In some cases you want to save an instance of rmq and use it like the rmq
|
93
93
|
# method, for this you'd use #wrap
|
@@ -96,7 +96,7 @@ module RubyMotionQuery
|
|
96
96
|
# q = RubyMotionQuery::RMQ.new
|
97
97
|
#
|
98
98
|
# # Bad
|
99
|
-
# q(my_view).view_controller
|
99
|
+
# q(my_view).view_controller
|
100
100
|
#
|
101
101
|
# # Good
|
102
102
|
# q.wrap(my_view).view_controller
|
@@ -107,7 +107,7 @@ module RubyMotionQuery
|
|
107
107
|
end
|
108
108
|
|
109
109
|
|
110
|
-
# Untested and I don' think it's getting set right in some situations
|
110
|
+
# Untested and I don' think it's getting set right in some situations
|
111
111
|
#
|
112
112
|
# @return [RMQ] rmq that created this rmq, if any
|
113
113
|
def parent_rmq
|
@@ -129,7 +129,7 @@ module RubyMotionQuery
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
# Returns a view or array of views.
|
132
|
+
# Returns a view or array of views.
|
133
133
|
# Normally used to get the only view in selected.
|
134
134
|
#
|
135
135
|
# @example
|
@@ -151,19 +151,19 @@ module RubyMotionQuery
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
# Is this rmq a root instance?
|
154
|
+
# Is this rmq a root instance?
|
155
155
|
#
|
156
156
|
# Which means it only has 1 selected view, and that view
|
157
|
-
# is the view you called rmq in. Which is a tad confusing, but if you call *just* rmq inside a
|
157
|
+
# is the view you called rmq in. Which is a tad confusing, but if you call *just* rmq inside a
|
158
158
|
# view, then only that view will be *selected* and this rmq will be *root*. If you call rmq
|
159
159
|
# inside a controller, only controller.view will be selected and the rma instance will be a root.
|
160
160
|
def root?
|
161
161
|
(selected.length == 1) && (selected.first == @context)
|
162
162
|
end
|
163
163
|
|
164
|
-
# The context is where rmq was created (not the selectors).
|
164
|
+
# The context is where rmq was created (not the selectors).
|
165
165
|
#
|
166
|
-
# Normally you are inside a controller or a UIView when you execute the rmq method.
|
166
|
+
# Normally you are inside a controller or a UIView when you execute the rmq method.
|
167
167
|
#
|
168
168
|
# @return [UIView] the controller's view or the view you are in when calling rmq
|
169
169
|
def context_or_context_view
|
@@ -182,14 +182,14 @@ module RubyMotionQuery
|
|
182
182
|
# (main)> rmq.all
|
183
183
|
# => RMQ 172658240. 26 selected. selectors: []. .log for more info
|
184
184
|
def inspect
|
185
|
-
out = "RMQ #{self.object_id}. #{self.count} selected. selectors: #{self.selectors
|
185
|
+
out = "RMQ #{self.object_id}. #{self.count} selected. selectors: #{self.selectors}. .log for more info"
|
186
186
|
out << "\n[#{selected.first}]" if self.count == 1
|
187
187
|
out
|
188
188
|
end
|
189
189
|
|
190
190
|
# Super useful in the console. log outputs to the console a table of the selected views
|
191
191
|
#
|
192
|
-
# @param :wide outputs wide format (really wide, but awesome: rmq.all.log :wide). :tree outputs the
|
192
|
+
# @param :wide outputs wide format (really wide, but awesome: rmq.all.log :wide). :tree outputs the
|
193
193
|
# log in a tree form
|
194
194
|
#
|
195
195
|
# @return [String]
|
@@ -227,7 +227,7 @@ module RubyMotionQuery
|
|
227
227
|
# rmq.all.log :wide
|
228
228
|
def log(opt = nil)
|
229
229
|
if opt == :tree
|
230
|
-
puts tree_to_s(selected)
|
230
|
+
puts tree_to_s(selected)
|
231
231
|
return
|
232
232
|
end
|
233
233
|
|
@@ -240,7 +240,7 @@ module RubyMotionQuery
|
|
240
240
|
out << line.chop if wide
|
241
241
|
out << line
|
242
242
|
|
243
|
-
selected.each do |view|
|
243
|
+
selected.each do |view|
|
244
244
|
out << " #{view.object_id.to_s.ljust(12)}|"
|
245
245
|
out << " #{view.class.name[0..21].ljust(22)}|"
|
246
246
|
out << " #{(view.rmq_data.style_name || '')[0..23].ljust(24)}|"
|
@@ -266,7 +266,7 @@ module RubyMotionQuery
|
|
266
266
|
out << line unless wide
|
267
267
|
end
|
268
268
|
|
269
|
-
out << "RMQ #{self.object_id}. #{self.count} selected. selectors: #{self.selectors
|
269
|
+
out << "RMQ #{self.object_id}. #{self.count} selected. selectors: #{self.selectors}"
|
270
270
|
|
271
271
|
puts out
|
272
272
|
end
|
@@ -274,9 +274,7 @@ module RubyMotionQuery
|
|
274
274
|
def tree_to_s(selected_views, depth = 0)
|
275
275
|
out = ""
|
276
276
|
|
277
|
-
selected_views.each do |view|
|
278
|
-
first = (view == selected_views.first)
|
279
|
-
last = (view == selected_views.last)
|
277
|
+
selected_views.each do |view|
|
280
278
|
|
281
279
|
if depth == 0
|
282
280
|
out << "\n"
|
@@ -290,7 +288,7 @@ module RubyMotionQuery
|
|
290
288
|
|
291
289
|
out << " #{view.class.name[0..21]}"
|
292
290
|
out << " ( #{view.rmq_data.style_name[0..23]} )" if view.rmq_data.style_name
|
293
|
-
out << " #{view.object_id
|
291
|
+
out << " #{view.object_id}"
|
294
292
|
out << " [ #{view.rmq_data.tag_names.join(',')} ]" if view.rmq_data.tag_names.length > 0
|
295
293
|
|
296
294
|
if view.origin
|
@@ -309,11 +307,11 @@ module RubyMotionQuery
|
|
309
307
|
out
|
310
308
|
end
|
311
309
|
|
312
|
-
protected
|
310
|
+
protected
|
313
311
|
def extract_views_from_selectors(view_container, working_selectors)
|
314
312
|
unless RMQ.is_blank?(working_selectors)
|
315
313
|
working_selectors.delete_if do |selector|
|
316
|
-
if selector.is_a?(UIView)
|
314
|
+
if selector.is_a?(UIView)
|
317
315
|
view_container << selector
|
318
316
|
true
|
319
317
|
end
|
@@ -339,7 +337,7 @@ module RubyMotionQuery
|
|
339
337
|
if (nr = view.nextResponder) && nr.is_a?(UIView)
|
340
338
|
out << nr
|
341
339
|
all_superviews_for(nr, out)
|
342
|
-
end
|
340
|
+
end
|
343
341
|
out
|
344
342
|
end
|
345
343
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
class ViewData
|
3
|
-
attr_accessor :events, :
|
3
|
+
attr_accessor :events, :built
|
4
4
|
|
5
5
|
# @return [Hash] Array of tag names assigned to to this view
|
6
6
|
def tags
|
@@ -12,11 +12,6 @@ module RubyMotionQuery
|
|
12
12
|
tags.keys
|
13
13
|
end
|
14
14
|
|
15
|
-
def validation_errors; @_validation_errors ||= {}; end
|
16
|
-
def validation_errors=(value); @_validation_errors = value; end
|
17
|
-
def validations; @_validations ||= []; end
|
18
|
-
def validations=(value); @_validations = value; end
|
19
|
-
|
20
15
|
# *Do not* use this, use {RMQ#tag} instead:
|
21
16
|
# @example
|
22
17
|
# rmq(my_view).tag(:foo)
|
@@ -49,6 +44,36 @@ module RubyMotionQuery
|
|
49
44
|
end
|
50
45
|
end
|
51
46
|
|
47
|
+
# @deprecated - use styles
|
48
|
+
def style_name
|
49
|
+
styles.first
|
50
|
+
end
|
51
|
+
|
52
|
+
# Sets first style name, this is only here for backwards compatibility and as
|
53
|
+
# a convenience method
|
54
|
+
def style_name=(value)
|
55
|
+
styles[0] = value
|
56
|
+
end
|
57
|
+
|
58
|
+
#view.rmq_data.styles
|
59
|
+
def styles
|
60
|
+
@_styles ||= []
|
61
|
+
end
|
62
|
+
|
63
|
+
#view.rmq_data.has_style?(:style_name_here)
|
64
|
+
def has_style?(name = nil)
|
65
|
+
if name
|
66
|
+
styles.include?(name)
|
67
|
+
else
|
68
|
+
RMQ.is_blank?(@_styles)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def validation_errors; @_validation_errors ||= {}; end
|
73
|
+
def validation_errors=(value); @_validation_errors = value; end
|
74
|
+
def validations; @_validations ||= []; end
|
75
|
+
def validations=(value); @_validations = value; end
|
76
|
+
|
52
77
|
def view_controller=(value)
|
53
78
|
#RubyMotionQuery::RMQ.debug.assert(value.is_a?(UIViewController), 'Invalid controller in ViewData', { controller: value })
|
54
79
|
|
@@ -13,10 +13,6 @@ module RubyMotionQuery
|
|
13
13
|
|
14
14
|
class Device
|
15
15
|
class << self
|
16
|
-
def ios_eight?
|
17
|
-
@_ios_eight ||= screen.respond_to?(:coordinateSpace)
|
18
|
-
end
|
19
|
-
|
20
16
|
# Find out what version of iOS you're using.
|
21
17
|
# `rmq.device.is_version? 8`
|
22
18
|
# `rmq.device.is_version? "7.1"`
|
@@ -16,8 +16,10 @@ module RubyMotionQuery
|
|
16
16
|
# rmq(UILabel)[3]
|
17
17
|
# or
|
18
18
|
# rmq(UILabel)[1..5]
|
19
|
-
|
20
|
-
|
19
|
+
# or
|
20
|
+
# rmq(UILabel)[2,3]
|
21
|
+
def [](*args)
|
22
|
+
RMQ.create_with_array_and_selectors(Array(selected[*args]), @selectors, @context)
|
21
23
|
end
|
22
24
|
alias :eq :[]
|
23
25
|
|
@@ -53,11 +53,10 @@ module RubyMotionQuery
|
|
53
53
|
#
|
54
54
|
# @example
|
55
55
|
# font = rmq.font.font_with_name('Helvetica Neue', 18)
|
56
|
-
def
|
57
|
-
# TODO, should rename this to just with_name, so it's rmq.font.with_name
|
56
|
+
def with_name(name, size)
|
58
57
|
UIFont.fontWithName(name, size: size)
|
59
58
|
end
|
60
|
-
alias :with_name
|
59
|
+
alias :font_with_name :with_name #for backwards compatibility
|
61
60
|
|
62
61
|
# Use this in the console to get a list of font families
|
63
62
|
# @return [Array]
|
@@ -272,7 +272,7 @@ module RubyMotionQuery
|
|
272
272
|
end.freeze
|
273
273
|
end
|
274
274
|
|
275
|
-
#
|
275
|
+
# This typically is not needed anywhere
|
276
276
|
def clear_cache
|
277
277
|
@grid_hash = {}
|
278
278
|
@_usable_width = nil
|
@@ -317,7 +317,7 @@ module RubyMotionQuery
|
|
317
317
|
out << left_m
|
318
318
|
out << r.to_s.rjust(4)
|
319
319
|
|
320
|
-
0.upto(@num_columns - 1).each do
|
320
|
+
0.upto(@num_columns - 1).each do
|
321
321
|
out << " ."
|
322
322
|
end
|
323
323
|
end
|
@@ -417,8 +417,6 @@ module RubyMotionQuery
|
|
417
417
|
return unless @grid
|
418
418
|
|
419
419
|
context = UIGraphicsGetCurrentContext()
|
420
|
-
screen_height = RMQ.device.screen_height
|
421
|
-
screen_width = RMQ.device.screen_width
|
422
420
|
|
423
421
|
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
|
424
422
|
CGContextSelectFont(context, 'Courier New', 7, KCGEncodingMacRoman)
|
@@ -27,7 +27,7 @@ module RubyMotionQuery
|
|
27
27
|
cached = true if cached.nil?
|
28
28
|
|
29
29
|
if cached
|
30
|
-
UIImage.imageNamed("#{file_base_name}.#{ext}")
|
30
|
+
UIImage.imageNamed("#{file_base_name}.#{ext}")
|
31
31
|
else
|
32
32
|
file_base_name << '@2x' if RMQ.device.retina?
|
33
33
|
file = NSBundle.mainBundle.pathForResource(file_base_name, ofType: ext)
|
@@ -42,10 +42,14 @@ module RubyMotionQuery
|
|
42
42
|
#
|
43
43
|
# @return [UIImage]
|
44
44
|
def resource_resizable(file_base_name, opts)
|
45
|
-
# TODO, also alloow short syntax, t: instead of top: etc
|
46
|
-
ext = opts[:ext] || DEFAULT_IMAGE_EXT
|
47
45
|
image = resource(file_base_name, opts)
|
48
|
-
|
46
|
+
|
47
|
+
frame = [ opts[:top] || opts[:t],
|
48
|
+
opts[:left] || opts[:l],
|
49
|
+
opts[:bottom] || opts[:b],
|
50
|
+
opts[:right] || opts[:r]
|
51
|
+
]
|
52
|
+
image.resizableImageWithCapInsets(frame, resizingMode: UIImageResizingModeStretch)
|
49
53
|
end
|
50
54
|
|
51
55
|
# Note: FROM Sugarcube, thanks Sugarcube
|
@@ -5,7 +5,7 @@ module RubyMotionQuery
|
|
5
5
|
if existing.length > 0
|
6
6
|
existing.remove
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
puts 'The currently selected views will be assigned to $q'
|
10
10
|
|
11
11
|
rmq(window).append(InspectorView).get.update(selected)
|
@@ -14,8 +14,8 @@ module RubyMotionQuery
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class InspectorView < UIView
|
17
|
-
# A note about this code. InspectorView will be sitting in the Window, not
|
18
|
-
# the current controller. So when you do this rmq(UIButton), that is on the
|
17
|
+
# A note about this code. InspectorView will be sitting in the Window, not
|
18
|
+
# the current controller. So when you do this rmq(UIButton), that is on the
|
19
19
|
# current controller. rmq(self).find(UIButton) would be the buttons in the
|
20
20
|
# inspector.
|
21
21
|
|
@@ -28,7 +28,7 @@ module RubyMotionQuery
|
|
28
28
|
|
29
29
|
rmq.stylesheet = InspectorStylesheet
|
30
30
|
@self_rmq.apply_style(:inspector_view)
|
31
|
-
|
31
|
+
|
32
32
|
@hud = @self_rmq.append(InspectorHud, :hud).on(:tap) do |sender, rmq_event|
|
33
33
|
select_at rmq_event.location_in(sender)
|
34
34
|
end.get
|
@@ -37,7 +37,7 @@ module RubyMotionQuery
|
|
37
37
|
|
38
38
|
rmq(root_view).animate(
|
39
39
|
animations: ->(q){ q.apply_style :root_view_scaled },
|
40
|
-
after: ->(finished, q) do
|
40
|
+
after: ->(finished, q) do
|
41
41
|
@self_rmq.animations.fade_in
|
42
42
|
dim_nav
|
43
43
|
end
|
@@ -45,12 +45,12 @@ module RubyMotionQuery
|
|
45
45
|
|
46
46
|
@stats = @self_rmq.append! UILabel, :stats
|
47
47
|
|
48
|
-
@self_rmq.append(UIButton, :close_button).on(:touch) do
|
48
|
+
@self_rmq.append(UIButton, :close_button).on(:touch) do
|
49
49
|
rmq(root_view).animate(
|
50
50
|
animations: ->(q){ q.apply_style(:root_view) },
|
51
51
|
after: ->(finished, inner_q){ rmq.stylesheet = @puppets_stylesheet })
|
52
52
|
|
53
|
-
@self_rmq.animations.drop_and_spin(after: ->(finished, inner_q) do
|
53
|
+
@self_rmq.animations.drop_and_spin(after: ->(finished, inner_q) do
|
54
54
|
inner_q.remove
|
55
55
|
end)
|
56
56
|
|
@@ -59,35 +59,35 @@ module RubyMotionQuery
|
|
59
59
|
show_nav_in_all_its_glory
|
60
60
|
end
|
61
61
|
|
62
|
-
@self_rmq.append(UIButton, :grid_button).on(:touch) do
|
62
|
+
@self_rmq.append(UIButton, :grid_button).on(:touch) do
|
63
63
|
@hud.draw_grid = !@hud.draw_grid
|
64
64
|
redisplay
|
65
65
|
end
|
66
66
|
|
67
|
-
@self_rmq.append(UIButton, :grid_x_button).on(:touch) do
|
67
|
+
@self_rmq.append(UIButton, :grid_x_button).on(:touch) do
|
68
68
|
@hud.draw_grid_x = !@hud.draw_grid_x
|
69
69
|
redisplay
|
70
70
|
end
|
71
71
|
|
72
|
-
@self_rmq.append(UIButton, :grid_y_button).on(:touch) do
|
72
|
+
@self_rmq.append(UIButton, :grid_y_button).on(:touch) do
|
73
73
|
@hud.draw_grid_y = !@hud.draw_grid_y
|
74
74
|
redisplay
|
75
75
|
end
|
76
76
|
|
77
|
-
@self_rmq.append(UIButton, :dim_button).on(:touch) do
|
77
|
+
@self_rmq.append(UIButton, :dim_button).on(:touch) do
|
78
78
|
@hud.dimmed = !@hud.dimmed
|
79
79
|
redisplay
|
80
80
|
end
|
81
81
|
|
82
|
-
@self_rmq.append(UIButton, :outline_button).on(:touch) do
|
82
|
+
@self_rmq.append(UIButton, :outline_button).on(:touch) do
|
83
83
|
@hud.views_outlined = !@hud.views_outlined
|
84
84
|
redisplay
|
85
85
|
end
|
86
86
|
|
87
|
-
@self_rmq.find(UIButton).distribute :horizontal, margin: 5
|
87
|
+
@self_rmq.find(UIButton).distribute :horizontal, margin: 5
|
88
88
|
|
89
89
|
@tree_zoomed = false
|
90
|
-
@tree_q = @self_rmq.append(UIScrollView, :tree).on(:tap) do
|
90
|
+
@tree_q = @self_rmq.append(UIScrollView, :tree).on(:tap) do
|
91
91
|
zoom_tree
|
92
92
|
end
|
93
93
|
end
|
@@ -111,7 +111,7 @@ module RubyMotionQuery
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def zoom_tree
|
114
|
-
rmq.animate do
|
114
|
+
rmq.animate do
|
115
115
|
if @tree_zoomed
|
116
116
|
@tree_q.apply_style(:tree)
|
117
117
|
else
|
@@ -140,7 +140,7 @@ module RubyMotionQuery
|
|
140
140
|
|
141
141
|
@hud.selected_views = []
|
142
142
|
root_view = rmq.root_view
|
143
|
-
|
143
|
+
|
144
144
|
if tapped_at
|
145
145
|
@hud.selected.each do |view|
|
146
146
|
rect = view.convertRect(view.bounds, toView: root_view)
|
@@ -209,7 +209,7 @@ module RubyMotionQuery
|
|
209
209
|
st.frame = {l: left, w: w, h: h}
|
210
210
|
|
211
211
|
st.border_color = rmq.color.from_rgba(34,202,250,0.7).CGColor
|
212
|
-
st.border_width = 0.5
|
212
|
+
st.border_width = 0.5
|
213
213
|
st.background_color = rmq.stylesheet.tree_node_background_color
|
214
214
|
|
215
215
|
end.enable_interaction.on(:tap) do |sender|
|
@@ -225,14 +225,14 @@ module RubyMotionQuery
|
|
225
225
|
out = %(
|
226
226
|
style_name: :#{view.rmq_data.style_name || ''}
|
227
227
|
#{rmq(view).frame.inspect}
|
228
|
-
#{view.class.name} - object_id: #{view.object_id
|
228
|
+
#{view.class.name} - object_id: #{view.object_id}
|
229
229
|
).strip
|
230
230
|
rmq(@stats).show.get.text = out
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
234
|
class InspectorHud < UIView
|
235
|
-
attr_accessor :selected, :selected_views, :dimmed, :views_outlined,
|
235
|
+
attr_accessor :selected, :selected_views, :dimmed, :views_outlined,
|
236
236
|
:draw_grid_x, :draw_grid, :draw_grid_y
|
237
237
|
|
238
238
|
def rmq_build
|
@@ -273,7 +273,6 @@ module RubyMotionQuery
|
|
273
273
|
# Fixes upside down issue
|
274
274
|
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0))
|
275
275
|
|
276
|
-
w = rmq.window
|
277
276
|
grid = rmq.stylesheet.grid
|
278
277
|
root_view = rmq.root_view
|
279
278
|
|
@@ -305,7 +304,7 @@ module RubyMotionQuery
|
|
305
304
|
0.upto(grid.num_columns - 1) do |c|
|
306
305
|
rec = grid[[c, r]]
|
307
306
|
CGContextSetFillColorWithColor(context, @column_fill_color)
|
308
|
-
CGContextFillRect(context, rec.to_cgrect)
|
307
|
+
CGContextFillRect(context, rec.to_cgrect)
|
309
308
|
text = "#{(c+97).chr}#{r}"
|
310
309
|
CGContextSetFillColorWithColor(context, @light_text_color)
|
311
310
|
CGContextShowTextAtPoint(context, rec.origin.x + 1, rec.origin.y + 5, text, text.length)
|
@@ -319,7 +318,7 @@ module RubyMotionQuery
|
|
319
318
|
rec = view.frame
|
320
319
|
rec.origin = rmq(view).location_in(root_view)
|
321
320
|
#rec.origin = view.origin
|
322
|
-
|
321
|
+
|
323
322
|
if @selected_views.include?(view)
|
324
323
|
CGContextSetFillColorWithColor(context, @view_selected_background_color.CGColor)
|
325
324
|
CGContextSetStrokeColorWithColor(context, @selected_outline_color)
|
@@ -327,7 +326,7 @@ module RubyMotionQuery
|
|
327
326
|
CGContextSetFillColorWithColor(context, @view_background_color)
|
328
327
|
CGContextSetStrokeColorWithColor(context, @outline_color)
|
329
328
|
end
|
330
|
-
|
329
|
+
|
331
330
|
if @dimmed
|
332
331
|
CGContextFillRect(context, rec)
|
333
332
|
end
|
@@ -11,12 +11,12 @@ module RubyMotionQuery
|
|
11
11
|
# @return [Array] The selectors, which is what you used for the query
|
12
12
|
# @example
|
13
13
|
# (main)> rmq(UILabel, UIImageView).selectors
|
14
|
-
# => [UILabel, UIImageView]
|
14
|
+
# => [UILabel, UIImageView]
|
15
15
|
def selectors
|
16
16
|
@_selectors
|
17
17
|
end
|
18
18
|
|
19
|
-
protected
|
19
|
+
protected
|
20
20
|
|
21
21
|
def match_context(new_selectors)
|
22
22
|
match(context_or_context_view, new_selectors)
|
@@ -30,7 +30,7 @@ module RubyMotionQuery
|
|
30
30
|
return true if match_hash(view, selector)
|
31
31
|
elsif selector.is_a?(Symbol)
|
32
32
|
# TODO, make this faster
|
33
|
-
return true if (view.rmq_data.
|
33
|
+
return true if (view.rmq_data.has_style?(selector)) || view.rmq_data.has_tag?(selector)
|
34
34
|
elsif selector.is_a?(Integer)
|
35
35
|
# TODO, make this hugely faster
|
36
36
|
return true if view.object_id == selector
|
@@ -48,7 +48,7 @@ module RubyMotionQuery
|
|
48
48
|
private
|
49
49
|
|
50
50
|
def match_hash(view, hash)
|
51
|
-
# TODO, check speed, and do sub hashes for stuff like origin
|
51
|
+
# TODO, check speed, and do sub hashes for stuff like origin
|
52
52
|
# it's probably pretty slow
|
53
53
|
hash.each do |k,v|
|
54
54
|
return true if view.respond_to?(k) && (view.send(k) == v)
|
@@ -1,7 +1,42 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
module Stylers
|
3
3
|
|
4
|
-
class UIControlStyler < UIViewStyler
|
4
|
+
class UIControlStyler < UIViewStyler
|
5
|
+
def content_vertical_alignment=(value)
|
6
|
+
@view.contentVerticalAlignment = value
|
7
|
+
end
|
8
|
+
|
9
|
+
def content_vertical_alignment
|
10
|
+
@view.contentVerticalAlignment
|
11
|
+
end
|
12
|
+
|
13
|
+
def content_horizontal_alignment=(value)
|
14
|
+
@view.contentHorizontalAlignment = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def content_horizontal_alignment
|
18
|
+
@view.contentHorizontalAlignment
|
19
|
+
end
|
20
|
+
|
21
|
+
def selected=(value)
|
22
|
+
@view.selected = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def selected
|
26
|
+
@view.isSelected
|
27
|
+
end
|
28
|
+
|
29
|
+
def highlighted=(value)
|
30
|
+
@view.highlighted = value
|
31
|
+
end
|
32
|
+
|
33
|
+
def highlighted
|
34
|
+
@view.isHighlighted
|
35
|
+
end
|
36
|
+
|
37
|
+
def state
|
38
|
+
@view.state
|
39
|
+
end
|
5
40
|
end
|
6
41
|
|
7
42
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module RubyMotionQuery
|
2
2
|
module Stylers
|
3
3
|
|
4
|
-
class UITableViewCellStyler < UIViewStyler
|
5
|
-
|
4
|
+
class UITableViewCellStyler < UIViewStyler
|
5
|
+
|
6
6
|
def accessory_type=(value)
|
7
7
|
@view.accessoryType = value
|
8
8
|
end
|
@@ -11,7 +11,15 @@ module RubyMotionQuery
|
|
11
11
|
@view.accessoryType
|
12
12
|
end
|
13
13
|
|
14
|
+
def accessory_view=(value)
|
15
|
+
@view.accessoryView = value
|
16
|
+
end
|
17
|
+
|
18
|
+
def accessory_view
|
19
|
+
@view.accessoryView
|
20
|
+
end
|
21
|
+
|
14
22
|
end
|
15
23
|
|
16
24
|
end
|
17
|
-
end
|
25
|
+
end
|
@@ -8,6 +8,15 @@ module RubyMotionQuery
|
|
8
8
|
def attributed_text ; view.attributedText ; end
|
9
9
|
def attributed_text=(v) ; view.attributedText = v ; end
|
10
10
|
|
11
|
+
def editable ; view.isEditable ; end
|
12
|
+
def editable=(v) ; view.editable = !!v ; end
|
13
|
+
|
14
|
+
def selectable ; view.isSelectable ; end
|
15
|
+
def selectable=(v) ; view.selectable = !!v ; end
|
16
|
+
|
17
|
+
def data_detector_types ; view.dataDetectorTypes ; end
|
18
|
+
def data_detector_types=(v) ; view.dataDetectorTypes = (DETECTOR_TYPES[v] || v) ; end
|
19
|
+
|
11
20
|
def font ; view.font ; end
|
12
21
|
def font=(v) ; view.font = v ; end
|
13
22
|
|
@@ -16,6 +25,15 @@ module RubyMotionQuery
|
|
16
25
|
alias :color :text_color
|
17
26
|
alias :color= :text_color=
|
18
27
|
|
28
|
+
DETECTOR_TYPES = {
|
29
|
+
phone: UIDataDetectorTypePhoneNumber,
|
30
|
+
link: UIDataDetectorTypeLink,
|
31
|
+
addresss: UIDataDetectorTypeAddress,
|
32
|
+
event: UIDataDetectorTypeCalendarEvent,
|
33
|
+
none: UIDataDetectorTypeNone,
|
34
|
+
all: UIDataDetectorTypeAll
|
35
|
+
}
|
36
|
+
|
19
37
|
end
|
20
38
|
end
|
21
39
|
end
|
@@ -297,7 +297,7 @@ module RubyMotionQuery
|
|
297
297
|
@view.setEnabled value
|
298
298
|
end
|
299
299
|
def enabled
|
300
|
-
@view.
|
300
|
+
@view.isEnabled
|
301
301
|
end
|
302
302
|
|
303
303
|
def scale=(amount)
|
@@ -354,12 +354,13 @@ module RubyMotionQuery
|
|
354
354
|
def border_width=(value)
|
355
355
|
@view.layer.borderWidth = value
|
356
356
|
end
|
357
|
+
|
357
358
|
def border_width
|
358
359
|
@view.layer.borderWidth
|
359
360
|
end
|
360
361
|
|
361
362
|
def border_color=(value)
|
362
|
-
if value
|
363
|
+
if is_color(value)
|
363
364
|
@view.layer.setBorderColor(value.CGColor)
|
364
365
|
else
|
365
366
|
@view.layer.setBorderColor value
|
@@ -370,6 +371,11 @@ module RubyMotionQuery
|
|
370
371
|
@view.layer.borderColor
|
371
372
|
end
|
372
373
|
|
374
|
+
def border=(options)
|
375
|
+
self.border_width = options.fetch(:width)
|
376
|
+
self.border_color = options.fetch(:color)
|
377
|
+
end
|
378
|
+
|
373
379
|
def corner_radius=(value = 2)
|
374
380
|
@view.clipsToBounds = true
|
375
381
|
@view.layer.cornerRadius = value
|
@@ -399,6 +405,11 @@ module RubyMotionQuery
|
|
399
405
|
def alpha ; view.alpha ; end
|
400
406
|
def alpha=(v) ; view.alpha = v ; end
|
401
407
|
|
408
|
+
private
|
409
|
+
|
410
|
+
def is_color(value)
|
411
|
+
[UICachedDeviceRGBColor, UIDeviceRGBColor].include?(value.class)
|
412
|
+
end
|
402
413
|
end
|
403
414
|
end
|
404
415
|
end
|
@@ -25,26 +25,67 @@ module RubyMotionQuery
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
# @example
|
29
|
+
# rmq(view).apply_style(:style_name_here)
|
30
|
+
# rmq(view).apply_style(:style_name_here, :another_style, :yet_another_style)
|
31
|
+
# rmq(view).apply_styles(:style_name_here, :another_style, :yet_another_style) # Alias
|
32
|
+
#
|
28
33
|
# @return [RMQ]
|
29
|
-
def apply_style(
|
30
|
-
|
31
|
-
|
34
|
+
def apply_style(*style_names)
|
35
|
+
if style_names
|
36
|
+
selected.each do |selected_view|
|
37
|
+
style_names.each do |style_name|
|
38
|
+
apply_style_to_view selected_view, style_name
|
39
|
+
end
|
40
|
+
end
|
32
41
|
end
|
33
42
|
self
|
34
43
|
end
|
44
|
+
alias :apply_styles :apply_style
|
35
45
|
|
46
|
+
# Pass a block to apply styles, an inline way of applynig a style
|
47
|
+
# @example
|
48
|
+
# rmq(view).style{|st| st.background_color = rmq.color.blue}
|
36
49
|
# @return [RMQ]
|
37
|
-
def style
|
50
|
+
def style
|
38
51
|
selected.each do |view|
|
39
52
|
yield(styler_for(view))
|
40
53
|
end
|
41
54
|
self
|
42
55
|
end
|
43
56
|
|
57
|
+
# @example
|
58
|
+
# rmq(view).styles
|
59
|
+
#
|
60
|
+
# @return style_names as an array
|
61
|
+
def styles
|
62
|
+
out = selected.map do |view|
|
63
|
+
view.rmq_data.styles
|
64
|
+
end
|
65
|
+
out.flatten!.uniq!
|
66
|
+
out
|
67
|
+
end
|
68
|
+
|
69
|
+
# @example
|
70
|
+
# foo = rmq(view).has_style?(:style_name_here)
|
71
|
+
#
|
72
|
+
# @return true if all selected views has the style
|
73
|
+
def has_style?(style_name)
|
74
|
+
selected.each do |view|
|
75
|
+
return false unless view.rmq_data.has_style?(style_name)
|
76
|
+
end
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
# Reapplies all styles in order. User rmq(view).styles to see the styles applied to a view(s)
|
81
|
+
# @example
|
82
|
+
# rmq.all.reapply_styles
|
83
|
+
# rmq(viewa, viewb, viewc).reapply_styles
|
84
|
+
#
|
44
85
|
# @return [RMQ]
|
45
86
|
def reapply_styles
|
46
87
|
selected.each do |selected_view|
|
47
|
-
|
88
|
+
selected_view.rmq_data.styles.each do |style_name|
|
48
89
|
apply_style_to_view selected_view, style_name
|
49
90
|
end
|
50
91
|
end
|
@@ -99,7 +140,7 @@ module RubyMotionQuery
|
|
99
140
|
def apply_style_to_view(view, style_name)
|
100
141
|
begin
|
101
142
|
stylesheet.public_send(style_name, styler_for(view))
|
102
|
-
view.rmq_data.style_name
|
143
|
+
view.rmq_data.styles << style_name unless view.rmq_data.has_style?(style_name)
|
103
144
|
view.rmq_style_applied
|
104
145
|
rescue NoMethodError => e
|
105
146
|
if e.message =~ /.*#{style_name.to_s}.*/
|
@@ -60,7 +60,7 @@ module RubyMotionQuery
|
|
60
60
|
selected.each do |view|
|
61
61
|
view.rmq_data.validations.each do |validation|
|
62
62
|
unless validation.valid_status
|
63
|
-
default_error = "Validation Error - input requires valid #{validation.rule_name
|
63
|
+
default_error = "Validation Error - input requires valid #{validation.rule_name}."
|
64
64
|
rule_message = view.rmq_data.validation_errors[validation.rule_name] || default_error
|
65
65
|
errors.push(rule_message)
|
66
66
|
end
|
@@ -71,24 +71,16 @@ module RubyMotionQuery
|
|
71
71
|
|
72
72
|
# @return [Array] of views where validations have failed
|
73
73
|
def invalid
|
74
|
-
|
75
|
-
|
76
|
-
view.rmq_data.validations.each do |validation|
|
77
|
-
invalid.push(view) unless validation.valid_status
|
78
|
-
end
|
74
|
+
selected.reject do |view|
|
75
|
+
view.rmq_data.validations.map{ |validation| validation.valid_status }.reduce(:&)
|
79
76
|
end
|
80
|
-
return invalid
|
81
77
|
end
|
82
78
|
|
83
|
-
# @return [Array] of views where validations have failed
|
79
|
+
# @return [Array] of views where validations have not failed
|
84
80
|
def valid
|
85
|
-
|
86
|
-
|
87
|
-
view.rmq_data.validations.each do |validation|
|
88
|
-
invalid.push(view) if validation.valid_status
|
89
|
-
end
|
81
|
+
selected.select do |view|
|
82
|
+
view.rmq_data.validations.map{ |validation| validation.valid_status }.reduce(:&)
|
90
83
|
end
|
91
|
-
return invalid
|
92
84
|
end
|
93
85
|
|
94
86
|
end # End RMQ
|
@@ -7,9 +7,9 @@ class <%= @name_camel_case %> < UIView
|
|
7
7
|
# Add subviews here, like so:
|
8
8
|
# q.append(UILabel, :some_label)
|
9
9
|
# -or-
|
10
|
-
# @submit_button = q.append(
|
10
|
+
# @submit_button = q.append(UIButton, :submit).get
|
11
11
|
# -or-
|
12
|
-
# @submit_button = q.append!
|
12
|
+
# @submit_button = q.append! UIButton, :submit
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_motion_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Werth
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.4.4
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: RubyMotionQuery - RMQ
|