Extension for editing custom object properties

Discussion about writing code for Inkscape.
peterink
Posts: 3
Joined: Fri Sep 02, 2011 12:00 am

Extension for editing custom object properties

Postby peterink » Fri Sep 02, 2011 12:12 am

Hi everyone,

I'd like to enhance the SVG produced by Inkscape with custom object properties. There are many examples of such use on the net. For instance a saw multiple uses of Inkscape for game level/board/map editors. So this is a very common need. However in every instance the recommended way of editing those properties is by using the built-in XML editor. Such an approach is error prone and it would be much better to have a nice GUI.

So I wanted to explore the possibility of writing an extension that provides a GUI for custom properties. As far as I saw writing an extension is easy enough and the GUI can be simply generated using <param> tags in the inx file. However I could not find a way to prefill those parameters with existing values from the SVG.

So is there a way to prefill extension parameters? If not then what other options do I have?


Thanks,

Peter

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Extension for editing custom object properties

Postby brynn » Fri Sep 02, 2011 9:30 am

Image
Welcome to InkscapeForum!

Besides saying welcome, I just wanted to make sure you already know about Object menu > Object properties. Since I'm not familiar with game-making I don't know what object properties you might be needing. But just in case you had overlooked it :D

Also, I'll move your topic to our new Development forum (which is for help writing extensions). :D

peterink
Posts: 3
Joined: Fri Sep 02, 2011 12:00 am

Re: Extension for editing custom object properties

Postby peterink » Fri Sep 02, 2011 12:23 pm

I know about default object properties. The idea is to attach custom properties (metadata) to objects that are application specific. In games those might be properties like speed, density or friction. The idea is for application to parse the SVG and interpret custom properties in application-specific way. This works very well. The only issue is how those properties are edited. Right now this can only be done using the XML editor. I am looking into the possibility of having a true GUI.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Extension for editing custom object properties

Postby ~suv » Fri Sep 02, 2011 10:07 pm

peterink wrote:However I could not find a way to prefill those parameters with existing values from the SVG.

So is there a way to prefill extension parameters?
Not possible with the internal options dialog for extensions (based on the current implementation of the extension system).
peterink wrote: If not then what other options do I have?
AFAIU related solutions (or workarounds): extensions like 'TeX Text' or 'Sozi' use an external dialog (built with PyGTK) to manage/edit custom properties/attributes.

User avatar
LiquidAsh
Posts: 71
Joined: Fri Apr 22, 2011 11:35 pm
Contact:

Re: Extension for editing custom object properties

Postby LiquidAsh » Mon Nov 07, 2011 1:26 am

I've been thinking about this same problem, and have one more suggestion to add to the more tried and tested methods that ~suv pointed out above. I've seen a few people use inkscape to build graphics for gui widgets... So a third option would be to have your gui widget graphics embeded within your svg: maybe grouped with your objects as hidden elements or overlapping them in a hidden layer (which is technically also a group I guess). Then your extension could simply hide and unhide gui elements and there would be no problem with parameter persistence. I think I'll actually play around with this over the next week as I'm also attempting to use Inkscape as a game level editor.


Return to “Programming”