Forums > MaxMSP

Jit Cellblock help


Lid
March 23, 2008 | 7:14 am

I’m looking to use Jit Cellblock as part of my program’s UI and was wondering if anyone’s come up with an efficient way to color a cell if it’s uncolored or uncolor a cell if it’s already colored…like a switch…

I was hoping this feature would already be part of the Inspector options but nope.

any ideas?

-Lid


March 23, 2008 | 6:44 pm

Quote: Lid wrote on Sun, 23 March 2008 00:14
—————————————————-
> I’m looking to use Jit Cellblock as part of my program’s UI and was wondering if anyone’s come up with an efficient way to color a cell if it’s uncolored or uncolor a cell if it’s already colored…like a switch…

That’s what mouse clicks already do, so you must mean with messages. Like this?

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 231 81 23 196617 1 0;
#P message 196 79 23 196617 0 1;
#P message 161 79 23 196617 0 0;
#P newex 161 116 56 196617 append inc;
#P user matrixctrl 161 144 66 66 MatrixDefaultCell.pct MatrixDefaultBkgnd.pct 66 66 16 16 4 4 16 16 1 1 48 2 5120 0;
#P connect 4 0 1 0;
#P connect 3 0 1 0;
#P connect 2 0 1 0;
#P connect 1 0 0 0;
#P window clipboard copycount 5;

This works with the one cell per row/column/matrix constraints (in the inspector) if needed.



Lid
March 23, 2008 | 9:11 pm

I’d rather use JitCellblock as opposed to the matrix controller since I’m planning on having row number and size as variables in the patch.

Yes I am planning on using mouse clicks (as well as messages potentially).

-Lid


March 23, 2008 | 11:09 pm

Quote: Lid wrote on Sun, 23 March 2008 14:11
—————————————————-
> I’d rather use JitCellblock as opposed to the matrix controller since I’m planning on having row number and size as variables in the patch.
>

I don’t think jit.cellblock is intended to be used as a switch like matrixctrl. If the reason you wanted to use jit.cellblock is because of the variable rows/columns, you should take a look at Max Tutorial 51: Javascript UI. It’s a jsui version of matrixctrl that supports variable rows and columns. Maybe that will do?

But if you really want to use jit.cellblock, you could watch the outlet of jit.cellblock to see what’s being clicked and keep track of the switch state yourself. Then send messages back into jit.cellblock to color the cells appropriately. Here’s a pretty dumb example just to give you an idea. In a real patch I’d probably use a coll or javascript to keep track of the switch state (instead of the matrixctrl).

For this kind of usage, I don’t like how jit.cellblock always highlights the selected cell. You can’t tell if you just turned something on or off…

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 330 303 46 196617 0 255 0;
#P message 175 303 70 196617 255 255 255;
#P newex 119 341 75 196617 pack 0 0 0 0 0;
#P newex 175 281 165 196617 if $i1==0 then bang else out2 bang;
#P newex 119 258 67 196617 unpack 0 0 0;
#P message 119 364 124 196617 cell $1 $2 brgb $3 $4 $5;
#P newex 119 155 56 196617 append inc;
#P user matrixctrl 119 183 66 67 MatrixDefaultCell.pct MatrixDefaultBkgnd.pct 66 67 16 16 4 4 16 16 1 1 48 2 5120 0;
#P user jit.cellblock 119 77 300 146 3 9 4 4 45 17 0 1 1 0 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#X cell 0 0 layout 0 1 0 0 0 0 255 255 255 -1 -1 -1;
#X cell 0 1 layout 0 1 0 0 63 0 255 255 255 -1 -1 -1;
#X cell 1 0 layout 0 1 0 0 0 0 255 255 255 -1 -1 -1;
#X cell 1 1 layout 0 1 0 0 63 0 255 255 255 -1 -1 -1;
#X cell 1 2 layout 0 1 0 0 63 0 255 255 255 -1 -1 -1;
#X cell 1 3 layout 0 1 0 0 63 0 255 255 255 -1 -1 -1;
#X cell 2 0 layout 0 1 0 0 0 0 255 255 255 -1 -1 -1;
#X cell 2 1 layout 0 1 0 0 0 0 255 255 255 -1 -1 -1;
#X cell 2 2 layout 0 1 0 0 0 0 255 255 255 -1 -1 -1;
#X cell 2 3 layout 0 1 219 50 0 0 255 255 255 -1 -1 -1;
#P fasten 3 0 0 0 124 389 100 389 100 66 124 66;
#P connect 4 1 6 1;
#P connect 6 0 3 0;
#P connect 4 0 6 0;
#P connect 8 0 6 2;
#P connect 7 0 6 2;
#P connect 5 0 7 0;
#P connect 5 1 8 0;
#P connect 4 2 5 0;
#P connect 1 0 4 0;
#P connect 2 0 1 0;
#P connect 0 0 2 0;
#P window clipboard copycount 9;


