Module: PurplishFrame::View

Included in:
CALayer, CocoaTouchView, CocoaView
Defined in:
lib/purplish-frame/ui/view.rb

Instance Method Summary collapse

Instance Method Details

#center_xObject



23
24
25
# File 'lib/purplish-frame/ui/view.rb', line 23

def center_x
  center.x
end

#center_x=(center_x) ⇒ Object



27
28
29
# File 'lib/purplish-frame/ui/view.rb', line 27

def center_x=(center_x)
  self.center = [center_x, center.y]
end

#center_yObject



31
32
33
# File 'lib/purplish-frame/ui/view.rb', line 31

def center_y
  center.y
end

#center_y=(center_y) ⇒ Object



35
36
37
# File 'lib/purplish-frame/ui/view.rb', line 35

def center_y=(center_y)
  self.center = [center.x, center_y]
end

#heightObject



49
50
51
# File 'lib/purplish-frame/ui/view.rb', line 49

def height
  view_frame.size.height
end

#inset!(dx, dy) ⇒ Object



99
100
101
# File 'lib/purplish-frame/ui/view.rb', line 99

def inset!(dx, dy)
  self.frame = frame.inset(dx, dy)
end

#leftObject



3
4
5
# File 'lib/purplish-frame/ui/view.rb', line 3

def left
  view_frame.origin.x
end

#left=(x) ⇒ Object



7
8
9
10
11
# File 'lib/purplish-frame/ui/view.rb', line 7

def left=(x)
  f = frame
  f.origin.x = x
  self.frame = f
end

#rightObject



13
14
15
# File 'lib/purplish-frame/ui/view.rb', line 13

def right
  view_frame.origin.x + view_frame.size.width
end

#right=(right) ⇒ Object



17
18
19
20
21
# File 'lib/purplish-frame/ui/view.rb', line 17

def right=(right)
  f = frame
  f.origin.x = right - f.size.width
  self.frame = f
end

#size_height_to_fitObject



75
76
77
78
79
80
81
# File 'lib/purplish-frame/ui/view.rb', line 75

def size_height_to_fit
  w = width
  #Otherwise it doesn't expand short UILabel when it's too short to fit longer text
  self.height = 1000
  sizeToFit
  self.width = w
end

#size_height_to_fit_align_bottomObject



83
84
85
86
87
# File 'lib/purplish-frame/ui/view.rb', line 83

def size_height_to_fit_align_bottom
  y = bottom
  size_height_to_fit
  self.bottom = y
end

#size_height_to_fit_max(f) ⇒ Object



89
90
91
92
# File 'lib/purplish-frame/ui/view.rb', line 89

def size_height_to_fit_max(f)
  size_height_to_fit
  self.height = f if height > f
end

#size_height_to_fit_min(f) ⇒ Object



94
95
96
97
# File 'lib/purplish-frame/ui/view.rb', line 94

def size_height_to_fit_min(f)
  size_height_to_fit
  self.height = f if height < f
end

#size_width_to_fitObject



53
54
55
56
57
# File 'lib/purplish-frame/ui/view.rb', line 53

def size_width_to_fit
  h = height
  sizeToFit
  self.height = h
end

#size_width_to_fit_align_rightObject



59
60
61
62
63
# File 'lib/purplish-frame/ui/view.rb', line 59

def size_width_to_fit_align_right
  x = right
  size_width_to_fit
  self.right = x
end

#size_width_to_fit_max(f) ⇒ Object



65
66
67
68
# File 'lib/purplish-frame/ui/view.rb', line 65

def size_width_to_fit_max(f)
  size_width_to_fit
  self.width = f if width > f
end

#size_width_to_fit_min(f) ⇒ Object



70
71
72
73
# File 'lib/purplish-frame/ui/view.rb', line 70

def size_width_to_fit_min(f)
  size_width_to_fit
  self.width = f if width < f
end

#widthObject



39
40
41
# File 'lib/purplish-frame/ui/view.rb', line 39

def width
  view_frame.size.width
end

#width=(width) ⇒ Object



43
44
45
46
47
# File 'lib/purplish-frame/ui/view.rb', line 43

def width=(width)
  f = frame
  f.size.width = width
  self.frame = f
end