icongravity and labelgravity

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
makeshyft
Posts: 187
Joined: Mon Apr 15, 2013 4:41 am
Contact:

icongravity and labelgravity

Post by makeshyft » Tue Aug 11, 2015 4:44 pm

Hi Livecode,

For some inexplicable reason, it seems reasonable that a button's label goes over it;s icon. if the icon's gravity is set to left and the label justification is set to left. the same goes for right justified and right gravity settings. For static text, font, icon, sure one can set it to look right, but beyond that, this functionality just doesn't make sense. This is especailly true with dynamic buttons who's label changes, and when the user is allowed to change the font of the label.

Wouldn't it make more sense if the label snapped to the edge of the icon so that it didn't cover it?????

So here is my suggestion for a "labelgravity" property that allows the label to snap to the edge of the icon.

This way we don't have to build our own controls that follow this simple idea of not covering the icon with the label.

Thank you for taking this into consideration.
Tom @
http://www.makeshyft.com
---------------------------------
Changing the Future, Today!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6163
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: icongravity and labelgravity

Post by dunbarx » Tue Aug 11, 2015 6:46 pm

Hi.

I see the icon covering the label, not the other way around. Is that what you meant? I don't know if there is a "right" way for this, that is, which of the two ought to be on top, but the property I would think you would want is something that could switch that order, sort of a localized "layer" property.

Craig Newman
Last edited by dunbarx on Tue Aug 11, 2015 9:39 pm, edited 1 time in total.

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 145
Joined: Thu Jun 29, 2006 4:16 pm

Re: icongravity and labelgravity

Post by Randy Hengst » Tue Aug 11, 2015 7:17 pm

FWIW, I agree with the idea of “labelGravity” being aware of the icon setting. The only way I’ve accomplished the look you described is to set icongravity to left, then set the textalign to right or center and adjust the font size and button width. Before iconGravity was introduced that align trick was only good with radio and checkbox buttons.

makeshyft
Posts: 187
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: icongravity and labelgravity

Post by makeshyft » Thu Aug 13, 2015 5:24 pm

For me, let label covers the icon.... see attached image.
Image 1.png
I just want to be able to left align icon, left align label.

My app is able to be translated using a database of strings, so when the string size changes (of the label) ..... it throws off the appearance of the button and depending on the size of the label, it can end up covering the icon.

just saying the label should be aware of the icon and its position and should be positioned next to it, not overtop.
Tom @
http://www.makeshyft.com
---------------------------------
Changing the Future, Today!

makeshyft
Posts: 187
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: icongravity and labelgravity

Post by makeshyft » Thu Aug 13, 2015 5:34 pm

Randy Hengst wrote:FWIW, I agree with the idea of “labelGravity” being aware of the icon setting. The only way I’ve accomplished the look you described is to set icongravity to left, then set the textalign to right or center and adjust the font size and button width. Before iconGravity was introduced that align trick was only good with radio and checkbox buttons.
Yep...thats the way to do it, except when the text is dynamic, it makes life really difficult. :D ..but if the button itself just snapped the label to the edge of the icon, problem solved.
Tom @
http://www.makeshyft.com
---------------------------------
Changing the Future, Today!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3302
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: icongravity and labelgravity

Post by bn » Thu Aug 13, 2015 7:45 pm

Hi Tom,

could you try this script in an extra button and let it run against a button of yours with icon and label and labelGravity to left, textAlign to right?
For me as soon as you have 5 or more characters in the label it adjusts the label to the right of the icon by changing the button width.

Code: Select all

on mouseUp
   
   -- fill in name of your btn
   put "b1" into tBtnName
   
   ask "text for label of btn"
   
   if it is "" then exit mouseUp
   lock screen
   set the label of btn tBtnName to it
   put the formattedWidth of btn tBtnName into tFW
   put the formattedWidth image id (the icon of btn tBtnName) into tIW
   
   put the topLeft of btn tBtnName into tTL
   put the rightmargin of btn tBtnName into tMarg
   set the width of btn tBtnName to tFW + tIW + tMarg
   set the topLeft of btn tBtnName to tTL
   unlock screen
 end mouseUp
is it this what you mean?

Kind regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3302
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: icongravity and labelgravity

Post by bn » Thu Aug 13, 2015 8:45 pm

Hi all,

I goofed up on the first version of the script I posted above by trying to make it more generic. Forgot to clean it up enough.
I corrected the script and it should now work when you fill in the name of your button to fill the variable tBtnName
Sorry for any inconvenience.

Kind regards
Bernd

makeshyft
Posts: 187
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: icongravity and labelgravity (solved?)

Post by makeshyft » Mon Aug 24, 2015 2:57 am

Hi Bernd,

Sorry I have not checked this thread, and didn't get any notifications.... thanks for your efforts in writing the code. I solved the problem by creating my own reusable button object, and so I pretty much did what you did but in a different way. I hope it comes in handy for someone.

Thanks everyone who weighed in.
Tom @
http://www.makeshyft.com
---------------------------------
Changing the Future, Today!

Post Reply

Return to “Feature Requests”