MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / OnMotion

Method OnMotion

gui/chrome_tabs.py:842–901  ·  view source on GitHub ↗

Determines what happens when the mouse moves. This handles primarily dragging (region tab can be dragged) as well as checking if we are over an actionable button.

(self, event)

Source from the content-addressed store, hash-verified

840 wx.PostEvent(self.Parent, PageChanged(-1, sel))
841
842 def OnMotion(self, event):
843 """
844 Determines what happens when the mouse moves. This handles primarily
845 dragging (region tab can be dragged) as well as checking if we are over
846 an actionable button.
847 """
848 mposx, mposy = event.GetPosition()
849
850 if self.start_drag:
851 if not self.dragging:
852 if self.drag_trigger < 0:
853 self.dragging = True
854 self.drag_trigger = self.drag_trail
855 self.CaptureMouse()
856 else:
857 self.drag_trigger -= 1
858 if self.dragging:
859 # we wish to keep tab within tab container boundaries. To do
860 # this, we must detect when mouse moves outside of boundaries.
861 # Set hard limits to 0 and the size of tab container.
862 dtx = mposx - self.dragx
863 w, h = self.dragged_tab.GetSize()
864
865 dtx = max(dtx, 0)
866
867 if dtx + w > self.tab_container_width + self.inclination * 2:
868 dtx = self.tab_container_width - w + self.inclination * 2
869
870 self.dragged_tab.SetPosition((dtx, self.dragy))
871
872 # we must modify the surrounding tabs
873 index = self.GetTabIndex(self.dragged_tab)
874
875 left_tab = self.GetTabAtLeft(index)
876 right_tab = self.GetTabAtRight(index)
877
878 if left_tab:
879 lw, lh = left_tab.GetSize()
880 lx, ly = left_tab.GetPosition()
881
882 if lx + lw / 2 - self.inclination * 2 > dtx:
883 self.SwitchTabs(index - 1, index, self.dragged_tab)
884
885 if right_tab:
886 rw, rh = right_tab.GetSize()
887 rx, ry = right_tab.GetPosition()
888
889 if rx + rw / 2 + self.inclination * 2 < dtx + w:
890 self.SwitchTabs(index + 1, index, self.dragged_tab)
891
892 self.UpdateTabsPosition(self.dragged_tab)
893 self.Refresh()
894 return
895
896 # If we aren't dragging, check for actionable buttons under mouse
897 self.CheckCloseHighlighted(mposx, mposy)
898 self.CheckAddHighlighted(mposx, mposy)
899 self.CheckTabPreview(mposx, mposy)

Callers

nothing calls this directly

Calls 12

GetTabIndexMethod · 0.95
GetTabAtLeftMethod · 0.95
GetTabAtRightMethod · 0.95
SwitchTabsMethod · 0.95
UpdateTabsPositionMethod · 0.95
CheckCloseHighlightedMethod · 0.95
CheckAddHighlightedMethod · 0.95
CheckTabPreviewMethod · 0.95
GetPositionMethod · 0.45
GetSizeMethod · 0.45
SetPositionMethod · 0.45
RefreshMethod · 0.45

Tested by

no test coverage detected