Permalink
Browse files

Corrected many design issues with Framework. ::App, ::Flow, ::Button …

…now work in both SwtShoes and SwingShoes.

./samples/simple_sound.rb demonstrates proper Flow and Button
  • Loading branch information...
1 parent 6972a27 commit 847f85c5ed15686a42c07d49e01d85f8bc2ec71c @pjfitzgibbons pjfitzgibbons committed Feb 15, 2012
Showing with 408 additions and 462 deletions.
  1. +16 −6 bin/rspec-swt
  2. BIN lib/jl1.0.1.jar
  3. BIN lib/jogg-0.0.7.jar
  4. BIN lib/jorbis-0.0.15.jar
  5. BIN lib/mp3spi1.9.5.jar
  6. +2 −2 lib/shoes.rb
  7. +1 −4 lib/shoes/app.rb
  8. +19 −0 lib/shoes/button.rb
  9. +6 −1 lib/shoes/element_methods.rb
  10. +32 −0 lib/shoes/sound.rb
  11. +1 −1 lib/swing_shoes.rb
  12. +12 −10 lib/swing_shoes/app.rb
  13. +27 −0 lib/swing_shoes/button.rb
  14. +1 −0 lib/swing_shoes/flow.rb
  15. +51 −0 lib/swing_shoes/sound.rb
  16. +1 −0 lib/swt_shoes.rb
  17. +2 −0 lib/swt_shoes/app.rb
  18. +22 −0 lib/swt_shoes/button.rb
  19. BIN lib/tritonus_share.jar
  20. BIN lib/vorbisspi1.0.3.jar
  21. +1 −0 lib/white_shoes.rb
  22. +15 −0 lib/white_shoes/button.rb
  23. +0 −21 rspec-swing
  24. +0 −21 rspec-swt
  25. +0 −21 rspec-white
  26. +1 −0 rspec.readme
  27. +17 −0 samples/simple-sound.rb
  28. +1 −1 spec/shoes/app_spec.rb
  29. +21 −0 spec/shoes/button_spec.rb
  30. +73 −0 spec/swing_shoes/button_spec.rb
  31. +4 −3 spec/swt_shoes/app_spec.rb
  32. +75 −0 spec/swt_shoes/button_spec.rb
  33. +1 −1 todo/spec_white_shoes_button_spec.rb → spec/white_shoes/button_spec.rb
  34. +4 −4 spec/white_shoes/shared_examples/shared_shoes_button_spec.rb
  35. +2 −4 swing-shoooesd
  36. +0 −16 todo/shoes_button.rb
  37. +0 −11 todo/spec/shoes/configuration_spec.rb
  38. +0 −40 todo/spec/shoes/elementary_button_spec.rb
  39. +0 −17 todo/spec/shoes/image_spec.rb
  40. +0 −5 todo/spec/shoes/native_spec.rb
  41. +0 −36 todo/spec/shoes/stack_spec.rb
  42. +0 −27 todo/spec/shoes/window_spec.rb
  43. +0 −16 todo/spec/swt/animation_spec.rb
  44. +0 −34 todo/spec/swt/runnable_block_spec.rb
  45. +0 −9 todo/spec_shoes_button_spec.rb
  46. +0 −49 todo/spec_swing_shoes_button_spec.rb
  47. +0 −49 todo/spec_swt_shoes_button_spec.rb
  48. +0 −28 todo/swing_shoes_button.rb
  49. +0 −17 todo/swt_shoes_button.rb
  50. +0 −8 todo/white_shoes_button.rb
