Skip to content

Commit

Permalink
for issue #54 - create a svghandle method for canvas.
Browse files Browse the repository at this point in the history
* very experimental at this point - code probably seg faults
  but it's all wired into the shoes maze.
* see https://github.com/Shoes3/shoes3/wiki/Creating-a-Class-for-Shoes-in-C
* some left over bits for the walkabout transition.
  • Loading branch information
Cecil committed Nov 10, 2015
1 parent 6758f4e commit 5e87671
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app.yaml
Expand Up @@ -7,4 +7,4 @@ revision: git
icons:
win32: platform/msw/shoes.ico
osx: static/Shoes.icns
gtk: static/shoes-icon-federales.png
gtk: static/shoes-icon-walkabout.png
4 changes: 4 additions & 0 deletions bugs/bug054.rb
@@ -0,0 +1,4 @@
# simple test of svghandle class
Shoes.app do
svgh = svghandle.new("string");
end
34 changes: 0 additions & 34 deletions make/xsnow/tasks.rb
Expand Up @@ -128,10 +128,7 @@ def pre_build
dylibs = get_dylibs f
dylibs.each do |dylib|
if @brew_hsh[File.basename(dylib)]
#if dylib =~ /\/usr\/local\//
sh "install_name_tool -change #{dylib} @executable_path/../#{File.basename dylib} #{f}"
#elsif dylib =~ /libz/ #10.9 has it in /usr/lib/libz.1.dylib
#sh "install_name_tool -change #{dylib} @executable_path/../#{File.basename dylib} #{f}"
else
puts "Bundle lib missing #{dylib}"
end
Expand All @@ -148,7 +145,6 @@ def change_install_names
sh "install_name_tool -id @executable_path/#{File.basename f} #{f}"
dylibs = get_dylibs f
dylibs.each do |dylib|
# another Cecil hack Should do the install_name_tool stuff
chmod 0755, dylib if File.writable? dylib
sh "install_name_tool -change #{dylib} @executable_path/#{File.basename dylib} #{f}"
end
Expand All @@ -158,38 +154,11 @@ def change_install_names

def copy_pango_modules
puts "Entering copy_pango_modules #{`pwd`}"
#modules_file = `brew --prefix`.chomp << '/etc/pango/pango.modules'
#modules_file = "deps/osx/10.6/pango.modules"
#modules_path = File.open(modules_file) {|f| f.grep(/^# ModulesPath = (.*)$/){$1}.first}
mkdir_p "#{TGT_DIR}/pango/modules"
#cp_r modules_path, "#{TGT_DIR}/pango"
#cp_r "#{BREWLOC}/lib/pango", "#{TGT_DIR}"
#Dir.glob("#{BREWLOC}/lib/pango/**/modules/*.so").each do |f|
# cp f, "#{TGT_DIR}/pango/modules"
# chmod 0755, "#{TGT_DIR}/pango/modules/#{File.basename(f)}"
#end
#cp `which pango-querymodules`.chomp, "#{TGT_DIR}/"
#cp "#{BREWLOC}/bin/pango-querymodules", "#{TGT_DIR}/"
#chmod 0755, "#{TGT_DIR}/pango-querymodules"
puts "Leaving copy_pango_modules"
end

def copy_gem_deplibs
puts "Entering copy_gem_deplibs"
#versions = Dir.glob("#{ENV['SQLLOC']}/Cellar/sqlite/*")
#newest = versions[-1]
#['libsqlite3.dylib'].each do |lib| #, 'libiconv.2.dylib', 'libz.1.dylib',
#'libcrypto.dylib'].each do |lib|
[].each do |lib|
cp "#{BREWLOC}/opt/zlib/lib/#{lib}", "#{TGT_DIR}"
chmod 0755, "#{TGT_DIR}/#{lib}"
end
#['libxml2.dylib', 'libintl.8.dylib']
[].each do |lib|
cp "#{BREWLOC}/lib/#{lib}", "#{TGT_DIR}"
puts "copy_gem_deplibs copied #{lib}"
chmod 0755, "#{TGT_DIR}/#{lib}"
end
puts "leaving copy_gem_deplib"
end

