Changing the width of a stack

Richard Gaskin ambassador at fourthworld.com
Sun Jun 28 18:47:53 CEST 2015


Peter Haworth wrote:
> The problem with globalloc and width and other stack related properties
> is they don't change the position of the left edge of the stack
> relative to the left edge of the centered control abc".

The coordinate systems for windows and their content regions in LiveCode 
reflect the APIs of the OSes it runs on.  OS X, iOS, Windows, Android, 
Gnome, and KDE all use a common convention of having window coordinates 
begin with 0,0 at the topleft of the current monitor, and local 
coordinates beginning with 0,0 at the topleft of the windows' content 
region.

Some APIs may allow a window to adjust the origin point of its content 
region from the topleft to some other location, and in LiveCode we can 
do the same by putting our controls in groups and moving the group 
wherever we want.

We can even handle resize events local to the group by having the parent 
stack or card resize the group, and within the group respond to the 
resizeControl message and adjust the group's content relative to the 
coordinates of "me".

If you see any apps made with something other than LiveCode that exhibit 
the sort of behavior you're looking for, just keep in mind that they're 
doing something very similar to how we'd do this in LC, just with a lot 
more code. :)

Most of what happens with UIs in computing is all smoke and mirrors, 
creating illusions for the user from a set of capable but limited raw 
materials.


> I suspected moving the centered control to the left edge of the stack would
> be reuired, just seems like there should be a more elegant way to do this,
> perhaps something like "position the left of stack xyz to the left of
> control abc".

SuperCard has an interesting background property called the backSize, a 
pair of integers defining the fixed size of any cards using that 
background, completely independent of the window size.

I used to crave such a thing in LC, thinking it might simplify making 
windows with scrollable content regions as it did for me in SC.

But in practice I've found LiveCode's use of groups for scrollable 
regions much more flexible.   In SC, like HC, any card had exactly one 
background, but in LC we can have any number of backgrounds, each 
scrolling independently of one another.

Scott Raney did implement a backSize property for groups many years ago, 
and I've used it in cases where I want a group's content region to be of 
a fixed size, independent of any controls it may have within it.

But over the years I've become ever more glad he implemented that as a 
group property rather than as a stack property as I'd requested, since 
groups are by far a more flexible solution, ultimately able to handle 
any scrolling of the sort we might do in SC, but also able to handle 
multi-pane layouts we couldn't dream of building in SC.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com



More information about the use-livecode mailing list