コード例 #1
0
ファイル: ViewManager.cs プロジェクト: hlorenzi/composer
        public void OnMouseUp(float x, float y)
        {
            this.mouseIsDown = false;

            if (this.mouseAction == MouseAction.Selection)
            {
                if (this.currentDraggingIsolatedRegion != null)
                {
                    this.currentDraggingIsolatedRegion.dragEndFunc?.Invoke(this.currentDraggingIsolatedRegion);

                    if (this.currentHoverRegion == this.currentDraggingIsolatedRegion)
                    {
                        this.currentDraggingIsolatedRegion.clickFunc?.Invoke(this.currentDraggingIsolatedRegion);
                    }

                    this.currentDraggingIsolatedRegion = null;
                }
                else
                {
                    this.ModifySelected((elem) => { });
                }

                this.Rebuild();
            }
        }
コード例 #2
0
        public void RefreshLayout(float x, float y)
        {
            this.resizeEndTime = this.timeRange.End;

            this.layoutRect = new Util.Rect(
                x, y,
                x, y + ADD_SECTION_BUTTON_SIZE + ADD_SECTION_BUTTON_MARGIN + SECTION_HANDLE_HEIGHT);

            this.contentRect = new Util.Rect(
                x, this.layoutRect.yMax,
                x, this.layoutRect.yMax);

            foreach (var track in this.trackSegments)
            {
                track.RefreshLayout(x, this.layoutRect.yMax);
                this.layoutRect  = this.layoutRect.Include(track.layoutRect);
                this.contentRect = this.contentRect.Include(track.contentRect);
            }

            this.layoutRect.yMax += ADD_SECTION_BUTTON_MARGIN;

            this.interactableRegions.Clear();

            this.regionAddSectionBeforeButton = new InteractableRegion(
                InteractableRegion.CursorKind.Select,
                new Util.Rect(
                    this.layoutRect.xMin,
                    this.layoutRect.yMin + ADD_SECTION_BUTTON_MARGIN,
                    this.layoutRect.xMin + ADD_SECTION_BUTTON_SIZE,
                    this.layoutRect.yMin + ADD_SECTION_BUTTON_MARGIN + ADD_SECTION_BUTTON_SIZE));
            this.regionAddSectionBeforeButton.SetButton(this.Click_AddSectionBefore);
            this.interactableRegions.Add(this.regionAddSectionBeforeButton);

            if (this.isLastRow)
            {
                this.regionAddSectionAfterButton = new InteractableRegion(
                    InteractableRegion.CursorKind.Select,
                    new Util.Rect(
                        this.layoutRect.xMin,
                        this.layoutRect.yMax + ADD_SECTION_BUTTON_MARGIN,
                        this.layoutRect.xMin + ADD_SECTION_BUTTON_SIZE,
                        this.layoutRect.yMax + ADD_SECTION_BUTTON_MARGIN + ADD_SECTION_BUTTON_SIZE));
                this.regionAddSectionAfterButton.SetButton(this.Click_AddSectionAfter);
                this.interactableRegions.Add(this.regionAddSectionAfterButton);
            }

            this.regionResizeHandle = new InteractableRegion(
                InteractableRegion.CursorKind.MoveHorizontal,
                new Util.Rect(
                    this.layoutRect.xMax - 5,
                    this.layoutRect.yMin + ADD_SECTION_BUTTON_SIZE + ADD_SECTION_BUTTON_MARGIN * 2,
                    this.layoutRect.xMax + 5,
                    this.layoutRect.yMin + ADD_SECTION_BUTTON_SIZE + ADD_SECTION_BUTTON_MARGIN * 2 + 10));
            this.regionResizeHandle.SetIsolated(null, this.Drag_SectionHandle, this.DragEnd_SectionHandle);
            this.interactableRegions.Add(this.regionResizeHandle);
        }
コード例 #3
0
ファイル: ViewManager.cs プロジェクト: hlorenzi/composer
        public void OnMouseDown(bool scroll, float x, float y, bool ctrlKey, bool shiftKey)
        {
            this.mouseIsDown       = true;
            this.mouseDragOriginX  = x + scrollX;
            this.mouseDragOriginY  = y + scrollY;
            this.noteInsertionMode = false;

            if (scroll)
            {
                this.mouseAction = MouseAction.Scrolling;
            }
            else
            {
                this.mouseAction   = MouseAction.Selection;
                this.cursorVisible = false;

                if ((!ctrlKey && (this.currentHoverElement == null || !this.currentHoverElement.selected)) ||
                    this.currentHoverRegion != null && this.currentHoverRegion.isolated)
                {
                    UnselectAll();
                }

                if (this.currentHoverElement != null)
                {
                    this.currentHoverElement.selected = true;
                }

                this.timeDragOrigin =
                    this.GetTimeAtPosition(this.mouseDragOriginX, this.mouseDragOriginY, true);

                this.trackDragOrigin =
                    this.GetTrackIndexAtPosition(this.mouseDragOriginX, this.mouseDragOriginY);

                var timeSnapped = (float)(System.Math.Round(this.timeDragOrigin / TimeSnap) * TimeSnap);

                this.pitchDragOrigin =
                    this.GetTrackSegmentAtPosition(this.mouseDragOriginX, this.mouseDragOriginY).
                    GetPitchAtPosition(this.mouseDragOriginY);

                if (this.currentHoverRegion != null && this.currentHoverRegion.isolated)
                {
                    this.currentDraggingIsolatedRegion = this.currentHoverRegion;
                    this.currentDraggingIsolatedRegion.dragStartFunc?.Invoke(this.currentDraggingIsolatedRegion);
                }
                else if (!ctrlKey && !shiftKey && this.currentHoverRegion == null)
                {
                    this.mouseAction = MouseAction.Cursor;
                    this.SetCursorTimeRange(timeSnapped, timeSnapped);
                    this.SetCursorTrackIndices(this.trackDragOrigin, this.trackDragOrigin);
                    this.cursorVisible = true;
                }
            }
        }
