ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to make a Layer moveable/resizeable in code
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndyColmes

USA
351 Posts

Posted - Mar 08 2017 :  10:10:02  Show Profile  Reply
I have the following code during runtime, but the Layer does not seem to be moveable or resizeable. What settings did I miss to do this? The LAYER_2 is the last added layer in the TImageEnView:

File2VectWindow.LayersCurrent := LAYER_2;
File2VectWindow.LayersSync := False;
File2VectWindow.LayersDrawBox := True;

File2VectWindow.Layers[ LAYER_2 ].VisibleBox := True;
File2VectWindow.Layers[ LAYER_2 ].Selectable := True;
File2VectWindow.Layers[ LAYER_2 ].Locked := False;

File2VectWindow.MouseInteract := [ miRotateLayers, miMoveLayers,
miResizeLayers ];
File2VectWindow.Update;

Thanks in advance.

Andy

w2m

USA
1990 Posts

Posted - Mar 08 2017 :  10:40:42  Show Profile  Reply
Does your layer contain transparency, any pixels with alpha = 0?
If so, you need File2VectWindow.SelectionOptions := File2VectWindow.SelectionOptions + [iesoSelectTranspLayers];

Try creating a simple test project, and add a TImageEnVect and set the TImageEnVect.Align to alClient. Then in the OnFormShow event add this code:

procedure TForm1.FormShow(Sender: TObject);
var
  iLayer: integer;
begin
  ImageEnVect1.LayersSync := False;
  ImageEnVect1.LayersDrawBox := True;
  ImageEnVect1.MouseInteract := [miRotateLayers, miMoveLayers, miResizeLayers];
  iLayer := ImageEnVect1.LayersAdd;
  ImageEnVect1.Layers[iLayer].PosX := 0;
  ImageEnVect1.Layers[iLayer].PosY := 0;
  ImageEnVect1.Layers[iLayer].Width := 200;
  ImageEnVect1.Layers[iLayer].Height := 200;
  ImageEnVect1.Layers[iLayer].VisibleBox := True;
  ImageEnVect1.Layers[iLayer].Selectable := True;
  ImageEnVect1.Layers[iLayer].Locked := False;
  iLayer := ImageEnVect1.LayersAdd;
  ImageEnVect1.Layers[iLayer].PosX := 200;
  ImageEnVect1.Layers[iLayer].PosY := 200;
  ImageEnVect1.Layers[iLayer].Width := 300;
  ImageEnVect1.Layers[iLayer].Height := 300;
  ImageEnVect1.LayersCurrent := iLayer;
  ImageEnVect1.Layers[iLayer].VisibleBox := True;
  ImageEnVect1.Layers[iLayer].Selectable := True;
  ImageEnVect1.Layers[iLayer].Locked := False;
  ImageEnVect1.Update;
end;

Add a TPanel on the form and set align property to alTop and add a TSpeedButton on the panel. Set the buttons name property to Rotate1. Set the buttons AllowAllUp property to true, and set the buttons group index to 1. Then add the following code:
procedure TForm1.Rotate1Click(Sender: TObject);
begin
  if Rotate1.Down then
    ImageEnVect1.MouseInteract := [miRotateLayers]
  else
    ImageEnVect1.MouseInteract := [miMoveLayers, miResizeLayers];
end;

If you enable all layer selection modes ([miRotateLayers, miMoveLayers, miResizeLayers]) then only the central grip is visible and the layer can be rotated and moved but not resized because there are no side or corner grips.
When miRotateLayers is enabled, only a central grip is visible to show the component is in rotateLayers mode. No side grips or corner grips are visible when in miRotateLayersmode so the image can not be resized in this mode. When the miMoveLayers, miResizeLayers mode is enabled, all side and corner grips become visible, but the central grip is removed. When the side grips are visible in the miMoveLayers, miResizeLayers mode the layer can be selected, moved and resized, but not rotated.

Nigel may want to add the above paragraph to the help file to explain how the MouseInteract modes work and which grips are visible in each mode.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Mar 11 2017 :  23:07:57  Show Profile  Reply
Thanks very much Bill for the clarification. I will experiment per your suggestions and see if it works for me.

Andy
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: