Class: WhirledPeas::Graphics::ContainerDimensions
- Inherits:
-
Object
- Object
- WhirledPeas::Graphics::ContainerDimensions
- Defined in:
- lib/whirled_peas/graphics/container_dimensions.rb
Instance Attribute Summary collapse
-
#children_height ⇒ Object
readonly
Returns the value of attribute children_height.
-
#children_width ⇒ Object
readonly
Returns the value of attribute children_width.
-
#num_cols ⇒ Object
readonly
Returns the value of attribute num_cols.
-
#num_rows ⇒ Object
readonly
Returns the value of attribute num_rows.
Instance Method Summary collapse
- #content_height ⇒ Object
- #content_width ⇒ Object
- #grid_height ⇒ Object
- #grid_width ⇒ Object
-
#initialize(settings, content_width, content_height, num_cols = 1, num_rows = 1) ⇒ ContainerDimensions
constructor
A new instance of ContainerDimensions.
- #inner_border_height ⇒ Object
- #inner_border_width ⇒ Object
- #inner_grid_height ⇒ Object
- #inner_grid_width ⇒ Object
- #margin_height ⇒ Object
- #margin_width ⇒ Object
- #outer_border_height ⇒ Object
- #outer_border_width ⇒ Object
- #outer_height ⇒ Object
- #outer_width ⇒ Object
- #padding_height ⇒ Object
- #padding_width ⇒ Object
- #scrollbar_height ⇒ Object
- #scrollbar_width ⇒ Object
Constructor Details
#initialize(settings, content_width, content_height, num_cols = 1, num_rows = 1) ⇒ ContainerDimensions
Returns a new instance of ContainerDimensions.
6 7 8 9 10 11 12 13 14 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 6 def initialize(settings, content_width, content_height, num_cols=1, num_rows=1) @orig_content_width = content_width @orig_content_height = content_height @children_width = content_width @children_height = content_height @num_cols = num_cols @num_rows = num_rows @settings = settings end |
Instance Attribute Details
#children_height ⇒ Object (readonly)
Returns the value of attribute children_height.
4 5 6 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 4 def children_height @children_height end |
#children_width ⇒ Object (readonly)
Returns the value of attribute children_width.
4 5 6 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 4 def children_width @children_width end |
#num_cols ⇒ Object (readonly)
Returns the value of attribute num_cols.
4 5 6 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 4 def num_cols @num_cols end |
#num_rows ⇒ Object (readonly)
Returns the value of attribute num_rows.
4 5 6 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 4 def num_rows @num_rows end |
Instance Method Details
#content_height ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 25 def content_height return orig_content_height unless settings.height if settings.border_sizing? settings.height - outer_border_height - - padding_height else settings.height end end |
#content_width ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 16 def content_width return orig_content_width unless settings.width if settings.border_sizing? settings.width - outer_border_width - - padding_width else settings.width end end |
#grid_height ⇒ Object
52 53 54 55 56 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 52 def grid_height (settings.border.inner_horiz? ? 1 : 0) + inner_grid_height + (settings..horiz? ? 1 : 0) end |
#grid_width ⇒ Object
40 41 42 43 44 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 40 def grid_width (settings.border.inner_vert? ? 1 : 0) + inner_grid_width + (settings..vert? ? 1 : 0) end |
#inner_border_height ⇒ Object
92 93 94 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 92 def inner_border_height settings.border.inner_horiz? ? 1 : 0 end |
#inner_border_width ⇒ Object
88 89 90 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 88 def inner_border_width settings.border.inner_vert? ? 1 : 0 end |
#inner_grid_height ⇒ Object
46 47 48 49 50 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 46 def inner_grid_height settings.padding.top + content_height + settings.padding.bottom end |
#inner_grid_width ⇒ Object
34 35 36 37 38 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 34 def inner_grid_width settings.padding.left + content_width + settings.padding.right end |
#margin_height ⇒ Object
76 77 78 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 76 def margin_height settings.margin.top + settings.margin.bottom end |
#margin_width ⇒ Object
72 73 74 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 72 def margin_width settings.margin.left + settings.margin.right end |
#outer_border_height ⇒ Object
84 85 86 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 84 def outer_border_height (settings.border.top? ? 1 : 0) + (settings.border.bottom? ? 1 : 0) end |
#outer_border_width ⇒ Object
80 81 82 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 80 def outer_border_width (settings.border.left? ? 1 : 0) + (settings.border.right? ? 1 : 0) end |
#outer_height ⇒ Object
65 66 67 68 69 70 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 65 def outer_height @outer_height ||= margin_height + outer_border_height + num_rows * (padding_height + content_height + ) + (num_rows - 1) * inner_border_height end |
#outer_width ⇒ Object
58 59 60 61 62 63 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 58 def outer_width @outer_width ||= margin_width + outer_border_width + num_cols * (padding_width + content_width + ) + (num_cols - 1) * inner_border_width end |
#padding_height ⇒ Object
100 101 102 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 100 def padding_height settings.padding.top + settings.padding.bottom end |
#padding_width ⇒ Object
96 97 98 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 96 def padding_width settings.padding.left + settings.padding.right end |
#scrollbar_height ⇒ Object
108 109 110 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 108 def settings..horiz? ? 1 : 0 end |
#scrollbar_width ⇒ Object
104 105 106 |
# File 'lib/whirled_peas/graphics/container_dimensions.rb', line 104 def settings..vert? ? 1 : 0 end |