Class: VER::TilingLayout
- Inherits:
-
Tk::Tile::LabelFrame
- Object
- Tk::Tile::LabelFrame
- VER::TilingLayout
show all
- Defined in:
- lib/ver/layout/tiling.rb,
lib/ver/layout/tiling/common.rb,
lib/ver/layout/tiling/vertical.rb,
lib/ver/layout/tiling/horizontal.rb,
config/plugin/animated_tiling.rb
Defined Under Namespace
Modules: CommonTiling, HorizontalTiling, VerticalTiling
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent, options = {}) ⇒ TilingLayout
Returns a new instance of TilingLayout.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/ver/layout/tiling.rb', line 9
def initialize(parent, options = {})
super
pack(fill: :both, expand: true)
@stack = []
@options = {}
self.strategy = VerticalTiling
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7
8
9
|
# File 'lib/ver/layout/tiling.rb', line 7
def options
@options
end
|
#stack ⇒ Object
Returns the value of attribute stack.
7
8
9
|
# File 'lib/ver/layout/tiling.rb', line 7
def stack
@stack
end
|
#strategy ⇒ Object
Returns the value of attribute strategy.
7
8
9
|
# File 'lib/ver/layout/tiling.rb', line 7
def strategy
@strategy
end
|
Instance Method Details
#apply(options = {}) ⇒ Object
120
121
122
123
|
# File 'lib/ver/layout/tiling.rb', line 120
def apply(options = {})
@options.merge!(options)
strategy.apply(self, @options)
end
|
#close_buffer(buffer) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/ver/layout/tiling.rb', line 34
def close_buffer(buffer)
stack.delete(buffer)
buffer.destroy
if previous = stack.first
apply
previous.focus
else
VER.exit
end
end
|
#create_buffer(options = {}) {|buffer| ... } ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/ver/layout/tiling.rb', line 25
def create_buffer(options = {})
buffer = Buffer.new(self, options)
yield buffer
stack.unshift(buffer)
apply
buffer.focus
end
|
#cycle_next(current) ⇒ Object
106
107
108
109
110
111
|
# File 'lib/ver/layout/tiling.rb', line 106
def cycle_next(current)
return unless index = stack.index(current)
stack.push(stack.shift)
apply
stack[index].focus
end
|
#cycle_prev(current) ⇒ Object
113
114
115
116
117
118
|
# File 'lib/ver/layout/tiling.rb', line 113
def cycle_prev(current)
return unless index = stack.index(current)
stack.unshift(stack.pop)
apply
stack[index].focus
end
|
#focus_next(current) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/ver/layout/tiling.rb', line 46
def focus_next(current)
visible = head_tail_hidden.first(2).flatten
return unless index = visible.index(current)
found = visible[index + 1] || visible[0]
found.focus
end
|
#focus_prev(current) ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/ver/layout/tiling.rb', line 54
def focus_prev(current)
visible = head_tail_hidden.first(2).flatten
return unless index = visible.index(current)
found = visible[index - 1]
found.focus
end
|
#head_tail_hidden(options = {}) ⇒ Object
125
126
127
128
|
# File 'lib/ver/layout/tiling.rb', line 125
def head_tail_hidden(options = {})
@options.merge!(options)
strategy.prepare(self, @options).first(3)
end
|
#push_bottom(buffer) ⇒ Object
100
101
102
103
104
|
# File 'lib/ver/layout/tiling.rb', line 100
def push_bottom(buffer)
stack.push(stack.delete(buffer))
apply
stack.first.focus unless visible?(buffer)
end
|
#push_down(current) ⇒ Object
called on #3 -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+ | | 2 | > | | 1 | > | | 3 | > | | 2 | | 1 -----
> | 3 -----
> | 1 -----
> | 1 -----
| | 3 | > | | 2 | > | | 2 | > | | 3 | -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+
85
86
87
88
89
90
91
92
93
|
# File 'lib/ver/layout/tiling.rb', line 85
def push_down(current)
return unless index = stack.index(current)
following = stack[index + 1] || stack[0]
current.raise(following)
stack[stack.index(following)], stack[index] = current, following
apply
following.focus unless visible?(current)
end
|
#push_top(current) ⇒ Object
95
96
97
98
|
# File 'lib/ver/layout/tiling.rb', line 95
def push_top(current)
stack.unshift(stack.delete(current))
apply
end
|
#push_up(current) ⇒ Object
called on #3 -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+ | | 2 | > | | 3 | > | | 1 | > | | 1 | | 1 -----
> | 1 -----
> | 3 -----
> | 3 -----
| | 3 | > | | 2 | > | | 2 | > | | 2 | -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+
69
70
71
72
73
74
75
76
77
|
# File 'lib/ver/layout/tiling.rb', line 69
def push_up(current)
return unless index = stack.index(current)
previous = stack[index - 1]
current.raise(previous)
stack[index - 1], stack[index] = current, previous
apply
previous.focus unless visible?(current)
end
|
#visible?(buffer) ⇒ Boolean
130
131
132
133
|
# File 'lib/ver/layout/tiling.rb', line 130
def visible?(buffer)
visible = head_tail_hidden.first(2).flatten
visible.include?(buffer)
end
|