cura 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +122 -0
- data/LICENSE +20 -0
- data/README.md +159 -0
- data/Rakefile +42 -0
- data/cura.gemspec +23 -0
- data/examples/box_model/bin/box_model +11 -0
- data/examples/box_model/debug.log +0 -0
- data/examples/box_model/lib/box_model.rb +21 -0
- data/examples/box_model/lib/box_model/application.rb +24 -0
- data/examples/hello_world/bin/hello_world +10 -0
- data/examples/hello_world/lib/hello_world.rb +201 -0
- data/examples/mruby-examples/README.md +10 -0
- data/examples/mruby-examples/include/cura_examples.h +6 -0
- data/examples/mruby-examples/mrbgem.rake +14 -0
- data/examples/mruby-examples/src/gem_init.c +34 -0
- data/examples/mruby-examples/tools/hello_world/hello_world.c +6 -0
- data/examples/todo_list/app.log +9 -0
- data/examples/todo_list/bin/todo_list +26 -0
- data/examples/todo_list/data.db +0 -0
- data/examples/todo_list/debug.log +0 -0
- data/examples/todo_list/lib/todo_list.rb +28 -0
- data/examples/todo_list/lib/todo_list/application.rb +54 -0
- data/examples/todo_list/lib/todo_list/component/header.rb +27 -0
- data/examples/todo_list/lib/todo_list/component/list.rb +50 -0
- data/examples/todo_list/lib/todo_list/component/list_item.rb +28 -0
- data/examples/todo_list/lib/todo_list/component/list_items.rb +97 -0
- data/examples/todo_list/lib/todo_list/component/lists.rb +89 -0
- data/examples/todo_list/lib/todo_list/database.rb +50 -0
- data/examples/todo_list/lib/todo_list/model/list.rb +9 -0
- data/examples/todo_list/lib/todo_list/model/list_item.rb +9 -0
- data/examples/todo_list/profile.html +11354 -0
- data/lib/cura.rb +13 -0
- data/lib/cura/adapter.rb +67 -0
- data/lib/cura/application.rb +245 -0
- data/lib/cura/attributes/has_ancestry.rb +40 -0
- data/lib/cura/attributes/has_application.rb +31 -0
- data/lib/cura/attributes/has_attributes.rb +89 -0
- data/lib/cura/attributes/has_children.rb +113 -0
- data/lib/cura/attributes/has_colors.rb +66 -0
- data/lib/cura/attributes/has_coordinates.rb +49 -0
- data/lib/cura/attributes/has_dimensions.rb +63 -0
- data/lib/cura/attributes/has_events.rb +89 -0
- data/lib/cura/attributes/has_focusability.rb +37 -0
- data/lib/cura/attributes/has_initialize.rb +15 -0
- data/lib/cura/attributes/has_offsets.rb +82 -0
- data/lib/cura/attributes/has_orientation.rb +53 -0
- data/lib/cura/attributes/has_relative_coordinates.rb +39 -0
- data/lib/cura/attributes/has_root.rb +104 -0
- data/lib/cura/attributes/has_side_attributes.rb +95 -0
- data/lib/cura/attributes/has_windows.rb +70 -0
- data/lib/cura/borders.rb +16 -0
- data/lib/cura/color.rb +330 -0
- data/lib/cura/component/base.rb +180 -0
- data/lib/cura/component/button.rb +57 -0
- data/lib/cura/component/group.rb +77 -0
- data/lib/cura/component/label.rb +224 -0
- data/lib/cura/component/listbox.rb +152 -0
- data/lib/cura/component/pack.rb +144 -0
- data/lib/cura/component/scrollbar.rb +184 -0
- data/lib/cura/component/textbox.rb +118 -0
- data/lib/cura/cursor.rb +77 -0
- data/lib/cura/error/base.rb +10 -0
- data/lib/cura/error/invalid_adapter.rb +18 -0
- data/lib/cura/error/invalid_application.rb +18 -0
- data/lib/cura/error/invalid_color.rb +18 -0
- data/lib/cura/error/invalid_component.rb +18 -0
- data/lib/cura/error/invalid_middleware.rb +18 -0
- data/lib/cura/event.rb +38 -0
- data/lib/cura/event/base.rb +108 -0
- data/lib/cura/event/click.rb +14 -0
- data/lib/cura/event/dispatcher.rb +122 -0
- data/lib/cura/event/focus.rb +14 -0
- data/lib/cura/event/handler.rb +74 -0
- data/lib/cura/event/key_down.rb +68 -0
- data/lib/cura/event/middleware/aimer/base.rb +38 -0
- data/lib/cura/event/middleware/aimer/dispatcher_target.rb +24 -0
- data/lib/cura/event/middleware/aimer/mouse_focus.rb +48 -0
- data/lib/cura/event/middleware/aimer/target_option.rb +38 -0
- data/lib/cura/event/middleware/base.rb +21 -0
- data/lib/cura/event/middleware/dispatch.rb +20 -0
- data/lib/cura/event/middleware/translator/base.rb +37 -0
- data/lib/cura/event/middleware/translator/mouse_click.rb +44 -0
- data/lib/cura/event/mouse.rb +34 -0
- data/lib/cura/event/mouse_button.rb +103 -0
- data/lib/cura/event/mouse_wheel_down.rb +14 -0
- data/lib/cura/event/mouse_wheel_up.rb +14 -0
- data/lib/cura/event/resize.rb +17 -0
- data/lib/cura/event/selected.rb +14 -0
- data/lib/cura/event/unfocus.rb +14 -0
- data/lib/cura/focus_controller.rb +89 -0
- data/lib/cura/key.rb +313 -0
- data/lib/cura/margins.rb +16 -0
- data/lib/cura/offsets.rb +91 -0
- data/lib/cura/padding.rb +16 -0
- data/lib/cura/pencil.rb +29 -0
- data/lib/cura/version.rb +6 -0
- data/lib/cura/window.rb +85 -0
- data/spec/cura/attributes/has_ancestry_spec.rb +108 -0
- data/spec/cura/attributes/has_application_spec.rb +59 -0
- data/spec/cura/attributes/has_attributes_spec.rb +75 -0
- data/spec/cura/attributes/has_children_spec.rb +169 -0
- data/spec/cura/attributes/has_colors_spec.rb +20 -0
- data/spec/cura/attributes/has_coordinates_spec.rb +19 -0
- data/spec/cura/attributes/has_dimensions_spec.rb +19 -0
- data/spec/cura/attributes/has_events_spec.rb +18 -0
- data/spec/cura/attributes/has_focusability_spec.rb +58 -0
- data/spec/cura/attributes/has_offsets_spec.rb +18 -0
- data/spec/cura/attributes/has_orientation_spec.rb +102 -0
- data/spec/cura/attributes/has_relative_coordinates_spec.rb +18 -0
- data/spec/cura/attributes/has_side_attributes_spec.rb +19 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/shared_examples_for_attributes.rb +122 -0
- metadata +211 -0
@@ -0,0 +1,169 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "cura/component/base"
|
4
|
+
|
5
|
+
require "cura/attributes/has_children"
|
6
|
+
|
7
|
+
describe Cura::Attributes::HasChildren do
|
8
|
+
|
9
|
+
let(:instance) do
|
10
|
+
instance_class = Class.new
|
11
|
+
instance_class.include(Cura::Attributes::HasChildren)
|
12
|
+
|
13
|
+
instance_class.new
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:child_class) do
|
17
|
+
instance_class = Class.new(Cura::Component::Base)
|
18
|
+
instance_class.include(Cura::Attributes::HasChildren)
|
19
|
+
|
20
|
+
instance_class
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:child_1) { child_class.new }
|
24
|
+
let(:child_2) { child_class.new }
|
25
|
+
let(:children) { [child_1, child_2] }
|
26
|
+
|
27
|
+
describe "#children" do
|
28
|
+
|
29
|
+
it "should be initialized with the correct value" do
|
30
|
+
expect(instance.children).to eq([])
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when recursive is unset" do
|
34
|
+
|
35
|
+
before do
|
36
|
+
instance.add_children(*children)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return it's children" do
|
40
|
+
expect(instance.children).to eq(children)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when recursive is set" do
|
46
|
+
|
47
|
+
let(:child) { child_class.new }
|
48
|
+
|
49
|
+
before do
|
50
|
+
instance.add_child(child)
|
51
|
+
child.add_children(*children)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return all of it's children's children as well" do
|
55
|
+
expect(instance.children(true)).to eq([child] + children)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#add_child" do
|
63
|
+
|
64
|
+
before do
|
65
|
+
instance.add_child(child_1)
|
66
|
+
instance.add_child(child_2)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should add the children" do
|
70
|
+
expect(instance.children).to eq([child_1, child_2])
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#add_children" do
|
76
|
+
|
77
|
+
before do
|
78
|
+
instance.add_children(child_1, child_2)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should add the children" do
|
82
|
+
expect(instance.children).to eq([child_1, child_2])
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#delete_child_at" do
|
88
|
+
|
89
|
+
before do
|
90
|
+
instance.add_children(child_1, child_2)
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when a positive index is given" do
|
94
|
+
|
95
|
+
before do
|
96
|
+
instance.delete_child_at(1)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should delete the child" do
|
100
|
+
expect(instance.children).to eq([child_1])
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
context "when a negative index is given" do
|
106
|
+
|
107
|
+
before do
|
108
|
+
instance.delete_child_at(-1)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should delete the child" do
|
112
|
+
expect(instance.children).to eq([child_1])
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#delete_child" do
|
120
|
+
|
121
|
+
before do
|
122
|
+
instance.add_children(child_1, child_2)
|
123
|
+
instance.delete_child(child_2)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should delete the child" do
|
127
|
+
expect(instance.children).to eq([child_1])
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#delete_children" do
|
133
|
+
|
134
|
+
before do
|
135
|
+
instance.add_children(child_1, child_2)
|
136
|
+
instance.delete_children
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should delete all children" do
|
140
|
+
expect(instance.children).to eq([])
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#children?" do
|
146
|
+
|
147
|
+
context "when there aren't children" do
|
148
|
+
|
149
|
+
it "should return false" do
|
150
|
+
expect(instance.children?).to eq(false)
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
context "when there are children" do
|
156
|
+
|
157
|
+
before do
|
158
|
+
instance.add_children(child_1, child_2)
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should return true" do
|
162
|
+
expect(instance.children?).to eq(true)
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "support/shared_examples_for_attributes"
|
4
|
+
|
5
|
+
require "cura/attributes/has_initialize"
|
6
|
+
require "cura/attributes/has_colors"
|
7
|
+
|
8
|
+
describe Cura::Attributes::HasColors do
|
9
|
+
|
10
|
+
let(:instance) do
|
11
|
+
instance_class = Class.new
|
12
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
13
|
+
instance_class.include(Cura::Attributes::HasColors)
|
14
|
+
|
15
|
+
instance_class.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it_should_behave_like "an object with color accessors", :foreground, :background
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "support/shared_examples_for_attributes"
|
3
|
+
|
4
|
+
require "cura/attributes/has_initialize"
|
5
|
+
require "cura/attributes/has_coordinates"
|
6
|
+
|
7
|
+
describe Cura::Attributes::HasCoordinates do
|
8
|
+
|
9
|
+
let(:instance) do
|
10
|
+
instance_class = Class.new
|
11
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
12
|
+
instance_class.include(Cura::Attributes::HasCoordinates)
|
13
|
+
|
14
|
+
instance_class.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it_should_behave_like "an object with integer accessors", :x, :y
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "support/shared_examples_for_attributes"
|
3
|
+
|
4
|
+
require "cura/attributes/has_initialize"
|
5
|
+
require "cura/attributes/has_dimensions"
|
6
|
+
|
7
|
+
describe Cura::Attributes::HasDimensions do
|
8
|
+
|
9
|
+
let(:instance) do
|
10
|
+
instance_class = Class.new
|
11
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
12
|
+
instance_class.include(Cura::Attributes::HasDimensions)
|
13
|
+
|
14
|
+
instance_class.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it_should_behave_like "an object with size accessors", :width, :height, default: :auto
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "cura/attributes/has_initialize"
|
4
|
+
require "cura/attributes/has_events"
|
5
|
+
|
6
|
+
describe Cura::Attributes::HasEvents do
|
7
|
+
|
8
|
+
let(:instance) do
|
9
|
+
instance_class = Class.new
|
10
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
11
|
+
instance_class.include(Cura::Attributes::HasEvents)
|
12
|
+
|
13
|
+
instance_class.new
|
14
|
+
end
|
15
|
+
|
16
|
+
pending
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "cura/attributes/has_initialize"
|
4
|
+
require "cura/attributes/has_focusability"
|
5
|
+
|
6
|
+
describe Cura::Attributes::HasFocusability do
|
7
|
+
|
8
|
+
let(:instance) do
|
9
|
+
instance_class = Class.new
|
10
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
11
|
+
instance_class.include(Cura::Attributes::HasFocusability)
|
12
|
+
|
13
|
+
instance_class.new
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#focusable?" do
|
17
|
+
|
18
|
+
it "should be initialized with the correct value" do
|
19
|
+
expect(instance.focusable?).to eq(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#focusable=" do
|
25
|
+
|
26
|
+
context "when a boolean is passed" do
|
27
|
+
|
28
|
+
it "should set the attribute correctly" do
|
29
|
+
instance.focusable = true
|
30
|
+
expect(instance.focusable?).to eq(true)
|
31
|
+
|
32
|
+
instance.focusable = false
|
33
|
+
expect(instance.focusable?).to eq(false)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when a truthy object is passed" do
|
39
|
+
|
40
|
+
it "should set the attribute correctly" do
|
41
|
+
instance.focusable = "truthy object"
|
42
|
+
expect(instance.focusable?).to eq(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when a falsey object is passed" do
|
48
|
+
|
49
|
+
it "should set the attribute correctly" do
|
50
|
+
instance.focusable = nil
|
51
|
+
expect(instance.focusable?).to eq(false)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "cura/attributes/has_initialize"
|
4
|
+
require "cura/attributes/has_offsets"
|
5
|
+
|
6
|
+
describe Cura::Attributes::HasOffsets do
|
7
|
+
|
8
|
+
let(:instance) do
|
9
|
+
instance_class = Class.new
|
10
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
11
|
+
instance_class.include(Cura::Attributes::HasOffsets)
|
12
|
+
|
13
|
+
instance_class.new
|
14
|
+
end
|
15
|
+
|
16
|
+
pending
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "cura/attributes/has_initialize"
|
4
|
+
require "cura/attributes/has_orientation"
|
5
|
+
|
6
|
+
describe Cura::Attributes::HasOrientation do
|
7
|
+
|
8
|
+
let(:instance_class) do
|
9
|
+
instance_class = Class.new
|
10
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
11
|
+
instance_class.include(Cura::Attributes::HasOrientation)
|
12
|
+
|
13
|
+
instance_class
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:instance) { instance_class.new }
|
17
|
+
|
18
|
+
describe "#orientation" do
|
19
|
+
|
20
|
+
it "should be initialized with the correct value" do
|
21
|
+
expect(instance.orientation).to eq(:vertical)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#orientation=" do
|
27
|
+
|
28
|
+
context "when a symbol is passed" do
|
29
|
+
|
30
|
+
context "and it is valid" do
|
31
|
+
|
32
|
+
it "should set the attribute correctly" do
|
33
|
+
instance.orientation = :horizontal
|
34
|
+
expect(instance.orientation).to eq(:horizontal)
|
35
|
+
|
36
|
+
instance.orientation = :vertical
|
37
|
+
expect(instance.orientation).to eq(:vertical)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
context "and it is invalid" do
|
43
|
+
|
44
|
+
it "should raise an ArgumentError" do
|
45
|
+
expect { instance.orientation = :invalid_symbol }.to raise_error(ArgumentError)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#horizontal?" do
|
55
|
+
|
56
|
+
context "when the orientation is set to :vertical" do
|
57
|
+
|
58
|
+
let(:instance) { instance_class.new(orientation: :vertical) }
|
59
|
+
|
60
|
+
it "should return the correct value" do
|
61
|
+
expect(instance.horizontal?).to eq(false)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when the orientation is set to :horizontal" do
|
67
|
+
|
68
|
+
let(:instance) { instance_class.new(orientation: :horizontal) }
|
69
|
+
|
70
|
+
it "should return the correct value" do
|
71
|
+
expect(instance.horizontal?).to eq(true)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#vertical?" do
|
79
|
+
|
80
|
+
context "when the orientation is set to :vertical" do
|
81
|
+
|
82
|
+
let(:instance) { instance_class.new(orientation: :vertical) }
|
83
|
+
|
84
|
+
it "should return the correct value" do
|
85
|
+
expect(instance.vertical?).to eq(true)
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when the orientation is set to :horizontal" do
|
91
|
+
|
92
|
+
let(:instance) { instance_class.new(orientation: :horizontal) }
|
93
|
+
|
94
|
+
it "should return the correct value" do
|
95
|
+
expect(instance.vertical?).to eq(false)
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "cura/attributes/has_initialize"
|
4
|
+
require "cura/attributes/has_relative_coordinates"
|
5
|
+
|
6
|
+
describe Cura::Attributes::HasRelativeCoordinates do
|
7
|
+
|
8
|
+
let(:instance) do
|
9
|
+
instance_class = Class.new
|
10
|
+
instance_class.include(Cura::Attributes::HasInitialize)
|
11
|
+
instance_class.include(Cura::Attributes::HasRelativeCoordinates)
|
12
|
+
|
13
|
+
instance_class.new
|
14
|
+
end
|
15
|
+
|
16
|
+
pending
|
17
|
+
|
18
|
+
end
|