Class: VER::Layout
- Inherits:
-
Tk::Tile::Frame
- Object
- Tk::Tile::Frame
- VER::Layout
show all
- Defined in:
- lib/ver/layout.rb
Defined Under Namespace
Modules: HorizontalTiling, Tiling, VerticalTiling
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parent, options = {}) ⇒ Layout
Returns a new instance of Layout.
5
6
7
8
9
10
11
12
13
|
# File 'lib/ver/layout.rb', line 5
def initialize(parent, options = {})
super
pack(fill: :both, expand: true)
@views = []
@options = {}
self.strategy = Layout::VerticalTiling
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3
4
5
|
# File 'lib/ver/layout.rb', line 3
def options
@options
end
|
#strategy ⇒ Object
Returns the value of attribute strategy.
3
4
5
|
# File 'lib/ver/layout.rb', line 3
def strategy
@strategy
end
|
#views ⇒ Object
Returns the value of attribute views.
3
4
5
|
# File 'lib/ver/layout.rb', line 3
def views
@views
end
|
Instance Method Details
#apply(options = {}) ⇒ Object
98
99
100
101
|
# File 'lib/ver/layout.rb', line 98
def apply(options = {})
@options.merge!(options)
strategy.apply(self, @options)
end
|
#close_view(view) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/ver/layout.rb', line 29
def close_view(view)
@views.delete view
view.destroy
if previous = @views.first
apply
previous.focus
else
VER.exit
end
end
|
#create_view {|view| ... } ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/ver/layout.rb', line 20
def create_view
view = View.new(self)
yield view
@views.unshift view
apply
view.focus
end
|
#focus_next(current) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/ver/layout.rb', line 41
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
49
50
51
52
53
54
55
56
|
# File 'lib/ver/layout.rb', line 49
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
103
104
105
106
|
# File 'lib/ver/layout.rb', line 103
def head_tail_hidden(options = {})
@options.merge!(options)
strategy.prepare(self, @options)
end
|
#push_bottom(view) ⇒ Object
93
94
95
96
|
# File 'lib/ver/layout.rb', line 93
def push_bottom(view)
@views.push(@views.delete(view))
apply
end
|
#push_down(current) ⇒ Object
called on #3 -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+ | | 2 | > | | 1 | > | | 3 | > | | 2 | | 1 -----
> | 3 -----
> | 1 -----
> | 1 -----
| | 3 | > | | 2 | > | | 2 | > | | 3 | -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+
79
80
81
82
83
84
85
86
|
# File 'lib/ver/layout.rb', line 79
def push_down(current)
return unless index = @views.index(current)
following = @views[index + 1] || @views[0]
current.raise(following)
@views[@views.index(following)], @views[index] = current, following
apply
end
|
#push_top(current) ⇒ Object
88
89
90
91
|
# File 'lib/ver/layout.rb', line 88
def push_top(current)
@views.unshift(@views.delete(current))
apply
end
|
#push_up(current) ⇒ Object
called on #3 -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+ | | 2 | > | | 3 | > | | 1 | > | | 1 | | 1 -----
> | 1 -----
> | 3 -----
> | 3 -----
| | 3 | > | | 2 | > | | 2 | > | | 2 | -----
—–+ > -----
—–+ > -----
—–+ > -----
—–+
64
65
66
67
68
69
70
71
|
# File 'lib/ver/layout.rb', line 64
def push_up(current)
return unless index = @views.index(current)
previous = @views[index - 1]
current.raise(previous)
@views[index - 1], @views[index] = current, previous
apply
end
|