Method: Fidgit::Label#initialize
- Defined in:
- lib/fidgit/elements/label.rb
#initialize(text, options = {}) ⇒ Label
Returns a new instance of Label.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fidgit/elements/label.rb', line 57 def initialize(text, = {}) = { color: default(:color), justify: default(:justify), background_color: default(:background_color), border_color: default(:border_color), icon_options: {}, font_name: default(:font_name), font_height: default(:font_height), icon_position: default(:icon_position), }.merge! super() # Bit of a fudge since font info is managed circularly here! # By using a grid, we'll be able to turn it around easily (in theory). @contents = grid num_rows: 1, padding: 0, spacing_h: spacing_h, spacing_v: spacing_v, width: [:width], height: [:height], z: z do |contents| @text = TextLine.new(text, parent: contents, justify: [:justify], color: [:color], padding: 0, z: z, font_name: [:font_name], font_height: [:font_height], align_h: :fill, align_v: :center) end # Create an image frame, but don't show it unless there is an image in it. @icon = ImageFrame.new(nil, [:icon_options].merge(z: z, align: :center)) @icon.image = [:icon] self.icon_position = [:icon_position] end |