MINT-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +69 -0
- data/History.txt +3 -0
- data/MINT-core.gemspec +58 -0
- data/Manifest.txt +77 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +63 -0
- data/Rakefile +29 -0
- data/bin/mint-aui +40 -0
- data/bin/mint-cui-gfx +47 -0
- data/bin/mint-juggernaut.sh +4 -0
- data/bin/mint-tuplespace +12 -0
- data/lib/MINT-core.rb +42 -0
- data/lib/MINT-core/agent/agent.rb +28 -0
- data/lib/MINT-core/agent/aui.rb +52 -0
- data/lib/MINT-core/agent/auicontrol.rb +135 -0
- data/lib/MINT-core/agent/cui-gfx.rb +160 -0
- data/lib/MINT-core/agent/cuicontrol.rb +46 -0
- data/lib/MINT-core/mapping/complementary.rb +100 -0
- data/lib/MINT-core/mapping/mapping.rb +47 -0
- data/lib/MINT-core/mapping/on_state_change.rb +65 -0
- data/lib/MINT-core/mapping/sequential.rb +87 -0
- data/lib/MINT-core/model/aui/AIC.rb +86 -0
- data/lib/MINT-core/model/aui/AIChoice.rb +65 -0
- data/lib/MINT-core/model/aui/AIINChoose.rb +54 -0
- data/lib/MINT-core/model/aui/AIMultiChoice.rb +5 -0
- data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +56 -0
- data/lib/MINT-core/model/aui/AIO.rb +170 -0
- data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +43 -0
- data/lib/MINT-core/model/aui/AISingleChoice.rb +9 -0
- data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +69 -0
- data/lib/MINT-core/model/aui/AISinglePresence.rb +100 -0
- data/lib/MINT-core/model/aui/aic.png +0 -0
- data/lib/MINT-core/model/aui/aic.scxml +50 -0
- data/lib/MINT-core/model/aui/aichoice.png +0 -0
- data/lib/MINT-core/model/aui/aichoice.scxml +60 -0
- data/lib/MINT-core/model/aui/aio.png +0 -0
- data/lib/MINT-core/model/aui/aio.scxml +43 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +71 -0
- data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
- data/lib/MINT-core/model/aui/aisinglepresence.scxml +58 -0
- data/lib/MINT-core/model/aui/model.rb +50 -0
- data/lib/MINT-core/model/body/gesture_button.rb +26 -0
- data/lib/MINT-core/model/body/handgesture.rb +279 -0
- data/lib/MINT-core/model/body/head.png +0 -0
- data/lib/MINT-core/model/body/head.rb +51 -0
- data/lib/MINT-core/model/body/head.scxml +28 -0
- data/lib/MINT-core/model/cui/gfx/CIC.rb +266 -0
- data/lib/MINT-core/model/cui/gfx/CIO.rb +381 -0
- data/lib/MINT-core/model/cui/gfx/model.rb +204 -0
- data/lib/MINT-core/model/cui/gfx/screen.rb +18 -0
- data/lib/MINT-core/model/device/button.rb +20 -0
- data/lib/MINT-core/model/device/joypad.rb +30 -0
- data/lib/MINT-core/model/device/mouse.rb +171 -0
- data/lib/MINT-core/model/device/pointer.rb +85 -0
- data/lib/MINT-core/model/device/wheel.rb +51 -0
- data/lib/MINT-core/model/interactor.rb +167 -0
- data/lib/MINT-core/model/task.rb +71 -0
- data/lib/MINT-core/overrides/rinda.rb +34 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/AIC_spec.rb +69 -0
- data/spec/AISinglePresence_spec.rb +94 -0
- data/spec/MINT-core_spec.rb +11 -0
- data/spec/aio_agent_spec.rb +234 -0
- data/spec/aio_spec.rb +144 -0
- data/spec/aisinglechoice_spec.rb +152 -0
- data/spec/aisinglechoiceelement_spec.rb +106 -0
- data/spec/cio_spec.rb +369 -0
- data/spec/core_spec.rb +29 -0
- data/spec/music_spec.rb +179 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +227 -0
@@ -0,0 +1,152 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'SingleChoice' do
|
4
|
+
before :each do
|
5
|
+
connection_options = { :adapter => "in_memory"}
|
6
|
+
DataMapper.setup(:default, connection_options)
|
7
|
+
class CallbackContext
|
8
|
+
attr_accessor :called
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@called = nil
|
12
|
+
end
|
13
|
+
def focus_next
|
14
|
+
@called = "focus_next"
|
15
|
+
end
|
16
|
+
def sync_cio_to_displayed
|
17
|
+
@called = "sync_cio_to_displayed"
|
18
|
+
end
|
19
|
+
def sync_cio_to_highlighted
|
20
|
+
@called = "sync_cio_to_highlighted"
|
21
|
+
end
|
22
|
+
def sync_cio_to_listed
|
23
|
+
@called = "sync_cio_to_listed"
|
24
|
+
end
|
25
|
+
def sync_cio_to_hidden
|
26
|
+
@caledled = "sync_cio_to_hidden"
|
27
|
+
end
|
28
|
+
def exists_next
|
29
|
+
true
|
30
|
+
end
|
31
|
+
def exists_prev
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
@callback = CallbackContext.new
|
36
|
+
|
37
|
+
@sc =MINT::AISingleChoice.new(:name => "choice",
|
38
|
+
:childs => [
|
39
|
+
MINT::AISingleChoiceElement.new(:name => "element_1"),
|
40
|
+
MINT::AISingleChoiceElement.new(:name => "element_2"),
|
41
|
+
MINT::AISingleChoiceElement.new(:name => "element_3"),
|
42
|
+
MINT::AISingleChoiceElement.new(:name => "element_4")]
|
43
|
+
)
|
44
|
+
AUIControl.organize(@sc,nil, 0)
|
45
|
+
@sc.save
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "child relations" do
|
49
|
+
before :each do
|
50
|
+
@sc.process_event(:present).should == [:defocused, :listing]
|
51
|
+
@sc.states.should == [:defocused, :listing]
|
52
|
+
|
53
|
+
@e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
|
54
|
+
@e2 = MINT::AISingleChoiceElement.first(:name => "element_2")
|
55
|
+
@e3 = MINT::AISingleChoiceElement.first(:name => "element_3")
|
56
|
+
@e4 = MINT::AISingleChoiceElement.first(:name => "element_4")
|
57
|
+
|
58
|
+
@e1.process_event(:present)
|
59
|
+
@e2.process_event(:present)
|
60
|
+
@e3.process_event(:present)
|
61
|
+
@e4.process_event(:present)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should deactivate other chosen elements on choose' do
|
65
|
+
@e1.process_event(:focus).should == [:focused, :unchosen]
|
66
|
+
@e1.new_states.should == [:focused]
|
67
|
+
|
68
|
+
@e1.process_event(:choose).should == [:focused, :chosen]
|
69
|
+
@e2.process_event(:choose).should == [:defocused, :chosen]
|
70
|
+
|
71
|
+
|
72
|
+
# TODO: state actualization should be done withnt :suspend, out re-querying?
|
73
|
+
@e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
|
74
|
+
@e1.states.should == [:focused, :unchosen]
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should accept drag event in unchosen or chosen' do
|
79
|
+
@e1.process_event(:focus).should == [:focused, :unchosen]
|
80
|
+
@e1.states.should == [:focused, :unchosen]
|
81
|
+
|
82
|
+
@e1.process_event(:drag).should == [:dragging, :chosen]
|
83
|
+
@e1.states.should == [:dragging, :chosen]
|
84
|
+
|
85
|
+
@e1.process_event(:drop).should == [:defocused, :chosen]
|
86
|
+
@e1.states.should == [:defocused, :chosen]
|
87
|
+
|
88
|
+
@e1.process_event(:focus).should == [:focused, :chosen]
|
89
|
+
@e1.states.should == [:focused, :chosen]
|
90
|
+
|
91
|
+
@e1.process_event(:drag).should == [:dragging, :chosen]
|
92
|
+
@e1.states.should == [:dragging, :chosen]
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should hide child elements on suspend' do
|
96
|
+
sc =MINT::AISingleChoice.first(:name => "choice")
|
97
|
+
sc.process_event(:suspend).should == [:suspended]
|
98
|
+
e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
|
99
|
+
e1.states.should == [:suspended]
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should hide if suspend is called from parent AIC' do
|
103
|
+
sc =MINT::AISingleChoice.first(:name => "choice")
|
104
|
+
|
105
|
+
aic = MINT::AIC.create(:name => "container", :states=>[:defocused],:childs =>[sc])
|
106
|
+
|
107
|
+
aic.process_event(:suspend).should == [:suspended]
|
108
|
+
e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
|
109
|
+
e1.states.should == [:suspended]
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should sync suspend to CUI" do
|
113
|
+
MINT::RadioButtonGroup.create(:name =>"choice", :states => [:presenting,:listed])
|
114
|
+
MINT::Selectable.create(:name =>"element_1", :states =>[:displayed,:listed])
|
115
|
+
MINT::Selectable.create(:name =>"element_2", :states =>[:displayed,:listed])
|
116
|
+
MINT::Selectable.create(:name =>"element_3", :states =>[:displayed,:listed])
|
117
|
+
MINT::Selectable.create(:name =>"element_4", :states =>[:displayed,:listed])
|
118
|
+
|
119
|
+
|
120
|
+
sc =MINT::AISingleChoice.first(:name => "choice")
|
121
|
+
|
122
|
+
aic = MINT::AIC.create(:name => "container", :states=>[:defocused],:childs =>[sc])
|
123
|
+
|
124
|
+
aic.process_event(:suspend).should == [:suspended]
|
125
|
+
e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
|
126
|
+
e1.states.should == [:suspended]
|
127
|
+
|
128
|
+
s4=MINT::Selectable.first(:name =>"element_4")
|
129
|
+
s4.states.should ==[:hidden]
|
130
|
+
rbg = MINT::RadioButtonGroup.first(:name=>"choice")
|
131
|
+
rbg.states.should == [:hidden]
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should remove elements that have been dropped elsewhere" do
|
135
|
+
pending("get drop from drag n drop working")
|
136
|
+
sc =MINT::AISingleChoice.first(:name => "choice")
|
137
|
+
e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
|
138
|
+
e1.process_event(:drag)
|
139
|
+
#e1.process_event(:drop)
|
140
|
+
dest =MINT::AISingleChoice.create(:name => "choice_dest",:states => [:defocused,:unchosen])
|
141
|
+
dest.process_event(:drop)
|
142
|
+
#dest.childs << e1
|
143
|
+
#p dest.childs.save
|
144
|
+
sc.childs.length.should ==3
|
145
|
+
dest.childs.length.should ==1
|
146
|
+
p sc.childs.inspect
|
147
|
+
e1 = MINT::AISingleChoiceElement.first(:name => "element_1").should_not == nil
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'SingleChoiceElement' do
|
4
|
+
before :each do
|
5
|
+
connection_options = { :adapter => "in_memory"}
|
6
|
+
DataMapper.setup(:default, connection_options)
|
7
|
+
@a = MINT::AISingleChoiceElement.create(:name => "test")
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should initialize with initiated' do
|
11
|
+
@a.states.should == [:initialized]
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should transform to organizing state for present action' do
|
15
|
+
@a.process_event(:organize).should == [:organized]
|
16
|
+
@a.states.should == [:organized]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should call back after event has been processed' do
|
20
|
+
class CallbackContext
|
21
|
+
attr_accessor :called
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@called = false
|
25
|
+
end
|
26
|
+
def focus_next
|
27
|
+
@called = true
|
28
|
+
end
|
29
|
+
def sync_cio_to_displayed
|
30
|
+
end
|
31
|
+
def sync_cio_to_highlighted
|
32
|
+
end
|
33
|
+
def sync_cio_to_listed
|
34
|
+
end
|
35
|
+
def exists_next
|
36
|
+
true
|
37
|
+
end
|
38
|
+
def exists_prev
|
39
|
+
true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
callback = CallbackContext.new
|
44
|
+
|
45
|
+
|
46
|
+
@a.process_event(:organize,callback).should == [:organized]
|
47
|
+
callback.called.should == false
|
48
|
+
|
49
|
+
@a.process_event(:present,callback).should == [:defocused, :unchosen]
|
50
|
+
@a.states.should == [:defocused, :unchosen]
|
51
|
+
@a.new_states.should == [:defocused, :unchosen, :p_t, :presenting, :selection_H]
|
52
|
+
callback.called.should == false
|
53
|
+
|
54
|
+
@a.process_event(:focus,callback).should == [:focused, :unchosen]
|
55
|
+
@a.new_states.should == [:focused]
|
56
|
+
callback.called.should == false
|
57
|
+
|
58
|
+
@a.process_event(:next,callback).should == [:defocused, :unchosen]
|
59
|
+
@a.new_states.should == [:defocused]
|
60
|
+
callback.called.should == true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should recover state after save and reload' do
|
64
|
+
@a.process_event(:organize).should == [:organized]
|
65
|
+
@a.save!
|
66
|
+
b = MINT::AIO.first(:name=>"test")
|
67
|
+
b.states.should == [:organized]
|
68
|
+
b.new_states.should == [:organized]
|
69
|
+
b.process_event(:present).should == [:defocused, :unchosen]
|
70
|
+
b.new_states.should == [:defocused, :unchosen, :p_t, :presenting, :selection_H]
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should recover state after save and reload from inside parallel state' do
|
75
|
+
@a.process_event(:organize).should == [:organized]
|
76
|
+
@a.process_event(:present).should == [:defocused, :unchosen]
|
77
|
+
@a.process_event(:focus).should == [:focused, :unchosen]
|
78
|
+
@a.save!
|
79
|
+
b = MINT::AIO.first(:name=>"test")
|
80
|
+
b.states.should ==[:focused, :unchosen]
|
81
|
+
b.process_event(:defocus).should == [:defocused, :unchosen]
|
82
|
+
#b.process_event(:choose).should == [:presented, :choosing]
|
83
|
+
end
|
84
|
+
it 'should support for query-based selection' do
|
85
|
+
@a.process_event(:organize).should == [:organized]
|
86
|
+
@a.process_event(:present).should == [:defocused, :unchosen]
|
87
|
+
@a.save!
|
88
|
+
b = MINT::AIO.first(:states=>/unchosen/)
|
89
|
+
b.name.should == "test"
|
90
|
+
c = MINT::AIO.first(:states=>/defocused/)
|
91
|
+
c.name.should == "test"
|
92
|
+
end
|
93
|
+
it 'should support for querying for superstates' do
|
94
|
+
@a.process_event(:organize).should == [:organized]
|
95
|
+
@a.process_event(:present).should == [:defocused, :unchosen]
|
96
|
+
@a.save!
|
97
|
+
puts @a.abstract_states
|
98
|
+
b = MINT::AIO.first(:abstract_states=>/presenting/)
|
99
|
+
b.name.should == "test"
|
100
|
+
end
|
101
|
+
it "should save abstract states property upon initial element creation" do
|
102
|
+
@a = MINT::AISingleChoiceElement.create(:name => "test")
|
103
|
+
puts @a.abstract_states
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
data/spec/cio_spec.rb
ADDED
@@ -0,0 +1,369 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'CUI' do
|
4
|
+
before :each do
|
5
|
+
connection_options = { :adapter => "in_memory"}
|
6
|
+
DataMapper.setup(:default, connection_options)
|
7
|
+
# DataMapper.setup(:default, { :adapter => "rinda",:local =>Rinda::TupleSpace.new})
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'CIO' do
|
12
|
+
before :each do
|
13
|
+
@up = MINT::CIO.create(:name => "up")
|
14
|
+
@down = MINT::CIO.create(:name => "down")
|
15
|
+
@left = MINT::CIO.create(:name => "left")
|
16
|
+
@right = MINT::CIO.create(:name => "right")
|
17
|
+
@center = MINT::CIO.create(:name => "center",:left=>@left,:right =>@right,:up =>@up, :down=>@down)
|
18
|
+
@down.up = @center
|
19
|
+
@up.down = @center
|
20
|
+
@left.right = @center
|
21
|
+
@right.left = @center
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should initialize with initiated' do
|
25
|
+
@center.states.should == [:initialized]
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should transform to display state after sequence of position,calculate, ready events ' do
|
29
|
+
@center.process_event(:position).should ==[:positioning]
|
30
|
+
@center.process_event(:calculated).should ==[:positioned]
|
31
|
+
@center.process_event(:display).should ==[:displayed]
|
32
|
+
@center.states.should == [:displayed]
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
describe "highlighting" do
|
38
|
+
before :each do
|
39
|
+
@up.states=[:displayed]
|
40
|
+
@down.states=[:displayed]
|
41
|
+
@left.states=[:displayed]
|
42
|
+
@right.states=[:displayed]
|
43
|
+
@center.states=[:highlighted]
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should move highlight to up and down' do
|
47
|
+
@center.process_event("up").should ==[:displayed]
|
48
|
+
@up.states.should ==[:highlighted]
|
49
|
+
|
50
|
+
@up.process_event("down").should == [:displayed]
|
51
|
+
@center.states.should ==[:highlighted]
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should move highlight to left and right' do
|
55
|
+
@center.process_event("left").should ==[:displayed]
|
56
|
+
@left.states.should ==[:highlighted]
|
57
|
+
|
58
|
+
@left.process_event("right").should == [:displayed]
|
59
|
+
@center.states.should ==[:highlighted]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "sync with AUI" do
|
64
|
+
before :each do
|
65
|
+
|
66
|
+
@up.states=[:displayed]
|
67
|
+
@down.states=[:displayed]
|
68
|
+
@left.states=[:displayed]
|
69
|
+
@right.states=[:displayed]
|
70
|
+
@center.states=[:highlighted]
|
71
|
+
|
72
|
+
@a_left = MINT::AIO.new(:name => "left",:states =>[:defocused])
|
73
|
+
@a_left.save!
|
74
|
+
|
75
|
+
@a_right = MINT::AIO.new(:name => "right",:states =>[:defocused])
|
76
|
+
@a_right.save!
|
77
|
+
@a_up = MINT::AIO.new(:name => "up",:states =>[:defocused])
|
78
|
+
@a_up.save!
|
79
|
+
@a_down = MINT::AIO.new(:name => "down",:states =>[:defocused])
|
80
|
+
@a_down.save!
|
81
|
+
@a_center = MINT::AIO.new(:name => "center",:states =>[:focused], :next =>@a_down)
|
82
|
+
@a_center.save!
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should sync highlight movements to AUI' do
|
87
|
+
@center.process_event(:left).should ==[:displayed]
|
88
|
+
MINT::AIO.first(:name=>"center").states.should ==[:defocused]
|
89
|
+
MINT::AIO.first(:name=>"left").states.should ==[:focused]
|
90
|
+
@left.states.should ==[:highlighted]
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should sync AUI focus movements to CUI' do
|
94
|
+
@center.save!
|
95
|
+
@down.save!
|
96
|
+
@a_center.process_event("next").should ==[:defocused]
|
97
|
+
@a_down.states.should ==[:focused]
|
98
|
+
MINT::CIO.first(:name=>"center").states.should ==[:displayed]
|
99
|
+
MINT::CIO.first(:name=>"down").states.should ==[:highlighted]
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should calculate its minimum size' do
|
103
|
+
@center.text="Hello world!"
|
104
|
+
@center.calculateMinimumSize
|
105
|
+
@center.minwidth.should==77
|
106
|
+
@center.minheight.should==26
|
107
|
+
end
|
108
|
+
|
109
|
+
def checkSizes(cio,x,y,width,height)
|
110
|
+
cio.x.should == x
|
111
|
+
cio.y.should == y
|
112
|
+
cio.width.should == width
|
113
|
+
cio.height.should ==height
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "layout calculation" do
|
117
|
+
before :each do
|
118
|
+
@solver = Cassowary::ClSimplexSolver.new
|
119
|
+
|
120
|
+
@up.states=[:initialized]
|
121
|
+
@down.states=[:initialized]
|
122
|
+
@left.states=[:initialized]
|
123
|
+
@right.states=[:initialized]
|
124
|
+
|
125
|
+
|
126
|
+
@a_left.states=[:organized]
|
127
|
+
@a_right.states=[:organized]
|
128
|
+
@a_up.states=[:organized]
|
129
|
+
@a_down.states=[:organized]
|
130
|
+
end
|
131
|
+
it "should calculate sizes for CIC" do
|
132
|
+
a_parent = MINT::AIC.new(:name=>"parent", :childs =>[@a_left,@a_right,@a_up,@a_down])
|
133
|
+
a_parent.save!
|
134
|
+
|
135
|
+
parent_cic = MINT::CIC.create(:name =>"parent",:cols=>2,:rows=>2,:x=>0,:y=>0,:width=>800,:height=>600)
|
136
|
+
|
137
|
+
parent_cic.calculate_container(@solver,10)
|
138
|
+
|
139
|
+
checkSizes(MINT::CIO.first(:name=>"left"),10,10,385,285)
|
140
|
+
checkSizes(MINT::CIO.first(:name=>"right"),405,10,385,285)
|
141
|
+
checkSizes(MINT::CIO.first(:name=>"up"),10,305,385,285)
|
142
|
+
checkSizes(MINT::CIO.first(:name=>"down"),405,305,385,285)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should calculate sizes for nested CICs" do
|
146
|
+
a_top = MINT::AIC.new(:name=>"top", :childs =>[
|
147
|
+
MINT::AIC.new(:name=>"parent_left", :childs =>[@a_left,@a_right,@a_up,@a_down],:states =>[:organized]),
|
148
|
+
MINT::AIC.new(:name=>"parent_right",:states =>[:organized])
|
149
|
+
])
|
150
|
+
a_top.save
|
151
|
+
|
152
|
+
top_cic = MINT::CIC.create(:name =>"top",:cols=>2,:rows=>1,:x=>0,:y=>0,:width=>800,:height=>600)
|
153
|
+
parent_left_cic = MINT::CIC.create(:name =>"parent_left",:cols=>2,:rows=>2)
|
154
|
+
parent_right_cic = MINT::CIC.create(:name =>"parent_right",:cols=>2,:rows=>2)
|
155
|
+
|
156
|
+
top_cic.calculate_container(@solver,10)
|
157
|
+
|
158
|
+
checkSizes(MINT::CIO.first(:name=>"parent_left"),10,10,385,580)
|
159
|
+
checkSizes(MINT::CIO.first(:name=>"parent_right"),405,10,385,580)
|
160
|
+
|
161
|
+
checkSizes(MINT::CIO.first(:name=>"left"),20,20,177,275)
|
162
|
+
checkSizes(MINT::CIO.first(:name=>"right"),207,20,177,275)
|
163
|
+
checkSizes(MINT::CIO.first(:name=>"up"),20,305,177,275)
|
164
|
+
checkSizes(MINT::CIO.first(:name=>"down"),207,305,177,275)
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should consider CIC definitions without column or row definition to be positioned vertically" do
|
169
|
+
|
170
|
+
a_top = MINT::AIC.new(:name=>"top", :childs =>[
|
171
|
+
MINT::AIC.new(:name=>"parent_left", :childs =>[@a_left,@a_right],:states =>[:organized]),
|
172
|
+
MINT::AIC.new(:name=>"parent_right",:states =>[:organized])
|
173
|
+
])
|
174
|
+
a_top.save!
|
175
|
+
|
176
|
+
top_cic = MINT::CIC.create(:name =>"top",:x=>0,:y=>0,:width=>800,:height=>800)
|
177
|
+
parent_left_cic = MINT::CIC.create(:name =>"parent_left").save!
|
178
|
+
parent_right_cic = MINT::CIC.create(:name =>"parent_right").save!
|
179
|
+
|
180
|
+
top_cic.calculate_container(@solver,10)
|
181
|
+
|
182
|
+
checkSizes(MINT::CIO.first(:name=>"parent_left"),10,10,780,385)
|
183
|
+
checkSizes(MINT::CIO.first(:name=>"parent_right"),10,405,780,385)
|
184
|
+
|
185
|
+
checkSizes(MINT::CIO.first(:name=>"left"),20,20,760,177)
|
186
|
+
checkSizes(MINT::CIO.first(:name=>"right"),20,207,760,177)
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should create CIC definitions that are missing and position them vertically vertically" do
|
191
|
+
|
192
|
+
a_top = MINT::AIC.new(:name=>"top", :childs =>[
|
193
|
+
MINT::AIC.new(:name=>"parent_left", :childs =>[@a_left,@a_right],:states =>[:organized]),
|
194
|
+
MINT::AIC.new(:name=>"parent_right",:states =>[:organized])
|
195
|
+
])
|
196
|
+
a_top.save!
|
197
|
+
|
198
|
+
top_cic = MINT::CIC.create(:name =>"top",:x=>0,:y=>0,:width=>800,:height=>800)
|
199
|
+
|
200
|
+
top_cic.calculate_container(@solver,10)
|
201
|
+
|
202
|
+
checkSizes(MINT::CIO.first(:name=>"parent_left"),10,10,780,385)
|
203
|
+
checkSizes(MINT::CIO.first(:name=>"parent_right"),10,405,780,385)
|
204
|
+
|
205
|
+
checkSizes(MINT::CIO.first(:name=>"left"),20,20,760,177)
|
206
|
+
checkSizes(MINT::CIO.first(:name=>"right"),20,207,760,177)
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should handle nested AIC definitions" do
|
211
|
+
|
212
|
+
MINT::AIC.new(:name=>"RecipeFinder_content",:states =>[:organized],
|
213
|
+
:childs =>[
|
214
|
+
MINT::AIC.new(:name=>"RecipeFilter",:states =>[:organized],
|
215
|
+
:childs => [
|
216
|
+
MINT::AIC.new(:name=>"RecipeFilter_description1",:states =>[:organized],
|
217
|
+
:childs =>[
|
218
|
+
MINT::AIINReference.new(:name=>"RecipeFilter_label",:label=>"Suchkriterien",:states =>[:organized]),
|
219
|
+
MINT::AIOUTContext.new(:name=>"RecipeFilter_description",:states =>[:organized],:text=>"In diesem Feld können Sie mit genauen Angaben zu Ihrem Gericht-Wunsch die Suche nach Ihrem Rezeptvorschlag eingrenzen."),
|
220
|
+
]),
|
221
|
+
MINT::AIC.new(:name=>"RecipeFilter_content",:states =>[:organized])
|
222
|
+
])
|
223
|
+
]).save!
|
224
|
+
|
225
|
+
|
226
|
+
test = MINT::CIC.new( :name => "RecipeFinder_content", :rows => 1, :cols=> 1,:x=>0, :y=>0, :width =>800, :height => 600)
|
227
|
+
test.save!
|
228
|
+
|
229
|
+
test.calculate_container(@solver,10)
|
230
|
+
|
231
|
+
checkSizes(MINT::CIO.first(:name=>"RecipeFilter_content"),20,305,760,275)
|
232
|
+
MINT::AIO.first(:name=>"RecipeFilter_label").label.should=="Suchkriterien"
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should calculate the layer level for nested containers" do
|
236
|
+
|
237
|
+
MINT::AIC.new(:name=>"RecipeFinder_content",:states =>[:organized],
|
238
|
+
:childs =>[
|
239
|
+
MINT::AIC.new(:name=>"RecipeFilter",:states =>[:organized],
|
240
|
+
:childs => [
|
241
|
+
MINT::AIC.new(:name=>"RecipeFilter_description1",:states =>[:organized],
|
242
|
+
:childs =>[
|
243
|
+
MINT::AIINReference.new(:name=>"RecipeFilter_label",:states =>[:organized],:label=>"Suchkriterien"),
|
244
|
+
MINT::AIOUTContext.new(:name=>"RecipeFilter_description",:states =>[:organized],:text=>"In diesem Feld können Sie mit genauen Angaben zu Ihrem Gericht-Wunsch die Suche nach Ihrem Rezeptvorschlag eingrenzen."),
|
245
|
+
]),
|
246
|
+
MINT::AIC.new(:name=>"RecipeFilter_content",:states =>[:organized])
|
247
|
+
])
|
248
|
+
]).save!
|
249
|
+
|
250
|
+
|
251
|
+
test = MINT::CIC.new( :name => "RecipeFinder_content", :rows => 1, :cols=> 1,:x=>0, :y=>0, :width =>800, :height => 600)
|
252
|
+
test.save!
|
253
|
+
|
254
|
+
test.calculate_container(@solver,10)
|
255
|
+
|
256
|
+
MINT::CIO.first(:name=>"RecipeFilter_content").layer.should ==2
|
257
|
+
MINT::CIO.first(:name=>"RecipeFilter_label").layer.should== 3
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
it "should end up with all cios set to state >positioned< after layout calculation" do
|
263
|
+
@solver = Cassowary::ClSimplexSolver.new
|
264
|
+
a_top = MINT::AIC.new(:name=>"top",:states =>[:organized], :childs =>[
|
265
|
+
MINT::AIC.new(:name=>"parent_left", :childs =>[@a_left,@a_right],:states =>[:organized]),
|
266
|
+
MINT::AIC.new(:name=>"parent_right",:states =>[:organized])
|
267
|
+
])
|
268
|
+
a_top.save!
|
269
|
+
|
270
|
+
top_cic = MINT::CIC.create(:name =>"top",:x=>0,:y=>0,:width=>800,:height=>800)
|
271
|
+
parent_left_cic = MINT::CIC.create(:name =>"parent_left").save!
|
272
|
+
parent_right_cic = MINT::CIC.create(:name =>"parent_right").save!
|
273
|
+
|
274
|
+
top_cic.calculate_container(@solver,10)
|
275
|
+
|
276
|
+
MINT::CIC.first(:name=>"top").states.should==[:positioned]
|
277
|
+
MINT::CIC.first(:name=>"parent_left").states.should==[:positioned]
|
278
|
+
MINT::CIC.first(:name=>"parent_right").states.should==[:positioned]
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should layout only elements that have not been calculated - case uncalculated leaf cios" do
|
282
|
+
@solver = Cassowary::ClSimplexSolver.new
|
283
|
+
a_top = MINT::AIC.new(:name=>"top",:states =>[:organized], :childs =>[
|
284
|
+
MINT::AIC.new(:name=>"parent_left",:states =>[:organized], :childs =>[@a_left,@a_right]),
|
285
|
+
MINT::AIC.new(:name=>"parent_right",:states =>[:organized])
|
286
|
+
])
|
287
|
+
a_top.save!
|
288
|
+
|
289
|
+
top_cic = MINT::CIC.create(:name =>"top",:states=>[:positioned],:x=>0,:y=>0,:width=>800,:height=>800)
|
290
|
+
parent_left_cic = MINT::CIC.create(:name =>"parent_left",:states=>[:positioned],:x=>10,:y=>10,:width=>300,:height=>800).save!
|
291
|
+
parent_right_cic = MINT::CIC.create(:name =>"parent_right",:states=>[:positioned],:x=>310,:y=>10,:width=>470,:height=>800).save!
|
292
|
+
|
293
|
+
top_cic.calculate_container(@solver,10)
|
294
|
+
|
295
|
+
MINT::CIC.first(:name=>"parent_left").states.should==[:positioned]
|
296
|
+
checkSizes(MINT::CIO.first(:name=>"parent_left"),10,10,300,800)
|
297
|
+
checkSizes(MINT::CIO.first(:name=>"left"),20,20,280,385)
|
298
|
+
checkSizes(MINT::CIO.first(:name=>"right"),20,415,280,385)
|
299
|
+
|
300
|
+
MINT::CIO.first(:name=>"left").states.should==[:positioned]
|
301
|
+
MINT::CIO.first(:name=>"right").states.should==[:positioned]
|
302
|
+
end
|
303
|
+
|
304
|
+
it "should layout uncalculated parental elements based on calculated leaf cios" do
|
305
|
+
pending("get the right container calculation working that has no childs!")
|
306
|
+
@solver = Cassowary::ClSimplexSolver.new
|
307
|
+
a_top = MINT::AIC.new(:name=>"top",:states =>[:organized], :childs =>[
|
308
|
+
MINT::AIC.new(:name=>"parent_left",:states =>[:organized], :childs =>[@a_left,@a_right]),
|
309
|
+
MINT::AIC.new(:name=>"parent_right",:states =>[:organized])
|
310
|
+
])
|
311
|
+
a_top.save!
|
312
|
+
|
313
|
+
top_cic = MINT::CIC.create(:name =>"top",:x=>0,:y=>0,:width=>800,:height=>800)
|
314
|
+
parent_left_cic = MINT::CIC.create(:name =>"parent_left").save!
|
315
|
+
parent_right_cic = MINT::CIC.create(:name =>"parent_right").save!
|
316
|
+
MINT::CIO.first(:name=>"left").update(:x =>20,:y=>20,:width=>280,:height=>385,:states=>[:positioned])
|
317
|
+
MINT::CIO.first(:name=>"right").update(:x =>20,:y=>415,:width=>280,:height=>385,:states=>[:positioned])
|
318
|
+
|
319
|
+
top_cic.calculate_position(nil,nil,@solver,0,10)
|
320
|
+
|
321
|
+
checkSizes(MINT::CIO.first(:name=>"right"),20,415,280,385)
|
322
|
+
checkSizes(MINT::CIO.first(:name=>"left"),20,20,280,385)
|
323
|
+
|
324
|
+
MINT::CIO.first(:name=>"parent_left").states.should==[:positioned]
|
325
|
+
MINT::CIO.first(:name=>"parent_right").states.should==[:positioned]
|
326
|
+
|
327
|
+
checkSizes(MINT::CIO.first(:name=>"parent_left"),10,10,300,800) # results are wrong border missing!
|
328
|
+
checkSizes(MINT::CIO.first(:name=>"parent_right"),10,10,0,0)
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
end
|
335
|
+
|
336
|
+
describe 'mouse' do
|
337
|
+
it "should highlight CIOs based on coordinates retrieved by mouse" do
|
338
|
+
connection_options = { :adapter => "in_memory"}
|
339
|
+
DataMapper.setup(:default, connection_options)
|
340
|
+
# DataMapper.setup(:default, { :adapter => "rinda",:local =>Rinda::TupleSpace.new})
|
341
|
+
|
342
|
+
a= MINT::CIO.create(:name=>"left_2x",:x=>1,:y =>1, :width=>390,:height =>800,:states => [:displayed])
|
343
|
+
b= MINT::CIO.create(:name=>"right_2x",:x=>400,:y =>2, :width=>389,:height =>799,:states => [:displayed])
|
344
|
+
|
345
|
+
puts b.pos.Xvalue
|
346
|
+
|
347
|
+
CUIControl.fill_active_cio_cache
|
348
|
+
|
349
|
+
Result = Struct.new(:x, :y)
|
350
|
+
|
351
|
+
CUIControl.find_cio_from_coordinates(Result.new(10,10))
|
352
|
+
|
353
|
+
a = MINT::CIO.first(:name=>"left_2x")
|
354
|
+
a.states.should==[:highlighted]
|
355
|
+
MINT::CIO.first(:name=>"right_2x").states.should==[:displayed]
|
356
|
+
|
357
|
+
CUIControl.find_cio_from_coordinates(Result.new(410,10))
|
358
|
+
|
359
|
+
MINT::CIO.first(:name=>"left_2x").states.should==[:displayed]
|
360
|
+
MINT::CIO.first(:name=>"right_2x").states.should==[:highlighted]
|
361
|
+
|
362
|
+
CUIControl.find_cio_from_coordinates(Result.new(395,10))
|
363
|
+
|
364
|
+
MINT::CIO.first(:name=>"left_2x").states.should==[:displayed]
|
365
|
+
MINT::CIO.first(:name=>"right_2x").states.should==[:displayed]
|
366
|
+
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|