This weekend, I finally found the time to play a little with Inkscape and try out your suggestions. I got the layer flipping working, not yet as an extension however.
Here's what I did:
1. Added 2 actions to the key mappings in keys/default.xml
<bind key="l" action="LayerFlipToNext" display="true" />
<bind key="L" action="LayerFlipToNext" display="true" />
<bind key="k" action="LayerFlipToPrev" display="true" />
<bind key="K" action="LayerFlipToPrev" display="true" />
2. Added 2 verbs for these actions to Verb::_base_verbs[] in verbs.cpp, defined in verbs.h.
new LayerVerb(SP_VERB_LAYER_FLIP_TO_NEXT, "LayerFlipToNext", N_("_Flip to Next Layer"),
N_("Flip to the next layer."), "flip_next"),
new LayerVerb(SP_VERB_LAYER_FLIP_TO_PREV, "LayerFlipToPrev", N_("_Flip to Previous Layer"),
N_("Flip to the previous layer."), "flip_prev"),
3. Wrote 2 case blocks for the verbs.
case SP_VERB_LAYER_FLIP_TO_NEXT: {
SPItem* currentLayer = SP_ITEM(dt->currentLayer());
if( currentLayer && dt->isLayer( currentLayer ) ) {
SPItem* nextLayer = SP_ITEM( SP_OBJECT_NEXT(currentLayer) );
if( nextLayer && dt->isLayer( nextLayer ) ) {
currentLayer->setExplicitlyHidden(true);
nextLayer->setExplicitlyHidden(false);
dt->setCurrentLayer( nextLayer );
}
}
break;
}
case SP_VERB_LAYER_FLIP_TO_PREV: {
SPItem* currentLayer = SP_ITEM(dt->currentLayer());
if( currentLayer && dt->isLayer( currentLayer ) ) {
SPItem* prevLayer = SP_ITEM( SP_OBJECT_PREV(currentLayer) );
if( prevLayer && dt->isLayer( prevLayer ) ) {
currentLayer->setExplicitlyHidden(true);
prevLayer->setExplicitlyHidden(false);
dt->setCurrentLayer( prevLayer );
}
}
break;
}
This works, and so far it's all I need, but I'd still like to know how I would implement this as an extension. I didn't, because I couldn't figure out:
1. How to register extensions with keys. The verbs all seem to be mapped to internal functions.
2. How to call the extension's effect method. It's nonstatic, so I'd think need an object pointer somehow. Where can I fetch it?
For some reason, I couldn't find the corresponding code blocks for Grid or BlurEdge...
Also, I am still looking for some keys on the keyboard that are still available. "k" and "l" are maybe already used somewhere else. When I tried "," and "." (comma and period), it seemed they were already used by some stroke scaling effect, even though it was not specified in keys/default.xml. Does anyone know where these effects are specified or where I can find a full list of all keys?
Thanks for your help! Gerrit
_________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/