Class pwlib.tools.selection
The selection tool.
Defined in: selection.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
<private> <inner> |
The last selection rectangle that was drawn.
|
<private> <inner> |
The area type under the current mouse location.
|
<private> <inner> |
The resize type.
|
<private> <inner> |
Tells if the drawing canvas needs to be updated or not.
|
Holds selection information and image.
|
|
Selection state.
|
|
<constant> |
The user is dragging/moving the selection rectangle.
|
<constant> |
The user is drawing a selection.
|
<constant> |
No selection is available.
|
<constant> |
The selection has been dropped, and the mouse button is down.
|
<constant> |
The user is resizing the selection rectangle.
|
<constant> |
The selection rectangle is available.
|
<private> <inner> |
The interval ID used for invoking the drawing operation every few
milliseconds.
|
<private> <inner> |
Holds the starting point on the x axis of the image, for any
ongoing operation.
|
<private> <inner> |
Holds the starting point on the y axis of the image, for the any
ongoing operation.
|
Method Attributes | Method Name and Description |
---|---|
activate()
The tool activation code.
|
|
Paste an image from the "clipboard".
|
|
The tool deactivation code.
|
|
<private> <inner> |
The
canvasSizeChange application event handler. |
<private> <inner> |
ev_configChange(ev)
The
configChange application event handler. |
keydown(ev)
The
keydown event handler. |
|
<private> <inner> |
Hide the selection marquee element.
|
<private> <inner> |
marqueeMousedown(ev)
The
mousedown event handler for the selection marquee element. |
<private> <inner> |
marqueeMousemove(ev)
The
mousemove event handler for the selection marquee element. |
<private> <inner> |
marqueeMouseup(ev)
The
mouseup event handler for the selection marquee element. |
<private> <inner> |
Determine the are where the mouse is located: if it is inside or outside of
the selection rectangle, or on the selection border.
|
mousedown(ev)
The
mousedown event handler. |
|
mousemove(ev)
The
mousemove event handler. |
|
mouseup(ev)
The
mouseup event handler. |
|
The tool preactivation code.
|
|
Select all the entire image.
|
|
<private> <inner> |
Initialize the selection buffer, when the user starts dragging or resizing
the selected pixels.
|
Copy the selected pixels.
|
|
Crop the image to selection width and height.
|
|
Cut the selected pixels.
|
|
Perform selection delete.
|
|
<private> <inner> |
Perform the selection drag operation.
|
<private> <inner> |
Perform the selection rectangle drawing operation.
|
Drop the current selection.
|
|
Fill the available selection with the current
bufferContext.fillStyle.
|
|
Merge the selection buffer onto the current image layer.
|
|
<private> <inner> |
Perform the selection buffer merge onto the current image layer.
|
<private> <inner> |
Perform the selection resize operation.
|
<private> <inner> |
timerFn()
The timer function.
|
- Parameters:
- {PaintWeb} app
- Reference to the main paint application object.
When the selection is available the mouse location can be on top/inside the selection rectangle, on the border of the selection, or outside the selection.
Possible values: 'in', 'out', 'border'.
- Default Value:
- 'out'
While the user resizes the selection this variable can hold the following values: 'n' (North), 'ne' (North-East), 'e' (East), 'se' (South-East), 's' (South), 'sw' (South-West), 'w' (West), 'nw' (North-West).
- Default Value:
- null
- Default Value:
- false
- pwlib.tools.selection#STATE_PENDING - Selection dropped after
the
mousedown
event is fired. The script can switch to STATE_DRAWING if the mouse moves, or to STATE_NONE if it does not (allowing the user to drop the selection). - pwlib.tools.selection#STATE_NONE - No selection is available.
- pwlib.tools.selection#STATE_DRAWING - The user is drawing the selection rectangle.
- pwlib.tools.selection#STATE_SELECTED - The selection rectangle is available.
- pwlib.tools.selection#STATE_DRAGGING - The user is dragging/moving the current selection.
- pwlib.tools.selection#STATE_RESIZING - The user is resizing the current selection.
- Default Value:
- STATE_NONE
- See:
- PaintWeb.config.toolDrawDelay
The pwlib.appEvent.selectionChange application event is dispatched.
If the PaintWeb.config.selection.transform value is false, then it becomes true. The pwlib.appEvent.configChange application is then dispatched.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
canvasSizeChange
application event handler. This method
makes sure the selection size stays in sync.
- Parameters:
- {pwlib.appEvent.canvasSizeChange} ev
- The application event object.
configChange
application event handler. This method makes
sure that changes to the selection transparency configuration option are
applied.
- Parameters:
- {pwlib.appEvent.configChange} ev
- The application event object.
keydown
event handler. This method calls selection-related
commands associated to keyboard shortcuts.
- Parameters:
- {Event} ev
- The DOM Event object.
- Returns:
- {Boolean} True if the keyboard shortcut was recognized, or false if not.
- See:
- PaintWeb.config.selection.keys holds the keyboard shortcuts configuration.
mousedown
event handler for the selection marquee element.
- Parameters:
- {Event} ev
- The DOM Event object.
mousemove
event handler for the selection marquee element.
- Parameters:
- {Event} ev
- The DOM Event object.
mouseup
event handler for the selection marquee element.
- Parameters:
- {Event} ev
- The DOM Event object.
mousedown
event handler. Depending on the mouse location,
this method does initiate different selection operations: drawing,
dropping, dragging or resizing.
Hold the Control key down to temporarily toggle the transformation mode.
- Parameters:
- {Event} ev
- The DOM Event object.
mousemove
event handler.
- Parameters:
- {Event} ev
- The DOM Event object.
mouseup
event handler. This method ends any selection
operation.
This method dispatches the pwlib.appEvent.selectionChange application event when the selection state is changed or when the selection size/location is updated.
- Parameters:
- {Event} ev
- The DOM Event object.
- Returns:
- {Boolean} True if the activation did not fail, or false otherwise. If false is returned, the selection tool cannot be activated.
This method dispatches the pwlib.appEvent.selectionChange application event.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
This method dispatches the pwlib.appEvent.clipboardUpdate application event.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
This method invokes the this#selectionMerge and PaintWeb#imageCrop methods.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
This method dispatches two application events: pwlib.appEvent.clipboardUpdate and pwlib.appEvent.selectionChange.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
This method changes the PaintWeb.config.selection.transform value to false if the current selection has pixels that are currently being manipulated. In such cases, the pwlib.appEvent.configChange application event is also dispatched.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
- Returns:
- {false|Array} False is returned if the selection is too small, otherwise an array of two elements is returned. The array holds the selection coordinates, x and y.
This method dispatches the pwlib.appEvent.selectionChange application event.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
This method dispatches the pwlib.appEvent.selectionChange application event.
- Returns:
- {Boolean} True if the operation was successful, or false if not.
- Returns:
- {false|Array} False is returned if the selection is too small, otherwise an array of four elements is returned. The array holds the selection information: x, y, width and height.