Fixed an endless redraw loop on GTK
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Fri, 27 Mar 2020 16:54:29 +0000 (17:54 +0100)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Fri, 27 Mar 2020 16:54:29 +0000 (17:54 +0100)
plugins/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/EditorCanvas.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicUICanvas.java

index aedaa48..3030103 100644 (file)
@@ -2,7 +2,6 @@ package net.mograsim.logic.model.editor.ui;
 
 import java.util.Collection;
 
-import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.widgets.Composite;
 
 import net.haspamelodica.swt.helper.gcs.TranslatedGC;
@@ -10,7 +9,6 @@ import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 import net.mograsim.logic.model.LogicUICanvas;
 import net.mograsim.logic.model.editor.Editor;
 import net.mograsim.logic.model.editor.handles.Handle;
-import net.mograsim.preferences.Preferences;
 
 //TODO: Remove Inheritance 
 public class EditorCanvas extends LogicUICanvas
@@ -37,10 +35,6 @@ public class EditorCanvas extends LogicUICanvas
                addZoomedRenderer(gc ->
                {
                        Rectangle visibleRegion = new Rectangle(-offX / zoom, -offY / zoom, gW / zoom, gH / zoom);
-                       Color background = Preferences.current().getColor("net.mograsim.logic.model.color.background");
-                       if (background != null)
-                               setBackground(background);// this.setBackground, not gc.setBackground to have the background fill the
-                                                                                       // canvas
 
                        TranslatedGC tgc = new TranslatedGC(gc, 0.0d, 0.0d, 1 / editor.toBeEdited.getSubmodelScale(), false);
                        editor.toBeEdited.getOutlineRenderer().render(tgc, new Rectangle(-offX / zoom, -offY / zoom, gW / zoom, gH / zoom));
index 9675167..3a70dcd 100644 (file)
@@ -47,14 +47,12 @@ public class LogicUICanvas extends ZoomableCanvas
 
                this.model = model;
 
+               Color background = Preferences.current().getColor("net.mograsim.logic.model.color.background");
+               if (background != null)
+                       setBackground(background);
+
                LogicUIRenderer renderer = new LogicUIRenderer(model);
-               addZoomedRenderer(gc ->
-               {
-                       Color background = Preferences.current().getColor("net.mograsim.logic.model.color.background");
-                       if (background != null)
-                               setBackground(background);// this.setBackground, not gc.setBackground to have the background fill the canvas
-                       renderer.render(gc, new Rectangle(-offX / zoom, -offY / zoom, gW / zoom, gH / zoom));
-               });
+               addZoomedRenderer(gc -> renderer.render(gc, new Rectangle(-offX / zoom, -offY / zoom, gW / zoom, gH / zoom)));
                model.setRedrawHandler(() ->
                {
                        if (!isDisposed())