Page 2 of 2

PostPosted: March 23rd, 2006, 10:07 pm
by Kambiz
Here are methods that can manage each case:
  1. ChangeZoomBy(ADelta, zoCursor);
  2. ScrollCenter(CursorPos); ChangeZoomBy(ADelta, zoCenter);
  3. ZoomGraph;
  4. ZoomRect(ARect);
  5. ChangeZoom(100, zoTopLeft);
elias's idea is somehow combination of zoCursor and zoCenter. The point under cursor should move toward center.

PostPosted: March 23rd, 2006, 10:11 pm
by Kambiz
By the way, I'll add a zoCursorCenter option for the second case.

PostPosted: March 23rd, 2006, 10:35 pm
by kokkoras
Kambiz wrote:elias's idea is somehow combination of zoCursor and zoCenter.

Yes indeed. That's why I said that we can do whatever zoom we like.
Kambiz wrote:The point under cursor should move toward center.
I think he wants it a bit fancy and animated like. As soon as initial and final states are known, he can throw in a few intermediate steps.


Thank you Kambiz :wink:

PostPosted: March 23rd, 2006, 10:50 pm
by Kambiz
Animated zoom is possible. For example, the new SGDemo has the following code for Mouse Wheel handlers.

Code: Select all
procedure TMainForm.SimpleGraphMouseWheelDown(Sender: TObject;
  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
var
  I: Integer;
begin
  MousePos := SimpleGraph.ScreenToClient(MousePos);
  if PtInRect(SimpleGraph.ClientRect, MousePos) then
  begin
    for I := 1 to 5 do
    begin
      SimpleGraph.ChangeZoomBy(-1, zoCursor);
      SimpleGraph.Update;
    end;
    Handled := True;
  end;
end;

procedure TMainForm.SimpleGraphMouseWheelUp(Sender: TObject;
  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
var
  I: Integer;
begin
  MousePos := SimpleGraph.ScreenToClient(MousePos);
  if PtInRect(SimpleGraph.ClientRect, MousePos) then
  begin
    for I := 1 to 5 do
    begin
      SimpleGraph.ChangeZoomBy(+1, zoCursor);
      SimpleGraph.Update;
    end;
    Handled := True;
  end;
end;

PostPosted: March 24th, 2006, 8:23 am
by elias
:) I think I see clear now the procedures I have to use. As soon as I can I'll send you a test for prooving. Found helpful your posts.