Expand Down Expand Up @@ -223,8 +192,6 @@ def copy_deps_to_dist
# of those dependencies. Finally, add any oddballs that must be
# included.
dylibs = get_dylibs("#{TGT_DIR}/#{NAME}-bin")
#pqlibs = get_dylibs("#{TGT_DIR}/pango-querymodules")
#dylibs.concat pqlibs
# add the gem's bundles.
rbvm = RUBY_V[/^\d+\.\d+/]
Dir["#{TGT_DIR}/lib/ruby/gems/#{rbvm}.0/gems/**/*.bundle"].each do |gb|
Expand Down Expand Up @@ -254,7 +221,6 @@ def copy_deps_to_dist
# the code below won't be triggered if they are.
puts "Adding #{libn}"
@brew_hsh[keyf] = libn
#cp @brew_hsh[keyf], "#{TGT_DIR}/" unless File.exists? "#{TGT_DIR}/#{keyf}"
cp "#{BREWLOC}/lib/#{keyf}", "#{TGT_DIR}/" unless File.exists? "#{TGT_DIR}/#{keyf}"
chmod 0755, "#{TGT_DIR}/#{keyf}" unless File.writable? "#{TGT_DIR}/#{keyf}"
else
Expand Down
2 changes: 2 additions & 0 deletions make/xwin7/env.rb
Expand Up @@ -197,6 +197,8 @@ def xfixrvmp(path)
'harfbuzz' => "#{bindll}/libharfbuzz-0.dll",
'png16' => "#{bindll}/libpng16-16.dll",
'xml2' => "#{bindll}/libxml2-2.dll",
'croco' => "#{bindll}/libcroco-0.6-3.dll",
'rsvg' => "#{bindll}/librsvg-2-2.dll",
'thread' => "#{bindll}/libgthread-2.0-0.dll",
'zlib1' => "#{bindll}/zlib1.dll",
'siji' => "/usr/lib/gcc/i686-w64-mingw32/4.8/libgcc_s_sjlj-1.dll",
Expand Down
13 changes: 13 additions & 0 deletions shoes/canvas.c
Expand Up @@ -779,6 +779,19 @@ shoes_canvas_timer(int argc, VALUE *argv, VALUE self)
return timer;
}

VALUE
shoes_canvas_svghandle(int argc, VALUE *argv, VALUE self)
{
rb_arg_list args;
VALUE handle;
SETUP();

rb_parse_args(argc, argv, "|I&", &args);
handle = shoes_svghandle_new(cSvgHandle, self);
rb_ary_push(canvas->app->extras, handle);
return handle;
}

