Ejemplo n.º 1
0
 public Segment(int x, int z, int direction, Rect checkSpace)
 {
     _direction  = direction > 3 ? direction - 3 : direction;
     _x          = GetXByDirection(x, direction);
     _z          = GetZByDirection(z, direction);
     _checkSpace = checkSpace;
 }
Ejemplo n.º 2
0
 public Button(string text, Util.Rect rect, Font font, VisualRectangle vsSelected, VisualRectangle vsUnselected)
 {
     this.font = font;
     this.vsSelected = vsSelected;
     this.vsUnselected = vsUnselected;
     this.rect = rect;
     this.text = text;
 }
Ejemplo n.º 3
0
 public Button(string text, Util.Rect rect)
 {
     this.font = GUIManager.mainFont;
     this.vsSelected = GUIManager.buttonRectSelected;
     this.vsUnselected = GUIManager.buttonRectUnselected;
     this.rect = rect;
     this.text = text;
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void Refresh()
        {
            this.layoutRect = new Util.Rect(0, 0, 0, 0);

            var y = TopMargin;

            foreach (var row in this.rows)
            {
                row.RefreshLayout(LeftMargin, y);
                y = row.layoutRect.yMax;

                this.layoutRect = this.layoutRect.Include(row.layoutRect);
            }

            foreach (var element in this.elements)
            {
                element.RefreshLayout();
            }
        }
Ejemplo n.º 6
0
        public override void RefreshLayout()
        {
            this.segments.Clear();
            this.interactableRegions.Clear();

            var tMult = this.manager.TimeToPixelsMultiplier;
            var pMult = this.manager.PitchedNoteHeight;

            foreach (var row in this.manager.EnumerateRowsInTimeRange(this.timeRange))
            {
                var trackPitchedNote = (TrackSegmentPitchedNotes)row.trackSegments[this.assignedTrack];

                if (this.pitch.MidiPitch < trackPitchedNote.minPitch.MidiPitch ||
                    this.pitch.MidiPitch > trackPitchedNote.maxPitch.MidiPitch)
                {
                    continue;
                }

                var midiPitchMinusTrackMin =
                    this.pitch.MidiPitch - trackPitchedNote.minPitch.MidiPitch;

                var startTimeMinusTrackStart = System.Math.Max(
                    0,
                    this.timeRange.Start - trackPitchedNote.row.timeRange.Start);

                var endTimeMinusTrackStart = System.Math.Min(
                    trackPitchedNote.row.timeRange.End,
                    this.timeRange.End) - trackPitchedNote.row.timeRange.Start;

                var noteRect = new Util.Rect(
                    trackPitchedNote.contentRect.xMin + tMult * startTimeMinusTrackStart,
                    trackPitchedNote.contentRect.yMax - pMult * (midiPitchMinusTrackMin + 1),
                    trackPitchedNote.contentRect.xMin + tMult * endTimeMinusTrackStart,
                    trackPitchedNote.contentRect.yMax - pMult * midiPitchMinusTrackMin);

                this.segments.Add(new Segment {
                    noteRect = noteRect
                });

                this.interactableRegions.Add(
                    new InteractableRegion(InteractableRegion.CursorKind.MoveAll, noteRect));
            }
        }
Ejemplo n.º 7
0
        public override void RefreshLayout()
        {
            this.interactableRegions.Clear();

            var tMult = this.manager.TimeToPixelsMultiplier;

            this.row = this.manager.GetRowOverlapping(this.time);
            if (this.row != null)
            {
                var track = this.row.trackSegmentKeyChanges;
                var timeMinusTrackStart = this.time - this.row.timeRange.Start;

                var handleRect = new Util.Rect(
                    track.contentRect.xMin + tMult * timeMinusTrackStart - HANDLE_WIDTH / 2,
                    track.contentRect.yMin,
                    track.contentRect.xMin + tMult * timeMinusTrackStart + HANDLE_WIDTH / 2,
                    track.contentRect.yMax);

                this.interactableRegions.Add(
                    new InteractableRegion(InteractableRegion.CursorKind.MoveHorizontal, handleRect));
            }
        }
Ejemplo n.º 8
0
        /** Draws a visual rectangle enclosing the rect parameter. Note that the actual rectangle drawn may be larger than the
          * inputted rectangle. */
        public void renderRect(Util.Rect desiredRect)
        {
            //Find the actual rectangle to enclose.
            Util.Rect actualRect = new Util.Rect();
            actualRect.w = desiredRect.w + objectWidth * 2;
            if (actualRect.w % objectWidth != 0)
                actualRect.w += (objectWidth - actualRect.w % objectWidth);

            actualRect.h = desiredRect.h + objectHeight * 2;
            if (actualRect.h % objectHeight != 0)
                actualRect.h = actualRect.h + (objectHeight - actualRect.h % objectHeight);

            actualRect.centreX = desiredRect.centreX;
            actualRect.centreY = desiredRect.centreY;

            int nWidthEdges = (actualRect.w - 2 * objectWidth) / objectWidth;
            int nHeightEdges = (actualRect.h - 2 * objectHeight) / objectHeight;

            int lowerLeftX = actualRect.x, lowerLeftY = actualRect.y;
            int upperRightX = actualRect.x+objectWidth*(1+nWidthEdges), upperRightY = actualRect.y + objectHeight * (1 + nHeightEdges);

            //Draw the 4 corners
            Sprite sprite = new Sprite(new Util.Rect(lowerLeftX, lowerLeftY, objectWidth, objectHeight), this); ;

            sprite.setTilesetIndex(0, 2);
            HighLevelRenderer.draw(sprite);

            sprite.rect.y = upperRightY;
            sprite.setTilesetIndex(0, 0);
            HighLevelRenderer.draw(sprite);

            sprite.rect.x = upperRightX;
            sprite.setTilesetIndex(2, 0);
            HighLevelRenderer.draw(sprite);

            sprite.rect.y = lowerLeftY;
            sprite.setTilesetIndex(2, 2);
            HighLevelRenderer.draw(sprite);

            //Draw the vertical edges.
            for (int i = lowerLeftY + objectHeight, j = 0; j < nHeightEdges; ++j, i += objectHeight)
            {
                sprite.rect.y = i;
                sprite.rect.x = lowerLeftX;
                sprite.setTilesetIndex(0, 1);
                HighLevelRenderer.draw(sprite);
                sprite.setTilesetIndex(2, 1);
                sprite.rect.x = upperRightX;
                HighLevelRenderer.draw(sprite);
            }

            //Draw the horizontal edges.
            for (int i = lowerLeftX + objectWidth, j = 0; j < nWidthEdges; ++j, i += objectWidth)
            {
                sprite.rect.x = i;
                sprite.rect.y = lowerLeftY;
                sprite.setTilesetIndex(1, 2);
                HighLevelRenderer.draw(sprite);
                sprite.setTilesetIndex(1, 0);
                sprite.rect.y = upperRightY;
                HighLevelRenderer.draw(sprite);
            }

            //Fill the insides
            sprite.setTilesetIndex(1, 1);
            for (int x = lowerLeftX + objectWidth, j = 0; j < nWidthEdges; ++j, x += objectWidth)
            {
                for (int y = lowerLeftY + objectHeight, k = 0; k < nHeightEdges; ++k, y += objectHeight)
                {
                    sprite.rect.x = x;
                    sprite.rect.y = y;
                    HighLevelRenderer.draw(sprite);
                }
            }

            int minWidth = this.width;
            int minHeight = this.height;
        }
Ejemplo n.º 9
0
 public InteractableRegion(CursorKind cursorKind, Util.Rect boundingBox)
 {
     this.cursorKind = cursorKind;
     this.rect       = boundingBox;
     this.isolated   = false;
 }