Module: VER::TilingLayout::CommonTiling

Included in:
HorizontalTiling, VerticalTiling
Defined in:
lib/ver/layout/tiling/common.rb,
config/plugin/animated_tiling.rb

Constant Summary collapse

DEFAULT =
{ master: 1, stacking: 3, center: 0.5 }

Instance Method Summary collapse

Instance Method Details

#apply(layout, given_options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/ver/layout/tiling/common.rb', line 15

def apply(layout, given_options = {})
  masters, stacked, hidden, options = prepare(layout, given_options)

  center = stacked.size == 0 ? 1.0 : options[:center]

  apply_hidden(hidden) if hidden
  apply_masters(masters, center) if masters
  apply_stacked(stacked, center) if stacked
end

#apply_hidden(*windows) ⇒ Object

animates hiding the given windows



20
21
22
# File 'config/plugin/animated_tiling.rb', line 20

def apply_hidden(windows)
  windows.each(&:place_forget)
end

#evolve(window, target) ⇒ Object

animates movement of an window to the position given as target



29
30
31
# File 'config/plugin/animated_tiling.rb', line 29

def evolve(window, target)
  window.place(target)
end

#prepare(layout, given_options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/ver/layout/tiling/common.rb', line 6

def prepare(layout, given_options)
  options = DEFAULT.merge(given_options)
  slaves = layout.stack
  master, stacking = options.values_at(:master, :stacking)
  given_options.merge!(options)
  head, tail, hidden = slaves[0...master], slaves[master..stacking], slaves[(stacking + 1)..-1]
  return head, tail, hidden, options
end