fidgit 0.2.4 → 0.2.5

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.
Files changed (85) hide show
  1. data/.gitignore +7 -7
  2. data/.rspec +2 -2
  3. data/CHANGELOG.md +30 -30
  4. data/Gemfile +3 -3
  5. data/LICENSE.txt +19 -19
  6. data/README.textile +139 -139
  7. data/Rakefile +37 -37
  8. data/config/default_schema.yml +216 -216
  9. data/examples/_all_examples.rb +9 -9
  10. data/examples/align_example.rb +55 -55
  11. data/examples/button_and_toggle_button_example.rb +37 -37
  12. data/examples/color_picker_example.rb +16 -16
  13. data/examples/color_well_example.rb +24 -24
  14. data/examples/combo_box_example.rb +23 -23
  15. data/examples/file_dialog_example.rb +41 -41
  16. data/examples/grid_packer_example.rb +28 -28
  17. data/examples/helpers/example_window.rb +16 -16
  18. data/examples/label_example.rb +22 -22
  19. data/examples/list_example.rb +22 -22
  20. data/examples/menu_pane_example.rb +26 -26
  21. data/examples/message_dialog_example.rb +64 -64
  22. data/examples/radio_button_example.rb +36 -36
  23. data/examples/readme_example.rb +31 -31
  24. data/examples/scroll_window_example.rb +48 -48
  25. data/examples/slider_example.rb +33 -33
  26. data/examples/splash_example.rb +41 -41
  27. data/examples/text_area_example.rb +32 -32
  28. data/fidgit.gemspec +35 -35
  29. data/lib/fidgit.rb +50 -50
  30. data/lib/fidgit/chingu_ext/window.rb +5 -5
  31. data/lib/fidgit/cursor.rb +37 -37
  32. data/lib/fidgit/elements/button.rb +112 -112
  33. data/lib/fidgit/elements/color_picker.rb +62 -62
  34. data/lib/fidgit/elements/color_well.rb +38 -38
  35. data/lib/fidgit/elements/combo_box.rb +113 -113
  36. data/lib/fidgit/elements/composite.rb +16 -16
  37. data/lib/fidgit/elements/container.rb +208 -208
  38. data/lib/fidgit/elements/element.rb +297 -297
  39. data/lib/fidgit/elements/file_browser.rb +151 -151
  40. data/lib/fidgit/elements/grid.rb +226 -226
  41. data/lib/fidgit/elements/group.rb +64 -64
  42. data/lib/fidgit/elements/horizontal.rb +11 -11
  43. data/lib/fidgit/elements/image_frame.rb +64 -64
  44. data/lib/fidgit/elements/label.rb +84 -84
  45. data/lib/fidgit/elements/list.rb +46 -46
  46. data/lib/fidgit/elements/main_packer.rb +24 -24
  47. data/lib/fidgit/elements/menu_pane.rb +160 -160
  48. data/lib/fidgit/elements/packer.rb +41 -41
  49. data/lib/fidgit/elements/radio_button.rb +85 -85
  50. data/lib/fidgit/elements/scroll_area.rb +67 -67
  51. data/lib/fidgit/elements/scroll_bar.rb +127 -127
  52. data/lib/fidgit/elements/scroll_window.rb +82 -82
  53. data/lib/fidgit/elements/slider.rb +124 -124
  54. data/lib/fidgit/elements/text_area.rb +493 -493
  55. data/lib/fidgit/elements/text_line.rb +91 -91
  56. data/lib/fidgit/elements/toggle_button.rb +66 -66
  57. data/lib/fidgit/elements/tool_tip.rb +34 -34
  58. data/lib/fidgit/elements/vertical.rb +11 -11
  59. data/lib/fidgit/event.rb +158 -158
  60. data/lib/fidgit/gosu_ext/color.rb +135 -135
  61. data/lib/fidgit/gosu_ext/gosu_module.rb +24 -24
  62. data/lib/fidgit/history.rb +90 -90
  63. data/lib/fidgit/redirector.rb +82 -82
  64. data/lib/fidgit/schema.rb +123 -123
  65. data/lib/fidgit/selection.rb +105 -105
  66. data/lib/fidgit/standard_ext/hash.rb +20 -20
  67. data/lib/fidgit/states/dialog_state.rb +51 -51
  68. data/lib/fidgit/states/file_dialog.rb +24 -24
  69. data/lib/fidgit/states/gui_state.rb +329 -329
  70. data/lib/fidgit/states/message_dialog.rb +60 -60
  71. data/lib/fidgit/version.rb +4 -4
  72. data/lib/fidgit/window.rb +19 -19
  73. data/spec/fidgit/elements/helpers/helper.rb +2 -2
  74. data/spec/fidgit/elements/helpers/tex_play_helper.rb +8 -8
  75. data/spec/fidgit/elements/image_frame_spec.rb +68 -68
  76. data/spec/fidgit/elements/label_spec.rb +36 -36
  77. data/spec/fidgit/event_spec.rb +209 -209
  78. data/spec/fidgit/gosu_ext/color_spec.rb +129 -129
  79. data/spec/fidgit/gosu_ext/helpers/helper.rb +2 -2
  80. data/spec/fidgit/helpers/helper.rb +3 -3
  81. data/spec/fidgit/history_spec.rb +153 -153
  82. data/spec/fidgit/redirector_spec.rb +77 -77
  83. data/spec/fidgit/schema_spec.rb +66 -66
  84. data/spec/fidgit/schema_test.yml +32 -32
  85. metadata +67 -22
