SVG support for Shoes #54

Closed
BackOrder opened this Issue Feb 4, 2015 · 165 comments

Comments

Projects
None yet
4 participants
@BackOrder
Collaborator

BackOrder commented Feb 4, 2015

Cairo supports SVG rendering through libRSVG.

https://wiki.gnome.org/action/show/Projects/LibRsvg?action=show&redirect=LibRsvg

From http://cairographics.org/examples/

  • librsvg is a SVG rendering library supporting a large subset of SVG 1.1.
  • Mozilla is using cairo to render SVG content as of Firefox 1.5 and 2.0. As of Firefox 3.0 it uses cairo for rendering all content and UI.
@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 5, 2015

Collaborator

Shoes::SVG should allow reading data from a string rather than a file and render its content on screen. It would still be possible to load a file in any event, such as in the example below. Or, perhaps, it should check whether a file or a string is passed and load data accordingly.

Shoes.app {
   svg(File.read("bunny.svg"))
}
Collaborator

BackOrder commented Feb 5, 2015

Shoes::SVG should allow reading data from a string rather than a file and render its content on screen. It would still be possible to load a file in any event, such as in the example below. Or, perhaps, it should check whether a file or a string is passed and load data accordingly.

Shoes.app {
   svg(File.read("bunny.svg"))
}
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Feb 5, 2015

Contributor

What does svg(File.read("bunny.svg")) return? A bit map image like png and jpg or a new Shoes widget class with svg specific methods and event handling to be written in C and Objective C?

Contributor

ccoupe commented Feb 5, 2015

What does svg(File.read("bunny.svg")) return? A bit map image like png and jpg or a new Shoes widget class with svg specific methods and event handling to be written in C and Objective C?

@ccoupe ccoupe added Wishlist and removed Enhancement labels Feb 5, 2015

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 5, 2015

Collaborator

This is something to think about. Ultimately it should become Shoes::SVG but we could implement the features incrementally for which the svg is rendered as a Shoes::Image, can be displayed, responds to normal image related methods. This should be easy to implement. The additional features can come as time goes.

For now I only need to be able to render svg on screen anyway. This would avoid me a whole lot of troubles converting files for different configurations using external tools. This enhancement will allow me to simplify and streamline the production of commercial software based on Shoes. My very next project will use it. So it's not wishlist as in wishful thinking...

Collaborator

BackOrder commented Feb 5, 2015

This is something to think about. Ultimately it should become Shoes::SVG but we could implement the features incrementally for which the svg is rendered as a Shoes::Image, can be displayed, responds to normal image related methods. This should be easy to implement. The additional features can come as time goes.

For now I only need to be able to render svg on screen anyway. This would avoid me a whole lot of troubles converting files for different configurations using external tools. This enhancement will allow me to simplify and streamline the production of commercial software based on Shoes. My very next project will use it. So it's not wishlist as in wishful thinking...

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 16, 2015

Collaborator

The following will be required to add SVG support to Shoes: librsvg, libxml2, libcroco. These can be found on http://www.gtk.org/download/win32.php for Windows related libraries. The binaries should do fine and the PC files can be obtained from the source files.

Collaborator

BackOrder commented Feb 16, 2015

The following will be required to add SVG support to Shoes: librsvg, libxml2, libcroco. These can be found on http://www.gtk.org/download/win32.php for Windows related libraries. The binaries should do fine and the PC files can be obtained from the source files.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 16, 2015

Collaborator

Shoes.svg method could have the following styles:

  • left, top for positioning
  • width, height to define rendered image size
  • ratio to set aspect ratio (true, false)
  • dpi to define the rendered image dpi

Equivalent methods may be considered for manipulating the svg at runtime.

REFERENCES
https://developer.gnome.org/rsvg/2.40/rsvg-Using-RSVG-with-cairo.html
http://cairographics.org/manual/cairo-SVG-Surfaces.html
https://developer.gnome.org/rsvg/2.40/RsvgHandle.html
librsvg source code contains examples in tests directory.

Collaborator

BackOrder commented Feb 16, 2015

Shoes.svg method could have the following styles:

  • left, top for positioning
  • width, height to define rendered image size
  • ratio to set aspect ratio (true, false)
  • dpi to define the rendered image dpi

Equivalent methods may be considered for manipulating the svg at runtime.

REFERENCES
https://developer.gnome.org/rsvg/2.40/rsvg-Using-RSVG-with-cairo.html
http://cairographics.org/manual/cairo-SVG-Surfaces.html
https://developer.gnome.org/rsvg/2.40/RsvgHandle.html
librsvg source code contains examples in tests directory.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Feb 16, 2015

Contributor

I've got a minor concern over libxml2. We already include an XML dll. Is there a choice of parsers when building libsvg from source?

Contributor

ccoupe commented Feb 16, 2015

I've got a minor concern over libxml2. We already include an XML dll. Is there a choice of parsers when building libsvg from source?

@ccoupe ccoupe added Enhancement and removed Wishlist labels Feb 16, 2015

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 17, 2015

Collaborator

Expat XML (libexpat) is an overly outdated, slow and complicate library. Might not be alive anymore as the last update is in 2012. Is libexpat used anywhere in Shoes? It is mostly included in GTK+ Bundle to ride along and compatibility. So librsvg does not support libexpat.

