ruby_motion_query 0.5.8 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,61 +22,22 @@ module RubyMotionQuery
22
22
  def view
23
23
  @view
24
24
  end
25
+ alias :get :view
25
26
 
26
27
  def view_has_been_styled?
27
28
  !@view.rmq_data.style_name.nil?
28
29
  end
29
30
 
30
- def superview
31
- @view.superview || rmq(@view).root_view || rmq.window
32
- end
33
- alias :parent :superview
34
-
35
- def super_height
36
- @view.superview.frame.size.height
37
- end
38
-
39
- def super_width
40
- @view.superview.frame.size.width
41
- end
42
-
43
- def tag(tags)
44
- rmq(@view).tag(tags)
45
- end
46
-
47
31
  def frame=(value)
48
- if value == :full # Thanks teacup for the name
49
- @view.frame = self.superview.bounds
50
- elsif value.is_a?(Hash)
51
- f = @view.frame
52
- h = value
53
-
54
- f.origin.x = h[:l] || h[:left] || f.origin.x
55
- f.origin.y = h[:t] || h[:top] || f.origin.y
56
- f.size.width = h[:w] || h[:width] || f.size.width
57
- f.size.height = h[:h] || h[:height] || f.size.height
58
-
59
- if sv = @view.superview
60
- if fr = (h[:from_right] || h[:fr])
61
- f.origin.x = sv.bounds.size.width - f.size.width - fr
62
- end
63
-
64
- if fb = (h[:from_bottom] || h[:fb])
65
- f.origin.y = sv.bounds.size.height - f.size.height - fb
66
- end
67
- end
68
-
69
- @view.frame = f
70
- else
71
- @view.frame = value
72
- end
32
+ RubyMotionQuery::Rect.update_view_frame(view, value)
73
33
  end
74
34
  def frame
75
- @view.frame
35
+ RubyMotionQuery::Rect.frame_for_view(@view)
76
36
  end
77
37
 
78
38
  # Sets the frame using the Window's coordinates
79
39
  def absolute_frame=(value)
40
+ # TODO change to new rect system
80
41
  self.frame = value
81
42
 
82
43
  f = @view.frame
@@ -86,6 +47,41 @@ module RubyMotionQuery
86
47
  @view.frame = f
87
48
  end
88
49
 
50
+ def prev_frame
51
+ if pv = RubyMotionQuery::Rect.previous_view
52
+ RubyMotionQuery::Rect.frame_for_view(pv)
53
+ end
54
+ end
55
+
56
+ def prev_view
57
+ RubyMotionQuery::Rect.previous_view
58
+ end
59
+
60
+ def bounds=(value)
61
+ RubyMotionQuery::Rect.update_view_bounds(view, value)
62
+ end
63
+ def bounds
64
+ RubyMotionQuery::Rect.bounds_for_view(@view)
65
+ end
66
+
67
+ def superview
68
+ @view.superview || rmq(@view).root_view || rmq.window
69
+ end
70
+ alias :parent :superview
71
+
72
+ def super_height
73
+ @view.superview.frame.size.height
74
+ end
75
+
76
+ def super_width
77
+ @view.superview.frame.size.width
78
+ end
79
+
80
+ def tag(tags)
81
+ rmq.wrap(@view).tag(tags)
82
+ end
83
+
84
+ # @deprecated - use frame or bounds
89
85
  def padded=(value)
90
86
  if value.is_a?(Hash)
91
87
  h = value
@@ -107,74 +103,102 @@ module RubyMotionQuery
107
103
  end
108
104
  end
109
105
 
106
+ # @deprecated - use frame or bounds
110
107
  def left=(value)
111
108
  f = @view.frame
112
109
  f.origin.x = value
113
110
  @view.frame = f
114
111
  end
112
+
113
+ # @deprecated - use frame or bounds
115
114
  def left
116
115
  @view.origin.x
117
116
  end
117
+
118
+ # @deprecated - use frame or bounds
118
119
  alias :x :left
119
120
 
121
+ # @deprecated - use frame or bounds
120
122
  def top=(value)
121
123
  f = @view.frame
122
124
  f.origin.y = value
123
125
  @view.frame = f
124
126
  end
127
+
128
+ # @deprecated - use frame or bounds
125
129
  def top
126
130
  @view.origin.y
127
131
  end
132
+
133
+ # @deprecated - use frame or bounds
128
134
  alias :y :top
129
135
 
