/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ /******************************************************************************* Version: 1.0 Author: Bastien BOURINEAU Date: 10/07/2012 Warning: loading too much bitmaps at start can take long and use uncessary large amount of memory *******************************************************************************/ struct PlugArea = [ PAREA_instance : PInstance, PAREA_bOnMaterial : I, PAREA_Material : SO3_MATERIAL, PAREA_iTechnique : I, PAREA_iPass : I, PAREA_iTexture : I, PAREA_win : SO3_WIDGET, PAREA_AlphaBuffer : AlphaBitmap, PAREA_AlphaDraw : AlphaBitmap, PAREA_iPosX : I, PAREA_iPosY : I, PAREA_iWidth : I, PAREA_iHeight : I, PAREA_tPercent : [I I I I I I I I], PAREA_tAlign : [I I], PAREA_bTransparency : I, PAREA_iOpacity : I, PAREA_iTransition : I, PAREA_fTransOpacity : F, PAREA_font : ObjFont, PAREA_cvfont : ObjBTFont, PAREA_sLabel : S, PAREA_ifColor : I, PAREA_bUrl : I, PAREA_sPath : S, PAREA_bShow : I, PAREA_iAvStates : I, PAREA_iState : I, PAREA_iActivateDelay : I, PAREA_iTimeAccumulator : I, PAREA_iLastInputState : I, PAREA_lInputs : [[S [I I]] r1], PAREA_httpReq : ObjCURL, PAREA_iZorder : I ] MkPlugArea;; var sTmpDownloadPath = "tmp/areas/";; fun restoreTexture(areastr)= setPluginInstanceCbScenePostRender areastr.PAREA_instance nil; V3DremoveWidgetControl (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) areastr.PAREA_win; SO3WidgetDestroy areastr.PAREA_win; set areastr.PAREA_win = nil; _DSalphaBitmap areastr.PAREA_AlphaBuffer; _DSalphaBitmap areastr.PAREA_AlphaDraw; set areastr.PAREA_AlphaBuffer = nil; set areastr.PAREA_AlphaDraw = nil; 0;; fun drawLabel(abmp, areastr)= let _GETalphaBitmaps abmp -> [bmp bmp8] in let _GETbitmapSize bmp -> [bw bh] in if (_platform != SCOL_PLATFORM_WINDOWS) then ( _BTDRAWtextAlphaBitmap abmp areastr.PAREA_cvfont [bw/2 bh/2] BT_TEXT_HORIZ_CENTERED|BT_TEXT_VERT_CENTER areastr.PAREA_ifColor 255 areastr.PAREA_sLabel; 0; ) else ( let G2DgetStringSize areastr.PAREA_font areastr.PAREA_sLabel -> [_ th] in ( _DRAWtext bmp areastr.PAREA_font (bw / 2) ((bh / 2) - (th / 2)) TD_CENTER areastr.PAREA_ifColor areastr.PAREA_sLabel; _DRAWtext8 bmp8 areastr.PAREA_font (bw / 2) ((bh / 2) - (th / 2)) TD_CENTER 0xffffff areastr.PAREA_sLabel; ); 0; ); 0;; fun updateBitmap(areastr)= if (areastr.PAREA_win == nil) then nil else let _GETalphaBitmapSize areastr.PAREA_AlphaBuffer -> [bw bh] in let _GETalphaBitmapSize areastr.PAREA_AlphaDraw -> [dbw dbh] in let bw -> width in let bh / (areastr.PAREA_iAvStates + 1) -> height in let 0 -> wpos in let height * areastr.PAREA_iState -> ypos in ( if ((areastr.PAREA_AlphaDraw == nil) || (dbw != width) || (dbh != height)) then ( _DSalphaBitmap areastr.PAREA_AlphaDraw; let _CRbitmap _channel width height -> bmp24 in let _CRbitmap8 _channel width height -> bmp8 in set areastr.PAREA_AlphaDraw = _CRalphaBitmap _channel bmp24 bmp8 nil nil; ) else nil; let _GETalphaBitmaps areastr.PAREA_AlphaBuffer -> [colorLayer alphaLayer] in let _GETalphaBitmaps areastr.PAREA_AlphaDraw -> [colorDraw alphaDraw] in ( _CPbitmap24 colorDraw 0 0 colorLayer wpos ypos width height nil; _CPbitmap8 alphaDraw 0 0 alphaLayer wpos ypos width height nil; ); drawLabel areastr.PAREA_AlphaDraw areastr; SO3BitmapWidgetBlitAlpha areastr.PAREA_win areastr.PAREA_AlphaDraw; ); 0;; fun computePosSize(areastr, vw, vh)= let areastr.PAREA_tPercent -> [px py pw ph xo yo wo ho] in let areastr.PAREA_tAlign -> [ax ay] in let if pw then (ftoi (((itof areastr.PAREA_iWidth) /. 100.0) *. (itof vw))) + wo else areastr.PAREA_iWidth -> pw in let if ph then (ftoi (((itof areastr.PAREA_iHeight) /. 100.0) *. (itof vh))) + ho else areastr.PAREA_iHeight -> ph in let if px then (ftoi (((itof areastr.PAREA_iPosX) /. 100.0) *. (itof vw))) + xo else areastr.PAREA_iPosX -> px in let if (ax == 1) then ((vw / 2) - (pw / 2)) + px else if (ax == 2) then (vw - pw) - px else px -> px in let if py then (ftoi (((itof areastr.PAREA_iPosY) /. 100.0) *. (itof vh))) + yo else areastr.PAREA_iPosY -> py in let if (ay == 1) then ((vh / 2) - (ph / 2)) + py else if (ay == 2) then (vh - ph) - py else py -> py in [px py pw ph];; fun cbResizeCtrl(inst, viewstr, ww, wh, areastr)= if areastr.PAREA_win == nil || areastr.PAREA_bOnMaterial then nil else let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let computePosSize areastr vw vh -> [px py pw ph] in ( SO3WidgetSetPosition areastr.PAREA_win px py; SO3WidgetSetSize areastr.PAREA_win pw ph; updateBitmap areastr; ); 0;; fun cbUpdateArea(inst, viewstr, etime, areastr)= let if etime <= 1000 then 1000 else etime -> etime in set areastr.PAREA_iTimeAccumulator = areastr.PAREA_iTimeAccumulator + (etime / 1000); let (itof areastr.PAREA_iTimeAccumulator) /. (itof areastr.PAREA_iActivateDelay) -> coef in let if coef >. 1.0 then 1.0 else coef -> coef in ( if (areastr.PAREA_win == nil) then nil else let _GETalphaBitmapSize areastr.PAREA_AlphaBuffer -> [bw bh] in let bh / (areastr.PAREA_iAvStates + 1) -> stateh in let stateh * areastr.PAREA_iState -> ypos in let G2DcopyAlphaBitmap _channel areastr.PAREA_AlphaBuffer 0 ypos bw stateh -> cpabmp1 in let _GETalphaBitmaps cpabmp1 -> [colorLayer1 alphaLayer1] in let stateh * (areastr.PAREA_iState + 1) -> ypos in let if (ypos >= bh) then _CRalphaBitmap _channel (_FILLbitmap (_CRbitmap _channel bw stateh) 0xeeeeee) alphaLayer1 nil nil //G2DcopyAlphaBitmap _channel areastr.PAREA_AlphaBuffer 0 stateh * areastr.PAREA_iState bw stateh else G2DcopyAlphaBitmap _channel areastr.PAREA_AlphaBuffer 0 ypos bw stateh -> cpabmp2 in let _GETalphaBitmaps cpabmp2 -> [colorLayer2 alphaLayer2] in ( drawLabel cpabmp1 areastr; drawLabel cpabmp2 areastr; // top bottom /*let (ftoi ((itof stateh) *. coef)) -> nh in ( _CPbitmap24 colorLayer1 0 0 colorLayer2 0 0 bw nh nil; _CPbitmap8 alphaLayer1 0 0 alphaLayer2 0 0 bw nh nil; );*/ // bottom top let (ftoi ((itof stateh) *. coef)) -> nh in ( _CPbitmap24 colorLayer1 0 stateh - nh colorLayer2 0 stateh - nh bw nh nil; _CPbitmap8 alphaLayer1 0 stateh - nh alphaLayer2 0 stateh - nh bw nh nil; ); /* let 0 -> ih in while (ih < stateh && ih < nh) do ( let 0 -> iw in while (iw < bw) do ( let _GETpixel24 colorLayer2 iw ih -> px in _PUTpixel24 colorLayer1 iw ih px; let _GETpixel8 alphaLayer2 iw ih -> px in _PUTpixel8 alphaLayer1 iw ih px; set iw = iw + 1; ); set ih = ih + 1; );*/ SO3BitmapWidgetBlitAlpha areastr.PAREA_win cpabmp1; _DSalphaBitmap cpabmp1; _DSalphaBitmap cpabmp2; ); ); if (areastr.PAREA_iTimeAccumulator < areastr.PAREA_iActivateDelay) then nil else ( // reset time accumulator setPluginInstanceCbScenePostRender inst nil; set areastr.PAREA_iTimeAccumulator = 0; SendPluginEvent areastr.PAREA_instance "Activate" nil nil; ); 0;; fun cbMouseIn(widget, areastr)= if(areastr.PAREA_iState == 3) then nil else ( set areastr.PAREA_iState = 0; //update bitmap ( updateBitmap areastr; 0; ); setPluginInstanceCbScenePostRender areastr.PAREA_instance mkfun4 @cbUpdateArea areastr; SendPluginEvent areastr.PAREA_instance "In" nil nil; ); 0;; fun cbMouseOut(widget, areastr)= if(areastr.PAREA_iState == 3) then nil else ( set areastr.PAREA_iState = 0; //update bitmap ( updateBitmap areastr; 0; ); // reset time accumulator setPluginInstanceCbScenePostRender areastr.PAREA_instance nil; set areastr.PAREA_iTimeAccumulator = 0; SendPluginEvent areastr.PAREA_instance "Out" nil nil; ); 0;; fun createPicture(inst, areastr)= let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in if areastr.PAREA_win != nil then nil else ( V3DremoveWidgetControl viewportstr areastr.PAREA_win; SO3WidgetDestroy areastr.PAREA_win; if areastr.PAREA_bOnMaterial then ( set areastr.PAREA_win = SO3BitmapWidgetCreateOnMaterial (V3DgetSession c3dXsession) areastr.PAREA_Material (strcat (getPluginInstanceName inst) "_pictureCtrl") areastr.PAREA_iWidth areastr.PAREA_iHeight areastr.PAREA_iTechnique areastr.PAREA_iPass areastr.PAREA_iTexture; 0; ) else ( let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let computePosSize areastr vw vh -> [px py pw ph] in set areastr.PAREA_win = SO3BitmapWidgetCreate (V3DgetSession c3dXsession) viewportstr.V3D_viewport (strcat (getPluginInstanceName inst) "_pictureCtrl") px py pw ph areastr.PAREA_iZorder; SO3WidgetSetTopOnFocus areastr.PAREA_win 0; SO3WidgetSetForeground areastr.PAREA_win 1; ); SO3WidgetEnterEventCb areastr.PAREA_win @cbMouseIn areastr; SO3WidgetExitEventCb areastr.PAREA_win @cbMouseOut areastr; V3DaddWidgetControl viewportstr areastr.PAREA_win; SO3WidgetSetKeyboardEnable areastr.PAREA_win 0; SO3WidgetSetMouseEnable areastr.PAREA_win 1; SO3WidgetSetTransparency areastr.PAREA_win areastr.PAREA_bTransparency; SO3WidgetSetOpacity areastr.PAREA_win (itof areastr.PAREA_iOpacity) *. 0.01; SO3WidgetSetVisibility areastr.PAREA_win 0; ); 0;; fun cbControlPreRenderShow(inst, sessionstr, etime, areastr)= let if etime <= 1000 then 1000 else etime -> etime in let (itof areastr.PAREA_iOpacity) /. (itof areastr.PAREA_iTransition) -> step in ( set areastr.PAREA_fTransOpacity = areastr.PAREA_fTransOpacity +. (step *. (itof (etime / 1000))); if areastr.PAREA_fTransOpacity >=. (itof areastr.PAREA_iOpacity) then ( set areastr.PAREA_fTransOpacity = itof areastr.PAREA_iOpacity; SO3WidgetSetOpacity areastr.PAREA_win (itof areastr.PAREA_iOpacity) *. 0.01; setPluginInstanceCbScenePreRender inst nil; SendPluginEvent inst "Shown" nil nil; 0; ) else ( SO3WidgetSetOpacity areastr.PAREA_win (areastr.PAREA_fTransOpacity *. 0.01); 0; ); ); 0;; fun cbControlPreRenderHide(inst, sessionstr, etime, areastr)= let if etime <= 1000 then 1000 else etime -> etime in let (itof areastr.PAREA_iOpacity) /. (itof areastr.PAREA_iTransition) -> step in ( set areastr.PAREA_fTransOpacity = areastr.PAREA_fTransOpacity -. (step *. (itof (etime / 1000))); if areastr.PAREA_fTransOpacity <=. 0.0 then ( set areastr.PAREA_fTransOpacity = 0.0; SO3WidgetSetOpacity areastr.PAREA_win 0.0; setPluginInstanceCbScenePreRender inst nil; if (areastr.PAREA_win == nil) then nil else ( V3DremoveWidgetControl (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) areastr.PAREA_win; SO3WidgetDestroy areastr.PAREA_win; set areastr.PAREA_win = nil; _DSalphaBitmap areastr.PAREA_AlphaBuffer; set areastr.PAREA_AlphaBuffer = nil; SendPluginEvent inst "Hidden" nil nil; ); 0; ) else ( SO3WidgetSetOpacity areastr.PAREA_win (areastr.PAREA_fTransOpacity *. 0.01); 0; ); ); 0;; fun cbDownloaded(file, data, areastr)= if data == nil then nil else let strcatn sTmpDownloadPath::(getPluginInstanceName areastr.PAREA_instance)::".tmp"::nil -> tmpfile in ( _storepack data tmpfile; let G2DloadAlphaBmp _channel tmpfile -> bmp in if bmp == nil then nil else ( if(areastr.PAREA_iState >= 2) then nil else set areastr.PAREA_iState = 0; _DSalphaBitmap areastr.PAREA_AlphaBuffer; set areastr.PAREA_AlphaBuffer = bmp; if (!areastr.PAREA_bShow) then nil else ( createPicture areastr.PAREA_instance areastr; updateBitmap areastr; if (areastr.PAREA_iTransition == 0) then ( SO3WidgetSetVisibility areastr.PAREA_win 1; SendPluginEvent areastr.PAREA_instance "Shown" nil nil; 0; ) else ( SO3WidgetSetOpacity areastr.PAREA_win (areastr.PAREA_fTransOpacity *. 0.01); SO3WidgetSetVisibility areastr.PAREA_win 1; setPluginInstanceCbScenePreRender areastr.PAREA_instance mkfun4 @cbControlPreRenderShow areastr; 0; ); ); ); ); 0;; fun cbChange(inst, from, action, param, reply, areastr)= let if param == nil then areastr.PAREA_bUrl else strIsUrl param -> isurl in let if param == nil then areastr.PAREA_sPath else param -> url in ( set areastr.PAREA_bUrl = isurl; set areastr.PAREA_sPath = url; if (!areastr.PAREA_bShow) then nil else ( if(areastr.PAREA_iState >= 2) then nil else set areastr.PAREA_iState = 0; if !areastr.PAREA_bUrl then ( let G2DloadAlphaBmp _channel areastr.PAREA_sPath -> bmp in if bmp == nil then nil else ( set areastr.PAREA_AlphaBuffer = bmp; createPicture inst areastr; updateBitmap areastr; SO3WidgetSetVisibility areastr.PAREA_win 1; ); 0; ) else ( if (areastr.PAREA_httpReq == nil) then nil else ( killHttpRequest areastr.PAREA_httpReq; set areastr.PAREA_httpReq = nil; ); set areastr.PAREA_httpReq = downloadFile areastr.PAREA_sPath mkfun3 @cbDownloaded areastr; 0; ); ); ); 0;; fun cbEnable(inst, from, action, param, reply, areastr)= set areastr.PAREA_iState = 0; 0;; fun cbDisable(inst, from, action, param, reply, areastr)= set areastr.PAREA_iState = 2; 0;; fun cbSetLabel(inst, from, action, param, reply, areastr)= set areastr.PAREA_sLabel = param; updateBitmap areastr; 0;; fun cbInput(inst, from, action, param, reply, areastr)= if (!areastr.PAREA_bShow) || (param == nil) || (areastr.PAREA_win == nil) then nil else let strextr param -> lp in let atoi (nth_list (hd lp) 0) -> sx in let atoi (nth_list (hd lp) 1) -> sy in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let computePosSize areastr vw vh -> [px py pw ph] in ( let switchstr areastr.PAREA_lInputs from -> icontrol in ( // if not already int the list we add it if (icontrol == nil) then ( set areastr.PAREA_lInputs = [from [sx sy]]::areastr.PAREA_lInputs; 0; ) else ( mutate icontrol <- [sx sy]; 0; ); ); let sizelist areastr.PAREA_lInputs -> size in let 0 -> i in let 0 -> over in ( while (i < size) do ( let nth_list areastr.PAREA_lInputs i -> [n [sx sy]] in if ((sx > px) && (sx < (px + pw)) && (sy > py) && (sy < (py + ph))) then set over = 1 else nil; set i = i + 1; ); if (over == 1) then ( if (areastr.PAREA_iLastInputState) then nil else ( set areastr.PAREA_iLastInputState = 1; cbMouseIn nil areastr; ); 0; ) else if (!areastr.PAREA_iLastInputState) then nil else ( set areastr.PAREA_iLastInputState = 0; cbMouseOut nil areastr; 0; ); ); ); 0;; // multi touch fun cbAddCursor(inst, viewstr, id, x, y, areastr)= if (!areastr.PAREA_bShow) || (areastr.PAREA_win == nil) then nil else let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let computePosSize areastr vw vh -> [px py pw ph] in ( let switchstr areastr.PAREA_lInputs (itoa id) -> icontrol in ( // if not already int the list we add it if (icontrol == nil) then ( set areastr.PAREA_lInputs = [(itoa id) [x y]]::areastr.PAREA_lInputs; 0; ) else ( mutate icontrol <- [x y]; 0; ); ); let sizelist areastr.PAREA_lInputs -> size in let 0 -> i in let 0 -> over in ( while (i < size) do ( let nth_list areastr.PAREA_lInputs i -> [n [sx sy]] in if ((sx > px) && (sx < (px + pw)) && (sy > py) && (sy < (py + ph))) then set over = 1 else nil; set i = i + 1; ); if (over == 1) then ( if (areastr.PAREA_iLastInputState) then nil else ( set areastr.PAREA_iLastInputState = 1; cbMouseIn nil areastr; ); 0; ) else if (!areastr.PAREA_iLastInputState) then nil else ( set areastr.PAREA_iLastInputState = 0; cbMouseOut nil areastr; 0; ); ); ); 0;; fun cbUpdateCursor(inst, viewstr, id, x, y, vx, vy, areastr)= if (!areastr.PAREA_bShow) || (areastr.PAREA_win == nil) then nil else let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let computePosSize areastr vw vh -> [px py pw ph] in ( let switchstr areastr.PAREA_lInputs (itoa id) -> icontrol in ( // if not already int the list we add it if (icontrol == nil) then ( set areastr.PAREA_lInputs = [(itoa id) [x y]]::areastr.PAREA_lInputs; 0; ) else ( mutate icontrol <- [x y]; 0; ); ); let sizelist areastr.PAREA_lInputs -> size in let 0 -> i in let 0 -> over in ( while (i < size) do ( let nth_list areastr.PAREA_lInputs i -> [n [sx sy]] in if ((sx > px) && (sx < (px + pw)) && (sy > py) && (sy < (py + ph))) then set over = 1 else nil; set i = i + 1; ); if (over == 1) then ( if (areastr.PAREA_iLastInputState) then nil else ( set areastr.PAREA_iLastInputState = 1; cbMouseIn nil areastr; ); 0; ) else if (!areastr.PAREA_iLastInputState) then nil else ( set areastr.PAREA_iLastInputState = 0; cbMouseOut nil areastr; 0; ); ); ); 0;; fun cbRemoveCursor(inst, viewstr, id, areastr)= let switchstr areastr.PAREA_lInputs (itoa id) -> [sx sy] in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in let computePosSize areastr vw vh -> [px py pw ph] in ( if (areastr.PAREA_bOnMaterial || ((sx > px) && (sx < (px + pw)) && (sy > py) && (sy < (py + ph)))) then ( set areastr.PAREA_iLastInputState = 0; cbMouseOut nil areastr; ) else nil; set areastr.PAREA_lInputs = remove_sid_from_list areastr.PAREA_lInputs (itoa id); ); 0;; fun cbSetPosition(inst, from, action, param, reply, areastr)= if param == nil then nil else let strextr param -> lp in let (nth_list (hd lp) 0) -> sx in let (nth_list (hd lp) 1) -> sy in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in ( let 0 -> xpercent in let if (!strcmp "%" (substr sx ((strlen sx) - 1) 1)) then ( set xpercent = 1; atoi sx; ) else atoi sx -> px in let 0 -> ypercent in let if (!strcmp "%" (substr sy ((strlen sy) - 1) 1)) then ( set ypercent = 1; atoi sy; ) else atoi sy -> py in let [(if px == nil then 0 else px) (if py == nil then 0 else py)] -> [px py] in ( mutate areastr.PAREA_tPercent <- [xpercent ypercent _ _ _ _ _ _]; set areastr.PAREA_iPosX = px; set areastr.PAREA_iPosY = py; let computePosSize areastr vw vh -> [px py pw ph] in ( SO3WidgetSetPosition areastr.PAREA_win px py; SO3WidgetSetSize areastr.PAREA_win pw ph; updateBitmap areastr; ); ); ); 0;; fun cbSetSize(inst, from, action, param, reply, areastr)= if param == nil then nil else let strextr param -> lp in let (nth_list (hd lp) 0) -> sx in let (nth_list (hd lp) 1) -> sy in let V3DgetSessionView c3dXsession -> viewstr in let V3DgetDefaultViewport viewstr -> viewportstr in let V3DgetViewportSize viewstr viewportstr -> [_ _ vw vh] in ( let 0 -> wpercent in let if (!strcmp "%" (substr sx ((strlen sx) - 1) 1)) then ( set wpercent = 1; atoi sx; ) else atoi sx -> px in let 0 -> hpercent in let if (!strcmp "%" (substr sy ((strlen sy) - 1) 1)) then ( set hpercent = 1; atoi sy; ) else atoi sy -> py in let [(if px == nil then 0 else px) (if py == nil then 0 else py)] -> [px py] in ( mutate areastr.PAREA_tPercent <- [_ _ wpercent hpercent _ _ _ _]; set areastr.PAREA_iWidth = px; set areastr.PAREA_iHeight = py; let computePosSize areastr vw vh -> [px py pw ph] in ( SO3WidgetSetPosition areastr.PAREA_win px py; SO3WidgetSetSize areastr.PAREA_win pw ph; updateBitmap areastr; ); ); ); 0;; fun cbSetOpacity(inst, from, action, param, reply, areastr)= if (param == nil) || (!strcmp "" strtrim param) || ((atoi param) == nil) then nil else let atoi param -> opacity in ( set areastr.PAREA_iOpacity = opacity; SO3WidgetSetOpacity areastr.PAREA_win (itof areastr.PAREA_iOpacity) *. 0.01; ); 0;; fun cbShow(inst, from, action, param, reply, areastr)= if (areastr.PAREA_bShow) then nil else ( setPluginInstanceCbScenePreRender inst nil; if(areastr.PAREA_iState >= 2) then nil else set areastr.PAREA_iState = 0; if !areastr.PAREA_bUrl then ( let G2DloadAlphaBmp _channel areastr.PAREA_sPath -> bmp in if bmp == nil then nil else ( set areastr.PAREA_AlphaBuffer = bmp; createPicture inst areastr; updateBitmap areastr; if (areastr.PAREA_iTransition == 0) then ( SO3WidgetSetVisibility areastr.PAREA_win 1; SendPluginEvent inst "Shown" nil nil; 0; ) else ( SO3WidgetSetOpacity areastr.PAREA_win (areastr.PAREA_fTransOpacity *. 0.01); SO3WidgetSetVisibility areastr.PAREA_win 1; setPluginInstanceCbScenePreRender areastr.PAREA_instance mkfun4 @cbControlPreRenderShow areastr; 0; ); ); 0; ) else ( if (areastr.PAREA_httpReq == nil) then nil else ( killHttpRequest areastr.PAREA_httpReq; set areastr.PAREA_httpReq = nil; ); set areastr.PAREA_httpReq = downloadFile areastr.PAREA_sPath mkfun3 @cbDownloaded areastr; 0; ); set areastr.PAREA_bShow = 1; ); 0;; fun cbHide(inst, from, action, param, reply, areastr)= if (!areastr.PAREA_bShow) then nil else ( setPluginInstanceCbScenePreRender inst nil; setPluginInstanceCbScenePostRender inst nil; set areastr.PAREA_iTimeAccumulator = 0; if(areastr.PAREA_iState >= 2) then nil else set areastr.PAREA_iState = 0; set areastr.PAREA_bShow = 0; set areastr.PAREA_lInputs = nil; if (areastr.PAREA_iTransition == 0) then ( if (areastr.PAREA_win == nil) then nil else ( V3DremoveWidgetControl (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) areastr.PAREA_win; SO3WidgetDestroy areastr.PAREA_win; set areastr.PAREA_win = nil; _DSalphaBitmap areastr.PAREA_AlphaBuffer; set areastr.PAREA_AlphaBuffer = nil; SendPluginEvent inst "Hidden" nil nil; ); 0; ) else ( SO3WidgetSetOpacity areastr.PAREA_win (areastr.PAREA_fTransOpacity *. 0.01); setPluginInstanceCbScenePreRender inst mkfun4 @cbControlPreRenderHide areastr; 0; ); ); 0;; // Destroy instance fun deleteOb(inst, areastr)= setPluginInstanceCbScenePreRender inst nil; if (areastr.PAREA_httpReq == nil) then nil else ( killHttpRequest areastr.PAREA_httpReq; set areastr.PAREA_httpReq = nil; ); _DSfont areastr.PAREA_font; _DSBTfont areastr.PAREA_cvfont; restoreTexture areastr; 0;; fun cbNewOb(inst)= let (getPluginInstanceParam inst "object") -> objname in let (getPluginInstanceParam inst "material") -> matname in let atoi (getPluginInstanceParam inst "technique") -> technique in let if (technique == nil) || (technique < 0) then 0 else technique -> technique in let atoi (getPluginInstanceParam inst "pass") -> pass in let if (pass == nil) || (pass < 0) then 0 else pass -> pass in let atoi (getPluginInstanceParam inst "texture") -> texture in let if (texture == nil) || (texture < 0) then 0 else texture -> texture in let atoi (getPluginInstanceParam inst "istexture") -> istexture in let if istexture == nil then 0 else istexture -> istexture in let (getPluginInstanceParam inst "path") -> path in let atoi (getPluginInstanceParam inst "isurl") -> isurl in let if isurl == nil then 0 else isurl -> isurl in let (getPluginInstanceParam inst "url") -> url in /*let atoi (getPluginInstanceParam inst "btnstates") -> btnstates in let if btnstates == nil then 0 else btnstates -> btnstates in*/ let atoi (getPluginInstanceParam inst "xpercent") -> xpercent in let if xpercent == nil then 0 else xpercent -> xpercent in let atoi (getPluginInstanceParam inst "xalign") -> xalign in let if xalign == nil then 0 else xalign -> xalign in let atoi (getPluginInstanceParam inst "posx") -> posx in let if posx == nil then 0 else posx -> posx in let atoi (getPluginInstanceParam inst "ypercent") -> ypercent in let if ypercent == nil then 0 else ypercent -> ypercent in let atoi (getPluginInstanceParam inst "yalign") -> yalign in let if yalign == nil then 0 else yalign -> yalign in let atoi (getPluginInstanceParam inst "posy") -> posy in let if posy == nil then 0 else posy -> posy in let atoi (getPluginInstanceParam inst "wpercent") -> wpercent in let if wpercent == nil then 1 else wpercent -> wpercent in let atoi (getPluginInstanceParam inst "width") -> width in let if width == nil then 100 else width -> width in let atoi (getPluginInstanceParam inst "hpercent") -> hpercent in let if hpercent == nil then 1 else hpercent -> hpercent in let atoi (getPluginInstanceParam inst "xoffset") -> xoffset in let if xoffset == nil then 0 else xoffset -> xoffset in let atoi (getPluginInstanceParam inst "yoffset") -> yoffset in let if yoffset == nil then 0 else yoffset -> yoffset in let atoi (getPluginInstanceParam inst "woffset") -> woffset in let if woffset == nil then 0 else woffset -> woffset in let atoi (getPluginInstanceParam inst "hoffset") -> hoffset in let if hoffset == nil then 0 else hoffset -> hoffset in let atoi (getPluginInstanceParam inst "height") -> height in let if height == nil then 100 else height -> height in let getPluginInstanceParam inst "fontname" -> fname in let if fname == nil then "Arial" else fname -> fname in let atoi (getPluginInstanceParam inst "fontcolor") -> fcolor in let if fcolor == nil then 0 else fcolor -> fcolor in let atoi (getPluginInstanceParam inst "fontsize") -> fsize in let if fsize == nil then 12 else fsize -> fsize in let atoi (getPluginInstanceParam inst "fontbold") -> fbold in let if fbold == nil then 0 else fbold -> fbold in let getPluginInstanceParam inst "label" -> label in let if label == nil then "" else label -> label in let G2DcrFont _channel fsize 0 FF_PIXEL|(if fbold then FF_WEIGHT else 0) fname -> font in let _CRBTfont _channel fname fsize (BT_FONT_ANTIALIAS | (if fbold then BT_FONT_BOLD else 0)) 1.0 -> cv_font in let atoi (getPluginInstanceParam inst "opacity") -> opacity in let if opacity == nil then 100 else opacity -> opacity in let atoi (getPluginInstanceParam inst "transition") -> transition in let if transition == nil then 0 else transition -> transition in let atoi (getPluginInstanceParam inst "transparency") -> trans in let if (trans == nil) then 0 else trans -> trans in let atoi (getPluginInstanceParam inst "delay") -> delay in let if delay == nil then 1000 else delay -> delay in let atoi (getPluginInstanceParam inst "show") -> show in let if (show == nil) then 1 else show -> show in let if !isurl then path else url -> file in let atoi (getPluginInstanceParam inst "zorder") -> zorder in let if zorder == nil then 100 else zorder -> zorder in let SO3SceneGetObject (V3DgetSession c3dXsession) objname -> obj in let if !istexture then nil else SO3SceneGetMaterial (V3DgetSession c3dXsession) (SO3EntityGetResourceGroup obj) matname -> mat in let MkPlugArea [inst istexture mat technique pass texture nil nil nil posx posy width height [xpercent ypercent wpercent hpercent xoffset yoffset woffset hoffset] [xalign yalign] trans opacity transition 0.0 font cv_font label fcolor isurl file 0 1/*btnstates*/ 0 delay 0 0 nil nil zorder] -> areastr in ( setPluginInstanceCbResizeView inst mkfun5 @cbResizeCtrl areastr; if show then cbShow inst nil nil nil nil areastr else cbHide inst nil nil nil nil areastr; PluginRegisterAction inst "Show" mkfun6 @cbShow areastr; PluginRegisterAction inst "Hide" mkfun6 @cbHide areastr; PluginRegisterAction inst "Change" mkfun6 @cbChange areastr; PluginRegisterAction inst "Enable" mkfun6 @cbEnable areastr; PluginRegisterAction inst "Disable" mkfun6 @cbDisable areastr; PluginRegisterAction inst "Set label" mkfun6 @cbSetLabel areastr; PluginRegisterAction inst "Input" mkfun6 @cbInput areastr; PluginRegisterAction inst "Set position" mkfun6 @cbSetPosition areastr; PluginRegisterAction inst "Set size" mkfun6 @cbSetSize areastr; PluginRegisterAction inst "Set opacity" mkfun6 @cbSetOpacity areastr; if (istexture) then nil else ( setPluginInstanceCbTouchPointAdd inst mkfun6 @cbAddCursor areastr; setPluginInstanceCbTouchPointRemove inst mkfun4 @cbRemoveCursor areastr; setPluginInstanceCbTouchPointUpdate inst mkfun8 @cbUpdateCursor areastr; ); setPluginInstanceCbDel inst mkfun2 @deleteOb areastr; SendPluginEvent areastr.PAREA_instance "Loaded" nil nil; ); 0;; fun IniPlug(file)= PlugRegister @cbNewOb nil; setPluginEditor @dynamicedit; 0;;