コード例 #1
0
 public LinkedTree(T value)
 {
     this.value     = value;
     this.parent    = null;
     this.lastChild = null;
     this.previous  = (this.next = null);
 }
コード例 #2
0
ファイル: ContainerWidget.cs プロジェクト: weimingtom/Sakura
 internal void updateWidth(float srcWidth, float dstWidth)
 {
     if (srcWidth > 0f && dstWidth > 0f)
     {
         for (LinkedTree <Widget> linkedTree = base.LinkedTree.FirstChild; linkedTree != null; linkedTree = linkedTree.NextSibling)
         {
             Widget value = linkedTree.Value;
             int    num   = (int)(value.Anchors & (Anchors)240);
             if (num <= 32)
             {
                 if (num != 0)
                 {
                     if (num != 16)
                     {
                         if (num == 32)
                         {
                             float num2 = value.X + value.Width;
                             float num3 = srcWidth - num2;
                             this.scaleWidth(value, dstWidth / srcWidth);
                             value.X = dstWidth - num3 - value.Width;
                         }
                     }
                     else
                     {
                         this.scaleWidth(value, dstWidth / srcWidth);
                     }
                 }
                 else
                 {
                     this.scaleX(value, dstWidth / srcWidth);
                     this.scaleWidth(value, dstWidth / srcWidth);
                 }
             }
             else if (num != 48)
             {
                 if (num != 64)
                 {
                     if (num == 96)
                     {
                         value.X += dstWidth - srcWidth;
                     }
                 }
                 else
                 {
                     value.X += (dstWidth - srcWidth) / 2f;
                 }
             }
             else
             {
                 float num4 = value.Width + dstWidth - srcWidth;
                 if (num4 > 0f)
                 {
                     value.Width = num4;
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: Widget.cs プロジェクト: weimingtom/Sakura
        protected internal void ResetState(bool includeSelf)
        {
            LinkedTree <Widget> nextAsList = this.LinkedTree.LastDescendant.NextAsList;

            for (LinkedTree <Widget> nextAsList2 = this.LinkedTree; nextAsList2 != nextAsList; nextAsList2 = nextAsList2.NextAsList)
            {
                if (includeSelf || !nextAsList2.Value.Equals(this))
                {
                    nextAsList2.Value.OnResetState();
                }
            }
        }
コード例 #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && this.linkedTree != null)
     {
         this.linkedTree.RemoveChild();
         for (LinkedTree <UIElement> nextAsList = this.linkedTree; nextAsList != null; nextAsList = nextAsList.NextAsList)
         {
             if (nextAsList.Value != null)
             {
                 nextAsList.Value.DisposeSelf();
             }
         }
     }
 }
コード例 #5
0
        public void InsertChildBefore(LinkedTree <T> tree)
        {
            for (LinkedTree <T> linkedTree = tree.parent; linkedTree != null; linkedTree = linkedTree.parent)
            {
            }
            this.RemoveChild();
            LinkedTree <T> lastDescendant = this.LastDescendant;

            this.parent                  = tree.parent;
            this.previous                = tree.previous;
            lastDescendant.next          = tree;
            this.previous.next           = this;
            lastDescendant.next.previous = lastDescendant;
        }
コード例 #6
0
ファイル: ContainerWidget.cs プロジェクト: weimingtom/Sakura
        internal void updateHeight(float srcHeight, float dstHeight)
        {
            if (srcHeight > 0f && dstHeight > 0f)
            {
                for (LinkedTree <Widget> linkedTree = base.LinkedTree.FirstChild; linkedTree != null; linkedTree = linkedTree.NextSibling)
                {
                    Widget value = linkedTree.Value;
                    switch (value.Anchors & (Anchors)15)
                    {
                    case Anchors.None:
                        this.scaleY(value, dstHeight / srcHeight);
                        this.scaleHeight(value, dstHeight / srcHeight);
                        break;

                    case Anchors.Top:
                        this.scaleHeight(value, dstHeight / srcHeight);
                        break;

                    case Anchors.Bottom:
                    {
                        float num  = value.Y + value.Height;
                        float num2 = srcHeight - num;
                        this.scaleHeight(value, dstHeight / srcHeight);
                        value.Y = dstHeight - num2 - value.Height;
                        break;
                    }

                    case Anchors.Top | Anchors.Bottom:
                    {
                        float num3 = value.Height + dstHeight - srcHeight;
                        if (num3 > 0f)
                        {
                            value.Height = num3;
                        }
                        break;
                    }

                    case Anchors.Height:
                        value.Y += (dstHeight - srcHeight) / 2f;
                        break;

                    case Anchors.Bottom | Anchors.Height:
                        value.Y += dstHeight - srcHeight;
                        break;
                    }
                }
            }
        }
コード例 #7
0
ファイル: Widget.cs プロジェクト: weimingtom/Sakura
 protected internal virtual void Render()
 {
     for (LinkedTree <UIElement> linkedTree = this.rootUIElement.linkedTree; linkedTree != null; linkedTree = linkedTree.NextAsList)
     {
         UIElement value = linkedTree.Value;
         if (value.Visible && !value.ZSort)
         {
             value.SetupFinalAlpha();
             value.SetupDrawState();
             value.Render();
         }
         else
         {
             linkedTree = linkedTree.LastDescendant;
         }
     }
 }
コード例 #8
0
ファイル: Widget.cs プロジェクト: weimingtom/Sakura
        internal void updateForEachDescendant(float elapsedTime)
        {
            LinkedTree <Widget> nextAsList = this.linkedTree.LastDescendant.NextAsList;

            for (LinkedTree <Widget> linkedTree = this.linkedTree; linkedTree != nextAsList; linkedTree = linkedTree.NextAsList)
            {
                Widget value = linkedTree.Value;
                if (value.Visible)
                {
                    value.OnUpdate(elapsedTime);
                }
                else
                {
                    linkedTree = linkedTree.LastDescendant;
                }
            }
        }
コード例 #9
0
 public void RemoveChild()
 {
     if (this.parent != null)
     {
         LinkedTree <T> lastDescendant = this.LastDescendant;
         if (this.parent.lastChild == this)
         {
             this.parent.lastChild = this.PreviousSibling;
         }
         this.previous.next = lastDescendant.next;
         if (lastDescendant.next != null)
         {
             lastDescendant.next.previous = this.previous;
         }
         this.parent   = null;
         this.previous = (lastDescendant.next = null);
     }
 }
コード例 #10
0
        public void AddChildLast(LinkedTree <T> child)
        {
            for (LinkedTree <T> linkedTree = this.parent; linkedTree != null; linkedTree = linkedTree.parent)
            {
            }
            child.RemoveChild();
            LinkedTree <T> lastDescendant  = this.LastDescendant;
            LinkedTree <T> lastDescendant2 = child.LastDescendant;

            child.parent         = this;
            child.previous       = lastDescendant;
            lastDescendant2.next = lastDescendant.next;
            child.previous.next  = child;
            if (lastDescendant2.next != null)
            {
                lastDescendant2.next.previous = lastDescendant2;
            }
            this.lastChild = child;
        }
コード例 #11
0
ファイル: Widget.cs プロジェクト: weimingtom/Sakura
 internal virtual void AddZSortUIElements(ref UIElement zSortList)
 {
     for (LinkedTree <UIElement> linkedTree = this.rootUIElement.linkedTree; linkedTree != null; linkedTree = linkedTree.NextAsList)
     {
         UIElement value = linkedTree.Value;
         if (value.Visible)
         {
             value.SetupFinalAlpha();
             if (value.ZSort)
             {
                 value.SetupSortValue();
                 value.nextZSortElement = zSortList;
                 zSortList = value;
             }
         }
         else
         {
             linkedTree = linkedTree.LastDescendant;
         }
     }
 }
コード例 #12
0
        public void InsertChildAfter(LinkedTree <T> tree)
        {
            for (LinkedTree <T> linkedTree = tree.parent; linkedTree != null; linkedTree = linkedTree.parent)
            {
            }
            this.RemoveChild();
            LinkedTree <T> lastDescendant  = tree.LastDescendant;
            LinkedTree <T> lastDescendant2 = this.LastDescendant;

            this.parent          = tree.parent;
            this.previous        = lastDescendant;
            lastDescendant2.next = lastDescendant.next;
            this.previous.next   = this;
            if (lastDescendant2.next != null)
            {
                lastDescendant2.next.previous = lastDescendant2;
            }
            if (this.parent.lastChild == tree)
            {
                this.parent.lastChild = this;
            }
        }
コード例 #13
0
ファイル: Widget.cs プロジェクト: weimingtom/Sakura
        internal void RenderToFrameBuffer(FrameBuffer frameBuffer, ref Matrix4 transform, bool useOrthoProjection)
        {
            if (frameBuffer == null)
            {
                throw new ArgumentNullException("frameBuffer");
            }
            if (!frameBuffer.Status)
            {
                throw new ArgumentException("Frame buffer is not renderable.", "frameBuffer");
            }
            UISystem.IsOffScreenRendering = true;
            GraphicsContext graphicsContext      = UISystem.GraphicsContext;
            int             num                  = frameBuffer.Width;
            int             num2                 = frameBuffer.Height;
            Matrix4         viewProjectionMatrix = UISystem.ViewProjectionMatrix;
            Matrix4         transform3D          = this.Transform3D;
            PivotType       pivotType            = this.PivotType;

            this.Transform3D = transform;
            this.PivotType   = PivotType.TopLeft;
            LinkedTree <Widget> parent     = this.linkedTree.Parent;
            LinkedTree <Widget> linkedTree = null;

            if (parent != null)
            {
                linkedTree = this.LinkedTree.NextSibling;
                this.linkedTree.RemoveChild();
            }
            graphicsContext.SetFrameBuffer(frameBuffer);
            graphicsContext.SetColorMask((ColorMask)15);
            UISystem.SetClipRegionFull();
            graphicsContext.SetViewport(0, 0, num, num2);
            graphicsContext.SetClearColor(0f, 0f, 0f, 1f);
            graphicsContext.Clear();
            if (useOrthoProjection)
            {
                float num3 = 100000f;
                float num4 = -100000f;
                UISystem.ViewProjectionMatrix = new Matrix4(2f / (float)num * UISystem.Scale, 0f, 0f, 0f, 0f, -2f / (float)num2 * UISystem.Scale, 0f, 0f, 0f, 0f, -2f / (num3 - num4), 0f, -1f, 1f, (num3 + num4) / (num3 - num4), 1f);
            }
            UISystem.Render(this);
            graphicsContext.Enable((EnableMode)4u, true);
            graphicsContext.SetBlendFuncRgb((BlendFuncMode)0, (BlendFuncFactor)0, (BlendFuncFactor)1);
            graphicsContext.SetBlendFuncAlpha((BlendFuncMode)0, (BlendFuncFactor)9, (BlendFuncFactor)0);
            UISystem.SetClipRegionFull();
            UISprite     uISprite = new UISprite(1);
            UISpriteUnit unit     = uISprite.GetUnit(0);

            unit.SetPosition(-1f, -1f);
            unit.Width  = (float)frameBuffer.Width + 2f;
            unit.Height = (float)frameBuffer.Height + 2f;
            unit.Color  = new UIColor(0f, 0f, 0f, 1f);
            uISprite.Render();
            graphicsContext.SetFrameBuffer(null);
            UISystem.SetClipRegionFull();
            graphicsContext.SetColorMask((ColorMask)7);
            UISystem.ViewProjectionMatrix = viewProjectionMatrix;
            if (linkedTree != null)
            {
                this.linkedTree.InsertChildBefore(linkedTree);
            }
            else if (parent != null)
            {
                parent.AddChildLast(this.linkedTree);
            }
            this.pivotType   = pivotType;
            this.Transform3D = transform3D;
            UISystem.IsOffScreenRendering = false;
        }