Exemplo n.º 1
0
        public void OnRender(RenderEventArgs e)
        {
            var transform = TransformToGlobal;

            Graphics.TexturedQuad quadOverlay = new Graphics.TexturedQuad();
            quadOverlay.ColorToModulate = Color;
            e.RenderManager.Draw(quadOverlay, Region, transform);
        }
Exemplo n.º 2
0
		public void OnRender(RenderEventArgs e)
		{
			var tranform = TransformToGlobal;
			for (int i = 0; i < Quads.Count; ++i)
			{
				var quad = Quads[i];
				e.RenderManager.Draw(quad.TextureQuad, quad.Bounds, tranform);
			}
		}
Exemplo n.º 3
0
            public override void OnRender(RenderEventArgs e)
            {
                if (FormattedText != null)
                {
                    var transform = TransformToGlobal;
                    e.RenderManager.Draw(new TexturedQuad { ColorToModulate = m_textBox.ImeCandidateListBackColor },
                        new Rectangle(-2, 0, FormattedText.Size.Width + 4, FormattedText.Size.Height),
                        transform);
                    var selection = FormattedText.GetLineRectangle(m_textBox.m_candidateListData.Selection);
                    selection.Left -= 2;
                    selection.Width += 4;
                    e.RenderManager.Draw(new TexturedQuad { ColorToModulate = m_textBox.ImeCandidateListSelectionBackColor },
                        selection, transform);
                }

                base.OnRender(e);
            }
Exemplo n.º 4
0
        public virtual void OnRender(RenderEventArgs e)
        {
            if (FormattedText != null)
            {
                var transform = TransformToGlobal;

                Graphics.TextRenderer.DrawOptions drawOptions;
                if (Shadowed)
                {
                    drawOptions = Graphics.TextRenderer.DrawOptions.Default;
                    drawOptions.ForcedColor = ShadowTextColor;
                    drawOptions.Offset = ShadowOffset;
                    e.TextRenderer.DrawText(FormattedText, transform, drawOptions);
                }
                drawOptions = Graphics.TextRenderer.DrawOptions.Default;
                drawOptions.ColorScaling = TextColor.ToVector4();
                drawOptions.OutlineColor = TextOutlineColor.ToVector4();
                e.TextRenderer.DrawText(FormattedText, transform, drawOptions);
            }
        }
Exemplo n.º 5
0
 public virtual void RenderPostMain(XnaMatrix transform, RenderEventArgs e) { }
Exemplo n.º 6
0
 public virtual void RenderDepth(XnaMatrix transform, RenderEventArgs e) { }