A good simple example how to use librsvg in Cairo: http://blog.mathieu-leplatre.info/static-build-of-cairo-and-librsvg.html

Collaborator

BackOrder commented Feb 17, 2015

Expat XML (libexpat) is an overly outdated, slow and complicate library. Might not be alive anymore as the last update is in 2012. Is libexpat used anywhere in Shoes? It is mostly included in GTK+ Bundle to ride along and compatibility. So librsvg does not support libexpat.

A good simple example how to use librsvg in Cairo: http://blog.mathieu-leplatre.info/static-build-of-cairo-and-librsvg.html

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Feb 17, 2015

Contributor

I believe libexpat is used by our old friend, fontconfig to parse the font.conf file.

Contributor

ccoupe commented Feb 17, 2015

I believe libexpat is used by our old friend, fontconfig to parse the font.conf file.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 17, 2015

Collaborator

The good news is that fontconfig can be configured to use libxml2 using ./configure --enable-libxml2.

Collaborator

BackOrder commented Feb 17, 2015

The good news is that fontconfig can be configured to use libxml2 using ./configure --enable-libxml2.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 17, 2015

Collaborator

An interesting experiment on Windows: removed libexpat-1.dll and ran cshoes.exe, checked manual and cobbler — working.

Collaborator

BackOrder commented Feb 17, 2015

An interesting experiment on Windows: removed libexpat-1.dll and ran cshoes.exe, checked manual and cobbler — working.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Feb 17, 2015

Collaborator

There is no libexpat-1 on MacOS X and probably not on Linux. Recommended to remove this unused library on Windows. It would be a good idea to list and compare libraries on all platforms.

Collaborator

BackOrder commented Feb 17, 2015

There is no libexpat-1 on MacOS X and probably not on Linux. Recommended to remove this unused library on Windows. It would be a good idea to list and compare libraries on all platforms.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Oct 26, 2015

Contributor

@BackOrder - since I'm redoing the dependencies for OSX , now would be the time to add librsvg to Shoes 3.3. Glancing at the API https://developer.gnome.org/rsvg/2.37/ it seems like a Shoes API is reasonable - make a class out of rsvghandle with some property getters and setter and init with a filename. Add a few methods for the GIO and Cairo calls and ??. Would that be sufficient for your needs?

Contributor

ccoupe commented Oct 26, 2015

@BackOrder - since I'm redoing the dependencies for OSX , now would be the time to add librsvg to Shoes 3.3. Glancing at the API https://developer.gnome.org/rsvg/2.37/ it seems like a Shoes API is reasonable - make a class out of rsvghandle with some property getters and setter and init with a filename. Add a few methods for the GIO and Cairo calls and ??. Would that be sufficient for your needs?

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Oct 26, 2015

Contributor

One other note. libexpat is included in OSX 10.6 and 10.9 in /usr/lib/ and it is used by Shoes - attempts to build libxml w/o homebrew have failed so far.

Contributor

ccoupe commented Oct 26, 2015

One other note. libexpat is included in OSX 10.6 and 10.9 in /usr/lib/ and it is used by Shoes - attempts to build libxml w/o homebrew have failed so far.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Oct 27, 2015

Collaborator

It sounds reasonable to me. Loading and displaying images, basic manipulations would be a great start.

Collaborator

BackOrder commented Oct 27, 2015

It sounds reasonable to me. Loading and displaying images, basic manipulations would be a great start.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Oct 27, 2015

Contributor

There is an existing rsvg gem (part of ruby-gnome project). I have no idea what it's api but it depends on Gtk so it should be understandable code.

Contributor

ccoupe commented Oct 27, 2015

There is an existing rsvg gem (part of ruby-gnome project). I have no idea what it's api but it depends on Gtk so it should be understandable code.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Oct 27, 2015

Collaborator

rvsg2 seems to have a decent implementation with frequent and recent contributions. I don't know how it would integrate with Shoes. My understanding is that it would be best to roll up our own to fully integrate to Shoes. What are your thoughts?

https://github.com/ruby-gnome2/ruby-gnome2/tree/master/rsvg2

Collaborator

BackOrder commented Oct 27, 2015

rvsg2 seems to have a decent implementation with frequent and recent contributions. I don't know how it would integrate with Shoes. My understanding is that it would be best to roll up our own to fully integrate to Shoes. What are your thoughts?

https://github.com/ruby-gnome2/ruby-gnome2/tree/master/rsvg2

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Oct 27, 2015

Contributor

There is a problem. From 10.9, attempt to configure:

configure: error: Package requirements (    gdk-pixbuf-2.0 >= 1.3.7     
glib-2.0 >= 2.12.0  gio-2.0 >= 2.24.0   libxml-2.0 >= 2.7.0     pangocai
ro >= 1.32.6    cairo >= 1.2.0  cairo-png >= 1.2.0
        libcroco-0.6 >= 0.6.1) were not met:

No package 'gdk-pixbuf-2.0' found
No package 'libxml-2.0' found
No package 'libcroco-0.6' found

