Difference between revisions of "Adding interface verbs"

From Inkscape Wiki
Jump to navigation Jump to search
(Corrected headings)
(Replaced content with "{{Deleted}}")
Tag: Replaced
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Commands in Inkscape are called 'Verbs'.  They permit invoking internal functionality through menus and keyboard shortcuts.  For example, they could allow you to assign a shortcut key to a set of actions you use a lot.
{{Deleted}}
 
Verbs are not terribly difficult to add.  You don't need to have much coding know-how in order to add a verb, and only a minimal knowledge of Inkscape internals.  The aim of this page is to provide novice coders with a "paint by numbers" process that can be followed to add a new verb to Inkscape.
 
== How to Add a Verb ==
 
First, add IDs for your new verbs to verbs.h:
 
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/head%3A/src/verbs.h verbs.h]
 
The place of the ID in the list determines to which group it belongs
(EditVerbs, FileVerbs, etc) - however, this is pretty arbitrary, so
don't sweat if you can't find a perfect group for your verb, just use
whichever makes most sense.
 
Then is the meat of the matter.  In verbs.cpp, fill in the verb structure with the name,
description, action ID, etc; also in the same file, write the actual
commands that the verb will do, in a switch case in one of ::perform
methods:
 
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/head%3A/src/verbs.cpp verbs.cpp]
 
As you see, these verbs do different things depending on which tool
you are in. Before verbification, this was coded into tool context
files, and now we can remove that:
 
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/head%3A/src/node-context.cpp node-context.cpp]
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/head%3A/src/select-context.cpp select-context.cpp]
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/head%3A/src/draw-context.cpp draw-context.cpp]
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/head%3A/src/draw-context.cpp draw-context.cpp]
 
(the last one required writing two functions that will be called by the
verb).
 
Now assign the keys to the newly created verbs:
 
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/11093/share/keys/inkscape.xml inkscape.xml]
 
and then copy inkscape.xml to default.xml.
 
Note: even if you are not assigning any key, you MUST list the new
verb in inkscape.xml, using a <bind> without a key. Not only this file
is a keymap, but it's also a reference for keymap writers, so it must
have all verbs, assigned or not.
 
If you added a shortcut which didn't exist before, update also doc/keys.xml.
 
If you want the new verb in the menu, edit menus-skeleton.h and
insert it there in an appropriate place.
 
Also review the other keymaps to see if you can assign the new verb to
some key that would make sense. So in adobe-illustrator.xml, I
assigned the new verbs to Alt+Ctrl+[], which seems to be the same
thing according to the comments:
 
[http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/11093/share/keys/adobe-illustrator-cs2.xml adobe-illustrator-cs2.xml]
 
Finally update the [[Release Notes|release notes]] with your new work!  :-)
 
== Node context is gone ==
As of revision 8976.
 
== Candidates for New Verbs ==
 
A couple words on what might be good candidates for verification:
 
* anything that all tools do but which is still not a verb, such as Esc for deselection
 
* anything that is needed for more complete keymaps emulating other editors, for example as listed [http://sourceforge.net/tracker/index.php?func=detail&aid=1532158&group_id=93438&atid=604309 in this bug report]. 
** the bug report requests includes various suggestions including: additional Zoom percentages; increase text, size and decrease text size; bold, italic, underline, text. 
**See also the alternate keyboard shortcut layouts found in inkscape/share/keys/ which contain comments about missing features or verbs. 
 
* any global action (i.e. which is not limited to some tool's context) for which it just makes sense to have a quick shortcut, even if it is already available via a dialog, a tool control, or some other more complicated way (example: centering selected objects; increasing/decreasing blur/opacity/stroke width in selection, etc.).
 
== Requests for New Verbs ==
 
If the above sounds like something you're interested in doing, here is a listing of actions that have been requested, that we'll need verbs for.
 
* Align-middle-and-center:  Need a shortcut key for aligning selected objects to their centers (horizontally and vertically).  [https://sourceforge.net/mailarchive/message.php?msg_id=37258028]
 
* Hide Selected/Unselected & Lock Selected/Unselected: Some shortcuts keys to hide any objects that are selected or objects that aren't and a similar system for locking.
 
If you'd like to see a verb added for a new action, but can't implement it yourself, you can add it to the above list.

Latest revision as of 14:51, 13 March 2023

This page has been deleted

This page is kept for historical reasons, e.g. to document specific decisions in Inkscape development.