void CreatePlaceholderWindow() { var tab = notebook.CurrentTab; placeholderWindow = new PlaceholderWindow(tab); int x, y; Gdk.Display.Default.GetPointer(out x, out y); placeholderWindow.MovePosition(x, y); placeholderWindow.Show(); placeholderWindow.Destroyed += delegate { placeholderWindow = null; buttonPressedOnTab = false; }; }
protected override bool OnMotionNotifyEvent(EventMotion evnt) { if (draggingTab && mouseHasLeft) { var sr = GetScreenRect(); sr.Height = BarHeight; sr.Inflate(30, 30); int x, y; Gdk.Display.Default.GetPointer(out x, out y); if (x < sr.Left || x > sr.Right || y < sr.Top || y > sr.Bottom) { draggingTab = false; mouseHasLeft = false; CreatePlaceholderWindow(); } } string newTooltip = null; if (placeholderWindow != null) { int x, y; Gdk.Display.Default.GetPointer(out x, out y); placeholderWindow.MovePosition(x, y); return(base.OnMotionNotifyEvent(evnt)); } if (!draggingTab) { var t = FindTab((int)evnt.X, (int)evnt.Y); // If the user clicks and drags on the 'x' which closes the current // tab we can end up with a null tab here if (t == null) { TooltipText = null; return(base.OnMotionNotifyEvent(evnt)); } SetHighlightedTab(t); var newOver = IsOverCloseButton(t, (int)evnt.X, (int)evnt.Y); if (newOver != overCloseButton) { overCloseButton = newOver; QueueDraw(); } if (!overCloseButton && !draggingTab && buttonPressedOnTab) { draggingTab = true; mouseHasLeft = false; dragXProgress = 1.0f; int x = (int)evnt.X; dragOffset = x - t.Allocation.X; dragX = x - dragOffset; lastDragX = (int)evnt.X; } else if (t != null) { newTooltip = t.Tooltip; } } else if (evnt.State.HasFlag(ModifierType.Button1Mask)) { dragX = (int)evnt.X - dragOffset; QueueDraw(); var t = FindTab((int)evnt.X, (int)TabPadding.Top + 3); if (t == null) { var last = (DockNotebookTab)notebook.Tabs.Last(); if (dragX > last.Allocation.Right) { t = last; } if (dragX < 0) { t = (DockNotebookTab)notebook.Tabs.First(); } } if (t != null && t != notebook.CurrentTab && ( ((int)evnt.X > lastDragX && t.Index > notebook.CurrentTab.Index) || ((int)evnt.X < lastDragX && t.Index < notebook.CurrentTab.Index))) { t.SaveAllocation(); t.SaveStrength = 1; notebook.ReorderTab((DockNotebookTab)notebook.CurrentTab, t); t.Animate("TabMotion", f => t.SaveStrength = f, 1.0f, 0.0f, easing: Easing.CubicInOut); } lastDragX = (int)evnt.X; } if (newTooltip != null && TooltipText != null && TooltipText != newTooltip) { TooltipText = null; } else { TooltipText = newTooltip; } return(base.OnMotionNotifyEvent(evnt)); }
void CreatePlaceholderWindow () { var tab = notebook.CurrentTab; placeholderWindow = new PlaceholderWindow (tab); int x, y; Gdk.Display.Default.GetPointer (out x, out y); placeholderWindow.MovePosition (x, y); placeholderWindow.Show (); placeholderWindow.Destroyed += delegate { placeholderWindow = null; buttonPressedOnTab = false; }; }