Class: WhirledPeas::Settings::ContainerSettings

Inherits:
ElementSettings
  • Object
show all
Defined in:
lib/whirled_peas/settings/container_settings.rb

Direct Known Subclasses

BoxSettings, GridSettings

Instance Method Summary collapse

Instance Method Details

#alignObject



15
16
17
# File 'lib/whirled_peas/settings/container_settings.rb', line 15

def align
  @_align || Alignment::DEFAULT
end

#align=(align) ⇒ Object



43
44
45
# File 'lib/whirled_peas/settings/container_settings.rb', line 43

def align=(align)
  @_align = Alignment.validate!(align)
end

#align_around?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/whirled_peas/settings/container_settings.rb', line 35

def align_around?
  align == Alignment::AROUND
end

#align_between?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/whirled_peas/settings/container_settings.rb', line 31

def align_between?
  align == Alignment::BETWEEN
end

#align_center?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/whirled_peas/settings/container_settings.rb', line 23

def align_center?
  align == Alignment::CENTER
end

#align_evenly?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/whirled_peas/settings/container_settings.rb', line 39

def align_evenly?
  align == Alignment::EVENLY
end

#align_left?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/whirled_peas/settings/container_settings.rb', line 19

def align_left?
  align == Alignment::LEFT
end

#align_right?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/whirled_peas/settings/container_settings.rb', line 27

def align_right?
  align == Alignment::RIGHT
end

#borderObject



98
99
100
# File 'lib/whirled_peas/settings/container_settings.rb', line 98

def border
  @_border ||= Border.new(theme)
end

#border_sizing?Boolean

Returns:

  • (Boolean)


207
208
209
# File 'lib/whirled_peas/settings/container_settings.rb', line 207

def border_sizing?
  @_sizing == Sizing::BORDER
end

#content_sizing?Boolean

Returns:

  • (Boolean)


211
212
213
# File 'lib/whirled_peas/settings/container_settings.rb', line 211

def content_sizing?
  @_sizing == Sizing::CONTENT
end

#content_startObject



190
191
192
# File 'lib/whirled_peas/settings/container_settings.rb', line 190

def content_start
  @_content_start ||= Position.new
end

#flowObject



106
107
108
# File 'lib/whirled_peas/settings/container_settings.rb', line 106

def flow
  @_flow || DisplayFlow::DEFAULT
end

#flow=(flow) ⇒ Object



102
103
104
# File 'lib/whirled_peas/settings/container_settings.rb', line 102

def flow=(flow)
  @_flow = DisplayFlow.validate!(flow)
end

#forward_flow?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/whirled_peas/settings/container_settings.rb', line 118

def forward_flow?
  %i[l2r t2b].include?(flow)
end

#full_border(style: nil, color: nil) ⇒ Object



92
93
94
95
96
# File 'lib/whirled_peas/settings/container_settings.rb', line 92

def full_border(style: nil, color: nil)
  set_border(
    left: true, top: true, right: true, bottom: true, inner_horiz: true, inner_vert: true, style: style, color: color
  )
end

#horizontal_flow?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/whirled_peas/settings/container_settings.rb', line 110

def horizontal_flow?
  %i[l2r r2l].include?(flow)
end

#inherit(parent) ⇒ Object



219
220
221
222
223
# File 'lib/whirled_peas/settings/container_settings.rb', line 219

def inherit(parent)
  super
  return unless parent.is_a?(ContainerSettings)
  @_border = Border.inherit(parent.border)
end

#marginObject



148
149
150
# File 'lib/whirled_peas/settings/container_settings.rb', line 148

def margin
  @_margin ||= Margin.new
end

#paddingObject



174
175
176
# File 'lib/whirled_peas/settings/container_settings.rb', line 174

def padding
  @_padding ||= Padding.new
end

#reverse_flow?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/whirled_peas/settings/container_settings.rb', line 122

def reverse_flow?
  !forward_flow?
end

#scrollbarObject



199
200
201
# File 'lib/whirled_peas/settings/container_settings.rb', line 199

def scrollbar
  @_scrollbar ||= Scrollbar.new
end

#set_border(left: nil, top: nil, right: nil, bottom: nil, inner_horiz: nil, inner_vert: nil, style: nil, color: nil) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/whirled_peas/settings/container_settings.rb', line 79