gdk-pixbuf is a show stopper if it can't be configured away. libxml can be done if one is very careful in osx. That's for the older librsvg-2.39.0. The Changelog for the very recent 2.40 says it won't work with gtk2 and ours Shoes/Windows version of Gtk3 isn't high enough. I haven't looked at libcroco yet. Just a warning that this may be hard to do or even impossible.

Contributor

ccoupe commented Oct 27, 2015

There is a problem. From 10.9, attempt to configure:

configure: error: Package requirements (    gdk-pixbuf-2.0 >= 1.3.7     
glib-2.0 >= 2.12.0  gio-2.0 >= 2.24.0   libxml-2.0 >= 2.7.0     pangocai
ro >= 1.32.6    cairo >= 1.2.0  cairo-png >= 1.2.0
        libcroco-0.6 >= 0.6.1) were not met:

No package 'gdk-pixbuf-2.0' found
No package 'libxml-2.0' found
No package 'libcroco-0.6' found

gdk-pixbuf is a show stopper if it can't be configured away. libxml can be done if one is very careful in osx. That's for the older librsvg-2.39.0. The Changelog for the very recent 2.40 says it won't work with gtk2 and ours Shoes/Windows version of Gtk3 isn't high enough. I haven't looked at libcroco yet. Just a warning that this may be hard to do or even impossible.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Oct 27, 2015

Contributor

Of course, for all I know, cocoa has the svg handling inside it and we really just need to create a native widget (for gtk and cocoa) that can handle what ever the Shoes API is. Quick google says cocoa/Shoes would need an svg/xml to core graphics importer & exporter. If true that's a lot of code to write and test so I would need some major help (aka some one else writes the code).

Contributor

ccoupe commented Oct 27, 2015

Of course, for all I know, cocoa has the svg handling inside it and we really just need to create a native widget (for gtk and cocoa) that can handle what ever the Shoes API is. Quick google says cocoa/Shoes would need an svg/xml to core graphics importer & exporter. If true that's a lot of code to write and test so I would need some major help (aka some one else writes the code).

@The-Cecil

This comment has been minimized.

Show comment
Hide comment
@The-Cecil

The-Cecil Oct 28, 2015

There is a cocoa project https://github.com/SVGKit/SVGKit that is active although they say it might be broken for OSX. It's also huge. If I was doing this, I'd look into getting librsvg working w/o a gtk requirement. Shoes really can't handle a completely different imaging model (vector vs pixel) in a general purpose way. We can already create and svg from an image but loading an svg into image seems very unlikely. Loading into a new widget might be possible but its going to be a lot of work and I'm not inclined to do it.

There is a cocoa project https://github.com/SVGKit/SVGKit that is active although they say it might be broken for OSX. It's also huge. If I was doing this, I'd look into getting librsvg working w/o a gtk requirement. Shoes really can't handle a completely different imaging model (vector vs pixel) in a general purpose way. We can already create and svg from an image but loading an svg into image seems very unlikely. Loading into a new widget might be possible but its going to be a lot of work and I'm not inclined to do it.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Nov 8, 2015

Collaborator

Loading into a new widget might be possible but its going to be a lot of work and I'm not inclined to do it.

It would just need some kind of wrapper class in Shoes C-level code with basic functionalities. We can extend it as time goes, as need goes. As a side note, it would be great to have some kind of wiki article on how to extend Shoes with new features, what a new class requires to be fully accessible in Shoes, etc.

Collaborator

BackOrder commented Nov 8, 2015

Loading into a new widget might be possible but its going to be a lot of work and I'm not inclined to do it.

It would just need some kind of wrapper class in Shoes C-level code with basic functionalities. We can extend it as time goes, as need goes. As a side note, it would be great to have some kind of wiki article on how to extend Shoes with new features, what a new class requires to be fully accessible in Shoes, etc.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Nov 8, 2015

Contributor

Yes, a better description is needed in the wiki if only to help me remember how and where (app.h, app.h, ruby.h, ruby.c, plus a few others)

I've almost got librsvg built on 10.9 but I am running into a problem with gobject-introspection versions building (some) but not working with librsvg. It turns out you can build gdk-pixbuf with out Gtk.

Contributor

ccoupe commented Nov 8, 2015

Yes, a better description is needed in the wiki if only to help me remember how and where (app.h, app.h, ruby.h, ruby.c, plus a few others)

I've almost got librsvg built on 10.9 but I am running into a problem with gobject-introspection versions building (some) but not working with librsvg. It turns out you can build gdk-pixbuf with out Gtk.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Nov 9, 2015

Contributor

Update:
librsvg is built on 10.9 and gem install rsvg2 also installs (along with pkg-config.gem, cairo.gem, and glib2.gem). So the dependencies are good enough for now. I'll do the windows build next - I've peeked at the extconf.rb of rsvg and it's impressive (and possibility cross compile problem but the gem comes with prebuilt mingw binaries so maybe not.

Contributor

ccoupe commented Nov 9, 2015

Update:
librsvg is built on 10.9 and gem install rsvg2 also installs (along with pkg-config.gem, cairo.gem, and glib2.gem). So the dependencies are good enough for now. I'll do the windows build next - I've peeked at the extconf.rb of rsvg and it's impressive (and possibility cross compile problem but the gem comes with prebuilt mingw binaries so maybe not.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Nov 9, 2015