View
@@ -1,16 +1,26 @@
-# !/usr/bin/env jruby
+#!/usr/bin/env jruby --1.9 -J-XstartOnFirstThread
#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#
-require 'pathname'
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
- Pathname.new(__FILE__).realpath)
+# http://jira.codehaus.org/browse/JRUBY-6324
+# random seed for srand is not initialized properly
+# call once and throw-away nil default first value
+x = srand
require 'rubygems'
-require 'bundler/setup'
-load Gem.bin_path('rspec-core', 'rspec')
+version = ">= 0"
+
+if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
+ version = $1
+ ARGV.shift
+end
+
+gem 'rspec-core', version
+load Gem.bin_path('rspec-core', 'rspec', version)
+
+exit 0
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -21,11 +21,11 @@ module Shoes
#require 'shoes/runnable_block'
#require 'shoes/timer_base'
#require 'shoes/layout'
-#require 'shoes/button'
+require 'shoes/button'
#require 'shoes/stack'
require 'shoes/flow'
#require 'shoes/edit_line'
#require 'shoes/edit_box'
#require 'shoes/check'
#require 'shoes/image'
-
+require 'shoes/sound'
View
@@ -31,13 +31,10 @@ def initialize(opts={}, &blk)
self.title = opts['title']
self.opts = opts
- self.blk = blk
gui_init
- flow do
- instance_eval &blk if blk
- end
+ instance_eval &blk if blk
gui_open
View
@@ -0,0 +1,19 @@
+module Shoes
+ class Button
+
+ attr_accessor :gui_container, :click_event_lambda
+ attr_accessor :gui_element
+ attr_accessor :text, :width, :height
+
+ def initialize(gui_container, text = 'Button', opts={}, click_event_lambda = nil)
+ self.gui_container = gui_container
+ self.click_event_lambda = click_event_lambda
+ self.text = text
+ self.height = opts[:height]
+ self.width = opts[:width]
+
+ gui_button_init
+ end
+
+ end
+end
@@ -18,7 +18,7 @@ def flow(opts = {}, &blk)
def button(text, opts={}, &blk)
- button = Shoes::Button.new(gui_container, text, opts, &blk)
+ button = Shoes::Button.new(self.gui_container, text, opts, blk)
#@elements[button.to_s] = button
#button
end
@@ -27,6 +27,11 @@ def animate(fps = 10, &blk)
anim = Shoes::Animation.new(self, fps, &blk)
end
+ # similar controls as Shoes::Video (#video)
+ def sound(soundfile, opts = {}, &blk)
+ playable_sound = Shoes::Sound.new(gui_container, soundfile, opts, &blk)
+ end
+
#
#def image(path, opts={})
# image = Image.new(path, @current_panel, opts)
View
@@ -0,0 +1,32 @@
+require 'facets/hash'
+
+module Shoes
+ class Flow
+
+ include Shoes::ElementMethods
+
+ attr_accessor :parent_container, :parent_gui_container, :gui_container
+ attr_accessor :blk
+ attr_accessor :width, :height, :margin
+
+
+ def initialize(parent_container, parent_gui_container, opts={}, blk = nil)
+ self.parent_container = parent_container
+ self.parent_gui_container = parent_gui_container
+ opts.stringify_keys!
+
+ self.width = opts['width']
+ self.height = opts['height']
+ self.margin = opts['margin']
+
+ self.blk = blk
+
+ gui_flow_init
+
+ instance_eval &blk unless blk.nil?
+
+ gui_flow_add_to_parent
+
+ end
+ end
+end
View
@@ -4,7 +4,7 @@
require 'swing_shoes/flow'
require 'swing_shoes/common_methods'
-#require 'swing_shoes/button'
+require 'swing_shoes/button'
module SwingShoes
View
@@ -2,7 +2,7 @@ module SwingShoes
module App
- attr_reader :frame, :container
+ attr_accessor :frame
import javax.swing.JPanel
import javax.swing.JFrame
@@ -13,25 +13,27 @@ module App
def gui_init
- frame = JFrame.new()
+ self.frame = JFrame.new()
- self.gui_container = container = frame.get_content_pane
+ self.gui_container = frame.get_content_pane
layout = FlowLayout.new(FlowLayout::LEFT)
- frame.setLayout(layout)
+ self.frame.setLayout(layout)
- instance_eval &blk if blk
+ self.frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
- frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
+ end
+
+ def gui_open
if opts['pack']
- frame.pack
+ self.frame.pack
else
- frame.setSize(Dimension.new(self.width, self.height))
- container.setSize(Dimension.new(self.width, self.height))
+ self.frame.setSize(Dimension.new(self.width, self.height))
+ self.gui_container.setSize(Dimension.new(self.width, self.height))
end
- frame.set_visible(true)
+ self.frame.set_visible(true)
end
end
View
@@ -0,0 +1,27 @@
+module SwingShoes
+ module Button
+
+ include SwingShoes::CommonMethods
+
+ attr_accessor :native_widget
+
+ import javax.swing.JButton
+
+ def gui_button_init
+ #def initialize(parent, text = 'Button', opts={}, &blk)
+ self.gui_element = button = JButton.new(self.text)
+ button.add_action_listener(self.click_event_lambda) if self.click_event_lambda
+ self.gui_container.add(button)
+ end
+
+ end
+end
+
+
+module Shoes
+ class Button
+ include SwingShoes::Button
+ end
+end
+
+
View
@@ -38,6 +38,7 @@ def gui_flow_init
def gui_flow_add_to_parent
self.parent_gui_container.add(self.gui_container, BorderLayout::CENTER)
+ self.gui_container.set_visible(true)
end
end
end
View
@@ -0,0 +1,51 @@
+require 'shoes/layout'
+
+module SwingShoes
+ module Flow
+ import java.awt.BorderLayout
+ import java.awt.Dimension
+ import java.awt.FlowLayout
+ import javax.swing.JPanel
+ import javax.swing.BoxLayout
+
+ import javax.swing.border.EmptyBorder
+
+ def gui_flow_init
+ #def initialize(parent_container, opts={}, &blk)
+ # opts.stringify_keys!
+ # @parent_container = parent_container
+ self.gui_container = container = JPanel.new()
+ #layout = BoxLayout.new(@container, BoxLayout::LINE_AXIS)
+ layout = FlowLayout.new
+ layout.alignment = FlowLayout::LEFT
+
+ container.set_layout(layout)
+
+ #debugger
+ unless self.parent_gui_container.is_a? BorderLayout
+ if (self.height && self.width)
+ container.set_preferred_size(Dimension.new(self.width, self.height))
+ end
+ end
+
+ if self.margin
+ container.border = EmptyBorder.new(margin, margin, margin, margin)
+ #@container.border = javax.swing.border.LineBorder.new(java.awt.Color::RED, 2, true)
+ #@container.setBackground(java.awt.Color::PINK)
+ end
+
+ end
+
+ def gui_flow_add_to_parent
+ self.parent_gui_container.add(self.gui_container, BorderLayout::CENTER)
+ end
+ end
+end
+
+
+module Shoes
+ class Flow
+ include SwingShoes::Flow
+ end
+end
+
View
@@ -12,6 +12,7 @@ def window(*a, &b)
require 'swt_shoes/layout'
#require 'swt_shoes/window'
require 'swt_shoes/flow'
+require 'swt_shoes/button'
module SwtShoes
module Shoes
View
@@ -11,6 +11,8 @@ module App
def gui_init
self.gui_container = container = Swt::Widgets::Shell.new(Swt.display, Swt::SWT::CLOSE)
+ layout = Swt::Layout::RowLayout.new
+ container.setLayout(layout)
opts = self.opts
View
@@ -0,0 +1,22 @@
+module SwtShoes
+ module Button
+
+ def gui_button_init
+ # Create a button on the specified _shell_
+ #def initialize(container, text = 'Button', opts = {}, &blk)
+ self.gui_element = button = Swt::Widgets::Button.new(self.gui_container, Swt::SWT::PUSH)
+ button.setText(self.text)
+ #@native_widget.setBounds(10, 10, 150, 30)
+
+ button.addSelectionListener(self.click_event_lambda) if click_event_lambda
+ button.pack
+ end
+
+ end
+end
+
+module Shoes
+ class Button
+ include SwtShoes::Button
+ end
+end
View
Binary file not shown.
View
Binary file not shown.
View
@@ -2,6 +2,7 @@
#require 'white_shoes/base'
require 'white_shoes/app'
require 'white_shoes/flow'
+require 'white_shoes/button'
require 'rubygems'
require 'facets/hash'
View
@@ -0,0 +1,15 @@
+module WhiteShoes
+ module Button
+ def gui_button_init
+ self.gui_element = "A new gui Button"
+ end
+ end
+
+end
+
+module Shoes
+ class Button
+ include WhiteShoes::Button
+ end
+end
+
View
@@ -1,21 +0,0 @@
-#!/usr/bin/env jruby --1.9 --debug
-#
-# This file was generated by RubyGems.
-#
-# The application 'rspec-core' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0"
-
-if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
- version = $1
- ARGV.shift
-end
-
-gem 'rspec-core', version
-load Gem.bin_path('rspec-core', 'rspec', version)
-
-exit 0
View
@@ -1,21 +0,0 @@
-#!/usr/bin/env jruby --1.9 --debug -J-XstartOnFirstThread
-#
-# This file was generated by RubyGems.
-#
-# The application 'rspec-core' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require 'rubygems'
-
-version = ">= 0"
-
-if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
- version = $1
- ARGV.shift
-end
-
-gem 'rspec-core', version
-load Gem.bin_path('rspec-core', 'rspec', version)
-
-exit 0
Oops, something went wrong.

0 comments on commit 847f85c

Please sign in to comment.