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,38 +1,38 @@
1
- require_relative 'helpers/example_window'
2
-
3
- # Example for Button and ToggleButton
4
- class ExampleState < Fidgit::GuiState
5
- def initialize
6
- super
7
-
8
- vertical do
9
- my_label = label "Label", tip: "I'm a label"
10
-
11
- buttons = []
12
-
13
- # A plain button, with some text on it.
14
- buttons << button("Button", tip: "I'm a button; press me!", shortcut: :auto) do
15
- my_label.text = "Pressed the button!"
16
- end
17
-
18
- # Buttons with icons in each possible positions.
19
- [:left, :right, :top, :bottom].each do |position|
20
- buttons << button("Icon at #{position}", icon: Gosu::Image["head_icon.png"], icon_position: position, icon_options: { factor: 2 }, tip: "I'm a button; press me!", shortcut: :auto) do
21
- my_label.text = "Pressed the button (icon to #{position})!"
22
- end
23
- end
24
-
25
- # A toggling button.
26
- buttons << toggle_button("ToggleButton", tip: "I'm a button that toggles", shortcut: :o) do |sender, value|
27
- my_label.text = "Turned the toggle button #{value ? "on" : "off"}!"
28
- end
29
-
30
- # A toggle-button that controls whether all the other buttons are enabled.
31
- toggle_button("Enable other two buttons", value: true) do |sender, value|
32
- buttons.each {|button| button.enabled = value }
33
- end
34
- end
35
- end
36
- end
37
-
1
+ require_relative 'helpers/example_window'
2
+
3
+ # Example for Button and ToggleButton
4
+ class ExampleState < Fidgit::GuiState
5
+ def initialize
6
+ super
7
+
8
+ vertical do
9
+ my_label = label "Label", tip: "I'm a label"
10
+
11
+ buttons = []
12
+
13
+ # A plain button, with some text on it.
14
+ buttons << button("Button", tip: "I'm a button; press me!", shortcut: :auto) do
15
+ my_label.text = "Pressed the button!"
16
+ end
17
+
18
+ # Buttons with icons in each possible positions.
19
+ [:left, :right, :top, :bottom].each do |position|
20
+ buttons << button("Icon at #{position}", icon: Gosu::Image["head_icon.png"], icon_position: position, icon_options: { factor: 2 }, tip: "I'm a button; press me!", shortcut: :auto) do
21
+ my_label.text = "Pressed the button (icon to #{position})!"
22
+ end
23
+ end
24
+
25
+ # A toggling button.
26
+ buttons << toggle_button("ToggleButton", tip: "I'm a button that toggles", shortcut: :o) do |sender, value|
27
+ my_label.text = "Turned the toggle button #{value ? "on" : "off"}!"
28
+ end
29
+
30
+ # A toggle-button that controls whether all the other buttons are enabled.
31
+ toggle_button("Enable other two buttons", value: true) do |sender, value|
32
+ buttons.each {|button| button.enabled = value }
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
38
  ExampleWindow.new.show
@@ -1,17 +1,17 @@
1
- require_relative 'helpers/example_window'
2
-
3
- class ExampleState < Fidgit::GuiState
4
- def initialize
5
- super
6
-
7
- vertical do
8
- my_label = label 'No color picked'
9
-
10
- color_picker(width: 100) do |sender, color|
11
- my_label.text = color.to_s
12
- end
13
- end
14
- end
15
- end
16
-
1
+ require_relative 'helpers/example_window'
2
+
3
+ class ExampleState < Fidgit::GuiState
4
+ def initialize
5
+ super
6
+
7
+ vertical do
8
+ my_label = label 'No color picked'
9
+
10
+ color_picker(width: 100) do |sender, color|
11
+ my_label.text = color.to_s
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
17
  ExampleWindow.new.show
