mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-04-30 13:42:38 +08:00
Local merge fix
This commit is contained in:
@@ -27,6 +27,13 @@ module RubyMotionQuery
|
|||||||
# /usr/bin/malloc_history 47706 0x937e5c0 | grep "rb_scope__.+?__"
|
# /usr/bin/malloc_history 47706 0x937e5c0 | grep "rb_scope__.+?__"
|
||||||
class Debug
|
class Debug
|
||||||
class << self
|
class << self
|
||||||
|
|
||||||
|
def inspector
|
||||||
|
if rmq(InspectorView).length == 0
|
||||||
|
rmq.append(InspectorView).animations.land_and_sink_and_throb
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Warning, this is very slow
|
# Warning, this is very slow
|
||||||
def log_detailed(label, params = {})
|
def log_detailed(label, params = {})
|
||||||
return unless RMQ.app.development? || RMQ.app.test?
|
return unless RMQ.app.development? || RMQ.app.test?
|
||||||
|
|||||||
27
motion/ruby_motion_query/inspector.rb
Normal file
27
motion/ruby_motion_query/inspector.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
module RubyMotionQuery
|
||||||
|
class InspectorView < UIView
|
||||||
|
|
||||||
|
def rmq_build
|
||||||
|
rmq.style do |st|
|
||||||
|
st.hidden = true
|
||||||
|
st.frame = :full
|
||||||
|
st.background_color = rmq.color.clear
|
||||||
|
st.scale = 3.0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def drawRect(rect)
|
||||||
|
super
|
||||||
|
|
||||||
|
context = UIGraphicsGetCurrentContext()
|
||||||
|
CGContextSetStrokeColorWithColor(context, rmq.color.red.CGColor)
|
||||||
|
|
||||||
|
CGContextSetLineWidth(context, 4.0)
|
||||||
|
|
||||||
|
CGContextMoveToPoint(context, 0,0)
|
||||||
|
CGContextAddLineToPoint(context, 200, 300)
|
||||||
|
CGContextStrokePath(context);
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -7,19 +7,9 @@ module RubyMotionQuery
|
|||||||
# rmq(my_view).resize(h: 10, w: 100)
|
# rmq(my_view).resize(h: 10, w: 100)
|
||||||
#
|
#
|
||||||
# @return [RMQ]
|
# @return [RMQ]
|
||||||
def layout(opts)
|
def layout(params)
|
||||||
# TODO, add centered and from_bottom and from_top, and bottom and top
|
|
||||||
# TODO, add animate option
|
|
||||||
left = opts[:left] || opts[:l] || opts[:x]
|
|
||||||
top = opts[:top] || opts[:t] || opts[:y]
|
|
||||||
width = opts[:width] || opts[:w]
|
|
||||||
height = opts[:height] || opts[:h]
|
|
||||||
|
|
||||||
selected.each do |view|
|
selected.each do |view|
|
||||||
view.frame = [
|
RubyMotionQuery::Rect.update_view_frame(view, params)
|
||||||
[left || view.origin.x, top || view.origin.y],
|
|
||||||
[width || view.size.width, height || view.size.height]
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self
|
self
|
||||||
@@ -28,11 +18,12 @@ module RubyMotionQuery
|
|||||||
alias :resize :layout
|
alias :resize :layout
|
||||||
|
|
||||||
# @return [RMQ]
|
# @return [RMQ]
|
||||||
def nudge(opts)
|
# TODO move nudge implementation into Rect
|
||||||
left = opts[:left] || opts[:l] || 0
|
def nudge(params)
|
||||||
right = opts[:right] || opts[:r] || 0
|
left = params[:left] || params[:l] || 0
|
||||||
up = opts[:up] || opts[:u] || 0
|
right = params[:right] || params[:r] || 0
|
||||||
down = opts[:down] || opts[:d] || 0
|
up = params[:up] || params[:u] || 0
|
||||||
|
down = params[:down] || params[:d] || 0
|
||||||
|
|
||||||
selected.each do |view|
|
selected.each do |view|
|
||||||
f = view.frame
|
f = view.frame
|
||||||
|
|||||||
254
motion/ruby_motion_query/rect.rb
Normal file
254
motion/ruby_motion_query/rect.rb
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
module RubyMotionQuery
|
||||||
|
|
||||||
|
class RMQ
|
||||||
|
def frame
|
||||||
|
if selected.length == 1
|
||||||
|
Rect.frame_for_view(selected.first)
|
||||||
|
else
|
||||||
|
selected.map{|s| Rect.frame_for_view(s)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def bounds
|
||||||
|
if selected.length == 1
|
||||||
|
Rect.bounds_for_view(selected.first)
|
||||||
|
else
|
||||||
|
selected.map{|s| Rect.bounds_for_view(s)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# RMQ Rect
|
||||||
|
#
|
||||||
|
# *******************---*******---*************************** value options
|
||||||
|
# * | | * -------------
|
||||||
|
# * | | * integer
|
||||||
|
# * | | * signed integer
|
||||||
|
# * top | * float
|
||||||
|
# * | | * :prev
|
||||||
|
# * | | *
|
||||||
|
# * --- | * additional size options
|
||||||
|
# * ***************|***** --- * -----------------------
|
||||||
|
# * * view | * | * :full
|
||||||
|
# * * | * | * :half
|
||||||
|
# * * bottom * | * :quarter
|
||||||
|
# * * | * | *
|
||||||
|
# *|--- left ---|* | * | * centered options
|
||||||
|
# * * | * height * ---------
|
||||||
|
# * * | * | * :horizontal
|
||||||
|
# * * | * | * :vertical
|
||||||
|
# *|-------------------- right -+---|* | * :both
|
||||||
|
# * * | * | *
|
||||||
|
# * * | * |--+--from_right----|*
|
||||||
|
# * * --- * | *
|
||||||
|
# * ***************---*** --- *
|
||||||
|
# * | *
|
||||||
|
# * |------ width - + -| *
|
||||||
|
# * | *
|
||||||
|
# * | *
|
||||||
|
# * from_bottom *
|
||||||
|
# * | *
|
||||||
|
# * | *
|
||||||
|
# * --- *
|
||||||
|
# ***********************************************************
|
||||||
|
#
|
||||||
|
class Rect < CGRect
|
||||||
|
|
||||||
|
class << self
|
||||||
|
|
||||||
|
def update_view_frame(view, params)
|
||||||
|
view.frame = view_rect_updated(view, view.frame, params)
|
||||||
|
end
|
||||||
|
def update_view_bounds(view, params)
|
||||||
|
view.bounds = view_rect_updated(view, view.bounds, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def view_rect_updated(view, rect, params)
|
||||||
|
if params == :full # Thanks teacup for the name
|
||||||
|
view.superview.bounds
|
||||||
|
elsif params.is_a?(Hash)
|
||||||
|
|
||||||
|
l = params[:l] || params[:left] || params[:x] || rect.origin.x
|
||||||
|
t = params[:t] || params[:top] || params[:y] || rect.origin.y
|
||||||
|
params_w = params[:w] || params[:width]
|
||||||
|
w = params_w || rect.size.width
|
||||||
|
params_h = params[:h] || params[:height]
|
||||||
|
h = params_h || rect.size.height
|
||||||
|
r = params[:r] || params[:right]
|
||||||
|
b = params[:b] || params[:bottom]
|
||||||
|
|
||||||
|
if sv = view.superview
|
||||||
|
fr = params[:from_right] || params[:fr]
|
||||||
|
fb = params[:from_bottom] || params[:fb]
|
||||||
|
|
||||||
|
if fr
|
||||||
|
if params_w
|
||||||
|
l = sv.bounds.size.width - w - fr
|
||||||
|
else
|
||||||
|
w = sv.bounds.size.width - l - fr
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if fb
|
||||||
|
if params_h
|
||||||
|
t = sv.bounds.size.height - h - fb
|
||||||
|
else
|
||||||
|
h = sv.bounds.size.height - t - fb
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
rect.origin.x = l
|
||||||
|
rect.origin.y = t
|
||||||
|
rect.size.width = w
|
||||||
|
rect.size.height = h
|
||||||
|
rect
|
||||||
|
|
||||||
|
else
|
||||||
|
rect
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def frame_for_view(view)
|
||||||
|
Rect.new(view.frame, view)
|
||||||
|
end
|
||||||
|
|
||||||
|
def bounds_for_view(view)
|
||||||
|
Rect.new(view.bounds, view)
|
||||||
|
end
|
||||||
|
|
||||||
|
end # << self
|
||||||
|
|
||||||
|
|
||||||
|
def initialize(rect, view = nil)
|
||||||
|
@view = view
|
||||||
|
self.origin = rect.origin
|
||||||
|
self.size = rect.size
|
||||||
|
end
|
||||||
|
|
||||||
|
def left
|
||||||
|
origin.x
|
||||||
|
end
|
||||||
|
alias :l :left
|
||||||
|
alias :x :left
|
||||||
|
|
||||||
|
def right
|
||||||
|
left + width
|
||||||
|
end
|
||||||
|
alias :r :right
|
||||||
|
|
||||||
|
def from_right
|
||||||
|
if @view && (sv = @view.superview)
|
||||||
|
sv.size.width - right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def top
|
||||||
|
origin.y
|
||||||
|
end
|
||||||
|
alias :t :top
|
||||||
|
alias :y :top
|
||||||
|
|
||||||
|
def bottom
|
||||||
|
top + height
|
||||||
|
end
|
||||||
|
alias :b :bottom
|
||||||
|
|
||||||
|
def from_bottom
|
||||||
|
if @view && (sv = @view.superview)
|
||||||
|
sv.size.height - bottom
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def width
|
||||||
|
size.width
|
||||||
|
end
|
||||||
|
alias :w :width
|
||||||
|
|
||||||
|
def height
|
||||||
|
size.height
|
||||||
|
end
|
||||||
|
alias :h :height
|
||||||
|
|
||||||
|
def z_order
|
||||||
|
if @view
|
||||||
|
@view.superview.subviews.to_a.index(@view) # is there a better way??
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def z_position
|
||||||
|
if @view
|
||||||
|
@view.layer.zPosition
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def log
|
||||||
|
def i_f_to_s(int_or_float)
|
||||||
|
if int_or_float % 1 == 0
|
||||||
|
int_or_float.to_i.to_s
|
||||||
|
else
|
||||||
|
int_or_float.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
l = i_f_to_s(left).ljust(5)
|
||||||
|
t = i_f_to_s(top).rjust(5)
|
||||||
|
w = i_f_to_s(width).ljust(5)
|
||||||
|
h = i_f_to_s(height).ljust(5)
|
||||||
|
b = i_f_to_s(bottom).rjust(5)
|
||||||
|
r = i_f_to_s(right).ljust(5)
|
||||||
|
fr = i_f_to_s(from_right).ljust(5)
|
||||||
|
fb = i_f_to_s(from_bottom).rjust(5)
|
||||||
|
|
||||||
|
ww = i_f_to_s(rmq.app.window.size.width)
|
||||||
|
wh = i_f_to_s(rmq.app.window.size.height)
|
||||||
|
|
||||||
|
if @view && (sv = @view.superview)
|
||||||
|
sw = i_f_to_s(sv.size.width)
|
||||||
|
sh = i_f_to_s(sv.size.height)
|
||||||
|
end
|
||||||
|
|
||||||
|
out = %(
|
||||||
|
*****************---*******---**************************
|
||||||
|
* | | * window
|
||||||
|
* #{ t} top | * {w: #{ww}, h: #{wh}}
|
||||||
|
* | | *
|
||||||
|
* --- | * superview
|
||||||
|
* ***************|***** --- * {w: #{sw}, h: #{sh}}
|
||||||
|
* * | * | *
|
||||||
|
* * | * | *
|
||||||
|
* * #{ b} bottom * | * view
|
||||||
|
* #{ l} * | * | * {l: #{l.strip}, t: #{t.strip},
|
||||||
|
*|-- left --|* | * | * w: #{w.strip}, h: #{h.strip}}
|
||||||
|
* * | * height #{ h} *
|
||||||
|
* * | * | * z_order: #{z_order}
|
||||||
|
* * #{ r} | * | * z_position: #{z_position}
|
||||||
|
*|------------------ right -+---|* | *
|
||||||
|
* * | * | #{fr} *
|
||||||
|
* * | * |--+--from_right---|*
|
||||||
|
* * --- * | *
|
||||||
|
* ***************---*** --- *
|
||||||
|
* | *
|
||||||
|
* |------ width - + --| *
|
||||||
|
* #{ w} | *
|
||||||
|
* | *
|
||||||
|
* | *
|
||||||
|
* #{fb} from_bottom *
|
||||||
|
* | *
|
||||||
|
* --- *
|
||||||
|
********************************************************
|
||||||
|
)
|
||||||
|
NSLog out
|
||||||
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
format = '#0.#'
|
||||||
|
s = "Rect {l: #{RMQ.format.numeric(left, format)}"
|
||||||
|
s << ", t: #{RMQ.format.numeric(top, format)}"
|
||||||
|
s << ", w: #{RMQ.format.numeric(width, format)}"
|
||||||
|
s << ", h: #{RMQ.format.numeric(height, format)}}"
|
||||||
|
s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -27,6 +27,20 @@ module RubyMotionQuery
|
|||||||
!@view.rmq_data.style_name.nil?
|
!@view.rmq_data.style_name.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def frame=(value)
|
||||||
|
RubyMotionQuery::Rect.update_view_frame(view, value)
|
||||||
|
end
|
||||||
|
def frame
|
||||||
|
RubyMotionQuery::Rect.frame_for_view(@view)
|
||||||
|
end
|
||||||
|
|
||||||
|
def bounds=(value)
|
||||||
|
RubyMotionQuery::Rect.update_view_bounds(view, value)
|
||||||
|
end
|
||||||
|
def bounds
|
||||||
|
RubyMotionQuery::Rect.bounds_for_view(@view)
|
||||||
|
end
|
||||||
|
|
||||||
def superview
|
def superview
|
||||||
@view.superview || rmq(@view).root_view || rmq.window
|
@view.superview || rmq(@view).root_view || rmq.window
|
||||||
end
|
end
|
||||||
@@ -41,40 +55,10 @@ module RubyMotionQuery
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag(tags)
|
def tag(tags)
|
||||||
rmq(@view).tag(tags)
|
rmq.wrap(@view).tag(tags)
|
||||||
end
|
|
||||||
|
|
||||||
def frame=(value)
|
|
||||||
if value == :full # Thanks teacup for the name
|
|
||||||
@view.frame = self.superview.bounds
|
|
||||||
elsif value.is_a?(Hash)
|
|
||||||
f = @view.frame
|
|
||||||
h = value
|
|
||||||
|
|
||||||
f.origin.x = h[:l] || h[:left] || f.origin.x
|
|
||||||
f.origin.y = h[:t] || h[:top] || f.origin.y
|
|
||||||
f.size.width = h[:w] || h[:width] || f.size.width
|
|
||||||
f.size.height = h[:h] || h[:height] || f.size.height
|
|
||||||
|
|
||||||
if sv = @view.superview
|
|
||||||
if fr = (h[:from_right] || h[:fr])
|
|
||||||
f.origin.x = sv.bounds.size.width - f.size.width - fr
|
|
||||||
end
|
|
||||||
|
|
||||||
if fb = (h[:from_bottom] || h[:fb])
|
|
||||||
f.origin.y = sv.bounds.size.height - f.size.height - fb
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@view.frame = f
|
|
||||||
else
|
|
||||||
@view.frame = value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
def frame
|
|
||||||
@view.frame
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def padded=(value)
|
def padded=(value)
|
||||||
if value.is_a?(Hash)
|
if value.is_a?(Hash)
|
||||||
h = value
|
h = value
|
||||||
@@ -96,74 +80,102 @@ module RubyMotionQuery
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def left=(value)
|
def left=(value)
|
||||||
f = @view.frame
|
f = @view.frame
|
||||||
f.origin.x = value
|
f.origin.x = value
|
||||||
@view.frame = f
|
@view.frame = f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def left
|
def left
|
||||||
@view.origin.x
|
@view.origin.x
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
alias :x :left
|
alias :x :left
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def top=(value)
|
def top=(value)
|
||||||
f = @view.frame
|
f = @view.frame
|
||||||
f.origin.y = value
|
f.origin.y = value
|
||||||
@view.frame = f
|
@view.frame = f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def top
|
def top
|
||||||
@view.origin.y
|
@view.origin.y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
alias :y :top
|
alias :y :top
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def width=(value)
|
def width=(value)
|
||||||
f = @view.frame
|
f = @view.frame
|
||||||
f.size.width = value
|
f.size.width = value
|
||||||
@view.frame = f
|
@view.frame = f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def width
|
def width
|
||||||
@view.size.width
|
@view.size.width
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def height=(value)
|
def height=(value)
|
||||||
f = @view.frame
|
f = @view.frame
|
||||||
f.size.height = value
|
f.size.height = value
|
||||||
@view.frame = f
|
@view.frame = f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def height
|
def height
|
||||||
@view.size.height
|
@view.size.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def bottom=(value)
|
def bottom=(value)
|
||||||
self.top = value - self.height
|
self.top = value - self.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def bottom
|
def bottom
|
||||||
self.top + self.height
|
self.top + self.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def from_bottom=(value)
|
def from_bottom=(value)
|
||||||
if sv = @view.superview
|
if sv = @view.superview
|
||||||
self.top = sv.bounds.size.height - self.height - value
|
self.top = sv.bounds.size.height - self.height - value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def from_bottom
|
def from_bottom
|
||||||
if sv = @view.superview
|
if sv = @view.superview
|
||||||
sv.bounds.size.height - self.top
|
sv.bounds.size.height - self.top
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def right=(value)
|
def right=(value)
|
||||||
self.left = value - self.width
|
self.left = value - self.width
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def right
|
def right
|
||||||
self.left + self.width
|
self.left + self.width
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def from_right=(value)
|
def from_right=(value)
|
||||||
if superview = @view.superview
|
if superview = @view.superview
|
||||||
self.left = superview.bounds.size.width - self.width - value
|
self.left = superview.bounds.size.width - self.width - value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated - use frame or bounds
|
||||||
def from_right
|
def from_right
|
||||||
if superview = @view.superview
|
if superview = @view.superview
|
||||||
superview.bounds.size.width - self.left
|
superview.bounds.size.width - self.left
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ describe 'position' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'should move and resize multiple views' do
|
it 'should move and resize multiple views' do
|
||||||
|
|
||||||
view = @vc.rmq.append(UIView).get
|
view = @vc.rmq.append(UIView).get
|
||||||
view2 = @vc.rmq.append(UIView).get
|
view2 = @vc.rmq.append(UIView).get
|
||||||
view3 = @vc.rmq.append(UIView).get
|
view3 = @vc.rmq.append(UIView).get
|
||||||
@@ -91,5 +90,4 @@ describe 'position' do
|
|||||||
|
|
||||||
@vc.rmq(view, view_2).location_in_root_view.should == [CGPoint.new(10, 20),CGPoint.new(20, 40)]
|
@vc.rmq(view, view_2).location_in_root_view.should == [CGPoint.new(10, 20),CGPoint.new(20, 40)]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
102
spec/rect.rb
Normal file
102
spec/rect.rb
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
describe 'rect' do
|
||||||
|
|
||||||
|
describe 'view_rect_updated' do
|
||||||
|
|
||||||
|
def apply_frame(new_frame)
|
||||||
|
RubyMotionQuery::Rect.update_view_frame(@view, new_frame)
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
@vc = UIViewController.alloc.init
|
||||||
|
@view = @vc.rmq.append(UIView).get
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply left or l or x' do
|
||||||
|
apply_frame l: 1
|
||||||
|
@view.frame.origin.x.should == 1
|
||||||
|
apply_frame left: 2
|
||||||
|
@view.frame.origin.x.should == 2
|
||||||
|
apply_frame x: 3
|
||||||
|
@view.frame.origin.x.should == 3
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply top or t or y' do
|
||||||
|
apply_frame t: 1
|
||||||
|
@view.frame.origin.y.should == 1
|
||||||
|
apply_frame top: 2
|
||||||
|
@view.frame.origin.y.should == 2
|
||||||
|
apply_frame y: 3
|
||||||
|
@view.frame.origin.y.should == 3
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply width or w' do
|
||||||
|
apply_frame w: 3
|
||||||
|
@view.frame.size.width.should == 3
|
||||||
|
apply_frame width: 4
|
||||||
|
@view.frame.size.width.should == 4
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply height or h' do
|
||||||
|
apply_frame h: 3
|
||||||
|
@view.frame.size.height.should == 3
|
||||||
|
apply_frame height: 4
|
||||||
|
@view.frame.size.height.should == 4
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply with only size' do
|
||||||
|
apply_frame w: 5, h: 6
|
||||||
|
@view.frame.size.width.should == 5
|
||||||
|
@view.frame.size.height.should == 6
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply with only origin' do
|
||||||
|
apply_frame l: 7, t: 8
|
||||||
|
@view.frame.origin.x.should == 7
|
||||||
|
@view.frame.origin.y.should == 8
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply in any order, size and origin' do
|
||||||
|
apply_frame l: 1, t: 2, w: 3, h: 4
|
||||||
|
@view.frame.origin.x.should == 1
|
||||||
|
@view.frame.origin.y.should == 2
|
||||||
|
@view.frame.size.width.should == 3
|
||||||
|
@view.frame.size.height.should == 4
|
||||||
|
|
||||||
|
apply_frame w: 1, l: 2, h: 3, t: 4
|
||||||
|
@view.frame.origin.x.should == 2
|
||||||
|
@view.frame.origin.y.should == 4
|
||||||
|
@view.frame.size.width.should == 1
|
||||||
|
@view.frame.size.height.should == 3
|
||||||
|
|
||||||
|
apply_frame h: 1, w: 2, t: 3, l: 4
|
||||||
|
@view.frame.origin.x.should == 4
|
||||||
|
@view.frame.origin.y.should == 3
|
||||||
|
@view.frame.size.width.should == 2
|
||||||
|
@view.frame.size.height.should == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should apply from_right and fr' do
|
||||||
|
apply_frame width: 10, from_right: 10
|
||||||
|
@view.frame.origin.x.should == rmq.device.width - 20
|
||||||
|
|
||||||
|
apply_frame w: 20, from_right: 20
|
||||||
|
@view.frame.origin.x.should == rmq.device.width - 40
|
||||||
|
end
|
||||||
|
|
||||||
|
#it 'should apply from_bottom and fb' do
|
||||||
|
#end
|
||||||
|
|
||||||
|
#it 'should change w when fr and l are set' do
|
||||||
|
#end
|
||||||
|
|
||||||
|
#it 'should change h when fb and t are set' do
|
||||||
|
#end
|
||||||
|
|
||||||
|
#it 'should change l when fr and w are set' do
|
||||||
|
#end
|
||||||
|
|
||||||
|
#it 'should change t when fb and w are set' do
|
||||||
|
#end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -31,6 +31,7 @@ class SyleSheetForUIViewStylerTests < RubyMotionQuery::Stylesheet
|
|||||||
st.frame = {left: 1, top: 2, width: 3, height: 4}
|
st.frame = {left: 1, top: 2, width: 3, height: 4}
|
||||||
st.frame = {from_right: 1, from_bottom: 2, width: 3, height: 4}
|
st.frame = {from_right: 1, from_bottom: 2, width: 3, height: 4}
|
||||||
st.frame = {fr: 1, fb: 2, w: 3, h: 4}
|
st.frame = {fr: 1, fb: 2, w: 3, h: 4}
|
||||||
|
st.frame = {l: 1, t: 2, fr: 3, fb: 4}
|
||||||
st.left = 20
|
st.left = 20
|
||||||
st.top = 30
|
st.top = 30
|
||||||
st.width = 40
|
st.width = 40
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ describe 'subviews' do
|
|||||||
@vc.view.subviews.first.should == view
|
@vc.view.subviews.first.should == view
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should insert view to the beginning of a view\'s subviews' do
|
it 'should insert view to the beginning of a views subviews' do
|
||||||
1.should == 1
|
1.should == 1
|
||||||
#TODO
|
#TODO
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user