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
 Guides and Snap to Guides
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
725 Posts

Posted - Mar 07 2016 :  01:50:46  Show Profile  Reply
Hello,

In the software that we have developed we need to implement Dynamic Guides which will show when the user is either moving or resizing a photo/layer.

We do not only want to show the guide we also want to snap the photo/layer in question as per the operation being performed.

In short the functionality that we are seeking is similar to what is provided by DelphiC++Builder IDE when we are moving or resizing a control. But in case of DelphiC++Builder IDE the control in question does not snap to a guide but in our case we need to snap it to the nearest dynamic guide.

If anyone has any ideas please do share.

TIA


Yogi Yang

xequte

38196 Posts

Posted - Mar 07 2016 :  19:54:15  Show Profile  Reply
Hi Yogi

You can just use the LayerNotify event:

function SnapToGrid(value: Integer) : integer;
const
  GRID_SIZE = 8;
begin
  // Simplistic snap to grid algorithm
  Result := Value - ( value mod GRID_SIZE );
end;

procedure Tfmain.ImageEnView1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
begin
  with ImageEnView1.Layers[ Layer ] do
  begin
    if event = ielMoved then
    begin
      PosX   := SnapToGrid( PosX );
      PosY   := SnapToGrid( PosY );
    end
    else
    if event = ielResized then
    begin
      Width  := SnapToGrid( PosX + Width ) - PosX;
      Height := SnapToGrid( PosY + Height ) - PosY;
    end;
  end;
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

kturkay

44 Posts

Posted - May 24 2020 :  01:24:46  Show Profile  Reply
hi!,
I am looking for imageenvect objects (selected one) snapping ability. am I missed something in help file ?

not important no need any efforts, just I thought it would be good to know if something exists also for objects something like layers. (btw... code below, not works good. moving objects flickers).thats my first attemption. result=object flickers on move or resize. do you know a better solution or maybe a property I missed?


procedure Tfmmain.ImageenVect1ObjectMoveResize(Sender: TObject; hobj, Grip: Integer;
  var OffsetX, OffsetY: Integer);
var
  iv:TImageenVect;
  isResize: boolean;
  PosX, PosY, width_, height_: Integer;
begin
  iv:=ImageenVect1;
  isResize := (Grip <> 3);

  PosX := Iv.ObjLeft[hobj];
  PosY := Iv.ObjTop[hobj];
  width_ := Iv.ObjWidth[hobj];
  height_ := Iv.ObjHeight[hobj];

  if not isResize then
  begin
    Iv.ObjLeft[hobj] := SnapToGrid(PosX);
    Iv.ObjTop[hobj] := SnapToGrid(PosY);
  end
  else   //otherwise it should resize ? probably
  begin
    Iv.ObjWidth[hobj] := SnapToGrid(PosX + width_) - PosX;
    Iv.ObjHeight[hobj] := SnapToGrid(PosY + height_) - PosY;
  end;

end;


-we love Imageen-
Go to Top of Page

xequte

38196 Posts

Posted - May 25 2020 :  22:23:34  Show Profile  Reply
Hi

Unfortunately, I'm not sure that there's an easy way to do it with TImageEnVect...

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: