Removed deprecations

This commit is contained in:
Todd Werth
2014-12-18 12:29:07 -08:00
parent d2fcf57f61
commit adcc99aa2e
12 changed files with 48 additions and 210 deletions

View File

@@ -13,10 +13,6 @@ class UIView
@_rmq_data ||= RubyMotionQuery::ViewData.new
end
# @deprecated No longer needed, use rmq_build
def rmq_did_create(self_in_rmq)
end
def rmq_created
end

View File

@@ -181,7 +181,7 @@ module RubyMotionQuery
options: UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionBeginFromCurrentState,
animations: ->(cq) {
cq.style do |st|
st.top = @rmq.device.height + st.height
st.frame = {t: @rmq.device.height + st.frame.height}
st.rotation = 180 + rand(50)
end
},

View File

@@ -44,7 +44,6 @@ module RubyMotionQuery
end
end
# @deprecated - use styles
def style_name
styles.first
end

View File

@@ -29,13 +29,13 @@ module RubyMotionQuery
# rmq(my_view).layout("a1:b5").show
# rmq(my_view, my_other_view).layout grid: "b2", w: 100, h: 200
# rmq(my_view, my_other_view).layout g: "b2", w: 100, h: 200
#
#
# @example with padding
# mq(my_view).layout(grid: "b2:d14", padding: 5)
# mq(my_view).layout(grid: "b2:d14", padding: {l: 5, t: 0, r: 5, b:0})
#
# @return [RMQ]
def layout(params)
def layout(params)
selected.each do |view|
RubyMotionQuery::Rect.update_view_frame(view, params)
end
@@ -47,7 +47,7 @@ module RubyMotionQuery
# @return [RMQ]
# TODO move nudge implementation into Rect
def nudge(params)
def nudge(params)
left = params[:left] || params[:l] || 0
right = params[:right] || params[:r] || 0
up = params[:up] || params[:u] || 0
@@ -79,12 +79,12 @@ module RubyMotionQuery
current_end = nil
selected.each_with_index do |view, i|
st = self.styler_for(view)
rect = view.rmq.frame
if type == :vertical
next if st.height == 0
next if rect.height == 0
else
next if st.width == 0
next if rect.width == 0
end
view_margin = if (margins && margins[i])
@@ -93,15 +93,20 @@ module RubyMotionQuery
margin
end
t = rect.top
l = rect.left
if type == :vertical
current_end = (st.top - view_margin) unless current_end
st.top = current_end + view_margin
current_end = st.bottom
current_end = (rect.top - view_margin) unless current_end
t = current_end + view_margin
current_end = rect.bottom
else
current_end = (st.left - view_margin) unless current_end
st.left = current_end + view_margin
current_end = st.right
current_end = (rect.left - view_margin) unless current_end
l = current_end + view_margin
current_end = rect.right
end
view.rmq.layout(l: l, t: t)
end
self
@@ -109,19 +114,20 @@ module RubyMotionQuery
def resize_to_fit_subviews
selected.each do |view|
st = self.styler_for(view)
w = 0
h = 0
view.subviews.each do |subview|
sub_st = self.styler_for(subview)
w = [sub_st.right, w].max
h = [sub_st.bottom, h].max
rect = subview.rmq.frame
w = [rect.right, w].max
h = [rect.bottom, h].max
end
st.width = w if st.width < w
st.height = h if st.height < h
rect = view.rmq.frame
w = rect.width if w == 0
h = rect.height if h == 0
view.rmq.layout(w: w, h: h)
end
self

View File