March 23, 2008 | 11:31 pm

Here is how i’ve done it before. Similar to Adam’s, but it uses another synched cellblock to keep track of the state, and the rgb5 message to set the selection color to match the brgb.

#P button 473 337 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 396 70 42 196617 r value;
#P newex 517 405 42 196617 s value;
#P newex 49 70 41 196617 r state;
#P newex 396 490 41 196617 s state;
#P user jit.cellblock 49 95 275 266 3 9 5 10 45 17 0 1 1 1 0 0 0 0 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 50 65 255 1 1 1 0 4 0 0 1;
#X cell 0 0 layout 0 1 0 0 0 0 50 65 255 -1 -1 -1;
#X cell 0 1 layout 0 1 33 219 0 0 50 65 255 -1 -1 -1;
#X cell 0 2 layout 0 1 32 171 0 0 50 65 255 -1 -1 -1;
#X cell 0 3 layout 0 1 0 61 0 0 50 65 255 -1 -1 -1;
#X cell 0 4 layout 0 1 0 211 0 0 50 65 255 -1 -1 -1;
#X cell 0 5 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 0 6 layout 0 1 32 14 0 0 50 65 255 -1 -1 -1;
#X cell 0 7 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 0 8 layout 0 1 0 0 0 0 50 65 255 -1 -1 -1;
#X cell 0 9 layout 0 1 6 82 0 0 50 65 255 -1 -1 -1;
#X cell 1 0 layout 0 1 0 0 0 0 50 65 255 -1 -1 -1;
#X cell 1 1 layout 0 1 32 51 0 0 50 65 255 -1 -1 -1;
#X cell 1 2 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 1 3 layout 0 1 32 14 0 0 50 65 255 -1 -1 -1;
#X cell 1 4 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 1 5 layout 0 1 0 0 0 0 50 65 255 -1 -1 -1;
#X cell 1 6 layout 0 1 6 82 0 0 50 65 255 -1 -1 -1;
#X cell 1 7 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 1 8 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 1 9 layout 0 1 255 55 34 0 50 65 255 -1 -1 -1;
#X cell 2 0 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 2 1 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 2 2 layout 0 1 0 211 0 0 50 65 255 -1 -1 -1;
#X cell 2 3 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 2 4 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 2 5 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 2 6 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 2 7 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 2 8 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 2 9 layout 0 1 0 0 0 0 50 65 255 -1 -1 -1;
#X cell 3 0 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 1 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 2 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 3 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 4 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 5 layout 0 1 0 0 0 0 50 65 255 -1 -1 -1;
#X cell 3 6 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 7 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 8 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 3 9 layout 0 1 6 82 0 0 50 65 255 -1 -1 -1;
#X cell 4 0 layout 0 1 0 169 0 0 50 65 255 -1 -1 -1;
#X cell 4 1 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 4 2 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 4 3 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 4 4 layout 0 1 6 157 0 0 50 65 255 -1 -1 -1;
#X cell 4 5 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 4 6 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 4 7 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 4 8 layout 0 1 50 65 255 0 50 65 255 -1 -1 -1;
#X cell 4 9 layout 0 1 6 158 0 0 50 65 255 -1 -1 -1;
#X set 0 0 off;
#X set 0 1 off;
#X set 0 2 off;
#X set 0 3 off;
#X set 0 4 off;
#X set 0 5 off;
#X set 0 6 off;
#X set 0 7 off;
#X set 0 8 off;
#X set 0 9 off;
#X set 1 0 off;
#X set 1 1 off;
#X set 1 2 off;
#X set 1 3 off;
#X set 1 4 off;
#X set 1 5 off;
#X set 1 6 off;
#X set 1 7 off;
#X set 1 8 off;
#X set 1 9 off;
#X set 2 0 off;
#X set 2 1 off;
#X set 2 2 off;
#X set 2 3 off;
#X set 2 4 off;
#X set 2 5 off;
#X set 2 6 off;
#X set 2 7 off;
#X set 2 8 off;
#X set 2 9 off;
#X set 3 0 off;
#X set 3 1 off;
#X set 3 2 off;
#X set 3 3 off;
#X set 3 4 off;
#X set 3 5 off;
#X set 3 6 off;
#X set 3 7 off;
#X set 3 8 off;
#X set 3 9 off;
#X set 4 0 off;
#X set 4 1 off;
#X set 4 2 off;
#X set 4 3 off;
#X set 4 4 off;
#X set 4 5 off;
#X set 4 6 off;
#X set 4 7 off;
#X set 4 8 off;
#X set 4 9 off;
#P newex 396 347 48 196617 pack 0 0;
#P newex 396 314 67 196617 unpack 0 0 0;
#P message 367 431 283 196617 rgb5 50 65 255 , cell $1 $2 brgb 50 65 255 , set current off;
#P user gswitch2 367 383 39 32 0 0;
#P message 396 459 280 196617 rgb5 255 55 34 , cell $1 $2 brgb 255 55 34 , set current on;
#P message 517 378 76 196617 set current $1;
#P newex 517 344 31 196617 == 0;
#P newex 473 313 54 196617 unpack s i;
#P user jit.cellblock 396 95 639 285 3 9 5 10 45 17 0 1 1 1 0 0 0 0 5 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#X set 0 0 0;
#X set 0 1 0;
#X set 0 2 0;
#X set 0 3 0;
#X set 0 4 0;
#X set 0 5 0;
#X set 0 6 0;
#X set 0 7 0;
#X set 0 8 0;
#X set 0 9 0;
#X set 1 0 0;
#X set 1 1 0;
#X set 1 2 0;
#X set 1 3 0;
#X set 1 4 0;
#X set 1 5 0;
#X set 1 6 0;
#X set 1 7 0;
#X set 1 8 0;
#X set 1 9 0;
#X set 2 0 0;
#X set 2 1 0;
#X set 2 2 0;
#X set 2 3 0;
#X set 2 4 0;
#X set 2 5 0;
#X set 2 6 0;
#X set 2 7 0;
#X set 2 8 0;
#X set 2 9 0;
#X set 3 0 0;
#X set 3 1 0;
#X set 3 2 0;
#X set 3 3 0;
#X set 3 4 0;
#X set 3 5 0;
#X set 3 6 0;
#X set 3 7 0;
#X set 3 8 0;
#X set 3 9 0;
#X set 4 0 0;
#X set 4 1 0;
#X set 4 2 0;
#X set 4 3 0;
#X set 4 4 0;
#X set 4 5 0;
#X set 4 6 0;
#X set 4 7 0;
#X set 4 8 0;
#X set 4 9 0;
#P fasten 14 0 2 0 478 363 505 363 505 339 522 339;
#P connect 1 0 14 0;
#P connect 0 1 1 0;
#P connect 1 1 2 0;
#P connect 7 0 8 0;
#P connect 0 0 7 0;
#P connect 8 0 5 1;
#P fasten 9 2 0 1 198 301 654 301 654 81 634 81;
#P connect 5 0 6 0;
#P connect 5 1 4 0;
#P connect 2 0 3 0;
#P fasten 2 0 5 0 522 370 372 370;
#P connect 11 0 9 0;
#P fasten 6 0 10 0 372 483 401 483;
#P connect 4 0 10 0;
#P connect 3 0 12 0;
#P connect 13 0 0 0;
#P fasten 7 1 8 1 429 340 439 340;
#P window clipboard copycount 15;


March 24, 2008 | 12:15 am

not that it matters so much, but in the previously posted patch you can take out the bang button from the left outlet of [unpack s i] to the [== 0] below it, its not needed.

not the most elegant patch, lots of ways to do this, but its a decent start.

-ben b.



Lid
March 24, 2008 | 6:21 pm

hey thanks Adam and Ben.

That’s great info…it will take a bit of time to digest it all..

especially if I look into the Javascript stuff… for now I’ll try and just use the JitCellblock object.

thanks again
-Lid


June 12, 2008 | 4:14 pm

Does any one know if there is a way to do multiple selection
of items on different rows of a jit.cellblock?


June 12, 2008 | 4:34 pm

Or is there a way I can select multiple rows?



Lid
June 13, 2008 | 6:20 pm

Try the patches that were sent under this topic…see if that works.


Viewing 10 posts - 1 through 10 (of 10 total)