fullscreenmode and rect of a substack on mobile device ?

Brian Milby brian at milby7.com
Sat Aug 18 14:49:49 EDT 2018


Here is the card script that I just tested on iOS.  It will rotate a two
object card between portrait/landscape on my phone with no issues.  It
handles either orientation as the initial orientation.

local sOrientation, sLongSide, sShortSide

on preOpenCard
   local tScreenRect

   if the environment is "mobile" then
      set the fullscreenmode of this stack to "noScale"
   end if

   -- get the dimensions of the current screen
   put the screenRect into tScreenRect

   -- figure out long/short sides
   if item 3 of tScreenRect > item 4 of tScreenRect then
      put item 3 of tScreenRect into sLongSide
      put item 4 of tScreenRect into sShortSide
   else
      put item 4 of tScreenRect into sLongSide
      put item 3 of tScreenRect into sShortSide
   end if

   put word 1 of mobileDeviceOrientation() into sOrientation
   if sOrientation is not in "portrait,landscape" then
      put "portrait" into sOrientation
   end if
   resizeStack
end preOpenCard


on orientationChanged
   local tNewOrientation

   put word 1 of mobileDeviceOrientation() into tNewOrientation
   if tNewOrientation is in "portrait,landscape" then
      put tNewOrientation into sOrientation
      resizeStack
   end if
end orientationChanged


on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight
   local tStackRect, tBrowserRect, tNavbarRect

   if sOrientation is "landscape" then
      put 0, 0, sLongSide, sShortSide into tStackRect
   else
      put 0, 0, sShortSide, sLongSide into tStackRect
   end if

   put tStackRect into tBrowserRect
   put item 4 of tStackRect - 50 into item 4 of tBrowserRect
   put tStackRect into tNavbarRect
   put item 4 of tBrowserRect into item 2 of tNavbarRect

   lock screen
   set the rect of this stack to tStackRect
   set the rect of widget "Browser" of me to tBrowserRect
   set the rect of widget "Navigation Bar" of me to tNavbarRect
   unlock screen
end resizeStack


On Sat, Aug 18, 2018 at 12:22 PM, Brian Milby <brian at milby7.com> wrote:

> For your browser example, you probably want to use noScale. You just need
> to be sure you capture the rect at the right time. You don’t know the new
> rect until after the orientation changed handler ends. I’ll see if I can
> locate that stack example again that you put up. Unfortunately I can only
> test on iOS right now.
>
> One good thing I discovered is that the content inside the browser widget
> is always native resolution (at least I thought so). So the only part of
> the screen that would have distortion would be the elements outside the
> widget if you used exactFit. It sounds like that was not the case for you
> though.
>
> I agree... the fullScreenModes are most useful when you want the elements
> of the application to scale with the device size.
>
> Thanks,
> Brian
> On Aug 18, 2018, 11:37 AM -0500, Sannyasin Brahmanathaswami via
> use-livecode <use-livecode at lists.runrev.com>, wrote:
>
> I have a similar issue with a stack that
>
> a) contains a browser that wants to fill the entire screen (of any device)
> b) a tool bar on the bottom, the background ( 50 px wide) which to set to
> 2000 wide
> c) a 4 widget that appear on bottom on top to background.
>
> It should work on portrait and landscape
>
> That's it, not a complicated screen to layout, responsive... or so we
> thought....
>
> Going around and around with this on support, I was using "show all"
> set at 414x736 (iPhone); and with Jacque's help to optimize my code
>
> This left pillar boxes left and right (show the stack/card color) on my
> Android.
>
> Using all the "new methods"
>
> mobileSetFullScreenRectForOrientations "portrait,portrait upside
> down","0,0,414,736"
>
> etc
>
> We were unable to gain programmatic control to use screenrect to fit the
> device.
>
> My Guess/I am wrong, HQ could let us know:
>
> seems the fullscreenmode[what-Ever-It-Is] will, at an engine level will
> override any attempt to do the simple "responsive" handlers of
>
> ========
>
> # snip the orientation changed handlers,
>
> # but it all comes down to this:
>
> put the screenrect into tRect
>
> set rect to widget "browser" to \
>
> (item 1 of the tRect, item 2 of the tRect, item 3 of tRect, item 4 of
> tRect-50)
>
> ========
>
> Support said
>
> use fullscreenmode "exactFit"
>
> Jacque predicted it would fail, all kinds of distortion. I used tried it,
> worked on the Pixel. (ratio of the widget at bottom barely noticeable) I
> happily deployed to my "nightly" branch
>
> When I finally dug out an iPad to test--oh horror, Jacque was right -- the
> widget and the bottom were all stretched out!
>
> So, I was stuck, went on another project, but I too would like to
>
> Ludovic THEBAULT wrote:
>
> How get the « real » rect of the stack ?
>
> is seems, if you want to do "responsive" design, that it will need to be
> done *without* using fullscreenmode, and do it by handling the screenrect
> yourself. Which defeats the purpose of fullScreenMode "help" for the
> developer.
>
> @Andy I will try the effective Screenrect to see what we get.
>
> BR
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>



More information about the use-livecode mailing list