Open Metallicow opened 4 years ago
@Metallicow thanks for your corrections. I will process them asap.
Issues 2, 3 and 4 could be resolved quite easily. The 1st, however, is a bit of a hassle. Have been struggling with that one all along. If you have any idea how to approach it, let me know.
Anyway, thanks for the compliments and "beating" you in writing a minimap ;-)
Well, I haven't hacked on the files as of yet, just kinda gave em a test run, But from a quick glance, you don't have any CaptureMouse()
or if HasCapture(): ReleaseMouse()
stuff in your OnLeftDown, OnLeftUp and OnMotion event defs, but that is where I would probably start. Basically on LeftDown capture the mouse and figure out what you need to do when it is captured as far as if the mouse is dragging over the widget or outside of it, but don't forget to release the mouse in the LeftUp def otherwise you get those hard to figure out assertions you sometimes see in the issues section, or worse... a hard crash.
If you look at some of the library widgets that have been fixed or I recall some of mine have this basic stuff after you rip the logic out. You just probably got to figure out on your own what to do when you are playing around with the mouse capture and what to sync, etc... you might need to make a few convenience methods or play around with the position of your event.Skip() call if you don't eat it in the handler to get the normal drag/scrolling action to take effect or do it programmatically.
... something along these lines would be a start.
def OnLeftUp(self, event):
if self.HasCapture():
self.ReleaseMouse()
self.Refresh()
def OnLeftDown(self, event):
if self.HasCapture():
self.ReleaseMouse()
self.CaptureMouse()
evtX, evtY = event.GetPosition()
self.left_down_pos = (evtX, evtY)
self.Refresh()
# ... Do something ...
self.parent.Refresh()
event.Skip()
def OnMotion(self, event):
evtX, evtY = event.GetPosition()
if self.HasCapture():
width, height = self.GetClientSize()
# ... Do something ...
self.parent.Refresh()
return
if event.LeftIsDown() and event.Dragging():
# ... Do something ...
self.parent.Refresh()
might look at the stc Update event also... it fires off a lot when doing stuff.
Capture / release mouse should do a good job.. thx. Stc update is surely something to investigate further, too.
As soon as I find the time, I'll be back with fixes.
Cheers Thom
For a first-pass at the code, I would like to say you have done a good job. :)
There are a few things that don't quite work as I would expect.
Dragging on the minimap and moving the mouse outside the minimap doesnt scroll properly like I've seen other implementations of a minimap do.(either dragging up or down the document)
This should be changed
self.SetDoubleBuffered(True)
toRobin states that some platforms are already DoubleBuffered by default, and doing it without a check would x4 or in otherwords make performance worse.
I see double loops often enough that a local opt list comprehension will definitely run faster since the method is pushing into C when dealing with all pixels.
would run faster as
As far as the
#INFO, Class with too many parameters: better design strategy?
, I personally will put all that stuff with the defaults in the class constructor, so it shows up when you request a calltip, but am not sure if that really should be written another way. I would assume most folks would only use 1 minimap, but I wouldnt rule out someone using it with dynamic sash or multisash type of setup.I think that's all I see at the moment. Thanks for spending the time to code this thing up! I always had it on my list of widgets to implement, but never seemed to get the time to code one up.