Exemplo n.º 7
0
        public void OnRender(RenderEventArgs e)
        {
            var scrollPosition = m_scrollPosition;
            if (m_scrollSlideTrack != null && m_scrollSlideTrack.IsPlaying)
            {
                m_scrollSlideTrack.Elapse((float)GameApp.Instance.TargetElapsedTime.TotalSeconds);
                scrollPosition = m_currentScrollPosition;
            }

            var transform = TransformToGlobal;
            var drawOptions = TextRenderer.DrawOptions.Default;
            drawOptions.DrawFlags |= TextRenderer.DrawFlags.BoundedByBox;
            drawOptions.BoundingBox = new Rectangle(0, 0, InputAreaWidth, Height);
            drawOptions.ColorScaling = ForeColor.ToVector4();
            drawOptions.Offset.X = -scrollPosition;

            if (m_selectionLength != 0)
            {
                var selectionBegin = m_selectionLength < 0 ? m_caretPosition + m_selectionLength : m_caretPosition;
                var selectionEnd = m_selectionLength > 0 ? m_caretPosition + m_selectionLength : m_caretPosition;

                // selection background
                var selectionLeft = m_allText.MeasureLeft(selectionBegin) - scrollPosition;
                var selectionWidth = m_allText.MeasureWidth(selectionBegin, selectionEnd);

                // clamp selection into window
                if (selectionLeft < 0)
                {
                    selectionWidth += selectionLeft;
                    selectionLeft = 0;
                }
                if (selectionLeft + selectionWidth > InputAreaWidth)
                {
                    selectionWidth = InputAreaWidth - selectionLeft;
                }

                if (selectionWidth > 0)
                {
                    e.RenderManager.Draw(new TexturedQuad
                    {
                        ColorToModulate = SelectionBackColor
                    }, new Rectangle(selectionLeft, 0, selectionWidth, Height), transform);

                    // draw the text before selection
                    if (selectionBegin > 0)
                    {
                        drawOptions.SubstringLength = selectionBegin;
                        e.TextRenderer.DrawText(m_allText, transform, drawOptions);
                    }
                    // draw the selected text
                    drawOptions.ColorScaling = SelectionForeColor.ToVector4();
                    drawOptions.SubstringStart = selectionBegin;
                    drawOptions.SubstringLength = selectionEnd - selectionBegin;
                    e.TextRenderer.DrawText(m_allText, transform, drawOptions);
                    // draw the text after selection
                    if (selectionEnd < m_text.Length)
                    {
                        drawOptions.ColorScaling = ForeColor.ToVector4();
                        drawOptions.SubstringStart = selectionEnd;
                        drawOptions.SubstringLength = m_text.Length - selectionEnd;
                        e.TextRenderer.DrawText(m_allText, transform, drawOptions);
                    }
                }
            }
            else
            {
                e.TextRenderer.DrawText(m_allText, transform, drawOptions);
            }

            // caret
            m_caretBlinkTimer += GameApp.Instance.TargetElapsedTime.Milliseconds;
            if (m_isFocused && !m_compositionData.InComposition && ((int)Math.Floor(m_caretBlinkTimer / CaretBlinkTime) % 2) == 0)
            {
                var caretPosition = m_allText.MeasureWidth(0, m_caretPosition) - scrollPosition;
                caretPosition = MathHelper.Clamp(caretPosition, 0, InputAreaWidth);
                e.RenderManager.Draw(new TexturedQuad { ColorToModulate = ForeColor },
                    new Rectangle(caretPosition - 1, 0, 2, Height), transform);
            }

            // ime indicator
            if (m_isFocused)
            {
                e.RenderManager.Draw(new TexturedQuad { ColorToModulate = ImeIndicatorBackColor },
                    new Rectangle(Width - ImeIndicatorWidth, 0, ImeIndicatorWidth, Height), transform);
                var indicatorWidth = m_inidcatorStr.MeasureWidth(0, m_inidcatorStr.Text.Length);
                var drawOptions2 = TextRenderer.DrawOptions.Default;
                drawOptions2.ColorScaling = ImeIndicatorForeColor.ToVector4();
                drawOptions2.Offset.X = Width - ImeIndicatorWidth / 2 - indicatorWidth / 2;
                e.TextRenderer.DrawText(m_inidcatorStr, transform, drawOptions2);
            }

            // composition string
            if (m_compositionData.InComposition)
            {
                // composition background
                var caretPosition = m_allText.MeasureLeft(m_caretPosition) - scrollPosition;
                var compositionLeft = caretPosition;
                var compositionWidth = m_compositionString.MeasureWidth(0, m_compositionString.Text.Length);

                // clamp composition into window
                if (compositionLeft < 0)
                {
                    compositionWidth += compositionLeft;
                    compositionLeft = 0;
                }
                if (compositionLeft + compositionWidth > InputAreaWidth)
                {
                    compositionWidth = InputAreaWidth - compositionLeft;
                }

                if (compositionWidth > 0)
                {
                    e.RenderManager.Draw(new TexturedQuad
                    {
                        ColorToModulate = ImeCompositionStringBackColor
                    }, new Rectangle(compositionLeft, 0, compositionWidth, Height), transform);

                    var drawOptions2 = TextRenderer.DrawOptions.Default;
                    drawOptions2.DrawFlags |= TextRenderer.DrawFlags.BoundedByBox;
                    drawOptions2.BoundingBox = new Rectangle(0, 0, InputAreaWidth, Height);
                    drawOptions2.ColorScaling = ImeCompositionStringForeColor.ToVector4();
                    drawOptions2.Offset.X = caretPosition;
                    e.TextRenderer.DrawText(m_compositionString, transform, drawOptions2);

                    for (int i = 0; i < m_compositionData.Attributes.Length; ++i)
                    {
                        // get the clause range sharing the same attribute
                        Ime.ClauseAttribute clauseAttr = m_compositionData.Attributes[i];
                        int j = i + 1;
                        for (; j < m_compositionData.Attributes.Length; ++j)
                        {
                            if (m_compositionData.Attributes[j] != clauseAttr)
                            {
                                break;
                            }
                        }

                        float clauseLeft = m_compositionString.MeasureLeft(i) + caretPosition;
                        float clauseWidth = m_compositionString.MeasureWidth(i, j);
                        // clamp clause into window
                        if (clauseLeft < 0)
                        {
                            clauseWidth += clauseLeft;
                            clauseLeft = 0;
                        }
                        if (clauseLeft + clauseWidth > InputAreaWidth)
                        {
                            clauseWidth = InputAreaWidth - clauseLeft;
                        }
                        if (clauseWidth > 0)
                        {
                            VirtualTexture lineTexture;
                            float lineThickness;
                            switch (clauseAttr)
                            {
                                case Ime.ClauseAttribute.Input:
                                case Ime.ClauseAttribute.InputError:
                                    lineTexture = GameApp.Service<Resources>().DashLine;
                                    lineThickness = 1f;
                                    break;
                                case Ime.ClauseAttribute.TargetConverted:
                                case Ime.ClauseAttribute.TargetNotConverted:
                                    lineTexture = GameApp.Service<Resources>().SolidLine;
                                    lineThickness = 2f;
                                    break;
                                default:
                                    lineTexture = GameApp.Service<Resources>().SolidLine;
                                    lineThickness = 1f;
                                    break;
                            }
                            
                            e.RenderManager.Draw(new TexturedQuad(lineTexture)
                            {
                                UVBounds = new Rectangle(0, 0, clauseWidth, GameApp.Service<Resources>().DashLine.Height),
                                Flags = TextureQuadFlags.OffsetByHalfTexel | TextureQuadFlags.WrapUV,
                            }, new Rectangle(clauseLeft, Height - lineThickness - 1, clauseWidth, lineThickness), transform);
                        }

                        i = j - 1;
                    }

                    // composition caret
                    if (((int)Math.Floor(m_caretBlinkTimer / CaretBlinkTime) % 2) == 0)
                    {
                        var caretPosition2 = caretPosition + m_compositionString.MeasureWidth(0, m_compositionData.Caret);
                        caretPosition2 = MathHelper.Clamp(caretPosition2, 0, InputAreaWidth);
                        e.RenderManager.Draw(new TexturedQuad { ColorToModulate = ImeCompositionStringForeColor },
                            new Rectangle(caretPosition2 - 1, 0, 2, Height), transform);
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void OnRender(RenderEventArgs e)
        {
            var transform = TransformToGlobal;

            Graphics.TexturedQuad face;
            if (!Enabled)
            {
                face = DisabledFace ?? NormalFace;
            }
            else if (IsMouseButton1Pressed)
            {
                face = PressedFace ?? HoverFace ?? NormalFace;
            }
            else if (IsMouseOver)
            {
                face = HoverFace ?? NormalFace;
            }
            else
            {
                face = NormalFace;
            }

            if (face != null)
            {
                e.RenderManager.Draw(face, Region, transform);
            }

            if (ButtonText != null)
            {
                Point position = Region.LeftTop + (Region.Size - ButtonText.Size) / 2.0f;
                var drawOptions = Graphics.TextRenderer.DrawOptions.Default;
                drawOptions.ColorScaling = TextColor.ToVector4();
                drawOptions.OutlineColor = TextOutlineColor.ToVector4();
                drawOptions.Offset = new Point((int)position.X, (int)position.Y);
                e.TextRenderer.DrawText(ButtonText, transform, drawOptions);
            }
        }