Ejemplo n.º 1
0
        public void ShowAGroupOf3x3Items_OutterGroupIsHorizontal()
        {
            LayoutGroup outterGroup = new LayoutGroup(false, Styles.DefaultGroupStyle);
            LayoutGroup innerGroup0 = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutGroup innerGroup1 = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutGroup innerGroup2 = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutEntry item        = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 50
            };

            innerGroup0.Add(item.Clone());
            innerGroup0.Add(item.Clone());
            innerGroup0.Add(item.Clone());
            innerGroup1.Add(item.Clone());
            innerGroup1.Add(item.Clone());
            innerGroup1.Add(item.Clone());
            innerGroup2.Add(item.Clone());
            innerGroup2.Add(item.Clone());
            innerGroup2.Add(item.Clone());
            outterGroup.Add(innerGroup0);
            outterGroup.Add(innerGroup1);
            outterGroup.Add(innerGroup2);

            outterGroup.CalcWidth();
            outterGroup.CalcHeight();
            outterGroup.SetX(0);
            outterGroup.SetY(0);

            outterGroup.ShowResult();
        }
Ejemplo n.º 2
0
        public void TheSizeOfAnEntryIsCorrectlyCalculated()
        {
            LayoutEntry item = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 50
            };

            item.CalcWidth();
            item.CalcHeight();

            Assert.Equal(item.ContentWidth + Const.ItemPaddingLeft + Const.ItemPaddingRight + Const.ItemBorderLeft + Const.ItemBorderRight, item.Rect.Width);
            Assert.Equal(item.ContentHeight + Const.ItemPaddingTop + Const.ItemPaddingBottom + Const.ItemBorderTop + Const.ItemBorderBottom, item.Rect.Height);
        }
Ejemplo n.º 3
0
        public void ShowA3LayerGroup()
        {
            LayoutGroup group1 = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutGroup group2 = new LayoutGroup(false, Styles.DefaultGroupStyle);
            LayoutGroup group3 = new LayoutGroup(false, Styles.DefaultGroupStyle);
            LayoutGroup group4 = new LayoutGroup(false, Styles.DefaultGroupStyle);
            LayoutGroup group5 = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutEntry item1  = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 50
            };
            LayoutEntry item2 = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 80
            };
            LayoutEntry item3 = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 80, ContentHeight = 50
            };
            LayoutEntry item4 = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 400, ContentHeight = 50
            };

            group1.Add(group2);
            group1.Add(group3);
            group1.Add(group4);

            group2.Add(item1.Clone());
            group2.Add(item2.Clone());
            group2.Add(item3.Clone());

            group3.Add(item1.Clone());
            group3.Add(group5);
            group3.Add(item1.Clone());

            group4.Add(item4.Clone());

            group5.Add(item1.Clone());
            group5.Add(item2.Clone());
            group5.Add(item1.Clone());

            group1.CalcWidth();
            group1.CalcHeight();
            group1.SetX(0);
            group1.SetY(0);

            group1.ShowResult();
        }
Ejemplo n.º 4
0
        public void TheSizeOfAVerticalGroupThatContainsASingleEntryIsCorrectlyCalculated()
        {
            LayoutGroup group = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutEntry item  = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 50
            };

            group.Add(item);

            group.CalcWidth();
            group.CalcHeight();

            Assert.Equal(item.Rect.Width + group.Style.PaddingHorizontal + group.Style.BorderHorizontal, group.Rect.Width);
            Assert.Equal(item.Rect.Height + group.Style.PaddingVertical + group.Style.BorderVertical, group.Rect.Height);
        }
Ejemplo n.º 5
0
        public void ShowAVerticalGroupOf1Items()
        {
            LayoutGroup group = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutEntry item  = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 50
            };

            group.Add(item);

            group.CalcWidth();
            group.CalcHeight();
            group.SetX(0);
            group.SetY(0);

            group.ShowResult();
        }
Ejemplo n.º 6
0
        public void ShowAHorizontalGroupOf3Items()
        {
            LayoutGroup group = new LayoutGroup(false, Styles.DefaultGroupStyle);
            LayoutEntry item  = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 50
            };

            group.Add(item.Clone());
            group.Add(item.Clone());
            group.Add(item.Clone());

            group.CalcWidth();
            group.CalcHeight();
            group.SetX(0);
            group.SetY(0);

            group.ShowResult();
        }
