sketch-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Temporary tools


From: Valentin Ungureanu
Subject: Temporary tools
Date: Sat, 15 Oct 2005 12:25:10 +0300
User-agent: Mutt/1.4.2.1i

Hi,

A new patch:
http://savannah.nongnu.org/patch/?func=detailitem&item_id=4516

It adds similar functionality to the canvas modes from skencil
0.6, but implemented with "temporary" tools. That means, for
example, that it would be possible to zoom in to some selected
nodes without losing the selection (this is possible in 0.6 but
not in 0.7)

A tool change begins with the application context which issues a
TOOL message. To this message I added a flag which indicates to
interested subscribers (only the editor so far) that an old tool
might be restored.

A tool (which is derived from ToolInstance) is temporary if:

    1. has the temporary attribute set to True. This informs the
       editor to instantiate it without ending the previous tool.

    2. one of its ButtonClick or ButtonRelease methods calls
       application.SetTool with the previous toolname and the
       use_old set to True (the tool can peek at some editor
       attributes like the previous toolname or the handles
       drawn by the previous tool because the editor passes
       itself as an argument rather early in the changing tool
       process).


What gives the "temporary" behavior is the fact that the editor
instantiates the tool without ending the previous one. The
previous instance is added to a list from where it is retrieved
back when the temporary tool ends. Since it is the same
instance, its state is preserved (e.g. the selected nodes from
EditTool remain selected). Temporary tools can be chained
indefinitely.

Despite the patch size, the changes are in fact small.

EditorWithSelection has a new attribute with the list of previous
tools and has the SetTool method changed.
The rest is just adding the new argument to the various methods
that manage changing the tool (from toolbox, canvas, etc) and
some new tests.

Note that after applying this patch there is nothing to see
(except watching the tests pass)

There is a second patch which transforms the zoom tool into a
temporary one:
http://savannah.nongnu.org/patch/?func=detailitem&item_id=4517

Now create a curve, activate the edit tool, select some nodes,
click on the zoom tool and zoom to the selected nodes with
press-drag-release. You should be back in the edit tool, with
the nodes still selected.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]