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,78 +1,78 @@
1
- require_relative 'helpers/helper'
2
-
3
- require 'redirector'
4
-
5
- include Fidgit
6
-
7
- describe RedirectorMethods do
8
- describe "::Object" do
9
- subject { Object.new }
10
-
11
- describe '#instance_methods_eval' do
12
- it "should fail if a block is not provided" do
13
- ->{ subject.instance_methods_eval }.should raise_error
14
- end
15
-
16
- it "should yield the target" do
17
- subject.instance_methods_eval { |target| @frog = target }
18
- @frog.should equal subject
19
- end
20
-
21
- it "should allow ivars to be read from the calling context" do
22
- @frog = 5
23
- fish = 0
24
- subject.instance_methods_eval { fish = @frog }
25
- fish.should equal 5
26
- end
27
-
28
- it "should allow ivars to be written to the calling context" do
29
- subject.instance_methods_eval { @frog = 10 }
30
- @frog.should equal 10
31
- end
32
-
33
- it "should not allow access to ivars in the subject" do
34
- subject.instance_variable_set :@frog, 5
35
- fish = 0
36
- subject.instance_methods_eval { fish = @frog }
37
- fish.should be_nil
38
- end
39
-
40
- it "should allow access to methods in the subject" do
41
- subject.should_receive(:frog)
42
- subject.instance_methods_eval { frog }
43
- end
44
-
45
- it "should allow stacked calls" do
46
- object1 = Object.new
47
- should_not_receive :frog
48
- object1.should_not_receive :frog
49
- subject.should_receive :frog
50
-
51
- object1.instance_methods_eval do
52
- subject.instance_methods_eval do
53
- frog
54
- end
55
- end
56
- end
57
-
58
- it "should fail if method does not exist on the subject or context" do
59
- ->{ subject.instance_methods_eval { frog } }.should raise_error NameError
60
- end
61
-
62
- it "should call the method on the context, if it doesn't exist on the subject" do
63
- should_receive(:frog)
64
- subject.instance_methods_eval { frog }
65
- end
66
-
67
- [:public, :protected, :private].each do |access|
68
- it "should preserve #{access} access for methods redirected on the context" do
69
- class << self; def frog; end; end
70
- (class << self; self; end).send access, :frog
71
- subject.should_receive :frog
72
- subject.instance_methods_eval { frog }
73
- (send "#{access}_methods").should include :frog
74
- end
75
- end
76
- end
77
- end
1
+ require_relative 'helpers/helper'
2
+
3
+ require 'redirector'
4
+
5
+ include Fidgit
6
+
7
+ describe RedirectorMethods do
8
+ describe "::Object" do
9
+ subject { Object.new }
10
+
11
+ describe '#instance_methods_eval' do
12
+ it "should fail if a block is not provided" do
13
+ ->{ subject.instance_methods_eval }.should raise_error
14
+ end
15
+
16
+ it "should yield the target" do
17
+ subject.instance_methods_eval { |target| @frog = target }
18
+ @frog.should equal subject
19
+ end
20
+
21
+ it "should allow ivars to be read from the calling context" do
22
+ @frog = 5
23
+ fish = 0
24
+ subject.instance_methods_eval { fish = @frog }
25
+ fish.should equal 5
26
+ end
27
+
28
+ it "should allow ivars to be written to the calling context" do
29
+ subject.instance_methods_eval { @frog = 10 }
30
+ @frog.should equal 10
31
+ end
32
+
33
+ it "should not allow access to ivars in the subject" do
34
+ subject.instance_variable_set :@frog, 5
35
+ fish = 0
36
+ subject.instance_methods_eval { fish = @frog }
37
+ fish.should be_nil
38
+ end
39
+
40
+ it "should allow access to methods in the subject" do
41
+ subject.should_receive(:frog)
42
+ subject.instance_methods_eval { frog }
43
+ end
44
+
45
+ it "should allow stacked calls" do
46
+ object1 = Object.new
47
+ should_not_receive :frog
48
+ object1.should_not_receive :frog
49
+ subject.should_receive :frog
50
+
51
+ object1.instance_methods_eval do
52
+ subject.instance_methods_eval do
53
+ frog
54
+ end
55
+ end
56
+ end
57
+
58
+ it "should fail if method does not exist on the subject or context" do
59
+ ->{ subject.instance_methods_eval { frog } }.should raise_error NameError
60
+ end
61
+
62
+ it "should call the method on the context, if it doesn't exist on the subject" do
63
+ should_receive(:frog)
64
+ subject.instance_methods_eval { frog }
65
+ end
66
+
67
+ [:public, :protected, :private].each do |access|
68
+ it "should preserve #{access} access for methods redirected on the context" do
69
+ class << self; def frog; end; end
70
+ (class << self; self; end).send access, :frog
71
+ subject.should_receive :frog
72
+ subject.instance_methods_eval { frog }
73
+ (send "#{access}_methods").should include :frog
74
+ end
75
+ end
76
+ end
77
+ end
78
78
  end