Ejemplo n.º 7
0
            public void DefaultSizedEntryProperlyInitialized()
            {
                var entry = new LayoutEntry();

                entry.Init(123, (100, 200), null);

                Assert.Equal(100, entry.ContentWidth);
                Assert.Equal(1, entry.MinWidth);
                Assert.Equal(9999, entry.MaxWidth);
                Assert.False(entry.IsFixedWidth);
                Assert.False(entry.HorizontallyStretched);
                Assert.Equal(0, entry.HorizontalStretchFactor);

                Assert.Equal(200, entry.ContentHeight);
                Assert.Equal(1, entry.MinHeight);
                Assert.Equal(9999, entry.MaxHeight);
                Assert.False(entry.IsFixedHeight);
                Assert.False(entry.VerticallyStretched);
                Assert.Equal(0, entry.VerticalStretchFactor);
            }
Ejemplo n.º 8
0
            public void FlexSizedEntryProperlyInitialized()
            {
                var options = GUILayout.StretchWidth(1).StretchHeight(2);
                var entry   = new LayoutEntry();

                entry.Init(123, Size.Zero, options);

                Assert.Equal(0, entry.ContentWidth);
                Assert.Equal(1, entry.MinWidth);
                Assert.Equal(9999, entry.MaxWidth);
                Assert.False(entry.IsFixedWidth);
                Assert.True(entry.HorizontallyStretched);
                Assert.Equal(1, entry.HorizontalStretchFactor);

                Assert.Equal(0, entry.ContentHeight);
                Assert.Equal(1, entry.MinHeight);
                Assert.Equal(9999, entry.MaxHeight);
                Assert.False(entry.IsFixedHeight);
                Assert.True(entry.VerticallyStretched);
                Assert.Equal(2, entry.VerticalStretchFactor);
            }
Ejemplo n.º 9
0
 Rectangle GetScrolledPosition( LayoutEntry le )
 {
     var p = le.UnscrolledPosition;
     p.Y -= Scroll;
     return p;
 }
Ejemplo n.º 10
0
        public Rectangle RefreshLayout( Rectangle target )
        {
            BackgroundArea = Rectangle.Empty;
            Layout.Clear();

            if ( GetLayers == null ) return target;
            var layers_ = GetLayers();
            if ( layers_ == null ) return target;
            var layers = layers_.ToArray();

            var textw = layers.Max( layer => TextRenderer.MeasureText( layer.Name, Font ).Width );
            var right = target.Right-Margin;
            var left  = right-16-2-textw-2-16-2-16-2-16-2-16;

            BackgroundArea = new Rectangle
                ( left-Margin
                , target.Top
                , (right+Margin) - (left-Margin)
                , target.Height
                );

            int y = target.Top+Margin;
            foreach ( var layer in layers ) {
                var x = left;

                var entry = new LayoutEntry();

                entry.Layer = layer;
                entry.TypeIconPosition       = new Rectangle(x,y,   16,16); x += 16+2;
                entry.TextPosition           = new Rectangle(x,y,textw,16); x += textw+2;
                entry.VisibilityIconPosition = new Rectangle(x,y,   16,16); x += 16+2;
                entry.RenameIconPosition     = new Rectangle(x,y,   16,16); x += 16+2;
                entry.MoveLayerUpPosition    = new Rectangle(x,y,   16,16); x += 16+2;
                entry.MoveLayerDownPosition  = new Rectangle(x,y,   16,16); x += 16+2;
                x-=2;
                Debug.Assert( x==right );

                entry.LinePosition = new Rectangle(left-2,y-1,right-left+4,18);

                Layout.Add(entry);
                y += 16+2;
            }

            return new Rectangle
                ( target.Left
                , target.Top
                , left-target.Left
                , target.Height
                );
        }
Ejemplo n.º 11
0
 public GServerTextBox(string initialText, LayoutEntry le)
     : base(0, false, le[0], le[1], le[2], le[3], initialText, (IFont)Engine.GetUniFont(1), Hues.Load(le[4] + 1), Hues.Load(le[4] + 1), Hues.Load(le[4] + 1))
 {
     this.m_RelayID = le[5];
     this.MaxChars  = 239;
 }
Ejemplo n.º 12
0
 public LayoutEntryDebuggerView(LayoutEntry entry)
 {
     this.entry = entry;
 }