def set_border(
  left: nil, top: nil, right: nil, bottom: nil, inner_horiz: nil, inner_vert: nil, style: nil, color: nil
)
  border.left = left unless left.nil?
  border.top = top unless top.nil?
  border.right = right unless right.nil?
  border.bottom = bottom unless bottom.nil?
  border.inner_horiz = inner_horiz unless inner_horiz.nil?
  border.inner_vert = inner_vert unless inner_vert.nil?
  border.style = style unless style.nil?
  border.color = color unless color.nil?
end

#set_content_start(left: nil, top: nil, right: nil, bottom: nil) ⇒ Object



178
179
180
181
182
183
184
185
186
187
188
# File 'lib/whirled_peas/settings/container_settings.rb', line 178

def set_content_start(left: nil, top: nil, right: nil, bottom: nil)
  if left && right
    raise ArgumentError, 'Setting left and right content_start is not supported'
  elsif top && bottom
    raise ArgumentError, 'Setting top and bottom content_start is not supported'
  end
  content_start.left = left if left
  content_start.top = top if top
  content_start.right = right if right
  content_start.bottom = bottom if bottom
end

#set_margin(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/whirled_peas/settings/container_settings.rb', line 126

def set_margin(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil)
  if horiz && (left || right)
    raise ArgumentError, 'Cannot set horizontal margin when setting left/right'
  elsif vert && (top || bottom)
    raise ArgumentError, 'Cannot set vertical margin when setting top/bottom'
  end

  if horiz
    margin.horiz = horiz
  else
    margin.left = left if left
    margin.right = right if right
  end

  if vert
    margin.vert = vert
  else
    margin.top = top if top
    margin.bottom = bottom if bottom
  end
end

#set_padding(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/whirled_peas/settings/container_settings.rb', line 152

def set_padding(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil)
  if horiz && (left || right)
    raise ArgumentError, 'Cannot set horizontal padding when setting left/right'
  elsif vert && (top || bottom)
    raise ArgumentError, 'Cannot set vertical padding when setting top/bottom'
  end

  if horiz
    padding.horiz = horiz
  else
    padding.left = left if left
    padding.right = right if right
  end

  if vert
    padding.vert = vert
  else
    padding.top = top if top
    padding.bottom = bottom if bottom
  end
end

#set_scrollbar(horiz: nil, vert: nil) ⇒ Object



194
195
196
197
# File 'lib/whirled_peas/settings/container_settings.rb', line 194

def set_scrollbar(horiz: nil, vert: nil)
  scrollbar.horiz = horiz unless horiz.nil?
  scrollbar.vert = vert unless vert.nil?
end

#sizingObject



203
204
205
# File 'lib/whirled_peas/settings/container_settings.rb', line 203

def sizing
  @_sizing || Sizing::DEFAULT
end

#sizing=(sizing) ⇒ Object



215
216
217
# File 'lib/whirled_peas/settings/container_settings.rb', line 215

def sizing=(sizing)
  @_sizing = Sizing.validate!(sizing)
end

#valignObject



47
48
49
# File 'lib/whirled_peas/settings/container_settings.rb', line 47

def valign
  @_valign || VertAlignment::DEFAULT
end

#valign=(valign) ⇒ Object



75
76
77
# File 'lib/whirled_peas/settings/container_settings.rb', line 75

def valign=(valign)
  @_valign = VertAlignment.validate!(valign)
end

#valign_around?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/whirled_peas/settings/container_settings.rb', line 67

def valign_around?
  valign == VertAlignment::AROUND
end

#valign_between?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/whirled_peas/settings/container_settings.rb', line 63

def valign_between?
  valign == VertAlignment::BETWEEN
end

#valign_bottom?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/whirled_peas/settings/container_settings.rb', line 59

def valign_bottom?
  valign == VertAlignment::BOTTOM
end

#valign_evenly?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/whirled_peas/settings/container_settings.rb', line 71

def valign_evenly?
  valign == VertAlignment::EVENLY
end

#valign_middle?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/whirled_peas/settings/container_settings.rb', line 55

def valign_middle?
  valign == VertAlignment::MIDDLE
end

#valign_top?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/whirled_peas/settings/container_settings.rb', line 51

def valign_top?
  valign == VertAlignment::TOP
end

#vertical_flow?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/whirled_peas/settings/container_settings.rb', line 114

def vertical_flow?
  !horizontal_flow?
end