@@ -1,25 +1,25 @@
1
- require_relative 'helpers/example_window'
2
-
3
- class ExampleState < Fidgit::GuiState
4
- def initialize
5
- super
6
-
7
- vertical do
8
- my_label = label "No color selected."
9
-
10
- group do
11
- grid num_columns: 15, padding: 0, spacing: 4 do
12
- 150.times do
13
- color_well(color: Gosu::Color.rgb(rand(255), rand(255), rand(255)))
14
- end
15
- end
16
-
17
- subscribe :changed do |sender, color|
18
- my_label.text = color.to_s
19
- end
20
- end
21
- end
22
- end
23
- end
24
-
1
+ require_relative 'helpers/example_window'
2
+
3
+ class ExampleState < Fidgit::GuiState
4
+ def initialize
5
+ super
6
+
7
+ vertical do
8
+ my_label = label "No color selected."
9
+
10
+ group do
11
+ grid num_columns: 15, padding: 0, spacing: 4 do
12
+ 150.times do
13
+ color_well(color: Gosu::Color.rgb(rand(255), rand(255), rand(255)))
14
+ end
15
+ end
16
+
17
+ subscribe :changed do |sender, color|
18
+ my_label.text = color.to_s
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
25
  ExampleWindow.new.show
@@ -1,24 +1,24 @@
1
- require_relative 'helpers/example_window'
2
-
3
- # Example for Button and ToggleButton
4
- class ExampleState < Fidgit::GuiState
5
- def initialize
6
- super
7
-
8
- vertical do
9
- my_label = label "Label", tip: "I'm a label"
10
-
11
- combo_box(value: 1, tip: "I'm a combo box; press me and make a selection!") do
12
- subscribe :changed do |sender, value|
13
- my_label.text = "Chose #{value}!"
14
- end
15
-
16
- item "One", 1
17
- item "Two", 2
18
- item "Three", 3
19
- end
20
- end
21
- end
22
- end
23
-
1
+ require_relative 'helpers/example_window'
2
+
3
+ # Example for Button and ToggleButton
4
+ class ExampleState < Fidgit::GuiState
5
+ def initialize
6
+ super
7
+
8
+ vertical do
9
+ my_label = label "Label", tip: "I'm a label"
10
+
11
+ combo_box(value: 1, tip: "I'm a combo box; press me and make a selection!") do
12
+ subscribe :changed do |sender, value|
13
+ my_label.text = "Chose #{value}!"
14
+ end
15
+
16
+ item "One", 1
17
+ item "Two", 2
18
+ item "Three", 3
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
24
  ExampleWindow.new.show
@@ -1,42 +1,42 @@
1
- require_relative 'helpers/example_window'
2
-
3
-
4
- Fidgit::Element.schema.merge_elements!(Element: { font_height: 15 })
5
-
6
- class ExampleState < Fidgit::GuiState
7
- def initialize
8
- super
9
-
10
- container.background_color = Gosu::Color.rgb(50, 50, 50)
11
- vertical align: :center do
12
- full_base_directory = ''
13
- restricted_base_directory = File.expand_path(File.join(__FILE__, '..', '..'))
14
- directory = File.join(restricted_base_directory, 'media', 'images')
15
-
16
- my_label = label "No files are actually loaded or saved by this example"
17
- button("Load...(limited path access)") do
18
- file_dialog(:open, base_directory: restricted_base_directory, directory: directory, pattern: "*.png") do |result, file|
19
- case result
20
- when :open
21
- my_label.text = "Loaded #{file}"
22
- when :cancel
23
- my_label.text = "Loading cancelled"
24
- end
25
- end
26
- end
27
-
28
- button("Save...(unrestricted path access)") do
29
- file_dialog(:save, base_directory: full_base_directory, directory: directory, pattern: "*.png") do |result, file|
30
- case result
31
- when :save
32
- my_label.text = "Saved #{file}"
33
- when :cancel
34
- my_label.text = "Save cancelled"
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
-
1
+ require_relative 'helpers/example_window'
2
+
3
+
4
+ Fidgit::Element.schema.merge_elements!(Element: { font_height: 15 })
5
+
6
+ class ExampleState < Fidgit::GuiState
7
+ def initialize
8
+ super
9
+
10
+ container.background_color = Gosu::Color.rgb(50, 50, 50)
11
+ vertical align: :center do
12
+ full_base_directory = ''
13
+ restricted_base_directory = File.expand_path(File.join(__FILE__, '..', '..'))
14
+ directory = File.join(restricted_base_directory, 'media', 'images')
15
+
16
+ my_label = label "No files are actually loaded or saved by this example"
17
+ button("Load...(limited path access)") do
18
+ file_dialog(:open, base_directory: restricted_base_directory, directory: directory, pattern: "*.png") do |result, file|
19
+ case result
20
+ when :open
21
+ my_label.text = "Loaded #{file}"
22
+ when :cancel
23
+ my_label.text = "Loading cancelled"
24
+ end
25
+ end
26
+ end
27
+
28
+ button("Save...(unrestricted path access)") do
29
+ file_dialog(:save, base_directory: full_base_directory, directory: directory, pattern: "*.png") do |result, file|
30
+ case result
31
+ when :save
32
+ my_label.text = "Saved #{file}"
33
+ when :cancel
34
+ my_label.text = "Save cancelled"
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
42
  ExampleWindow.new.show
