Esempio n. 1
0
 // Resizes the sprite to accomidate the gui component
 public void resize(Point2i pt, Size2i size)
 {
     vertices[0]=	new Point3f(pt.x, pt.y, 0f);
     vertices[1]=	new Point3f(pt.x, pt.y+size.height, 0f);
     vertices[2]=	new Point3f(pt.x+size.width, pt.y+size.height, 0f);
     vertices[3]=	new Point3f(pt.x+size.width, pt.y, 0f);
     bvolume=	new BVBox(pt.toPoint3f(), (pt+size).toPoint3f());
 }
Esempio n. 2
0
        protected override Size2i CalcChildrenMinimumSize(Group group)
        {
            int n = group.Children.Count;

            if (n <= 0)
            {
                return(Size2i.Zero);
            }
            int  w      = 0;
            int  h      = 0;
            bool addgap = false; //we dont add gap for the last child, which is the first we compute size for


            foreach (Widget child in group.Children)
            {
                Size2i sz = child.LayoutResult.MinSize;

                if ((child.PackSide & PackSide.Top) != 0 || (child.PackSide & PackSide.Bottom) != 0)
                {
                    w  = Math.Max(w, sz.Width);
                    h += sz.Height;
                    if (addgap)
                    {
                        h += group.GapY;
                    }
                }
                else  //left or right packing, or assume top on none set
                {
                    w += sz.Width;
                    h  = Math.Max(h, sz.Height);
                    if (addgap)
                    {
                        w += group.GapX;
                    }
                }

                addgap = true;
            }

            return(new Size2i(w, h));
        }
Esempio n. 3
0
        protected override Size2i CalcChildrenMinimumSize(Group group)
        {
            Size2i   res      = Size2i.Zero;
            Splitter splitter = group as Splitter;
            int      sw       = splitter.SplitterWidth;

            if (splitter.Vertical)
            { //splitbar is vertical, sum widths
                res = new Size2i(
                    splitter.Panel1.LayoutResult.MinSize.Width + splitter.Panel2.LayoutResult.MinSize.Width + sw,
                    Math.Max(splitter.Panel1.LayoutResult.MinSize.Height, splitter.Panel2.LayoutResult.MinSize.Height)
                    );
            }
            else
            { //splitbar is horizontal, sum heights
                res = new Size2i(
                    Math.Max(splitter.Panel1.LayoutResult.MinSize.Width, splitter.Panel2.LayoutResult.MinSize.Width),
                    splitter.Panel1.LayoutResult.MinSize.Height + splitter.Panel2.LayoutResult.MinSize.Height + sw
                    );
            }

            return(res);
        }
Esempio n. 4
0
 virtual public void RefreshChildren()
 {
     SizerObject.RecursiveCalcLayoutInfo(this);
     SizerObject.RecursiveCalcFinalPos(this, Size2i.Max(Bounds.Size, LayoutResult.MinSize));
     // RecursiveLayoutChildren();
 }
Esempio n. 5
0
 // Subtracts the two sizes together
 public Size2f subtract(Size2i size)
 {
     return new Size2f(width-(float)size.width, height-(float)size.height);
 }
Esempio n. 6
0
 /// <summary>
 /// Does the physical layout of all children. Call RecursiveCalcLayoutInfo first!
 /// </summary>
 /// <param name="group">The group to layout.</param>
 /// <param name="area">The area to fit the child controls to.</param>
 public abstract void CalcChildrenFinalPos(Group group, Size2i size);
Esempio n. 7
0
 // Subtracts the two sizes together
 public Size3f subtract(Size2i size)
 {
     return new Size3f(width-(float)size.width, height-(float)size.height, depth);
 }
Esempio n. 8
0
        // Gets the minimum value of the size
        public static Size2i min(Size2i value, Size2i min)
        {
            // Variables
            Size2i	temp=	value;

            if(value.width< min.width)
                temp.width=	min.width;
            if(value.height< min.height)
                temp.height=	min.height;

            return temp;
        }
Esempio n. 9
0
        // Gets the most minimum size of the two given sizes
        public static Size2i getMostMin(Size2i val1, Size2i val2)
        {
            // Variables
            Size2i	size=	Size2i.NO_SIZE;

            if(val1.width< val2.width)
                size.width=	val1.width;
            else
                size.width=	val2.width;
            if(val1.height< val2.height)
                size.height=	val1.height;
            else
                size.height=	val2.height;

            return size;
        }
