Best way to display items tiled

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
SammaySarkar
Posts: 7
Joined: Thu Jan 23, 2014 11:49 am

Best way to display items tiled

Post by SammaySarkar » Mon Feb 03, 2014 2:07 pm

Hi, I want to make a program which should display an arbitrary number of objects tiled. What's the best way to go about doing this?
It's like a file manager in tiled view. I'm mostly confused about the arbitrary numbers part.

I've just started out programming with LiveCode, and also programming in general, which explains my "noobism".

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Best way to display items tiled

Post by dunbarx » Mon Feb 03, 2014 4:33 pm

When you say "tiled", do you mean these objects are on one "layer" and have their locations locked to a grid of some sort?

If so, check out the "rect", "grid", "gridSize", and all the "topLeft/top/bottom/bottomRight/etc." properties. These last will give you all their related properties in the "See also" line.

In the inspector, you can arrange multiple selected objects in the "Align Objects" pane.

Craig Newman

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Best way to display items tiled

Post by dave_probertGA6e24 » Mon Feb 03, 2014 7:23 pm

I think you want to look at creating a group that will represent your 'blank' tile (eg. with an icon, a text field and any other aspects), then having a function to take your arbitrary list of 'things' (objects) and loop through them - creating a copy of the blank 'tile' for each one and filling in the necessary info.

The hard part is to set the position correctly.

If you want the area that the tiles are in to be scrolling then you would need a group that you copy the blanks into and set the scrolling properties of that group to auto (or whatever you prefer). You would also need to set the width and height of the group and most importantly set the 'lockloc' of it (else adding the items will make the group grow and is likely not what you want!)

Setting the positions of the new 'tiles' once they are created should be as simple as setting the 'left' of the new one to the 'right' of the previous one (plus a margin), unless that would make it go over the 'edge' of the enclosing group - if that happens then set it's 'top' to the bottom of the previous row (plus a margin).

If the enclosing group is to be resizable then you should look at a function that will do the positioning dynamically for all items within the group.

It would be really nice if there was a version of the data grid that had a tiled view that could be accessed as an alternative to the current 'list' styles.

If the target platform is a tablet then you should also think of adding a touchable scroll effect - search the livecode examples and tutorials on how to do that. Maybe someone has one already?

I hope some of the above makes sense. It's something I've also had to struggle with in the early days.

Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

SammaySarkar
Posts: 7
Joined: Thu Jan 23, 2014 11:49 am

Re: Best way to display items tiled

Post by SammaySarkar » Tue Feb 04, 2014 5:19 am

Great suggestions! I think copying groups is what I should do.
@dunbarx: is there any way to align objects from within the code?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Best way to display items tiled

Post by dunbarx » Tue Feb 04, 2014 7:11 am

Sure, since you can set the loc or other physical attributes of controls:

set the topLeft of yourControlA to the topRight of yourControlB

or

set the loc of yourControlA to (item 1 of the loc of yourControlB + the width of yourControlB / 2) & "," & item 2 of the loc of yourControlB

That sort of thing.

Craig

Post Reply