TfpgCanvas GetClipRect
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?
Could you possibly attach a small test program (source code) explaining or showing the issue.
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.
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.