Dynamic labels for buttons with (oddshaped) icon images?

Wilhelm Sanke sanke at hrz.uni-kassel.de
Tue Feb 10 12:36:18 CST 2009


Returning home from my extended weekend I looked at the results of your 
lively discussion.

I support Klaus'  enhancement request 3265, which is indeed exactly what 
I had in mind.

I also experimented with the "jiggling" approach and found the following 
enhancement (at least I hope it is an enhancement),

- calculating the necessary total new height of the button rect, and
- computing the DivFactor, which varies among other factors according to 
the textsize:

"on mouseUp
  put the icon of btn 12 into tID
  put the height of img ID tID into timgheight
  set the height of btn 12 to (timgheight  + the textheight of btn 12)
  put the height of btn 12 into tBtHeight
# the line above to simplify the following computations
  put (2* (tBtHeight-(the textheight of btn 12 + the effective textsize 
of btn 12))) / tBtHeight into tDivFactor
  put (the height of btn 12 - the textheight of btn 12 - the effective 
textsize of btn 12) / tdivfactor into tMargin
  set the margins of btn 12 to 0,tMargin,0,tMargin
end mouseUp"

(Pay attention to possible line breaks in the mail).

I have replaced the *div* operator of Jacqueline's and Klaus' scripts 
with the simple division using "/" as it provides finer adjustments.
(Revolution in many cases handles fractional values excellently and many 
scripts - especially such with longer repeat loops - can be speeded up 
enormously  when we leave out "trunc", "round" etc. You can, for 
instance, see this when changing color values of imagedata with "numtochar")

The script above (most accurately) places the label "on top" of the icon 
with any icon image height and fontsize. What we might still need is an 
extra tiny "jiggle" factor that achieves another mini-adjustment of 1 to 
3 pixels.

The resulting button is higher (with the transparent area at the bottom) 
than the icon image, which for some uses may need extra workarounds, 
e.g. if you want to drag the button to a field and set the loc of the 
button to the loc of the field (using "intersect" etc.).

But what you can do now is to *group" the button and set the height of 
the group to the height of the icon image.

=================
Scott Rossi had written:

> It's possible, but it's not a little script. :-)  I demoed a customizable
> button object at the last RevLive conference in Vegas.  One can set 
> the font
> of the text, the orientation of the text, margins, and include an icon
> (which orients itself as expected, as opposed to the current 
> behavior). But
> this all needs to be handled as a group of objects. Features in the 
> upcoming
> version of Rev will make this type of control much more practical for end
> users.

So your not-so-little-script probably contains more and other factors to 
achieve a perfect adjustment.

I suppose you refer to the scripts of "tm|button" of your "tm|elements", 
which however have not yet been released - at least I could not find a 
relevant link on your homepage. Will your "tm|elements" be released any 
time soon?

Best regards,

Wilhelm Sanke
<http://www.sanke.org/MetaMedia>




More information about the use-livecode mailing list