Collaborate on UI Handlers
Sannyasin Brahmanathaswami
brahma at hindu.org
Wed Feb 13 20:36:11 EST 2019
I was looking for a name for a library that would be like "model" in the way that Andre describes it in his book. But it has nothing to data or disk acces, but it has to do with a "view" ; but it is meant to be "encapsulated/independent" of the view. In this case the "view" is a card, in a binary LC stack. With generic handers, to which you send the long id of some control.
Now, I am sure that this nothing new to all you old timers.
If you look up "UI Handlers" in Google search, you find all kinds of references in many languages. So I called it
lib_UIHandlers.livecodescript
(See below for same examples)
Then it occurred to me "Wow, because it can 'stand alone', we could share such a library with the community, and it should work anywhere!"
Would anyone be interested in collaborating on such a library? I would buts in a public repository, you could fork it, and send pull requests. I think everyone will benefit and some of you have already fabulous handlers that you put in the library. In fact, in think LC IDE is probably full of them.
Brahmanathaswami
There would different sections:
( I use Jacqueline method of naming handler
Which must be sorted by order of appearance")
Things like:
************************
on __RESPONSIVE
end __RESPONSIVE
command positionBottom pControl, pHorizontal
# place a control at the bottom of the screen
# pHorizontal is single integer which it the left of the control
# It empty, defaults to center to scrren
put the long id of this card into tCard
put the rect of tCard into sCardRect
put item 3 of sCardRect into tWidth
put item 4 of sCardRect into tHeight
put the loc of tCard into tCardLoc
if pHorizontal is empty then
set the loc of pControl to ( round(tWidth/2),tHeight)
else
set the left of pControl to pHorizontal
end if
set the bottom of pControl to tHeight
end positionBottom
####################
on ___IMAGEManipulation
end ___IMAGEManipulation
# we typically have the some requirement
# change image by height, width.
# we always need to know it original size
command insertImageDimensions pImage
put ( (the formattedwidth of pImage) & "x" & (the formattedheight of pImage) ) into sCurrentGraphicRect
end insertImageDimensions
function getRectOfCurrentGrc
return sCurrentGraphicRect
end getRectOfCurrentGrc
command setRectOfCurrentGrc pimage
put the formattedWidth of pImage into tFWd
put the formattedHeight of pImage into tFHt
put (tFWd & "x" & tFHt) into sCurrentGraphicRect
end setRectOfCurrentGrc
on resizeToHeight pImage,pSize
set the itemdel to "x"
put item 1 of sCurrentGraphicRect into tOrigImgWidth
put item 2 of sCurrentGraphicRect into tOrigImgHeight
# it may not be necessary
if pSize > tOrigImgHeight then exit resizeToHeight
put (pSize)/tOrigImgHeight into tRatio
put (tOrigImgWidth * tRatio) into tNewWidth
put (tOrigImgHeight * tRatio) into tNewHeight
set the rect of pImage to 0,0,tNewWidth,tNewHeight
end resizeToHeight
etc.
Svasti Astu, Be Well!
Brahmanathaswami
Get the SivaSiva app, it's free:
https://www.himalayanacademy.com/apps/sivasiva
More information about the use-livecode
mailing list