class Split
—————————————————————————– #
File: SplitLayout.rb Description: Author: j kepler http://github.com/mare-imbrium/canis/ Date: 2014-05-10 - 13:48 License: MIT Last update: 2014-05-10 20:19
—————————————————————————– #
SplitLayout.rb Copyright (C) 2012-2014 j kepler ---- This layout allows for complex arrangements of stacks and flows. One can divide the layout into splits (vertical or horizontal) and keep dividing a split, or placing a component in it. However, to keep it simple and reduce the testing, I am insisting that a weightage be specified with a split. layout = SplitLayout.new :height => -1, :top_margin => 1, :bottom_margin => 1, :left_margin => 1 x, y = layout.vsplit( 0.30, 0.70) x.component = mylist y1, y2 = y.split( 0.40, 0.60 ) y2.component = mytable y11,y12,y13 = y1.vsplit( 0.3, 0.3, 0.4) y11 = list1 y12 = list2 y13 = list3 Or hopefully: layout.split(0.3, 0.7) do |x,y| x.component = mylist y.split(0.4, 0.6) do |a,b| b.component = mytable a.vsplit( 0.3, 0.3, 0.4) do | p,q,r | p.component = list1 end end end
Attributes
component[R]
height[RW]
left[RW]
name[RW]
parent[RW]
link to parent own weight
split_wts[RW]
weights of child splits, given in cons
splits[R]
top[RW]
type[R]
weight[RW]
link to parent own weight
width[RW]
Public Class Methods
new(type, weight, parent)
click to toggle source
# File lib/canis/core/include/layouts/SplitLayout.rb, line 52 def initialize type, weight, parent @type = type @weight = weight @parent = parent end
Public Instance Methods
_split(type, args) { |flatten| ... }
click to toggle source
# File lib/canis/core/include/layouts/SplitLayout.rb, line 57 def _split type, args, &block @split_wts = args @splits = [] args.each do |e| @splits << Split.new(type, e, self) end if block_given? yield @splits.flatten else return @splits.flatten end end
component=(c)
click to toggle source
Set a component into a split. set name of component as name of split, more for debugging
# File lib/canis/core/include/layouts/SplitLayout.rb, line 78 def component=(c) @component = c @name = c.name || c.class.to_s end
Also aliased as: <<
split(*args, &block)
click to toggle source
# File lib/canis/core/include/layouts/SplitLayout.rb, line 69 def split *args, &block _split :h, args, &block end
vsplit(*args, &block)
click to toggle source
# File lib/canis/core/include/layouts/SplitLayout.rb, line 72 def vsplit *args, &block _split :v, args, &block end