136
+ # @deprecated - use frame or bounds
130
137
  def width=(value)
131
138
  f = @view.frame
132
139
  f.size.width = value
133
140
  @view.frame = f
134
141
  end
142
+
143
+ # @deprecated - use frame or bounds
135
144
  def width
136
145
  @view.size.width
137
146
  end
138
147
 
148
+ # @deprecated - use frame or bounds
139
149
  def height=(value)
140
150
  f = @view.frame
141
151
  f.size.height = value
142
152
  @view.frame = f
143
153
  end
154
+
155
+ # @deprecated - use frame or bounds
144
156
  def height
145
157
  @view.size.height
146
158
  end
147
159
 
160
+ # @deprecated - use frame or bounds
148
161
  def bottom=(value)
149
162
  self.top = value - self.height
150
163
  end
164
+
165
+ # @deprecated - use frame or bounds
151
166
  def bottom
152
167
  self.top + self.height
153
168
  end
154
169
 
170
+ # @deprecated - use frame or bounds
155
171
  def from_bottom=(value)
156
172
  if sv = @view.superview
157
173
  self.top = sv.bounds.size.height - self.height - value
158
174
  end
159
175
  end
176
+
177
+ # @deprecated - use frame or bounds
160
178
  def from_bottom
161
179
  if sv = @view.superview
162
180
  sv.bounds.size.height - self.top
163
181
  end
164
182
  end
165
183
 
184
+ # @deprecated - use frame or bounds
166
185
  def right=(value)
167
186
  self.left = value - self.width
168
187
  end
188
+
189
+ # @deprecated - use frame or bounds
169
190
  def right
170
191
  self.left + self.width
171
192
  end
172
193
 
194
+ # @deprecated - use frame or bounds
173
195
  def from_right=(value)
174
196
  if superview = @view.superview
175
197
  self.left = superview.bounds.size.width - self.width - value
176
198
  end
177
199
  end
200
+
201
+ # @deprecated - use frame or bounds
178
202
  def from_right
179
203
  if superview = @view.superview
180
204
  superview.bounds.size.width - self.left
@@ -206,6 +230,7 @@ module RubyMotionQuery
206
230
  @view.center.y
207
231
  end
208
232
 
233
+ # @deprecated - use frame or bounds
209
234
  # param can be :horizontal, :vertical, :both
210
235
  def centered=(option)
211
236
  if parent = @view.superview
@@ -346,6 +371,9 @@ module RubyMotionQuery
346
371
  @view.layer.masksToBounds
347
372
  end
348
373
 
374
+ def accessibility_label=(value)
375
+ @view.accessibilityLabel = value
376
+ end
349
377
  end
350
378
  end
351
379
  end
@@ -129,6 +129,13 @@ module RubyMotionQuery
129
129
  attr_accessor :application_was_setup
130
130
  end
131
131
 
132
+ def grid
133
+ @grid || RMQ.app.grid
134
+ end
135
+ def grid=(value)
136
+ @grid = value
137
+ end
138
+
132
139
  # Convenience methods -------------------
133
140
  def rmq(*working_selectors)
134
141
  q = if @controller.nil?
@@ -174,10 +181,12 @@ module RubyMotionQuery
174
181
  RMQ.app.window
175
182
  end
176
183
 
184
+ # TODO, cache, then clear when orientation changes
177
185
  def app_width
178
186
  portrait? ? app_size.width : app_size.height
179
187
  end
180
188
 
189
+ # TODO, cache, then clear when orientation changes
181
190
  def app_height
182
191
  portrait? ? app_size.height : app_size.width
183
192
  end
@@ -186,10 +195,12 @@ module RubyMotionQuery
186
195
  device.screen.applicationFrame.size
187
196
  end
188
197
 
198
+ # TODO, cache, then clear when orientation changes
189
199
  def screen_width
190
200
  portrait? ? screen_size.width : screen_size.height
191
201
  end
192
202
 
203
+ # TODO, cache, then clear when orientation changes
193
204
  def screen_height
194
205
  portrait? ? screen_size.height : screen_size.width
195
206
  end
@@ -180,6 +180,8 @@ module RubyMotionQuery
180
180
  if (klass == UIButton) || klass < UIButton
181
181
  klass.buttonWithType(UIButtonTypeCustom).tap do |o|
182
182
  o.hidden = false
183
+ #o.setTitleColor(rmq.color.black, forState: UIControlStateNormal)
184
+ #o.setTitle('Ok', forState: UIControlStateNormal)
183
185
  o.opaque = true
