Class: WhirledPeas::Settings::ContainerSettings
- Inherits:
-
ElementSettings
- Object
- ElementSettings
- WhirledPeas::Settings::ContainerSettings
show all
- Defined in:
- lib/whirled_peas/settings/container_settings.rb
Instance Method Summary
collapse
-
#align ⇒ Object
-
#align=(align) ⇒ Object
-
#align_around? ⇒ Boolean
-
#align_between? ⇒ Boolean
-
#align_center? ⇒ Boolean
-
#align_evenly? ⇒ Boolean
-
#align_left? ⇒ Boolean
-
#align_right? ⇒ Boolean
-
#border ⇒ Object
-
#border_sizing? ⇒ Boolean
-
#content_sizing? ⇒ Boolean
-
#content_start ⇒ Object
-
#flow ⇒ Object
-
#flow=(flow) ⇒ Object
-
#forward_flow? ⇒ Boolean
-
#full_border(style: nil, color: nil) ⇒ Object
-
#horizontal_flow? ⇒ Boolean
-
#inherit(parent) ⇒ Object
-
#margin ⇒ Object
-
#padding ⇒ Object
-
#reverse_flow? ⇒ Boolean
-
#scrollbar ⇒ Object
-
#set_border(left: nil, top: nil, right: nil, bottom: nil, inner_horiz: nil, inner_vert: nil, style: nil, color: nil) ⇒ Object
-
#set_content_start(left: nil, top: nil, right: nil, bottom: nil) ⇒ Object
-
#set_margin(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil) ⇒ Object
-
#set_padding(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil) ⇒ Object
-
#set_scrollbar(horiz: nil, vert: nil) ⇒ Object
-
#sizing ⇒ Object
-
#sizing=(sizing) ⇒ Object
-
#valign ⇒ Object
-
#valign=(valign) ⇒ Object
-
#valign_around? ⇒ Boolean
-
#valign_between? ⇒ Boolean
-
#valign_bottom? ⇒ Boolean
-
#valign_evenly? ⇒ Boolean
-
#valign_middle? ⇒ Boolean
-
#valign_top? ⇒ Boolean
-
#vertical_flow? ⇒ Boolean
Instance Method Details
#align ⇒ Object
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
35
36
37
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 35
def align_around?
align == Alignment::AROUND
end
|
#align_between? ⇒ Boolean
31
32
33
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 31
def align_between?
align == Alignment::BETWEEN
end
|
#align_center? ⇒ Boolean
23
24
25
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 23
def align_center?
align == Alignment::CENTER
end
|
#align_evenly? ⇒ Boolean
39
40
41
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 39
def align_evenly?
align == Alignment::EVENLY
end
|
#align_left? ⇒ Boolean
19
20
21
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 19
def align_left?
align == Alignment::LEFT
end
|
#align_right? ⇒ Boolean
27
28
29
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 27
def align_right?
align == Alignment::RIGHT
end
|
#border ⇒ Object
98
99
100
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 98
def border
@_border ||= Border.new(theme)
end
|
#border_sizing? ⇒ Boolean
207
208
209
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 207
def border_sizing?
@_sizing == Sizing::BORDER
end
|
#content_sizing? ⇒ Boolean
211
212
213
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 211
def content_sizing?
@_sizing == Sizing::CONTENT
end
|
#content_start ⇒ Object
190
191
192
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 190
def content_start
@_content_start ||= Position.new
end
|
#flow ⇒ Object
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
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
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
|
#margin ⇒ Object
148
149
150
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 148
def margin
@_margin ||= Margin.new
end
|
#padding ⇒ Object
174
175
176
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 174
def padding
@_padding ||= Padding.new
end
|
#reverse_flow? ⇒ Boolean
122
123
124
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 122
def reverse_flow?
!forward_flow?
end
|
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
|
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
|
#sizing ⇒ Object
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
|
#valign ⇒ Object
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
67
68
69
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 67
def valign_around?
valign == VertAlignment::AROUND
end
|
#valign_between? ⇒ Boolean
63
64
65
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 63
def valign_between?
valign == VertAlignment::BETWEEN
end
|
#valign_bottom? ⇒ Boolean
59
60
61
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 59
def valign_bottom?
valign == VertAlignment::BOTTOM
end
|
#valign_evenly? ⇒ Boolean
71
72
73
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 71
def valign_evenly?
valign == VertAlignment::EVENLY
end
|
#valign_middle? ⇒ Boolean
55
56
57
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 55
def valign_middle?
valign == VertAlignment::MIDDLE
end
|
#valign_top? ⇒ Boolean
51
52
53
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 51
def valign_top?
valign == VertAlignment::TOP
end
|
#vertical_flow? ⇒ Boolean
114
115
116
|
# File 'lib/whirled_peas/settings/container_settings.rb', line 114
def vertical_flow?
!horizontal_flow?
end
|