class WhirledPeas::Graphics::ContainerCoords

Attributes

dimensions[R]
settings[R]
start_left[R]
start_top[R]

Public Class Methods

new(dimensions, settings, start_left, start_top) click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 4
def initialize(dimensions, settings, start_left, start_top)
  @dimensions = dimensions
  @settings = settings
  @start_left = start_left
  @start_top = start_top
end

Public Instance Methods

border_left() click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 19
def border_left
  left + settings.margin.left
end
border_top() click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 23
def border_top
  top + settings.margin.top
end
content_left(col_index=0) click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 35
def content_left(col_index=0)
  padding_left + settings.padding.left + col_index * dimensions.grid_width
end
content_top(row_index=0) click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 50
def content_top(row_index=0)
  padding_top + settings.padding.top + row_index * dimensions.grid_height
end
left() click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 11
def left
  start_left
end
offset_content_left(col_index=0) click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 39
def offset_content_left(col_index=0)
  if settings.content_start.left
    content_left(col_index) + settings.content_start.left
  elsif settings.content_start.right
    left_offset = dimensions.content_width - dimensions.children_width
    content_left(col_index) + left_offset - settings.content_start.right
  else
    content_left(col_index)
  end
end
offset_content_top(row_index=0) click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 54
def offset_content_top(row_index=0)
  if settings.content_start.top
    content_top(row_index) + settings.content_start.top
  elsif settings.content_start.bottom
    top_offset = dimensions.content_height - dimensions.children_height
    content_top(row_index) + top_offset - settings.content_start.bottom
  else
    content_top(row_index)
  end
end
padding_left() click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 27
def padding_left
  border_left + (settings.border.left? ? 1 : 0)
end
padding_top() click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 31
def padding_top
  border_top + (settings.border.top? ? 1 : 0)
end
top() click to toggle source
# File lib/whirled_peas/graphics/container_coords.rb, line 15
def top
  start_top
end