lacci 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +8 -1
  4. data/lib/lacci/scarpe_cli.rb +2 -2
  5. data/lib/lacci/scarpe_core.rb +2 -1
  6. data/lib/lacci/version.rb +1 -1
  7. data/lib/scarpe/niente/app.rb +23 -0
  8. data/lib/scarpe/niente/display_service.rb +66 -0
  9. data/lib/scarpe/niente/drawable.rb +59 -0
  10. data/lib/scarpe/niente/shoes_spec.rb +93 -0
  11. data/lib/scarpe/niente.rb +32 -0
  12. data/lib/shoes/app.rb +111 -72
  13. data/lib/shoes/background.rb +2 -2
  14. data/lib/shoes/border.rb +2 -2
  15. data/lib/shoes/builtins.rb +63 -0
  16. data/lib/shoes/changelog.rb +52 -0
  17. data/lib/shoes/colors.rb +3 -1
  18. data/lib/shoes/constants.rb +41 -2
  19. data/lib/shoes/display_service.rb +80 -18
  20. data/lib/shoes/download.rb +2 -2
  21. data/lib/shoes/drawable.rb +654 -0
  22. data/lib/shoes/drawables/arc.rb +27 -0
  23. data/lib/shoes/drawables/arrow.rb +21 -0
  24. data/lib/shoes/drawables/border.rb +28 -0
  25. data/lib/shoes/drawables/button.rb +57 -0
  26. data/lib/shoes/drawables/check.rb +33 -0
  27. data/lib/shoes/drawables/document_root.rb +20 -0
  28. data/lib/shoes/{widgets → drawables}/edit_box.rb +9 -8
  29. data/lib/shoes/{widgets → drawables}/edit_line.rb +8 -7
  30. data/lib/shoes/drawables/flow.rb +20 -0
  31. data/lib/shoes/drawables/font_helper.rb +62 -0
  32. data/lib/shoes/{widgets → drawables}/image.rb +7 -7
  33. data/lib/shoes/drawables/line.rb +17 -0
  34. data/lib/shoes/drawables/link.rb +31 -0
  35. data/lib/shoes/drawables/list_box.rb +59 -0
  36. data/lib/shoes/drawables/oval.rb +48 -0
  37. data/lib/shoes/drawables/para.rb +206 -0
  38. data/lib/shoes/drawables/progress.rb +15 -0
  39. data/lib/shoes/drawables/radio.rb +35 -0
  40. data/lib/shoes/drawables/rect.rb +18 -0
  41. data/lib/shoes/{widgets → drawables}/shape.rb +8 -8
  42. data/lib/shoes/drawables/slot.rb +178 -0
  43. data/lib/shoes/drawables/stack.rb +21 -0
  44. data/lib/shoes/drawables/star.rb +28 -0
  45. data/lib/shoes/drawables/subscription_item.rb +93 -0
  46. data/lib/shoes/drawables/text_drawable.rb +122 -0
  47. data/lib/shoes/drawables/video.rb +17 -0
  48. data/lib/shoes/drawables/widget.rb +74 -0
  49. data/lib/shoes/drawables.rb +32 -0
  50. data/lib/shoes/errors.rb +38 -0
  51. data/lib/shoes/log.rb +2 -2
  52. data/lib/shoes/margin_helper.rb +79 -0
  53. data/lib/shoes/ruby_extensions.rb +15 -0
  54. data/lib/shoes-spec.rb +93 -0
  55. data/lib/shoes.rb +31 -10
  56. metadata +58 -31
  57. data/lib/shoes/spacing.rb +0 -9
  58. data/lib/shoes/widget.rb +0 -218
  59. data/lib/shoes/widgets/alert.rb +0 -19
  60. data/lib/shoes/widgets/arc.rb +0 -51
  61. data/lib/shoes/widgets/button.rb +0 -35
  62. data/lib/shoes/widgets/check.rb +0 -28
  63. data/lib/shoes/widgets/document_root.rb +0 -20
  64. data/lib/shoes/widgets/flow.rb +0 -22
  65. data/lib/shoes/widgets/font.rb +0 -14
  66. data/lib/shoes/widgets/line.rb +0 -18
  67. data/lib/shoes/widgets/link.rb +0 -25
  68. data/lib/shoes/widgets/list_box.rb +0 -25
  69. data/lib/shoes/widgets/para.rb +0 -68
  70. data/lib/shoes/widgets/radio.rb +0 -35
  71. data/lib/shoes/widgets/slot.rb +0 -75
  72. data/lib/shoes/widgets/span.rb +0 -26
  73. data/lib/shoes/widgets/stack.rb +0 -24
  74. data/lib/shoes/widgets/star.rb +0 -44
  75. data/lib/shoes/widgets/subscription_item.rb +0 -60
  76. data/lib/shoes/widgets/text_widget.rb +0 -51
  77. data/lib/shoes/widgets/video.rb +0 -15
  78. data/lib/shoes/widgets.rb +0 -29
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Border < Shoes::Drawable
5
+ # Shoes style with verification or value mapping:
6
+ # shoes_style(:left) { |val| convert_to_integer(val, "left") }
7
+
8
+ shoes_styles :stroke, :strokewidth # Write your shoes styles here
9
+
10
+ shoes_style(:strokewidth) { |val| convert_to_integer(val, "strokewidth") }
11
+ shoes_style(:curve) { |val| convert_to_integer(val, "curve") }
12
+
13
+ Shoes::Drawable.drawable_default_styles[Shoes::Border][:stroke] = :black
14
+ Shoes::Drawable.drawable_default_styles[Shoes::Border][:strokewidth] = 1
15
+ Shoes::Drawable.drawable_default_styles[Shoes::Border][:curve] = 0
16
+
17
+ opt_init_args :stroke, :strokewidth, :curve
18
+ def initialize(*args, **kwargs)
19
+ super
20
+ @draw_context = Shoes::App.instance.current_draw_context
21
+
22
+ create_display_drawable
23
+ end
24
+
25
+ private
26
+
27
+ end
28
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Button < Shoes::Drawable
5
+ shoes_styles :text, :width, :height, :top, :left, :color, :padding_top, :padding_bottom, :text_color, :size, :font_size, :tooltip
6
+ shoes_events :click
7
+
8
+ init_args :text
9
+ # Creates a new Button object.
10
+ #
11
+ # @param text [String] The text displayed on the button.
12
+ # @param width [Integer] The requested width of the button in pixels.
13
+ # @param height [Integer] The requested height of the button in pixels.
14
+ # @param top [Integer] The position of the top edge of the button relative to its parent widget.
15
+ # @param left [Integer] The position of the left edge of the button relative to its parent widget.
16
+ # @param size [Integer] The font size of the button text.
17
+ # @param color [String] The background color of the button.
18
+ # @param padding_top [Integer] The padding above the button text.
19
+ # @param padding_bottom [Integer] The padding below the button text.
20
+ # @param text_color [String] The color of the button text.
21
+ # @yield A block of code to be executed when the button is clicked.
22
+ # @return [Shoes::Button] the button object
23
+ #
24
+ # @example
25
+ # Shoes.app do
26
+ # @push = button "Push me"
27
+ # @note = para "Nothing pushed so far"
28
+ # @push.click {
29
+ # @note.replace(
30
+ # "Aha! Click! ",
31
+ # link("Go back") { @note.replace("Nothing pushed so far") }
32
+ # )
33
+ # }
34
+ # end
35
+ def initialize(*args, **kwargs, &block)
36
+ # Properties passed as positional args, not keywords, don't get auto-set
37
+ @block = block
38
+
39
+ super
40
+
41
+ # Bind block to a handler named "click"
42
+ bind_self_event("click") do
43
+ @log.debug("Button clicked, calling handler") if @block
44
+ @block&.call
45
+ end
46
+
47
+ create_display_drawable
48
+ end
49
+
50
+ # Set the click handler
51
+ #
52
+ # @yield A block to be called when the button is clicked.
53
+ def click(&block)
54
+ @block = block
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Check < Shoes::Drawable
5
+ shoes_styles :checked
6
+ shoes_events :click
7
+
8
+ init_args
9
+ opt_init_args :checked
10
+ def initialize(*args, **kwargs, &block)
11
+ @block = block
12
+ super
13
+
14
+ bind_self_event("click") do
15
+ self.checked = !checked?
16
+ @block.call(self) if @block
17
+ end
18
+ create_display_drawable
19
+ end
20
+
21
+ def click(&block)
22
+ @block = block
23
+ end
24
+
25
+ def checked?
26
+ @checked ? true : false
27
+ end
28
+
29
+ def checked(value)
30
+ self.checked = value
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class DocumentRoot < Shoes::Flow
5
+ shoes_events # No DocumentRoot-specific events yet
6
+
7
+ Shoes::Drawable.drawable_default_styles[Shoes::DocumentRoot][:height] = "100%"
8
+ Shoes::Drawable.drawable_default_styles[Shoes::DocumentRoot][:width] = "100%"
9
+
10
+ init_args
11
+ def initialize(**kwargs, &block)
12
+ super
13
+ end
14
+
15
+ # The default inspect string can be absolutely huge in console output, and it's frequently printed.
16
+ def inspect
17
+ "<Shoes::DocumentRoot>"
18
+ end
19
+ end
20
+ end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Shoes
4
- class EditBox < Shoes::Widget
5
- display_properties :text, :height, :width
3
+ class Shoes
4
+ class EditBox < Shoes::Drawable
5
+ shoes_styles :text, :height, :width ,:tooltip, :font
6
+ shoes_events :change
6
7
 
