Beispiel #1
0
        protected void UpdatePositionAndSize()
        {
            // wait until lyric update ruby position.
            ScheduleAfterChildren(() =>
            {
                var textTagRect = editorLyricPiece.GetTextTagPosition(Item);

                var startIndexPosition = editorLyricPiece.GetTextIndexPosition(TextIndexUtils.FromStringIndex(Item.StartIndex, false));
                var endIndexPosition   = editorLyricPiece.GetTextIndexPosition(TextIndexUtils.FromStringIndex(Item.EndIndex, true));

                // update select position
                updateDrawableRect(previewTextArea, textTagRect);

                // update index range position.
                var indexRangePosition = new Vector2(startIndexPosition.X, textTagRect.Y);
                var indexRangeSize     = new Vector2(endIndexPosition.X - startIndexPosition.X, textTagRect.Height);
                updateDrawableRect(indexRangeBackground, new RectangleF(indexRangePosition, indexRangeSize));
            });

            void updateDrawableRect(Drawable target, RectangleF rect)
            {
                target.X      = rect.X;
                target.Y      = rect.Y;
                target.Width  = rect.Width;
                target.Height = rect.Height;
            }
        }
Beispiel #2
0
        [TestCase(0, true, -1, TextIndex.IndexState.End)] // In utils not checking is index out of range
        public void TestFromStringIndex(int textindex, bool end, int actualIndex, TextIndex.IndexState actualState)
        {
            var actualTextIndex = new TextIndex(actualIndex, actualState);

            Assert.AreEqual(TextIndexUtils.FromStringIndex(textindex, end), actualTextIndex);
        }