Class: HotCocoa::LayoutOptions
Constant Summary collapse
- VALID_EXPANSIONS =
[nil, :height, :width, [:height, :width], [:width, :height]]
Instance Attribute Summary collapse
-
#defaults_view ⇒ Object
Returns the value of attribute defaults_view.
- #view ⇒ NSView readonly
Instance Method Summary collapse
- #align ⇒ Object
- #align=(value) ⇒ Object
- #bottom_padding ⇒ Object
- #bottom_padding=(value) ⇒ Object
- #expand ⇒ Object
- #expand=(value) ⇒ Object
- #expand_height? ⇒ Boolean
- #expand_width? ⇒ Boolean
-
#initialize(view, options = {}) ⇒ LayoutOptions
constructor
A new instance of LayoutOptions.
- #inspect ⇒ Object
- #left_padding ⇒ Object
- #left_padding=(value) ⇒ Object
- #padding ⇒ Object
- #padding=(value) ⇒ Object
- #right_padding ⇒ Object
- #right_padding=(value) ⇒ Object
- #start=(value) ⇒ Object
- #start? ⇒ Boolean
- #top_padding ⇒ Object
- #top_padding=(value) ⇒ Object
- #update_layout_views! ⇒ Object
Constructor Details
#initialize(view, options = {}) ⇒ LayoutOptions
Returns a new instance of LayoutOptions.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hotcocoa/layout_view.rb', line 50 def initialize view, = {} @view = view @start = [:start] @expand = [:expand] @padding = [:padding] @left_padding = @padding || [:left_padding] @right_padding = @padding || [:right_padding] @top_padding = @padding || [:top_padding] @bottom_padding = @padding || [:bottom_padding] @align = [:align] @defaults_view = [:defaults_view] end |
Instance Attribute Details
#defaults_view ⇒ Object
Returns the value of attribute defaults_view.
5 6 7 |
# File 'lib/hotcocoa/layout_view.rb', line 5 def defaults_view @defaults_view end |
#view ⇒ NSView (readonly)
8 9 10 |
# File 'lib/hotcocoa/layout_view.rb', line 8 def view @view end |
Instance Method Details
#align ⇒ Object
170 171 172 173 174 175 176 177 |
# File 'lib/hotcocoa/layout_view.rb', line 170 def align return @align unless @align.nil? if in_layout_view? @view.superview.default_layout.align else :left end end |
#align=(value) ⇒ Object
179 180 181 182 183 |
# File 'lib/hotcocoa/layout_view.rb', line 179 def align= value return if value == @align @align = value update_layout_views! end |
#bottom_padding ⇒ Object
161 162 163 164 165 166 167 168 |
# File 'lib/hotcocoa/layout_view.rb', line 161 def bottom_padding return @bottom_padding unless @bottom_padding.nil? if in_layout_view? @view.superview.default_layout.bottom_padding else padding end end |
#bottom_padding=(value) ⇒ Object
154 155 156 157 158 159 |
# File 'lib/hotcocoa/layout_view.rb', line 154 def bottom_padding= value return if value == @bottom_padding @bottom_padding = value @padding = nil update_layout_views! end |
#expand ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/hotcocoa/layout_view.rb', line 87 def return @expand unless @expand.nil? if in_layout_view? @view.superview.default_layout. else false end end |
#expand=(value) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/hotcocoa/layout_view.rb', line 78 def value return if value == @expand unless VALID_EXPANSIONS.include?(value) raise ArgumentError, "Expand must be nil, :height, :width or [:width, :height] not #{value.inspect}" end @expand = value update_layout_views! end |
#expand_height? ⇒ Boolean
101 102 103 104 |
# File 'lib/hotcocoa/layout_view.rb', line 101 def e = self. e == :height || (e.respond_to?(:include?) && e.include?(:height)) end |
#expand_width? ⇒ Boolean
96 97 98 99 |
# File 'lib/hotcocoa/layout_view.rb', line 96 def e = self. e == :width || (e.respond_to?(:include?) && e.include?(:width)) end |
#inspect ⇒ Object
196 197 198 199 200 201 202 203 |
# File 'lib/hotcocoa/layout_view.rb', line 196 def inspect "#<#{self.class} " + "start=#{start?}, " + "expand=#{.inspect}, " + "padding=[l:#{left_padding}, r:#{right_padding}, t:#{top_padding}, b:#{bottom_padding}], " + "align=#{align.inspect}, " + "view=#{view.inspect}>" end |
#left_padding ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/hotcocoa/layout_view.rb', line 113 def left_padding return @left_padding unless @left_padding.nil? if in_layout_view? @view.superview.default_layout.left_padding else padding end end |
#left_padding=(value) ⇒ Object
106 107 108 109 110 111 |
# File 'lib/hotcocoa/layout_view.rb', line 106 def left_padding= value return if value == @left_padding @left_padding = value @padding = nil update_layout_views! end |
#padding ⇒ Object
192 193 194 |
# File 'lib/hotcocoa/layout_view.rb', line 192 def padding @padding || 0.0 end |
#padding=(value) ⇒ Object
185 186 187 188 189 190 |
# File 'lib/hotcocoa/layout_view.rb', line 185 def padding= value return if value == @padding @right_padding = @left_padding = @top_padding = @bottom_padding = value @padding = value update_layout_views! end |
#right_padding ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/hotcocoa/layout_view.rb', line 129 def right_padding return @right_padding unless @right_padding.nil? if in_layout_view? @view.superview.default_layout.right_padding else padding end end |
#right_padding=(value) ⇒ Object
122 123 124 125 126 127 |
# File 'lib/hotcocoa/layout_view.rb', line 122 def right_padding= value return if value == @right_padding @right_padding = value @padding = nil update_layout_views! end |
#start=(value) ⇒ Object
63 64 65 66 67 |
# File 'lib/hotcocoa/layout_view.rb', line 63 def start= value return if value == @start @start = value update_layout_views! end |
#start? ⇒ Boolean
69 70 71 72 73 74 75 76 |
# File 'lib/hotcocoa/layout_view.rb', line 69 def start? return @start unless @start.nil? if in_layout_view? @view.superview.default_layout.start? else true end end |
#top_padding ⇒ Object
145 146 147 148 149 150 151 152 |
# File 'lib/hotcocoa/layout_view.rb', line 145 def top_padding return @top_padding unless @top_padding.nil? if in_layout_view? @view.superview.default_layout.top_padding else padding end end |
#top_padding=(value) ⇒ Object
138 139 140 141 142 143 |
# File 'lib/hotcocoa/layout_view.rb', line 138 def top_padding= value return if value == @top_padding @top_padding = value @padding = nil update_layout_views! end |
#update_layout_views! ⇒ Object
205 206 207 208 |
# File 'lib/hotcocoa/layout_view.rb', line 205 def update_layout_views! @view.superview.relayout! if in_layout_view? @defaults_view.relayout! if @defaults_view end |