-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change SwtShoes to Swt::Shoes. Close #6
Note, this commit doesn't change the directory structure of specs.
- Loading branch information
1 parent
76efabe
commit c176f22
Showing
36 changed files
with
530 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
call jruby --1.9 -e "$:<< 'lib'; require 'shoes'; require 'shoes/configuration'; Shoes.configuration.framework = 'swt_shoes'; require '%1' " | ||
call jruby --1.9 -e "$:<< 'lib'; require 'shoes'; require 'shoes/configuration'; Shoes.configuration.framework = 'shoes/swt'; require '%1' " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
call jruby --1.9 --debug -e "$:<< 'lib'; require 'shoes'; require 'shoes/configuration'; Shoes.configuration.framework = 'swt_shoes'; require '%1' " | ||
call jruby --1.9 --debug -e "$:<< 'lib'; require 'shoes'; require 'shoes/configuration'; Shoes.configuration.framework = 'shoes/swt'; require '%1' " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'shoes/timer_base' | ||
|
||
module Shoes | ||
module Swt | ||
module Animation | ||
def gui_init | ||
# Wrap the animation block so we can count frames. | ||
# Note that the task re-calls itself on each run. | ||
task = Proc.new do | ||
@blk.call(@current_frame) | ||
@current_frame += 1 | ||
@app.gui_container.redraw | ||
::Swt.display.timer_exec (2000 / @framerate), task | ||
end | ||
::Swt.display.timer_exec (2000 / @framerate), task | ||
end | ||
|
||
#def stop | ||
#end | ||
|
||
#def start | ||
#end | ||
end | ||
end | ||
end | ||
|
||
module Shoes | ||
class Animation | ||
include Shoes::Swt::Animation | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'swt' | ||
|
||
#require 'shoes/framework_adapters/swt_shoes/window' | ||
|
||
module Shoes | ||
module Swt | ||
|
||
# Shoes::App.new creates a new Shoes application window! | ||
# The default window is a [flow] | ||
# | ||
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 | ||
|
||
container.setSize(self.width, self.height) | ||
container.setText(self.title) | ||
|
||
container.addListener(::Swt::SWT::Close, main_window_on_close) | ||
end | ||
|
||
|
||
def gui_open | ||
self.gui_container.open | ||
|
||
::Swt.event_loop { ::Swt.display.isDisposed } | ||
|
||
Shoes.logger.debug "::Swt.display disposed... exiting Shoes::App.new" | ||
end | ||
|
||
private | ||
def main_window_on_close | ||
lambda { | ||
Shoes.logger.debug "main_window on_close block begin... disposing ::Swt.display" | ||
::Swt.display.dispose | ||
Shoes.logger.debug "::Swt.display disposed" | ||
} | ||
end | ||
end | ||
end | ||
end | ||
|
||
module Shoes | ||
class App | ||
include Shoes::Swt::App | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Shoes | ||
module Swt | ||
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 | ||
|
||
def move(left, top) | ||
super(left, top) | ||
unless gui_element.disposed? | ||
# If this element is part of a layout, we need to pop it into its own | ||
# composite layer before moving it, so the rest of of the elements in | ||
# the layout can reflow. | ||
if gui_container.get_layout | ||
old_gui_container = self.gui_container | ||
self.gui_container = ::Swt::Widgets::Composite.new(@app.gui_container, ::Swt::SWT::NO_BACKGROUND) | ||
self.gui_element.dispose | ||
self.gui_container.set_layout nil | ||
self.gui_element = ::Swt::Widgets::Button.new(gui_container, ::Swt::SWT::PUSH).tap do |button| | ||
button.set_text(self.text) | ||
button.add_selection_listener(self.click_event_lambda) if click_event_lambda | ||
button.pack | ||
end | ||
self.gui_container.set_bounds(0, 0, @app.gui_container.size.x, @app.gui_container.size.y) | ||
self.gui_container.move_above(old_gui_container) | ||
old_gui_container.layout | ||
end | ||
self.gui_element.set_location left, top | ||
self.gui_element.redraw | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
module Shoes | ||
class Button | ||
include Shoes::Swt::Button | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Shoes | ||
module Swt | ||
module Color | ||
def to_native | ||
::Swt::Graphics::Color.new(Shoes.display, @red, @green, @blue) | ||
end | ||
end | ||
end | ||
end | ||
|
||
module Shoes | ||
class Color | ||
include Shoes::Swt::Color | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module Shoes | ||
module Swt | ||
# flow takes these options | ||
# :margin - integer - add this many pixels to all 4 sides of the layout | ||
|
||
module Flow | ||
|
||
def gui_flow_init | ||
self.gui_container = container = ::Swt::Widgets::Composite.new(self.parent_gui_container, ::Swt::SWT::NO_BACKGROUND) | ||
|
||
# RowLayout is horizontal by default, wrapping by default | ||
layout = ::Swt::Layout::RowLayout.new | ||
|
||
# set the margins | ||
set_margin(layout) | ||
|
||
if self.width && self.height | ||
container.setSize(self.width, self.height) | ||
end | ||
|
||
container.setLayout(layout) | ||
end | ||
|
||
def gui_flow_add_to_parent | ||
#self.parent_gui_container.add(self.gui_container) | ||
end | ||
|
||
# Add this many pixels to margins on layout | ||
def set_margin(layout) | ||
if margin_pixels = self.margin | ||
layout.marginTop = margin_pixels | ||
layout.marginRight = margin_pixels | ||
layout.marginBottom = margin_pixels | ||
layout.marginLeft = margin_pixels | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
module Shoes | ||
class Flow | ||
include Shoes::Swt::Flow | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Shoes | ||
module Swt | ||
module Line | ||
attr_reader :gui_container, :gui_element | ||
attr_reader :gui_paint_callback | ||
|
||
def gui_init | ||
# @gui_opts must be provided if this shape is responsible for | ||
# drawing itself. If this shape is part of another shape, then | ||
# @gui_opts should be nil | ||
if @gui_opts | ||
@gui_container = @gui_opts[:container] | ||
default_paint_callback = lambda do |event| | ||
gc = event.gc | ||
gc.set_antialias ::Swt::SWT::ON | ||
gc.set_foreground self.stroke.to_native | ||
gc.set_line_width self.style[:strokewidth] | ||
gc.draw_line(@left, @top, right, bottom) | ||
end | ||
@gui_paint_callback = @gui_opts[:paint_callback] || default_paint_callback | ||
@gui_container.add_paint_listener(@gui_paint_callback) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
module Shoes | ||
class Line | ||
include Shoes::Swt::Line | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Shoes | ||
module Swt | ||
module Oval | ||
attr_reader :gui_container, :gui_element | ||
attr_reader :gui_paint_callback | ||
|
||
# FIXME: This (mostly) duplicates Shoes::Swt::Line#gui_init | ||
def gui_init | ||
# @gui_opts must be provided if this shape is responsible for | ||
# drawing itself. If this shape is part of another shape, then | ||
# @gui_opts should be nil | ||
if @gui_opts | ||
@gui_container = @gui_opts[:container] | ||
@gui_paint_callback = lambda do |event| | ||
gc = event.gc | ||
gc.set_antialias ::Swt::SWT::ON | ||
gc.set_background self.fill.to_native | ||
gc.fill_oval(@left, @top, @width, @height) | ||
gc.set_foreground self.stroke.to_native | ||
gc.set_line_width self.style[:strokewidth] | ||
gc.draw_oval(@left, @top, @width, @height) | ||
end | ||
@gui_container.add_paint_listener(@gui_paint_callback) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
module Shoes | ||
class Oval | ||
include Shoes::Swt::Oval | ||
end | ||
end |
Oops, something went wrong.