@@ -140,130 +140,6 @@ module RubyMotionQuery
rmq.wrap(@view).tag(tags)
end
# @deprecated - use frame or bounds
def padded=(value)
if value.is_a?(Hash)
h = value
h[:l] ||= (h[:left] || 0)
h[:t] ||= (h[:top] || 0)
h[:r] ||= (h[:right] || 0)
h[:b] ||= (h[:bottom] || 0)
sbounds = self.superview.bounds
value = [
[h[:l], h[:t]],
[
sbounds.size.width - h[:l] - h[:r],
sbounds.size.height - h[:t] - h[:b]
]]
@view.frame = value
end
end
# @deprecated - use frame or bounds
def left=(value)
f = @view.frame
f.origin.x = value
@view.frame = f
end
# @deprecated - use frame or bounds
def left
@view.origin.x
end
# @deprecated - use frame or bounds
alias :x :left
# @deprecated - use frame or bounds
def top=(value)
f = @view.frame
f.origin.y = value
@view.frame = f
end
# @deprecated - use frame or bounds
def top
@view.origin.y
end
# @deprecated - use frame or bounds
alias :y :top
# @deprecated - use frame or bounds
def width=(value)
f = @view.frame
f.size.width = value
@view.frame = f
end
# @deprecated - use frame or bounds
def width
@view.size.width
end
# @deprecated - use frame or bounds
def height=(value)
f = @view.frame
f.size.height = value
@view.frame = f
end
# @deprecated - use frame or bounds
def height
@view.size.height
end
# @deprecated - use frame or bounds
def bottom=(value)
self.top = value - self.height
end
# @deprecated - use frame or bounds
def bottom
self.top + self.height
end
# @deprecated - use frame or bounds
def from_bottom=(value)
if sv = @view.superview
self.top = sv.bounds.size.height - self.height - value
end
end
# @deprecated - use frame or bounds
def from_bottom
if sv = @view.superview
sv.bounds.size.height - self.top
end
end
# @deprecated - use frame or bounds
def right=(value)
self.left = value - self.width
end
# @deprecated - use frame or bounds
def right
self.left + self.width
end
# @deprecated - use frame or bounds
def from_right=(value)
if superview = @view.superview
self.left = superview.bounds.size.width - self.width - value
end
end
# @deprecated - use frame or bounds
def from_right
if superview = @view.superview
superview.bounds.size.width - self.left
end
end
def center=(value)
@view.center = value
end
@@ -289,22 +165,6 @@ module RubyMotionQuery
@view.center.y
end
# @deprecated - use frame or bounds
# param can be :horizontal, :vertical, :both
def centered=(option)
if parent = @view.superview
case option
when :horizontal
# Not using parent.center.x here for orientation
self.center_x = parent.bounds.size.width / 2
when :vertical
self.center_y = parent.bounds.size.height / 2
else
@view.center = [parent.bounds.size.width / 2, parent.bounds.size.height / 2]
end
end
end
def background_color=(value)
@view.setBackgroundColor value
end

View File

@@ -230,22 +230,13 @@ module RubyMotionQuery
RMQ.app.window
end
# @deprecated - use device_width
def app_width
def device_width
device.width
end
alias :device_width :app_width
# @deprecated - use device_height
def app_height
def device_height
device.height
end
alias :device_width :app_width
# @deprecated - use device_width and device_height in your stylesheets
def app_size
CGSizeMake(device.width, device.height)
end
def screen_width
device.screen_width
@@ -255,11 +246,6 @@ module RubyMotionQuery
device.screen_height
end
# @deprecated - use screen_width and screen_height in your stylesheets
def screen_size
CGSizeMake(screen_width, screen_height)
end
def content_width
content_size.width
end

View File

@@ -57,7 +57,6 @@ module RubyMotionQuery
end
if created
new_view.rmq_did_create(self.wrap(new_view))
new_view.rmq_created
end
new_view.rmq_build if built

View File

@@ -72,14 +72,6 @@ module RubyMotionQuery
o.respond_to?(:weakref_alive?) # This is the only way to do this currently
end
# @deprecated this has been fixed in RubyMotion 2.17, so this method is no longer needed.
def weak_ref_is_same_object?(a, b)
# This was the workaround that isn't needed anymore, for your reference:
#(a.class == b.class) && (a.object_id == b.object_id)
a == b
end
# Gives you the value of a weakref, if the object it wraps no longer exists, returns nil
def weak_ref_value(o)
if o && o.weakref_alive?