Contributor

Windows is being a problem. Gobject-introspection won't cross compile because it tries to run linux python and there is confusion about which include files to use. That's during the configuration phase - a nasty place in autoconf to be mucking about. Of course I don't have python-dev on my Win7 system.

The rsvg2 gem does install on Windows (prebuilt .so's) and it does use libsrvg inside so it can be built, somehow. The link above to prebuilt Windows dlls doesn't work as given but http://sourceforge.net/projects/ezwinports/files/ does have librsvg-2.40.1-2-w32-bin.zip which includes the dlls and headers but may create some version number mis-match for Shoes. A good place to start, though because the README.txt is very useful.

Contributor

ccoupe commented Nov 9, 2015

Windows is being a problem. Gobject-introspection won't cross compile because it tries to run linux python and there is confusion about which include files to use. That's during the configuration phase - a nasty place in autoconf to be mucking about. Of course I don't have python-dev on my Win7 system.

The rsvg2 gem does install on Windows (prebuilt .so's) and it does use libsrvg inside so it can be built, somehow. The link above to prebuilt Windows dlls doesn't work as given but http://sourceforge.net/projects/ezwinports/files/ does have librsvg-2.40.1-2-w32-bin.zip which includes the dlls and headers but may create some version number mis-match for Shoes. A good place to start, though because the README.txt is very useful.

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Nov 9, 2015

Contributor

Eventually I found --disable-introspection for configuring librsvg, We now have cross compiled rsvg (and dependencies) for mingw and osx. Time to create an API (and put it in Shoes)

Contributor

ccoupe commented Nov 9, 2015

Eventually I found --disable-introspection for configuring librsvg, We now have cross compiled rsvg (and dependencies) for mingw and osx. Time to create an API (and put it in Shoes)

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Nov 10, 2015

Collaborator

This is an amazing news!

Collaborator

BackOrder commented Nov 10, 2015

This is an amazing news!

@The-Cecil

This comment has been minimized.

Show comment
Hide comment
@The-Cecil

The-Cecil Nov 10, 2015

Thinking out loud, again ;^). Assume we have loaded an SVG in shoes and have a shoes/ruby object that mirrors the RsvgHandle. Now we want to display it which done with rsvg_handle_render_cairo() which writes to a cairo_t* which we could get where ever Shoes stashes returns from calls to shoes_cairo_create but that requires in input arg shoes_canvas* If I remember correctly there are a lot of those calls in Shoes. Rather than re-inventing canvas can we just add a new method to canvas something like 'render_svg(rsrvghandle)' That might the way to get started but may not be sufficient. I don't know.

Ideally the SVG would be more like a Shoes Art element (Shoes::Shapes) or maybe an Image?. I'm confused. I think I'll create that svghandle object just to have something that works the rakefiles and allows some testing. (and the wiki article)

Thinking out loud, again ;^). Assume we have loaded an SVG in shoes and have a shoes/ruby object that mirrors the RsvgHandle. Now we want to display it which done with rsvg_handle_render_cairo() which writes to a cairo_t* which we could get where ever Shoes stashes returns from calls to shoes_cairo_create but that requires in input arg shoes_canvas* If I remember correctly there are a lot of those calls in Shoes. Rather than re-inventing canvas can we just add a new method to canvas something like 'render_svg(rsrvghandle)' That might the way to get started but may not be sufficient. I don't know.

Ideally the SVG would be more like a Shoes Art element (Shoes::Shapes) or maybe an Image?. I'm confused. I think I'll create that svghandle object just to have something that works the rakefiles and allows some testing. (and the wiki article)

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Nov 10, 2015

Collaborator

Ideally the SVG would be more like a Shoes Art element (Shoes::Shapes) or maybe an Image?. I'm confused. I think I'll create that svghandle object just to have something that works the rakefiles and allows some testing. (and the wiki article)

Ultimately, it should support both but it may be challenging to implement Shapes. My suggestion is that we remain pragmatic and focus on Image for now. Rescaling may be necessary when the image is resized to avoid resampling.

Let's make it easy first and later add features. What do you say?

Collaborator

BackOrder commented Nov 10, 2015

Ideally the SVG would be more like a Shoes Art element (Shoes::Shapes) or maybe an Image?. I'm confused. I think I'll create that svghandle object just to have something that works the rakefiles and allows some testing. (and the wiki article)

Ultimately, it should support both but it may be challenging to implement Shapes. My suggestion is that we remain pragmatic and focus on Image for now. Rescaling may be necessary when the image is resized to avoid resampling.

Let's make it easy first and later add features. What do you say?

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Nov 10, 2015

Contributor

I am starting small. Hopefully, in a day or two I can get svrghandle.new(:file => path) and svghandle.new(string) and svrghandle.close() defined in C and the rakefiles setup for all platforms to build the no-ops. Documenting that effort https://github.com/Shoes3/shoes3/wiki/Creating-a-Class-for-Shoes-in-C as I go does slow me down - probably a good thing.

Contributor

ccoupe commented Nov 10, 2015

