whirled_peas 0.5.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +31 -0
- data/README.md +748 -137
- data/Rakefile +4 -32
- data/bin/easing +33 -0
- data/bin/reset_cursor +11 -0
- data/bin/screen_test +68 -0
- data/examples/graph.rb +54 -0
- data/examples/intro.rb +52 -0
- data/examples/scrolling.rb +54 -0
- data/lib/whirled_peas.rb +4 -12
- data/lib/whirled_peas/animator.rb +5 -0
- data/lib/whirled_peas/animator/debug_consumer.rb +17 -0
- data/lib/whirled_peas/animator/easing.rb +72 -0
- data/lib/whirled_peas/animator/frame.rb +5 -0
- data/lib/whirled_peas/animator/frameset.rb +33 -0
- data/lib/whirled_peas/animator/producer.rb +35 -0
- data/lib/whirled_peas/animator/renderer_consumer.rb +31 -0
- data/lib/whirled_peas/command.rb +5 -0
- data/lib/whirled_peas/command/base.rb +86 -0
- data/lib/whirled_peas/command/config_command.rb +44 -0
- data/lib/whirled_peas/command/debug.rb +21 -0
- data/lib/whirled_peas/command/fonts.rb +22 -0
- data/lib/whirled_peas/command/frame_command.rb +34 -0
- data/lib/whirled_peas/command/frames.rb +24 -0
- data/lib/whirled_peas/command/help.rb +38 -0
- data/lib/whirled_peas/command/play.rb +108 -0
- data/lib/whirled_peas/command/record.rb +57 -0
- data/lib/whirled_peas/command/still.rb +29 -0
- data/lib/whirled_peas/command_line.rb +22 -220
- data/lib/whirled_peas/config.rb +56 -6
- data/lib/whirled_peas/device.rb +5 -0
- data/lib/whirled_peas/device/null_device.rb +8 -0
- data/lib/whirled_peas/device/output_file.rb +19 -0
- data/lib/whirled_peas/device/screen.rb +26 -0
- data/lib/whirled_peas/graphics.rb +14 -0
- data/lib/whirled_peas/graphics/box_painter.rb +48 -47
- data/lib/whirled_peas/graphics/canvas.rb +22 -11
- data/lib/whirled_peas/graphics/composer.rb +98 -0
- data/lib/whirled_peas/graphics/container_coords.rb +24 -13
- data/lib/whirled_peas/graphics/container_dimensions.rb +37 -9
- data/lib/whirled_peas/graphics/container_painter.rb +283 -36
- data/lib/whirled_peas/graphics/content_dimensions.rb +19 -0
- data/lib/whirled_peas/graphics/content_painter.rb +20 -0
- data/lib/whirled_peas/graphics/debugger.rb +10 -1
- data/lib/whirled_peas/graphics/graph_dimensions.rb +12 -0
- data/lib/whirled_peas/graphics/graph_painter.rb +95 -0
- data/lib/whirled_peas/graphics/grid_painter.rb +25 -15
- data/lib/whirled_peas/graphics/mock_screen.rb +1 -1
- data/lib/whirled_peas/graphics/painter.rb +15 -6
- data/lib/whirled_peas/graphics/renderer.rb +13 -30
- data/lib/whirled_peas/graphics/text_painter.rb +11 -13
- data/lib/whirled_peas/settings/alignment.rb +24 -0
- data/lib/whirled_peas/settings/bg_color.rb +2 -0
- data/lib/whirled_peas/settings/border.rb +16 -16
- data/lib/whirled_peas/settings/color.rb +13 -14
- data/lib/whirled_peas/settings/container_settings.rb +133 -40
- data/lib/whirled_peas/settings/debugger.rb +9 -0
- data/lib/whirled_peas/settings/display_flow.rb +13 -11
- data/lib/whirled_peas/settings/element_settings.rb +8 -3
- data/lib/whirled_peas/settings/graph_settings.rb +21 -0
- data/lib/whirled_peas/settings/grid_settings.rb +15 -0
- data/lib/whirled_peas/settings/scrollbar.rb +15 -0
- data/lib/whirled_peas/settings/sizing.rb +19 -0
- data/lib/whirled_peas/settings/spacing.rb +34 -0
- data/lib/whirled_peas/settings/text_color.rb +2 -0
- data/lib/whirled_peas/settings/vert_alignment.rb +24 -0
- data/lib/whirled_peas/utils/ansi.rb +13 -0
- data/lib/whirled_peas/utils/file_handler.rb +57 -0
- data/lib/whirled_peas/utils/title_font.rb +1 -1
- data/lib/whirled_peas/version.rb +1 -1
- data/screen_test/{rendered/elements → elements}/box.frame +1 -1
- data/screen_test/{rendered/elements → elements}/box.rb +0 -0
- data/screen_test/elements/graph.frame +1 -0
- data/screen_test/elements/graph.rb +12 -0
- data/screen_test/elements/grid.frame +1 -0
- data/screen_test/{rendered/elements → elements}/grid.rb +0 -0
- data/screen_test/elements/screen_overflow_x.frame +1 -0
- data/screen_test/{rendered/elements/screen_overflow.rb → elements/screen_overflow_x.rb} +0 -0
- data/screen_test/elements/screen_overflow_y.frame +1 -0
- data/screen_test/elements/screen_overflow_y.rb +9 -0
- data/screen_test/elements/text.frame +1 -0
- data/screen_test/{rendered/elements → elements}/text.rb +0 -0
- data/screen_test/elements/text_multiline.frame +1 -0
- data/screen_test/{rendered/elements → elements}/text_multiline.rb +0 -0
- data/screen_test/settings/align/box_around.frame +1 -0
- data/screen_test/settings/align/box_around.rb +16 -0
- data/screen_test/settings/align/box_between.frame +1 -0
- data/screen_test/settings/align/box_between.rb +16 -0
- data/screen_test/settings/align/box_center.frame +1 -0
- data/screen_test/{rendered/settings/align/box.rb → settings/align/box_center.rb} +5 -4
- data/screen_test/settings/align/box_default.frame +1 -0
- data/screen_test/{rendered/settings/align/grid.rb → settings/align/box_default.rb} +6 -6
- data/screen_test/settings/align/box_evenly.frame +1 -0
- data/screen_test/settings/align/box_evenly.rb +16 -0
- data/screen_test/settings/align/box_left.frame +1 -0
- data/screen_test/settings/align/box_left.rb +21 -0
- data/screen_test/settings/align/box_right.frame +1 -0
- data/screen_test/settings/align/box_right.rb +21 -0
- data/screen_test/settings/align/children_center.frame +1 -0
- data/screen_test/settings/align/children_center.rb +15 -0
- data/screen_test/settings/align/children_left.frame +1 -0
- data/screen_test/settings/align/children_left.rb +15 -0
- data/screen_test/settings/align/children_right.frame +1 -0
- data/screen_test/settings/align/children_right.rb +15 -0
- data/screen_test/settings/align/grid_center.frame +1 -0
- data/screen_test/settings/align/grid_center.rb +18 -0
- data/screen_test/settings/align/grid_default.frame +1 -0
- data/screen_test/settings/align/grid_default.rb +17 -0
- data/screen_test/settings/align/grid_left.frame +1 -0
- data/screen_test/settings/align/grid_left.rb +18 -0
- data/screen_test/settings/align/grid_right.frame +1 -0
- data/screen_test/settings/align/grid_right.rb +18 -0
- data/screen_test/settings/ansi/bold.frame +1 -0
- data/screen_test/{rendered/settings/width/overflow_box_t2b.rb → settings/ansi/bold.rb} +4 -5
- data/screen_test/{rendered/settings → settings}/ansi/color.frame +1 -1
- data/screen_test/{rendered/settings → settings}/ansi/color.rb +0 -0
- data/screen_test/settings/ansi/underline.frame +1 -0
- data/screen_test/{rendered/settings → settings}/ansi/underline.rb +4 -5
- data/screen_test/{rendered/settings → settings}/border.frame +1 -1
- data/screen_test/{rendered/settings → settings}/border.rb +1 -1
- data/screen_test/settings/flow/box_b2t.frame +1 -0
- data/screen_test/settings/flow/box_b2t.rb +26 -0
- data/screen_test/settings/flow/box_l2r.frame +1 -0
- data/screen_test/settings/flow/box_l2r.rb +26 -0
- data/screen_test/settings/flow/box_r2l.frame +1 -0
- data/screen_test/settings/flow/box_r2l.rb +26 -0
- data/screen_test/settings/flow/box_t2b.frame +1 -0
- data/screen_test/settings/flow/box_t2b.rb +26 -0
- data/screen_test/settings/flow/grid_b2t.frame +1 -0
- data/screen_test/settings/flow/grid_b2t.rb +14 -0
- data/screen_test/settings/flow/grid_l2r.frame +1 -0
- data/screen_test/{rendered/settings/margin.rb → settings/flow/grid_l2r.rb} +4 -4
- data/screen_test/settings/flow/grid_r2l.frame +1 -0
- data/screen_test/settings/flow/grid_r2l.rb +14 -0
- data/screen_test/settings/flow/grid_t2b.frame +1 -0
- data/screen_test/settings/flow/grid_t2b.rb +14 -0
- data/screen_test/settings/height/box.frame +1 -0
- data/screen_test/{rendered/settings → settings}/height/box.rb +0 -0
- data/screen_test/settings/height/box_border_sizing.frame +1 -0
- data/screen_test/settings/height/box_border_sizing.rb +15 -0
- data/screen_test/settings/height/grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/height/grid.rb +0 -0
- data/screen_test/settings/height/overflow_box.frame +1 -0
- data/screen_test/settings/height/overflow_box.rb +13 -0
- data/screen_test/settings/height/overflow_box_l2r.frame +1 -0
- data/screen_test/settings/height/overflow_box_l2r.rb +17 -0
- data/screen_test/settings/height/overflow_box_t2b.frame +1 -0
- data/screen_test/settings/height/overflow_box_t2b.rb +16 -0
- data/screen_test/settings/height/overflow_grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/height/overflow_grid.rb +0 -0
- data/screen_test/settings/margin.frame +1 -0
- data/screen_test/settings/margin.rb +16 -0
- data/screen_test/settings/padding.frame +1 -0
- data/screen_test/settings/padding.rb +13 -0
- data/screen_test/settings/position/box_left.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_left.rb +2 -2
- data/screen_test/settings/position/box_left_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_left_negative.rb +2 -2
- data/screen_test/settings/position/box_top.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_top.rb +1 -1
- data/screen_test/settings/position/box_top_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/box_top_negative.rb +2 -2
- data/screen_test/settings/position/grid_left.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_left.rb +1 -1
- data/screen_test/settings/position/grid_left_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_left_negative.rb +1 -1
- data/screen_test/settings/position/grid_top.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_top.rb +1 -1
- data/screen_test/settings/position/grid_top_negative.frame +1 -0
- data/screen_test/{rendered/settings → settings}/position/grid_top_negative.rb +1 -1
- data/screen_test/settings/scroll/horiz_box.frame +1 -0
- data/screen_test/settings/scroll/horiz_box.rb +17 -0
- data/screen_test/settings/scroll/horiz_box_align_center.rb +18 -0
- data/screen_test/settings/scroll/horiz_box_align_right.rb +18 -0
- data/screen_test/settings/scroll/vert_box.frame +1 -0
- data/screen_test/settings/scroll/vert_box.rb +20 -0
- data/screen_test/settings/title_font.frame +1 -0
- data/screen_test/{rendered/settings → settings}/title_font.rb +1 -1
- data/screen_test/settings/valign/box_around.frame +1 -0
- data/screen_test/settings/valign/box_around.rb +17 -0
- data/screen_test/settings/valign/box_between.frame +1 -0
- data/screen_test/settings/valign/box_between.rb +17 -0
- data/screen_test/settings/valign/box_bottom.frame +1 -0
- data/screen_test/settings/valign/box_bottom.rb +17 -0
- data/screen_test/settings/valign/box_default.frame +1 -0
- data/screen_test/settings/valign/box_default.rb +16 -0
- data/screen_test/settings/valign/box_evenly.frame +1 -0
- data/screen_test/settings/valign/box_evenly.rb +17 -0
- data/screen_test/settings/valign/box_middle.frame +1 -0
- data/screen_test/settings/valign/box_middle.rb +17 -0
- data/screen_test/settings/valign/box_top.frame +1 -0
- data/screen_test/settings/valign/box_top.rb +17 -0
- data/screen_test/settings/valign/grid_bottom.frame +1 -0
- data/screen_test/settings/valign/grid_bottom.rb +15 -0
- data/screen_test/settings/valign/grid_default.frame +1 -0
- data/screen_test/settings/valign/grid_default.rb +14 -0
- data/screen_test/settings/valign/grid_middle.frame +1 -0
- data/screen_test/settings/valign/grid_middle.rb +15 -0
- data/screen_test/settings/valign/grid_top.frame +1 -0
- data/screen_test/settings/valign/grid_top.rb +15 -0
- data/screen_test/settings/width/box_border_sizing.frame +1 -0
- data/screen_test/settings/width/box_border_sizing.rb +15 -0
- data/screen_test/settings/width/box_content.frame +1 -0
- data/screen_test/settings/width/box_content.rb +15 -0
- data/screen_test/settings/width/box_default.frame +1 -0
- data/screen_test/{rendered/settings/width/box.rb → settings/width/box_default.rb} +3 -2
- data/screen_test/settings/width/grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/width/grid.rb +2 -2
- data/screen_test/settings/width/overflow_align_center.frame +1 -0
- data/screen_test/settings/width/overflow_align_center.rb +14 -0
- data/screen_test/settings/width/overflow_align_right.frame +1 -0
- data/screen_test/settings/width/overflow_align_right.rb +14 -0
- data/screen_test/settings/width/overflow_box.frame +1 -0
- data/screen_test/settings/width/overflow_box.rb +13 -0
- data/screen_test/settings/width/overflow_box_l2r.frame +1 -0
- data/screen_test/settings/width/overflow_box_l2r.rb +16 -0
- data/screen_test/settings/width/overflow_box_t2b.frame +1 -0
- data/screen_test/settings/width/overflow_box_t2b.rb +17 -0
- data/screen_test/settings/width/overflow_grid.frame +1 -0
- data/screen_test/{rendered/settings → settings}/width/overflow_grid.rb +0 -0
- data/tools/whirled_peas/tools/screen_tester.rb +285 -0
- metadata +192 -98
- data/bin/debug +0 -35
- data/lib/whirled_peas/debugger.rb +0 -80
- data/lib/whirled_peas/frame.rb +0 -6
- data/lib/whirled_peas/frame/consumer.rb +0 -30
- data/lib/whirled_peas/frame/debug_consumer.rb +0 -30
- data/lib/whirled_peas/frame/event_loop.rb +0 -90
- data/lib/whirled_peas/frame/producer.rb +0 -67
- data/lib/whirled_peas/graphics/screen.rb +0 -65
- data/lib/whirled_peas/graphics/text_dimensions.rb +0 -15
- data/lib/whirled_peas/settings/text_align.rb +0 -19
- data/lib/whirled_peas/template.rb +0 -5
- data/lib/whirled_peas/template/box_element.rb +0 -8
- data/lib/whirled_peas/template/composer.rb +0 -68
- data/lib/whirled_peas/template/container.rb +0 -28
- data/lib/whirled_peas/template/debugger.rb +0 -34
- data/lib/whirled_peas/template/element.rb +0 -13
- data/lib/whirled_peas/template/grid_element.rb +0 -8
- data/lib/whirled_peas/template/text_element.rb +0 -24
- data/screen_test/rendered/elements/grid.frame +0 -1
- data/screen_test/rendered/elements/text.frame +0 -1
- data/screen_test/rendered/elements/text_multiline.frame +0 -1
- data/screen_test/rendered/settings/align/box.frame +0 -1
- data/screen_test/rendered/settings/align/children_center.frame +0 -1
- data/screen_test/rendered/settings/align/children_center.rb +0 -13
- data/screen_test/rendered/settings/align/children_left.frame +0 -1
- data/screen_test/rendered/settings/align/children_left.rb +0 -13
- data/screen_test/rendered/settings/align/children_right.frame +0 -1
- data/screen_test/rendered/settings/align/children_right.rb +0 -13
- data/screen_test/rendered/settings/align/grid.frame +0 -1
- data/screen_test/rendered/settings/ansi/bold.frame +0 -1
- data/screen_test/rendered/settings/ansi/bold.rb +0 -15
- data/screen_test/rendered/settings/ansi/underline.frame +0 -1
- data/screen_test/rendered/settings/flow/l2r.frame +0 -1
- data/screen_test/rendered/settings/flow/l2r.rb +0 -24
- data/screen_test/rendered/settings/flow/t2b.frame +0 -1
- data/screen_test/rendered/settings/flow/t2b.rb +0 -24
- data/screen_test/rendered/settings/height/box.frame +0 -1
- data/screen_test/rendered/settings/height/grid.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_box.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_box.rb +0 -13
- data/screen_test/rendered/settings/height/overflow_box_l2r.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_box_l2r.rb +0 -15
- data/screen_test/rendered/settings/height/overflow_box_t2b.frame +0 -1
- data/screen_test/rendered/settings/height/overflow_box_t2b.rb +0 -14
- data/screen_test/rendered/settings/height/overflow_grid.frame +0 -1
- data/screen_test/rendered/settings/margin.frame +0 -1
- data/screen_test/rendered/settings/padding.frame +0 -1
- data/screen_test/rendered/settings/padding.rb +0 -11
- data/screen_test/rendered/settings/position/box_left.frame +0 -1
- data/screen_test/rendered/settings/position/box_left_negative.frame +0 -1
- data/screen_test/rendered/settings/position/box_top.frame +0 -1
- data/screen_test/rendered/settings/position/box_top_negative.frame +0 -1
- data/screen_test/rendered/settings/position/grid_left.frame +0 -1
- data/screen_test/rendered/settings/position/grid_left_negative.frame +0 -1
- data/screen_test/rendered/settings/position/grid_top.frame +0 -1
- data/screen_test/rendered/settings/position/grid_top_negative.frame +0 -1
- data/screen_test/rendered/settings/title_font.frame +0 -1
- data/screen_test/rendered/settings/width/box.frame +0 -1
- data/screen_test/rendered/settings/width/grid.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_box.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_box.rb +0 -11
- data/screen_test/rendered/settings/width/overflow_box_l2r.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_box_l2r.rb +0 -14
- data/screen_test/rendered/settings/width/overflow_box_t2b.frame +0 -1
- data/screen_test/rendered/settings/width/overflow_grid.frame +0 -1
- data/screen_test/screen_tester.rb +0 -191
@@ -1,47 +1,92 @@
|
|
1
|
+
require_relative 'alignment'
|
1
2
|
require_relative 'border'
|
2
3
|
require_relative 'display_flow'
|
3
4
|
require_relative 'element_settings'
|
4
5
|
require_relative 'margin'
|
5
6
|
require_relative 'padding'
|
6
7
|
require_relative 'position'
|
8
|
+
require_relative 'scrollbar'
|
9
|
+
require_relative 'sizing'
|
10
|
+
require_relative 'vert_alignment'
|
7
11
|
|
8
12
|
module WhirledPeas
|
9
13
|
module Settings
|
10
14
|
class ContainerSettings < ElementSettings
|
11
|
-
attr_accessor :width, :height
|
12
|
-
|
13
15
|
def align
|
14
|
-
@_align ||
|
16
|
+
@_align || Alignment::DEFAULT
|
15
17
|
end
|
16
18
|
|
17
19
|
def align_left?
|
18
|
-
align ==
|
20
|
+
align == Alignment::LEFT
|
19
21
|
end
|
20
22
|
|
21
23
|
def align_center?
|
22
|
-
align ==
|
24
|
+
align == Alignment::CENTER
|
23
25
|
end
|
24
26
|
|
25
27
|
def align_right?
|
26
|
-
align ==
|
28
|
+
align == Alignment::RIGHT
|
29
|
+
end
|
30
|
+
|
31
|
+
def align_between?
|
32
|
+
align == Alignment::BETWEEN
|
33
|
+
end
|
34
|
+
|
35
|
+
def align_around?
|
36
|
+
align == Alignment::AROUND
|
37
|
+
end
|
38
|
+
|
39
|
+
def align_evenly?
|
40
|
+
align == Alignment::EVENLY
|
27
41
|
end
|
28
42
|
|
29
43
|
def align=(align)
|
30
|
-
@_align =
|
44
|
+
@_align = Alignment.validate!(align)
|
45
|
+
end
|
46
|
+
|
47
|
+
def valign
|
48
|
+
@_valign || VertAlignment::DEFAULT
|
49
|
+
end
|
50
|
+
|
51
|
+
def valign_top?
|
52
|
+
valign == VertAlignment::TOP
|
53
|
+
end
|
54
|
+
|
55
|
+
def valign_middle?
|
56
|
+
valign == VertAlignment::MIDDLE
|
57
|
+
end
|
58
|
+
|
59
|
+
def valign_bottom?
|
60
|
+
valign == VertAlignment::BOTTOM
|
61
|
+
end
|
62
|
+
|
63
|
+
def valign_between?
|
64
|
+
valign == VertAlignment::BETWEEN
|
65
|
+
end
|
66
|
+
|
67
|
+
def valign_around?
|
68
|
+
valign == VertAlignment::AROUND
|
69
|
+
end
|
70
|
+
|
71
|
+
def valign_evenly?
|
72
|
+
valign == VertAlignment::EVENLY
|
73
|
+
end
|
74
|
+
|
75
|
+
def valign=(valign)
|
76
|
+
@_valign = VertAlignment.validate!(valign)
|
31
77
|
end
|
32
78
|
|
33
79
|
def set_border(
|
34
80
|
left: nil, top: nil, right: nil, bottom: nil, inner_horiz: nil, inner_vert: nil, style: nil, color: nil
|
35
81
|
)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@_border.color = color unless color.nil?
|
82
|
+
border.left = left unless left.nil?
|
83
|
+
border.top = top unless top.nil?
|
84
|
+
border.right = right unless right.nil?
|
85
|
+
border.bottom = bottom unless bottom.nil?
|
86
|
+
border.inner_horiz = inner_horiz unless inner_horiz.nil?
|
87
|
+
border.inner_vert = inner_vert unless inner_vert.nil?
|
88
|
+
border.style = style unless style.nil?
|
89
|
+
border.color = color unless color.nil?
|
45
90
|
end
|
46
91
|
|
47
92
|
def full_border(style: nil, color: nil)
|
@@ -51,7 +96,7 @@ module WhirledPeas
|
|
51
96
|
end
|
52
97
|
|
53
98
|
def border
|
54
|
-
@_border
|
99
|
+
@_border ||= Border.new
|
55
100
|
end
|
56
101
|
|
57
102
|
def flow=(flow)
|
@@ -59,7 +104,7 @@ module WhirledPeas
|
|
59
104
|
end
|
60
105
|
|
61
106
|
def flow
|
62
|
-
@_flow || DisplayFlow::
|
107
|
+
@_flow || DisplayFlow::DEFAULT
|
63
108
|
end
|
64
109
|
|
65
110
|
def horizontal_flow?
|
@@ -78,51 +123,99 @@ module WhirledPeas
|
|
78
123
|
!forward_flow?
|
79
124
|
end
|
80
125
|
|
81
|
-
def set_margin(left: nil, top: nil, right: nil, bottom: nil)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
126
|
+
def set_margin(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil)
|
127
|
+
if horiz && (left || right)
|
128
|
+
raise ArgumentError, 'Cannot set horizontal margin when setting left/right'
|
129
|
+
elsif vert && (top || bottom)
|
130
|
+
raise ArgumentError, 'Cannot set vertical margin when setting top/bottom'
|
131
|
+
end
|
132
|
+
|
133
|
+
if horiz
|
134
|
+
margin.horiz = horiz
|
135
|
+
else
|
136
|
+
margin.left = left if left
|
137
|
+
margin.right = right if right
|
138
|
+
end
|
139
|
+
|
140
|
+
if vert
|
141
|
+
margin.vert = vert
|
142
|
+
else
|
143
|
+
margin.top = top if top
|
144
|
+
margin.bottom = bottom if bottom
|
145
|
+
end
|
87
146
|
end
|
88
147
|
|
89
148
|
def margin
|
90
|
-
@_margin
|
149
|
+
@_margin ||= Margin.new
|
91
150
|
end
|
92
151
|
|
93
|
-
def set_padding(left: nil, top: nil, right: nil, bottom: nil)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
152
|
+
def set_padding(left: nil, top: nil, right: nil, bottom: nil, horiz: nil, vert: nil)
|
153
|
+
if horiz && (left || right)
|
154
|
+
raise ArgumentError, 'Cannot set horizontal padding when setting left/right'
|
155
|
+
elsif vert && (top || bottom)
|
156
|
+
raise ArgumentError, 'Cannot set vertical padding when setting top/bottom'
|
157
|
+
end
|
158
|
+
|
159
|
+
if horiz
|
160
|
+
padding.horiz = horiz
|
161
|
+
else
|
162
|
+
padding.left = left if left
|
163
|
+
padding.right = right if right
|
164
|
+
end
|
165
|
+
|
166
|
+
if vert
|
167
|
+
padding.vert = vert
|
168
|
+
else
|
169
|
+
padding.top = top if top
|
170
|
+
padding.bottom = bottom if bottom
|
171
|
+
end
|
99
172
|
end
|
100
173
|
|
101
174
|
def padding
|
102
|
-
@_padding
|
175
|
+
@_padding ||= Padding.new
|
103
176
|
end
|
104
177
|
|
105
178
|
def set_position(left: nil, top: nil)
|
106
|
-
|
107
|
-
|
108
|
-
@_position.top = top if top
|
179
|
+
position.left = left if left
|
180
|
+
position.top = top if top
|
109
181
|
end
|
110
182
|
|
111
183
|
def position
|
112
|
-
@_position
|
184
|
+
@_position ||= Position.new
|
185
|
+
end
|
186
|
+
|
187
|
+
def set_scrollbar(horiz: nil, vert: nil)
|
188
|
+
scrollbar.horiz = horiz unless horiz.nil?
|
189
|
+
scrollbar.vert = vert unless vert.nil?
|
190
|
+
end
|
191
|
+
|
192
|
+
def scrollbar
|
193
|
+
@_scrollbar ||= Scrollbar.new
|
194
|
+
end
|
195
|
+
|
196
|
+
def sizing
|
197
|
+
@_sizing || Sizing::DEFAULT
|
198
|
+
end
|
199
|
+
|
200
|
+
def border_sizing?
|
201
|
+
@_sizing == Sizing::BORDER
|
202
|
+
end
|
203
|
+
|
204
|
+
def content_sizing?
|
205
|
+
@_sizing == Sizing::CONTENT
|
206
|
+
end
|
207
|
+
|
208
|
+
def sizing=(sizing)
|
209
|
+
@_sizing = Sizing.validate!(sizing)
|
113
210
|
end
|
114
211
|
|
115
212
|
def inherit(parent)
|
116
213
|
super
|
117
214
|
return unless parent.is_a?(ContainerSettings)
|
118
|
-
@_align = parent._align
|
119
|
-
@_flow = parent._flow
|
120
215
|
set_border(color: parent.border.color, style: parent.border.style)
|
121
216
|
end
|
122
217
|
|
123
218
|
protected
|
124
|
-
|
125
|
-
attr_accessor :_align, :_flow
|
126
219
|
end
|
127
220
|
end
|
128
221
|
end
|
@@ -3,6 +3,7 @@ require_relative 'container_settings'
|
|
3
3
|
require_relative 'margin'
|
4
4
|
require_relative 'padding'
|
5
5
|
require_relative 'position'
|
6
|
+
require_relative 'scrollbar'
|
6
7
|
|
7
8
|
module WhirledPeas
|
8
9
|
module Settings
|
@@ -41,6 +42,8 @@ module WhirledPeas
|
|
41
42
|
border_value(value)
|
42
43
|
when Padding
|
43
44
|
padding_value(value)
|
45
|
+
when Scrollbar
|
46
|
+
scrollbar_value(value)
|
44
47
|
else
|
45
48
|
value.inspect
|
46
49
|
end
|
@@ -82,6 +85,12 @@ module WhirledPeas
|
|
82
85
|
return if values == ''
|
83
86
|
"Padding(#{values})"
|
84
87
|
end
|
88
|
+
|
89
|
+
def scrollbar_value(scrollbar)
|
90
|
+
values = non_defaults(scrollbar, Scrollbar.new, %i[horiz? vert?])
|
91
|
+
return if values == ''
|
92
|
+
"Scrollbar(#{values})"
|
93
|
+
end
|
85
94
|
end
|
86
95
|
end
|
87
96
|
end
|
@@ -6,18 +6,20 @@ module WhirledPeas
|
|
6
6
|
TOP_TO_BOTTOM = :t2b
|
7
7
|
BOTTOM_TO_TOP = :b2t
|
8
8
|
|
9
|
+
DEFAULT = LEFT_TO_RIGHT
|
10
|
+
|
11
|
+
VALID = [
|
12
|
+
DisplayFlow::LEFT_TO_RIGHT,
|
13
|
+
DisplayFlow::RIGHT_TO_LEFT,
|
14
|
+
DisplayFlow::TOP_TO_BOTTOM,
|
15
|
+
DisplayFlow::BOTTOM_TO_TOP
|
16
|
+
]
|
17
|
+
private_constant :VALID
|
18
|
+
|
9
19
|
def self.validate!(flow)
|
10
|
-
return
|
11
|
-
if
|
12
|
-
|
13
|
-
DisplayFlow::RIGHT_TO_LEFT,
|
14
|
-
DisplayFlow::TOP_TO_BOTTOM,
|
15
|
-
DisplayFlow::BOTTOM_TO_TOP
|
16
|
-
].include?(flow)
|
17
|
-
flow
|
18
|
-
else
|
19
|
-
raise ArgumentError, "Unsupported display flow: #{flow}"
|
20
|
-
end
|
20
|
+
return if flow.nil?
|
21
|
+
return flow if VALID.include?(flow)
|
22
|
+
raise ArgumentError, "Unsupported display flow: #{flow.inspect}"
|
21
23
|
end
|
22
24
|
end
|
23
25
|
private_constant :DisplayFlow
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
+
require_relative 'alignment'
|
3
4
|
require_relative 'bg_color'
|
4
|
-
require_relative 'text_align'
|
5
5
|
require_relative 'text_color'
|
6
6
|
|
7
7
|
module WhirledPeas
|
@@ -13,8 +13,13 @@ module WhirledPeas
|
|
13
13
|
child
|
14
14
|
end
|
15
15
|
|
16
|
+
attr_accessor :width, :height
|
17
|
+
|
18
|
+
def validate!
|
19
|
+
end
|
20
|
+
|
16
21
|
def bg_color
|
17
|
-
@_bg_color
|
22
|
+
@_bg_color || BgColor::DEFAULT
|
18
23
|
end
|
19
24
|
|
20
25
|
def bg_color=(color)
|
@@ -30,7 +35,7 @@ module WhirledPeas
|
|
30
35
|
end
|
31
36
|
|
32
37
|
def color
|
33
|
-
@_color
|
38
|
+
@_color || TextColor::DEFAULT
|
34
39
|
end
|
35
40
|
|
36
41
|
def color=(color)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'text_color'
|
2
|
+
require_relative 'element_settings'
|
3
|
+
|
4
|
+
module WhirledPeas
|
5
|
+
module Settings
|
6
|
+
class GraphSettings < ElementSettings
|
7
|
+
def axis_color
|
8
|
+
@_axis_color || color
|
9
|
+
end
|
10
|
+
|
11
|
+
def axis_color=(color)
|
12
|
+
@_axis_color = TextColor.validate!(color)
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate!
|
16
|
+
super
|
17
|
+
raise SettingsError, "`height` must be set for GraphSettings" if height.nil?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -6,6 +6,21 @@ module WhirledPeas
|
|
6
6
|
module Settings
|
7
7
|
class GridSettings < ContainerSettings
|
8
8
|
attr_accessor :num_cols
|
9
|
+
|
10
|
+
def validate!
|
11
|
+
super
|
12
|
+
if num_cols.nil? || num_cols <= 0
|
13
|
+
raise SettingsError, "`num_cols` must be set to a positive number for GridSettings"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_scrollbar(*)
|
18
|
+
raise NotImplementedError, 'Grids do not support scrollbars'
|
19
|
+
end
|
20
|
+
|
21
|
+
def sizing=(*)
|
22
|
+
raise NotImplementedError, 'Grids only support the default sizing model'
|
23
|
+
end
|
9
24
|
end
|
10
25
|
end
|
11
26
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module WhirledPeas
|
2
|
+
module Settings
|
3
|
+
class Sizing
|
4
|
+
CONTENT = :content
|
5
|
+
BORDER = :border
|
6
|
+
|
7
|
+
DEFAULT = CONTENT
|
8
|
+
|
9
|
+
VALID = [CONTENT, BORDER]
|
10
|
+
private_constant :VALID
|
11
|
+
|
12
|
+
def self.validate!(sizing)
|
13
|
+
return if sizing.nil?
|
14
|
+
return sizing if VALID.include?(sizing)
|
15
|
+
raise ArgumentError, "Unsupported sizing model: #{sizing.inspect}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,21 +3,55 @@ module WhirledPeas
|
|
3
3
|
class Spacing
|
4
4
|
attr_writer :left, :top, :right, :bottom
|
5
5
|
|
6
|
+
def left=(value)
|
7
|
+
@left = validate!(value)
|
8
|
+
end
|
9
|
+
|
6
10
|
def left
|
7
11
|
@left || 0
|
8
12
|
end
|
9
13
|
|
14
|
+
def top=(value)
|
15
|
+
@top = validate!(value)
|
16
|
+
end
|
17
|
+
|
10
18
|
def top
|
11
19
|
@top || 0
|
12
20
|
end
|
13
21
|
|
22
|
+
def right=(value)
|
23
|
+
@right = validate!(value)
|
24
|
+
end
|
25
|
+
|
14
26
|
def right
|
15
27
|
@right || 0
|
16
28
|
end
|
17
29
|
|
30
|
+
def bottom=(value)
|
31
|
+
@bottom = validate!(value)
|
32
|
+
end
|
33
|
+
|
18
34
|
def bottom
|
19
35
|
@bottom || 0
|
20
36
|
end
|
37
|
+
|
38
|
+
def horiz=(value)
|
39
|
+
self.left = self.right = value
|
40
|
+
end
|
41
|
+
|
42
|
+
def vert=(value)
|
43
|
+
self.top = self.bottom = value
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def validate!(value)
|
49
|
+
if value && value < 0
|
50
|
+
raise ArgumentError, "Negative values for #{self.class.name.split('::').last.downcase} are not allowed"
|
51
|
+
else
|
52
|
+
value
|
53
|
+
end
|
54
|
+
end
|
21
55
|
end
|
22
56
|
private_constant :Spacing
|
23
57
|
end
|