|
Krita Source Code Documentation
|
#include <KoToolManager.h>
Inheritance diagram for KoToolManager:Public Slots | |
| void | switchBackRequested () |
| void | switchInputDeviceRequested (const KoInputDevice &id) |
| void | switchToolRequested (const QString &id) |
| void | themeChanged () |
Signals | |
| void | aboutToChangeTool (KoCanvasController *canvas) |
| void | addedTool (KoToolAction *toolAction, KoCanvasController *canvas) |
| void | changedStatusText (const QString &statusText) |
| void | changedTool (KoCanvasController *canvas) |
| void | createOpacityResource (bool isOpacityPresetMode, KoToolBase *tool) |
| void | currentLayerChanged (const KoCanvasController *canvas, const KoShapeLayer *layer) |
| void | inputDeviceChanged (const KoInputDevice &device) |
| void | textModeChanged (bool text) |
| void | toolCodesSelected (const QList< QString > &types) |
| void | toolOptionWidgetsChanged (KoCanvasController *controller, const QList< QPointer< QWidget > > &widgets) |
Public Attributes | |
| CanvasData * | canvasData |
| QHash< KoCanvasController *, QList< CanvasData * > > | canvasses |
| KoInputDevice | inputDevice |
| bool | layerExplicitlyDisabled |
| QHash< KoCanvasBase *, KoToolProxy * > | proxies |
| KoToolManager * | q |
| QList< KoToolAction * > | toolActionList |
Private Member Functions | |
| KoToolManager (const KoToolManager &) | |
| KoToolManager | operator= (const KoToolManager &) |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes | |
| Private *const | d |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
This class manages the activation and deactivation of tools for each input device.
Managing the active tool and switching tool based on various variables.
There is only one tool box and a tool manager per one main vindow and view manager. This tool manager manages all the canvases of the main window via their corresponding KoCanvasController() objects.
For a new view that extends KoView all you need to do is implement KoView::createToolBox()
KoToolManager also keeps track of the current tool based on a complex set of conditions and heuristics:
Nota bene: if you use KoToolManager and register your canvases with it you no longer have to manually implement methods to route mouse, tablet, key or wheel events to the active tool. In fact, it's no longer interesting to you which tool is active; you can safely route the paint event through KoToolProxy::paint().
(The reason the input events are handled completely by the toolmanager and the paint events not is that, generally speaking, it's okay if the tools get the input events first, but you want to paint your shapes or other canvas stuff first and only then paint the tool stuff.)
Definition at line 126 of file KoToolManager.h.
| KoToolManager::KoToolManager | ( | ) |
Definition at line 185 of file KoToolManager.cpp.
|
override |
Definition at line 190 of file KoToolManager.cpp.
References d, and KIS_SAFE_ASSERT_RECOVER_NOOP.
|
private |
| KoToolManager::~Private | ( | ) |
|
signal |
Emitted when a new tool is going to override the current tool
| canvas | the currently active canvas. |
| KoCanvasController * KoToolManager::activeCanvasController | ( | ) | const |
Definition at line 277 of file KoToolManager.cpp.
References Private::canvas, and d.
| QString KoToolManager::activeToolId | ( | ) | const |
Returns the toolId of the currently active tool.
Definition at line 334 of file KoToolManager.cpp.
References d.
| void KoToolManager::addController | ( | KoCanvasController * | controller | ) |
Register a new canvas controller
| controller | the view controller that this toolmanager will manage the tools for |
Definition at line 221 of file KoToolManager.cpp.
References attachCanvas(), attemptCanvasControllerRemoval(), d, detachCanvas(), and KoCanvasController::proxyObject.
|
signal |
emitted whenever a new tool is dynamically added for the given canvas
| void KoToolManager::attachCanvas | ( | KoCanvasController * | controller | ) |
| void KoToolManager::attemptCanvasControllerRemoval | ( | QObject * | controller | ) |
Attempt to remove a controller. This is automatically called when a controller's proxy object is deleted, and it ensures that the controller is, in fact, removed, even if the creator forgot to do so.
| controller | the proxy object of the controller to be removed |
Definition at line 241 of file KoToolManager.cpp.
References KoCanvasControllerProxyObject::canvasController(), and removeCanvasController().
|
signal |
Emitted whenever the active tool changes the status text.
| statusText | the new status text |
|
signal |
Emitted when a new tool was selected or became active.
| canvas | the currently active canvas. |
| void KoToolManager::connectActiveTool | ( | ) |
| CanvasData * KoToolManager::createCanvasData | ( | KoCanvasController * | controller, |
| const KoInputDevice & | device ) |
|
signal |
Emitted to create and store the opacity resource in tool. The opacity is a derived or abstract resource depending on isOpacityPresetMode.
| KoToolBase * KoToolManager::createTool | ( | KoCanvasController * | controller, |
| KoToolAction * | toolAction ) |
| KoInputDevice KoToolManager::currentInputDevice | ( | ) | const |
Definition at line 211 of file KoToolManager.cpp.
References d.
|
signal |
Emitted after the current layer changed either its properties or to a new layer.
| canvas | the currently active canvas. |
| layer | the layer that is selected. |
| void KoToolManager::currentLayerChanged | ( | const KoShapeLayer * | layer | ) |
| void KoToolManager::detachCanvas | ( | KoCanvasController * | controller | ) |
| void KoToolManager::disconnectActiveTool | ( | ) |
| bool KoToolManager::eventFilter | ( | QObject * | object, |
| QEvent * | event ) |
| void KoToolManager::initializeCurrentToolForCanvas | ( | ) |
Definition at line 313 of file KoToolManager.cpp.
References d, and KIS_ASSERT_RECOVER_RETURN.
| void KoToolManager::initializeToolActions | ( | ) |
Initialize actions for switching to tools. The actions will have the text / shortcut as stated by the toolFactory. If the application calls this in their KoView extending class they will have all the benefits from allowing this in the menus and to allow the use to configure the shortcuts used.
Definition at line 216 of file KoToolManager.cpp.
References d.
|
signal |
Every time a new input device gets used by a tool, this event is emitted.
| device | the new input device that the user picked up. |
|
private |
| void KoToolManager::postSwitchTool | ( | ) |
For the list of shapes find out which tool is the highest priority tool that can handle it.
| shapes | a list of shapes, a selection for example, that is used to look for the tool. |
Definition at line 283 of file KoToolManager.cpp.
References KoToolFactoryBase::activationShapeId(), d, KoToolAction::id(), KoInteractionTool_ID, KoToolAction::priority(), KoShape::shapeId(), and KoToolAction::toolFactory.
| KoToolManager::Private * KoToolManager::priv | ( | ) |
| KoToolManager::Private | ( | KoToolManager * | ) |
| void KoToolManager::removeCanvasController | ( | KoCanvasController * | controller | ) |
Remove a set of controllers When the controller is no longer used it should be removed so all tools can be deleted and stop eating memory.
| controller | the controller that is removed |
Definition at line 233 of file KoToolManager.cpp.
References attachCanvas(), d, detachCanvas(), and KoCanvasController::proxyObject.
| void KoToolManager::requestToolActivation | ( | KoCanvasController * | controller | ) |
| void KoToolManager::setAbstractResource | ( | KoAbstractCanvasResourceInterfaceSP | abstractResource, |
| KoToolBase * | tool ) |
Definition at line 345 of file KoToolManager.cpp.
References KoToolBase::setAbstractResource().
| void KoToolManager::setConverter | ( | KoDerivedResourceConverterSP | converter, |
| KoToolBase * | tool ) |
Definition at line 340 of file KoToolManager.cpp.
References KoToolBase::setConverter().
| void KoToolManager::setCurrentCanvas | ( | KoCanvasController * | controller | ) |
Set the active canvas when the owning view manager changes its current view.
Definition at line 356 of file KoToolManager.cpp.
References Private::canvas, d, CanvasData::inputDevice, KIS_SAFE_ASSERT_RECOVER_RETURN, and toolOptionWidgetsChanged().
| void KoToolManager::setup | ( | ) |
|
slot |
Switches to the last tool used just before the current one, if any.
Definition at line 260 of file KoToolManager.cpp.
References d.
| void KoToolManager::switchBackRequested | ( | ) |
| void KoToolManager::switchCanvasData | ( | CanvasData * | cd | ) |
| void KoToolManager::switchInputDevice | ( | const KoInputDevice & | device | ) |
Request a switch from to the param input device. This will cause the tool for that device to be selected.
|
slot |
Request change input device
| id | the id of the input device |
Definition at line 254 of file KoToolManager.cpp.
References d.
| void KoToolManager::switchTool | ( | const QString & | id | ) |
|
slot |
Request switching tool
| id | the id of the tool |
Definition at line 249 of file KoToolManager.cpp.
References d.
| void KoToolManager::switchToolTemporaryRequested | ( | const QString & | id | ) |
|
signal |
Emitted when the tool's text mode has changed.
| inTextMode | whether it is now in text mode. |
|
slot |
Notify theme changes
Definition at line 323 of file KoToolManager.cpp.
References CanvasData::allTools, canvasData, d, and KoToolBase::updateOptionsWidgetIcons().
| QList< KoToolAction * > KoToolManager::toolActionList | ( | ) | const |
Returns the list of toolActions for the current tools.
| KoToolBase * KoToolManager::toolById | ( | KoCanvasBase * | canvas, |
| const QString & | id ) const |
Returns the tool for the given tool id. The tool may be 0
| canvas | the canvas that is a child of a previously registered controller who's tool you want. |
| id | the tool identifier |
Definition at line 267 of file KoToolManager.cpp.
References KoCanvasController::canvas(), Private::canvas, and d.
Emitted after the selection changed to state which unique shape-types are now in the selection.
| types | a list of string that are the shape types of the selected objects. |
|
signal |
Emit the new tool option widgets to be used with this canvas.
| void KoToolManager::updateCursor | ( | const QCursor & | cursor | ) |
| void KoToolManager::updateToolForProxy | ( | ) |
| CanvasData* KoToolManager::canvasData |
Definition at line 71 of file KoToolManager_p.h.
| QHash<KoCanvasController*, QList<CanvasData*> > KoToolManager::canvasses |
Definition at line 68 of file KoToolManager_p.h.
|
private |
Definition at line 306 of file KoToolManager.h.
| KoInputDevice KoToolManager::inputDevice |
Definition at line 73 of file KoToolManager_p.h.
| bool KoToolManager::layerExplicitlyDisabled |
Definition at line 75 of file KoToolManager_p.h.
| QHash<KoCanvasBase*, KoToolProxy*> KoToolManager::proxies |
Definition at line 69 of file KoToolManager_p.h.
| KoToolManager* KoToolManager::q |
Definition at line 64 of file KoToolManager_p.h.
| QList< KoToolAction * > KoToolManager::toolActionList |
Definition at line 66 of file KoToolManager_p.h.