Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TfpgCanvas GetClipRect #113

Open
ozon85 opened this issue Oct 8, 2021 · 3 comments
Open

TfpgCanvas GetClipRect #113

ozon85 opened this issue Oct 8, 2021 · 3 comments

Comments

@ozon85
Copy link

ozon85 commented Oct 8, 2021

Hello.
In fpgui develop i try to draw on canvas. I wanted to take advantage of the optimization using cliprect.
The GetClipRect function returns an empty rectangle from the FClipRect field. It seems that this field is not updated when a message is received in the TfpgWidget.msgpaint method. It Planned in the future?

@graemeg
Copy link
Owner

graemeg commented Oct 8, 2021

Could you possibly attach a small test program (source code) explaining or showing the issue.

@ozon85
Copy link
Author

ozon85 commented Oct 10, 2021

I wrote the code for your fpGUI example-develop\examples\gui\img test_jpg
I added the code to the

TfrmMain procedure.FormPaint(Sender: TObject);
var clip:TfpgRect;
begin
clip:=  canvas.GetClipRect;
if (clip.Width>0) and(clip.Height>0)then
 clip:=  canvas.GetClipRect; 
 
  Canvas.DrawImage(0, 0, FImage);
end;

The clip rectangle always remains empty (Windows and Linux), no matter what I do with the form.

@ozon85
Copy link
Author

ozon85 commented Oct 10, 2021

Also inside
procedure TfpgWidget.msgpaint(var msg: TfpgMessageRec)
I found that for the widget defines its FInvalidRect, which corresponds to the rectangle that needs updating.
Based on this, I wrote a descendant of TfpgWidget with an overridden HandlePaint method:

procedure TfpgFreeimageControl.HandlePaint;
var clip:TfpgRect;
  Color: TfpgColor;
begin
inherited;
clip:=canvas.GetClipRect;
if clip.IsRectEmpty then
clip:=GetClientRect;
clip.IntersectRect(clip,FInvalidRect);
if clip.IsRectEmpty then exit;

Color:=random(high(longword));
canvas.Color:=Color;
canvas.FillRectangle(clip);
end;

How it view:
https://i.ibb.co/mDSN9TJ/Getclip-Rect1.jpg

And under linux canvas.GetClipRect Is Unassigned for Linux, at that time in Windows it has all visible part of my control on form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants