From f96350f7c8d3bfe19475ce83a2d713298c2563cc Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Thu, 13 May 2021 17:16:28 +0100 Subject: [PATCH] avoid unneccesary refresh on primitive resize --- canvas/circle.go | 5 +++-- canvas/line.go | 4 ++++ canvas/rectangle.go | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/canvas/circle.go b/canvas/circle.go index 6a98f1962e..d691b979a8 100644 --- a/canvas/circle.go +++ b/canvas/circle.go @@ -28,11 +28,12 @@ func (l *Circle) Size() fyne.Size { // Resize sets a new bottom-right position for the circle object // If it has a stroke width this will cause it to Refresh. func (l *Circle) Resize(size fyne.Size) { - l.Position2 = fyne.NewPos(l.Position1.X+size.Width, l.Position1.Y+size.Height) - if l.StrokeWidth == 0 { + if size == l.Size() { return } + l.Position2 = fyne.NewPos(l.Position1.X+size.Width, l.Position1.Y+size.Height) + Refresh(l) } diff --git a/canvas/line.go b/canvas/line.go index ef4827bccd..66a59f7306 100644 --- a/canvas/line.go +++ b/canvas/line.go @@ -30,6 +30,10 @@ func (l *Line) Size() fyne.Size { // Resize sets a new bottom-right position for the line object and it will then be refreshed. func (l *Line) Resize(size fyne.Size) { + if size == l.Size() { + return + } + l.Position2 = fyne.NewPos(l.Position1.X+size.Width, l.Position1.Y+size.Height) Refresh(l) } diff --git a/canvas/rectangle.go b/canvas/rectangle.go index 6700a488a1..68a8244ff5 100644 --- a/canvas/rectangle.go +++ b/canvas/rectangle.go @@ -26,6 +26,10 @@ func (r *Rectangle) Refresh() { // Resize on a rectangle updates the new size of this object. // If it has a stroke width this will cause it to Refresh. func (r *Rectangle) Resize(s fyne.Size) { + if s == r.Size() { + return + } + r.baseObject.Resize(s) if r.StrokeWidth == 0 { return