Class: Rooibos::Welcome::UI::ButtonAreas
- Inherits:
-
Data
- Object
- Data
- Rooibos::Welcome::UI::ButtonAreas
- Defined in:
- lib/rooibos/welcome.rb
Overview
Value object wrapping hit-test areas for clickable buttons.
Instance Attribute Summary collapse
-
#exit ⇒ Object
readonly
Returns the value of attribute exit.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Instance Method Summary collapse
Instance Attribute Details
#exit ⇒ Object (readonly)
Returns the value of attribute exit
147 148 149 |
# File 'lib/rooibos/welcome.rb', line 147 def exit @exit end |
#website ⇒ Object (readonly)
Returns the value of attribute website
147 148 149 |
# File 'lib/rooibos/welcome.rb', line 147 def website @website end |
Instance Method Details
#button_at(x, y) ⇒ Object
150 151 152 153 154 155 |
# File 'lib/rooibos/welcome.rb', line 150 def (x, y) return :website if website&.contains?(x, y) return :exit if exit&.contains?(x, y) nil end |
#contains?(name, x, y) ⇒ Boolean
148 |
# File 'lib/rooibos/welcome.rb', line 148 def contains?(name, x, y) = public_send(name)&.contains?(x, y) |
#for_viewport(width, height) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/rooibos/welcome.rb', line 157 def (width, height) = RatatuiRuby::Layout::Rect.new(x: 0, y: 0, width:, height:) frame = UI.frame(focused: nil, hovered: nil) inner = frame.inner() content_rects = RatatuiRuby::Layout::Layout.split( inner, direction: :vertical, constraints: CONTENT_CONSTRAINTS ) = RatatuiRuby::Layout::Layout.split( content_rects[1], direction: :horizontal, constraints: BUTTON_BAR_CONSTRAINTS ) ButtonAreas.new( website: [BUTTON_SLOTS[:website]], exit: [BUTTON_SLOTS[:exit]] ) end |