7
- def initialize(text = "", height: nil, width: nil, &block)
8
- @text = text
8
+ init_args
9
+ opt_init_args :text
10
+ def initialize(*args, **kwargs, &block)
9
11
  @callback = block
10
-
11
12
  super
12
13
 
13
14
  bind_self_event("change") do |new_text|
@@ -15,7 +16,7 @@ module Shoes
15
16
  @callback&.call(self)
16
17
  end
17
18
 
18
- create_display_widget
19
+ create_display_drawable
19
20
  end
20
21
 
21
22
  def change(&block)
@@ -23,7 +24,7 @@ module Shoes
23
24
  end
24
25
 
25
26
  def append(new_text)
26
- self.text = self.text + new_text
27
+ self.text = (self.text || "") + new_text
27
28
  end
28
29
  end
29
30
  end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Shoes
4
- class EditLine < Shoes::Widget
5
- display_properties :text, :width
3
+ class Shoes
4
+ class EditLine < Shoes::Drawable
5
+ shoes_styles :text, :width, :font, :tooltip, :stroke
6
+ shoes_events :change
6
7
 
7
- def initialize(text = "", width: nil, &block)
8
+ init_args
9
+ opt_init_args :text
10
+ def initialize(*args, **kwargs, &block)
8
11
  @block = block
