示例#1
0
    public void OpenGuidePopup()
    {
        IconCanvasGuidePopup guidePopup = new IconCanvasGuidePopup();

        guidePopup.Callback += (float val, IconCanvasGuideType type) => { IconCanvasGuide.AddGuide(val, type); };
        PopupWindow.Show(new Rect(rulerSize + 5f, toolbarHeight + rulerSize + 5f, 0, 0), guidePopup);
    }
示例#2
0
    void OnEnable()
    {
        wantsMouseMove             = true;
        wantsMouseEnterLeaveWindow = true;

        Prefs.DrawRulers.valueChanged.AddListener(Repaint);

        if (!canvas)
        {
            canvas = CreateInstance(typeof(IconCanvas)) as IconCanvas;
            canvas.Size.valueChanged.AddListener(Repaint);
        }
        canvas.Reset();
        IconCanvasGuide.ClearAllGuides();
    }
示例#3
0
    public void MouseDrag(Event e)
    {
        if (e.button == 0 && dragging)
        {
            localPosition = IconSetWindow.Instance.canvas.GetLocalMousePositionOnGrid();
            localPosition = IconCanvasGuide.GetSnappedLocation(this);

            if (e.control)
            {
                localPosition = new Vector2(Handles.SnapValue(localPosition.x, 1f / IconSetWindow.Instance.canvas.cells), Handles.SnapValue(localPosition.y, 1f / IconSetWindow.Instance.canvas.cells));
            }

            e.Use();
            dirty = true;
        }
    }
示例#4
0
 void ReceiveFunctionCallback(string function)
 {
     if (function == "Add guide...")
     {
         popupDelegate = OpenGuidePopup;
     }
     if (function == "Clear points")
     {
         canvas.ClearPoints();
     }
     if (function == "Reset grid")
     {
         canvas.Reset();
     }
     if (function == "Toggle guide rulers")
     {
         Prefs.DrawRulers.value = !Prefs.DrawRulers.value;
     }
     if (function == "Clear guides")
     {
         IconCanvasGuide.ClearAllGuides();
     }
 }
示例#5
0
 public void DrawDottedLine(IconCanvasGuide guide, Vector2 offset)
 {
     DrawDottedLine(guide[0], guide[1], guide.width, guide.dash, guide.space, (guide.hovered || guide == activeGuide) ? guide.hover : guide.color, guide.type, offset);
 }
示例#6
0
 public void DrawDottedLine(IconCanvasGuide guide)
 {
     DrawDottedLine(guide[0], guide[1], guide.width, guide.dash, guide.space, (guide.hovered || guide == activeGuide) ? guide.hover : guide.color);
 }
示例#7
0
    public void ProcessGuideEvents(Event e)
    {
        Vector2 localMouse = canvas.GetLocalMousePositionOnGrid();

        if (e.type == EventType.MouseDown && e.button == 0)
        {
            if (topRuler.Contains(e.mousePosition))
            {
                activeGuide = new IconCanvasGuide(canvas, localMouse, IconCanvasGuideType.Horizontal);
            }
            else if (leftRuler.Contains(e.mousePosition))
            {
                activeGuide = new IconCanvasGuide(canvas, localMouse, IconCanvasGuideType.Vertical);
            }
            else
            {
                activeGuide = IconCanvasGuide.GetGuideAtPos(e.mousePosition);

                // May not need this
                if (activeGuide != null)
                {
                    activeGuide.snap = e.control;
                    activeGuide.SetLocalPosition(localMouse);
                }
            }

            if (activeGuide != null)
            {
                e.Use();
                GUI.changed = true;
            }
        }

        if ((e.type == EventType.MouseMove || e.type == EventType.MouseDrag) && activeGuide != null)
        {
            activeGuide.snap = e.control;
            activeGuide.SetLocalPosition(localMouse);
            e.Use();
            GUI.changed = true;
        }

        if (e.type == EventType.MouseUp && e.button == 0 && activeGuide != null)
        {
            if (activeGuide.Value < 0f || activeGuide.Value > 1f)
            {
                activeGuide.DeleteGuide();
            }

            activeGuide = null;

            e.Use();
            GUI.changed = true;
        }

        if (activeGuide != null && e.isKey)
        {
            activeGuide.snap = e.control;
            activeGuide.SetLocalPosition(localMouse);
            GUI.changed = true;
        }
    }