ImageEn, unit imageenview



TIELayerOptions = set of (loAllowMultiSelect, loAutoSelectMask, loAutoUndoChangesByUser, loAutoUndoChangesByCode, loAutoPromptForImage, loFitToLayersWhenZooming, loAutoFixBorders, loAutoFixRotation, loDynamicCanvas, loKeyboardShortcuts, loDisableTextEditOnDblClick, loPreventOutOfBounds, loPropsOnDblClick, loResizeOnRotate, loDragSelection, loProtectBackground, loSwapBackgroundProps, loAutoTextEditing, loStampMode, loShowRichTextToolbar, loAllowReturnsInRichText, loShowRotationGrip);


Options to control layer behavior:
Value Description
loAllowMultiSelect If included, users can select multiple layers by holding down the Shift key. Moving, resizing, rotation, and other methods will apply to all selected layers
loAutoSelectMask If you have enabled a mask for a layer, then when selecting the layer the mask will also be selected (so that any resizing actions apply to the mask layer too)
loAutoUndoChangesByUser If you have enabled AutoUndo, then changes to layers made by users (using layer interactions or layer TActions) will be saved to the undo stack
loAutoUndoChangesByCode If you have enabled AutoUndo, then programmatic changes to layers will be saved to the undo stack. This applies to the methods: LayersAdd, LayersInsert, LayersCreateFromSelection, LayersCreatePolylineFromSelection, LayersCreateFromFile, LayersCreateFromEdge, LayersCreateFromAlpha, LayersRemove, LayersMerge, LayersMergeAll, LayersAlign, LayersArrange, LayersRotateAll, LayersGroup, LayersUngroup, LayersCropBackground
loAutoPromptForImage When setting MouseInteractLayers to mlCreateImageLayers, the user can drag select to create an TIEImageLayer If loAutoPromptForImage is enabled, then the user will be prompted to browse for an image file when after completing the selection. If the user cancels, the image layer is not added.
loAutoFixBorders If included, LayersFixBorders will be called prior to rotation to removes any transparency around the edges of the image.
loAutoFixRotation If included, LayersFixRotations will be called after rotation to lock in the rotation angle of image layers.
loDynamicCanvas If included, ImageEn will align the view to the bounds of all layers (i.e. by LayersRect). You will be able to scroll to access layers that have been pushed beyond the bounds of Layer 0. However this may cause the view to scroll when moving layers around (so is best paired with Center=False). When not enabled, the view is aligned with Layer 0, and any layers pushed outside of the bounds of layer 0 may be inaccessible if they are off-screen.
loKeyboardShortcuts Enables shortcuts to manipulate the selected layer(s). See the keyboard shortcut list in the TIELayer Documentation
loDisableTextEditOnDblClick By default, double-clicking a text layer allow it to be edited. Specify loDisableTextEditOnDblClick to prevent text editing by the user (see also ReadOnly and TextEditorPopupMenu)
loPreventOutOfBounds When enabled, layers cannot be moved outside of the background (layer 0) area
loPropsOnDblClick When double-clicking a layer (other than the background), it will display the Layer Properties Dialog. Note: For TIETextLayer and TIELineLayer, double-click will enable text editing instead. If you always want to display layer properties, also specify loDisableTextEditOnDblClick
loResizeOnRotate When the user rotates a shape or polyline with AspectRatioLocked=True, should the layer be automatically sized to maintain the original size of the shape?
loDragSelection Multiple layers can be selected by clicking the background and dragging (must specify mlMoveLayers, mlResizeLayers or mlRotate layers in MouseInteractLayers)
loProtectBackground If included, the background layer (Layer 0) cannot be deleted or moved position by the user (will also apply to any attached TImageEnLayerMView)
loSwapBackgroundProps If included, then when the user deletes or moves the background layer (Layer 0), the new background will inherit the Locked and Selectable properties of the old one (and vice versa)
loAutoTextEditing When setting MouseInteractLayers to mlCreateTextLayers, the user can drag select to create an TIETextLayer If loAutoTextEditing is enabled, then the layer will automatically start in text editing mode after completing the selection.
loStampMode When a mlCreate*Layers item is specified for MouseInteractLayers, layers are added by a single click instead of dragging.
loShowRichTextToolbar When editing a text layer with formatting enabled, a rich text toolbar is displayed. You can specify the buttons of the layer using RichEditorToolbar
loAllowReturnsInRichText When editing a text layer with formatting enabled, the return key can be used to insert hard returns into text. Otherwise, the return key applies the text changes.
loShowRotationGrip When layer rotation is enabled (MouseInteractLayers includes mlRotateLayers), a large grip is shown at the bottom of layers which can be clicked to rotate the layer. If this option is not include, user can drag rotate anywhere outside of the layer area.

loAllowMultiSelect in use:

loDragSelection in use:


// Enable automatic mask selection
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAutoSelectMask ];

// Enable automatic undo for all image changes including layer changes
ImageEnView1.Proc.AutoUndo := True;
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAutoUndoChangesByUser ];

// Disable multiple selection of layers
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions - [ loAllowMultiSelect ];

// Allow users to create image layers. Prompt for an image file after selection
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAutoPromptForImage ];
ImageEnView1.MouseInteractLayers := [ mlCreateImageLayers ];

// Display the entire image (including outlying layers) within the view
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loFitToLayersWhenZooming ];
ImageEnView1.Fit( False );

// Disable keyboard shortcuts
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions - [ loKeyboardShortcuts ];

// Allow layers to be double-clicked to edit their properties (even if they are text layers)
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loPropsOnDblClick, loDisableTextEditOnDblClick ];

// Layers cannot be dragged beyond the background layer
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loPreventOutOfBounds ];

// Prevent automatic sizing of layers when user rotates
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions - [ loResizeOnRotate ];

// Prevent the user from changing or deleting the background
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions - [ lpProtectBackground ];

// Do not transfer properties when moving the background layer
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions - [ loSwapBackgroundProps ];

// Allow users to create text layers. Start in text editing mode (user can immediately begin typing text)
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loAutoTextEditing ];
ImageEnView1.MouseInteractLayers := [ mlCreateTextLayers ];

// Add a star every time the layer clicks on the image (use OnNewLayer event to customize size)
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loStampMode ];
IEGlobalSettings().DefaultLayerShape := iesStar5;
ImageEnView1.MouseInteractLayers := mlCreateShapeLayers;

// Hide the rotation grip
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions - [ loShowRotationGrip ];

// Show toolbar when editing rich text of a TIETextLayer
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [ loShowRichTextToolbar ];