Module: VER::Layout::Tiling

Included in:
HorizontalTiling, VerticalTiling
Defined in:
lib/ver/layout.rb

Constant Summary collapse

DEFAULT =
{ master: 1, stacking: 3 }

Instance Method Summary collapse

Instance Method Details

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



118
119
120
121
122
123
124
125
126
# File 'lib/ver/layout.rb', line 118

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

  limit = stacked.size == 0 ? 1.0 : 0.5

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

#apply_hidden(windows) ⇒ Object



128
129
130
# File 'lib/ver/layout.rb', line 128

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

#prepare(layout, options) ⇒ Object



111
112
113
114
115
116
# File 'lib/ver/layout.rb', line 111

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