@@ -1,67 +1,67 @@
1
- require_relative 'helpers/helper'
2
-
3
- require 'fidgit'
4
-
5
- SCHEMA_FILE_NAME = File.expand_path(File.join(__FILE__, '..', 'schema_test.yml'))
6
-
7
- include Fidgit
8
-
9
- describe Schema do
10
- subject { Schema.new(Hash.new) }
11
-
12
- context "given the default schema" do
13
- subject { Schema.new(YAML.load(File.read(SCHEMA_FILE_NAME))) }
14
-
15
- describe "#constant" do
16
- it "should have the constant :scroll_bar_thickness" do
17
- subject.constant(:scroll_bar_thickness).should equal 12
18
- end
19
-
20
- it "should have the color constant :none" do
21
- subject.constant(:none).should eq Gosu::Color.rgba(0, 0, 0, 0)
22
- end
23
-
24
- it "should have the color constant :white" do
25
- subject.constant(:white).should eq Gosu::Color.rgb(255, 255, 255)
26
- end
27
-
28
- it "should not have the constant :moon_cow_height" do
29
- subject.constant(:moon_cow_height).should be_nil
30
- end
31
- end
32
-
33
- describe "#default" do
34
- it "should fail if the class given is not an Element" do
35
- ->{ subject.default(String, :frog) }.should raise_error ArgumentError
36
- end
37
-
38
- it "should fail if the value is not ever defined" do
39
- ->{ subject.default(Element, :knee_walking_turkey) }.should raise_error
40
- end
41
-
42
- it "should give the correct value for a defined color" do
43
- subject.default(Element, :color).should eq Gosu::Color.rgb(255, 255, 255)
44
- end
45
-
46
- it "should give the symbol name if the value is one" do
47
- subject.default(Element, :align_h).should be :left
48
- end
49
-
50
- it "should give the correct value for a defined constant" do
51
- subject.default(VerticalScrollBar, :width).should equal 12
52
- end
53
-
54
- it "should give the correct value for a color defined in an ancestor class" do
55
- subject.default(Label, :color).should eq Gosu::Color.rgb(255, 255, 255)
56
- end
57
-
58
- it "should give the correct value for a defined nested value" do
59
- subject.default(Fidgit::Button, [:disabled, :background_color]).should eq Gosu::Color.rgb(50, 50, 50)
60
- end
61
-
62
- it "should give the outer value for an undefined nested value" do
63
- subject.default(Element, [:hover, :color]).should eq Gosu::Color.rgb(255, 255, 255)
64
- end
65
- end
66
- end
1
+ require_relative 'helpers/helper'
2
+
3
+ require 'fidgit'
4
+
5
+ SCHEMA_FILE_NAME = File.expand_path(File.join(__FILE__, '..', 'schema_test.yml'))
6
+
7
+ include Fidgit
8
+
9
+ describe Schema do
10
+ subject { Schema.new(Hash.new) }
11
+
12
+ context "given the default schema" do
13
+ subject { Schema.new(YAML.load(File.read(SCHEMA_FILE_NAME))) }
14
+
15
+ describe "#constant" do
16
+ it "should have the constant :scroll_bar_thickness" do
17
+ subject.constant(:scroll_bar_thickness).should equal 12
18
+ end
19
+
20
+ it "should have the color constant :none" do
21
+ subject.constant(:none).should eq Gosu::Color.rgba(0, 0, 0, 0)
22
+ end
23
+
24
+ it "should have the color constant :white" do
25
+ subject.constant(:white).should eq Gosu::Color.rgb(255, 255, 255)
26
+ end
27
+
28
+ it "should not have the constant :moon_cow_height" do
29
+ subject.constant(:moon_cow_height).should be_nil
30
+ end
31
+ end
32
+
33
+ describe "#default" do
34
+ it "should fail if the class given is not an Element" do
35
+ ->{ subject.default(String, :frog) }.should raise_error ArgumentError
36
+ end
37
+
38
+ it "should fail if the value is not ever defined" do
39
+ ->{ subject.default(Element, :knee_walking_turkey) }.should raise_error
40
+ end
41
+
42
+ it "should give the correct value for a defined color" do
43
+ subject.default(Element, :color).should eq Gosu::Color.rgb(255, 255, 255)
44
+ end
45
+
46
+ it "should give the symbol name if the value is one" do
47
+ subject.default(Element, :align_h).should be :left
48
+ end
49
+
50
+ it "should give the correct value for a defined constant" do
51
+ subject.default(VerticalScrollBar, :width).should equal 12
52
+ end
53
+
54
+ it "should give the correct value for a color defined in an ancestor class" do
55
+ subject.default(Label, :color).should eq Gosu::Color.rgb(255, 255, 255)
56
+ end
57
+
58
+ it "should give the correct value for a defined nested value" do
59
+ subject.default(Fidgit::Button, [:disabled, :background_color]).should eq Gosu::Color.rgb(50, 50, 50)
60
+ end
61
+
62
+ it "should give the outer value for an undefined nested value" do
63
+ subject.default(Element, [:hover, :color]).should eq Gosu::Color.rgb(255, 255, 255)
64
+ end
65
+ end
66
+ end
67
67
  end