@@ -1,130 +1,130 @@
1
- require_relative "helpers/helper"
2
-
3
- include Gosu
4
-
5
- describe Color do
6
- describe "rgb" do
7
- it "should create a color with the correct values from channel values" do
8
- color = Color.rgb(1, 2, 3)
9
- color.red.should equal 1
10
- color.green.should equal 2
11
- color.blue.should equal 3
12
- color.alpha.should equal 255
13
- end
14
- end
15
-
16
- describe "rgba" do
17
- it "should create a color with the correct value from channel valuess" do
18
- color = Color.rgba(1, 2, 3, 4)
19
- color.red.should equal 1
20
- color.green.should equal 2
21
- color.blue.should equal 3
22
- color.alpha.should equal 4
23
- end
24
- end
25
-
26
- describe "argb" do
27
- it "should create a color with the correct values from channel values" do
28
- color = Color.argb(1, 2, 3, 4)
29
- color.red.should equal 2
30
- color.green.should equal 3
31
- color.blue.should equal 4
32
- color.alpha.should equal 1
33
- end
34
- end
35
-
36
- describe "ahsv" do
37
- it "should create a color with the correct values from channel values" do
38
- color = Color.ahsv(1, 180.0, 0.5, 0.7)
39
- color.hue.should be_within(0.001).of(180.0)
40
- color.saturation.should be_within(0.01).of(0.5)
41
- color.value.should be_within(0.01).of(0.7)
42
- color.alpha.should equal 1
43
- end
44
- end
45
-
46
- describe "hsva" do
47
- it "should create a color with the correct values from channel values" do
48
- color = Color.hsva(180.0, 0.5, 0.7, 4)
49
- color.hue.should be_within(0.001).of(180.0)
50
- color.saturation.should be_within(0.01).of(0.5)
51
- color.value.should be_within(0.01).of(0.7)
52
- color.alpha.should equal 4
53
- end
54
- end
55
-
56
- describe "from_tex_play" do
57
- it "should create a color with the correct values" do
58
- color = Color.from_tex_play([1 / 255.0, 2 / 255.0, 3 / 255.0, 4 / 255.0])
59
- color.red.should equal 1
60
- color.green.should equal 2
61
- color.blue.should equal 3
62
- color.alpha.should equal 4
63
- end
64
- end
65
-
66
- describe "#to_tex_play" do
67
- it "should create an array with the correct values" do
68
- array = Color.rgba(1, 2, 3, 4).to_tex_play
69
- array.should eq [1 / 255.0, 2 / 255.0, 3 / 255.0, 4 / 255.0]
70
- end
71
- end
72
-
73
- describe "#==" do
74
- it "should return true for colours that are identical" do
75
- (Color.rgb(1, 2, 3) == Color.rgb(1, 2, 3)).should be_true
76
- end
77
-
78
- it "should return false for colours that are not the same" do
79
- (Color.rgb(1, 2, 3) == Color.rgb(4, 2, 3)).should be_false
80
- end
81
- end
82
-
83
- describe "#transparent?" do
84
- it "should be true if alpha is 0" do
85
- Color.rgba(1, 1, 1, 0).should be_transparent
86
- end
87
-
88
- it "should be false if 0 > alpha > 255" do
89
- Color.rgba(1, 1, 1, 2).should_not be_transparent
90
- end
91
-
92
- it "should be false if alpha == 255" do
93
- Color.rgba(1, 1, 1, 255).should_not be_transparent
94
- end
95
- end
96
-
97
- describe "#opaque?" do
98
- it "should be true if alpha is 0" do
99
- Color.rgba(1, 1, 1, 0).should_not be_opaque
100
- end
101
-
102
- it "should be false if 0 > alpha > 255" do
103
- Color.rgba(1, 1, 1, 2).should_not be_opaque
104
- end
105
-
106
- it "should be false if alpha == 255" do
107
- Color.rgba(1, 1, 1, 255).should be_opaque
108
- end
109
- end
110
-
111
- describe "#+" do
112
- it "should add two colours together" do
113
- (Color.rgba(1, 2, 3, 4) + Color.rgba(10, 20, 30, 40)).should == Color.rgba(11, 22, 33, 44)
114
- end
115
-
116
- it "should cap values at 255" do
117
- (Color.rgba(56, 56, 56, 56) + Color.rgba(200, 200, 200, 200)).should == Color.rgba(255, 255, 255, 255)
118
- end
119
- end
120
-
121
- describe "#-" do
122
- it "should subtract one color from another two colours together" do
123
- (Color.rgba(10, 20, 30, 40) - Color.rgba(1, 2, 3, 4)).should == Color.rgba(9, 18, 27, 36)
124
- end
125
-
126
- it "should cap values at 0" do
127
- (Color.rgba(56, 56, 56, 56) - Color.rgba(57, 57, 57, 57)).should == Color.rgba(0, 0, 0, 0)
128
- end
129
- end
1
+ require_relative "helpers/helper"
2
+
3
+ include Gosu
4
+
5
+ describe Color do
6
+ describe "rgb" do
7
+ it "should create a color with the correct values from channel values" do
8
+ color = Color.rgb(1, 2, 3)
9
+ color.red.should equal 1
10
+ color.green.should equal 2
11
+ color.blue.should equal 3
12
+ color.alpha.should equal 255
13
+ end
14
+ end
15
+
16
+ describe "rgba" do
17
+ it "should create a color with the correct value from channel valuess" do
18
+ color = Color.rgba(1, 2, 3, 4)
19
+ color.red.should equal 1
20
+ color.green.should equal 2
21
+ color.blue.should equal 3
22
+ color.alpha.should equal 4
23
+ end
24
+ end
25
+
26
+ describe "argb" do
27
+ it "should create a color with the correct values from channel values" do
28
+ color = Color.argb(1, 2, 3, 4)
29
+ color.red.should equal 2
30
+ color.green.should equal 3
31
+ color.blue.should equal 4
32
+ color.alpha.should equal 1
33
+ end
34
+ end
35
+
36
+ describe "ahsv" do
37
+ it "should create a color with the correct values from channel values" do
38
+ color = Color.ahsv(1, 180.0, 0.5, 0.7)
39
+ color.hue.should be_within(0.001).of(180.0)
40
+ color.saturation.should be_within(0.01).of(0.5)
41
+ color.value.should be_within(0.01).of(0.7)
42
+ color.alpha.should equal 1
43
+ end
44
+ end
45
+
46
+ describe "hsva" do
47
+ it "should create a color with the correct values from channel values" do
48
+ color = Color.hsva(180.0, 0.5, 0.7, 4)
49
+ color.hue.should be_within(0.001).of(180.0)
50
+ color.saturation.should be_within(0.01).of(0.5)
51
+ color.value.should be_within(0.01).of(0.7)
52
+ color.alpha.should equal 4
53
+ end
54
+ end
55
+
56
+ describe "from_tex_play" do
57
+ it "should create a color with the correct values" do
58
+ color = Color.from_tex_play([1 / 255.0, 2 / 255.0, 3 / 255.0, 4 / 255.0])
59
+ color.red.should equal 1
60
+ color.green.should equal 2
61
+ color.blue.should equal 3
62
+ color.alpha.should equal 4
63
+ end
64
+ end
65
+
66
+ describe "#to_tex_play" do
67
+ it "should create an array with the correct values" do
68
+ array = Color.rgba(1, 2, 3, 4).to_tex_play
69
+ array.should eq [1 / 255.0, 2 / 255.0, 3 / 255.0, 4 / 255.0]
70
+ end
71
+ end
72
+
73
+ describe "#==" do
74
+ it "should return true for colours that are identical" do
75
+ (Color.rgb(1, 2, 3) == Color.rgb(1, 2, 3)).should be_true
76
+ end
77
+
78
+ it "should return false for colours that are not the same" do
79
+ (Color.rgb(1, 2, 3) == Color.rgb(4, 2, 3)).should be_false
80
+ end
81
+ end
82
+
83
+ describe "#transparent?" do
84
+ it "should be true if alpha is 0" do
85
+ Color.rgba(1, 1, 1, 0).should be_transparent
86
+ end
87
+
88
+ it "should be false if 0 > alpha > 255" do
89
+ Color.rgba(1, 1, 1, 2).should_not be_transparent
90
+ end
91
+
92
+ it "should be false if alpha == 255" do
93
+ Color.rgba(1, 1, 1, 255).should_not be_transparent
94
+ end
95
+ end
96
+
97
+ describe "#opaque?" do
98
+ it "should be true if alpha is 0" do
99
+ Color.rgba(1, 1, 1, 0).should_not be_opaque
100
+ end
101
+
102
+ it "should be false if 0 > alpha > 255" do
103
+ Color.rgba(1, 1, 1, 2).should_not be_opaque
104
+ end
105
+
106
+ it "should be false if alpha == 255" do
107
+ Color.rgba(1, 1, 1, 255).should be_opaque
108
+ end
109
+ end
110
+
111
+ describe "#+" do
112
+ it "should add two colours together" do
113
+ (Color.rgba(1, 2, 3, 4) + Color.rgba(10, 20, 30, 40)).should == Color.rgba(11, 22, 33, 44)
114
+ end
115
+
116
+ it "should cap values at 255" do
117
+ (Color.rgba(56, 56, 56, 56) + Color.rgba(200, 200, 200, 200)).should == Color.rgba(255, 255, 255, 255)
118
+ end
119
+ end
120
+
121
+ describe "#-" do
122
+ it "should subtract one color from another two colours together" do
123
+ (Color.rgba(10, 20, 30, 40) - Color.rgba(1, 2, 3, 4)).should == Color.rgba(9, 18, 27, 36)
124
+ end
125
+
126
+ it "should cap values at 0" do
127
+ (Color.rgba(56, 56, 56, 56) - Color.rgba(57, 57, 57, 57)).should == Color.rgba(0, 0, 0, 0)
128
+ end
129
+ end
130
130
  end
