/// <summary> /// Draws the GUIAreas with the set Color. Only use in OnGUI() /// </summary> public static void DrawGUIAreas() { foreach (Rect rect in insideGUIRects.Values) { CustomGUIUtils.DrawBox(rect, color); } }
public static void DrawMouseDebug() { Vector3 mouse = Input.mousePosition.SwapScreenToWorldPoint(); CustomGUIUtils.DrawBox( new Rect( mouse.x - CustomHandles.HandlePixelSize, mouse.y - CustomHandles.HandlePixelSize, CustomHandles.HandlePixelSize * 2, CustomHandles.HandlePixelSize * 2), new Color(0f, 1f, 0f, 0.3f)); }
public void OnGUI() { for (int i = 0; i < 4; i++) { dragNDrop.DropAreaBegin("A" + i); CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightRed); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("A" + i); dragNDrop.DropAreaBegin("B" + i); CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.GreenApple); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("B" + i); dragNDrop.DropAreaBegin("C" + i); CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("C" + i); } dragNDrop.DropAreaBegin("D"); CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("D"); dragNDrop.DropAreaBegin("inner1"); CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightRed); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("inner1"); dragNDrop.DropAreaBegin("inner2"); CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.GreenApple); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("inner2"); foreach (String stri in strings) { dragNDrop.DragObjectBegin(stri); CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, stri.ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); dragNDrop.DragObjectEnd(stri); } foreach (object obj in objects) { dragNDrop.DragObjectBegin(obj); if (dragNDrop.CurrentDragObject.IsDragging) { Rect drawRect = dragNDrop.CurrentDragObject.CurrentRect; drawRect.width = drawRect.height = 50; drawRect.x = InputHelpers.MouseOnGUI().x - drawRect.width / 2; drawRect.y = InputHelpers.MouseOnGUI().y - drawRect.height / 2; GUI.DrawTexture(drawRect, DefaultIconSet.Device); } else { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, obj.ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); } dragNDrop.DragObjectEnd(obj); } //foreach (DropArea dropArea in dragNDrop.dropAreas.Values) //{ // if (dropArea.Object != null) // { // if (dropArea.Object.GetType() == typeof(A)) // { // A readA = dropArea.GetObject<A>(); // Debug.Log("A gelesen: " + readA.ToString()); // } // } //} }
private static void DrawVerticalLine(Rect rect, float x, Color color) { //if (x > rect.xMin && x < rect.xMax) CustomGUIUtils.DrawBox(new Rect(x, rect.yMin, 1, rect.height), color); }
private static void DrawHorizontalLine(Rect rect, float y, Color color) { //if (y > rect.yMin && y < rect.yMax) CustomGUIUtils.DrawBox(new Rect(rect.xMin, y, rect.width, 1), color); }
private static void DrawDot(Vector2 center) { CustomGUIUtils.DrawBox(new Rect(center.x - 1, center.y - 1, 3, 3), Color.black); }
public void OnGUI() { GUI.Label(new Rect(boxWidth + 50, 0, 500, 500), "Dragging String = " + draggingString + "\n strings.Count " + strings.Count + "\n" + strings.ListToString <String>()); accumulatedHeight = gap; // Draw DropAreas for (int i = 0; i < strings.Count; i++) { if (dragNDrop.DropAreaBegin(i.ToString())) { CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Orangeish); //GUI.Label(dragNDrop.ThisDropArea.Rect, " " + i + ". " + dragNDrop.ThisDropArea.ToString()); GUI.Label(dragNDrop.ThisDropArea.Rect, " " + i); dragNDrop.ThisDropArea.Rect = new Rect(gap, accumulatedHeight, boxWidth, boxHeight); accumulatedHeight += gap + boxHeight; dragNDrop.SetObject(i.ToString(), strings[i]); dragNDrop.DropAreaEnd(i.ToString()); } } accumulatedHeight = gap; List <String> concurrentStrings = new List <string>(strings); int currentItem = 0; foreach (String str in concurrentStrings) { DragObject currentstr = dragNDrop.TryGetDragObject(str); int i = concurrentStrings.IndexOf(str); if (currentstr.IsDragging) { draggingStringOldIndex = i; draggingString = strings[i]; strings.RemoveAt(i); Debug.Log("Dragging String = " + draggingString + "\n" + strings.ListToString <String>()); } if (dragNDrop.DragObjectBegin(concurrentStrings[i])) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, concurrentStrings[i].ToString()); Rect icon = new Rect(dragNDrop.CurrentDragObject.CurrentRect); icon.width = icon.height; GUI.DrawTexture(icon, DefaultIconSet.Device); dragNDrop.DragObjectEnd(concurrentStrings[i]); } currentItem++; } if (draggingString != null) { for (int i = 0; i < strings.Count; i++) { DropArea dropArea; if (dragNDrop.dropAreas.TryGetValue(i.ToString(), out dropArea)) { dragNDrop.TryCreateDropArea("before" + i, null, new Rect(dropArea.Rect.x, dropArea.Rect.y, dropArea.Rect.width, dropArea.Rect.height / 2f), dropArea.Types.ToArray()); dragNDrop.TryCreateDropArea("after" + i, null, new Rect(dropArea.Rect.x, dropArea.Rect.y + dropArea.Rect.height / 2f, dropArea.Rect.width, dropArea.Rect.height / 2f), dropArea.Types.ToArray()); if (dragNDrop.DropAreaBegin("before" + i)) { if (dragNDrop.ThisDropArea.ContainsMouse()) { CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish); //GUI.Label(dragNDrop.ThisDropArea.Rect, " " + i + ". " + dragNDrop.ThisDropArea.ToString()); GUI.Label(dragNDrop.ThisDropArea.Rect, "before " + i); } dragNDrop.DropAreaEnd("before" + i); } if (dragNDrop.DropAreaBegin("after" + i)) { //CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish); ////GUI.Label(dragNDrop.ThisDropArea.Rect, " " + i + ". " + dragNDrop.ThisDropArea.ToString()); //GUI.Label(dragNDrop.ThisDropArea.Rect, "after " + i); if (dragNDrop.ThisDropArea.ContainsMouse()) { CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.Greenish); //GUI.Label(dragNDrop.ThisDropArea.Rect, " " + i + ". " + dragNDrop.ThisDropArea.ToString()); GUI.Label(dragNDrop.ThisDropArea.Rect, "after " + i); } dragNDrop.DropAreaEnd("after" + i); } } } bool newDropArea = false; if (dragNDrop.DragObjectBegin(draggingString)) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, draggingString.ToString()); Rect icon = new Rect(dragNDrop.CurrentDragObject.CurrentRect); icon.width = icon.height; GUI.DrawTexture(icon, DefaultIconSet.Device); newDropArea = dragNDrop.DragObjectEnd(draggingString); } //if (newDropArea) //{ //} DragObject currentstr = dragNDrop.TryGetDragObject(draggingString); if (!currentstr.IsDragging) { Debug.Log(currentstr.DropArea.Id); if (currentstr.DropArea.Id.StartsWith("before") || currentstr.DropArea.Id.StartsWith("after")) { if (currentstr.DropArea.Id.StartsWith("before")) { int newIndex = int.Parse(currentstr.DropArea.Id.Replace("before", "")); strings.Insert(newIndex, draggingString); } else if (currentstr.DropArea.Id.StartsWith("after")) { int newIndex = int.Parse(currentstr.DropArea.Id.Replace("after", "")) + 1; strings.Insert(newIndex, draggingString); currentstr.t = 0f; currentstr.Ease = true; currentstr.EaseEndRect = dragNDrop.dropAreas[newIndex.ToString()].Rect; } } else { //strings.Capacity += 1; Debug.Log("old Index" + draggingStringOldIndex); strings.Insert(draggingStringOldIndex, draggingString); } draggingString = null; draggingStringOldIndex = -1; } } }
private void WorkerStatusGUI() { EditorGUILayout.BeginVertical(); zoomFactor = EditorGUILayout.Slider("Zoom", zoomFactor, 0.000001f, 0.25f); autoScroll = EditorGUILayout.ToggleLeft("AutoScroll", autoScroll); #region StatusBar // Count number of Job-Todos int todoCount = 0; foreach (StatusUpdateMessage item in SimpleClient.jobStatus.Values) { foreach (TodoItem cildItem in item.childDict.Values) { foreach (TodoItem childTodo in cildItem.childDict.Values) { todoCount++; } todoCount++; } todoCount++; } // Calculate %-Step float step; if (SimpleClient.jobStatus.Values.Count > 0) { step = 1f / todoCount; } else { step = 0; } // Determine how many Job-Todos have been done float complete = 0; foreach (StatusUpdateMessage item in SimpleClient.jobStatus.Values) { foreach (TodoItem cildItem in item.childDict.Values) { foreach (TodoItem childTodo in cildItem.childDict.Values) { if (childTodo.status == Status.DONE) { complete += step; } } if (cildItem.status == Status.DONE) { complete += step; } } if (item.status == Status.DONE) { complete += step; } } EditorGUILayout.LabelField("", GUILayout.Height(20)); EditorGUI.ProgressBar(new Rect(0, 90, this.position.width - 200, 20), complete, (int)(complete * 100) + " % "); #endregion // Statusbar #region Timer string timer; if (stopTime == null) { timer = startTime != null?startTime.Duration() : "00:00:00.000"; } else { timer = TimeStamp.Duration(TimeStamp.Duration(startTime, stopTime)); } if (timerFontStyle == null) { timerFontStyle.font = (Font)Resources.Load("digitalmono"); timerFontStyle.fontSize = 34; } EditorGUI.LabelField(new Rect(this.position.width - 190, 85, 180, 20), timer, timerFontStyle); #endregion // Timer EditorGUILayout.EndVertical(); GUILayout.Space(10f); //Rect lastRect = GUILayoutUtility.GetLastRect(); //Debug.Log(lastRect); float panelOffset = 120; float autoScrollPosition = this.position.width - GoldenRatio.LongSideOf(this.position.width); float panelWidth = this.position.width - border; if (startTime != null) { panelWidth = Mathf.Max((float)TimeStamp.DurationInMillis(startTime, TimeStamp.Now()) * zoomFactor + autoScrollPosition, this.position.width - border); } if (stopTime != null) { panelWidth = Mathf.Min((float)TimeStamp.DurationInMillis(startTime, stopTime) * zoomFactor + autoScrollPosition, panelWidth); } int jobCount = SimpleClient.jobStatus.Values.Count; float panelHeight = jobCount * (4 * height + 4 * separator + 2 * padding) + yOffset; using (EditorGUILayout.ScrollViewScope scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, false, false, GUILayout.Width(this.position.width), GUILayout.Height(this.position.height - panelOffset))) { scrollPos = scrollView.scrollPosition; EditorGUILayout.LabelField("", darkgrey, GUILayout.Width(panelWidth), GUILayout.Height(panelHeight)); if (autoScroll) { scrollPos.x = Mathf.Infinity; } float now = xOffset; if (startTime != null) { now = (float)TimeStamp.DurationInMillis(startTime, TimeStamp.Now()) * zoomFactor + xOffset; } if (generateLocal) { float y = 0f; y += yOffset; foreach (StatusUpdateMessage item in SimpleClient.jobStatus.Values) { y += separator; TodoItem worker = item.Get(Job.Worker); DrawJobItemBar(item, y); y += padding; y += height + separator; DrawTodoItemBar(worker, y); foreach (string todo in worker.childTodos) { DrawTodoItemBar(worker.childDict[todo], y); } y += height; y += padding; y += separator; } } else { float y = 0f; y += yOffset; foreach (StatusUpdateMessage item in SimpleClient.jobStatus.Values) { y += separator; TodoItem master = item.Get(Job.Master); TodoItem transfer = item.Get(Job.Transfer); TodoItem worker = item.Get(Job.Worker); DrawJobItemBar(item, y); y += padding; DrawTodoItemBar(master, y); foreach (string todo in master.childTodos) { DrawTodoItemBar(master.childDict[todo], y); } y += height + separator; foreach (string todo in transfer.childTodos) { DrawTodoItemBar(transfer.childDict[todo], y); } y += height + separator; DrawTodoItemBar(worker, y); foreach (string todo in worker.childTodos) { DrawTodoItemBar(worker.childDict[todo], y); } y += height; y += padding; y += separator; } } if (stopTime == null) { CustomGUIUtils.DrawBox(new Rect(now, 0, 1, panelHeight), Color.black); } #region Draw Time indicators if (1000 * zoomFactor > 20) { for (float x = 0; x < panelWidth; x += (1000 * zoomFactor)) { CustomGUIUtils.DrawBox(new Rect(x, 0, 1, panelHeight), Color.grey); } } if (15000 * zoomFactor > 20) { for (float x = 0; x < panelWidth; x += (15000 * zoomFactor)) { CustomGUIUtils.DrawBox(new Rect(x, 0, 1, panelHeight), XKCDColors.LightRed); } } for (float x = 0; x < panelWidth; x += (60000 * zoomFactor)) { CustomGUIUtils.DrawBox(new Rect(x, 0, 1, panelHeight), Color.red); } #endregion // Draw time indicators } Repaint(); }
public void OnGUI() { if (dragNDrop.DropAreaBegin("outer")) { CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("outer"); } if (dragNDrop.DropAreaBegin("outer2")) { CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("outer2"); } if (dragNDrop.DragObjectBegin(strings[0])) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[0].ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); // DropAreas if (dragNDrop.DropAreaBegin("inner1")) { Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect); drawRect.x += 10; drawRect.y += 10; drawRect.width = 130; drawRect.height = 150; dragNDrop.ThisDropArea.Rect = drawRect; CustomGUIUtils.DrawBox(drawRect, XKCDColors.LightRed); GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("inner1"); } if (dragNDrop.DropAreaBegin("inner2")) { Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect); drawRect.x += 10; drawRect.y += 210; drawRect.width = 130; drawRect.height = 150; dragNDrop.ThisDropArea.Rect = drawRect; CustomGUIUtils.DrawBox(drawRect, XKCDColors.GreenApple); GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("inner2"); } // DragObjects if (dragNDrop.DragObjectBegin(strings[1])) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[1].ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); dragNDrop.DragObjectEnd(strings[1]); } if (dragNDrop.DragObjectBegin(strings[2])) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[2].ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); dragNDrop.DragObjectEnd(strings[2]); } dragNDrop.DragObjectEnd(strings[0]); } //foreach (DropArea dropArea in dragNDrop.dropAreas.Values) //{ // if (dropArea.Object != null) // { // if (dropArea.Object.GetType() == typeof(A)) // { // A readA = dropArea.GetObject<A>(); // Debug.Log("A gelesen: " + readA.ToString()); // } // } //} }
public void OnGUI() { if (dragNDrop.DropAreaBegin("outer")) { CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, XKCDColors.LightGreyBlue); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("outer"); } if (dragNDrop.DropAreaBegin("outer2")) { CustomGUIUtils.DrawBox(dragNDrop.ThisDropArea.Rect, color); GUI.Label(dragNDrop.ThisDropArea.Rect, dragNDrop.ThisDropArea.ToString()); if (dragNDrop.ThisDropArea.ContainsMouse() && InputHelpers.ClickedLeft()) { color = XKCDColors.Blue; } if (color == XKCDColors.Blue) { dragNDrop.ThisDropArea.Rect = EasingCurves.EaseRect( "outer2", dragNDrop.ThisDropArea.Rect, new Rect(dragNDrop.ThisDropArea.Rect).AddOffset(new Rect(-100, -100, -200, -200)), EasingCurves.EaseType.easeOutElastic); } dragNDrop.DropAreaEnd("outer2"); } if (dragNDrop.DragObjectBegin(strings[0])) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[0].ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); // DropAreas if (dragNDrop.DropAreaBegin("inner1")) { Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect); drawRect.x += 10; drawRect.y += 10; drawRect.width = 130; drawRect.height = 150; dragNDrop.ThisDropArea.Rect = drawRect; CustomGUIUtils.DrawBox(drawRect, XKCDColors.LightRed); GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("inner1"); } if (dragNDrop.DropAreaBegin("inner2")) { Rect drawRect = new Rect(dragNDrop.CurrentDragObject.CurrentRect); drawRect.x += 10; drawRect.y += 210; drawRect.width = 130; drawRect.height = 150; dragNDrop.ThisDropArea.Rect = drawRect; CustomGUIUtils.DrawBox(drawRect, XKCDColors.GreenApple); GUI.Label(drawRect, dragNDrop.ThisDropArea.ToString()); dragNDrop.DropAreaEnd("inner2"); } // DragObjects if (dragNDrop.DragObjectBegin(strings[1])) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[1].ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); dragNDrop.DragObjectEnd(strings[1]); } if (dragNDrop.DragObjectBegin(strings[2])) { CustomGUIUtils.DrawBox(dragNDrop.CurrentDragObject.CurrentRect, myGrey); GUI.Label(dragNDrop.CurrentDragObject.CurrentRect, strings[2].ToString()); GUI.DrawTexture(dragNDrop.CurrentDragObject.CurrentRect, DefaultIconSet.Device); dragNDrop.DragObjectEnd(strings[2]); } dragNDrop.DragObjectEnd(strings[0]); } //foreach (DropArea dropArea in dragNDrop.dropAreas.Values) //{ // if (dropArea.Object != null) // { // if (dropArea.Object.GetType() == typeof(A)) // { // A readA = dropArea.GetObject<A>(); // Debug.Log("A gelesen: " + readA.ToString()); // } // } //} }