@@ -1,32 +1,32 @@
1
- # Test case schema
2
- ---
3
-
4
- # Define all constant values here. For colours, use [R, G, B] or [R, G, B, A].
5
- # Reference constants with ?constant_name
6
- :constants:
7
- # General constants (strings and numbers).
8
- :scroll_bar_thickness: 12
9
-
10
- # Gosu::Color constants
11
- :none: [0, 0, 0, 0]
12
- :white: [255, 255, 255]
13
- :gray: [100, 100, 100]
14
- :dark_gray: [50, 50, 50]
15
-
16
- # Default element attributes.
17
- :elements:
18
- :Button:
19
- :background_color: ?gray
20
-
21
- :disabled:
22
- :background_color: ?dark_gray
23
-
24
- :Element:
25
- :color: ?white
26
- :align_h: :left
27
-
28
- :HorizontalScrollBar:
29
- :height: ?scroll_bar_thickness
30
-
31
- :VerticalScrollBar:
32
- :width: ?scroll_bar_thickness
1
+ # Test case schema
2
+ ---
3
+
4
+ # Define all constant values here. For colours, use [R, G, B] or [R, G, B, A].
5
+ # Reference constants with ?constant_name
6
+ :constants:
7
+ # General constants (strings and numbers).
8
+ :scroll_bar_thickness: 12
9
+
10
+ # Gosu::Color constants
11
+ :none: [0, 0, 0, 0]
12
+ :white: [255, 255, 255]
13
+ :gray: [100, 100, 100]
14
+ :dark_gray: [50, 50, 50]
15
+
16
+ # Default element attributes.
17
+ :elements:
18
+ :Button:
19
+ :background_color: ?gray
20
+
21
+ :disabled:
22
+ :background_color: ?dark_gray
23
+
24
+ :Element:
25
+ :color: ?white
26
+ :align_h: :left
27
+
28
+ :HorizontalScrollBar:
29
+ :height: ?scroll_bar_thickness
30
+
31
+ :VerticalScrollBar:
32
+ :width: ?scroll_bar_thickness
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fidgit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-26 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gosu
16
- requirement: &21791436 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.7.41
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21791436
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.41
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: chingu
27
- requirement: &21791040 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 0.9rc7
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *21791040
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9rc7
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: clipboard
38
- requirement: &21790560 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 0.9.9
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *21790560
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.9
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: ffi
49
- requirement: &21790212 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 1.0.11
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *21790212
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.11
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rspec
60
- requirement: &21789936 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,21 +85,31 @@ dependencies:
65
85
  version: 2.8.0
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *21789936
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.8.0
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: texplay
71
- requirement: &21789660 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
75
100
  - !ruby/object:Gem::Version
76
- version: 0.3.5
101
+ version: 0.4.3
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *21789660
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.4.3
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: rake
82
- requirement: &21789408 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *21789408
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: yard
93
- requirement: &21789108 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,10 +133,15 @@ dependencies:
98
133
  version: '0'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *21789108
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: RedCloth
104
- requirement: &21788772 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
147
  - - ~>
@@ -109,7 +149,12 @@ dependencies:
109
149
  version: 4.2.9
110
150
  type: :development
111
151
  prerelease: false
112
- version_requirements: *21788772
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 4.2.9
113
158
  description: Fidgit is a GUI library built on Gosu/Chingu
114
159
  email:
115
160
  - bil.bagpuss@gmail.com
@@ -228,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
273
  version: '0'
229
274
  requirements: []
230
275
  rubyforge_project: fidgit
231
- rubygems_version: 1.8.16
276
+ rubygems_version: 1.8.23
232
277
  signing_key:
233
278
  specification_version: 3
234
279
  summary: Fidgit is a GUI library built on Gosu/Chingu