I am starting small. Hopefully, in a day or two I can get svrghandle.new(:file => path) and svghandle.new(string) and svrghandle.close() defined in C and the rakefiles setup for all platforms to build the no-ops. Documenting that effort https://github.com/Shoes3/shoes3/wiki/Creating-a-Class-for-Shoes-in-C as I go does slow me down - probably a good thing.

ccoupe added a commit that referenced this issue Nov 10, 2015

for issue #54 - create a svghandle method for canvas.
* 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.
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Nov 10, 2015

Contributor

The wiki article is mostly accurate and although the code is incomplete the framework is there.

Contributor

ccoupe commented Nov 10, 2015

The wiki article is mostly accurate and although the code is incomplete the framework is there.

ccoupe added a commit that referenced this issue Nov 12, 2015

issue #54 - can load svg into Shoes - no display yet.
* draw will be interesting.
* not comfortable with method names or usage. seems clumsy.

ccoupe added a commit that referenced this issue Nov 12, 2015

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Nov 12, 2015

Contributor

I've managed to get an svg loaded into Shoes but getting it to draw is down the cairo maze and I have no idea what I'm missing. @passenger94 would you like to take a look and tell me what I'm missing? The code only builds on a Loose Shoes Linux (x86_64) - apt-get install rsvg2-dev.

Contributor

ccoupe commented Nov 12, 2015

I've managed to get an svg loaded into Shoes but getting it to draw is down the cairo maze and I have no idea what I'm missing. @passenger94 would you like to take a look and tell me what I'm missing? The code only builds on a Loose Shoes Linux (x86_64) - apt-get install rsvg2-dev.

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 20, 2015

Contributor

styles are somewhat working, somewhat ... we can call them with expected behavior ... sometimes.
There is definitively something wrong in the drawing process, investigating ...
Just saying that hopefully we are not far from having something workable, i guess there is just some unplugged wire somewhere ...
@ccoupe it seems, to me, that everything is in place and make sense, just that wire somewhere

Contributor

passenger94 commented Dec 20, 2015

styles are somewhat working, somewhat ... we can call them with expected behavior ... sometimes.
There is definitively something wrong in the drawing process, investigating ...
Just saying that hopefully we are not far from having something workable, i guess there is just some unplugged wire somewhere ...
@ccoupe it seems, to me, that everything is in place and make sense, just that wire somewhere

ccoupe added a commit that referenced this issue Dec 22, 2015

update x86_64 tight shoes build for librsvg2 #54
* remove native/gtksvg.c
* hide canvas.h ref to old paint funtion.

ccoupe added a commit that referenced this issue Dec 22, 2015

for #164 - finish updating all tight shoes to ruby 2.1.8
* librsvg2 included in all tight shoes (distribution) #54
@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 22, 2015

Contributor

almost there, styles are working now, still some inaccuracies
(had to change the drawing process)

Contributor

passenger94 commented Dec 22, 2015

almost there, styles are working now, still some inaccuracies
(had to change the drawing process)

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 22, 2015

Contributor

Excellent! I've got a lot of documentation to write or revise and much cross platform testing so I'm anxious to see what you've done. I always learn something from you.

[changed for to from]

Contributor

ccoupe commented Dec 22, 2015

Excellent! I've got a lot of documentation to write or revise and much cross platform testing so I'm anxious to see what you've done. I always learn something from you.

[changed for to from]

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 22, 2015

Contributor

@ccoupe Thanks, i worked above the tremendous work you've done so far !!!

Got a working draft, at least the same as image widget ! new PR
of course, needs heavy testing.

The whole thing is very dependent on the quality of the svg file, at the moment it should better be perfect. I think it's inherent of the svg nature : we have an object which has arbitrary dimensions (only aspect ratio has a relative meaning) inside a document which also has dimensions, those 2 need not to coincide (like in groups), we are going to render it at some user defined size inside a canvas of possibly yet another size ... and finally the svg side might not be under user control ... oh and last by certainly not least there's dpi !!! (probably not useful inside Shoes though, only when saving to file ? maybe HiDef Screens ?)

Like mentioned before, a way to get the list of groups and layers would be nice ( might be useless if namings are cryptic, another place where the svg file should better be well formatted) - ok there is still inkscape and/or a text editor -

Contributor

passenger94 commented Dec 22, 2015

@ccoupe Thanks, i worked above the tremendous work you've done so far !!!

Got a working draft, at least the same as image widget ! new PR
of course, needs heavy testing.

The whole thing is very dependent on the quality of the svg file, at the moment it should better be perfect. I think it's inherent of the svg nature : we have an object which has arbitrary dimensions (only aspect ratio has a relative meaning) inside a document which also has dimensions, those 2 need not to coincide (like in groups), we are going to render it at some user defined size inside a canvas of possibly yet another size ... and finally the svg side might not be under user control ... oh and last by certainly not least there's dpi !!! (probably not useful inside Shoes though, only when saving to file ? maybe HiDef Screens ?)

Like mentioned before, a way to get the list of groups and layers would be nice ( might be useless if namings are cryptic, another place where the svg file should better be well formatted) - ok there is still inkscape and/or a text editor -

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 22, 2015

Contributor

