Module: UnderOs::UI::Style::Positioning
- Included in:
- UnderOs::UI::Style
- Defined in:
- lib/under_os/ui/style/positioning.rb
Instance Method Summary collapse
- #bottom ⇒ Object
- #bottom=(bottom) ⇒ Object
- #contentHeight ⇒ Object
- #contentHeight=(value) ⇒ Object
- #contentWidth ⇒ Object
- #contentWidth=(value) ⇒ Object
- #height ⇒ Object
- #height=(height) ⇒ Object
- #left ⇒ Object
- #left=(left) ⇒ Object
- #overflow ⇒ Object
- #overflow=(value) ⇒ Object
- #overflowX ⇒ Object
- #overflowX=(value) ⇒ Object
- #overflowY ⇒ Object
- #overflowY=(value) ⇒ Object
- #right ⇒ Object
- #right=(right) ⇒ Object
- #top ⇒ Object
- #top=(top) ⇒ Object
- #width ⇒ Object
- #width=(width) ⇒ Object
- #zIndex ⇒ Object
- #zIndex=(number) ⇒ Object
Instance Method Details
#bottom ⇒ Object
47 48 49 |
# File 'lib/under_os/ui/style/positioning.rb', line 47 def bottom parent_size.y - top end |
#bottom=(bottom) ⇒ Object
51 52 53 |
# File 'lib/under_os/ui/style/positioning.rb', line 51 def bottom=(bottom) @view.frame = [[left, parent_size[:y] - convert_size(bottom, :y) - height], [width, height]] end |
#contentHeight ⇒ Object
73 74 75 |
# File 'lib/under_os/ui/style/positioning.rb', line 73 def contentHeight @view.contentSize.height rescue 0 end |
#contentHeight=(value) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/under_os/ui/style/positioning.rb', line 77 def contentHeight=(value) return unless @view.is_a?(UIScrollView) if value == 'auto' value = 0 @view.subviews.each do |view| y = view.origin.y + view.size.height value = y if y > value end end @view.contentSize = CGSizeMake(contentWidth, value) end |
#contentWidth ⇒ Object
55 56 57 |
# File 'lib/under_os/ui/style/positioning.rb', line 55 def contentWidth @view.contentSize.width rescue 0 end |
#contentWidth=(value) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/under_os/ui/style/positioning.rb', line 59 def contentWidth=(value) return unless @view.is_a?(UIScrollView) if value == 'auto' value = 0 @view.subviews.each do |view| x = view.origin.x + view.size.width value = x if x > value end end @view.contentSize = CGSizeMake(value, contentHeight) end |
#height ⇒ Object
15 16 17 |
# File 'lib/under_os/ui/style/positioning.rb', line 15 def height @view.frame.size.height end |
#height=(height) ⇒ Object
19 20 21 |
# File 'lib/under_os/ui/style/positioning.rb', line 19 def height=(height) @view.frame = [[left, top], [width, convert_size(height, :y)]] end |
#left ⇒ Object
31 32 33 |
# File 'lib/under_os/ui/style/positioning.rb', line 31 def left @view.frame.origin.x end |
#left=(left) ⇒ Object
35 36 37 |
# File 'lib/under_os/ui/style/positioning.rb', line 35 def left=(left) @view.frame = [[convert_size(left, :x), top], [width, height]] end |
#overflow ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/under_os/ui/style/positioning.rb', line 99 def overflow case "#{overflowX}-#{overflowY}" when 'visible-visible' then :visible when 'hidden-hidden' then :hidden when 'visible-hidden' then :x when 'hidden-visible' then :y else [overflowX, overflowY] end end |
#overflow=(value) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/under_os/ui/style/positioning.rb', line 109 def overflow=(value) x, y = case value.to_s when 'x' then ['visible', 'hidden'] when 'y' then ['hidden', 'visible'] when 'hidden' then ['hidden', 'hidden'] else ['visible', 'visible'] end self.overflowX = x self.overflowY = y end |
#overflowX ⇒ Object
121 122 123 |
# File 'lib/under_os/ui/style/positioning.rb', line 121 def overflowX @view.isScrollEnabled && @view.showsHorizontalScrollIndicator ? :visible : :hidden end |
#overflowX=(value) ⇒ Object
125 126 127 128 129 130 |
# File 'lib/under_os/ui/style/positioning.rb', line 125 def overflowX=(value) return unless @view.is_a?(UIScrollView) @view.showsHorizontalScrollIndicator = value.to_s == 'visible' @view.directionalLockEnabled = overflowY == :hidden @view.scrollEnabled = overflowX != :hidden || overflowY != :hidden end |
#overflowY ⇒ Object
132 133 134 |
# File 'lib/under_os/ui/style/positioning.rb', line 132 def overflowY @view.isScrollEnabled && @view.showsVerticalScrollIndicator ? :visible : :hidden end |
#overflowY=(value) ⇒ Object
136 137 138 139 140 141 |
# File 'lib/under_os/ui/style/positioning.rb', line 136 def overflowY=(value) return unless @view.is_a?(UIScrollView) @view.showsVerticalScrollIndicator = value.to_s == 'visible' @view.directionalLockEnabled = overflowX == :hidden @view.scrollEnabled = overflowX != :hidden || overflowY != :hidden end |
#right ⇒ Object
39 40 41 |
# File 'lib/under_os/ui/style/positioning.rb', line 39 def right parent_size.x - left end |
#right=(right) ⇒ Object
43 44 45 |
# File 'lib/under_os/ui/style/positioning.rb', line 43 def right=(right) @view.frame = [[parent_size[:x] - convert_size(right, :x) - width, top], [width, height]] end |
#top ⇒ Object
23 24 25 |
# File 'lib/under_os/ui/style/positioning.rb', line 23 def top @view.frame.origin.y end |
#top=(top) ⇒ Object
27 28 29 |
# File 'lib/under_os/ui/style/positioning.rb', line 27 def top=(top) @view.frame = [[left, convert_size(top, :y)], [width, height]] end |
#width ⇒ Object
7 8 9 |
# File 'lib/under_os/ui/style/positioning.rb', line 7 def width @view.frame.size.width end |
#width=(width) ⇒ Object
11 12 13 |
# File 'lib/under_os/ui/style/positioning.rb', line 11 def width=(width) @view.frame = [[left, top], [convert_size(width, :x), height]] end |
#zIndex ⇒ Object
91 92 93 |
# File 'lib/under_os/ui/style/positioning.rb', line 91 def zIndex @view.layer.zPosition end |
#zIndex=(number) ⇒ Object
95 96 97 |
# File 'lib/under_os/ui/style/positioning.rb', line 95 def zIndex=(number) @view.layer.zPosition = number end |