Created
September 25, 2012 05:20
-
-
Save nasser/3780145 to your computer and use it in GitHub Desktop.
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
module UI | |
class Canvas | |
def initialize x, y, w, h | |
@pointer = Native.ofxuicanvas_new x.to_f, y.to_f, w.to_f, h.to_f | |
end | |
def font file | |
Native.ofxuicanvas_setFont @pointer, File.expand_path(file).to_ptr, true, true, true, 0.0, 150 | |
end | |
def add_button name, value, x, y, w, h | |
Native.ofxuicanvas_addButton @pointer, name.to_ptr, value, x.to_f, y.to_f, w.to_f, h.to_f | |
end | |
def add_slider name, value, min, max, x, y, w, h | |
Native.ofxuicanvas_addSlider @pointer, name.to_ptr, min.to_f, max.to_f, value.to_f, x.to_f, y.to_f, w.to_f, h.to_f | |
end | |
def draw | |
Native.ofxuicanvas_draw @pointer | |
end | |
module Native | |
extend FFI::Cpp::Library | |
ffi_lib "scratch/ofxUI.so" | |
typedef :pointer, :ofxUIWidget | |
enum :ofxWidgetAlignment, | |
[ :align_left, | |
:align_free, | |
:align_right, | |
:align_top, | |
:align_bottom ] | |
attach_constructor :ofxUICanvas, 528, [:float, :float, :float, :float] | |
attach_method :ofxUICanvas, :addWidgetDown, [:ofxUIWidget, :ofxWidgetAlignment, :bool], :pointer | |
attach_method :ofxUICanvas, :setFont, [:stdstring, :bool, :bool, :bool, :float, :int], :bool | |
attach_method :ofxUICanvas, :addButton, [:stdstring, :bool, :float, :float, :float, :float], :pointer | |
attach_method :ofxUICanvas, :addFPS, [:int], :pointer | |
attach_method :ofxUICanvas, :addSlider, [:stdstring, :float, :float, :float, :float, :float, :float, :float], :pointer | |
attach_method :ofxUICanvas, :draw, [], :void | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment