Module: Shoes::Common::Visibility
- Included in:
- UIElement, Swt::Arc, Swt::Arrow, Swt::Background, Swt::Border, Swt::Image, Swt::InputBox, Swt::Line, Swt::ListBox, Swt::Oval, Swt::Progress, Swt::Rect, Swt::Shape, Swt::Slot, Swt::Star, Swt::SwtButton, Swt::TextBlock
- Defined in:
- shoes-core/lib/shoes/common/visibility.rb
Instance Method Summary collapse
-
#hidden? ⇒ Boolean
(also: #hidden)
Root method for determining whether we’re visible or not, taking into account our parent chain’s visibility.
- #hidden_from_view? ⇒ Boolean
-
#hide ⇒ Object
Hides the element, so that it can’t be seen.
- #outside_parent_view? ⇒ Boolean
-
#show ⇒ Object
Reveals the element, if it is hidden.
-
#toggle ⇒ Object
Hides an element if it is shown.
- #visible? ⇒ Boolean
Instance Method Details
#hidden? ⇒ Boolean Also known as:
Root method for determining whether we’re visible or not, taking into account our parent chain’s visibility.
14 15 16 |
# File 'shoes-core/lib/shoes/common/visibility.rb', line 14 def hidden? (defined?(@parent) && @parent&.hidden?) || style[:hidden] end |
#hidden_from_view? ⇒ Boolean
24 25 26 |
# File 'shoes-core/lib/shoes/common/visibility.rb', line 24 def hidden_from_view? hidden? || outside_parent_view? end |
#hide ⇒ Object
Hides the element, so that it can’t be seen. See also #show and #toggle.
7 8 9 10 |
# File 'shoes-core/lib/shoes/common/visibility.rb', line 7 def hide style(hidden: true) self end |
#outside_parent_view? ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'shoes-core/lib/shoes/common/visibility.rb', line 28 def outside_parent_view? # Painted elements handle slot bounds themselves when painting return false if @parent.nil? || @parent.variable_height? || painted? # We hide when we're at all outside our parent's bounds !@parent.contains?(dimensions) end |
#show ⇒ Object
Reveals the element, if it is hidden. See also #hide and #toggle.
37 38 39 40 |
# File 'shoes-core/lib/shoes/common/visibility.rb', line 37 def show style(hidden: false) self end |
#toggle ⇒ Object
Hides an element if it is shown. Or shows the element, if it is hidden. See also #hide and #show.
44 45 46 47 |
# File 'shoes-core/lib/shoes/common/visibility.rb', line 44 def toggle style(hidden: !style[:hidden]) self end |
#visible? ⇒ Boolean
20 21 22 |
# File 'shoes-core/lib/shoes/common/visibility.rb', line 20 def visible? !hidden? end |