@@ -1,29 +1,29 @@
1
- require_relative 'helpers/example_window'
2
-
3
- class ExampleState < Fidgit::GuiState
4
- BORDER_COLOR = Gosu::Color.rgb(255, 0, 0)
5
- FIXED_NUM = 5
6
- NUM_CELLS = 17
7
-
8
- def initialize
9
- super
10
-
11
- vertical do
12
- label "Grid with #{FIXED_NUM} columns"
13
- grid num_columns: FIXED_NUM, border_color: BORDER_COLOR, cell_border_color: Gosu::Color.rgba(0, 255, 0, 255), cell_border_thickness: 1 do
14
- NUM_CELLS.times do |i|
15
- label "Cell #{i}", font_height: rand(15) + 15, border_color: BORDER_COLOR, border_thickness: 1
16
- end
17
- end
18
-
19
- label "Grid with #{FIXED_NUM} rows"
20
- grid num_rows: FIXED_NUM, border_color: BORDER_COLOR, cell_background_color: Gosu::Color.rgba(0, 100, 100, 255) do
21
- NUM_CELLS.times do |i|
22
- label "Cell #{i}", font_height: rand(15) + 15, border_color: BORDER_COLOR, border_thickness: 1
23
- end
24
- end
25
- end
26
- end
27
- end
28
-
1
+ require_relative 'helpers/example_window'
2
+
3
+ class ExampleState < Fidgit::GuiState
4
+ BORDER_COLOR = Gosu::Color.rgb(255, 0, 0)
5
+ FIXED_NUM = 5
6
+ NUM_CELLS = 17
7
+
8
+ def initialize
9
+ super
10
+
11
+ vertical do
12
+ label "Grid with #{FIXED_NUM} columns"
13
+ grid num_columns: FIXED_NUM, border_color: BORDER_COLOR, cell_border_color: Gosu::Color.rgba(0, 255, 0, 255), cell_border_thickness: 1 do
14
+ NUM_CELLS.times do |i|
15
+ label "Cell #{i}", font_height: rand(15) + 15, border_color: BORDER_COLOR, border_thickness: 1
16
+ end
17
+ end
18
+
19
+ label "Grid with #{FIXED_NUM} rows"
20
+ grid num_rows: FIXED_NUM, border_color: BORDER_COLOR, cell_background_color: Gosu::Color.rgba(0, 100, 100, 255) do
21
+ NUM_CELLS.times do |i|
22
+ label "Cell #{i}", font_height: rand(15) + 15, border_color: BORDER_COLOR, border_thickness: 1
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
29
  ExampleWindow.new.show
@@ -1,17 +1,17 @@
1
- require_relative '../../lib/fidgit'
2
-
3
- media_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'media'))
4
- Gosu::Image.autoload_dirs << File.join(media_dir, 'images')
5
- Gosu::Sample.autoload_dirs << File.join(media_dir, 'samples')
6
- Gosu::Font.autoload_dirs << File.join(media_dir, 'fonts')
7
-
8
- class ExampleWindow < Chingu::Window
9
- def initialize(options = {})
10
- super(640, 480, false)
11
-
12
- on_input(:escape) { close }
13
-
14
- caption = "#{File.basename($0).chomp(".rb").tr('_', ' ')} #{ENV['FIDGIT_EXAMPLES_TEXT']}"
15
- push_game_state ExampleState
16
- end
1
+ require_relative '../../lib/fidgit'
2
+
3
+ media_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'media'))
4
+ Gosu::Image.autoload_dirs << File.join(media_dir, 'images')
5
+ Gosu::Sample.autoload_dirs << File.join(media_dir, 'samples')
6
+ Gosu::Font.autoload_dirs << File.join(media_dir, 'fonts')
7
+
8
+ class ExampleWindow < Chingu::Window
9
+ def initialize(options = {})
10
+ super(640, 480, false)
11
+
12
+ on_input(:escape) { close }
13
+
14
+ caption = "#{File.basename($0).chomp(".rb").tr('_', ' ')} #{ENV['FIDGIT_EXAMPLES_TEXT']}"
15
+ push_game_state ExampleState
16
+ end
17
17
  end
