Reducing height of window from the top down

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Reducing height of window from the top down

Post by gyroscope » Tue Jul 01, 2008 10:48 pm

Edit: the title of this thread isn't relevant now as I'll live with a workaround I've done... I still have a question though concerning this topic of reducing window height:

Hi, I've jumped to another of my projects today for the while; for this I'm using:

Code: Select all

 revChangeWindowSize 504,285,"snap"
wait .08 second
revChangeWindowSize 504,190,"snap"
wait .08 second ----etc
which works well snapping up from the bottom of the window, "snapping back", there's the flash of the white background before the image appears. I've tried using

Code: Select all

set the bufferhiddenimages to true
and putting the revChangeWindowSize lines in between lock and unlock screen, but that doesn't seem to make any difference.

Does anyone know how to stop this flashing please?

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Wed Jul 02, 2008 4:49 pm

Code: Select all

lock screen
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed Jul 02, 2008 10:21 pm

Hi BvG, thank you for your reply; I have tried that but still it flashes...(which is surprising to me, I thought of all things that that would have done the trick...) :?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Jul 03, 2008 9:02 am

Hi Gyroscope,

This is an engine problem that cannot be solved.

You could wite your own script, similar to:

Code: Select all

repeat with x = 300 to 400 with messages
  set the height of this stack to x
  wait 0 millisecs with messages
end repeat
This doesn't work perfectly, but better than revChangeWindowSize.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Thu Jul 03, 2008 2:10 pm

Here is a modification of some code I use to resize windows. I use send in time combined with a wait message and it works pretty well. I use Malte Debrill's Animation Engine to make the resize less abrupt.

If you don't have Animation Engine then you could try the trial. Otherwise you will have to take out aeEaseInOUt, aeEaseIn, etc. They can be found in _easeThePropertySetting.

Code: Select all

## card script
on preOpenCard
	put the width of this card + 100 into theWidth
        put the height of this card + 100 into theHeight
        put "ease in" into theEase

	SetStackWidthAndHeight the long id of this stack, theWidth, theHeight, theEase, 200
	wait until the width of this stack is theWidth and the height of this stack is theHeight with messages
end on preOpenCard

Code: Select all

## library script

local sAnims

command SetStackWidthAndHeight pStack, pWidth, pHeight, pEase, pDuration
    put the rect of pStack into theRect
    
    if pEase is not empty then
        put theRect into theNewRect
        put item 1 of theNewRect + pWidth into item 3 of theNewRect
        put item 2 of theNewRect + pHeight into item 4 of theNewRect
        _InitializeAnimationForControl pStack, "rect", pEase, pDuration, theRect, theNewRect
    else
        put item 1 of theRect + pWidth into item 3 of theRect
        put item 2 of theRect + pHeight into item 4 of theRect
        set the rect of pStack to theRect
    end if
end SetStackWidthAndHeight


private command _InitializeAnimationForControl pControl, pProperty, pEase, pDuration, pStartValue, pEndValue
    put the long id of pControl into pControl
    cancel sAnims[pControl, "send id"] ## cancel existing animation
    
    if pEase is not among the items of "ease in,ease out, ease in out" then put "ease out" into pEase
    if pDuration is not an integer then put "250" into pDuration
    
    put pProperty into sAnims[pControl, "property"]
    put pStartValue into sAnims[pControl, "start value"]
    put pEndValue into sAnims[pControl, "end value"]
    put pEase into sAnims[pControl, "ease"]
    put pDuration into sAnims[pControl, "duration"]
    
    put the milliseconds into sAnims[pControl, "start time"]
    _easeThePropertySetting pControl
end _InitializeAnimationForControl


command _easeThePropertySetting pControl
    put the milliseconds - sAnims[pControl, "start time"] into theElapsedTime
     
    repeat with i = 1 to the number of items of sAnims[pControl, "start value"]
        put item i of sAnims[pControl, "start value"] into theStart
        put item i of sAnims[pControl, "end value"] into theEnd
        
        switch sAnims[pControl, "ease"]
            case "ease in"
                put round(aeEaseIn(theStart, theEnd, sAnims[pControl, "duration"], theElapsedTime, 3)) into item i of theValue
                break
            case "ease in out"
            case "ease in and out"
                put round(aeEaseInOUt(theStart, theEnd, sAnims[pControl, "duration"], theElapsedTime, 3)) into item i of theValue
                break
            default
                put round(aeEaseOut(theStart, theEnd, sAnims[pControl, "duration"], theElapsedTime, 3)) into item i of theValue
        end switch
    end repeat
    
    ## check before so we know if we need to coerce values to min/max
    if theElapsedTime >= sAnims[pControl, "duration"] then
        put sAnims[pControl, "end value"] into theValue
    end if
     
    ## set property
    switch sAnims[pControl, "property"]
        case "loc"
            set the loc of pControl to theValue
            break
        case "left"
            set the left of pControl to theValue
            break
        case "topleft"
            set the topleft of pControl to theValue
            break
        case "top"
            set the top of pControl to theValue
            break
        case "topright"
            set the topright of pControl to theValue
            break
        case "right"
            set the right of pControl to theValue
            break
        case "bottomright"
            set the bottomright of pControl to theValue
            break
        case "bottom"
            set the bottom of pControl to theValue
            break
        case "bottomleft"
            set the bottomleft of pControl to theValue
            break
        case "vscroll"
            set the vscroll of pControl to theValue
            break
        case "hscroll"
            set the hscroll of pControl to theValue
            break
        case "height"
            if word 1 of pControl is "stack" then
                lock screen
            end if
            put the rect of pControl into theRect
            put item 2 of theRect + theValue into item 4 of theRect
            set the rect of pControl to theRect
            if word 1 of pControl is "stack" then
                unlock screen
            end if
            break
        case "width"
            put the rect of pControl into theRect
            put item 1 of theRect + theValue into item 3 of theRect
            set the rect of pControl to theRect
            break
        case "rect"
            if word 1 of pControl is "stack" then
                lock screen
            end if
            set the rect of pControl to theValue
            if word 1 of pControl is "stack" then
                unlock screen
            end if
            break
    end switch
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Jul 03, 2008 2:13 pm

Hi Trevor,

The code looks impressive, but does it actually prevent the white area from appearing when the window size increases?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Thu Jul 03, 2008 4:12 pm

You may still see some white on occasion. Using a timer gave me the best results of the techniques I tried however.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Mon Jul 07, 2008 11:59 am

Hi, apologies for the delay in replying (we've been away for four days house/pet sitting for my brother-in-law, if that's at all interesting! :wink:)

Mark, thanks for your code snippet; it works nicely but I specifically need the window to be "nailed down" at the top, with the height changing from the bottom of the window up or down (which revChangeWindowSize does nicely).

Trevor, thanks for that comprehensive coding, I haven't tried it yet but if the screen still occassionally flashes, I think perhaps I'll live with the "consistent flashing" as it is. (Your time/info given there still very much appreciated though... :))

For interest, I do have Malte Debrill's Animation Engine; it looks superb, and I think I'll be making much use of it for a game or two which I want to put together (but I now have four "serious" projects to complete before that...)

:)

Post Reply