9
- @text = text
10
-
11
12
  super
12
13
 
13
14
  bind_self_event("change") do |new_text|
@@ -15,7 +16,7 @@ module Shoes
15
16
  @block&.call(new_text)
16
17
  end
17
18
 
18
- create_display_widget
19
+ create_display_drawable
19
20
  end
20
21
 
21
22
  def change(&block)
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Flow < Shoes::Slot
5
+ include Shoes::Background
6
+
7
+ Shoes::Drawable.drawable_default_styles[Shoes::Flow][:width] = "100%"
8
+
9
+ shoes_events
10
+
11
+ def initialize(*args, **kwargs, &block)
12
+ super
13
+
14
+ # Create the display-side drawable *before* instance_eval, which will add child drawables with their display drawables
15
+ create_display_drawable
16
+
17
+ Shoes::App.instance.with_slot(self, &block) if block_given?
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,62 @@
1
+ module FontHelper
2
+
3
+ def parse_font(font)
4
+
5
+ input = font
6
+ regex = /\s+(?=(?:[^']*'[^']*')*[^']*$)(?![^']*,[^']*')/
7
+ result = input.split(regex)
8
+
9
+ fs = nil
10
+ fv = nil
11
+ fw = nil
12
+ fss = nil
13
+ ff = ""
14
+
15
+ fos = ["italic", "oblique"]
16
+ fov = ["small-caps", "initial", "inherit"]
17
+ fow = ["bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
18
+ foss = ["xx-small", "x-small", "small","large", "x-large", "xx-large", "smaller", "larger"]
19
+
20
+ result.each do |i|
21
+ if fos.include?(i)
22
+ fs = i
23
+ next
24
+ elsif fov.include?(i)
25
+ fv = i
26
+ next
27
+ elsif fow.include?(i)
28
+ fw = i
29
+ next
30
+ elsif foss.include?(i)
31
+ fss = i
32
+ next
33
+ else
34
+ if contains_number?(i)
35
+
36
+ fss=i;
37
+
38
+ elsif i != "normal" && i != "medium" && i.strip != ""
39
+
40
+ if ff == "Arial"
41
+
42
+ ff = i
43
+
44
+ else
45
+
46
+ ff = ff+" "+i
47
+
48
+ end
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ [fs, fv , fw , fss , ff.strip]
55
+ end
56
+
57
+ def contains_number?(str)
58
+
59
+ !!(str =~ /\d/)
60
+
61
+ end
62
+ end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Shoes
4
- class Image < Shoes::Widget
5
- display_properties :url, :width, :height, :top, :left, :click
6
-
7
- def initialize(url, width: nil, height: nil, top: nil, left: nil, click: nil)
8
- @url = url
3
+ class Shoes
4
+ class Image < Shoes::Drawable
5
+ shoes_styles :url, :width, :height, :top, :left, :click
6
+ shoes_events # No Image-specific events yet
9
7
 
8
+ init_args :url
9
+ def initialize(*args, **kwargs)
10
10
  super
11
11
 
12
12
  # Get the image dimensions
13
13
  # @width, @height = size
14
14
 
15
- create_display_widget
15
+ create_display_drawable
16
16
  end
17
17
 
18
18
  def replace(url)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Line < Shoes::Drawable
5
+ shoes_styles :left, :top, :x2, :y2, :draw_context
6
+ shoes_events # No Line-specific events yet
7
+
8
+ init_args :left, :top, :x2, :y2
9
+ def initialize(*args, **kwargs)
10
+ @draw_context = Shoes::App.instance.current_draw_context
11
+
12
+ super
13
+
14
+ create_display_drawable
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class Link < Shoes::TextDrawable
5
+ shoes_styles :text, :click, :has_block
6
+ shoes_events :click
7
+
8
+ #Shoes::Drawable.drawable_default_styles[Shoes::Link][:click] = "#"
9
+
10
+ init_args # Empty by the time it reaches Drawable#initialize
11
+ def initialize(*args, **kwargs, &block)
12
+ @block = block
13
+ # We can't send a block to the display drawable, but we can send a boolean
14
+ @has_block = !block.nil?
15
+
16
+ super
17
+
18
+ bind_self_event("click") do
19
+ @block&.call
20
+ end
21
+ end
22
+ end
23
+
24
+ # In Shoes, the LinkHover pseudo-class is used to set default styles for links when
25
+ # hovered over. The functionality isn't present in Lacci yet.
26
+ class LinkHover < Link
27
+ def initialize
28
+ raise "This class should never be instantiated directly! Use link, not link_hover!"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ class ListBox < Shoes::Drawable
5
+ shoes_styles :items, :height, :width
6
+
7
+ # Shoes3 uses choose as the initialize arg, and .choose(item) as the setter here,
8
+ # but queries it with .text. So this is an unusual style, and we've chosen this
9
+ # name not to conflict with Shoes3.
10
+ shoes_style :chosen
11
+
12
+ shoes_events :change
13
+
14
+ init_args # No positional args
15
+ def initialize(**kwargs, &block)
16
+ # These aren't being set as styles -- remove them from kwargs before calling super
17
+ # TODO: set [] as default value for items?
18
+ @items = kwargs.delete(:items) || []
19
+ @chosen = kwargs.delete(:choose) || @items&.first
20
+
21
+ super(**kwargs, &block)
22
+
23
+ bind_self_event("change") do |new_item|
24
+ self.chosen = new_item
25
+ @callback&.call(self)
26
+ end
27
+
28
+ create_display_drawable
29
+ end
30
+
31
+ # Select an item. `item` should be a text entry from `items`.
32
+ #
33
+ # @param item [String] the item to choose
34
+ # @return [void]
35
+ def choose(item)
36
+ unless self.items.include?(item)
37
+ raise Shoes::Errors::NoSuchListItemError, "List items (#{self.items.inspect}) do not contain item #{item.inspect}!"
38
+ end
39
+
40
+ @chosen = item
41
+ end
42
+
43
+ # The currently chosen text item or nil.
44
+ #
45
+ # @return [String|NilClass] the current text item or nil.
46
+ def text
47
+ @chosen
48
+ end
49
+
50
+ # Register a block to be called when the selection changes.
51
+ #
52
+ # @yield the block to be called when selection changes
53
+ # @return [Shoes::ListBox] self
54
+ def change(&block)
55
+ @callback = block
56
+ self # Allow chaining calls
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Shoes
4
+ # Docs: https://github.com/scarpe-team/scarpe/blob/main/docs/static/manual.md#ovalleft-top-radius--shoesshape
5
+ class Oval < Shoes::Drawable
6
+ shoes_styles :center, :draw_context, :stroke, :fill
7
+
8
+ shoes_style(:left) { |val| convert_to_integer(val, "left") }
9
+ shoes_style(:top) { |val| convert_to_integer(val, "top") }
10
+ shoes_style(:radius) { |val| convert_to_integer(val, "radius") }
11
+ shoes_style(:height) { |val| convert_to_integer(val, "height") }
12
+ shoes_style(:width) { |val| convert_to_integer(val, "width") }
13
+ shoes_style(:strokewidth) { |val| convert_to_integer(val, "strokewidth") }
14
+
15
+ Shoes::Drawable.drawable_default_styles[Shoes::Oval][:fill] = "black"
16
+ Shoes::Drawable.drawable_default_styles[Shoes::Oval][:stroke] = "black"
17
+
18
+ init_args :left, :top
19
+ opt_init_args :radius, :height
20
+ def initialize(*args, **options)
21
+ @draw_context = Shoes::App.instance.current_draw_context
22
+
23
+ super # Parse any positional or keyword args
24
+
25
+ unless @left && @top && (@width || @height || @radius)
26
+ raise Shoes::Errors::InvalidAttributeValueError, "Oval requires left, top and one of (width, height, radius) to be specified!"
27
+ end
28
+
29
+ # Calzini expects "radius" to mean the x-axis-aligned radius, not y-axis-aligned.
30
+ # For an axis-aligned oval the two may be different.
31
+
32
+ # If we have no width, but a radius, default the width to be the radius * 2
33
+ @width ||= @radius * 2 if @radius
34
+
35
+ # We now know we have width or height, but maybe not both.
36
+
37
+ # Default to a circle - set height from width or vice-versa
38
+ @width ||= @height
39
+ @height ||= @width
40
+
41
+ # If we don't have radius yet, set it from width
42
+ @radius ||= @width / 2
43
+
44
+ create_display_drawable
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,206 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'font_helper.rb'
3
+ class Shoes
4
+ class Para < Shoes::Drawable
5
+ include FontHelper
6
+ shoes_styles :text_items, :size, :family, :font_weight, :font, :font_variant, :emphasis, :kerning
7
+ shoes_style(:stroke) { |val, _name| Shoes::Colors.to_rgb(val) }
8
+ shoes_style(:fill) { |val, _name| Shoes::Colors.to_rgb(val) }
9
+
10
+ shoes_style(:align) do |val|
11
+ unless ["left", "center", "right"].include?(val)
12
+ raise(Shoes::Errors::InvalidAttributeValueError, "Align must be one of left, center or right!")
13
+ end
14
+ val
15
+ end
16
+
17
+ Shoes::Drawable.drawable_default_styles[Shoes::Para][:size] = :para
18
+
19
+ shoes_events # No Para-specific events yet
20
+
21
+ # Initializes a new instance of the `Para` drawable. There are different
22
+ # methods to instantiate slightly different styles of Para, such as
23
+ # `tagline`, `caption` and `subtitle`. These will always be different
24
+ # sizes, but may be generally styled differently for some display services.
25
+ #
26
+ # @param args The text content of the paragraph.
27
+ # @param kwargs [Hash] the various Shoes styles for this paragraph.
28
+ #
29
+ # @example
30
+ # Shoes.app do
31
+ # p = para "Hello, This is at the top!", stroke: red, size: :title, font: "Arial"
32
+ #
33
+ # banner("Welcome to Shoes!")
34
+ # title("Shoes Examples")
35
+ # subtitle("Explore the Features")
36
+ # tagline("Step into a World of Shoes")
37
+ # caption("A GUI Framework for Ruby")
38
+ # inscription("Designed for Easy Development")
39
+ #
40
+ # p.replace "On top we'll switch to ", strong("bold"), "!"
41
+ # end
42
+
43
+ def initialize(*args, **kwargs)
44
+
45
+ if kwargs[:font]
46
+ arr= parse_font(kwargs[:font])
47
+
48
+ if arr[0] != nil
49
+
50
+ kwargs[:emphasis] = arr[0]
51
+
52
+ end
53
+
54
+ if arr[1] != nil
55
+
56
+ kwargs[:font_variant] = arr[1]
57
+
58
+ end
59
+
60
+ if arr[2] != nil
61
+
62
+ kwargs[:font_weight] = arr[2]
63
+
64
+ end
65
+
66
+ if arr[3] != nil
67
+
68
+ kwargs[:size] = arr[3]
69
+
70
+ end
71
+
72
+ if arr[4] != ""
73
+
74
+ kwargs[:family] = arr[4]
75
+
76
+ end
77
+
78
+ end
79
+
80
+ # Don't pass text_children args to Drawable#initialize
81
+ super(*[], **kwargs)
82
+
83
+ # Text_children alternates strings and TextDrawables, so we can't just pass
84
+ # it as a Shoes style. It won't serialize.
85
+ update_text_children(args)
86
+
87
+ create_display_drawable
88
+ end
89
+
90
+
91
+
92
+ private
93
+
94
+ def text_children_to_items(text_children)
95
+ text_children.map { |arg| arg.is_a?(TextDrawable) ? arg.linkable_id : arg.to_s }
96
+ end
97
+
98
+ public
99
+
100
+ # Sets the paragraph text to a new value, which can
101
+ # include {TextDrawable}s like em(), strong(), etc.
102
+ #
103
+ # @param children [Array] the arguments can be Strings and/or TextDrawables
104
+ # @return [void]
105
+ def replace(*children)
106
+ update_text_children(children)
107
+ end
108
+
109
+ # Set the paragraph text to a single String.
110
+ # To use bold, italics, etc. use {Para#replace} instead.
111
+ #
112
+ # @param child [String] the new text to use for this Para
113
+ # @return [void]
114
+ def text=(*children)
115
+ update_text_children(children)
116
+ end
117
+
118
+ # Return the text, but not the styling, of the para's
119
+ # contents. For example, if the contents had strong
120
+ # and emphasized text, the bold and emphasized would
121
+ # be removed but the text would be returned.
122
+ #
123
+ # @return [String] the text from this para
124
+ def text
125
+ @text_children.map(&:to_s).join
126
+ end
127
+
128
+ # Return the text but not styling from the para. This
129
+ # is the same as #text.
130
+ #
131
+ # @return [String] the text from this para
132
+ def to_s
133
+ self.text
134
+ end
135
+
136
+ private
137
+
138
+ # Text_children alternates strings and TextDrawables, so we can't just pass
139
+ # it as a Shoes style. It won't serialize.
140
+ def update_text_children(children)
141
+ @text_children = children.flatten
142
+ # This should signal the display drawable to change
143
+ self.text_items = text_children_to_items(@text_children)
144
+ end
145
+
146
+
147
+ end
148
+ end
149
+
150
+ class Shoes
151
+ class Drawable
152
+ # Return a banner-sized para. This can use all the normal
153
+ # Para styles and arguments. See {Para#initialize} for
154
+ # details.
155
+ #
156
+ # @return [Shoes::Para] the new para drawable
157
+ def banner(*args, **kwargs)
158
+ para(*args, **{ size: :banner }.merge(kwargs))
159
+ end
160
+
161
+ # Return a title-sized para. This can use all the normal
162
+ # Para styles and arguments. See {Para#initialize} for
163
+ # details.
164
+ #
165
+ # @return [Shoes::Para] the new para drawable
166
+ def title(*args, **kwargs)
167
+ para(*args, **{ size: :title }.merge(kwargs))
168
+ end
169
+
170
+ # Return a subtitle-sized para. This can use all the normal
171
+ # Para styles and arguments. See {Para#initialize} for
172
+ # details.
173
+ #
174
+ # @return [Shoes::Para] the new para drawable
175
+ def subtitle(*args, **kwargs)
176
+ para(*args, **{ size: :subtitle }.merge(kwargs))
177
+ end
178
+
179
+ # Return a tagline-sized para. This can use all the normal
180
+ # Para styles and arguments. See {Para#initialize} for
181
+ # details.
182
+ #
183
+ # @return [Shoes::Para] the new para drawable
184
+ def tagline(*args, **kwargs)
185
+ para(*args, **{ size: :tagline }.merge(kwargs))
186
+ end
187
+
188
+ # Return a caption-sized para. This can use all the normal
189
+ # Para styles and arguments. See {Para#initialize} for
190
+ # details.
191
+ #
192
+ # @return [Shoes::Para] the new para drawable
193
+ def caption(*args, **kwargs)
194
+ para(*args, **{ size: :caption }.merge(kwargs))
195
+ end
196
+
197
+ # Return an inscription-sized para. This can use all the normal
198
+ # Para styles and arguments. See {Para#initialize} for
199
+ # details.
200
+ #
201
+ # @return [Shoes::Para] the new para drawable
202
+ def inscription(*args, **kwargs)
203
+ para(*args, **{ size: :inscription }.merge(kwargs))
204
+ end
205
+ end
206
+ end