Example #1
0
        public Table(int rowAmount = 0, int colAmount = 0)
        {
            tbPos.x  = 0;
            tbPos.y  = 0;
            tbHeight = 0;
            tbWidth  = 0;

            this.rowAmount = rowAmount;
            this.colAmount = colAmount;

            matchType = MatchType.MatchParentSize;

            TableLine tableLine;

            for (int i = 0; i < rowAmount; i++)
            {
                tableLine = new TableLine(LineDir.HORIZONTAL);
                tableLine.lineComputeMode  = LineComputeMode.AUTO;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                rowLineList.Add(tableLine);
            }

            //
            for (int i = 0; i < colAmount; i++)
            {
                tableLine = new TableLine(LineDir.VERTICAL);
                tableLine.lineComputeMode  = LineComputeMode.AUTO;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                colLineList.Add(tableLine);
            }
        }
Example #2
0
        public void SetLineArea(int lineIdx, TableLine setLine)
        {
            List <TableLine> lineList = null;
            float            tbLength;

            if (setLine.lineDir == LineDir.HORIZONTAL)
            {
                lineList = rowLineList;
                tbLength = tbHeight;
            }
            else
            {
                lineList = colLineList;
                tbLength = tbWidth;
            }

            TableLine adjustLine = lineList[lineIdx];

            adjustLine.lineComputeMode          = setLine.lineComputeMode;
            adjustLine.computeParam             = setLine.computeParam;
            adjustLine.enableAutoAdjustRichSize = setLine.enableAutoAdjustRichSize;
            adjustLine.lineDir          = setLine.lineDir;
            adjustLine.minComputedValue = setLine.minComputedValue;
            adjustLine.maxComputedValue = setLine.maxComputedValue;
        }
Example #3
0
        public void SetAutoTableLine(int idx, LineDir lineDir)
        {
            TableLine tableLine = new TableLine(lineDir);

            tableLine.lineComputeMode  = LineComputeMode.AUTO;
            tableLine.maxComputedValue = -1;
            tableLine.minComputedValue = -1;
            SetTableLine(idx, tableLine);
        }
Example #4
0
        public void SetTableLine(int idx, TableLine tableLine)
        {
            List <TableLine> lineList;
            int amount;

            if (tableLine.lineDir == LineDir.HORIZONTAL)
            {
                lineList = rowLineList;
                amount   = rowAmount;
            }
            else
            {
                lineList = colLineList;
                amount   = colAmount;
            }

            if (idx < lineList.Count)
            {
                TableLine tl = new TableLine(tableLine.lineDir);
                tl.computeParam     = tableLine.computeParam;
                tl.computedDistance = tableLine.computedDistance;
                tl.lineComputeMode  = tableLine.lineComputeMode;
                tl.minComputedValue = tableLine.minComputedValue;
                tl.maxComputedValue = tableLine.maxComputedValue;
                lineList[idx]       = tl;
            }
            else
            {
                int n = idx - lineList.Count;
                for (int i = 0; i < n; i++)
                {
                    TableLine tl = new TableLine(tableLine.lineDir);
                    tl.computeParam     = tableLine.computeParam;
                    tl.computedDistance = tableLine.computedDistance;
                    tl.lineComputeMode  = tableLine.lineComputeMode;
                    tl.minComputedValue = tableLine.minComputedValue;
                    tl.maxComputedValue = tableLine.maxComputedValue;
                    lineList.Add(tl);
                    amount++;
                }

                if (tableLine.lineDir == LineDir.HORIZONTAL)
                {
                    rowAmount = amount;
                }
                else
                {
                    colAmount = amount;
                }
            }
        }
Example #5
0
 void ModifyTableSize(LineDir lineDir, TableLine line, ref float usedLength, ref float tbLength)
 {
     if (matchType == MatchType.MatchParentSize ||
         (matchType == MatchType.MatchParentHeight && lineDir == LineDir.HORIZONTAL) ||
         (matchType == MatchType.MatchParentWidth && lineDir == LineDir.VERTICAL))
     {
         return;
     }
     else if (usedLength > tbLength)
     {
         usedLength           -= line.computeParam;
         line.computeParam     = tbLength - usedLength;
         usedLength           += line.computeParam;
         line.computedDistance = line.computeParam;
     }
 }
Example #6
0
        void AddNewCol(
            bool enableAutoAdjustRichSize   = false,
            LineComputeMode lineComputeMode = LineComputeMode.AUTO,
            float computeParam     = 0,
            float computedDistance = 0)
        {
            colAmount += 1;

            TableLine tableLine = new TableLine(LineDir.VERTICAL);

            tableLine.enableAutoAdjustRichSize = enableAutoAdjustRichSize;
            tableLine.lineComputeMode          = lineComputeMode;
            tableLine.computeParam             = computeParam;
            tableLine.computedDistance         = computedDistance;
            tableLine.maxComputedValue         = -1;
            tableLine.minComputedValue         = -1;
            colLineList.Add(tableLine);
        }
Example #7
0
        void AddNewRow(
            bool enableAutoAdjustRichSize   = false,
            LineComputeMode lineComputeMode = LineComputeMode.AUTO,
            float computeParam     = 0,
            float computedDistance = 0)
        {
            rowAmount += 1;

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.enableAutoAdjustRichSize = enableAutoAdjustRichSize;
            tableLine.lineComputeMode          = lineComputeMode;
            tableLine.computeParam             = computeParam;
            tableLine.computedDistance         = computedDistance;
            tableLine.maxComputedValue         = -1;
            tableLine.minComputedValue         = -1;
            rowLineList.Add(tableLine);
        }
Example #8
0
        public Table(float x, float y, float tbWidth, float tbHeight, int rowAmount = 0, int colAmount = 0)
        {
            this.tbPos.x  = x;
            this.tbPos.y  = y;
            this.tbHeight = tbHeight;
            this.tbWidth  = tbWidth;

            this.rowAmount = rowAmount;
            this.colAmount = colAmount;

            //
            TableLine tableLine;
            float     rowComputedDist = tbHeight / rowAmount;
            float     rowPercent      = 1f / rowAmount;

            for (int i = 0; i < rowAmount; i++)
            {
                tableLine = new TableLine(LineDir.HORIZONTAL);
                tableLine.lineComputeMode  = LineComputeMode.PERCENTAGE;
                tableLine.computeParam     = rowPercent;
                tableLine.computedDistance = rowComputedDist;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                rowLineList.Add(tableLine);
            }

            //
            float colComputedDist = tbWidth / colAmount;
            float colPercent      = 1f / colAmount;

            for (int i = 0; i < colAmount; i++)
            {
                tableLine = new TableLine(LineDir.VERTICAL);
                tableLine.lineComputeMode  = LineComputeMode.PERCENTAGE;
                tableLine.computeParam     = colPercent;
                tableLine.computedDistance = colComputedDist;
                tableLine.maxComputedValue = -1;
                tableLine.minComputedValue = -1;
                colLineList.Add(tableLine);
            }
        }