184
186
  end
185
187
  elsif reuse_identifier = opts[:reuse_identifier]
@@ -28,6 +28,20 @@ module RubyMotionQuery
28
28
  self
29
29
  end
30
30
 
31
+ # Check if any of the selected has a given tag
32
+ # @example
33
+ # rmq(my_view).has_tag?(:your_tag) #false
34
+ # rmq(my_view).tag(:your_tag)
35
+ # rmq(my_view).has_tag?(:your_tag) #true
36
+ #
37
+ # @return [Boolean] true if any selection views have tag provided
38
+ def has_tag? tag
39
+ selected.each do |view|
40
+ return true if view.rmq_data.has_tag?(tag)
41
+ end
42
+ false # tag doesn't exist if we got here
43
+ end
44
+
31
45
  # See /motion/data.rb for the rest of the tag stuff
32
46
 
33
47
  end
@@ -3,11 +3,7 @@ module RubyMotionQuery
3
3
  class << self
4
4
  # @return [Boolean]
5
5
  def is_class?(o)
6
- # This line fails in spec, causes exit without message. It works fine in production
7
- #(o.class == Class) && (defined?(o) == 'constant')
8
-
9
- # So I'm doing this instead
10
- !!(o.respond_to?(:name) && o.name.to_s[0] =~ /[A-Z]/)
6
+ o.class == Class
11
7
  end
12
8
 
13
9
  # This is purposely not blank? as to not conflict with many libraries that
@@ -84,6 +80,13 @@ module RubyMotionQuery
84
80
  a == b
85
81
  end
86
82
 
83
+ # Gives you the value of a weakref, if the object it wraps no longer exists, returns nil
84
+ def weak_ref_value(o)
85
+ if o && o.weakref_alive?
86
+ o
87
+ end
88
+ end
89
+
87
90
  # Mainly used for console and logging
88
91
  #
89
92
  # @return [String]
@@ -1,5 +1,5 @@
1
1
  module RubyMotionQuery
2
- VERSION = "0.5.8"
2
+ VERSION = "0.6.0"
3
3
 
4
4
  class RMQ
5
5
  def version
@@ -8,11 +8,12 @@ class <%= @name_camel_case %> < UIView
8
8
  # q.append(UILabel, :some_label)
9
9
  # -or-
10
10
  # @submit_button = q.append(UIButon, :submit).get
11
+ # -or-
12
+ # @submit_button = q.append! UIButon, :submit
11
13
  end
12
14
 
13
15
  end
14
16
 
15
-
16
17
  # To style this view include its stylesheet at the top of each controller's
17
18
  # stylesheet that is going to use it:
18
19
  # class SomeStylesheet < ApplicationStylesheet
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.5.8
4
+ version: 0.6.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-05-23 00:00:00.000000000 Z
12
+ date: 2014-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
@@ -40,7 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  description: RubyMotionQuery - RMQ - A fast, non-magical, non-polluting, jQuery-like
43
- library for RubyMotion
43
+ front-end library for RubyMotion
44
44
  email: todd@infinitered.com
45
45
  executables:
46
46
  - rmq
@@ -66,8 +66,12 @@ files:
66
66
  - motion/ruby_motion_query/factory.rb
67
67
  - motion/ruby_motion_query/font.rb
68
68
  - motion/ruby_motion_query/format.rb
69
+ - motion/ruby_motion_query/grid.rb
69
70
  - motion/ruby_motion_query/image.rb
71
+ - motion/ruby_motion_query/inspector.rb
72
+ - motion/ruby_motion_query/inspector_stylesheet.rb
70
73
  - motion/ruby_motion_query/position.rb
74
+ - motion/ruby_motion_query/rect.rb
71
75
  - motion/ruby_motion_query/selectors.rb
72
76
  - motion/ruby_motion_query/stylers/protocols/ui_text_input_traits.rb
73
77
  - motion/ruby_motion_query/stylers/ui_button_styler.rb
@@ -119,7 +123,7 @@ files:
119
123
  - templates/view/app/stylesheets/name_stylesheet.rb
120
124
  - templates/view/app/views/name.rb
121
125
  - templates/view/spec/views/name.rb
122
- homepage: http://infinitered.com/rmq
126
+ homepage: http://rubymotionquery.com
123
127
  licenses:
124
128
  - MIT
125
129
  metadata: {}