View File

@@ -42,12 +42,6 @@ describe 'ext' do
view.rmq.context.should == view
end
it 'DEPRECATED - should call rmq_did_create after appending to view' do
vc = UIViewController.alloc.init
view = vc.rmq.append(ExtTestView).get
view.controller.should == vc
end
it 'should call rmq_did_create after creating a view' do
vc = UIViewController.alloc.init
view = vc.rmq.create(ExtTestView).get

View File

@@ -21,7 +21,7 @@ describe 'factory' do
blank_rmq = rmq.create_blank_rmq
blank_rmq.is_a?(RubyMotionQuery::RMQ).should == true
blank_rmq.length.should == 0
RubyMotionQuery::RMQ.weak_ref_is_same_object?(rmq.context, blank_rmq.context).should == true
rmq.context.should == blank_rmq.context
blank_rmq.selectors.should == rmq.selectors
blank_rmq.to_a.should == []
end

View File

@@ -72,12 +72,26 @@ describe 'position' do
origins.should == [ CGPoint.new(0,0),CGPoint.new(10,0) ]
end
it 'should resize to fit subviews' do
view = @vc.rmq.append(UIView).get
view.rmq.append(UIButton).resize(height: 50, width: 10)
view.size.width.should == 0
it 'should resize to fit subviews by making the view smaller' do
view = @vc.rmq.append(UIView).layout(h: 100, w: 20).get
view.rmq.append(UIButton).layout(h: 50, w: 10)
view.rmq.append(UIButton).layout(h: 5, w: 1)
view.size.width.should == 20
view.rmq.resize_to_fit_subviews
view.size.width.should == 10
view.size.height.should == 50
end
it 'should resize to fit subviews by making the view larger' do
view = @vc.rmq.append(UIView).layout(h: 100, w: 20).get
view.rmq.append(UIButton).layout(h: 50, w: 10)
view.rmq.append(UILabel).layout(h: 500, w: 70)
view.rmq.append(UIView).layout(h: 5, w: 1)
view.size.width.should == 20
view.size.height.should == 100
view.rmq.resize_to_fit_subviews
view.size.width.should == 70
view.size.height.should == 500
end
it 'should nudge a view in various directions' do

View File

@@ -58,26 +58,18 @@ describe 'stylesheet' do
size = @screen.bounds.size
rmq.device.orientation = :portrait
@vc.rmq.stylesheet.app_width.should == size.width
@vc.rmq.stylesheet.app_height.should == size.height
@vc.rmq.stylesheet.screen_width.should == size.width
@vc.rmq.stylesheet.screen_height.should == size.height
rmq.device.orientation = :landscape_left
@vc.rmq.stylesheet.app_width.should == size.width
@vc.rmq.stylesheet.app_height.should == size.height
@vc.rmq.stylesheet.screen_width.should == size.height
@vc.rmq.stylesheet.screen_height.should == size.width
rmq.device.orientation = :landscape_right
@vc.rmq.stylesheet.app_width.should == size.width
@vc.rmq.stylesheet.app_height.should == size.height
@vc.rmq.stylesheet.screen_width.should == size.height
@vc.rmq.stylesheet.screen_height.should == size.width
rmq.device.orientation = nil
@vc.rmq.stylesheet.app_width.should == size.width
@vc.rmq.stylesheet.app_height.should == size.height
@vc.rmq.stylesheet.screen_width.should == size.width
@vc.rmq.stylesheet.screen_height.should == size.height
end
@@ -100,7 +92,7 @@ describe 'stylesheet' do
foo_view = UIView.alloc.initWithFrame(CGRectZero)
rmq3 = rmq1.wrap(foo_view)
rmq3.parent_rmq.should == rmq1
RubyMotionQuery::RMQ.weak_ref_is_same_object?(rmq3.view_controller, rmq1.view_controller).should == true
rmq3.view_controller.should == rmq1.view_controller
rmq3.stylesheet.should == ss1
bar_view = UIView.alloc.initWithFrame(CGRectZero)