Esempio n. 10
0
 // Subtracts the point with a size to get another point
 public Point2i subtract(Size2i size)
 {
     return new Point2i(x-size.width, y-size.height);
 }
Esempio n. 11
0
 // Adds the point with a size to get another point
 public Point2i add(Size2i size)
 {
     return new Point2i(x+size.width, y+size.height);
 }
Esempio n. 12
0
 // Subtracts the point with a size to get another point
 public Point3f subtract(Size2i size)
 {
     return new Point3f(x-(float)size.width, y-(float)size.height, z);
 }
Esempio n. 13
0
 // Adds the point with a size to get another point
 public Point3f add(Size2i size)
 {
     return new Point3f(x+(float)size.width, y+(float)size.height, z);
 }
Esempio n. 14
0
        private void UpdateWindowPlacement()
        {
            Window window = Form.Tag as Window;

            if (window == null)
            {
                return;
            }

            Rect2i         oldbounds = null;
            Point2i        pos       = null;
            Size2i         size      = null;
            WindowSize     initsize  = window.InitialSize;
            WindowPosition initpos   = window.InitialPosition;

            if (initsize == WindowSize.Minimal)
            {
                if (oldbounds == null)
                {
                    window.Refresh();
                    oldbounds = window.Bounds;
                }
                size = oldbounds.Size; // window.LayoutInfo.MinSize;
            }
            else if (initsize == WindowSize.Current)
            {
                if (oldbounds == null)
                {
                    oldbounds = window.Bounds;
                }
                size = oldbounds.Size;
            }
            else
            {
                throw new Exception("Unimplemented initial size");
            }



            if (pos == null && initpos == WindowPosition.Current)
            {
                //if (oldbounds == null) oldbounds = Bounds;
                pos = new Point2i(oldbounds.X, oldbounds.Y);
            }
            if (pos == null && initpos == WindowPosition.CenterParent)
            {
                Form frm = Form.ActiveForm; //form to center to

                //Dont center invisible windows, this is actually a hack
                //around centering to visual studios so called 'parking window' if this
                //is the app:s first window shown
                if (frm != null && frm.Visible == false)
                {
                    frm = null;
                }

                //now we got a form to center to?
                if (frm != null)
                {
                    var fb = frm.Bounds;
                    int x  = fb.Left + fb.Width / 2 - size.Width / 2;
                    int y  = fb.Top + fb.Height / 2 - size.Height / 2;
                    pos = new Point2i(x, y);
                }
                else //no active window, fallback to screen center
                {
                    initpos = WindowPosition.CenterScreen;
                }
            }
            if (pos == null && initpos == WindowPosition.CenterScreen)
            {
                var rs = Guppy.ScreenResolution;
                int x  = rs.Width / 2 - size.Width / 2;
                int y  = rs.Height / 2 - size.Height / 2;

                pos = new Point2i(x, y);
            }
            if (pos == null) //unresolvable
            {
                throw new Exception("Unimplemented initial position");
            }

            //next time we show, use the current size and position
            window.InitialPosition = WindowPosition.Current;
            window.InitialSize     = WindowSize.Current;

            Bounds = new Rect2i(pos, size);
        } //End UpdateWindowPlacement
Esempio n. 15
0
 // Adds the point with a size to get another point
 public Point3i add(Size2i size)
 {
     return new Point3i(x+size.width, y+size.height, z);
 }
