Class: Glimmer::LibUI::AttributedString
- Inherits:
-
Object
- Object
- Glimmer::LibUI::AttributedString
- Defined in:
- lib/glimmer/libui/attributed_string.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#parent_proxy ⇒ Object
readonly
Returns the value of attribute parent_proxy.
-
#string ⇒ Object
Returns the value of attribute string.
Instance Method Summary collapse
- #area_proxy ⇒ Object
- #background(value = nil) ⇒ Object
- #color(value = nil) ⇒ Object
- #destroy ⇒ Object
- #draw(area_draw_params) ⇒ Object
- #font(value = nil) ⇒ Object
-
#initialize(keyword, parent_proxy, args, &block) ⇒ AttributedString
constructor
A new instance of AttributedString.
- #post_add_content ⇒ Object
- #redraw ⇒ Object
- #underline(value = nil) ⇒ Object
Constructor Details
#initialize(keyword, parent_proxy, args, &block) ⇒ AttributedString
Returns a new instance of AttributedString.
33 34 35 36 37 38 39 40 |
# File 'lib/glimmer/libui/attributed_string.rb', line 33 def initialize(keyword, parent_proxy, args, &block) @keyword = keyword @parent_proxy = parent_proxy @args = args @string = @args.first || '' @block = block post_add_content if @block.nil? end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
31 32 33 |
# File 'lib/glimmer/libui/attributed_string.rb', line 31 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
31 32 33 |
# File 'lib/glimmer/libui/attributed_string.rb', line 31 def block @block end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
31 32 33 |
# File 'lib/glimmer/libui/attributed_string.rb', line 31 def keyword @keyword end |
#parent_proxy ⇒ Object (readonly)
Returns the value of attribute parent_proxy.
31 32 33 |
# File 'lib/glimmer/libui/attributed_string.rb', line 31 def parent_proxy @parent_proxy end |
#string ⇒ Object
Returns the value of attribute string.
30 31 32 |
# File 'lib/glimmer/libui/attributed_string.rb', line 30 def string @string end |
Instance Method Details
#area_proxy ⇒ Object
85 86 87 |
# File 'lib/glimmer/libui/attributed_string.rb', line 85 def area_proxy @parent_proxy.parent_proxy end |
#background(value = nil) ⇒ Object
54 55 56 |
# File 'lib/glimmer/libui/attributed_string.rb', line 54 def background(value = nil) # UI.attributed_string_set_attribute(@parent_proxy.attributed_string, color_attribute, start, start + @string.size) end |
#color(value = nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/glimmer/libui/attributed_string.rb', line 46 def color(value = nil) if value.nil? @color else @color = Glimmer::LibUI.interpret_color(value) end end |
#destroy ⇒ Object
77 78 79 |
# File 'lib/glimmer/libui/attributed_string.rb', line 77 def destroy @parent_proxy&.children&.delete(self) end |
#draw(area_draw_params) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/glimmer/libui/attributed_string.rb', line 68 def draw(area_draw_params) @start = ::LibUI.attributed_string_len(@parent_proxy.attributed_string) ::LibUI.attributed_string_append_unattributed(@parent_proxy.attributed_string, @string) unless color.nil? color_attribute = ::LibUI.new_color_attribute(@color[:r], @color[:g], @color[:b], @color[:a] || 1.0) ::LibUI.attributed_string_set_attribute(@parent_proxy.attributed_string, color_attribute, @start, @start + @string.size) end end |
#font(value = nil) ⇒ Object
42 43 44 |
# File 'lib/glimmer/libui/attributed_string.rb', line 42 def font(value = nil) # UI.attributed_string_set_attribute(@parent_proxy.attributed_string, color_attribute, start, start + @string.size) end |
#post_add_content ⇒ Object
62 63 64 65 66 |
# File 'lib/glimmer/libui/attributed_string.rb', line 62 def post_add_content block_result = block&.call @string = block_result if block_result.is_a?(String) @parent_proxy&.post_initialize_child(self) end |
#redraw ⇒ Object
81 82 83 |
# File 'lib/glimmer/libui/attributed_string.rb', line 81 def redraw area_proxy&.queue_redraw_all end |
#underline(value = nil) ⇒ Object
58 59 60 |
# File 'lib/glimmer/libui/attributed_string.rb', line 58 def underline(value = nil) # UI.attributed_string_set_attribute(@parent_proxy.attributed_string, color_attribute, start, start + @string.size) end |