@@ -1,23 +1,23 @@
1
- require_relative 'helpers/example_window'
2
-
3
- # Labels can have text and/or icons.
4
- class ExampleState < Fidgit::GuiState
5
- def initialize
6
- super
7
-
8
- vertical background_color: Gosu::Color.rgb(255, 0, 0) do
9
- label "Hello!", tip: 'A label with text'
10
- label "Hello!", icon: Gosu::Image["head_icon.png"], tip: 'A label with text & icon'
11
- label '', icon: Gosu::Image["head_icon.png"], tip: 'A label with just icon'
12
- label '', background_color: Gosu::Color.rgb(0, 255, 0), tip: 'No text or icon'
13
- end
14
-
15
- vertical do
16
- label ":left justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :left, tip: 'A label with text'
17
- label ":right justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :right, tip: 'A label with text'
18
- label ":center justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :center, tip: 'A label with text'
19
- end
20
- end
21
- end
22
-
1
+ require_relative 'helpers/example_window'
2
+
3
+ # Labels can have text and/or icons.
4
+ class ExampleState < Fidgit::GuiState
5
+ def initialize
6
+ super
7
+
8
+ vertical background_color: Gosu::Color.rgb(255, 0, 0) do
9
+ label "Hello!", tip: 'A label with text'
10
+ label "Hello!", icon: Gosu::Image["head_icon.png"], tip: 'A label with text & icon'
11
+ label '', icon: Gosu::Image["head_icon.png"], tip: 'A label with just icon'
12
+ label '', background_color: Gosu::Color.rgb(0, 255, 0), tip: 'No text or icon'
13
+ end
14
+
15
+ vertical do
16
+ label ":left justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :left, tip: 'A label with text'
17
+ label ":right justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :right, tip: 'A label with text'
18
+ label ":center justification", width: 400, background_color: Gosu::Color.rgb(0, 100, 0), justify: :center, tip: 'A label with text'
19
+ end
20
+ end
21
+ end
22
+
23
23
  ExampleWindow.new.show
@@ -1,23 +1,23 @@
1
- require_relative 'helpers/example_window'
2
-
3
- # Labels can have text and/or icons.
4
- class ExampleState < Fidgit::GuiState
5
- def initialize
6
- super
7
-
8
- vertical do
9
- my_label = label "No clicky"
10
-
11
- list do
12
- item "chunky bacon", :CHUNKYBACON, tip: "You prefer Chunky Bacon, don't you?"
13
- item "lentils", :LENTILS, tip: "Lentils? Well, I suppose someone has to like them"
14
-
15
- subscribe :changed do |sender, value|
16
- my_label.text = "I like #{value} more than anything in the world!"
17
- end
18
- end
19
- end
20
- end
21
- end
22
-
1
+ require_relative 'helpers/example_window'
2
+
3
+ # Labels can have text and/or icons.
4
+ class ExampleState < Fidgit::GuiState
5
+ def initialize
6
+ super
7
+
8
+ vertical do
9
+ my_label = label "No clicky"
10
+
11
+ list do
12
+ item "chunky bacon", :CHUNKYBACON, tip: "You prefer Chunky Bacon, don't you?"
13
+ item "lentils", :LENTILS, tip: "Lentils? Well, I suppose someone has to like them"
14
+
15
+ subscribe :changed do |sender, value|
16
+ my_label.text = "I like #{value} more than anything in the world!"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
23
  ExampleWindow.new.show