Esempio n. 16
0
        public override void CalcChildrenFinalPos(Group group, Size2i size)
        {
            size = Size2i.Max(size, group.LayoutResult.MinSize);

            //Compute the space we have to distribute among expanding controls:
            int expandspacex = Math.Max(0, size.Width - group.LayoutResult.MinSize.Width);
            int expandspacey = Math.Max(0, size.Height - group.LayoutResult.MinSize.Height);

            //Find the internal rectangle to layout inside
            Rect2i area = GetChildLayoutArea(group, size);


            //compute number of controls that expands in some direction
            int numxexpanding = 0;
            int numyexpanding = 0;

            foreach (Widget child in group.Children)
            {
                if (child.LayoutResult.ExpandX)
                {
                    numxexpanding++;
                }
                if (child.LayoutResult.ExpandY)
                {
                    numyexpanding++;
                }
            }


            int ci = group.Children.Count;

            foreach (Widget child in group.Children)
            {
                PackSide chpack = child.PackSide;

                Rect2i alloc;

                bool last = (ci == group.Children.Count - 1);                  //last control laid out?
                int  gapx = (ci == group.Children.Count - 1) ? 0:group.GapX;   //no gap added for last control
                int  gapy = (ci == group.Children.Count - 1) ? 0 : group.GapY; //no gap added for last control

                int extrax = 0, extray = 0;
                if (child.LayoutResult.ExpandX)
                {
                    if (last) //last control can expand on all remaining space
                    {
                        extrax = Math.Max(0, area.Width - child.LayoutResult.MinSize.Width);
                    }
                    else
                    {
                        extrax = DistributSpace(ci, numxexpanding, expandspacex);
                    }
                }

                if (child.LayoutResult.ExpandY)
                {
                    if (last) //last control can expand on all remaining space
                    {
                        extray = Math.Max(0, area.Height - child.LayoutResult.MinSize.Height);
                    }
                    else
                    {
                        extray = DistributSpace(ci, numyexpanding, expandspacey);
                    }
                }

                if ((chpack & PackSide.Bottom) != 0)
                {
                    alloc = new Rect2i(area.Left, area.Bottom - child.LayoutResult.MinSize.Height - extray, area.Width, child.LayoutResult.MinSize.Height + extray);
                    area  = area.Shrink(new Margin(0, 0, 0, alloc.Height + gapy));
                }
                else if ((chpack & PackSide.Left) != 0)
                {
                    alloc = new Rect2i(area.Left, area.Top, child.LayoutResult.MinSize.Width + extrax, area.Height);
                    area  = area.Shrink(new Margin(alloc.Width + gapx, 0, 0, 0));
                }
                else if ((chpack & PackSide.Right) != 0)
                {
                    alloc = new Rect2i(area.Right - child.LayoutResult.MinSize.Width - extrax, area.Top, child.LayoutResult.MinSize.Width + extrax, area.Height);
                    area  = area.Shrink(new Margin(0, 0, alloc.Width + gapx, 0));
                }
                else //PackTop or packing not set which defaults to top
                {
                    alloc = new Rect2i(area.Left, area.Top, area.Width, child.LayoutResult.MinSize.Height + extray);
                    area  = area.Shrink(new Margin(0, alloc.Height + gapy, 0, 0));
                }


                // child.LayoutResult.FinalPos = StickRectangle(alloc, child.LayoutResult.MinSize, FinalStick(child));
            }
        }
Esempio n. 17
0
        // Clamps the size to the given min and max bounds
        public static Size2i clamp(Size2i value, Size2i min, Size2i max)
        {
            // Variables
            Size2i	temp=	value;

            if(value.width< min.width)
                temp.width=	min.width;
            else if(value.width> max.width)
                temp.width=	max.width;
            if(value.height< min.height)
                temp.height=	min.height;
            else if(value.height> max.height)
                temp.height=	max.height;

            return temp;
        }
