public void AddTab (Tab tab) { tabs.Add (tab); tabSizes.Add (tab.Size); if (tabs.Count == 1) tab.Active = true; QueueResize (); }
Cairo.Rectangle GetBounds(Tab tab) { if (tab == null) { return(new Cairo.Rectangle(0, 0, 0, 0)); } int spacerWidth = 0; int idx = tabs.IndexOf(tab); double distance = 0; for (int i = 0; i < idx; i++) { if (tabs[i].TabPosition == tab.TabPosition) { distance += tabSizes[i].X - spacerWidth; } } return(new Cairo.Rectangle(tab.TabPosition == TabPosition.Left ? distance : Allocation.Width - distance - tabSizes[idx].X, 0, tabSizes[idx].X, tabSizes[idx].Y)); }
protected override bool OnMotionNotifyEvent(Gdk.EventMotion evnt) { mx = evnt.X; my = evnt.Y; var oldHoverTab = hoverTab; hoverTab = null; foreach (var tab in tabs) { if (tab.IsSeparator || !tab.Visible) { continue; } var bounds = GetBounds(tab); if (bounds.X < mx && mx < bounds.X + bounds.Width) { hoverTab = tab; break; } } if (hoverTab != oldHoverTab && oldHoverTab != null) { var oldBounds = GetBounds(oldHoverTab); QueueDrawArea((int)oldBounds.X, (int)oldBounds.Y, (int)oldBounds.Width, (int)oldBounds.Height); } if (hoverTab != null) { var bounds = GetBounds(hoverTab); QueueDrawArea((int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height); } return(base.OnMotionNotifyEvent(evnt)); }
public void InsertTab(int index, Tab tab) { if (index < 0 || index >= tabs.Count) { tabs.Add(tab); tabSizes.Add(tab.Size); } else { tabs.Insert(index, tab); tabSizes.Insert(index, tab.Size); } if (tabs.Count == 1) { tab.Active = tab.Visible; } else if (activeTab >= index) { activeTab++; } if (FocusedTab >= index) { FocusedTab++; } QueueResize(); tab.Allocation = GetBounds(tab); if (tab.Accessible != null) { Accessible.AddAccessibleElement(tab.Accessible); tab.AccessibilityPressed += OnTabPressed; UpdateAccessibilityTabs(); } }
public void InsertTab (int index, Tab tab) { if (index < 0 || index >= tabs.Count) { tabs.Add (tab); tabSizes.Add (tab.Size); } else { tabs.Insert (index, tab); tabSizes.Insert (index, tab.Size); } if (tabs.Count == 1) tab.Active = true; else if (activeTab >= index) activeTab++; QueueResize (); }
public void AddTab (Tab tab) { InsertTab (tabs.Count, tab); }
protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing evnt) { if (hoverTab != null) { var bounds = GetBounds (hoverTab); hoverTab = null; QueueDrawArea ((int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height); } return base.OnLeaveNotifyEvent (evnt); }
protected override bool OnMotionNotifyEvent (Gdk.EventMotion evnt) { mx = evnt.X; my = evnt.Y; var oldHoverTab = hoverTab; hoverTab = null; foreach (var tab in tabs) { if (tab.IsSeparator) continue; var bounds = GetBounds (tab); if (bounds.X < mx && mx < bounds.X + bounds.Width) { hoverTab = tab; break; } } if (hoverTab != oldHoverTab && oldHoverTab != null) { var oldBounds = GetBounds (oldHoverTab); QueueDrawArea ((int)oldBounds.X, (int)oldBounds.Y, (int)oldBounds.Width, (int)oldBounds.Height); } if (hoverTab != null) { var bounds = GetBounds (hoverTab); QueueDrawArea ((int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height); } return base.OnMotionNotifyEvent (evnt); }
Cairo.Rectangle GetBounds (Tab tab) { if (tab == null) return new Cairo.Rectangle (0, 0, 0, 0); int spacerWidth = 0; int idx = tabs.IndexOf (tab); double distance = 0; for (int i = 0; i < idx; i++) { if (tabs[i].TabPosition == tab.TabPosition) distance += tabSizes[i].X - spacerWidth; } return new Cairo.Rectangle (tab.TabPosition == TabPosition.Left ? distance : Allocation.Width - distance - tabSizes[idx].X, 0, tabSizes[idx].X, tabSizes[idx].Y); }
public void AddTab(Tab tab) { InsertTab(tabs.Count, tab); }
protected Tab AddButton (string label, IBaseViewContent viewContent) { CheckCreateSubViewToolbar (); updating = true; Tab tab = new Tab (subViewToolbar, label); tab.Tag = subViewToolbar.TabCount; tab.Activated += (sender, e) => { SetCurrentView ((int)((Tab)sender).Tag); QueueDraw (); }; subViewToolbar.AddTab (tab); Gtk.VBox widgetBox = new Gtk.VBox (); widgetBox.Realized += delegate { widgetBox.Add (viewContent.Control); }; subViewNotebook.AppendPage (widgetBox, new Gtk.Label ()); widgetBox.ShowAll (); EnsureToolbarBoxSeparator (); updating = false; return tab; }