Class: Motion::GridOverlayView

Inherits:
UIView
  • Object
show all
Defined in:
lib/project/views/grid_overlay_view.rb

Constant Summary collapse

DEFAULTS =
{ stroke_color: UIColor.grayColor,
stroke_width: 1.0,
x_lines: 2,
y_lines: 2 }

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stroke_colorObject

Returns the value of attribute stroke_color.



9
10
11
# File 'lib/project/views/grid_overlay_view.rb', line 9

def stroke_color
  @stroke_color
end

#stroke_widthObject

Returns the value of attribute stroke_width.



9
10
11
# File 'lib/project/views/grid_overlay_view.rb', line 9

def stroke_width
  @stroke_width
end

#x_intervalObject

Returns the value of attribute x_interval.



8
9
10
# File 'lib/project/views/grid_overlay_view.rb', line 8

def x_interval
  @x_interval
end

#x_linesObject

Returns the value of attribute x_lines.



9
10
11
# File 'lib/project/views/grid_overlay_view.rb', line 9

def x_lines
  @x_lines
end

#y_intervalObject

Returns the value of attribute y_interval.



8
9
10
# File 'lib/project/views/grid_overlay_view.rb', line 8

def y_interval
  @y_interval
end

#y_linesObject

Returns the value of attribute y_lines.



9
10
11
# File 'lib/project/views/grid_overlay_view.rb', line 9

def y_lines
  @y_lines
end

Instance Method Details

#drawRect(rect) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/project/views/grid_overlay_view.rb', line 72

def drawRect(rect)
  super

  setup_drawing

  draw_horizontal_lines
  draw_vertical_lines

  fill_path
end

#hideObject



36
37
38
39
40
41
42
43
44
# File 'lib/project/views/grid_overlay_view.rb', line 36

def hide
  unless hidden?
    @original_color = stroke_color

    self.stroke_color = UIColor.clearColor

    setNeedsDisplay
  end
end

#initWithFrame(frame) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/project/views/grid_overlay_view.rb', line 11

def initWithFrame(frame)
  super.tap do |view|
    view.backgroundColor = UIColor.clearColor

    self.x_lines      = DEFAULTS[:x_lines]
    self.y_lines      = DEFAULTS[:y_lines]
    self.stroke_color = DEFAULTS[:stroke_color]
    self.stroke_width = DEFAULTS[:stroke_width]
  end
end

#showObject



30
31
32
33
34
# File 'lib/project/views/grid_overlay_view.rb', line 30

def show
  self.stroke_color = @original_color

  setNeedsDisplay
end

#toggleObject



22
23
24
25
26
27
28
# File 'lib/project/views/grid_overlay_view.rb', line 22

def toggle
  if hidden?
    show
  else
    hide
  end
end