hilitePattern not resizing

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sincipient820
Posts: 25
Joined: Mon Feb 25, 2013 4:00 am

hilitePattern not resizing

Post by sincipient820 » Tue Apr 09, 2013 11:17 pm

i've set the hilitePattern of a scrolling list field to an image ID.. however, the image is being tiled rather than filling the selectedText line.... I currently use a functional resizeStack handler but it doesn't seem to address the image ID of the hilitePattern... suggestions?.. thanks

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: hilitePattern not resizing

Post by Mark » Wed Apr 10, 2013 3:02 am

Hi,

From the dictionary: "To be used as a pattern on Mac OS systems, an image must be 128x128 pixels or less, and both its height and width must be a power of 2. To be used on Windows and Unix systems, height and width must be divisible by 8. To be used as a fully cross-platform pattern, both an image's dimensions should be one of 8, 16, 32, 64, or 128.". You might want to try to reshape the picture to make its width and height divisible by 8. Also, I'm not sure you can use a hilitePattern to fill an entire line of a field, because the lineHeight of a field is probably often not divisible by 8 and if the picture is required to be a rectangle, then it probably won't work as the background for one line anyway.

You could use the formattedRect of the selectedChunk to get the rect (or at least the top and bottom) of the currently selected text. You could use with left and right of the field containing that text to calculate the exact rect of the selected text. If you make the field transparent, then you can put an image behind it and set its rect to the value calculated from the formattedRect (and the right and the left). This way, you have something similar to a hilitedPattern.

Sorry, I don´t understand the second part of your question.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: hilitePattern not resizing

Post by jacque » Wed Apr 10, 2013 5:41 pm

If I remember right, the size restrictions on patterns was removed a while ago, but it looks like the dictionary was not updated.

sincipient820, does your resizestack handler resize the pattern image? Is the image's lockloc set to true? That is what used to work, but I did notice in the last release that the engine was ignoring the image size when creating the hilite pattern. I'm not sure if that's been fixed in the latest release.

The workaround I had to use was to create a temporary snapshot of the resized image and use that for the hilitepattern.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: hilitePattern not resizing

Post by Mark » Wed Apr 10, 2013 6:04 pm

Hi,

I also vaguely remember such a change, but when checking the dictionary, the limitations were still there.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

sincipient820
Posts: 25
Joined: Mon Feb 25, 2013 4:00 am

Re: hilitePattern not resizing

Post by sincipient820 » Wed Apr 10, 2013 8:30 pm

Jacque,
the resizeStack handler does appear to resize the image on the image card however not on the card where the hilitePattern appears... the lockloc does not appear to be on either... I'm going to try Mark's suggest first and i'll report my results.. thanks

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: hilitePattern not resizing

Post by Mark » Wed Apr 10, 2013 9:22 pm

Hi,

Why do you need a resizeable image? Can't you just use a solid colour?

Perhaps you need to set the hilitePattern to empty and then to the id of the image again, after resizing the image. This might force it to redraw. (I haven't tried this myself).

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: hilitePattern not resizing

Post by jacque » Wed Apr 10, 2013 11:53 pm

sincipient820 , that was my experience too. It may be fixed in version 6.0 because they did some work with icons that now resize when the source image changes. I haven't had a chance to test it yet. The trick I used works well and it's being used in a commercial app in the App Store without any problem. But I was wrong about using a snapshot, I just remembered I did it a little differently:

The source image is stored normally wherever you want, I used a hidden group. I made a copy and stored it in the same place. The reason for keeping the copy is so that you always have the original, unaltered image available. I assigned the hilitepattern of the field to the id of the copy. When I needed to resize the hilitepattern, I resized the original and then set the imagedata of the copy to the imagedata of the original. That makes the copy a non-resized image, which the hilitepattern property will use correctly.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sincipient820
Posts: 25
Joined: Mon Feb 25, 2013 4:00 am

Re: hilitePattern not resizing

Post by sincipient820 » Fri Apr 12, 2013 10:58 pm

thanks guys, i'll try to implement these suggestions this weekend and get back to the thread with results

Post Reply