Esempio n. 18
0
        public override void CalcChildrenFinalPos(Group group, Size2i size)
        {
            int    numrows, numcols;
            Rect2i area = GetChildLayoutArea(group, size);

            GetNumRowsCols(group, out numrows, out numcols);

            int[]  minheights      = new int[numrows];
            int[]  minwidths       = new int[numcols];
            bool[] expandx         = new bool[numcols];
            bool[] expandy         = new bool[numrows];
            int[]  row_allocations = new int[numrows]; //final height of table rows
            int[]  col_allocations = new int[numcols]; //final width of table columns
            //compute the space usable for expanding vertically and the minimum space each
            //row and column needs. this is filled in minwidths,minheights,expandx,expandy
            #region COMPUTE_EXPANSION_CONSTRAINTS
            int rowexpandspace     = area.Height;                      //vertical space available for expanding after gap and minheights subtracted
            int colexpandspace     = area.Width;                       //horizontal space available for expanding after gap and minwidths subtracted
            int num_expanding_cols = 0;                                //number of vertically expanding rows
            int num_expanding_rows = 0;                                //number of horizontally expanding columns
            rowexpandspace -= Math.Max((numrows - 1) * group.GapY, 0); //remove gap size
            colexpandspace -= Math.Max((numcols - 1) * group.GapX, 0); //remove gap size
            for (int row = 0; row < numrows; row++)
            {
                expandy[row] = RowIsExpanding(group, row, numrows, numcols, out minheights[row]);
                if (expandy[row])
                {
                    num_expanding_rows++;
                }
                rowexpandspace -= minheights[row];
            }

            for (int col = 0; col < numcols; col++)
            {
                expandx[col] = ColumnIsExpanding(group, col, numrows, numcols, out minwidths[col]);
                if (expandx[col])
                {
                    num_expanding_cols++;
                }
                colexpandspace -= minwidths[col];
            }
            #endregion


            //Now compute the actual width and height of each cell of the table
            //into the row_allocations[] and col_allocations[] arrays, distributing possible expansion
            int row_expand_count = 0; //needed for distribution of space
            int col_expand_count = 0; //needed for distribution of space
            for (int row = 0; row < numrows; row++)
            {
                if (expandy[row])
                {
                    row_allocations[row] = minheights[row] + DistributSpace(row, num_expanding_rows, rowexpandspace);
                    row_expand_count++;
                }
                else
                {
                    row_allocations[row] = minheights[row];
                }
            }
            for (int col = 0; col < numcols; col++)
            {
                if (expandx[col])
                {
                    col_allocations[col] = minwidths[col] + DistributSpace(col, num_expanding_cols, colexpandspace);
                    col_expand_count++;
                }
                else
                {
                    col_allocations[col] = minwidths[col];
                }
            }



            //now, we have an allocation for each row and column, so now we can compute the final allocation
            //for each child
            int left = area.Left;
            row_expand_count = 0;
            col_expand_count = 0;
            for (int col = 0; col < numcols; col++)
            {
                int top = area.Top;
                for (int row = 0; row < numrows; row++)
                {
                    Widget w = GetChild(group, col, row, numrows, numcols);
                    if (w == null)
                    {
                        continue;
                    }

                    //compute the childs size and position inside the allocation rectangle in the table:
                    Rect2i tablealloc = new Rect2i(left, top, col_allocations[col], row_allocations[row]);



                    //w.LayoutResult.FinalPos = StickRectangle(tablealloc, w.LayoutResult.MinSize, FinalStick(w));
                    w.LayoutResult.FinalPos = AlignRectangle(tablealloc, w.LayoutResult.MinSize, FinalAlign(w), w.LayoutResult.ExpandX, w.LayoutResult.ExpandY);

                    top += row_allocations[row] + group.GapY;
                }
                left += col_allocations[col] + group.GapX;
            }
        }
Esempio n. 19
0
        // Gets the maximum value of the size
        public static Size2i max(Size2i value, Size2i max)
        {
            // Variables
            Size2i	temp=	value;

            if(value.width> max.width)
                temp.width=	max.width;
            if(value.height> max.height)
                temp.height=	max.height;

            return temp;
        }
Esempio n. 20
0
 // Cuts off part the rendering screen
 public void startScissorCut(Point2i location, Size2i size)
 {
     Gl.glEnable(Gl.GL_SCISSOR_TEST);
     Gl.glScissor(location.x, location.y+size.height, size.width, size.height);
 }
Esempio n. 21
0
 // Adds the two sizes together
 public Size3f add(Size2i size)
 {
     return new Size3f(width+(float)size.width, height+(float)size.height, depth);
 }
Esempio n. 22
0
 // Adds the two sizes together
 public Size2f add(Size2i size)
 {
     return new Size2f(width+(float)size.width, height+(float)size.height);
 }
Esempio n. 23
0
 public Rectangle(Point2i pmPos, Size2i pmSize)
     : this((Point2f)pmPos, (Size2f)pmSize)
 {
 }
Esempio n. 24
0
 // Finds if the two sizes are equal to each other
 public bool equals(Size2i size)
 {
     return ((int)width== size.width && (int)height== size.height);
 }