IDE: Fix missing highlighted element in diagrams when using GTK3 wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Wed, 08 Mar 2023 23:18:41 +0100
branchwxPython4
changeset 3742 8c3d9159b6a9
parent 3741 838242d34741
child 3745 8a393ba12cd7
IDE: Fix missing highlighted element in diagrams when using GTK3

- wx's logical function does not work on gtk3, and highlighting relies on it
- skipping logical funciion at all "works" but this now makes highlight opaque
- no easy fix for highlight transparency since emulated with AND Wx logical function
+ added other highlight related cosmetic fix.
editors/Viewer.py
--- a/editors/Viewer.py	Fri Mar 03 19:20:49 2023 +0100
+++ b/editors/Viewer.py	Wed Mar 08 23:18:41 2023 +0100
@@ -91,6 +91,8 @@
 ZOOM_FACTORS = [math.sqrt(2) ** x for x in xrange(-6, MAX_ZOOMIN)]
 
 
+WX_NO_LOGICAL = "gtk3" in wx.PlatformInfo
+
 def GetVariableCreationFunction(variable_type):
     def variableCreationFunction(viewer, id, specific_values):
         return FBD_Variable(viewer,
@@ -833,6 +835,8 @@
         dc.SetFont(self.GetFont())
         self.Editor.DoPrepareDC(dc)
         dc.SetUserScale(self.ViewScale[0], self.ViewScale[1])
+        if WX_NO_LOGICAL:
+            dc.SetLogicalFunction = lambda *a,**k: None
 
     def GetLogicalDC(self):
         dc = wx.ClientDC(self.Editor)
@@ -2275,13 +2279,12 @@
             if not event.Dragging() and (gettime() - self.LastHighlightCheckTime) > REFRESH_PERIOD:
                 self.LastHighlightCheckTime = gettime()
                 highlighted = self.FindElement(event, connectors=False)
-                if self.HighlightedElement is not None and self.HighlightedElement != highlighted:
-                    self.HighlightedElement.SetHighlighted(False)
-                    self.HighlightedElement = None
-                if highlighted is not None:
-                    if not self.Debug and isinstance(highlighted, (Wire, Graphic_Group)):
-                        highlighted.HighlightPoint(pos)
-                    if self.HighlightedElement != highlighted:
+                if self.HighlightedElement != highlighted:
+                    if self.HighlightedElement is not None:
+                        self.HighlightedElement.SetHighlighted(False)
+                    if highlighted is not None:
+                        if not self.Debug and isinstance(highlighted, (Wire, Graphic_Group)):
+                            highlighted.HighlightPoint(pos)
                         highlighted.SetHighlighted(True)
                 self.HighlightedElement = highlighted
             if self.rubberBand.IsShown():