VALUE
shoes_canvas_shape(int argc, VALUE *argv, VALUE self)
{
Expand Down
5 changes: 5 additions & 0 deletions shoes/canvas.h
Expand Up @@ -405,6 +405,7 @@ VALUE shoes_canvas_image(int, VALUE *, VALUE);
VALUE shoes_canvas_animate(int, VALUE *, VALUE);
VALUE shoes_canvas_every(int, VALUE *, VALUE);
VALUE shoes_canvas_timer(int, VALUE *, VALUE);
VALUE shoes_canvas_svghandle(int, VALUE *, VALUE);
VALUE shoes_canvas_imagesize(VALUE, VALUE);
VALUE shoes_canvas_shape(int, VALUE *, VALUE);
void shoes_canvas_remove_item(VALUE, VALUE, char, char);
Expand Down Expand Up @@ -575,6 +576,10 @@ VALUE shoes_timer_start(VALUE);
VALUE shoes_timer_stop(VALUE);
void shoes_timer_call(VALUE);

VALUE shoes_svghandle_new(VALUE, VALUE);
VALUE shoes_svghandle_alloc(VALUE);
VALUE shoes_svghandle_close(VALUE);

void shoes_color_mark(shoes_color *);
VALUE shoes_color_new(int, int, int, int);
VALUE shoes_color_alloc(VALUE);
Expand Down
24 changes: 24 additions & 0 deletions shoes/ruby.c
Expand Up @@ -15,6 +15,7 @@

VALUE cShoes, cApp, cDialog, cTypes, cShoesWindow, cMouse, cCanvas, cFlow, cStack, cMask, cWidget, cShape, cImage, cEffect, cVideo, cTimerBase, cTimer, cEvery, cAnim, cPattern, cBorder, cBackground, cTextBlock, cPara, cBanner, cTitle, cSubtitle, cTagline, cCaption, cInscription, cTextClass, cSpan, cDel, cStrong, cSub, cSup, cCode, cEm, cIns, cLinkUrl, cNative, cButton, cCheck, cRadio, cEditLine, cEditBox, cListBox, cProgress, cSlider, cColor, cDownload, cResponse, cColors, cLink, cLinkHover, ssNestSlot;
VALUE cTextEditBox;
VALUE cSvgHandle;
VALUE eVlcError, eImageError, eInvMode, eNotImpl;
VALUE reHEX_SOURCE, reHEX3_SOURCE, reRGB_SOURCE, reRGBA_SOURCE, reGRAY_SOURCE, reGRAYA_SOURCE, reLF;
VALUE symAltQuest, symAltSlash, symAltDot, symAltEqual, symAltSemiColon;
Expand Down Expand Up @@ -4116,6 +4117,25 @@ shoes_timer_draw(VALUE self, VALUE c, VALUE actual)
return self;
}

// new in 3.3.0

VALUE
shoes_svghandle_new(VALUE klass, VALUE arg)
{
return Qnil;
}
VALUE
shoes_svghandle_alloc(VALUE klass)
{
return Qnil;
}

VALUE
shoes_svghandle_close(VALUE self)
{
return Qnil;
}

void
shoes_msg(ID typ, VALUE str)
{
Expand Down Expand Up @@ -4979,6 +4999,10 @@ shoes_ruby_init()
cAnim = rb_define_class_under(cTypes, "Animation", cTimerBase);
cEvery = rb_define_class_under(cTypes, "Every", cTimerBase);
cTimer = rb_define_class_under(cTypes, "Timer", cTimerBase);

cSvgHandle = rb_define_class_under(cTypes, "SvgHandle", rb_cObject);
rb_define_alloc_func(cSvgHandle, shoes_svghandle_alloc);
rb_define_method(cSvgHandle, "close", CASTHOOK(shoes_svghandle_close), 0);

cColor = rb_define_class_under(cTypes, "Color", rb_cObject);
rb_define_alloc_func(cColor, shoes_color_alloc);
Expand Down
2 changes: 2 additions & 0 deletions shoes/ruby.h
Expand Up @@ -85,6 +85,7 @@ extern VALUE cTextClass, cSpan, cStrong, cSub, cSup, cCode, cDel, cEm, cIns, cBu
extern VALUE cEditLine, cEditBox, cListBox, cProgress, cSlider, cCheck, cRadio, cColor;
extern VALUE cDownload, cResponse, cColors, cLink, cLinkHover, ssNestSlot;
extern VALUE cTextEditBox;
extern VALUE cSvgHandle;
extern VALUE aMsgList;
extern VALUE eInvMode, eNotImpl, eImageError;
extern VALUE reHEX_SOURCE, reHEX3_SOURCE, reRGB_SOURCE, reRGBA_SOURCE, reGRAY_SOURCE, reGRAYA_SOURCE, reLF;
Expand Down Expand Up @@ -249,6 +250,7 @@ SYMBOL_DEFS(SYMBOL_EXTERN);
f("+animate", animate, -1); \
f("+every", every, -1); \
f("+timer", timer, -1); \
f("+svghandle", svghandle, -1); \
f("+shape", shape, -1); \
f(".move_to", move_to, 2); \
f(".line_to", line_to, 2); \
Expand Down

0 comments on commit 5e87671

Please sign in to comment.