Class: Vedeu::Geometries::DSL
Overview
Geometry allows the configuration of the position and size of an interface. Within Vedeu, as the same for ANSI terminals, has the origin at top-left, y = 1, x = 1. The ‘y’ coordinate is deliberately first.
The Geometry DSL can be used within the Interface DSL or standalone. Here are example of declarations for a ‘geometry` block:
A standalone geometry definition:
Vedeu.geometry :some_interface do
height 5
width 20
x 3
y 10
xn 30
yn 20
end
An interface including a geometry definition:
Vedeu.interface :some_interface do
geometry do
height 5
width 20
x 3
y 10
xn 30
yn 20
end
end
If a declaration is omitted for ‘height` or `width` the full remaining space available in the terminal will be used. `x` and `y` both default to 1.
You can also make a geometry declaration dependent on another view:
Vedeu.interface :other_panel do
end
Vedeu.interface :main do
geometry do
height 10
y { use(:other_panel).south }
end
end
This view will begin just below “other_panel”.
This crude ASCII diagram represents a Geometry within Vedeu, each of the labels is a value you can access or define.
x north xn
y +--------------+
| top |
| |
west | left right | east
| |
| bottom |
yn +--------------+
south
Instance Attribute Summary
Attributes included from DSL
#client, #model
Instance Method Summary
collapse
Methods included from DSL::Use
#use
included
Methods included from DSL
#attributes, #initialize, #method_missing, #name
Methods included from Common
#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Vedeu::DSL
Instance Method Details
#align(vertical: :none, horizontal: :none, width: nil, height: nil) ⇒ Vedeu::Geometries::Geometry
Align the interface/view horizontally or vertically within the terminal.
100
101
102
103
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 100
def align(vertical: :none, horizontal: :none, width: nil, height: nil)
horizontal_alignment(horizontal, width)
vertical_alignment(vertical, height)
end
|
131
132
133
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 131
def align_bottom(height = nil)
vertical_alignment(:bottom, height)
end
|
#align_centre(width = nil) ⇒ Vedeu::Geometries::Geometry
Also known as:
align_center
138
139
140
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 138
def align_centre(width = nil)
horizontal_alignment(:centre, width)
end
|
146
147
148
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 146
def align_left(width = nil)
horizontal_alignment(:left, width)
end
|
153
154
155
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 153
def align_middle(height = nil)
vertical_alignment(:middle, height)
end
|
160
161
162
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 160
def align_right(width = nil)
horizontal_alignment(:right, width)
end
|
167
168
169
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 167
def align_top(height = nil)
vertical_alignment(:top, height)
end
|
175
176
177
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 175
def columns(value)
Vedeu::Geometries::Grid.columns(value)
end
|
#height(value) ⇒ Fixnum
Also known as:
height=
182
183
184
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 182
def height(value)
model.height = proc { value }
end
|
109
110
111
112
113
114
115
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 109
def horizontal_alignment(value = :none, width = nil)
alignment = Vedeu::Coercers::HorizontalAlignment.validate(value)
model.width = width if width
model.horizontal_alignment = alignment
model
end
|
#rows(value) ⇒ Fixnum
191
192
193
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 191
def rows(value)
Vedeu::Geometries::Grid.rows(value)
end
|
120
121
122
123
124
125
126
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 120
def vertical_alignment(value = :none, height = nil)
alignment = Vedeu::Coercers::VerticalAlignment.validate(value)
model.height = height if height
model.vertical_alignment = alignment
model
end
|
#width(value) ⇒ Fixnum
Also known as:
width=
198
199
200
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 198
def width(value)
model.width = proc { value }
end
|
#x(value = 1, &block) ⇒ Fixnum
Also known as:
x=
207
208
209
210
211
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 207
def x(value = 1, &block)
return model.x = block if block_given?
model.x = value
end
|
#xn(value = 1, &block) ⇒ Fixnum
Also known as:
xn=
218
219
220
221
222
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 218
def xn(value = 1, &block)
return model.xn = block if block_given?
model.xn = value
end
|
#y(value = 1, &block) ⇒ Fixnum
Also known as:
y=
229
230
231
232
233
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 229
def y(value = 1, &block)
return model.y = block if block_given?
model.y = value
end
|
#yn(value = 1, &block) ⇒ Fixnum
Also known as:
yn=
240
241
242
243
244
|
# File 'lib/vedeu/geometries/dsl/dsl.rb', line 240
def yn(value = 1, &block)
return model.yn = block if block_given?
model.yn = value
end
|