Possible ListCOMP rowAttribs bug

I’m not 100% sure, if this is expected behaviour.
After settings the bgColor of a cell for the first time, it is not possible to change it with rowAttribs afterwards.
I made a simple example.

Thanks for having a look.

(Using the newest experimental.)
ListRowBgColor.toe (5.07 KB)

The reason is that cell attributes take precedence over row attributes.

To disable the cell attribute and see the row attribute, set it back to value None

We will update the wiki with this tip.

Cheers,
Rob.

Thanks Rob, good to know.

Is there a way to change an attribute of a whole row then, besides doing a for loop?

Cheers, David

Ivan just gave me an answer to my question:
posting.php?mode=reply&f=12&t=11859

So nevermind and thank you,
David

PS: I wonder, if there would be a drawback of just overwriting the cellAttribs with rowAttribs and vice versa? Like this someone could use whatever attribs fits best and set the values…

No disadvantage in manually copying over attributes, except you lose the efficiency of just updating a few attribs, instead of each cell.

Well, then it would be nice, if we could overwrite the cellAttribs with rowAttribs without setting them to None first. Or is there an advantage to have two different attribs (cell and row) defining a cell?

Don’t quite follow.
Each visible cell can have up to 4 attributes (cell, row, column, table).
You can define a row background for example (row attribute), then have 1 particular cell a different color (cell attribute), while having every other cell a default color (table attribute).
Final attributes are based on priority of which are defined.
Cheers

So, there are 4 attributes defining the same thing, lets say bgColor, but with different priorities.
I was just thinking, maybe it would be more convenient to have just one attribute for bgColor, but 4 ways to set it.

rowAttribs.bgColor would set a whole row to a certain color, without having to loop through all the cells and set their cellAttribs.bgColor to None.

And with tableAttribs.bgColor I could set the whole table to a color without having to loop through all cell rowAttribs, colAttribs and cellAttribs…

Or is there an advantage the way it is, that I didn’t see?

Cheers.

If you set rowAttribs.bgColor, then you do not have to loop through the cell attributes.
In that case, you would just leave them all at default None.
rowAttributes define bgColor for the entire row, in one spot.

That way, any cell background color will be the first one set of cell, row, column, or table.

No looping is necessary, but you have to remember which attributes to turn off, to get lower priority attributes to take effect.

That’s the way its currently implemented.

Not sure if Im answering your question properly, but let me know if that makes sense.

Cheers,
Rob.

Maybe I can explain it better with a little example:

A user can click on each cell of a table and it will change it’s background to a random color.
If he clicks on a row or col header it will change the whole row or column to the same color.
Then there is a reset button, that changes the whole table back to the default color.

How would you implement that without having to loop through cells?

I understand now.
In your case, you’re looking for a quick way of erasing all the individual cell colors you set.
(or alternatively copying one set of attributes to all cells in a row).

Might be something like:

n.cellAttributes[3,4].copyToRow() #copies all attributes of 3,4 onto row 3.

Exactly. It would be nice to have methods like:

Set bgColor of all cells to (1,0,0)
Set bgColor of all cells in row 1 to (0,1,0)
Set bgColor of all cells in col 1 to (0,0,1)

I would like to use the listCOMP as a kind of spreadsheet interface, but having to loop through a possibly high number of cells make it feel unresponsive.

Two other problems I had with this approach:

  • The listCOMP seems to process all of the cells each frame and not only the ones visible in the viewport. (At least my frame rate drops after a certain number of cells.)
  • Scrolling up and down the list doesn’t happen row by row, but shifts a bit, so rows get cut at the top. (It’s just a cosmetical issue, but it feels weird.)

I made a small video showing both of this issues.
First I scroll down the list to demonstrate rows getting cut at the top.
Then I deactivate the viewer and you can see the fps go from 36 or so to 60.
ListCOMP.mov (868 KB)