Beispiel #1
0
 private void UpdateBackgroundSprite()
 {
     if ((this.updateFlags & Label.UpdateFlags.Background) == Label.UpdateFlags.Background)
     {
         UISpriteUnit unit = this.backgroundSprt.GetUnit(0);
         unit.Width        = this.Width;
         unit.Height       = this.Height;
         unit.Color        = this.BackgroundColor;
         this.updateFlags &= ~Label.UpdateFlags.Background;
     }
 }
Beispiel #2
0
        protected internal override void Render()
        {
            if (this.Width != 0f && this.Height != 0f)
            {
                this.UpdateBackgroundSprite();
                if (string.IsNullOrEmpty(this.Text))
                {
                    this.textSprt.Visible = false;
                }
                else
                {
                    this.UpdateTextSprite();
                }
            }
            this.updateFlags = (Label.UpdateFlags) 0;
//			Debug.WriteLine("=====================Render " + this.GetHashCode());
            base.Render();
        }
Beispiel #3
0
 private void UpdateTextSprite()
 {
     if ((this.updateFlags & Label.UpdateFlags.Text) == Label.UpdateFlags.Text)
     {
         //FIXME:refresh text texture
         UISpriteUnit unit = this.textSprt.GetUnit(0);
         unit.Width  = this.Width;
         unit.Height = this.Height;
         unit.Color  = this.TextColor;
         TextRenderHelper textRenderHelper = new TextRenderHelper();
         textRenderHelper.Font = this.Font;
         textRenderHelper.HorizontalAlignment = this.HorizontalAlignment;
         textRenderHelper.VerticalAlignment   = this.VerticalAlignment;
         textRenderHelper.LineBreak           = this.LineBreak;
         textRenderHelper.TextTrimming        = this.TextTrimming;
         textRenderHelper.LineGap             = this.LineGap;
         this.textSprt.Visible    = true;
         this.textSprt.ShaderType = ShaderType.TextTexture;
         this.textSprt.__name     = "see UpdateTextSprite";
         if (this.textSprt.Image != null)
         {
             this.textSprt.Image.Dispose();
         }
         //FIXME:write text to memory bitmap
         this.textSprt.Image = textRenderHelper.DrawText(ref this.text, (int)unit.Width, (int)unit.Height);
         if (this.TextShadow != null)
         {
             this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow;
             this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[]
             {
                 this.TextShadow.Color.R,
                 this.TextShadow.Color.G,
                 this.TextShadow.Color.B,
                 this.TextShadow.Color.A
             };
             this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[]
             {
                 this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width,
                 this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height
             };
         }
         this.updateFlags &= ~Label.UpdateFlags.Text;
     }
 }
Beispiel #4
0
 public Label()
 {
     this.backgroundSprt = new UISprite(1);
     base.RootUIElement.AddChildLast(this.backgroundSprt);
     this.backgroundSprt.ShaderType = ShaderType.SolidFill;
     this.BackgroundColor           = TextRenderHelper.DefaultBackgroundColor;
     this.textSprt = new UISprite(1);
     base.RootUIElement.AddChildLast(this.textSprt);
     this.textSprt.ShaderType = ShaderType.TextTexture;
     this.Text                = "";
     this.Font                = UISystem.DefaultFont;
     this.TextColor           = TextRenderHelper.DefaultTextColor;
     this.TextShadow          = null;
     this.HorizontalAlignment = HorizontalAlignment.Left;
     this.VerticalAlignment   = VerticalAlignment.Middle;
     this.LineBreak           = LineBreak.Character;
     this.TextTrimming        = TextTrimming.EllipsisCharacter;
     this.LineGap             = 0f;
     this.Width               = 214f;
     this.Height              = 27f;
     this.updateFlags         = (Label.UpdateFlags.Background | Label.UpdateFlags.Text);
 }