Class: WhirledPeas::Graphics::ContainerCoords

Inherits:
Object
  • Object
show all
Defined in:
lib/whirled_peas/graphics/container_coords.rb

Instance Method Summary collapse

Constructor Details

#initialize(dimensions, settings, start_left, start_top) ⇒ ContainerCoords

Returns a new instance of ContainerCoords.



4
5
6
7
8
9
# 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

Instance Method Details

#border_leftObject



19
20
21
# File 'lib/whirled_peas/graphics/container_coords.rb', line 19

def border_left
  left + settings.margin.left
end

#border_topObject



23
24
25
# File 'lib/whirled_peas/graphics/container_coords.rb', line 23

def border_top
  top + settings.margin.top
end

#content_left(col_index = 0) ⇒ Object



35
36
37
# 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) ⇒ Object



50
51
52
# 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

#leftObject



11
12
13
# File 'lib/whirled_peas/graphics/container_coords.rb', line 11

def left
  start_left
end

#offset_content_left(col_index = 0) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# 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) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# 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_leftObject



27
28
29
# File 'lib/whirled_peas/graphics/container_coords.rb', line 27

def padding_left
  border_left + (settings.border.left? ? 1 : 0)
end

#padding_topObject



31
32
33
# File 'lib/whirled_peas/graphics/container_coords.rb', line 31

def padding_top
  border_top + (settings.border.top? ? 1 : 0)
end

#topObject



15
16
17
# File 'lib/whirled_peas/graphics/container_coords.rb', line 15

def top
  start_top
end