Class: UnderOs::UI::Sidebar

Inherits:
View
  • Object
show all
Defined in:
lib/under_os/ui/sidebar.rb

Constant Summary collapse

LOCATIONS =
[:top, :left, :right, :bottom]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Sidebar

Returns a new instance of Sidebar.



6
7
8
9
10
# File 'lib/under_os/ui/sidebar.rb', line 6

def initialize(options={})
  super

  self.location = options.delete(:location) if options.has_key?(:location)
end

Instance Method Details

#hiddenObject



37
38
39
# File 'lib/under_os/ui/sidebar.rb', line 37

def hidden
  !classNames.include?('visible')
end

#hideObject



31
32
33
34
35
# File 'lib/under_os/ui/sidebar.rb', line 31

def hide
  @_class_names -= ['visible']

  animate location => -slide_distance
end

#locationObject



12
13
14
# File 'lib/under_os/ui/sidebar.rb', line 12

def location
  @location || :bottom
end

#location=(value) ⇒ Object



16
17
18
19
# File 'lib/under_os/ui/sidebar.rb', line 16

def location=(value)
  @location = value.to_sym
  @location = nil if ! LOCATIONS.include?(@location)
end

#showObject



21
22
23
24
25
26
27
28
29
# File 'lib/under_os/ui/sidebar.rb', line 21

def show
  class_names = self.classNames
  class_names.reject!{ |n| LOCATIONS.include?(n.to_sym) }

  self.classNames = class_names + [location, 'visible']
  self.style = {location => -slide_distance, display: :block}

  animate location => 0
end

#slide_distanceObject



41
42
43
# File 'lib/under_os/ui/sidebar.rb', line 41

def slide_distance
  [:top, :bottom].include?(location) ? size.y : size.x
end