uh-layout 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uh/layout/column.rb +10 -2
- data/lib/uh/layout/container.rb +1 -0
- data/lib/uh/layout/version.rb +1 -1
- data/lib/uh/layout.rb +1 -1
- data/spec/uh/layout/column_spec.rb +25 -1
- data/spec/uh/layout/container_spec.rb +8 -0
- data/spec/uh/layout_spec.rb +2 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5eb173000501f534469ab6801bd388d44d309f3
|
4
|
+
data.tar.gz: 014263683a19cedca1cb588cbc65d5cfaafb0254
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a188d97b67af33cacf8466fb7216364ec782b74dc1688d1e27a0a08df31989c656e647a395dc03839b012d6412de4208a37f84a8f1095f20567d82e38a7a646
|
7
|
+
data.tar.gz: 8003a17f7f10d7a35df2510a9913b104f1ef4295873689d36cc8874926087d5590266588d01fde91fd38d28d5f16418e19f7ad9667192dfc1c9e159336e0a2ca
|
data/lib/uh/layout/column.rb
CHANGED
@@ -16,10 +16,10 @@ module Uh
|
|
16
16
|
|
17
17
|
attr_reader :geo, :clients, :mode
|
18
18
|
|
19
|
-
def initialize(geo)
|
19
|
+
def initialize(geo, mode: :stack)
|
20
20
|
@geo = geo.dup
|
21
21
|
@clients = Container.new
|
22
|
-
@mode =
|
22
|
+
@mode = mode
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_s
|
@@ -44,6 +44,14 @@ module Uh
|
|
44
44
|
MODES[@mode].new @clients, @geo
|
45
45
|
end
|
46
46
|
|
47
|
+
def client_swap(direction)
|
48
|
+
@clients.set direction
|
49
|
+
if @mode == :tile
|
50
|
+
arrange_clients
|
51
|
+
show_hide_clients
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
47
55
|
def arrange_clients
|
48
56
|
arranger.arrange
|
49
57
|
clients.each &:moveresize
|
data/lib/uh/layout/container.rb
CHANGED
data/lib/uh/layout/version.rb
CHANGED
data/lib/uh/layout.rb
CHANGED
@@ -3,9 +3,10 @@ module Uh
|
|
3
3
|
describe Column do
|
4
4
|
let(:geo) { build_geo }
|
5
5
|
let(:other_geo) { build_geo 640, 0, 320, 240 }
|
6
|
+
let(:mode) { :stack }
|
6
7
|
let(:client) { build_client }
|
7
8
|
let(:other_client) { build_client }
|
8
|
-
subject(:column) { described_class.new geo }
|
9
|
+
subject(:column) { described_class.new geo, mode: mode }
|
9
10
|
|
10
11
|
it 'has a copy to given geo' do
|
11
12
|
expect(column.geo).to eq(geo).and not_be geo
|
@@ -71,6 +72,29 @@ module Uh
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
75
|
+
describe '#client_swap' do
|
76
|
+
before { column << client << other_client }
|
77
|
+
|
78
|
+
it 'sends #set message to clients with given direction' do
|
79
|
+
expect(column.clients).to receive(:set).with :pred
|
80
|
+
column.client_swap :pred
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when column mode is tile' do
|
84
|
+
let(:mode) { :tile }
|
85
|
+
|
86
|
+
it 'arranges current column clients' do
|
87
|
+
expect(column).to receive :arrange_clients
|
88
|
+
column.client_swap :pred
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'shows and hides clients in current column' do
|
92
|
+
expect(column).to receive :show_hide_clients
|
93
|
+
column.client_swap :pred
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
74
98
|
describe '#arrange_clients' do
|
75
99
|
before { column << client << other_client }
|
76
100
|
|
@@ -173,6 +173,14 @@ module Uh
|
|
173
173
|
expect { container.set :pred }.not_to change { container.current }
|
174
174
|
end
|
175
175
|
end
|
176
|
+
|
177
|
+
context 'when entries count is less than 2' do
|
178
|
+
let(:entries) { %i[foo] }
|
179
|
+
|
180
|
+
it 'raises a RuntimeError' do
|
181
|
+
expect { container.set :pred }.to raise_error Layout::RuntimeError
|
182
|
+
end
|
183
|
+
end
|
176
184
|
end
|
177
185
|
|
178
186
|
describe '#swap' do
|
data/spec/uh/layout_spec.rb
CHANGED
@@ -353,15 +353,9 @@ module Uh
|
|
353
353
|
context 'with one column and two clients' do
|
354
354
|
before { layout << other_client << client }
|
355
355
|
|
356
|
-
it '
|
356
|
+
it 'sends #client_swap to current column with given direction' do
|
357
|
+
expect(layout.current_column).to receive(:client_swap).with :pred
|
357
358
|
layout.handle_client_swap :pred
|
358
|
-
expect(layout.current_column.clients.to_a)
|
359
|
-
.to eq [client, other_client]
|
360
|
-
end
|
361
|
-
|
362
|
-
it 'does not change current client' do
|
363
|
-
expect { layout.handle_client_swap :pred }
|
364
|
-
.not_to change { layout.current_client }
|
365
359
|
end
|
366
360
|
|
367
361
|
it 'updates widgets' do
|