@@ -1,3 +1,3 @@
1
- require "rspec"
2
-
1
+ require "rspec"
2
+
3
3
  require_relative File.join(File.dirname(__FILE__), "..", "..", "..", "..", "lib", "fidgit")
@@ -1,4 +1,4 @@
1
- require "rspec"
2
- require "fileutils"
3
-
1
+ require "rspec"
2
+ require "fileutils"
3
+
4
4
  $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "fidgit"))
@@ -1,153 +1,153 @@
1
- require_relative 'helpers/helper'
2
-
3
- require 'history'
4
-
5
- module Fidgit
6
- class History
7
- class Maths < Action
8
- def initialize(value)
9
- @value = value
10
- end
11
- end
12
-
13
- class Add < Maths
14
- def do
15
- $x += @value
16
- end
17
-
18
- def undo
19
- $x -= @value
20
- end
21
- end
22
-
23
- class Sub < Maths
24
- def do
25
- $x -= @value
26
- end
27
-
28
- def undo
29
- $x += @value
30
- end
31
- end
32
- end
33
-
34
- describe History do
35
- before :each do
36
- $x = 0 # Used as target of test action.
37
- @object = described_class.new
38
- end
39
-
40
- describe "initialize()" do
41
- it "should produce an object that is not undoable or redoable" do
42
- @object.can_undo?.should be_false
43
- @object.can_redo?.should be_false
44
- end
45
- end
46
-
47
- describe "do()" do
48
- it "should raise an error if the parameter is incorrect" do
49
- lambda { @object.do(12) }.should raise_error ArgumentError
50
- end
51
-
52
- it "should perform the action's do() method correctly" do
53
- @object.do(History::Add.new(2))
54
-
55
- $x.should == 2
56
- @object.can_undo?.should be_true
57
- @object.can_redo?.should be_false
58
- end
59
-
60
- it "should correctly delete any re-doable actions, even if there is only one" do
61
- @object.do(History::Add.new(2))
62
- @object.undo
63
- @object.do(History::Add.new(3))
64
- @object.undo
65
-
66
- @object.can_undo?.should be_false
67
- end
68
- end
69
-
70
- describe "undo()" do
71
- it "should raise an error if there is nothing to undo" do
72
- lambda { @object.undo }.should raise_error
73
- end
74
-
75
- it "should perform the undo method on the action" do
76
- @object.do(History::Add.new(2))
77
- @object.undo
78
-
79
- $x.should == 0
80
- @object.can_undo?.should be_false
81
- @object.can_redo?.should be_true
82
- end
83
- end
84
-
85
- describe "redo()" do
86
- it "should raise an error if there is nothing to redo" do
87
- lambda { @object.redo }.should raise_error
88
- end
89
-
90
- it "should perform the undo method on the action" do
91
- @object.do(History::Add.new(2))
92
- @object.undo
93
- @object.redo
94
-
95
- $x.should == 2
96
- @object.can_undo?.should be_true
97
- @object.can_redo?.should be_false
98
- end
99
- end
100
-
101
- describe "replace_last()" do
102
- it "should raise an error if there is nothing to redo" do
103
- lambda { @object.replace_last(12) }.should raise_error ArgumentError
104
- end
105
-
106
- it "should raise an error if there is nothing to replace" do
107
- lambda { @object.replace_last(History::Add2.new) }.should raise_error
108
- end
109
-
110
- it "should correctly replace the last action" do
111
- @object.do(History::Add.new(2))
112
- @object.replace_last(History::Sub.new(1))
113
-
114
- $x.should == -1
115
- @object.can_redo?.should be_false
116
- @object.can_undo?.should be_true
117
- end
118
-
119
- it "should not remove redoable actions" do
120
- @object.do(History::Add.new(2))
121
- @object.do(History::Add.new(8))
122
- @object.undo
123
- @object.replace_last(History::Sub.new(1))
124
-
125
- $x.should == -1
126
- @object.can_redo?.should be_true
127
- @object.can_undo?.should be_true
128
-
129
- @object.redo
130
- $x.should == 7
131
- end
132
- end
133
- end
134
-
135
- # Abstract class, so doesn't really do anything.
136
- describe History::Action do
137
- before :each do
138
- @object = described_class.new
139
- end
140
-
141
- describe "do()" do
142
- it "should raise an error" do
143
- lambda { @object.do }.should raise_error NotImplementedError
144
- end
145
- end
146
-
147
- describe "undo()" do
148
- it "should raise an error" do
149
- lambda { @object.undo }.should raise_error NotImplementedError
150
- end
151
- end
152
- end
153
- end
1
+ require_relative 'helpers/helper'
2
+
3
+ require 'history'
4
+
5
+ module Fidgit
6
+ class History
7
+ class Maths < Action
8
+ def initialize(value)
9
+ @value = value
10
+ end
11
+ end
12
+
13
+ class Add < Maths
14
+ def do
15
+ $x += @value
16
+ end
17
+
18
+ def undo
19
+ $x -= @value
20
+ end
21
+ end
22
+
23
+ class Sub < Maths
24
+ def do
25
+ $x -= @value
26
+ end
27
+
28
+ def undo
29
+ $x += @value
30
+ end
31
+ end
32
+ end
33
+
34
+ describe History do
35
+ before :each do
36
+ $x = 0 # Used as target of test action.
37
+ @object = described_class.new
38
+ end
39
+
40
+ describe "initialize()" do
41
+ it "should produce an object that is not undoable or redoable" do
42
+ @object.can_undo?.should be_false
43
+ @object.can_redo?.should be_false
44
+ end
45
+ end
46
+
47
+ describe "do()" do
48
+ it "should raise an error if the parameter is incorrect" do
49
+ lambda { @object.do(12) }.should raise_error ArgumentError
50
+ end
51
+
52
+ it "should perform the action's do() method correctly" do
53
+ @object.do(History::Add.new(2))
54
+
55
+ $x.should == 2
56
+ @object.can_undo?.should be_true
57
+ @object.can_redo?.should be_false
58
+ end
59
+
60
+ it "should correctly delete any re-doable actions, even if there is only one" do
61
+ @object.do(History::Add.new(2))
62
+ @object.undo
63
+ @object.do(History::Add.new(3))
64
+ @object.undo
65
+
66
+ @object.can_undo?.should be_false
67
+ end
68
+ end
69
+
70
+ describe "undo()" do
71
+ it "should raise an error if there is nothing to undo" do
72
+ lambda { @object.undo }.should raise_error
73
+ end
74
+
75
+ it "should perform the undo method on the action" do
76
+ @object.do(History::Add.new(2))
77
+ @object.undo
78
+
79
+ $x.should == 0
80
+ @object.can_undo?.should be_false
81
+ @object.can_redo?.should be_true
82
+ end
83
+ end
84
+
85
+ describe "redo()" do
86
+ it "should raise an error if there is nothing to redo" do
87
+ lambda { @object.redo }.should raise_error
88
+ end
89
+
90
+ it "should perform the undo method on the action" do
91
+ @object.do(History::Add.new(2))
92
+ @object.undo
93
+ @object.redo
94
+
95
+ $x.should == 2
96
+ @object.can_undo?.should be_true
97
+ @object.can_redo?.should be_false
98
+ end
99
+ end
100
+
101
+ describe "replace_last()" do
102
+ it "should raise an error if there is nothing to redo" do
103
+ lambda { @object.replace_last(12) }.should raise_error ArgumentError
104
+ end
105
+
106
+ it "should raise an error if there is nothing to replace" do
107
+ lambda { @object.replace_last(History::Add2.new) }.should raise_error
108
+ end
109
+
110
+ it "should correctly replace the last action" do
111
+ @object.do(History::Add.new(2))
112
+ @object.replace_last(History::Sub.new(1))
113
+
114
+ $x.should == -1
115
+ @object.can_redo?.should be_false
116
+ @object.can_undo?.should be_true
117
+ end
118
+
119
+ it "should not remove redoable actions" do
120
+ @object.do(History::Add.new(2))
121
+ @object.do(History::Add.new(8))
122
+ @object.undo
123
+ @object.replace_last(History::Sub.new(1))
124
+
125
+ $x.should == -1
126
+ @object.can_redo?.should be_true
127
+ @object.can_undo?.should be_true
128
+
129
+ @object.redo
130
+ $x.should == 7
131
+ end
132
+ end
133
+ end
134
+
135
+ # Abstract class, so doesn't really do anything.
136
+ describe History::Action do
137
+ before :each do
138
+ @object = described_class.new
139
+ end
140
+
141
+ describe "do()" do
142
+ it "should raise an error" do
143
+ lambda { @object.do }.should raise_error NotImplementedError
144
+ end
145
+ end
146
+
147
+ describe "undo()" do
148
+ it "should raise an error" do
149
+ lambda { @object.undo }.should raise_error NotImplementedError
150
+ end
151
+ end
152
+ end
153
+ end