ImageEn, unit imageenview

TImageEnView.OnDrawLayerGrip

TImageEnView.OnDrawLayerGrip


Declaration

property OnDrawLayerGrip: TIEDrawLayerGrip;


Description

Occurs when a layer grip is painted. If you handle this event the default behavior is disabled.
ABitmap is the destination bitmap and LayerIndex is the layer we are drawing.
Grip is in the range 0-9 as follows:
Value Description
0 Left-top
1 Right-top
2 Right-bottom
3 Left-bottom
4 Left side
5 Right side
6 Top side
7 Bottom side
8 Rotation center grip
9 Rotation grip (grip that appears below the layer for easy rotation)
Rect specifies the actual grip rectangle.

See the LayerEditing\Layers demo for more details.


ImageEnView Paint Events

The main paint events of TImageEnView are OnDrawBackBuffer which occurs when the back buffer is painted and OnDrawCanvas which occurs every time the canvas is painted. Generally OnDrawBackBuffer is used for better performance, because the back buffer painting only occurs after the content is updated. If you need constant custom drawing (e.g. to draw a marker at the current cursor position) then use OnDrawCanvas.

In layer applications, OnBeforeDrawLayer and OnDrawLayer will occur while painting each individual layer. Use these methods if you need easy custom drawing upon each individual layer (e.g. a layer title). Generally OnBeforeDrawLayer is best, unless you need to paint to the whole image (i.e. outside the area of the layer).

Other drawing events:
OnDrawBackground occurs when the background (area behind the image is painted) is painted to allow custom background styling
OnDrawLayerBox occurs when the box around a layer is painted to allow custom styling of the box
OnDrawLayerGrip occurs when the grips of the selected layer are drawn to allow custom grip styling
OnTransitionPaint occurs while transitioning from one image to the next
OnPaint notifies whenever there is a paint event. It is not used for custom drawing
OnDrawPolygon notifies whenever a point of a polygonal selection is drawn


Examples

// Draw custom style grips
procedure Tfmain.ImageEnView1DrawLayerGrip(Sender: TObject;
  ABitmap: TBitmap; layer, grip: Integer; rect: TRect);
begin
  with ABitmap.Canvas do
  begin
    Pen.Style := psSolid;
    Pen.Mode  := pmCopy;
    Pen.Color := clGreen;
    Brush.Style := bsSolid;
    Brush.Color := $0000FF00;
    with rect do
      Ellipse(Left-1, Top-1, Right+1, Bottom+1);
  end;
end;

// Only draw corner grips
procedure Tfmain.ImageEnView1DrawLayerGrip(Sender: TObject;
  ABitmap: TBitmap; layer, grip: Integer; rect: TRect);
begin
  if grip in [0,1,2,3] then
  begin
    iec := TIECanvas.Create( ABitmap.Canvas );
    IEDrawGrip( iec, rect,  ImageEnView1.GetLayersGripStyle() );
    iec.Free();
  end;
end;


See Also

GetLayersGripStyle
SetLayersBoxStyle
SetLayersGripStyle
LayersDrawBox
TIELayer.VisibleBox
OnDrawLayerBox