Author Topic: CellSetBorderVisible doesnt seem to work  (Read 133 times)

manofspirit

  • Newbie
  • *
  • Posts: 38
    • View Profile
CellSetBorderVisible doesnt seem to work
« on: June 09, 2019, 02:34:02 PM »
Hi there,

I want to hide some cell borders and tried CellSetBorderVisible(i, false) but it doesnt seem to hide the border.

Please advise

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #1 on: June 10, 2019, 03:32:31 AM »
Try latest beta (9.3 b1).
CellSetBorderVisible was not issuing a grid refresh so you needed to call Redraw() manually after setting the visibile cell borders.

Note that since cell edges are shared between adjacent cells, calling CellSetBorderVisible on just one cell won't hide those cell borders if the adjacent cells are visible.
 

manofspirit

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #2 on: June 10, 2019, 05:23:49 AM »
I tried 9.3.b3 but same issue.

Please see the attached image, this is what i want to achieve, all the red cells will become invisible including cell color and border.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #3 on: June 10, 2019, 07:41:23 AM »
Import beta 4 and check demo scene 3.

manofspirit

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #4 on: June 10, 2019, 09:25:15 AM »
Hi

Demo works, but If you call CellSetVisible along with border then demo doesnt work.

These are the changes i did:

Code
for (int k = 0; k < tgs.cells.Count; k++)
{
tgs.CellSetVisible(k, false);
tgs.CellSetBorderVisible (k, false);
}

and then

Code
void toggleCellVisible (int cellIndex) {

tgs.CellSetBorderVisible (cellIndex, !tgs.CellHasBorderVisible (cellIndex));
tgs.CellSetVisible(cellIndex, !tgs.CellHasBorderVisible (cellIndex));

}

Thanks

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #5 on: June 10, 2019, 09:32:09 AM »
CellSetVisible hides/shows BOTH surface and border while SetBorderVisible only affects the border.
Check your code, maybe you should store the result of CellHasBorder call before using it in both calls.

manofspirit

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #6 on: June 10, 2019, 10:04:26 AM »
CellSetVisible hides/shows BOTH surface and border while SetBorderVisible only affects the border.
Check your code, maybe you should store the result of CellHasBorder call before using it in both calls.

Finally found the bug why my own grid was not hiding the borders,
so if i set dimensions and set cell size then my cells dont get hidden.
please provide a fix.

WORKS
Code
for (int i = 0; i < TotalColors; i++)
        {

            currentColor = Colors[i];


            if (i < 5)
            {
                currentColor = Colors[i] = Color.clear;
            }


            if (currentColor == Color.clear)
            {

                GridSystem.CellSetVisible(i, false);


            }
            else
            {

                GridSystem.CellSetVisible(i, true);

            }



        }
       
        GridSystem.Redraw();


Doesnt Work
Code
GridSystem.SetDimensions(SourceImageHeight, SourceImageWidth);
        GridSystem.cellSize = CellSize;


       
        for (int i = 0; i < TotalColors; i++)
        {

            currentColor = Colors[i];


            if (i < 5)
            {
                currentColor = Colors[i] = Color.clear;
            }


            if (currentColor == Color.clear)
            {

                GridSystem.CellSetVisible(i, false);


            }
            else
            {

                GridSystem.CellSetVisible(i, true);

            }



        }
       
        GridSystem.Redraw();

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #7 on: June 10, 2019, 10:35:33 AM »
Add a Redraw() call after setting the cellSize property.
Reason is that those methods force a full grid reconstruction which resets the grid settings. That grid reconstructions occurs at the end of frame, not immedaitely, unless you call Redraw(). This is by design, so you can call many methods that affect grid shape/dimensions/etc. and only one full grid reconstruction occurs (otherwise it could be slow on devices).
« Last Edit: June 10, 2019, 10:52:45 AM by Kronnect »

manofspirit

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: CellSetBorderVisible doesnt seem to work
« Reply #8 on: June 10, 2019, 11:13:36 AM »
Add a Redraw() call after setting the cellSize property.
Reason is that those methods force a full grid reconstruction which resets the grid settings. That grid reconstructions occurs at the end of frame, not immedaitely, unless you call Redraw(). This is by design, so you can call many methods that affect grid shape/dimensions/etc. and only one full grid reconstruction occurs (otherwise it could be slow on devices).

phew, it worked now.
Thanks