コード例 #4
0
 public void DragEnd_SectionHandle(InteractableRegion region)
 {
     if (this.resizeEndTime >= this.timeRange.Start &&
         this.resizeEndTime != this.timeRange.End)
     {
         if (this.resizeEndTime < this.timeRange.End)
         {
             this.manager.project.CutRange(
                 Util.TimeRange.StartEnd(this.resizeEndTime, this.timeRange.End));
         }
         else
         {
             this.manager.project.InsertEmptySpace(
                 this.timeRange.End, this.resizeEndTime - this.timeRange.End);
         }
     }
     this.manager.Rebuild();
 }
コード例 #5
0
ファイル: ViewManager.cs プロジェクト: hlorenzi/composer
        public void OnMouseMove(float x, float y)
        {
            this.mouseCurrentX = x + scrollX;
            this.mouseCurrentY = y + scrollY;

            if (this.mouseIsDown)
            {
                if (this.mouseAction == MouseAction.Selection)
                {
                    if (this.currentHoverRegion != null && this.currentHoverRegion.isolated)
                    {
                        this.currentHoverRegion.dragFunc?.Invoke(this.currentHoverRegion);
                    }
                    else
                    {
                        foreach (var element in this.elements)
                        {
                            if (element.selected)
                            {
                                element.Drag();
                                element.RefreshLayout();
                            }
                        }
                    }
                }
                else if (this.mouseAction == MouseAction.Scrolling)
                {
                    var deltaX = this.mouseDragOriginX - this.mouseCurrentX;
                    var deltaY = this.mouseDragOriginY - this.mouseCurrentY;

                    this.ScrollTo(this.scrollX + deltaX, this.scrollY + deltaY);

                    this.mouseCurrentX = this.mouseDragOriginX = x + scrollX;
                    this.mouseCurrentY = this.mouseDragOriginY = y + scrollY;
                }
                else if (this.mouseAction == MouseAction.Cursor)
                {
                    var track = this.GetTrackIndexAtPosition(this.mouseCurrentX, this.mouseCurrentY);

                    var time        = this.GetTimeAtPosition(this.mouseCurrentX, this.mouseCurrentY, true);
                    var timeSnapped = (float)(System.Math.Round(time / TimeSnap) * TimeSnap);

                    this.SetCursorTimeRange(this.cursorTime1, timeSnapped);
                    this.SetCursorTrackIndices(this.cursorTrack1, track);
                }
            }
            else
            {
                var lastHoverRegion = this.currentHoverRegion;

                this.currentHoverElement = null;
                this.currentHoverRegion  = null;

                foreach (var element in this.elements)
                {
                    foreach (var region in element.interactableRegions)
                    {
                        if (region.rect.Contains(x + scrollX, y + scrollY))
                        {
                            this.currentHoverElement = element;
                            this.currentHoverRegion  = region;
                        }
                    }
                }

                foreach (var row in this.rows)
                {
                    foreach (var region in row.interactableRegions)
                    {
                        if (region.rect.Contains(x + scrollX, y + scrollY))
                        {
                            this.currentHoverElement = null;
                            this.currentHoverRegion  = region;
                        }
                    }
                }

                if (this.currentHoverRegion != null)
                {
                    switch (this.currentHoverRegion.cursorKind)
                    {
                    case InteractableRegion.CursorKind.Select:
                        this.control.Cursor = System.Windows.Forms.Cursors.Hand; break;

                    case InteractableRegion.CursorKind.MoveAll:
                        this.control.Cursor = System.Windows.Forms.Cursors.SizeAll; break;

                    case InteractableRegion.CursorKind.MoveHorizontal:
                        this.control.Cursor = System.Windows.Forms.Cursors.SizeWE; break;

                    default:
                        this.control.Cursor = System.Windows.Forms.Cursors.Default; break;
                    }
                }
                else
                {
                    this.control.Cursor = System.Windows.Forms.Cursors.Default;
                }
            }
        }
コード例 #6
0
 public void Click_AddSectionAfter(InteractableRegion region)
 {
     this.manager.project.InsertSection(this.timeRange.End, this.manager.project.WholeNoteDuration * 4);
     this.manager.Rebuild();
 }
コード例 #7
0
 public void Drag_SectionHandle(InteractableRegion region)
 {
     this.resizeEndTime = System.Math.Max(
         this.timeRange.Start,
         this.timeRange.End + this.manager.DragTimeOffsetIrrespectiveOfRow);
 }