public virtual void OnClick() { if (_lastClickedItem != null && _lastClickedItem != this) { _lastClickedItem.OnOtherItemClicked(this); } _lastClickedItem = this; }
public override void OnOtherItemClicked(DTToolbarItem other) { base.OnOtherItemClicked(other); On = false; }
public virtual void OnOtherItemClicked(DTToolbarItem other) { }
static void Render(SceneView view) { Event ev = Event.current; MouseOverToolbarElement = false; // Only let certain hotkeys pass if (!EditorGUIUtility.editingTextField) { GUIUtility.keyboardControl = GUIUtility.GetControlID(FocusType.Passive); } List <DTProject> projects = DT.Projects; projects.Sort(); Handles.BeginGUI(); GUI.skin = null; // to ensure light-skin is used if set in preferences (or not Pro) // Get largest item for each side if (RecalcItemSize) { calcMaxItemDimension(); } // Get starting position for each side _InitialRects = getInitialItemRect(); _ItemRect = new Rect[4]; _InitialRects.CopyTo(_ItemRect, 0); DTToolbarItem lastItem = null; DTSelection.MuteEvents = true; DTToolbarItem hovering = null; foreach (DTProject project in projects) { #if UNITY_5_0 if (true) #else if (project.ShowToolbarInAllSceneViews || view.titleContent.text == "Scene") #endif { int side = (int)project.ToolbarOrientation; if (lastItem && lastItem.Project.ToolbarOrientation != project.ToolbarOrientation) { lastItem = null; } List <DTToolbarItem> items = project.ToolbarItems; // Render items for (int i = 0; i < items.Count; i++) { if (items[i].Visible) { Vector2 itemSize = items[i].GetItemSize(); // size of current item _ItemRect[side] = advanceItemRect(lastItem, items[i], itemSize); // advance by using the last itemRect and the new(current) size items[i].mItemRect = _ItemRect[side]; // Store current item rect if (items[i].Enabled) { Handles.EndGUI(); EditorKeyBinding.BindingsEnabled = false; if (items[i].mItemRect.Contains(DTGUI.MousePosition)) { hovering = items[i]; MouseOverToolbarElement = true; } items[i].OnSceneGUI(); EditorKeyBinding.BindingsEnabled = true; Handles.BeginGUI(); } GUI.enabled = items[i].Enabled; items[i].Render(_ItemRect[side]); GUI.enabled = true; if (ev != null && items[i].Enabled && (DTToolbarItem.FocusedItem == null || DTToolbarItem.FocusedItem == items[i])) { items[i].HandleEvents(ev); } lastItem = items[i]; } } } } DTSelection.MuteEvents = false; detailOpen = false; // Render items client area (Note: itemRect contains the last rendered item, a.k.a. a way to get the number of rows/cols needed foreach (DTProject project in projects) { #if UNITY_5_0 if (true) #else if (project.ShowToolbarInAllSceneViews || view.titleContent.text == "Scene") #endif { List <DTToolbarItem> items = project.ToolbarItems; for (int i = 0; i < items.Count; i++) { if (items[i].Visible && items[i].ShowClientArea) { detailOpen = true; Rect clientRect = items[i].mItemRect; int side = (int)project.ToolbarOrientation; switch (project.ToolbarOrientation) { case DTToolbarOrientation.Left: clientRect.x = _ItemRect[side].x + _MaxItemDimension[side].x + 5; break; case DTToolbarOrientation.Right: clientRect.x = _ItemRect[side].x - 5; break; case DTToolbarOrientation.Top: clientRect.y = _ItemRect[side].y + _MaxItemDimension[side].y + 5; break; case DTToolbarOrientation.Bottom: clientRect.y = _ItemRect[side].y - 5; break; } if (clientRect.width > 0 && clientRect.height > 0) { items[i].mBackgroundRects.Clear(); MouseOverToolbarElement = MouseOverToolbarElement || clientRect.Contains(DTGUI.MousePosition); EditorKeyBinding.BindingsEnabled = false; items[i].RenderClientArea(clientRect); EditorKeyBinding.BindingsEnabled = true; if (DTGUI.IsClick) { foreach (Rect r in items[i].mBackgroundRects) { if (r.Contains(ev.mousePosition)) { DTGUI.UseEvent(items[i].GetHashCode(), ev); } } } } } } } } // Handle statusbar info when hovering over an item if (hovering != null) { DTToolbarItem._StatusBar.Set(hovering.StatusBarInfo, "Info"); } else { DTToolbarItem._StatusBar.Clear("Info"); } // Render Statusbar DTToolbarItem._StatusBar.Render(getStatusBarRect(), null, true); Handles.EndGUI(); }
static Rect advanceItemRect(DTToolbarItem lastItem, DTToolbarItem newItem, Vector2 newItemSize) { Rect itemRect; float space = 0; int side = (int)newItem.Project.ToolbarOrientation; if (lastItem != null) { itemRect = lastItem.mItemRect; if (lastItem.Project != newItem.Project) { space = PROJECTSPACE; } else { space = (newItem.Order - lastItem.Order >= 10) ? ITEMSPACE : 0; } } else { itemRect = _InitialRects[side]; } switch (newItem.Project.ToolbarOrientation) { case DTToolbarOrientation.Left: itemRect.y += itemRect.height + 3 + space; if (itemRect.y + newItemSize.y > SceneView.currentDrawingSceneView.position.height - 30) { itemRect.y = 10; itemRect.x += _MaxItemDimension[(int)DTToolbarOrientation.Left].x + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Left].x; itemRect.height = newItemSize.y; break; case DTToolbarOrientation.Right: itemRect.y += itemRect.height + 3 + space; if (itemRect.y + newItemSize.y > SceneView.currentDrawingSceneView.position.height - 30) { itemRect.y = 10; itemRect.x -= _MaxItemDimension[(int)DTToolbarOrientation.Right].x + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Right].x; itemRect.height = newItemSize.y; break; case DTToolbarOrientation.Top: itemRect.x += 3 + itemRect.width + space; if (itemRect.x + newItemSize.x > SceneView.currentDrawingSceneView.position.width - _MaxItemDimension[(int)DTToolbarOrientation.Left].x - _MaxItemDimension[(int)DTToolbarOrientation.Right].x) { itemRect.x = _InitialRects[(int)DTToolbarOrientation.Top].x; itemRect.y += _MaxItemDimension[(int)DTToolbarOrientation.Top].y + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Top].x; itemRect.height = newItemSize.y; break; case DTToolbarOrientation.Bottom: itemRect.x += 3 + itemRect.width + space; if (itemRect.x + newItemSize.x > SceneView.currentDrawingSceneView.position.width - _MaxItemDimension[(int)DTToolbarOrientation.Left].x - _MaxItemDimension[(int)DTToolbarOrientation.Right].x) { itemRect.x = _InitialRects[(int)DTToolbarOrientation.Top].x; itemRect.y -= _MaxItemDimension[(int)DTToolbarOrientation.Bottom].y + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Bottom].x; itemRect.height = newItemSize.y; break; } return(itemRect); }
public virtual void OnClick() { if (_lastClickedItem!=null && _lastClickedItem!=this) _lastClickedItem.OnOtherItemClicked(this); _lastClickedItem = this; }
public override void OnOtherItemClicked(DTToolbarItem other) { if (other is DTToolbarToggleButton) base.OnOtherItemClicked(other); }
public override void OnOtherItemClicked(DTToolbarItem other) { } // IMPORTANT!
public override void OnOtherItemClicked(DTToolbarItem other) { base.OnOtherItemClicked(other); FreeNonPersistent(); }
static Rect advanceItemRect(DTToolbarItem lastItem, DTToolbarItem newItem, Vector2 newItemSize) { Rect itemRect; float space = 0; int side=(int)newItem.Project.ToolbarOrientation; if (lastItem != null) { itemRect = lastItem.mItemRect; if (lastItem.Project != newItem.Project) space = PROJECTSPACE; else space = (newItem.Order - lastItem.Order >= 10) ? ITEMSPACE : 0; } else itemRect=_InitialRects[side]; switch (newItem.Project.ToolbarOrientation) { case DTToolbarOrientation.Left: itemRect.y += itemRect.height + 3 + space; if (itemRect.y + newItemSize.y > SceneView.currentDrawingSceneView.position.height - 30) { itemRect.y = 10; itemRect.x += _MaxItemDimension[(int)DTToolbarOrientation.Left].x + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Left].x; itemRect.height = newItemSize.y; break; case DTToolbarOrientation.Right: itemRect.y += itemRect.height + 3 + space; if (itemRect.y + newItemSize.y > SceneView.currentDrawingSceneView.position.height - 30) { itemRect.y = 10; itemRect.x -= _MaxItemDimension[(int)DTToolbarOrientation.Right].x + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Right].x; itemRect.height = newItemSize.y; break; case DTToolbarOrientation.Top: itemRect.x += 3 + itemRect.width + space; if (itemRect.x + newItemSize.x > SceneView.currentDrawingSceneView.position.width - _MaxItemDimension[(int)DTToolbarOrientation.Left].x - _MaxItemDimension[(int)DTToolbarOrientation.Right].x) { itemRect.x = _InitialRects[(int)DTToolbarOrientation.Top].x; itemRect.y += _MaxItemDimension[(int)DTToolbarOrientation.Top].y + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Top].x; itemRect.height = newItemSize.y; break; case DTToolbarOrientation.Bottom: itemRect.x += 3 + itemRect.width+space; if (itemRect.x + newItemSize.x > SceneView.currentDrawingSceneView.position.width - _MaxItemDimension[(int)DTToolbarOrientation.Left].x - _MaxItemDimension[(int)DTToolbarOrientation.Right].x) { itemRect.x = _InitialRects[(int)DTToolbarOrientation.Top].x; itemRect.y -= _MaxItemDimension[(int)DTToolbarOrientation.Bottom].y + 5; } itemRect.width = _MaxItemDimension[(int)DTToolbarOrientation.Bottom].x; itemRect.height = newItemSize.y; break; } return itemRect; }