Fenêtre extensible ( Vertical, Horizontal )
Hello
Voici un exemple pour avoir une boite de dialogue extensible. Comme vous pouvez voir l'exemple ci-dessous est vraiment très simple.
"Afin d'éviter tout décalage, le point d'alignement des images est réglé sur (0,0)
( coin supérieur gauche sur chaque image dans cet exemple )"
Expand Window Vertical
Dans ce tuto, je n'utilise aucune image 1 bit ( mask ) pour afficher ou masquer la fenêtre, le tout se fait par redimensionnement
la taille de la scène au départ est de 220 pixel de haut et 300 pixel de large voir image de gauche ensuite, la partie du bas est placée hors scène.
Lors du 1er clic sur le bouton, on modifie les coordonnées ( WindowRect.Height ) de la fenêtre pour afficher l'image du bas ( voir image de droite ). Le 2em clic reprend la taille d'origine de la scène, soit ici dans cet exemple, 220 pixel de haut.
Je me suis inspiré du code de sebastien portebois ( centrer une MIAW ) pour redimensionner la fenêtre et illustrer cet exemple, la grosse partie du code est basée uniquement sur les coordonnées de la fenêtre.
script de comportement placé sur le bouton
-- Fenêtre extensible ( Vertical ) ----------------------------- -- Script by Laurent Leedoriden -- Copyright © 1996 - 2005 Leedoriden DSFW -- All rights reserved -- created : 06/18/2005 -- last updated : ---------------------------- property pListImg, pDown on beginsprite me pDown = 0 pListImg = ["btnup_op","btndo_op"] end on mouseup me pDown = 1 - pDown if pDown then sprite(me.spritenum).member = pListImg[2] me.ExpandWindow(620) else sprite(me.spritenum).member = pListImg[1] me.ExpandWindow(220) end if end on ExpandWindow(me, WindowSize) WindowRect = (the activewindow).rect WindowWidth = WindowRect.width WindowHeight = WindowRect.height WindowTop = WindowRect.top WindowLeft = WindowRect.left -- WindowHeight = WindowSize NewRect = rect(0,0, WindowWidth, WindowHeight) NewRect = NewRect.offset(WindowLeft, WindowTop) (the activewindow).rect = NewRect end
Expand Window Horizontal
Pour le redimensionnement Horizontal, il faut prendre en compte quelques valeurs la largeur de la barre de titre, la position ( LocH) du bouton Quitter )…
( seulement si, comme ici, la barre de titre est un bitmap ) dans le contraire, cela ne s'applique pas
Dans cette version, la barre de titre est composée de 3 images
côté gauche, il reste à sa place et n'est pas modifié lors du changement de taille de la fenêtre
partie centrale, elle sera redimensionnée lors du changement de taille de la fenêtre
côté droit, il sera, quant à lui, en mouvement lors du changement de taille de la fenêtre
-- Fenêtre extensible ( Horizontal ) ----------------------------- -- Script by Laurent Leedoriden -- Copyright © 1996 - 2005 Leedoriden DSFW -- All rights reserved -- created : 06/18/2005 -- last updated : ---------------------------- property pListImg, pDown property pLargeurBarre, pLocHBtnExit, pLargeurBtnExit, pLocHRightBarre, pLargeurRightBarre on beginsprite me pDown = 0 pListImg = ["btnup_op","btndo_op"] pLargeurBarre = sprite("barre").width pLocHRightBarre = sprite("RightBarre").loch pLargeurRightBarre = sprite("RightBarre").width pLocHBtnExit = sprite("BtnExit").loch pLargeurBtnExit = sprite("BtnExit").width end on mouseup me pDown = 1 - pDown if pDown then sprite(me.spritenum).member = pListImg[2] me.ExpandWindow(600) -- expand window horizontal else sprite(me.spritenum).member = pListImg[1] me.ExpandWindow(300) -- expand window horizontal end if end on ExpandWindow(me, WindowSize) WindowRect = (the activewindow).rect WindowWidth = WindowRect.width WindowHeight = WindowRect.height WindowTop = WindowRect.top WindowLeft = WindowRect.left -- WindowWidth = WindowSize -- largeur modifiée NewRect = rect(0,0, WindowWidth, WindowHeight) NewRect = NewRect.offset(WindowLeft, WindowTop) (the activewindow).rect = NewRect -- positionner : barre de titre, bouton exit, pLargeurBarre = (WindowWidth - pLargeurRightBarre) - pLargeurRightBarre sprite("barre").width = pLargeurBarre pLocHRightBarre = pLargeurBarre + pLargeurRightBarre sprite("RightBarre").loch = pLocHRightBarre pLocHBtnExit = (WindowWidth - (pLargeurRightBarre + pLargeurBtnExit)) sprite("BtnExit").loch = pLocHBtnExit end
tuto by Leedoriden