maybe this goes also in the wiki :
Wiring PLACE_COMMON, CLASS_COMMON2, TRANS_COMMON, EVENT_COMMON macros in ruby.c to svg widget ...
Those connect style(), show(), click(), etc... methods to a widget. (skew, rotate, scale belongs to them...)
I have working style() method now !

  • an_svg_widget.style retrieves the styles applied to the widget
  • an_svg_widget.style(:displace_top => 25) change/set :displace style and update the canvas

(beware when retrieving style if the svg was opened with :content style !!! might be huge, therefore heavy for shoes to handle in a text block)

also added 2 methods to retrieve the offsets of the group/id : offset_x() and offset_y((), mainly for debug purpose, when the placements are not what one expect, it's possible to check if the problem comes from there. They go along with preferred_width(), preferred_height() methods, already implemented.

Contributor

passenger94 commented Dec 22, 2015

maybe this goes also in the wiki :
Wiring PLACE_COMMON, CLASS_COMMON2, TRANS_COMMON, EVENT_COMMON macros in ruby.c to svg widget ...
Those connect style(), show(), click(), etc... methods to a widget. (skew, rotate, scale belongs to them...)
I have working style() method now !

  • an_svg_widget.style retrieves the styles applied to the widget
  • an_svg_widget.style(:displace_top => 25) change/set :displace style and update the canvas

(beware when retrieving style if the svg was opened with :content style !!! might be huge, therefore heavy for shoes to handle in a text block)

also added 2 methods to retrieve the offsets of the group/id : offset_x() and offset_y((), mainly for debug purpose, when the placements are not what one expect, it's possible to check if the problem comes from there. They go along with preferred_width(), preferred_height() methods, already implemented.

ccoupe added a commit that referenced this issue Dec 23, 2015

for #54 - svghandle things. Add group? method
* allow a svghandle to be the first arg to svg (like string and path are)
* add svg.group?(string) method
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 23, 2015

Contributor

Like mentioned before, a way to get the list of groups and layers would be nice ( might be useless if namings are cryptic, another place where the svg file should better be well formatted)

I think this can be done with an xml2 parse of the xml for <g id that returns a Ruby hash? of all somewhere in libsrsvg this parsing is being done (a lot if you look). We could write a svg.groups method that returns them all, either by writin the matching ruby/xml2 C code or evaluating a Ruby string from C that "require 'noko'; nokogiri.query(string ,query)'. main.c/skel or is it app.c does this trick on Shoes startup. If you've never looked at the C code that sets DIR, you should.

Figuring out what that the shortest Ruby string is? Nokogiri just confuses me so any help is appreciated.

Contributor

ccoupe commented Dec 23, 2015

Like mentioned before, a way to get the list of groups and layers would be nice ( might be useless if namings are cryptic, another place where the svg file should better be well formatted)

I think this can be done with an xml2 parse of the xml for <g id that returns a Ruby hash? of all somewhere in libsrsvg this parsing is being done (a lot if you look). We could write a svg.groups method that returns them all, either by writin the matching ruby/xml2 C code or evaluating a Ruby string from C that "require 'noko'; nokogiri.query(string ,query)'. main.c/skel or is it app.c does this trick on Shoes startup. If you've never looked at the C code that sets DIR, you should.

Figuring out what that the shortest Ruby string is? Nokogiri just confuses me so any help is appreciated.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Dec 23, 2015

Collaborator

Like mentioned before, a way to get the list of groups and layers would be nice ( might be useless if namings are cryptic, another place where the svg file should better be well formatted)

Another brilliant suggestion!

Collaborator

BackOrder commented Dec 23, 2015

Like mentioned before, a way to get the list of groups and layers would be nice ( might be useless if namings are cryptic, another place where the svg file should better be well formatted)

Another brilliant suggestion!

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 23, 2015

Contributor

(beware when retrieving style if the svg was opened with :content style !!! might be huge,

Yes. There are many Shoes "style" things you do not want to do with an Svg. I'm OK with svg being the stray dog at the doorstep of Shoes consistency. I'm going to write some more scripts/samples to test and demonstrate all that code that is stubbed out. If someone figures out the ruby/nokogiri query for all groups/layers that returns a hash of ?that would be helpful.

Contributor

ccoupe commented Dec 23, 2015

(beware when retrieving style if the svg was opened with :content style !!! might be huge,

Yes. There are many Shoes "style" things you do not want to do with an Svg. I'm OK with svg being the stray dog at the doorstep of Shoes consistency. I'm going to write some more scripts/samples to test and demonstrate all that code that is stubbed out. If someone figures out the ruby/nokogiri query for all groups/layers that returns a hash of ?that would be helpful.

ccoupe added a commit that referenced this issue Dec 23, 2015

incomplete. #54 - using handles
* samples/good-flip.rb ("tap') displays one card at a time
* suffle button doesn't do anything yet
@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 23, 2015

Contributor

@ccoupe for the nokogiri search, this one works for me :

require 'nokogiri'

Shoes.app width: 500 do
    doc = File.open("#{DIR}/samples/paris.svg") { |f| Nokogiri::XML(f) }
   ids = doc.css("g").each_with_object("") { |tag, str| str << tag["id"].inspect << "\n" }

    para ids
end

search for nodes "g", then get the attribute "id", i think it's possible to go directly to the id attribute
EDIT ids = doc.css("g[id]").each_with_object("") { |elem, str| str << elem.attributes["id"].value << "\n" }

still, we must find a way to filter the result adequately

Contributor

passenger94 commented Dec 23, 2015

@ccoupe for the nokogiri search, this one works for me :

require 'nokogiri'

Shoes.app width: 500 do
    doc = File.open("#{DIR}/samples/paris.svg") { |f| Nokogiri::XML(f) }
   ids = doc.css("g").each_with_object("") { |tag, str| str << tag["id"].inspect << "\n" }

    para ids
end

search for nodes "g", then get the attribute "id", i think it's possible to go directly to the id attribute
EDIT ids = doc.css("g[id]").each_with_object("") { |elem, str| str << elem.attributes["id"].value << "\n" }

still, we must find a way to filter the result adequately

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 23, 2015

Contributor

@passenger94 - we need a way to skip the defs section.

Contributor

ccoupe commented Dec 23, 2015

@passenger94 - we need a way to skip the defs section.

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 24, 2015

Contributor

yes !

    ids = doc.css("g[id]")
    def_ids = doc.css("defs g[id]")
    groups = ids - def_ids
    groups.each_with_object("") { |elem, str| str << elem.attributes["id"].value << "\n" }

but that's not the end of the story ....
we also have layers above "target groups", and sub groups inside "target groups", add to this the cryptic names...
Maybe the best is to present the result of the query in a tree view, so one can at least see the hierarchy : top ones, if few, probably are layers, then comes hopefuly groups/id of interest and leaves are sub groups
it could also easily, as we all expect, be more complicated, (i don't know the svg specifications) :-D

Contributor

passenger94 commented Dec 24, 2015

yes !

    ids = doc.css("g[id]")
    def_ids = doc.css("defs g[id]")
    groups = ids - def_ids
    groups.each_with_object("") { |elem, str| str << elem.attributes["id"].value << "\n" }

but that's not the end of the story ....
we also have layers above "target groups", and sub groups inside "target groups", add to this the cryptic names...
Maybe the best is to present the result of the query in a tree view, so one can at least see the hierarchy : top ones, if few, probably are layers, then comes hopefuly groups/id of interest and leaves are sub groups
it could also easily, as we all expect, be more complicated, (i don't know the svg specifications) :-D

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 24, 2015

Contributor

I think we've discovered why librsvg2 doesn't have a similar C function. So, if you're going to work with groups you need to know the names before you start coding. bonded.svg is another card deck from Klondike and the code above doesn't work as well. I've modified samples/good-svgview.rb to do the nokogiri query so it isn't lost knowledge. I should probably file a bug about list box items size - too much vertical space.

Try drawing the jokers in paris.svg - something is not right.

Contributor

ccoupe commented Dec 24, 2015

I think we've discovered why librsvg2 doesn't have a similar C function. So, if you're going to work with groups you need to know the names before you start coding. bonded.svg is another card deck from Klondike and the code above doesn't work as well. I've modified samples/good-svgview.rb to do the nokogiri query so it isn't lost knowledge. I should probably file a bug about list box items size - too much vertical space.

Try drawing the jokers in paris.svg - something is not right.

ccoupe added a commit that referenced this issue Dec 24, 2015

per discussion in #54, animate a shuffle with svghandles
* segfaults in rb_threads if closed from window adornment
* use tap button to display next card
* off by one errors are likely because it's demo hack
* needs a real programmer

ccoupe added a commit that referenced this issue Dec 24, 2015

ccoupe added a commit that referenced this issue Dec 24, 2015

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 24, 2015

Contributor

Ian's deck that I claimed is malformed, svg-cards.svg almost works.

Contributor

ccoupe commented Dec 24, 2015

Ian's deck that I claimed is malformed, svg-cards.svg almost works.

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 24, 2015

Contributor

Try drawing the jokers in paris.svg - something is not right.

i'm aware of this, it's the reason why i created offset_x, offset_y methods. Unfortunately there is nothing we can do : the svg file has a problem and rsvglib fetch wrong dimensions : x,y, width and height have nonsense values for the jokers ... (i even upgraded librsvg to the latest 2.40.12)
I took me a while to figure out what's going on ; the group "jokerpip" described in the defs section has wrong placements (at least for librsvg) and are creating a mess once used in the joker groups ! (remove the "jokerpip" elements, in the joker groups, and all is good again)
i fixed the problem in inkscape and have now a working version

Contributor

passenger94 commented Dec 24, 2015

Try drawing the jokers in paris.svg - something is not right.

i'm aware of this, it's the reason why i created offset_x, offset_y methods. Unfortunately there is nothing we can do : the svg file has a problem and rsvglib fetch wrong dimensions : x,y, width and height have nonsense values for the jokers ... (i even upgraded librsvg to the latest 2.40.12)
I took me a while to figure out what's going on ; the group "jokerpip" described in the defs section has wrong placements (at least for librsvg) and are creating a mess once used in the joker groups ! (remove the "jokerpip" elements, in the joker groups, and all is good again)
i fixed the problem in inkscape and have now a working version

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 24, 2015

Contributor

list box items size - too much vertical space.

what is the problem ? did you mean the popup window is too big ?

Contributor

passenger94 commented Dec 24, 2015

list box items size - too much vertical space.

what is the problem ? did you mean the popup window is too big ?

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 24, 2015

Contributor

when clicking on the list box (gtk3) with a long list there is a lot of vertical white space between list items. At first, I thought it had extra `\n in the entries. It could be be my theme vs your theme.

Contributor

ccoupe commented Dec 24, 2015

when clicking on the list box (gtk3) with a long list there is a lot of vertical white space between list items. At first, I thought it had extra `\n in the entries. It could be be my theme vs your theme.

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 24, 2015

Contributor

you mean gtk3, right ? svg branch is using gtk3 ?
it's ok by my side ... probably a theme thing ...

Contributor

passenger94 commented Dec 24, 2015

you mean gtk3, right ? svg branch is using gtk3 ?
it's ok by my side ... probably a theme thing ...

ccoupe added a commit that referenced this issue Dec 25, 2015

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 25, 2015

Contributor

we have 2 group? method now, one for svg_handle one for svg, is it intended ?

what is the plan for save method ? is it useful as we don't modify the file/xml ? incidentally what about dpi, if we don't save to a file ?

Contributor

passenger94 commented Dec 25, 2015

we have 2 group? method now, one for svg_handle one for svg, is it intended ?

what is the plan for save method ? is it useful as we don't modify the file/xml ? incidentally what about dpi, if we don't save to a file ?

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 25, 2015

Contributor

We don't need group? method for svghandle. That's the problem for me with creating API - you don't really know what you'll need until you start write the test scripts or an app.

save() would be a lot like snapshot - render the svghandle to an svg/ps/pdf surface (ie file) and use the given dpi setting. I think that'ss what @BackOrder wanted. in the long discussion above.

Contributor

ccoupe commented Dec 25, 2015

We don't need group? method for svghandle. That's the problem for me with creating API - you don't really know what you'll need until you start write the test scripts or an app.

save() would be a lot like snapshot - render the svghandle to an svg/ps/pdf surface (ie file) and use the given dpi setting. I think that'ss what @BackOrder wanted. in the long discussion above.

@passenger94

This comment has been minimized.

Show comment
Hide comment
@passenger94

passenger94 Dec 25, 2015

Contributor

ok, so save() would be a way to convert an svg to a rasterized image ,say png, at some specified dpi ?
why not export() ?
For vector files ps or svg the only possible change is to embed a new dpi useful elsewhere in another program ?

Contributor

passenger94 commented Dec 25, 2015

ok, so save() would be a way to convert an svg to a rasterized image ,say png, at some specified dpi ?
why not export() ?
For vector files ps or svg the only possible change is to embed a new dpi useful elsewhere in another program ?

@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Dec 25, 2015

Contributor

export() is a better name. Like the code comment says, no one know what its supposed to do. I would not bother with it until every thing else is cleaned up and working.

Contributor

ccoupe commented Dec 25, 2015

export() is a better name. Like the code comment says, no one know what its supposed to do. I would not bother with it until every thing else is cleaned up and working.

@BackOrder

This comment has been minimized.

Show comment
Hide comment
@BackOrder

BackOrder Dec 26, 2015

Collaborator

I agree with @ccoupe : export() makes more sense. Save() might be used later on, i.e. imagine saving a group into its own svg.

Collaborator

BackOrder commented Dec 26, 2015

I agree with @ccoupe : export() makes more sense. Save() might be used later on, i.e. imagine saving a group into its own svg.

ccoupe added a commit that referenced this issue Dec 29, 2015

turns out there is a reason to have svghandle.group? in #54
* see samples/good-flip line 29. We don't have an Svg onscreen to
  query into.
* edge case to be sure - or maybe not.

ccoupe added a commit that referenced this issue Dec 30, 2015

for #54 good-flip creates svghandle as needed instead of preloading
* good startup speed on slow platforms
* good drawing speed
* needs a clever thread to started from init_with_path that loads missing
  handles while the user clicks. - That would make it expert-cardflip.rb

ccoupe added a commit that referenced this issue Jan 2, 2016

update linux rake files to better handle librsvg and be
a little smarter on the loose shoes build. Addresses #54 and #149

ccoupe added a commit that referenced this issue Jan 5, 2016

Prepare for beta release of 3.3.0
* updated manual. Errors exist in there.
* changed name of samples/good-flip to samples/good-cardflip
* commented out debugging printfs and puts
* still haven't fixed the osx array mystery.
* don't have svg.export written.
* good enough for a beta to get some feedback on svg #54 and #109
@ccoupe

This comment has been minimized.

Show comment
Hide comment
@ccoupe

ccoupe Jan 12, 2016

Contributor

Closing #54 for Shoes 3,3,0. If there are bug/enhancements please create a more specific report.

Contributor

ccoupe commented Jan 12, 2016

Closing #54 for Shoes 3,3,0. If there are bug/enhancements please create a more specific report.

@ccoupe ccoupe closed this Jan 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment