/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com
Copyright (c) 2017 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 / I-maginer
Created: 08.30.2017
**************************************************/
/*! @defgroup v3DHUDApi OpenSpace3D 3D HUD API
* OpenSpace3D 3D HUD API
* @{
*/
/** @} */
proto VUIinit = fun [V3Dsession] I;;
proto VUIreset = fun [V3Dsession] I;;
var VUI_STARTED = 0;;
// enable global drawing method instead of local
var VUI_DRAW_GLOBAL = 1;;
// force using bt draw text functions for debug
var VUI_FORCE_BT_TEXT = 1;;
var VUI_FORCE_BT_FONTFILE = 1;;
var VUI_BT_FONT_PATH = "fonts";;
var VUI_BT_ASSET_FONT_PATH = "assets/fonts";;
var VUI_NameIndex = 0;;
typeof VUI_focusedContainer = VUIcontainer;;
// - Default resources -
var VUI_USER_THEME_FOLDER = "assets/themes";;
var VUI_defTheme = "hud/default.uith";;
var VUI_defResWin = "hud/win.png";;
var VUI_defResBtn = "hud/btn.png";;
var VUI_defResTxt = "hud/text.png";;
var VUI_defResListElt = "hud/listelt.png";;
var VUI_defResListEltCheck = "hud/listeltcheck.png";;
var VUI_defResTreeBtn = "hud/treebtn.png";;
var VUI_defResScrollBtn = "hud/scrollbtn.png";;
var VUI_defResCheckBtn = "hud/check.png";;
// - Elements type -
var VUI_EltBackground = 0;;
var VUI_EltFrame = 1;;
var VUI_EltButton = 2;; // mode text or bitmap ? //G2DstrechAlphaBitmapToBackgroundBitmap / animated button
var VUI_EltLabel = 3;;
var VUI_EltText = 4;;
var VUI_EltEditText = 5;;
var VUI_EltSelect = 6;;
var VUI_EltFloatValue = 7;;
var VUI_EltList = 8;;
var VUI_EltListElement = 9;;
var VUI_EltMenu = 10;;
var VUI_EltBtnMenu = 11;;
var VUI_EltSubMenu = 12;;
var VUI_EltSlider = 13;;
var VUI_EltTable = 14;;
// - Element scroll type
var VUI_EltScrollV = 1;;
var VUI_EltScrollH = 2;;
// - Container types -
var VUIC_2D = 1;;
var VUIC_Material = 2;;
var VUIC_3D = 4;;
var VUIC_VR = 8;;
var VUIC_EXTERNAL = 16;;
// - Text size flags -
var VUI_TextStatic = 1;;
var VUI_TextAuto = 2;;
var VUI_TextAutoHeight = 4;;
// - Resources resize flags -
var VUI_ResStreched = 1;;
var VUI_ResSplited = 2;;
var VUI_ResKeepRatio = 4;;
// - Menu align
var iVUIMNU_ALIGNLEFT = 0;;
var iVUIMNU_ALIGNRIGHT = 1;;
var iVUIMNU_ALIGNTOP = 2;;
var iVUIMNU_ALIGNBOTTOM = 3;;
// - Text alignment
var iVUITEXT_HALIGNLEFT = 1;;
var iVUITEXT_HALIGNCENTER = 2;;
var iVUITEXT_HALIGNRIGHT = 4;;
var iVUITEXT_VALIGNTOP = 8;;
var iVUITEXT_VALIGNCENTER = 16;;
var iVUITEXT_VALIGNBOTTOM = 32;;
// - Text font type
var iVUITEXT_BOLD = 1;;
var iVUITEXT_ITALIC = 2;;
var iVUITEXT_HOLLOW = 4;;
//typeof lVUILabels [VUIlabel r1];; //!< list of scene 3D labels
var fVUIPIXELDENSITY = 1.0;;
//VR
var iVUIBASEVRWIDTH = 1920;;
var iVUIBASEVRHEIGHT = 1080;;
var iVUIBASEVRDIST = 0.8;;
var iVUIBASEVRMARGIN = 50.0;;
var iVUIBASEVRFOV = 45.0;;
var sVUIResourcesGroup = "V3DUIdefaultResources";;
var fVUIGlobalScaleFactor = 1.0;;
fun VUIupdateScreenSensity(viewstr)=
set fVUIPIXELDENSITY = if (_platform == SCOL_PLATFORM_ANDROID) then (if (_getDeviceScreenDensity != 1.0) then (1.0 /. _getDeviceScreenDensity *. 1.10) else 1.0) else if (_platform == SCOL_PLATFORM_IOS) then 1.0 else 1.0;
set fVUIPIXELDENSITY = fVUIPIXELDENSITY *. fVUIGlobalScaleFactor;
//addLogMessage strcatn "Screen density: "::(ftoa _getDeviceScreenDensity)::" to: "::(ftoa fVUIPIXELDENSITY)::nil;
0;;
/*
Fonts
*/
struct VUIfont =
[
VUIF_Font : ObjFont, //!< windows font
VUIF_BTfont : ObjBTFont, //!< openCV font
VUIF_sFontFace : S, //!< font face
VUIF_iFontFlags : I, //!< font flags : iVUITEXT_BOLD | iVUITEXT_ITALIC | iVUITEXT_HOLLOW
VUIF_iFontSize : I, //!< font size
VUIF_iFontType : I, //!< define if windows or openCV font is used
VUIF_tFontWoffset : [I I], //!< offset for windows font to match hardcoded BT font offset
VUIF_iColor : I, //!< font color
VUIF_iUsed : I //!< used by
] mkVUIfont;;
typeof lVUIFonts = [[S VUIfont] r1];;
/*
Themes
*/
struct VUIthemeRes =
[
VUITHR_pSource : S, //!< Resource file name
VUITHR_bgColor : I, //!< Resource background color
VUITHR_iBorder : I, //!< Resource border size
VUITHR_bdColor : I, //!< Resource border color
VUITHR_iFlags : I, //!< Resource resize flags
VUITHR_iNbStates : I, //!< Resource nb states
VUITHR_iNbCols : I, //!< Resource nb colons
VUITHR_iNbFrames : I, //!< Resource anim frames
VUITHR_iFramesPerSecond : I //!< Resource anim speed
] mkVUIthemeRes;;
struct VUIthemeFont =
[
VUITHF_sFontFace : S, //!< font face
VUITHF_iFontFlags : I, //!< font flags : iVUITEXT_BOLD | iVUITEXT_ITALIC | iVUITEXT_HOLLOW
VUITHF_iFontSize : I, //!< font size
VUITHF_iFontColor : I //!< font color
] mkVUIthemeFont;;
struct VUIthemeElt =
[
VUITHE_sName : S, //!< Resource name
VUITHE_res : VUIthemeRes, //!< Resource definition
VUITHE_font : VUIthemeFont //!< Resource font definition
] mkVUIthemeElt;;
struct VUIthemeDef =
[
VUITHD_sName : S, //!< Definition name
VUITHD_parent : VUItheme, //!< Definition parent
VUITHD_lElements : [[S VUIthemeElt] r1] //!< Definition list
] mkVUIthemeDef;;
struct VUItheme =
[
VUITH_sPath : S, //!< Theme file
VUITH_sName : S, //!< Theme name
VUITH_lDefinitions : [[S VUIthemeDef] r1] //!< Theme definition list
] mkVUItheme;;
typeof VUIdefaultTheme = VUItheme;;
fun VUIloadThemeElements(defstr, lres)=
if (lres == nil) then nil else
(
let hd lres -> emarkstr in
let XMLgetParam emarkstr "name" -> name in
let XMLgetMarkByValueFromMarkSons emarkstr "UIResource" -> rmarkstr in
let XMLgetMarkByValueFromMarkSons emarkstr "UIFont" -> fmarkstr in
let mkVUIthemeElt [name nil nil] -> estr in
(
if (rmarkstr == nil) then nil else
let XMLgetData rmarkstr -> path in
let htoi XMLgetParam rmarkstr "bgcolor" -> bgcolor in
let atoi XMLgetParam rmarkstr "border" -> border in
let if (border == nil) then 0 else border -> border in
let htoi XMLgetParam rmarkstr "borderColor" -> bdcolor in
let if (bdcolor == nil) then 0x000000 else bdcolor -> bdcolor in
let XMLgetBoolParam rmarkstr "keepRatio" -> ratio in
let XMLgetBoolParam rmarkstr "splited" -> split in
let if (split) then VUI_ResSplited else VUI_ResStreched -> flags in
let if (ratio) then flags | VUI_ResKeepRatio else flags -> flags in
let atoi XMLgetParam rmarkstr "states" -> states in
let atoi XMLgetParam rmarkstr "cols" -> cols in
let atoi XMLgetParam rmarkstr "frames" -> frames in
let atoi XMLgetParam rmarkstr "animFPS" -> fps in
let mkVUIthemeRes [path bgcolor border bdcolor flags states cols frames fps] -> thresstr in
set estr.VUITHE_res = thresstr;
if (fmarkstr == nil) then nil else
let XMLgetParam fmarkstr "face" -> face in
let XMLgetBoolParam fmarkstr "bold" -> bold in
let XMLgetBoolParam fmarkstr "hollow" -> hollow in
let XMLgetBoolParam fmarkstr "italic" -> italic in
let if (bold) then iVUITEXT_BOLD else 0 -> flags in
let if (hollow) then flags | iVUITEXT_HOLLOW else flags -> flags in
let if (italic) then flags | iVUITEXT_ITALIC else flags -> flags in
let atoi XMLgetParam fmarkstr "size" -> size in
let htoi XMLgetParam fmarkstr "color" -> color in
let mkVUIthemeFont [face flags size color] -> thfontstr in
set estr.VUITHE_font = thfontstr;
set defstr.VUITHD_lElements = [name estr]::defstr.VUITHD_lElements;
);
VUIloadThemeElements defstr tl lres;
);
0;;
fun VUIloadThemeDefinitions(thstr, ldef)=
if (ldef == nil) then nil else
(
let hd ldef -> emarkstr in
let XMLgetParam emarkstr "name" -> name in
let XMLgetMarksByValueFromMarkSons emarkstr "UIElements" -> lelt in
let mkVUIthemeDef [name thstr nil] -> defstr in
(
VUIloadThemeElements defstr lelt;
set thstr.VUITH_lDefinitions = [name defstr]::thstr.VUITH_lDefinitions;
);
VUIloadThemeDefinitions thstr tl ldef;
);
0;;
fun VUIloadTheme(file)=
let XMLload file -> xmlstr in
if (xmlstr == nil) then nil else
(
let XMLgetMarkByValue xmlstr "UITheme" -> thmarkstr in
let XMLgetParam thmarkstr "name" -> name in
let XMLgetMarksByValueFromMarkSons thmarkstr "UIDefinition" -> lelements in
let mkVUItheme [file name nil] -> thstr in
(
VUIloadThemeDefinitions thstr lelements;
XMLclose xmlstr;
thstr;
);
);;
fun VUIgetThemeElement(defstr, elt)=
switchstr defstr.VUITHD_lElements elt;;
fun VUIgetThemeDef(themestr, def)=
let switchstr themestr.VUITH_lDefinitions def -> defstr in
if (defstr) == nil then
switchstr themestr.VUITH_lDefinitions "common"
else defstr;;
/*! @ingroup v3DHUDApi
* \brief Split a theme reference between definition name and element name
*
* Prototype: fun [S] [S S]
*
* \param S : the theme reference
*
* \return [S S] : the definition name and element name
**/
fun VUIsplitThemeRef(themeref)=
let strfind "/" themeref 0 -> pos in
let strlen themeref -> length in
if (pos == nil) then
[themeref nil]
else if (pos == (length - 1)) then
[(substr themeref 0 pos) nil]
else
[(substr themeref 0 pos) (substr themeref (pos + 1) (length - pos - 1))];;
/*
Dialog box
*/
struct VUIDlg =
[
VUIDLG_container : VUIcontainer, //!< Dialog box container
VUIDLG_title : VUIelement, //!< Dialog box title
VUIDLG_frame : VUIelement, //!< Dialog box frame
VUIDLG_okBtn : VUIelement, //!< Dialog box frame
VUIDLG_cancelBtn : VUIelement, //!< Dialog box frame
VUIDLG_cbValidate : fun [VUIDlg I] I //!< Dialog box callback
] mkVUIDlg;;
/*
List control
*/
struct VUIListElement =
[
VUILE_list : VUIList, //!< List list
VUILE_element : VUIelement, //!< List element graphics
VUILE_parent : VUIListElement, //!< List parent
VUILE_children : [VUIListElement r1], //!< Sons list
VUILE_iState : I, //!< element state, fold / unfold
VUILE_sValue : S, //!< value
VUILE_sParam : S, //!< param
VUILE_cbSelect : fun [VUIListElement] I //!< callback on select
] mkVUIListElement;;
struct VUIList =
[
VUIL_container : VUIcontainer, //!< List container
VUIL_element : VUIelement, //!< List element
VUIL_scrollUp : VUIelement, //!< List scroll top element
VUIL_scrollDown : VUIelement, //!< List scroll bottom element
VUIL_lListElts : [VUIListElement r1], //!< Sons list
VUIL_tEltOffset : [I I], //!< Elements offset for sons (tree mode)
VUIL_tMargin : [I I], //!< Elements Text margin
VUIL_tScroll : [I I], //!< Elements scroll offset
VUIL_tContentSize : [I I], //!< Elements full size
VUIL_bMultiSelect : I, //!< List multi selection
VUIL_lSelected : [VUIListElement r1], //!< List selection
VUIL_cbSelect : fun [VUIList [VUIListElement r1]] I, //!< List callback on select
VUIL_trmScroll : Timer,
VUIL_sThemeRef : S //!< List theme ref
] mkVUIList;;
/*
Float control
*/
struct VUIFloat =
[
VUIF_container : VUIcontainer, //!< Float container
VUIF_element : VUIelement, //!< Float parent
VUIF_etext : VUIelement, //!< Float text element
VUIF_prevBtn : VUIelement, //!< Float prev btn
VUIF_nextBtn : VUIelement, //!< Float next btn
VUIF_fMin : F, //!< Float min
VUIF_fMax : F, //!< Float max
VUIF_fStep : F, //!< Float step
VUIF_iNbDec : I, //!< Float number decimal
VUIF_fValue : F, //!< Float value
VUIF_trm : Timer, //!< Float timer for incremental change
VUIF_cbChange : fun [VUIFloat F I] I //!< Float callback on change value
] mkVUIFloat;;
/*
Slider control
*/
struct VUISlider =
[
VUISL_container : VUIcontainer, //!< Slider container
VUISL_element : VUIelement, //!< Slider parent
VUISL_slider : VUIelement, //!< Slider
VUISL_fill : VUIelement, //!< Slider fill
VUISL_cursor : VUIelement, //!< Slider cursor
VUISL_text : VUIelement, //!< Slider text
VUISL_fMin : F, //!< Slider min
VUISL_fMax : F, //!< Slider max
VUISL_fStep : F, //!< Slider step
VUISL_iNbDec : I, //!< Slider number decimal
VUISL_fValue : F, //!< Slider value
VUISL_iDirection : I, //!< Slider direction
VUISL_iCursorSize : I, //!< Slider cursor width (in px)
VUISL_iTextPos : I, //!< Slider text position
VUISL_bClicking : I, //!< Slider click state
VUISL_cbChange : fun [VUISlider F] I //!< Slider callback on change value
] mkVUISlider;;
/*
Select control
*/
struct VUISelect =
[
VUIS_container : VUIcontainer, //!< Select container
VUIS_element : VUIelement, //!< Select parent
VUIS_list : VUIList, //!< Select list
VUIS_lValues : [S r1], //!< Select values
VUIS_sValue : S, //!< Select selected value
VUIS_tEltOffset : [I I], //!< Elements offset for sons (tree mode)
VUIS_tMargin : [I I], //!< Elements Text margin in list
VUIS_cbSelect : fun [VUISelect S] I, //!< Select callback on change value
VUIS_sThemeRef : S //!< Select theme ref
] mkVUISelect;;
/*
Table control
*/
struct VUITableLine =
[
VUITBL_table : VUITable, //!< Parent table
VUITBL_element : VUIelement, //!< Line
VUITBL_cells : tab VUIelement, //!< Cells
VUITBL_iHeight : I //!< Line height
]mkVUITableLine;;
struct VUITable =
[
VUITB_container : VUIcontainer, //!< Table container
VUITB_element : VUIelement, //!< Table parent
VUITB_tTableSize : [I I], //!< Table dimensions
VUITB_table : tab VUITableLine, //!< Table
VUITB_colWidth : tab I, //!< Widths of the columns
VUITB_iBorder : I, //!< Border size
VUITB_cbChange : fun [VUITable VUIelement I I S] I //!< Table callback on change value
]mkVUITable;;
/*
Menu control
*/
struct VUISubMenu =
[
VUIMS_btnMenu : VUIBtnMenu, //!< Parent menu button
VUIMS_parent : VUISubMenu, //!< Parent submenu
VUIMS_sValue : S, //!< Submenu value
VUIMS_lChildren : [VUISubMenu r1], //!< Submenu children
VUIMS_bCheck : I, //!< Submenu check mode
VUIMS_iCheckState : I, //!< Submenu check state
VUIMS_cbSelect : fun [VUISubMenu] I //!< Select callback on change value
] mkVUISubMenu;;
struct VUIBtnMenu =
[
VUIMB_parent : VUImenu, //!< Parent menu
VUIMB_element : VUIelement, //!< Menu parent
VUIMB_lSubMenus : [VUISubMenu r1], //!< Menu list
VUIMB_sValue : S, //!< Menu button value
VUIMB_iMode : I, //!< Menu button mode 0 text inside, 1 bubble text
VUIMB_bUnfoldChildren : I, //!< Menu unfold chlidren on show
VUIMB_tooltip : VUIelement, //!< Menu tooltip
VUIMB_list : VUIList, //!< Submenu list
VUIMB_cbSelect : fun [VUIBtnMenu] I //!< Select callback on change value
] mkVUIBtnMenu;;
struct VUImenu =
[
VUIM_container : VUIcontainer, //!< Menu container
VUIM_element : VUIelement, //!< Menu parent
VUIM_scrollMinus : VUIelement, //!< List scroll top / left element
VUIM_scrollPlus : VUIelement, //!< List scroll bottom / right element
VUIM_lBtnMenus : [VUIBtnMenu r1], //!< Menu list
VUIM_tEltOffset : [I I], //!< Menu offset for submenus
VUIM_tMargin : [I I], //!< Menu Text margin in list
VUIM_iAlignMode : I, //!< Menu alignment for submenus
VUIM_tScroll : [I I], //!< Menu scroll
VUIM_trmScroll : Timer, //!< Menu scroll timer
VUIM_selectedBtn : VUIBtnMenu, //!< Menu last selected button
VUIM_sThemeRef : S //!< Menu theme ref
] mkVUImenu;;
/*
VR Keyboard
*/
struct VUIkeyboard =
[
VUIK_session : V3Dsession,
VUIK_group : VUIcontainerGroup,
VUIK_txtContainer : VUIcontainer, //!< Keyboard container
VUIK_upContainer : VUIcontainer, //!< Keyboard container
VUIK_symContainer : VUIcontainer, //!< Keyboard container
VUIK_numContainer : VUIcontainer, //!< Keyboard container
VUIK_toolContainer : VUIcontainer, //!< Keyboard container
VUIK_iMode : I, //!< Keyboard mode 0 default, 1 text, 2 numeric
VUIK_bVisible : I //!< Keyboard state
] mkVUIkeyboard;;
typeof VUIdefVrKeyboard = VUIkeyboard;;
proto VUIshowVrKeyboard = fun [VUIkeyboard I] VUIkeyboard;;
proto VUIhideVrKeyboard = fun [VUIkeyboard] VUIkeyboard;;
var lVUIKeyTxt = ["q" 16 113 81]::["w" 17 119 87]::["e" 18 101 69]::["r" 19 114 82]::["t" 20 116 84]::["y" 21 121 89]::["u" 22 117 85]::["i" 23 105 73]::["o" 24 111 79]::["p" 25 112 80]::
["a" 30 97 65]::["s" 31 115 83]::["d" 32 100 68]::["f" 33 102 70]::["g" 34 103 71]::["h" 35 104 72]::["j" 36 106 74]::["k" 37 107 75]::["l" 38 108 76]::["'" 416 39 39]::
["Cap" 404 0 0]::["z" 44 122 90]::["x" 45 120 88]::["c" 46 99 67]::["v" 47 118 86]::["b" 48 98 66]::["n" 49 110 78]::["m" 50 109 77]::["!" 403 33 33]::["?" 50 63 63]::
["#+=" 0 0 0]::["@" 418 64 64]::["Space" 57 32 32]::["," 401 44 44]::["." 400 46 46]::nil;;
var lVUIKeySym = ["+" 78 43]::["-" 74 45]::["*" 55 42]::["/" 309 47]::["=" 411 61]::["%" 1024 37]::["<" 1024 60]::[">" 1024 62]::["$" 1024 36]::["#" 1024 35]::
["\"" 1024 34]::["'" 1024 39]::["(" 1024 40]::[")" 1024 41]::["[" 1024 91]::["]" 1024 93]::["_" 1024 95]::[":" 1024 58]::[";" 1024 59]::["?" 50 63]::
["\\" 1024 92]::["^" 1024 94]::["{" 1024 123]::["}" 1024 125]::["|" 1024 124]::["~" 1024 126]::["" (-4) 0]::
["abc" 0 0]::["@" 418 64]::["Space" 57 32]::["," 401 44]::["." 400 46]::nil;;
var lVUIKeyNum = ["1" 2 49]::["2" 3 50]::["3" 4 51]::["4" 5 52]::["5" 6 53]::["6" 7 54]::["7" 8 55]::["8" 9 56]::["9" 10 57]::["." 400 46]::["0" 11 48]::["-" 74 45]::nil;;
var lVUIKeyTool = ["Back" 14 8]::["Enter" 28 13]::["clear" 339 0]::["Hide" 1 0]::nil;;
/*
Fonts interface
*/
struct VUIfontInt =
[
VUIFI_Font : VUIfont, //!< font ref
VUIFI_bFromTheme : I, //!< font created from theme
VUIFI_tThemeInfos : [S S] //!< font theme def and name
] mkVUIfontInt;;
/*
Text control
*/
struct VUIText =
[
VUIT_parent : VUIelement, //!< Text parent
VUIT_font : VUIfontInt, //!< Text font interface
VUIT_sContent : S, //!< Text content
VUIT_bNumberOnly : I, //!< Text number only
VUIT_bIsPassword : I, //!< Text show dots
VUIT_tPos : [I I], //!< Text pos
VUIT_tSize : [I I], //!< Text size
VUIT_tMargin : [I I], //!< Text margin
VUIT_tCoords : [I I I I], //!< Text rect
VUIT_iAlign : I, //!< Text alignment flags
VUIT_bMultiline : I, //!< Text with multi ligne
VUIT_tScroll : [I I], //!< Text scroll offset
VUIT_bAutoScroll : I, //!< Text auto scroll
VUIT_tTextSize : [I I], //!< Text text content size
VUIT_iCursor : I, //!< Text show cursor
VUIT_iUpdateSize : I, //!< Text size flags
VUIT_scrollTop : VUIelement, //!< Text scroll top element
VUIT_scrollBottom : VUIelement, //!< Text scroll bottom element
VUIT_trmScroll : Timer, //!< Text scroll timer
VUIT_bNeedUpdate : I //!< Text need update
] mkVUIText;;
/*
Resources
*/
struct VUIRes =
[
VUIR_parent : VUIelement, //!< Resource parent
VUIR_pSource : P, //!< Resource file path
VUIR_resIndex : I, //!< Resource index in VUIresourceTab
VUIR_oBuffer : AlphaBitmap, //!< Resource buffer
VUIR_bgColor : I, //!< Resource background color
VUIR_iBorder : I, //!< Resource border size
VUIR_bdColor : I, //!< Resource border color
VUIR_iFocusedBorder : I, //!< Resource focused border size
VUIR_bFocusedColor : I, //!< Resource focused border color
VUIR_iFlags : I, //!< Resource resize flags
VUIR_iNbStates : I, //!< Resource nb states
VUIR_iCurState : I, //!< Resource current state
VUIR_iNbCols : I, //!< Resource nb colons
VUIR_iCurCol : I, //!< Resource current colon
VUIR_iNbFrames : I, //!< Resource anim frames
VUIR_iCurFrame : I, //!< Resource current anim frame
VUIR_iFramesPerSecond : I, //!< Resource current anim frame
VUIR_iTick : I, //!< Resource last tick time
VUIR_bEnable : I, //!< Resource enable state for updates
VUIR_bNeedUpdate : I, //!< Resource need update
VUIR_bJustUpdated : I, //!< Resource need update
VUIR_bFromTheme : I, //!< Resource made from theme
VUIR_tThemeInfos : [S S] //!< Resource theme def and name
] mkVUIRes;;
var iVUIMaxResources = 256;;
typeof VUIresourceTab = tab [P AlphaBitmap I];; //!< HUD Res bitmaps
typeof VUIanimatedResourcesList = [VUIRes r1];; //!< HUD Animated Resources to update
/*
Elements
*/
struct VUIelement =
[
VUIE_iType : I, //!< element type
VUIE_container : VUIcontainer, //!< element parent container
VUIE_parent : VUIelement, //!< element parent
VUIE_Text : VUIText, //!< element text
VUIE_resource : VUIRes, //!< element resource
VUIE_vPos : [F F], //!< element 2D position
VUIE_vSize : [F F], //!< element 2D size
VUIE_vContRect : [I I I I], //!< element children 2D size
VUIE_tPercent : [I I I I I I I I], //!< element 2D size ratio [(x pos is percent) (y pos is percent) (width is percent) (height is percent) (x offset) (y offset) (width offset) (height offset)]
VUIE_tAlign : [I I], //!< element 2D align
VUIE_bVisible : I, //!< element visibility
VUIE_bJustDraw : I, //!< element draw state
VUIE_tDrawCoords : [I I I I I I], //!< element current drawing coords
VUIE_tLocalCoords : [I I I I], //!< element local coords
VUIE_tGlobalCoords : [I I I I], //!< element global coords
VUIE_children : [VUIelement r1], //!< element children
VUIE_bIgnoreInput : I, //!< element ignore inputs
VUIE_iClick : I, //!< element click state
VUIE_iCheckState : I, //!< element check state
VUIE_iScrollMode : I, //!< element scroll mode
VUIE_tScroll : [I I], //!< element scroll offset
VUIE_scrollTop : VUIelement, //!< element scroll top element
VUIE_scrollBottom : VUIelement, //!< element scroll bottom element
VUIE_scrollLeft : VUIelement, //!< element scroll left element
VUIE_scrollRight : VUIelement, //!< element scroll right element
VUIE_trmScroll : Timer, //!< element scroll timer
VUIE_cbCheck : fun [VUIelement I] I, //!< element cbCheck
VUIE_cbClick : fun [VUIelement I I I I] I,//!< element cbClick
VUIE_cbUnClick : fun [VUIelement I I I I] I,//!< element cbUnclick
VUIE_cbFullClick : fun [VUIelement I I I I] I,//!< element cbUnclick
VUIE_cbMouseIn : fun [VUIelement] I, //!< element cbMouseIn
VUIE_cbMouseOut : fun [VUIelement] I, //!< element cbMouseOut
VUIE_cbMouseMove : fun [VUIelement I I I I] I,//!< element cbMouseMove
VUIE_cbMouseWheel : fun [VUIelement I I I I] I,//!< element cbMouseWheel
VUIE_cbFocused : fun [VUIelement I] I, //!< element cbFocused
VUIE_cbValidate : fun [VUIelement S I] I, //!< element cbValidate
VUIE_cbKeyDown : fun [VUIelement I] I, //!< element cbKeyDown
VUIE_cbKeyUp : fun [VUIelement I] I, //!< element cbKeyUp
VUIE_cbPreDraw : fun [VUIelement] I, //!< element cbPreDraw
VUIE_cbDraw : fun [VUIelement] I, //!< element cbDraw
VUIE_cbPostDraw : fun [VUIelement] I //!< element cbPostDraw
] mkVUIelement;;
/*
Widgets
*/
struct VUIWcont =
[
VUIW_view : V3Dview, //!< Container widget viewstr
VUIW_widget : SO3_WIDGET, //!< Container widget
VUIW_bOnBackground : I, //!< Container widget on background
VUIW_bOnMaterial : I, //!< Container widget mode
VUIW_bTopOnFocus : I, //!< Container have top on focus flag
VUIW_bExternal : I, //!< Container widget external
VUIW_bForeground : I, //!< Container have foreground flag
VUIW_fQuality : F, //!< Container widget quality
VUIW_vPos : [F F], //!< Container 2D position
VUIW_vSize : [F F], //!< Container 2D size
VUIW_tPercent : [I I I I I I I I], //!< Container 2D size ratio
VUIW_tAlign : [I I], //!< Container 2D align 1 for center 2 for right or bottom
VUIW_iOpacity : I, //!< Container opacity 0-100
VUIW_bFadeState : I, //!< Container fade state
VUIW_iFadeCur : F, //!< Container fade val
VUIW_iFadeTo : F, //!< Container fade destination
VUIW_iFadeSpeed : I, //!< Container fade speed
VUIW_cbFade : fun [VUIcontainer I] I, //!< Container fade callback
VUIW_iZorder : I, //!< Container widget Z order / Z position offset from camera for VR mode
VUIW_bEnableInputs : I, //!< Container enable inputs state
VUIW_material : SO3_MATERIAL, //!< Container widget material
VUIW_iTechnique : I, //!< Container widget technique
VUIW_iPass : I, //!< Container widget pass
VUIW_iTexture : I, //!< Container widget texture unit
VUIW_vMousePos : [[I [I I]] r1], //!< Container widget last move pos
VUIW_vClickPos : [[I [I I]] r1], //!< Container widget last click pos
VUIW_vClickTrans : [[I [I I]] r1], //!< Container widget last click trans
VUIW_tMouseInertia : [I I], //!< Container mouse inertia
VUIW_iInertiaTick : I, //!< Container mouse inertia tick
VUIW_iFadeTick : I, //!< Container fade animation tick
VUIW_trmTouchTimeOut : Timer, //!< Timer to enable mouse after a touch
VUIW_cbClick : fun [VUIcontainer I I I] I,//!< Container cbClick
VUIW_cbUnClick : fun [VUIcontainer I I I] I,//!< Container cbUnclick
VUIW_cbMouseIn : fun [VUIcontainer] I, //!< Container cbMouseIn
VUIW_cbMouseOut : fun [VUIcontainer] I, //!< Container cbMouseOut
VUIW_cbMouseMove : fun [VUIcontainer I I I] I,//!< Container cbMouseMove
VUIW_cbFocused : fun [VUIcontainer I] I //!< Container cbFocused
] mkVUIWcont;;
var VUI_ContSizePixel = 0;;
var VUI_ContSizeScale = 1;;
/*
3D interfaces
*/
struct VUI3Dcont =
[
VUI3D_session : V3Dsession, //!< session structure
VUI3D_target : SO3_OBJECT, //!< node to follow
VUI3D_node : SO3_OBJECT, //!< node used to manipulate the label
VUI3D_plane : SO3_OBJECT, //!< plane on which the label is displayed
VUI3D_material : SO3_MATERIAL, //!< Container material of the plane
VUI3D_texture : SO3_TEXTURE, //!< texture of the plane
VUI3D_vPos : [F F F], //!< Container 3D position
VUI3D_vOffset : [F F], //!< Container offset relative to its position
VUI3D_sName : S, //!< name of the 3D ui
VUI3D_iIndex : I, //!< index of the 3D ui
VUI3D_fScale : F, //!< scale factor
VUI3D_bAutoScale : I, //!< define if the label automatically scale to stay the same size on screen
VUI3D_fMaxAutoscaleDist : F, //!< Distance from the camera after which a 3D container with autoscale on stops scaling
VUI3D_bAutoTarget : I, //!< define if the label automatically scale to stay the same size on screen
VUI3D_bOnTop : I
] mkVUI3Dcont;;
/*
Container
*/
struct VUIcontainer =
[
VUICNT_iMode : I, //!< Container mode widget / VR 3D plan
VUICNT_group : VUIcontainerGroup, //!< Container parent group
VUICNT_strw : VUIWcont, //!< Container widget structure
VUICNT_str3d : VUI3Dcont, //!< Container VR structure
VUICNT_fScale : F, //!< Container buffer ratio to optim memory
VUICNT_iSizeMode : I, //!< Container resize mode
VUICNT_buffer : VUIelement, //!< Container draw buffer
VUICNT_extBuffer : [ObjBuff I I I], //!< Container draw external buffer
VUICNT_extSize : [I I], //!< Container draw external buffer last size
VUICNT_lElements : [VUIelement r1], //!< Container elements list
VUICNT_lastFocusedElt : VUIelement, //!< Container last focused element
VUICNT_lastMouseInElt : [[I VUIelement] r1], //!< Container last mouse in element
VUICNT_lastMouseClElt : [[I VUIelement] r1], //!< Container last mouse clicked element
VUICNT_bVisible : I, //!< Container visibility
VUICNT_bClearOnUpdate : I, //!< Container update mode
VUICNT_bNeedUpdate : I, //!< Container need update
VUICNT_bNeedResizeUpdate : I, //!< Container need update after resize
VUICNT_cbThemeUpdate : fun [VUIcontainer] I, //!< Container callback on theme update
VUICNT_cbPreUpdate : fun [VUIcontainer AlphaBitmap] I, //!< Container callback on pre update with AlphaBitmap buffer
VUICNT_cbPostUpdate : fun [VUIcontainer AlphaBitmap] I //!< Container callback on pre update with AlphaBitmap buffer
] mkVUIcontainer;;
struct VUIcontainerGroup =
[
VUICG_thm : VUItheme, //!< Group Theme
VUICG_lcntList : [VUIcontainer r1] //!< Group containers
] mkVUIcontainerGroup;;
typeof VUIcontainerEnableList = [VUIcontainer r1];;
typeof VUIcontainerAllList = [VUIcontainer r1];;
proto VUIsetElementBorder = fun [VUIelement I I] I;;
proto VUIsetElementFocusedBorder = fun [VUIelement I I] I;;
proto VUIsetFocusedContainer = fun [VUIcontainer] I;;
proto VUIsetContainerTopOnFocus = fun [VUIcontainer I] I;;
proto VUIsetContainerForeground = fun [VUIcontainer I] I;;
proto VUIshowContainer = fun [VUIcontainer I] I;;
proto VUIshowContainerExt = fun [VUIcontainer I fun [VUIcontainer I] I] I;;
/* ********************************************************************************************* /
Groups
/ ********************************************************************************************* */
fun VUIgetGroupTheme(groupstr)=
if (groupstr == nil) || (groupstr.VUICG_thm == nil) then
VUIdefaultTheme
else
groupstr.VUICG_thm;;
fun VUIgetContainerGroupTheme(contstr)=
if (contstr.VUICNT_group == nil) || (contstr.VUICNT_group.VUICG_thm == nil) then
VUIdefaultTheme
else
contstr.VUICNT_group.VUICG_thm;;
/* ********************************************************************************************* /
Font
/ ********************************************************************************************* */
/*! @ingroup VUIApi
* \brief Delete a VUIfont
*
* Prototype: fun [VUIfont] I
*
* \param VUIfont : font to delete
*
* \return I : 0
**/
fun VUIdelFont(fontstr)=
if (fontstr == nil) then nil else
(
set fontstr.VUIF_iUsed = fontstr.VUIF_iUsed - 1;
if (fontstr.VUIF_iUsed > 0) then nil else
(
let strcatn fontstr.VUIF_sFontFace::(itoa fontstr.VUIF_iFontSize)::(itoa fontstr.VUIF_iFontFlags)::(itoa fontstr.VUIF_iColor)::(itoa fontstr.VUIF_iFontType)::nil -> fname in
set lVUIFonts = remove_sid_from_listi lVUIFonts fname;
_DSfont fontstr.VUIF_Font;
_DSBTfont fontstr.VUIF_BTfont;
);
);
0;;
/*! @ingroup VUIApi
* \brief Get the size needed to write a text
*
* Prototype: fun [VUIfont S I I] [I I]
*
* \param VUIfont : font to use
* \param S : text
* \param I : maximum width for the text. If nil or <= 0, the text will take all the width needed
* \param I : alignement flags
* 1: iVUITEXT_HALIGNLEFT, 2: iVUITEXT_HALIGNCENTER, 4: iVUITEXT_HALIGNRIGHT, default: iVUITEXT_HALIGNLEFT,
* 8: iVUITEXT_VALIGNTOP, 16: iVUITEXT_VALIGNCENTER, 32: iVUITEXT_VALIGNBOTTOM, default: iVUITEXT_VALIGNTOP
*
* \return [I I] : width and height needed to write the text
**/
fun VUIgetTextSize(fontstr, text, maxwidth, alignflags)=
if (alignflags != 0) then nil else
set alignflags = iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP;
if ((text == nil) || (!strcmp text "")) then
(
if (maxwidth == nil || maxwidth <= 0) then
[0 0]
else
[maxwidth 0];
)
else if (fontstr.VUIF_iFontType == 0) then
(
//addLogMessage strcat "VUIgetTextSize: " text;
if (maxwidth == nil || maxwidth <= 0) then
_BTGETtextSize fontstr.VUIF_BTfont text
else
[maxwidth _BTGETtextAreaHeight fontstr.VUIF_BTfont text alignflags|BT_TEXT_WORD_WRAP maxwidth];
)
else
(
let fontstr.VUIF_tFontWoffset -> [xfoff yfoff] in
if (maxwidth == nil || maxwidth <= 0) then
(
let _GETstringSize fontstr.VUIF_Font text -> [w h] in
[(w + (2 * xfoff)) (h + (2 * yfoff))];
)
else
[maxwidth (_GETtextRectHeight fontstr.VUIF_Font text (maxwidth - (2 * yfoff))) + (2 * yfoff)];
);;
fun VUIgetAlignFlagsBT(flags)=
let 0 -> alignflags in
(
if (!(flags & iVUITEXT_HALIGNLEFT)) then nil else
set alignflags = alignflags | BT_TEXT_HORIZ_LEFT;
if (!(flags & iVUITEXT_HALIGNCENTER)) then nil else
set alignflags = alignflags | BT_TEXT_HORIZ_CENTERED;
if (!(flags & iVUITEXT_HALIGNRIGHT)) then nil else
set alignflags = alignflags | BT_TEXT_HORIZ_RIGHT;
if (!(flags & iVUITEXT_VALIGNTOP)) then nil else
set alignflags = alignflags | BT_TEXT_VERT_TOP;
if (!(flags & iVUITEXT_VALIGNCENTER)) then nil else
set alignflags = alignflags | BT_TEXT_VERT_CENTER;
if (!(flags & iVUITEXT_VALIGNBOTTOM)) then nil else
set alignflags = alignflags | BT_TEXT_VERT_BOTTOM;
alignflags;
);;
fun VUIgetAlignFlags(flags)=
let 0 -> alignflags in
(
if (!(flags & iVUITEXT_HALIGNLEFT)) then nil else
set alignflags = alignflags | TD_LEFT;
if (!(flags & iVUITEXT_HALIGNCENTER)) then nil else
set alignflags = alignflags | TD_CENTER;
if (!(flags & iVUITEXT_HALIGNRIGHT)) then nil else
set alignflags = alignflags | TD_RIGHT;
if (!(flags & iVUITEXT_VALIGNTOP)) then nil else
set alignflags = alignflags | TD_TOP;
if (!(flags & iVUITEXT_VALIGNCENTER)) then nil else
set alignflags = alignflags | TD_BASELINE;
if (!(flags & iVUITEXT_VALIGNBOTTOM)) then nil else
set alignflags = alignflags | TD_BOTTOM;
alignflags;
);;
/*! @ingroup VUIApi
* \brief Draw a text to a bitmap, within a defined area
*
* Prototype: fun [ObjBitmap VUIfont [I I I I] [I I] I I S] ObjBitmap
*
* \param ObjBitmap : alpha bitmap to draw on
* \param VUIfont : font to use
* \param [I I I I] : rect [x y w h]
* \param [I I] : offset [x y]
* \param I : color
* \param I : alignement flags
* 1: iVUITEXT_HALIGNLEFT, 2: iVUITEXT_HALIGNCENTER, 4: iVUITEXT_HALIGNRIGHT, default: iVUITEXT_HALIGNLEFT,
* 8: iVUITEXT_VALIGNTOP, 16: iVUITEXT_VALIGNCENTER, 32: iVUITEXT_VALIGNBOTTOM, default: iVUITEXT_VALIGNTOP
* \param S : text
*
* \return ObjBitmap : ObjBitmap with text on it
**/
fun VUIdrawTextBitmap(bmp, fontstr, rect, offset, fontcolor, alignflags, text)=
if (alignflags != 0) then nil else
set alignflags = iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP;
if (fontcolor != nil) then nil else
set fontcolor = fontstr.VUIF_iColor;
let sanitizeString text -> text in
if (fontstr.VUIF_iFontType == 0) then
let VUIgetAlignFlagsBT alignflags -> flags in
(
_BTDRAWtextAreaBitmap bmp fontstr.VUIF_BTfont rect offset flags|BT_TEXT_WORD_WRAP fontcolor text;
0;
)
else
let rect -> [x y w h] in
let offset -> [xoff yoff] in
let fontstr.VUIF_tFontWoffset -> [xfoff yfoff] in
let VUIgetAlignFlags alignflags -> flags in
let VUIgetTextSize fontstr text w alignflags -> [_ th] in
let [(x + xoff + xfoff) (y + yoff + yfoff) (w - xoff - (2 * xfoff)) (h - yoff - (2 * yfoff))] -> [tpx tpy tpw tph] in
(
_DRAWrectangleText bmp fontstr.VUIF_Font tpx tpy tpw tph fontcolor flags text;
0;
);
bmp;;
/*! @ingroup VUIApi
* \brief Draw a text to an alpha bitmap, within a defined area
*
* Prototype: fun [AlphaBitmap VUIfont [I I I I] [I I] I I S] AlphaBitmap
*
* \param AlphaBitmap : alpha bitmap to draw on
* \param VUIfont : font to use
* \param [I I I I] : rect [x y w h]
* \param [I I] : offset [x y]
* \param I : color
* \param I : alignement flags
* 1: iVUITEXT_HALIGNLEFT, 2: iVUITEXT_HALIGNCENTER, 4: iVUITEXT_HALIGNRIGHT, default: iVUITEXT_HALIGNLEFT,
* 8: iVUITEXT_VALIGNTOP, 16: iVUITEXT_VALIGNCENTER, 32: iVUITEXT_VALIGNBOTTOM, default: iVUITEXT_VALIGNTOP
* \param S : text
*
* \return AlphaBitmap : AlphaBitmap with text on it
**/
fun VUIdrawTextAlphaBitmap(abmp, fontstr, rect, offset, fontcolor, alignflags, text)=
//addLogMessage strcat "VUIdrawTextAlphaBitmap : " text;
//TODO : It might be better to take the alignment into account in the scroll offset rather than make text behave as if alignflags = iVUITEXT_VALIGNTOP if th > h.
// Doing so prevents to align the text to the bottom or center even if the text exceed the rect size in the generic function that is supposed to be VUIdrawTextAlphaBitmap.
// This behaviour is directly in the C code
if (alignflags != 0) then nil else
set alignflags = iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP;
if (fontcolor != nil) then nil else
set fontcolor = fontstr.VUIF_iColor;
let sanitizeString text -> text in
if (fontstr.VUIF_iFontType == 0) then
let VUIgetAlignFlagsBT alignflags -> flags in
(
_BTDRAWtextAreaAlphaBitmap abmp fontstr.VUIF_BTfont rect offset flags|BT_TEXT_WORD_WRAP fontcolor 255 text;
0;
)
else
let _GETalphaBitmaps abmp -> [bmpRgb bmp8] in
let rect -> [x y w h] in
let offset -> [xoff yoff] in
let fontstr.VUIF_tFontWoffset -> [xfoff yfoff] in
let VUIgetAlignFlags alignflags -> flags in
let VUIgetTextSize fontstr text w alignflags -> [_ th] in
let [(x + xoff + xfoff) (y + yoff + yfoff) (w - xoff - (2 * xfoff)) (h - yoff - (2 * yfoff))] -> [tpx tpy tpw tph] in
(
_DRAWrectangleText bmpRgb fontstr.VUIF_Font tpx tpy tpw tph fontcolor flags text;
_DRAWrectangleText8 bmp8 fontstr.VUIF_Font tpx tpy tpw tph 0xffffff flags text;
0;
);
abmp;;
fun VUIgetFontFaceBT(face)=
face;;
fun VUIgetFontFileBT(face)=
let _checkpack face -> pfont in
let if (pfont != nil) then pfont else
_checkpack strcatn VUI_BT_FONT_PATH::"/"::face::".ttf"::nil
-> pfont in
let if (pfont != nil) then pfont else
_checkpack strcatn VUI_BT_ASSET_FONT_PATH::"/"::face::".ttf"::nil
-> pfont in
if (pfont == nil) then
_checkpack strcatn VUI_BT_FONT_PATH::"/sans.ttf"::nil
else
pfont;;
fun VUIgetFontFace(face)=
if (!strcmpi face "serif") then
"Times New Roman"
else if (!strcmpi face "sans") then
"Microsoft Sans Serif"
else if (!strcmpi face "script") then
"Segoe Script"
else
face;;
fun VUIgetFontFlagsBT(flags)=
let 0 -> fontflags in
(
if (!(flags & iVUITEXT_BOLD)) then nil else
set fontflags = fontflags | BT_FONT_BOLD;
if (!(flags & iVUITEXT_ITALIC)) then nil else
set fontflags = fontflags | BT_FONT_ITALIC;
if (!(flags & iVUITEXT_HOLLOW)) then nil else
set fontflags = fontflags | BT_FONT_HOLLOW;
fontflags;
);;
fun VUIgetFontFlags(flags)=
let 0 -> fontflags in
(
if (!(flags & iVUITEXT_BOLD)) then nil else
set fontflags = fontflags | FF_WEIGHT;
if (!(flags & iVUITEXT_ITALIC)) then nil else
set fontflags = fontflags | FF_ITALIC;
if (!(flags & iVUITEXT_HOLLOW)) then nil else
set fontflags = fontflags | FF_HOLLOW;
fontflags;
);;
fun VUIgetFontByValues(face, size, flags, color, type)=
let strcatn face::(itoa size)::(itoa flags)::(itoa color)::(itoa type)::nil -> name in
switchstri lVUIFonts name;;
/*! @ingroup VUIApi
* \brief Create a VUIfont
*
* Prototype: fun [S I I I I I] VUIfont
*
* \param S : face
* \param I : size
* \param I : font flags 1: iVUITEXT_BOLD, 2: iVUITEXT_ITALIC, 4: iVUITEXT_HOLLOW
* \param I : font color
* \param I : If 0, all platforms will use the same font, if 1, Windows devices will use a different type of font allowing to use special characters
* \param I : 0 or 1 (init value to increment the ref count)
* \return VUIfont : the created font
**/
fun VUIaddFont(face, size, flags, color, auto, init)=
if ((face == nil) || (!strcmp face "")) then nil else
let if (_platform != SCOL_PLATFORM_WINDOWS) then 0 else auto && !VUI_FORCE_BT_TEXT -> type in
//let ftoi (fVUIPIXELDENSITY *. (itof size)) -> size in
let VUIgetFontByValues face size flags color type -> fontstr in
if (fontstr != nil) then
(
set fontstr.VUIF_iUsed = fontstr.VUIF_iUsed + init;
fontstr;
)
else
(
let if (type == 1) then nil else if VUI_FORCE_BT_FONTFILE then
_CRBTfontFromFile _channel (VUIgetFontFileBT face) size (VUIgetFontFlagsBT flags)|BT_FONT_ANTIALIAS 1.0
else
_CRBTfont _channel (VUIgetFontFaceBT face) size (VUIgetFontFlagsBT flags)|BT_FONT_ANTIALIAS 1.0
-> BTfont in
let if (type == 0) then nil else G2DcrFont _channel size+1 0 (VUIgetFontFlags flags)|FF_CLEARTYPE|FF_PIXEL (VUIgetFontFace face) -> font in
let mkVUIfont [font BTfont face flags size type [2 2] color init] -> fontstr in
let strcatn face::(itoa size)::(itoa flags)::(itoa color)::(itoa type)::nil -> fname in
(
//addLogMessage strcat "Add font : " fname;
set lVUIFonts = [fname fontstr]::lVUIFonts;
fontstr;
);
);;
/*! @ingroup VUIApi
* \brief Create a VUIfont
*
* Prototype: fun [S I I I I] VUIfont
*
* \param S : face
* \param I : size
* \param I : font flags
* \param I : font color
* 1: iVUITEXT_BOLD, 2: iVUITEXT_ITALIC, 4: iVUITEXT_HOLLOW
* \param I : If 0, all platforms will use the same font, if 1, Windows devices will use a different type of font allowing to use special characters
*
* \return VUIfont : the created font
**/
fun VUIcreateFont(face, size, flags, color, auto)=
VUIaddFont face size flags color auto 1;;
fun VUIcreateFontInterface(font)=
if (font == nil) then nil else
mkVUIfontInt[font 0 nil];;
fun VUIgetFontFromInterface(fontistr)=
fontistr.VUIFI_Font;;
fun VUIaddThemeFont(fthstr)=
if (fthstr == nil) then nil else
VUIaddFont fthstr.VUITHF_sFontFace fthstr.VUITHF_iFontSize fthstr.VUITHF_iFontFlags fthstr.VUITHF_iFontColor 1 0;;
/* Resources */
fun VUIgetResourceByIndex(index)=
if (VUIresourceTab == nil) then nil else
(
let VUIresourceTab.index -> [_ rbmp _] in
rbmp;
);;
fun VUIgetResourceByFile(file)=
if (VUIresourceTab == nil) then nil else
let _PtoScol file -> path in
let nil -> index in
let nil -> abmp in
(
let 0 -> i in
while ((i < iVUIMaxResources) && (index == nil)) do
(
let VUIresourceTab.i -> [pres rbmp nb] in
if (strcmpi path (_PtoScol pres)) then nil else
(
set abmp = rbmp;
set index = i;
set VUIresourceTab.i = [pres rbmp (nb + 1)];
//addLogMessage strcatn "Found resource "::path::" at: "::(itoa index)::nil;
);
set i = i + 1;
);
if (index == nil || abmp == nil) then
nil
else
[index abmp];
);;
fun VUIaddResourceIndex(file)=
if (VUIresourceTab != nil) then nil else
set VUIresourceTab = mktab iVUIMaxResources nil;
let nil -> index in
let nil -> abmp in
(
let 0 -> i in
while ((i < iVUIMaxResources) && (index == nil)) do
(
let VUIresourceTab.i -> relt in
let relt -> [pres obmp _] in
if (relt != nil) then nil else
(
//let _PtoScol file -> path in
//addLogMessage strcatn "Add resource "::path::" at: "::(itoa i)::nil;
set abmp = (G2DloadAlphaBmpFile _channel file);
set VUIresourceTab.i = [file abmp 1];
set index = i;
);
set i = i + 1;
);
[index abmp];
);;
fun VUIgetResourceVisualSize(resstr)=
let resstr.VUIR_resIndex -> index in
let VUIresourceTab.index -> [_ rbmp _] in
let _GETalphaBitmapSize rbmp -> [bw bh] in
let bw / (resstr.VUIR_iNbCols * resstr.VUIR_iNbFrames) -> ow in
let bh / (resstr.VUIR_iNbStates + 1) -> oh in
[ow oh];;
fun VUIelementNeedUpdate(eltstr, force)=
set eltstr.VUIE_container.VUICNT_bNeedUpdate = 1;
set eltstr.VUIE_container.VUICNT_buffer.VUIE_resource.VUIR_bNeedUpdate = eltstr.VUIE_container.VUICNT_bClearOnUpdate;
set eltstr.VUIE_resource.VUIR_bNeedUpdate = 1;
if (!force) then nil else
(
if (eltstr.VUIE_parent != nil) then
VUIelementNeedUpdate eltstr.VUIE_parent 0
else if (eltstr != eltstr.VUIE_container.VUICNT_buffer) then
VUIelementNeedUpdate eltstr.VUIE_container.VUICNT_buffer 0
else
nil;
);
if (VUI_DRAW_GLOBAL) then nil else
while (eltstr != nil) do
(
set eltstr.VUIE_resource.VUIR_bNeedUpdate = 1;
set eltstr = eltstr.VUIE_parent;
);
0;;
fun VUIgetViewSize(viewstr)=
let V3DgetDefaultViewport viewstr -> viewportstr in
let V3DgetViewportSize viewstr viewportstr -> [_ _ cvw cvh] in
//for mobile devices with scale
let if (viewstr.V3D_bVRmode) then [(max iVUIBASEVRWIDTH cvw) (max iVUIBASEVRHEIGHT cvh)] else [(max 100 cvw) (max 100 cvh)] -> [cvw cvh] in
let [ftoi ((itof cvw) *. (if (viewstr.V3D_bVRmode) then fVUIGlobalScaleFactor else fVUIPIXELDENSITY)) ftoi ((itof cvh) *. (if (viewstr.V3D_bVRmode) then fVUIGlobalScaleFactor else fVUIPIXELDENSITY))] -> [cvw cvh] in
let if (cvh <= 0) then 1 else if (viewstr.V3D_bVRmode) then iVUIBASEVRHEIGHT else cvh -> cvh in
[cvw cvh];;
fun VUIshowElement(eltstr, state)=
if (eltstr.VUIE_bVisible == state) then nil else
(
set eltstr.VUIE_bVisible = state;
VUIelementNeedUpdate eltstr 1;
);
0;;
fun VUIdestroyResource(resstr)=
if (resstr == nil) then nil else
(
//addLogMessage strcatn "Destroy resource : "::" > "::(_PtoScol resstr.VUIR_pSource)::nil;
//remove from animated list
if (resstr.VUIR_iNbFrames <= 1) then nil else
set VUIanimatedResourcesList = remove_from_list VUIanimatedResourcesList resstr;
//clean resource buffer if count <= 0
if (resstr.VUIR_resIndex == nil) then nil else
(
let resstr.VUIR_resIndex -> index in
let VUIresourceTab.index -> relt in
let relt -> [pres rbmp count] in
if (relt == nil) then nil else
(
//if (!strcmpi (_PtoScol resstr.VUIR_pSource) (_PtoScol pres)) then nil else
// addLogMessage strcatn "Warning!!!! Resource: "::(itoa index)::" > "::(_PtoScol pres)::" > "::(_PtoScol resstr.VUIR_pSource)::nil;
if ((count - 1) > 0) then
(
//addLogMessage strcatn "Free resource count : "::(itoa count)::" > "::(_PtoScol resstr.VUIR_pSource)::nil;
set VUIresourceTab.index = [pres rbmp (count - 1)];
)
else
(
//addLogMessage strcatn "Free resource: "::(itoa index)::" > "::(_PtoScol pres)::nil;
_DSalphaBitmap rbmp;
set VUIresourceTab.index = nil;
);
);
set resstr.VUIR_resIndex = nil;
);
//clean the buffer
if (resstr.VUIR_oBuffer == nil) then nil else
(
_DSalphaBitmap resstr.VUIR_oBuffer;
set resstr.VUIR_oBuffer = nil;
);
);
0;;
fun VUIloadResource(resstr)=
if (resstr.VUIR_pSource == nil) then nil else
(
let VUIgetResourceByFile resstr.VUIR_pSource -> res in
//let if (res != nil) then addLogMessage strcatn "load resource - already loaded : "::(_PtoScol resstr.VUIR_pSource)::nil else addLogMessage strcatn "load resource - not yet loaded : "::(_PtoScol resstr.VUIR_pSource)::nil -> _ in
let if (res != nil) then res else VUIaddResourceIndex resstr.VUIR_pSource -> [index abmp] in
(
/*
let VUIresourceTab.index -> relt in
let relt -> [pres rbmp count] in
if (!strcmpi (_PtoScol resstr.VUIR_pSource) (_PtoScol pres)) then nil else
addLogMessage strcatn "Warning!!!! Load Resource: "::(itoa index)::" > "::(_PtoScol pres)::" > "::(_PtoScol resstr.VUIR_pSource)::nil;
*/
//addLogMessage strcatn "load resource added : "::(_PtoScol resstr.VUIR_pSource)::nil;
set resstr.VUIR_resIndex = index;
);
);
0;;
fun VUImakeResource(eltstr, bgcolor, border, bdcolor, file, flags, nbstates, nbcols, nbframe, framepersec)=
let mkVUIRes [eltstr file nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil 0 1 0 0 nil] -> resstr in
let if (flags == nil) then VUI_ResStreched else flags -> flags in
let if (nbstates == nil) then 0 else nbstates -> nbstates in
let if (nbcols == nil) || (nbcols <= 0) then 1 else nbcols -> nbcols in
let if (nbframe == nil) || (nbframe <= 0) then 1 else nbframe -> nbframe in
let if (framepersec == nil) then 0 else framepersec -> framepersec in
let if bgcolor == nil then 0xffffff00 else bgcolor -> bgcolor in
let if border == nil then 0 else border -> border in
let if bdcolor == nil then 0x000000ff else bdcolor -> bdcolor in
(
//remove provious resource
if (eltstr.VUIE_resource == nil) then nil else
(
//addLogMessage strcatn "Destroy ressource : "::(_PtoScol eltstr.VUIE_resource.VUIR_pSource)::nil;
VUIdestroyResource eltstr.VUIE_resource;
);
set resstr.VUIR_bgColor = bgcolor;
set resstr.VUIR_iBorder = border;
set resstr.VUIR_bdColor = bdcolor;
set resstr.VUIR_iFocusedBorder = 0;
set resstr.VUIR_bFocusedColor = 0x0000ffff;
set resstr.VUIR_iFlags = flags;
set resstr.VUIR_iNbStates = nbstates;
set resstr.VUIR_iCurState = 0;
set resstr.VUIR_iNbCols = nbcols;
set resstr.VUIR_iCurCol = 0;
set resstr.VUIR_iNbFrames = nbframe;
set resstr.VUIR_iCurFrame = 0;
set resstr.VUIR_iFramesPerSecond = framepersec;
if (!eltstr.VUIE_container.VUICNT_bVisible) then nil else
set resstr.VUIR_bEnable = 1;
if (nbframe <= 1) then nil else
set VUIanimatedResourcesList = resstr::VUIanimatedResourcesList;
VUIloadResource resstr;
set eltstr.VUIE_resource = resstr;
VUIelementNeedUpdate eltstr 1;
resstr;
);;
fun VUIdestroyElement(eltstr)=
//addLogMessage strcat "destroy Element : " (_PtoScol eltstr.VUIE_resource.VUIR_pSource);
VUIdestroyResource eltstr.VUIE_resource;
if (eltstr.VUIE_Text == nil) then nil else
VUIdelFont eltstr.VUIE_Text.VUIT_font.VUIFI_Font;
if (eltstr.VUIE_parent == nil) then
set eltstr.VUIE_container.VUICNT_lElements = remove_from_list eltstr.VUIE_container.VUICNT_lElements eltstr
else
set eltstr.VUIE_parent.VUIE_children = remove_from_list eltstr.VUIE_parent.VUIE_children eltstr;
VUIelementNeedUpdate eltstr.VUIE_parent 0;
// need a copy
let eltstr.VUIE_children -> children in
while (children != nil) do
(
let hd children -> childstr in
VUIdestroyElement childstr;
set children = tl children;
);
set eltstr.VUIE_container.VUICNT_bNeedUpdate = 1;
0;;
fun VUIgetScrollableElement(eltstr)=
if (eltstr.VUIE_iType == VUI_EltBtnMenu || eltstr.VUIE_iType == VUI_EltList || eltstr.VUIE_iType == VUI_EltMenu || eltstr.VUIE_iType == VUI_EltListElement || eltstr.VUIE_iType == VUI_EltSlider || eltstr.VUIE_iType == VUI_EltSubMenu ||
(eltstr.VUIE_Text != nil) && eltstr.VUIE_Text.VUIT_bMultiline && (eltstr.VUIE_Text.VUIT_scrollBottom.VUIE_bVisible || eltstr.VUIE_Text.VUIT_scrollTop.VUIE_bVisible))
then nil else
if (eltstr.VUIE_iScrollMode) then
eltstr
else VUIgetScrollableElement eltstr.VUIE_parent;;
fun VUImakeFloat(contstr, eltstr, minval, maxval, step, nbdec, value)=
let mkVUIFloat [contstr eltstr nil nil nil minval maxval step nbdec value nil nil] -> floatstr in
(
floatstr;
);;
fun VUImakeSlider(contstr, eltstr, minval, maxval, step, nbdec, value, direction, cursorsize, textpos)=
let mkVUISlider [contstr eltstr nil nil nil nil minval maxval step nbdec value direction cursorsize textpos 0 nil] -> sliderstr in
(
sliderstr;
);;
fun VUImakeSelect(contstr, eltstr, lvalues, margin, offset, themeref)=
let mkVUISelect [contstr eltstr nil lvalues nil offset margin nil themeref] -> selectstr in
(
selectstr;
);;
fun VUImakeTable(contstr, elstr, tablesize, colwidths, border)=
let mkVUITable [contstr elstr tablesize nil colwidths border nil] -> tablestr in
let tablestr.VUITB_tTableSize -> [x y] in
(
set tablestr.VUITB_table = (mktab y nil);
let 0 -> i in
while (i < y) do
(
let mkVUITableLine [tablestr nil (mktab x nil) 0] -> linestr in
set tablestr.VUITB_table.i = linestr;
set i = i + 1;
);
tablestr;
);;
fun VUImakeMenu(contstr, eltstr, margin, offset, align, themeref)=
let mkVUImenu [contstr eltstr nil nil nil offset margin align [0 0] nil nil themeref] -> menustr in
(
menustr;
);;
fun VUImakeBtnMenu(menustr, eltstr, value, mode, unfoldchildren)=
let mkVUIBtnMenu [menustr eltstr nil value mode unfoldchildren nil nil nil] -> bmenustr in
(
set menustr.VUIM_lBtnMenus = lcat menustr.VUIM_lBtnMenus bmenustr::nil;
bmenustr;
);;
fun VUImakeSubMenu(bmenustr, pmenustr, value, check)=
let mkVUISubMenu [bmenustr pmenustr value nil check 0 nil] -> smenustr in
(
if (pmenustr == nil) then
set bmenustr.VUIMB_lSubMenus = lcat bmenustr.VUIMB_lSubMenus smenustr::nil
else
set pmenustr.VUIMS_lChildren = lcat pmenustr.VUIMS_lChildren smenustr::nil;
smenustr;
);;
fun VUImakeList(contstr, eltstr, eltoffset, margin, multiselect, themeref)=
let if (eltoffset == nil) then [0 0] else eltoffset -> eltoffset in
let if (multiselect == nil) then 0 else multiselect -> multiselect in
let mkVUIList [contstr eltstr nil nil nil eltoffset margin [0 0] [0 0] multiselect nil nil nil themeref] -> liststr in
(
liststr;
);;
fun VUImakeListElement(liststr, eltstr, parentstr, value, param)=
let mkVUIListElement [liststr eltstr parentstr nil 0 value param nil] -> leltstr in
(
if (parentstr == nil) then nil else
set parentstr.VUILE_children = lcat parentstr.VUILE_children leltstr::nil;
leltstr;
);;
fun VUIcountListHierarchy(eltstr)=
let eltstr.VUILE_parent -> pstr in
let 0 -> i in
(
while (pstr != nil) do
(
set pstr = pstr.VUILE_parent;
set i = i + 1;
);
i;
);;
fun VUIsetElementTheme(eltstr, defstr, element)=
let VUIgetThemeElement defstr element -> ethstr in
let ethstr.VUITHE_res -> rthstr in
(
if (rthstr) == nil then
(
VUImakeResource eltstr nil nil nil nil nil nil nil nil nil;
0;
)
else
(
//addLogMessage strcatn "set ressource : "::element::" > "::rthstr.VUITHR_pSource::nil;
let VUImakeResource eltstr rthstr.VUITHR_bgColor rthstr.VUITHR_iBorder rthstr.VUITHR_bdColor (_checkpack rthstr.VUITHR_pSource) rthstr.VUITHR_iFlags rthstr.VUITHR_iNbStates rthstr.VUITHR_iNbCols rthstr.VUITHR_iNbFrames rthstr.VUITHR_iFramesPerSecond -> resstr in
(
set resstr.VUIR_bFromTheme = 1;
set resstr.VUIR_tThemeInfos = [defstr.VUITHD_sName ethstr.VUITHE_sName];
);
0;
);
);
0;;
fun VUImakeElement(contstr, parentstr, pos, size, ratiosize, align, type)=
if (parentstr != nil && parentstr.VUIE_container != contstr) then
(
addLogMessage "[ERROR] VUImakeElement : The container is different from the parent element container!";
nil;
)
else
let pos -> [px py] in
let size -> [w h] in
let mkVUIelement [type contstr parentstr nil nil pos size [0 0 (ftoi w) (ftoi h)] ratiosize align 1 0 nil [(ftoi px) (ftoi py) (ftoi w) (ftoi h)] nil nil 0 0 0
0 [0 0] nil nil nil nil nil
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] -> eltstr in
(
//do not store cont element buffer
if ((parentstr == nil) && (contstr == nil)) then nil else
if (parentstr == nil) then
set contstr.VUICNT_lElements = lcat contstr.VUICNT_lElements eltstr::nil
else
(
set parentstr.VUIE_children = lcat parentstr.VUIE_children eltstr::nil;
//force btns to be on last list elements
if (parentstr.VUIE_scrollBottom == nil) then nil else
(
set parentstr.VUIE_children = remove_from_list parentstr.VUIE_children parentstr.VUIE_scrollBottom;
set parentstr.VUIE_children = lcat parentstr.VUIE_children parentstr.VUIE_scrollBottom::nil;
);
if (parentstr.VUIE_scrollTop == nil) then nil else
(
set parentstr.VUIE_children = remove_from_list parentstr.VUIE_children parentstr.VUIE_scrollTop;
set parentstr.VUIE_children = lcat parentstr.VUIE_children parentstr.VUIE_scrollTop::nil;
);
if (parentstr.VUIE_scrollLeft == nil) then nil else
(
set parentstr.VUIE_children = remove_from_list parentstr.VUIE_children parentstr.VUIE_scrollLeft;
set parentstr.VUIE_children = lcat parentstr.VUIE_children parentstr.VUIE_scrollLeft::nil;
);
if (parentstr.VUIE_scrollRight == nil) then nil else
(
set parentstr.VUIE_children = remove_from_list parentstr.VUIE_children parentstr.VUIE_scrollRight;
set parentstr.VUIE_children = lcat parentstr.VUIE_children parentstr.VUIE_scrollRight::nil;
);
);
VUIelementNeedUpdate eltstr 1;
eltstr;
);;
fun VUImake3Dcont(contstr, sessionstr, pos, offset, scale, autoscale, maxautoscaledist, autotarget, ontop)=
let mkVUI3Dcont [sessionstr nil nil nil nil nil nil nil nil nil nil nil nil nil nil] -> vrcontstr in
let if scale == nil then 1.0 else scale -> scale in
let if pos == nil then [0.0 0.0 0.0] else pos -> pos in
let if offset == nil then [0.0 0.0] else offset -> offset in
let V3DgetSession sessionstr -> scene in
(
set vrcontstr.VUI3D_vPos = pos;
set vrcontstr.VUI3D_vOffset = offset;
set vrcontstr.VUI3D_fScale = scale;
set vrcontstr.VUI3D_bAutoScale = autoscale;
set vrcontstr.VUI3D_fMaxAutoscaleDist = maxautoscaledist;
set vrcontstr.VUI3D_bAutoTarget = autotarget;
set vrcontstr.VUI3D_bOnTop = ontop;
set VUI_NameIndex = VUI_NameIndex + 1;
set vrcontstr.VUI3D_sName = strcat "VUI3D_" (itoa VUI_NameIndex);
let strcat vrcontstr.VUI3D_sName "_node" -> nodename in
set vrcontstr.VUI3D_node = SO3SceneNodeCreate scene nodename;
let strcat vrcontstr.VUI3D_sName "_plane" -> planename in
set vrcontstr.VUI3D_plane = SO3PlaneCreate scene sVUIResourcesGroup planename [1.0 1.0] nil nil;
let strcat vrcontstr.VUI3D_sName "_mat" -> matname in
set vrcontstr.VUI3D_material = SO3MaterialCreate scene matname sVUIResourcesGroup;
let strcat vrcontstr.VUI3D_sName "_3dconttex" -> texname in
set vrcontstr.VUI3D_texture = SO3TextureCreate scene texname nil sVUIResourcesGroup 2 2;
SO3ObjectSetVisible vrcontstr.VUI3D_plane 0 1;
SO3ObjectSetFlags vrcontstr.VUI3D_node iNodeFlagVUI;
SO3ObjectSetFlags vrcontstr.VUI3D_plane iNodeFlagVUI;
SO3MaterialSetPassCullingEnable vrcontstr.VUI3D_material 0 0 0;
SO3MaterialSetReceiveShadows vrcontstr.VUI3D_material 0;
SO3MaterialSetIgnoreSlicePlane vrcontstr.VUI3D_material 1;
SO3MaterialSetPassDepthCheckEnabled vrcontstr.VUI3D_material 0 0 !ontop;
SO3ObjectSetRenderQueue vrcontstr.VUI3D_plane if (ontop) then 95 else 70;
SO3ObjectSetMouseForeGround vrcontstr.VUI3D_plane ontop;
SO3MaterialSetPassLighting vrcontstr.VUI3D_material 0 0 0;
SO3ObjectSetCastShadows vrcontstr.VUI3D_plane 0;
SO3MaterialSetTexture vrcontstr.VUI3D_material vrcontstr.VUI3D_texture 0 0 0;
SO3EntitySetMaterial vrcontstr.VUI3D_plane vrcontstr.VUI3D_material 0;
SO3ObjectLink vrcontstr.VUI3D_plane vrcontstr.VUI3D_node;
SO3ObjectSetOrientation vrcontstr.VUI3D_plane SO3MathsEulerPYRToQuat [SO3MathsDegreeToRadian (-.90.0) SO3MathsDegreeToRadian 180.0 0.0];
SO3ObjectSetPosition vrcontstr.VUI3D_node pos;
let offset -> [xoff yoff] in
SO3ObjectSetPosition vrcontstr.VUI3D_plane [xoff yoff 0.0];
set contstr.VUICNT_str3d = vrcontstr;
);;
fun VUImakeWcont(contstr, viewstr, xpos, ypos, width, height, ratiosize, align, opacity, zorder)=
let mkVUIWcont [viewstr nil 0 0 0 0 0 1.0 [xpos ypos] [width height] ratiosize align opacity 0 nil nil 0 nil zorder 1 nil nil nil nil nil nil nil [0 0] 0 0 nil nil nil nil nil nil nil] -> wcontstr in
(
//make container buffer
if (contstr.VUICNT_buffer == nil) then nil else
VUIdestroyElement contstr.VUICNT_buffer;
set contstr.VUICNT_buffer = VUImakeElement nil nil [0.0 0.0] wcontstr.VUIW_vSize nil nil VUI_EltBackground;
set contstr.VUICNT_buffer.VUIE_container = contstr;
set contstr.VUICNT_strw = wcontstr;
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) "common" -> defstr in
VUIsetElementTheme contstr.VUICNT_buffer defstr "background";
wcontstr;
);;
fun VUIdestroyWcontainer(contwstr)=
V3DremoveWidgetControl (V3DgetDefaultViewport contwstr.VUIW_view) contwstr.VUIW_widget;
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetDestroy contwstr.VUIW_widget;
0;;
fun VUImakeContainer(type, groupstr)=
let mkVUIcontainer [type groupstr nil nil nil nil nil nil nil nil nil nil nil nil 1 1 1 nil nil nil] -> contstr in
(
set contstr.VUICNT_fScale = 1.0;
set contstr.VUICNT_bVisible = 0;
set contstr.VUICNT_iSizeMode = VUI_ContSizeScale; //if (_platform != SCOL_PLATFORM_WINDOWS && _platform != SCOL_PLATFORM_APPLE && _platform != SCOL_PLATFORM_LINUX) then VUI_ContSizeScale else VUI_ContSizePixel;
set VUIcontainerAllList = contstr::VUIcontainerAllList;
if (groupstr == nil) then nil else
set groupstr.VUICG_lcntList = contstr::groupstr.VUICG_lcntList;
contstr;
);;
fun VUImakeKeyboard(sessionstr, groupstr, mode)=
let mkVUIkeyboard [sessionstr groupstr nil nil nil nil nil mode 0] -> keybstr in
(
keybstr;
);;
/*! @ingroup VUIApi
* \brief Delete a 3D container
*
* Prototype: fun [VUI3Dcont] I
*
* \param VUI3Dcont : 3d container to delete
*
* \return I : 0
**/
fun VUIdestroy3DContainer(vrcontstr)=
SO3ObjectDestroy vrcontstr.VUI3D_plane;
SO3ObjectDestroy vrcontstr.VUI3D_node;
SO3MaterialDestroy vrcontstr.VUI3D_material;
SO3TextureDestroy vrcontstr.VUI3D_texture;
0;;
/*! @ingroup v3DHUDApi
* \brief Destroy a 3D container
*
* Prototype: fun [VUIcontainer] I
*
* \param VUIcontainer : the 3d container
*
* \return I : return 0
**/
fun VUIdestroyContainer(contstr)=
set VUIcontainerEnableList = remove_from_list VUIcontainerEnableList contstr;
set VUIcontainerAllList = remove_from_list VUIcontainerAllList contstr;
if (contstr.VUICNT_group == nil) then nil else
set contstr.VUICNT_group.VUICG_lcntList = remove_from_list contstr.VUICNT_group.VUICG_lcntList contstr;
VUIdestroyWcontainer contstr.VUICNT_strw;
set contstr.VUICNT_strw = nil;
VUIdestroyElement contstr.VUICNT_buffer;
set contstr.VUICNT_buffer = nil;
VUIdestroy3DContainer contstr.VUICNT_str3d;
set contstr.VUICNT_str3d = nil;
let contstr.VUICNT_lElements -> leltstr in
while (leltstr != nil) do
(
VUIdestroyElement hd leltstr;
set leltstr = tl leltstr;
);
if (!VUIdefVrKeyboard.VUIK_bVisible) then nil else
VUIhideVrKeyboard VUIdefVrKeyboard;
0;;
fun VUIgetContainerBufferSize(contstr)=
if ((contstr.VUICNT_iMode == VUIC_EXTERNAL) && (contstr.VUICNT_extBuffer != nil)) then
let contstr.VUICNT_extBuffer -> [_ w h _] in
[w h]
else
_GETalphaBitmapSize contstr.VUICNT_buffer.VUIE_resource.VUIR_oBuffer;;
fun VUIscaleCoords(vec, scale)=
let vec -> [x y w h _ _] in
[ftoi ((itof x) *. scale) ftoi ((itof y) *. scale) ftoi ((itof w) *. scale) ftoi ((itof h) *. scale)];;
fun VUIunscaleCoords(vec, scale)=
let vec -> [x y w h _ _] in
[ftoi ((itof x) /. scale) ftoi ((itof y) /. scale) ftoi ((itof w) /. scale) ftoi ((itof h) /. scale)];;
fun VUIscaleCoords2(vec, scale)=
let vec -> [x y w h] in
[ftoi ((itof x) *. scale) ftoi ((itof y) *. scale) ftoi ((itof w) *. scale) ftoi ((itof h) *. scale)];;
fun VUIunscaleCoords2(vec, scale)=
let vec -> [x y w h] in
[ftoi ((itof x) /. scale) ftoi ((itof y) /. scale) ftoi ((itof w) /. scale) ftoi ((itof h) /. scale)];;
fun VUIscaleVec(vec, scale)=
let vec -> [x y] in
[ftoi ((itof x) *. scale) ftoi ((itof y) *. scale)];;
fun VUIunscaleVec(vec, scale)=
let vec -> [x y] in
[ftoi ((itof x) /. scale) ftoi ((itof y) /. scale)];;
fun VUIscaleValue(val, scale)=
ftoi (val *. scale);;
fun VUIunscaleValue(val, scale)=
ftoi (val /. scale);;
fun VUIreplaceAllText(text, repchar, state)=
if (!state) then text else
let nil -> ndata in
let strextr text -> l in
(
if l == nil then nil else
let sizelist l -> size in
let 0 -> i in
(
while i < size do
(
let nth_list l i -> elem in
let strcatnSep elem " " -> line in
let strlen line -> ls in
let "" -> nline in
(
let 0 -> s in
while (s < ls) do
(
set nline = strcat nline repchar;
set s = s + 1;
);
if i == 0 then
set ndata = nline
else
set ndata = strcatn ndata::"\n"::nline::nil;
);
set i = i + 1;
);
);
ndata;
);;
fun VUIcomputeEposSize(eltstr, vw, vh)=
let eltstr.VUIE_vSize -> [width height] in
let eltstr.VUIE_vPos -> [posx posy] in
let eltstr.VUIE_tPercent -> [xp yp wp hp xo yo wo ho] in
let eltstr.VUIE_tAlign -> [ax ay] in
let eltstr.VUIE_resource -> resstr in
let if xp then (ftoi (((itof vw) *. posx) /. 100.0)) + xo else ftoi posx -> px in
let if yp then (ftoi (((itof vh) *. posy) /. 100.0)) + yo else ftoi posy -> py in
let if wp then
if xp then
(ftoi (((itof vw) *. (posx +. width)) /. 100.0)) + wo - (px - xo)
else
(ftoi (((itof vw) *. width) /. 100.0)) + wo
else
ftoi width
-> pw in
let if hp then
if yp then
(ftoi (((itof vh) *. (posy +. height)) /. 100.0)) + ho - (py - yo)
else
(ftoi (((itof vh) *. height) /. 100.0)) + ho
else
ftoi height
-> ph in
let 0 -> rxoff in
let 0 -> ryoff in
let if ((resstr.VUIR_iFlags & VUI_ResKeepRatio) && (resstr.VUIR_resIndex != nil)) then
let VUIgetResourceVisualSize resstr -> [bw bh] in
let (pw * bh) / bw -> rnh in
if ((vh - ((abs py) + rnh)) < 0) then
let ((vh * bw) / bh) -> rpw in
(
set rxoff = (pw - rpw) / 2;
[rpw ph]
)
else
(
set ryoff = (ph - rnh) / 2;
[pw rnh]
)
else
[pw ph]
-> [pw ph] in
(
let eltstr.VUIE_Text -> textstr in
if (textstr == nil) then nil else
(
let if (textstr.VUIT_sContent == nil) then if textstr.VUIT_iCursor then "|" else "" else if textstr.VUIT_iCursor then strcat textstr.VUIT_sContent "|" else textstr.VUIT_sContent -> text in
if (textstr.VUIT_iUpdateSize == VUI_TextStatic) then
(
let textstr.VUIT_tMargin -> [mx my] in
let textstr.VUIT_tPos -> [tx ty] in
let textstr.VUIT_tSize -> [tw th] in
let if (tw == 0) then (pw - tx - (mx * 2)) else tw -> tw in
let if (th == 0) then (ph - ty - (my * 2)) else th -> th in
let if (!textstr.VUIT_bNeedUpdate) then
let textstr.VUIT_tTextSize -> [ptw pth] in
[tw pth]
else
VUIgetTextSize textstr.VUIT_font.VUIFI_Font text tw textstr.VUIT_iAlign -> textsize in
let if (textsize != nil) then textsize else [10 10] -> [ttw tth] in
(
set textstr.VUIT_tCoords = [(tx + mx) (ty + my) tw th];
set textstr.VUIT_tTextSize = [ttw tth];
);
0;
)
else
(
let textstr.VUIT_tPos -> [tx ty] in
let textstr.VUIT_tMargin -> [mx my] in
let if (textstr.VUIT_iUpdateSize == VUI_TextAutoHeight) then
if (!textstr.VUIT_bNeedUpdate) then
let textstr.VUIT_tTextSize -> [ptw pth] in
[(pw - (mx * 2)) pth]
else
VUIgetTextSize textstr.VUIT_font.VUIFI_Font text (pw - (mx * 2)) textstr.VUIT_iAlign
else
if (!textstr.VUIT_bNeedUpdate) then
textstr.VUIT_tTextSize
else
VUIgetTextSize textstr.VUIT_font.VUIFI_Font text 0 textstr.VUIT_iAlign
-> textsize in
let if (textsize != nil) then textsize else [10 10] -> [tw th] in
(
set textstr.VUIT_tTextSize = [tw th];
set pw = tw + (mx * 2);
set ph = th + (my * 2);
set textstr.VUIT_tCoords = [(mx + tx) (my + ty) tw th];
);
0;
);
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 0;
);
let if (ax == 1) then ((vw - pw) / 2) + px else if (ax == 2) then (vw - pw) - px else rxoff + px -> px in
let if (ay == 1) then ((vh - ph) / 2) + py else if (ay == 2) then (vh - ph) - py else ryoff + py -> py in
[px py pw ph];
);;
fun VUIcomputeWposSize(contstr, vw, vh)=
let contstr.VUICNT_strw -> contwstr in
let contwstr.VUIW_vSize -> [width height] in
let contwstr.VUIW_vPos -> [posx posy] in
let contwstr.VUIW_tPercent -> [px py pw ph xo yo wo ho] in
let contwstr.VUIW_tAlign -> [ax ay] in
let contstr.VUICNT_buffer.VUIE_resource -> resstr in
let if pw then (ftoi ((width *. (itof vw)) /. 100.0)) + wo else VUIunscaleValue width contstr.VUICNT_fScale -> pw in
let if ph then (ftoi ((height *. (itof vh)) /. 100.0)) + ho else VUIunscaleValue height contstr.VUICNT_fScale -> ph in
let if px then (ftoi ((posx *. (itof vw)) /. 100.0)) + xo else VUIunscaleValue posx contstr.VUICNT_fScale -> px in
let if py then (ftoi ((posy *. (itof vh)) /. 100.0)) + yo else VUIunscaleValue posy contstr.VUICNT_fScale -> py in
let 0 -> rxoff in
let 0 -> ryoff in
let if ((resstr.VUIR_iFlags & VUI_ResKeepRatio) && (resstr.VUIR_resIndex != nil)) then
let VUIgetResourceVisualSize resstr -> [bw bh] in
let (pw * bh) / bw -> rnh in
if ((vh - ((abs py) + rnh)) < 0) then
let ((vh * bw) / bh) -> rpw in
(
set rxoff = (pw - rpw) / 2;
[rpw ph]
)
else
(
set ryoff = (ph - rnh) / 2;
[pw rnh]
)
else
[pw ph]
-> [pw ph] in
let if (ax == 1) then ((vw - pw) / 2) + px else if (ax == 2) then (vw - pw) - px else rxoff + px -> px in
let if (ay == 1) then ((vh - ph) / 2) + py else if (ay == 2) then (vh - ph) - py else ryoff + py -> py in
(
set contstr.VUICNT_buffer.VUIE_tGlobalCoords = [px py pw ph];
set contstr.VUICNT_buffer.VUIE_tLocalCoords = [px py pw ph];
[px py pw ph];
);;
fun VUIshowContainerW(contwstr, state)=
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetSetVisibility contwstr.VUIW_widget state;
0;;
fun VUIupdateResourceBuffer(resstr, width, height)=
set resstr.VUIR_bJustUpdated = 0;
//no need to update size
if (width == nil || height == nil) then nil else
let _GETalphaBitmapSize resstr.VUIR_oBuffer -> [bw bh] in
if ((resstr.VUIR_oBuffer != nil) && (bw == width) && (bh == height)) then nil else
(
if (resstr.VUIR_oBuffer == nil) then nil else
_DSalphaBitmap resstr.VUIR_oBuffer;
let _CRbitmap _channel width height -> bmp24 in
let _CRbitmap8 _channel width height -> bmp8 in
(
set resstr.VUIR_oBuffer = _CRalphaBitmap _channel bmp24 bmp8 nil nil;
_DSbitmap bmp24;
_DSbitmap8 bmp8;
);
set resstr.VUIR_bNeedUpdate = 1;
);
if (!resstr.VUIR_bNeedUpdate) then nil else
(
let VUIgetResourceByIndex resstr.VUIR_resIndex -> obmp in
if (obmp == nil) then
(
let _GETalphaBitmaps resstr.VUIR_oBuffer -> [bmp bmp8] in
let ftoi (((itof (G2DgetAlphaFromColor resstr.VUIR_bgColor)) /. 126.0) *. 255.0) -> alpha in
//let ftoi (((itof (G2DgetAlphaFromColor resstr.VUIR_parent.VUIE_container.VUICNT_buffer.VUIE_resource.VUIR_bgColor)) /. 126.0) *. 255.0) -> alpha2 in
//let max alpha2 alpha -> alpha in
let G2Drgba2rgb resstr.VUIR_bgColor -> rgb in
(
_FILLbitmap bmp rgb;
_FILLbitmap8 bmp8 alpha;
if (resstr.VUIR_iBorder <= 0) then nil else
let G2Drgba2rgb resstr.VUIR_bdColor -> bdrgb in
let ftoi (((itof (G2DgetAlphaFromColor resstr.VUIR_bdColor)) /. 126.0) *. 255.0) -> balpha in
(
_BTDRAWrect bmp [0 0 width height] bdrgb resstr.VUIR_iBorder nil nil;
_BTDRAWrect8 bmp8 [0 0 width height] (make_rgb balpha balpha balpha) resstr.VUIR_iBorder nil nil;
);
if (resstr.VUIR_iFocusedBorder <= 0) then nil else
let G2Drgba2rgb resstr.VUIR_bFocusedColor -> bdrgb in
let ftoi (((itof (G2DgetAlphaFromColor resstr.VUIR_bFocusedColor)) /. 126.0) *. 255.0) -> balpha in
(
_BTDRAWrect bmp [0 0 width height] bdrgb resstr.VUIR_iFocusedBorder nil nil;
_BTDRAWrect8 bmp8 [0 0 width height] (make_rgb balpha balpha balpha) resstr.VUIR_iFocusedBorder nil nil;
);
set resstr.VUIR_bNeedUpdate = 0;
0;
);
)
else
(
let _GETalphaBitmapSize obmp -> [bw bh] in
let bw / (resstr.VUIR_iNbCols * resstr.VUIR_iNbFrames) -> ow in
let bh / (resstr.VUIR_iNbStates + 1) -> oh in
let ow * ((resstr.VUIR_iNbFrames * resstr.VUIR_iCurCol) + resstr.VUIR_iCurFrame) -> ox in
let if (!resstr.VUIR_iNbStates) then 0 else oh * (if (resstr.VUIR_iNbStates < resstr.VUIR_iCurState) then if (resstr.VUIR_iCurState == 3) then 0 else (min resstr.VUIR_iNbStates resstr.VUIR_iCurState) else resstr.VUIR_iCurState) -> oy in
G2DstrechAlphaBitmapRectToBackgroundBitmap obmp [ox oy ow oh] resstr.VUIR_oBuffer if (resstr.VUIR_iFlags & VUI_ResSplited) then 1 else 0;
if (resstr.VUIR_iBorder <= 0) then nil else
let _GETalphaBitmaps resstr.VUIR_oBuffer -> [bmp bmp8] in
let G2Drgba2rgb resstr.VUIR_bdColor -> bdrgb in
let ftoi (((itof (G2DgetAlphaFromColor resstr.VUIR_bdColor)) /. 126.0) *. 255.0) -> balpha in
(
_BTDRAWrect bmp [0 0 width height] bdrgb resstr.VUIR_iBorder nil nil;
_BTDRAWrect8 bmp8 [0 0 width height] (make_rgb balpha balpha balpha) resstr.VUIR_iBorder nil nil;
);
if (resstr.VUIR_iFocusedBorder <= 0) then nil else
let _GETalphaBitmaps resstr.VUIR_oBuffer -> [bmp bmp8] in
let G2Drgba2rgb resstr.VUIR_bFocusedColor -> bdrgb in
let ftoi (((itof (G2DgetAlphaFromColor resstr.VUIR_bFocusedColor)) /. 126.0) *. 255.0) -> balpha in
(
_BTDRAWrect bmp [0 0 width height] bdrgb resstr.VUIR_iFocusedBorder nil nil;
_BTDRAWrect8 bmp8 [0 0 width height] (make_rgb balpha balpha balpha) resstr.VUIR_iFocusedBorder nil nil;
);
set resstr.VUIR_bNeedUpdate = 0;
0;
);
let resstr.VUIR_parent.VUIE_Text -> textstr in
if ((textstr == nil) || (!strcmp textstr.VUIT_sContent "") && (resstr.VUIR_parent.VUIE_iType != VUI_EltEditText)) then
(
if (!textstr.VUIT_bMultiline) then nil else
let textstr.VUIT_tScroll -> [_ scy] in
(
set textstr.VUIT_scrollTop.VUIE_bVisible = 0;
set textstr.VUIT_scrollBottom.VUIE_bVisible = 0;
set textstr.VUIT_tScroll = [0 0];
set textstr.VUIT_bAutoScroll = 0;
);
)
else
let VUIreplaceAllText textstr.VUIT_sContent "*" textstr.VUIT_bIsPassword -> content in
let if (content == nil) then "" else content -> content in
let if (textstr.VUIT_iCursor == 1) then strcat content "|" else if (textstr.VUIT_iCursor == 2) then strcat content " " else content -> text in
let textstr.VUIT_tTextSize -> [tw th] in
let textstr.VUIT_tCoords -> [_ _ cw ch] in
(
// auto scroll
if !textstr.VUIT_bAutoScroll then nil else
let if tw < cw then 0 else (-(tw - cw)) -> offx in
let if th < ch then 0 else (-(th - ch)) -> offy in
(
set textstr.VUIT_tScroll = [offx offy];
set textstr.VUIT_bAutoScroll = 0;
);
//show scroll buttons
if (!textstr.VUIT_bMultiline) then nil else
let textstr.VUIT_tScroll -> [_ scy] in
(
set textstr.VUIT_scrollTop.VUIE_bVisible = if (scy < 0) then 1 else 0;
set textstr.VUIT_scrollBottom.VUIE_bVisible = if (th > ch) && (scy > (-(th - ch))) then 1 else 0;
);
VUIdrawTextAlphaBitmap resstr.VUIR_oBuffer textstr.VUIT_font.VUIFI_Font textstr.VUIT_tCoords textstr.VUIT_tScroll textstr.VUIT_font.VUIFI_Font.VUIF_iColor textstr.VUIT_iAlign text;
0;
);
set resstr.VUIR_bJustUpdated = 1;
);
0;;
fun VUIgetElementInCoord(eltlist, x, y)=
if (eltlist == nil) then nil else
(
let hd eltlist -> eltstr in
let eltstr.VUIE_tGlobalCoords -> [dx dy dw dh] in
let VUIunscaleCoords (if (VUI_DRAW_GLOBAL) then eltstr.VUIE_tDrawCoords else [dx dy dw dh 0 0]) eltstr.VUIE_container.VUICNT_fScale -> coords in
if ((eltstr.VUIE_tDrawCoords != nil) && eltstr.VUIE_bVisible && (isCoordInRect x y coords)) then
(
//look for child in coord
let revertlist eltstr.VUIE_children -> children in
let VUIgetElementInCoord children x y -> child in
if ((child == nil) || (child.VUIE_bIgnoreInput && !child.VUIE_Text.VUIT_scrollTop.VUIE_bVisible && !child.VUIE_Text.VUIT_scrollBottom.VUIE_bVisible)) then
if (eltstr.VUIE_bIgnoreInput && !eltstr.VUIE_Text.VUIT_scrollTop.VUIE_bVisible && !eltstr.VUIE_Text.VUIT_scrollBottom.VUIE_bVisible) then
VUIgetElementInCoord tl eltlist x y
else
eltstr
else
child;
)
else
VUIgetElementInCoord tl eltlist x y;
);;
fun VUIbuildAllElementsList(refstr, eltlist)=
if (eltlist == nil) then nil else
let eltlist -> [eltstr next] in
if (refstr != eltstr) then
(
let if (!eltstr.VUIE_bVisible || eltstr.VUIE_bIgnoreInput || (eltstr.VUIE_resource.VUIR_iCurState == 3) || (eltstr.VUIE_iType == nil) || (eltstr.VUIE_iType == VUI_EltFrame) || (eltstr.VUIE_iType == VUI_EltBackground) ||
(eltstr.VUIE_iType == VUI_EltLabel) || (eltstr.VUIE_iType == VUI_EltText) || (eltstr.VUIE_iType == VUI_EltTable) || (eltstr.VUIE_iType == VUI_EltSubMenu) ||
(eltstr.VUIE_iType == VUI_EltList) || (eltstr.VUIE_iType == VUI_EltMenu) || (eltstr.VUIE_iType == VUI_EltFloatValue)) then
VUIbuildAllElementsList refstr eltstr.VUIE_children
else
eltstr::VUIbuildAllElementsList refstr eltstr.VUIE_children
-> children in
lcat children VUIbuildAllElementsList refstr next;
)
else
VUIbuildAllElementsList refstr next;;
fun getElementsCenterDirection(eltstr1, eltstr2, dir)=
let eltstr1.VUIE_tGlobalCoords -> [sx sy sw sh] in
let eltstr2.VUIE_tGlobalCoords -> [dx dy dw dh] in
let [sx + (sw / 2) sy + (sh / 2)] -> [x1 y1] in
/*let if (dir == (-1)) then
let [dx + dw dy + (dh / 2)] -> [x2 y2] in
[x2 y2]
else if (dir == 1) then
let [dx dy + (dh / 2)] -> [x2 y2] in
[x2 y2]
else if (dir == 2) then
let [dx + (dw / 2) dy + dh] -> [x2 y2] in
[x2 y2]
else
let [dx + (dw / 2) dy] -> [x2 y2] in
[x2 y2]
-> [x2 y2] in*/
let [dx + (dw / 2) dy + (dh / 2)] -> [x2 y2] in
let getVector2dAngle [x1 y1] [x2 y2] -> ang in
let if ang >. 180.0 then ang -. 360.0 else if ang <. (-.180.0) then ang +. 360.0 else ang -> ang in
let (sqr itof(x1 - x2)) +. (sqr itof(y1 - y2)) -> dist in
[ang dist];;
fun getElementClosest(refstr, eltstr1, eltstr2, dir)=
let 75.0 -> tolerance in
let refstr.VUIE_tGlobalCoords -> [rx ry rw rh] in
let if (eltstr1 != nil) then
getElementsCenterDirection refstr eltstr1 dir
else
[nil nil]
-> [ang1 dist1] in
let if (eltstr2 != nil) then
getElementsCenterDirection refstr eltstr2 dir
else
[nil nil]
-> [ang2 dist2] in
let if (dir == (-1)) then
-.90.0
else if (dir == 1) then
90.0
else if (dir == 2) then
0.0
else
180.0
-> tang in
let if ((dir == (-2)) || (dir == 2)) then
(if ((ang1 != nil) && ((ang1 >. (-.tang -. tolerance)) && (ang1 <. (-.tang +. tolerance))) || ((ang1 >. (tang -. tolerance)) && (ang1 <. (tang +. tolerance)))) then [(if (ang1 <. 0.0) then absf (-.tang -. ang1) else absf (tang -. ang1)) 1] else [0.0 0])
else
(if ((ang1 != nil) && (ang1 >. (tang -. tolerance)) && (ang1 <. (tang +. tolerance))) then [absf (tang -. ang1) 1] else [0.0 0])
-> [aa1 a1] in
let if ((dir == (-2)) || (dir == 2)) then
(if ((ang2 != nil) && ((ang2 >. (-.tang -. tolerance)) && (ang2 <. (-.tang +. tolerance))) || ((ang2 >. (tang -. tolerance)) && (ang2 <. (tang +. tolerance)))) then [(if (ang2 <. 0.0) then absf (-.tang -. ang2) else absf (tang -. ang2)) 1] else [0.0 0])
else
(if ((ang2 != nil) && (ang2 >. (tang -. tolerance)) && (ang2 <. (tang +. tolerance))) then [absf (tang -. ang2) 1] else [0.0 0])
-> [aa2 a2] in
(
if ((((dist1 == nil) || (dist2 <. dist1)) && ((a2 && !a1) || (a2 && (aa2 <. (tolerance *. 0.5))) || (a2 && (aa2 <=. aa1)))) ||
(a2 && a1 && (aa2 <. (tolerance *. 0.5)) && (aa1 >. (tolerance *. 0.25)) && (aa2 <. aa1)) || (a2 && !a1))
then
eltstr2
else
eltstr1;
);;
fun VUIgetNextElement(eltstr, dir)=
let eltstr.VUIE_tGlobalCoords -> [dx dy dw dh] in
let nil -> found in
(
//Search in children first
let VUIbuildAllElementsList eltstr eltstr.VUIE_children -> eltlist in
(
while (eltlist != nil) do
(
let hd eltlist -> tstr in
set found = getElementClosest eltstr found tstr dir;
set eltlist = tl eltlist;
);
);
//Search in same parents
let VUIbuildAllElementsList eltstr eltstr.VUIE_parent.VUIE_children -> eltlist in
if (found != nil) then nil else
(
while (eltlist != nil) do
(
let hd eltlist -> tstr in
set found = getElementClosest eltstr found tstr dir;
set eltlist = tl eltlist;
);
);
//Search in container
if (found != nil) then nil else
let VUIbuildAllElementsList eltstr eltstr.VUIE_container.VUICNT_lElements -> eltlist in
(
while (eltlist != nil) do
(
let hd eltlist -> tstr in
set found = getElementClosest eltstr found tstr dir;
set eltlist = tl eltlist;
);
);
found;
);;
fun VUIdrawElement(contstr, eltstr)=
if (eltstr.VUIE_tDrawCoords == nil) then nil else
if ((VUI_DRAW_GLOBAL || (eltstr.VUIE_parent == nil)) && (contstr.VUICNT_iMode == VUIC_EXTERNAL) && (contstr.VUICNT_extBuffer != nil)) then
(
let contstr.VUICNT_extBuffer -> [buff bw bh bc] in
let _GETalphaBitmaps eltstr.VUIE_resource.VUIR_oBuffer -> [bmp bmp8] in
let _BTGETbitmapBuffer8 bmp8 -> abuffer in
let _BTGETbitmapBufferExt bmp -> [obmp obw obh obc] in
let eltstr.VUIE_tDrawCoords -> [dx dy dw dh npx npy] in
(
_BTBLENDalphaBitmapsBuffer buff bw bh bc [dx dy dw dh] obmp obw obh obc [npx npy dw dh] abuffer ((itof contstr.VUICNT_strw.VUIW_iOpacity) *. 0.01);
);
0;
)
else
(
let if (VUI_DRAW_GLOBAL) then
contstr.VUICNT_buffer.VUIE_resource
else if (eltstr.VUIE_parent != nil) then
eltstr.VUIE_parent.VUIE_resource
else
contstr.VUICNT_buffer.VUIE_resource
-> res in
let eltstr.VUIE_tDrawCoords -> [dx dy dw dh npx npy] in
(
set eltstr.VUIE_bJustDraw = 1;
_BTBLENDalphaBitmaps res.VUIR_oBuffer [dx dy dw dh] eltstr.VUIE_resource.VUIR_oBuffer [npx npy dw dh] 1.0;
//_MGalphaBitmap res.VUIR_oBuffer dx dy eltstr.VUIE_resource.VUIR_oBuffer npx npy dw dh;
/*
let _GETalphaBitmaps res.VUIR_oBuffer -> [buff abuff] in
let _GETalphaBitmaps eltstr.VUIE_resource.VUIR_oBuffer -> [dbuff dabuff] in
(
_SPLUSbitmap8 abuff dx dy dw dh dabuff npx npy;
_CPalphaBitmap buff dx dy eltstr.VUIE_resource.VUIR_oBuffer npx npy dw dh;
);
addLogMessage strcatn "draw at: "::(itoa dx)::" "::(itoa dy)::nil;
if (((VUIgetResourceByIndex res.VUIR_resIndex) == nil) && (eltstr.VUIE_parent.VUIE_resource.VUIR_resIndex == nil)) then
(
let _GETalphaBitmaps eltstr.VUIE_resource.VUIR_oBuffer -> [dbuff dabuff] in
(
_CPbitmap24 buff dx dy dbuff npx npy dw dh nil;
_CPbitmap8 abuff dx dy dabuff npx npy dw dh nil;
);
0;
)
else
(
_CPalphaBitmap buff dx dy eltstr.VUIE_resource.VUIR_oBuffer npx npy dw dh;
0;
); */
0;
);
);
0;;
fun VUImakeElementDrawCoords(eltstr)=
let if (VUI_DRAW_GLOBAL) then eltstr.VUIE_tGlobalCoords else eltstr.VUIE_tLocalCoords -> [dx dy dw dh] in
let if (VUI_DRAW_GLOBAL) then
if (eltstr.VUIE_parent == nil) then
// Compute the correct coords for the elements with no parents
/*let eltstr.VUIE_container.VUICNT_buffer.VUIE_tGlobalCoords -> [_ _ cw ch] in
let if (dx + dw) > cw then (cw - dx) else dw -> nw in
let if (dy + dh) > ch then (ch - dy) else dh -> nh in
[dx dy nw nh 0 0]*/
[dx dy dw dh 0 0]
else
let eltstr.VUIE_parent.VUIE_tDrawCoords -> [px py pw ph pox poy] in
let if (dx > (px + pw)) || ((dx + dw) < px) then nil else if (dx < px) then px else dx -> nx in
let if (dy > (py + ph)) || ((dy + dh) < py) then nil else if (dy < py) then py else dy -> ny in
let if (dx + dw) > (px + pw) then ((px + pw) - nx) else dw - (nx - dx) -> nw in
let if (dy + dh) > (py + ph) then ((py + ph) - ny) else dh - (ny - dy) -> nh in
let nx - dx -> npx in
let ny - dy -> npy in
[nx ny nw nh npx npy]
else
[dx dy dw dh 0 0]
-> [nx ny nw nh npx npy] in
set eltstr.VUIE_tDrawCoords = if ((nx == nil) || (ny == nil)) then nil else [nx ny nw nh npx npy];
0;;
fun VUIupdateElementCoords(contstr, eltstr)=
let if (eltstr.VUIE_parent != nil) then
eltstr.VUIE_parent.VUIE_tGlobalCoords
else
let VUIgetContainerBufferSize contstr -> [pw ph] in
[0 0 pw ph]
-> [vx vy vw vh] in
let if ((eltstr.VUIE_parent != nil) && ((eltstr != eltstr.VUIE_parent.VUIE_scrollLeft) && (eltstr != eltstr.VUIE_parent.VUIE_scrollRight) &&
(eltstr != eltstr.VUIE_parent.VUIE_scrollTop) && (eltstr != eltstr.VUIE_parent.VUIE_scrollBottom))) then
eltstr.VUIE_parent.VUIE_tScroll
else
[0 0]
-> [offx offy] in
let VUIcomputeEposSize eltstr vw vh -> [dx dy dw dh] in
(
let eltstr.VUIE_parent.VUIE_vContRect -> [tx ty tw th] in
set eltstr.VUIE_parent.VUIE_vContRect = [(min tx dx) (min ty dy) (max tw (dx + dw)) (max th (dy + dh))];
set eltstr.VUIE_tLocalCoords = [(dx + offx) (dy + offy) dw dh];
let vx + dx -> dx in
let vy + dy -> dy in
set eltstr.VUIE_tGlobalCoords = [(dx + offx) (dy + offy) dw dh];
);
0;;
fun VUIupdateElement(contstr, eltstr)=
let if (eltstr.VUIE_parent != nil) then
eltstr.VUIE_parent.VUIE_tGlobalCoords
else
let VUIgetContainerBufferSize contstr -> [pw ph] in
[0 0 pw ph]
-> [vx vy vw vh] in
let if ((eltstr.VUIE_parent != nil) && ((eltstr != eltstr.VUIE_parent.VUIE_scrollLeft) && (eltstr != eltstr.VUIE_parent.VUIE_scrollRight) &&
(eltstr != eltstr.VUIE_parent.VUIE_scrollTop) && (eltstr != eltstr.VUIE_parent.VUIE_scrollBottom))) then
eltstr.VUIE_parent.VUIE_tScroll
else
[0 0]
-> [offx offy] in
let VUIcomputeEposSize eltstr vw vh -> [dx dy dw dh] in
(
VUIupdateResourceBuffer eltstr.VUIE_resource dw dh;
let eltstr.VUIE_parent.VUIE_vContRect -> [tx ty tw th] in
set eltstr.VUIE_parent.VUIE_vContRect = [(min tx dx) (min ty dy) (max tw (dx + dw)) (max th (dy + dh))];
set eltstr.VUIE_tLocalCoords = [(dx + offx) (dy + offy) dw dh];
let vx + dx -> dx in
let vy + dy -> dy in
set eltstr.VUIE_tGlobalCoords = [(dx + offx) (dy + offy) dw dh];
VUImakeElementDrawCoords eltstr;
);
0;;
fun VUIisFocusedInput()=
let 0 -> input in
(
let VUIcontainerEnableList -> list in
while ((list != nil) && !input) do
(
let hd list -> contstr in
(
if (contstr.VUICNT_lastFocusedElt.VUIE_iType != VUI_EltEditText) then nil else
set input = 1;
);
set list = tl list;
);
input;
);;
fun VUIsetFocusedElement(contstr, eltstr)=
if (contstr == VUIdefVrKeyboard.VUIK_txtContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_upContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_symContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_numContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_toolContainer) then nil else
if (contstr.VUICNT_lastFocusedElt == eltstr) then
(
if (contstr.VUICNT_lastFocusedElt.VUIE_iType != VUI_EltEditText) then nil else
(
//show virtual keyboard if needed
if (contstr.VUICNT_strw.VUIW_view.V3D_bVRmode && !VUIdefVrKeyboard.VUIK_bVisible) then
(
VUIshowVrKeyboard VUIdefVrKeyboard if (contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_bNumberOnly) then 2 else 0;
0;
)
else if ((_platform != SCOL_PLATFORM_ANDROID) && (_platform != SCOL_PLATFORM_IOS)) then nil else
(
_ShowSoftKeyboard 1;
0;
);
);
)
else
(
if (contstr.VUICNT_lastFocusedElt == nil) then nil else
(
//remove outline
if (contstr.VUICNT_lastFocusedElt.VUIE_resource.VUIR_iFocusedBorder == 0) then nil else
(
VUIsetElementFocusedBorder contstr.VUICNT_lastFocusedElt 0 0xffffffff;
set contstr.VUICNT_lastFocusedElt.VUIE_container.VUICNT_bClearOnUpdate = 1;
);
//remove as animated resource for cursor blink
if (contstr.VUICNT_lastFocusedElt.VUIE_iScrollMode || contstr.VUICNT_lastFocusedElt.VUIE_iType == VUI_EltEditText) then
(
set contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_bAutoScroll = 0;
set contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_iCursor = 0;
set contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_bNeedUpdate = 1;
VUIelementNeedUpdate contstr.VUICNT_lastFocusedElt 0;
set VUIanimatedResourcesList = remove_from_list VUIanimatedResourcesList contstr.VUICNT_lastFocusedElt.VUIE_resource;
if (contstr.VUICNT_lastFocusedElt.VUIE_iType != VUI_EltEditText) then nil else
(
//hide virtual keyboard
if (contstr.VUICNT_strw.VUIW_view.V3D_bVRmode) then
(
VUIhideVrKeyboard VUIdefVrKeyboard;
0;
)
else if ((_platform != SCOL_PLATFORM_ANDROID) && (_platform != SCOL_PLATFORM_IOS)) then nil else
(
_ShowSoftKeyboard 0;
0;
);
//validate event
if (!contstr.VUICNT_strw.VUIW_bEnableInputs || contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_bMultiline) then nil else
exec contstr.VUICNT_lastFocusedElt.VUIE_cbValidate with [contstr.VUICNT_lastFocusedElt contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_sContent 0];
);
)
else nil;
exec contstr.VUICNT_lastFocusedElt.VUIE_cbFocused with [contstr.VUICNT_lastFocusedElt 0];
);
if (eltstr == nil) then nil else
(
exec eltstr.VUIE_cbFocused with [eltstr 1];
//add as animated resource for cursor blink
if (eltstr.VUIE_iScrollMode || eltstr.VUIE_iType == VUI_EltEditText) then
(
set VUIanimatedResourcesList = eltstr.VUIE_resource::VUIanimatedResourcesList;
VUIelementNeedUpdate eltstr 0;
if (eltstr.VUIE_iType != VUI_EltEditText) then nil else
(
set eltstr.VUIE_Text.VUIT_bAutoScroll = 1;
if (contstr.VUICNT_strw.VUIW_view.V3D_bVRmode) then
(
VUIshowVrKeyboard VUIdefVrKeyboard if (eltstr.VUIE_Text.VUIT_bNumberOnly) then 2 else 0;
0;
)
else if ((_platform != SCOL_PLATFORM_ANDROID) && (_platform != SCOL_PLATFORM_IOS)) then nil else
(
_ShowSoftKeyboard 1;
0;
);
);
)
else nil;
);
set contstr.VUICNT_lastFocusedElt = eltstr;
0;
);
0;;
fun VUIgetListContentSize(liststr, lestrlist, size, allstate)=
if (lestrlist == nil) then size else
(
let hd lestrlist -> lestr in
(
let liststr.VUIL_tEltOffset -> [ox oy] in
let lestr.VUILE_element.VUIE_tLocalCoords -> [ex ey ew eh] in
let if (lestr.VUILE_children == nil) then ew else ew + 24 -> ew in
let size -> [sw sh] in
let VUIcountListHierarchy lestr -> nboff in
set size = [(max (ew + (ox * nboff)) sw) (sh + eh + oy)];
if ((lestr.VUILE_iState == 0) && !allstate) then nil else
set size = VUIgetListContentSize liststr lestr.VUILE_children size allstate;
);
VUIgetListContentSize liststr (tl lestrlist) size allstate;
);;
fun VUIgetListFullContentSize(liststr, allstate)=
let liststr.VUIL_tEltOffset -> [ox oy] in
let liststr.VUIL_tMargin -> [mx my] in
let VUIgetListContentSize liststr liststr.VUIL_lListElts liststr.VUIL_tMargin allstate -> [lw lh] in
[(lw + mx * 2) (lh + my - oy)];;
fun VUIupdateElementsCoords(contstr, eltlist)=
if (eltlist == nil) then nil else
(
let hd eltlist -> eltstr in
(
if (!eltstr.VUIE_bVisible || (eltstr.VUIE_iType == VUI_EltListElement) || (eltstr.VUIE_iType == VUI_EltBtnMenu)) then nil else
VUIupdateElementCoords contstr eltstr;
VUIupdateElementsCoords contstr tl eltlist;
);
);
0;;
fun VUIupdateElements(contstr, eltlist)=
if (eltlist == nil) then nil else
(
let hd eltlist -> eltstr in
(
let if (eltstr.VUIE_parent == nil) then
eltstr.VUIE_container.VUICNT_buffer.VUIE_bJustDraw
else
eltstr.VUIE_parent.VUIE_bJustDraw
-> pupdate in
if (!eltstr.VUIE_bVisible || (eltstr.VUIE_iType == VUI_EltListElement) || (eltstr.VUIE_iType == VUI_EltBtnMenu)) then nil else
let eltstr.VUIE_vContRect -> [ptx pty ptw pth] in
let eltstr.VUIE_tLocalCoords -> [_ _ ocw och] in
(
set eltstr.VUIE_vContRect = [0 0 0 0];
VUIupdateElement contstr eltstr;
if (eltstr.VUIE_cbPreDraw == nil) then nil else
exec eltstr.VUIE_cbPreDraw with [eltstr];
//Scrolling
if (!eltstr.VUIE_iScrollMode) then nil else
(
//update elements to get the correct rect
VUIupdateElementsCoords contstr eltstr.VUIE_children;
//manage scroll on resize
let eltstr.VUIE_tLocalCoords -> [_ _ dw dh] in
let [(dw - ocw) (dh - och)] -> [ppw pph] in
let eltstr.VUIE_tScroll -> [scx scy] in
if ((ppw == 0) && (pph == 0)) then nil else
set eltstr.VUIE_tScroll = [if (scx == 0) then 0 else (min 0 (scx + ppw)) if (scy == 0) then 0 else (min 0 (scy + pph))];
//manage scroll on sons change in cbPreDraw
let eltstr.VUIE_tScroll -> [scx scy] in
let eltstr.VUIE_vContRect -> [tx ty tw th] in
let [(tw - ptw) (th - pth)] -> [ppw pph] in
if ((ppw == 0) && (pph == 0)) then nil else
set eltstr.VUIE_tScroll = [if (scx == 0) then 0 else (min 0 (scx - ppw)) if (scy == 0) then 0 else (min 0 (scy - pph))];
//show scroll buttons
let eltstr.VUIE_tLocalCoords -> [_ _ cw ch] in
let eltstr.VUIE_vContRect -> [tx ty tw th] in
(
let eltstr.VUIE_tScroll -> [scx scy] in
(
if !(eltstr.VUIE_iScrollMode & VUI_EltScrollV) then nil else
(
set eltstr.VUIE_scrollTop.VUIE_bVisible = if (scy < 0) then 1 else 0;
set eltstr.VUIE_scrollBottom.VUIE_bVisible = if (th > ch) && (scy > (-(th - ch))) then 1 else 0;
);
if !(eltstr.VUIE_iScrollMode & VUI_EltScrollH) then nil else
(
set eltstr.VUIE_scrollLeft.VUIE_bVisible = if (scx < 0) then 1 else 0;
set eltstr.VUIE_scrollRight.VUIE_bVisible = if (tw > cw) && (scx > (-(tw - cw))) then 1 else 0;
);
);
);
);
if (!VUI_DRAW_GLOBAL || (!contstr.VUICNT_bClearOnUpdate && !eltstr.VUIE_resource.VUIR_bJustUpdated && !pupdate)) then nil else
VUIdrawElement contstr eltstr;
if (eltstr.VUIE_cbDraw == nil) then nil else
exec eltstr.VUIE_cbDraw with [eltstr];
VUIupdateElements contstr eltstr.VUIE_children;
set eltstr.VUIE_bJustDraw = 0;
);
);
VUIupdateElements contstr tl eltlist;
);
0;;
fun VUIupdateContBuffer(contstr)=
let contstr.VUICNT_buffer -> eltstr in
let SO3WidgetGetSize contstr.VUICNT_strw.VUIW_widget -> [pw ph] in
let VUIscaleVec [pw ph] contstr.VUICNT_fScale -> [bw bh] in
(
set eltstr.VUIE_bJustDraw = eltstr.VUIE_resource.VUIR_bNeedUpdate;
VUIupdateResourceBuffer eltstr.VUIE_resource bw bh;
if (contstr.VUICNT_cbPreUpdate == nil) then nil else
exec contstr.VUICNT_cbPreUpdate with [contstr eltstr.VUIE_resource.VUIR_oBuffer];
if ((contstr.VUICNT_iMode != VUIC_EXTERNAL) || (contstr.VUICNT_extBuffer == nil)) then nil else
(
let contstr.VUICNT_extBuffer -> [_ ew eh _] in
set contstr.VUICNT_extSize = [ew eh];
);
VUIupdateElements contstr contstr.VUICNT_lElements;
/*let _GETalphaBitmapSize eltstr.VUIE_resource.VUIR_oBuffer -> [w h] in
let _CRBTmat _channel eltstr.VUIE_resource.VUIR_oBuffer -> buff in
(
SO3BitmapWidgetBlitBuffer contstr.VUICNT_strw.VUIW_widget (_BTGETmatBuffer buff) w h 4;
_DSBTmat buff;
);*/
if ((contstr.VUICNT_iMode != VUIC_EXTERNAL) || (contstr.VUICNT_extBuffer == nil)) then
SO3BitmapWidgetBlitAlpha contstr.VUICNT_strw.VUIW_widget eltstr.VUIE_resource.VUIR_oBuffer;
if (contstr.VUICNT_cbPostUpdate == nil) then nil else
exec contstr.VUICNT_cbPostUpdate with [contstr eltstr.VUIE_resource.VUIR_oBuffer];
set eltstr.VUIE_bJustDraw = 0;
);
0;;
fun VUIupdateListElement(liststr, eltstr, offset)=
let liststr.VUIL_element.VUIE_container -> contstr in
let if (eltstr.VUIE_parent != nil) then
eltstr.VUIE_parent.VUIE_tDrawCoords
else
let VUIgetContainerBufferSize contstr -> [pw ph] in
[0 0 pw ph 0 0]
-> [vx vy vw vh pnx pny] in
let VUIcomputeEposSize eltstr vw vh -> [dx dy dw dh] in
let offset -> [ox oy] in
let dx + ox -> dx in
let dy + oy -> dy in
let vx + dx -> gx in
let vy + dy -> gy in
let liststr.VUIL_element.VUIE_tDrawCoords -> [_ _ _ ph _ _] in
(
set eltstr.VUIE_tLocalCoords = [dx dy dw dh];
set eltstr.VUIE_tGlobalCoords = [gx gy dw dh];
VUImakeElementDrawCoords eltstr;
if ((dy > ph) || ((dy + dh) <= 0)) then
(
set eltstr.VUIE_bVisible = 0;
)
else
(
set eltstr.VUIE_bVisible = 1;
VUIupdateResourceBuffer eltstr.VUIE_resource dw dh;
if (!VUI_DRAW_GLOBAL) then nil else
VUIdrawElement eltstr.VUIE_container eltstr;
//update childrens if any
VUIupdateElements contstr eltstr.VUIE_children;
if (VUI_DRAW_GLOBAL) then nil else
VUIdrawElement eltstr.VUIE_container eltstr;
set eltstr.VUIE_bJustDraw = 0;
);
//offset
[ox (dy + dh)];
);;
fun VUIupdateListElements(liststr, lestrlist, offset)=
if (lestrlist == nil) then offset else
(
let hd lestrlist -> lestr in
(
set offset = VUIupdateListElement liststr lestr.VUILE_element offset;
if (lestr.VUILE_iState == 0) then nil else
set offset = VUIupdateListElements liststr lestr.VUILE_children offset;
);
VUIupdateListElements liststr (tl lestrlist) offset;
);;
fun VUIupdateListElementCoords(liststr, eltstr, offset)=
let liststr.VUIL_element.VUIE_container -> contstr in
let if (eltstr.VUIE_parent != nil) then
eltstr.VUIE_parent.VUIE_tDrawCoords
else
let VUIgetContainerBufferSize contstr -> [pw ph] in
[0 0 pw ph 0 0]
-> [vx vy vw vh pnx pny] in
let VUIcomputeEposSize eltstr vw vh -> [dx dy dw dh] in
let offset -> [ox oy] in
let dx + ox -> dx in
let dy + oy -> dy in
let vx + dx -> gx in
let vy + dy -> gy in
let liststr.VUIL_element.VUIE_tDrawCoords -> [_ _ _ ph _ _] in
(
set eltstr.VUIE_tLocalCoords = [dx dy dw dh];
set eltstr.VUIE_tGlobalCoords = [gx gy dw dh];
VUImakeElementDrawCoords eltstr;
//offset
[ox (dy + dh)];
);;
fun VUIupdateListElementsCoords(liststr, lestrlist, offset)=
if (lestrlist == nil) then offset else
(
let hd lestrlist -> lestr in
(
set offset = VUIupdateListElementCoords liststr lestr.VUILE_element offset;
set offset = VUIupdateListElementsCoords liststr lestr.VUILE_children offset;
);
VUIupdateListElementsCoords liststr (tl lestrlist) offset;
);;
fun VUIgetListElementByName(liststr, lestrlist, value, ret)=
if ((lestrlist == nil) || (ret != nil)) then ret else
(
let hd lestrlist -> lestr in
(
if (!strcmp lestr.VUILE_sValue value) then
set ret = lestr
else
set ret = VUIgetListElementByName liststr lestr.VUILE_children value ret;
);
VUIgetListElementByName liststr (tl lestrlist) value ret;
);;
fun VUIshowListElementNode(leltstr, state, sons)=
if (!sons) then nil else
set leltstr.VUILE_element.VUIE_bVisible = state;
let leltstr.VUILE_children -> children in
while (children != nil) do
(
VUIshowListElementNode hd children (if !state then 0 else leltstr.VUILE_iState) 1;
set children = tl children;
);
0;;
fun VUIsetElementCheckState(eltstr, state)=
if (eltstr.VUIE_iCheckState == state) then nil else
(
set eltstr.VUIE_iCheckState = state;
if (eltstr.VUIE_resource == nil) || (state > (eltstr.VUIE_resource.VUIR_iNbCols - 1)) then nil else
(
//addLogMessage strcat "Check : " itoa state;
set eltstr.VUIE_resource.VUIR_iCurCol = state;
VUIelementNeedUpdate eltstr 0;
);
exec eltstr.VUIE_cbCheck with [eltstr state];
);
0;;
fun VUIunfoldListElement(leltstr, state)=
set leltstr.VUILE_iState = state;
VUIshowListElementNode leltstr state 0;
if (leltstr.VUILE_element.VUIE_children == nil) then nil else
VUIsetElementCheckState hd leltstr.VUILE_element.VUIE_children state;
0;;
fun VUIincElementCheckState(eltstr)=
let if ((eltstr.VUIE_resource == nil) || (eltstr.VUIE_resource.VUIR_iNbCols < 2)) then
!eltstr.VUIE_iCheckState
else if ((eltstr.VUIE_iCheckState + 1) > (eltstr.VUIE_resource.VUIR_iNbCols - 1)) then
0
else
eltstr.VUIE_iCheckState + 1
-> nstate in
VUIsetElementCheckState eltstr nstate;
0;;
fun VUIgetElementCheckState(eltstr)=
eltstr.VUIE_iCheckState;;
fun VUIsetElementIgnoreInput(eltstr, state)=
set eltstr.VUIE_bIgnoreInput = state;;
fun VUIgetElementIgnoreInput(eltstr)=
eltstr.VUIE_bIgnoreInput;;
fun VUIscrollList(liststr, delta)=
//addLogMessage strcat "ScrollList : " itoa delta;
let liststr.VUIL_tScroll -> [sw sh] in
let VUIgetListFullContentSize liststr 0 -> [tw th] in
let liststr.VUIL_element.VUIE_tGlobalCoords -> [_ _ cw ch] in
let sh + delta -> offset in
let if offset > (-(th - ch)) then offset else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
if (nh == sh) then nil else
(
set liststr.VUIL_tScroll = [sw nh];
VUIelementNeedUpdate liststr.VUIL_element 1;
);
0;;
fun cbVUIlistScrollTimer(trm, p)=
let p -> [liststr delta] in
VUIscrollList liststr delta;
0;;
fun cbVUIlistScrollBtnClick(eltstr, id, x, y , btn, p)=
let p -> [liststr delta] in
(
if (liststr.VUIL_trmScroll == nil) then nil else
(
_deltimer liststr.VUIL_trmScroll;
set liststr.VUIL_trmScroll = nil;
);
set liststr.VUIL_trmScroll = _rfltimer _starttimer _channel 60 @cbVUIlistScrollTimer p;
);
0;;
fun cbVUIlistScrollBtnUnClick(eltstr, id, x, y , btn, liststr)=
if (liststr.VUIL_trmScroll == nil) then nil else
(
_deltimer liststr.VUIL_trmScroll;
set liststr.VUIL_trmScroll = nil;
);
0;;
fun VUIdrawListCb(eltstr, liststr)=
VUIupdateListElements liststr liststr.VUIL_lListElts liststr.VUIL_tScroll;
let VUIgetListFullContentSize liststr 0 -> [tw th] in
let liststr.VUIL_element.VUIE_tGlobalCoords -> [_ _ cw ch] in
(
let liststr.VUIL_tScroll -> [sw sh] in
let if ((liststr.VUIL_container.VUICNT_lastFocusedElt != liststr.VUIL_element) && (liststr.VUIL_container.VUICNT_lastFocusedElt.VUIE_parent != liststr.VUIL_element)) then [0 0] else liststr.VUIL_container.VUICNT_strw.VUIW_tMouseInertia -> [ix iy] in
let sh + iy -> offset in
let if offset > (-(th - ch)) then offset else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
if (nh == sh) then nil else
(
set liststr.VUIL_tScroll = [sw nh];
VUIelementNeedUpdate liststr.VUIL_element 1;
);
let liststr.VUIL_tScroll -> [sw sh] in
let if sh > (-(th - ch)) then sh else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
(
//update scrolls
set liststr.VUIL_scrollUp.VUIE_bVisible = if (nh >= 0) then 0 else 1;
set liststr.VUIL_scrollDown.VUIE_bVisible = if sh > (-(th - ch)) then 1 else 0;
);
);
0;;
fun VUIgetMenuContentSize(menustr, mbstrlist, size)=
if (mbstrlist == nil) then size else
(
let hd mbstrlist -> mbstr in
(
let menustr.VUIM_tMargin -> [mx my] in
let mbstr.VUIMB_element.VUIE_tLocalCoords -> [ex ey ew eh] in
let size -> [sw sh] in
let menustr.VUIM_iAlignMode -> alignmode in
let if (alignmode == iVUIMNU_ALIGNRIGHT) then
[(max ew sw) (sh + eh + my)]
else if (alignmode == iVUIMNU_ALIGNTOP) then
[(sw + ew + mx) (max eh sh)]
else if (alignmode == iVUIMNU_ALIGNBOTTOM) then
[(sw + ew + mx) (max eh sh)]
else
[(max ew sw) (sh + eh + my)]
-> nsize in
set size = nsize;
);
VUIgetMenuContentSize menustr (tl mbstrlist) size;
);;
fun VUIgetMenuFullContentSize(menustr)=
let menustr.VUIM_tEltOffset -> [ox oy] in
let menustr.VUIM_tMargin -> [mx my] in
let VUIgetMenuContentSize menustr menustr.VUIM_lBtnMenus menustr.VUIM_tMargin -> [lw lh] in
[(lw + mx * 2) (lh + my)];;
fun VUIupdateMenuElement(menustr, eltstr, offset)=
let menustr.VUIM_tMargin -> [mx my] in
let menustr.VUIM_iAlignMode -> alignmode in
let offset -> [ox oy] in
(
let if (alignmode == iVUIMNU_ALIGNRIGHT) then
[[(itof mx) (itof (my + oy))] [2 0]]
else if (alignmode == iVUIMNU_ALIGNTOP) then
[[(itof (mx + ox)) (itof my)] [0 0]]
else if (alignmode == iVUIMNU_ALIGNBOTTOM) then
[[(itof (mx + ox)) (itof my)] [0 2]]
else
[[(itof mx) (itof (my + oy))] [0 0]] // left
-> [pos align] in
(
set eltstr.VUIE_vPos = pos;
set eltstr.VUIE_tAlign = align;
);
let menustr.VUIM_container -> contstr in
let if (eltstr.VUIE_parent != nil) then
eltstr.VUIE_parent.VUIE_tDrawCoords
else
let VUIgetContainerBufferSize contstr -> [pw ph] in
[0 0 pw ph 0 0]
-> [vx vy vw vh pnx pny] in
let VUIcomputeEposSize eltstr vw vh -> [dx dy dw dh] in
/*let offset -> [ox oy] in
let dx + ox -> dx in
let dy + oy -> dy in*/
let menustr.VUIM_element.VUIE_tDrawCoords -> [_ _ pw ph _ _] in
(
set eltstr.VUIE_tLocalCoords = [dx dy dw dh];
let vx + dx -> dx in
let vy + dy -> dy in
set eltstr.VUIE_tGlobalCoords = [dx dy dw dh];
VUImakeElementDrawCoords eltstr;
if ((dy > ph) || ((dy + dh) <= 0) || (dx > pw) || ((dx + dw) <= 0)) then
(
set eltstr.VUIE_bVisible = 0;
)
else
(
set eltstr.VUIE_bVisible = 1;
VUIupdateResourceBuffer eltstr.VUIE_resource dw dh;
if (!VUI_DRAW_GLOBAL) then nil else
VUIdrawElement eltstr.VUIE_container eltstr;
//update childrens if any
VUIupdateElements contstr eltstr.VUIE_children;
if (VUI_DRAW_GLOBAL) then nil else
VUIdrawElement eltstr.VUIE_container eltstr;
set eltstr.VUIE_bJustDraw = 0;
);
//offset
if (alignmode == iVUIMNU_ALIGNRIGHT) then
[ox (dy + dh)]
else if (alignmode == iVUIMNU_ALIGNTOP) then
[(dx + dw) oy]
else if (alignmode == iVUIMNU_ALIGNBOTTOM) then
[(dx + dw) oy]
else
[ox (dy + dh)];
);
);;
fun VUIupdateMenuElements(menustr, mbstrlist, offset)=
if (mbstrlist == nil) then offset else
(
let hd mbstrlist -> mbstr in
set offset = VUIupdateMenuElement menustr mbstr.VUIMB_element offset;
VUIupdateMenuElements menustr (tl mbstrlist) offset;
);;
fun VUIscrollMenu(menustr, delta)=
//addLogMessage strcat "ScrollMenu : " itoa delta;
let menustr.VUIM_tScroll -> [sw sh] in
let VUIgetMenuFullContentSize menustr -> [tw th] in
let menustr.VUIM_element.VUIE_tGlobalCoords -> [_ _ cw ch] in
let if (menustr.VUIM_iAlignMode == iVUIMNU_ALIGNRIGHT) || (menustr.VUIM_iAlignMode == iVUIMNU_ALIGNLEFT) then
let sh + delta -> offset in
let if offset > (-(th - ch)) then offset else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
if (nh == sh) then nil else [sw nh]
else
let sw + delta -> offset in
let if offset > (-(tw - cw)) then offset else -(tw - cw) -> nw in
let if nw >= 0 then 0 else nw -> nw in
if (nw == sw) then nil else [nw sh]
-> nscroll in
if (nscroll == nil) then nil else
(
set menustr.VUIM_tScroll = nscroll;
VUIelementNeedUpdate menustr.VUIM_element 1;
);
0;;
fun cbVUImenuScrollTimer(trm, p)=
let p -> [menustr delta] in
VUIscrollMenu menustr delta;
0;;
fun cbVUImenuScrollBtnClick(eltstr, id, x, y , btn, p)=
let p -> [menustr delta] in
(
if (menustr.VUIM_trmScroll == nil) then nil else
(
_deltimer menustr.VUIM_trmScroll;
set menustr.VUIM_trmScroll = nil;
);
set menustr.VUIM_trmScroll = _rfltimer _starttimer _channel 60 @cbVUImenuScrollTimer p;
);
0;;
fun cbVUImenuScrollBtnUnClick(eltstr, id, x, y , btn, menustr)=
if (menustr.VUIM_trmScroll == nil) then nil else
(
_deltimer menustr.VUIM_trmScroll;
set menustr.VUIM_trmScroll = nil;
);
0;;
fun VUIdrawMenuCb(eltstr, menustr)=
VUIupdateMenuElements menustr menustr.VUIM_lBtnMenus menustr.VUIM_tScroll;
let VUIgetMenuFullContentSize menustr -> [tw th] in
let menustr.VUIM_element.VUIE_tGlobalCoords -> [_ _ cw ch] in
(
let menustr.VUIM_tScroll -> [sw sh] in
let if ((menustr.VUIM_container.VUICNT_lastFocusedElt != menustr.VUIM_element) && (menustr.VUIM_container.VUICNT_lastFocusedElt.VUIE_parent != menustr.VUIM_element)) then [0 0] else menustr.VUIM_container.VUICNT_strw.VUIW_tMouseInertia -> [ix iy] in
let if (menustr.VUIM_iAlignMode == iVUIMNU_ALIGNRIGHT) || (menustr.VUIM_iAlignMode == iVUIMNU_ALIGNLEFT) then
let sh + iy -> offset in
let if offset > (-(th - ch)) then offset else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
if (nh == sh) then nil else [sw nh]
else
let sw + ix -> offset in
let if offset > (-(tw - cw)) then offset else -(tw - cw) -> nw in
let if nw >= 0 then 0 else nw -> nw in
if (nw == sw) then nil else [nw sh]
-> nscroll in
if (nscroll == nil) then nil else
(
set menustr.VUIM_tScroll = nscroll;
VUIelementNeedUpdate menustr.VUIM_element 1;
);
let menustr.VUIM_tScroll -> [sw sh] in
let if (menustr.VUIM_iAlignMode == iVUIMNU_ALIGNRIGHT) || (menustr.VUIM_iAlignMode == iVUIMNU_ALIGNLEFT) then
let if sh > (-(th - ch)) then sh else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
[(if (nh >= 0) then 0 else 1) (if sh > (-(th - ch)) then 1 else 0)]
else
let if sw > (-(tw - cw)) then sw else -(tw - cw) -> nw in
let if nw >= 0 then 0 else nw -> nw in
[(if (nw >= 0) then 0 else 1) (if sw > (-(tw - cw)) then 1 else 0)]
-> [vu vd] in
(
//update scrolls
set menustr.VUIM_scrollPlus.VUIE_bVisible = vu;
set menustr.VUIM_scrollMinus.VUIE_bVisible = vd;
);
);
0;;
fun VUIscrollText(eltstr, delta)=
//addLogMessage strcat "ScrollText : " itoa delta;
if ((eltstr.VUIE_Text == nil) || !eltstr.VUIE_bVisible || !eltstr.VUIE_container.VUICNT_bVisible || !eltstr.VUIE_Text.VUIT_bMultiline) then 0 else
let eltstr.VUIE_Text.VUIT_tTextSize -> [tw th] in
let eltstr.VUIE_Text.VUIT_tScroll -> [sw sh] in
let eltstr.VUIE_Text.VUIT_tCoords -> [_ _ cw ch] in
let sh + delta -> offset in
let if offset > (-(th - ch)) then offset else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
if (nh == sh) then 0 else
(
set eltstr.VUIE_Text.VUIT_tScroll = [sw nh];
VUIelementNeedUpdate eltstr 1;
1;
);;
fun cbVUItextScrollTimer(trm, p)=
let p -> [textstr delta] in
VUIscrollText textstr.VUIT_parent delta;
0;;
fun cbVUItextScrollBtnClick(eltstr, id, x, y , btn, p)=
let p -> [textstr delta] in
(
if (textstr.VUIT_trmScroll == nil) then nil else
(
_deltimer textstr.VUIT_trmScroll;
set textstr.VUIT_trmScroll = nil;
);
set textstr.VUIT_trmScroll = _rfltimer _starttimer _channel 60 @cbVUItextScrollTimer p;
);
0;;
fun cbVUItextScrollBtnUnClick(eltstr, id, x, y , btn, textstr)=
if (textstr.VUIT_trmScroll == nil) then nil else
(
_deltimer textstr.VUIT_trmScroll;
set textstr.VUIT_trmScroll = nil;
);
0;;
fun VUIscrollElement(eltstr, dx, dy)=
let eltstr.VUIE_tScroll -> [sw sh] in
let eltstr.VUIE_vContRect -> [tx ty tw th] in
let eltstr.VUIE_tLocalCoords -> [_ _ cw ch] in
let sh + dy -> yoff in
let if yoff > (-(th - ch)) then yoff else -(th - ch) -> nh in
let if nh >= 0 then 0 else nh -> nh in
let sw + dx -> xoff in
let if xoff > (-(tw - cw)) then xoff else -(tw - cw) -> nw in
let if nw >= 0 then 0 else nw -> nw in
if ((nh == sh) && (nw == sw)) then nil else
(
set eltstr.VUIE_tScroll = [nw nh];
VUIelementNeedUpdate eltstr 1;
);
0;;
fun cbVUIelementScrollTimer(trm, p)=
let p -> [eltstr [dx dy]] in
VUIscrollElement eltstr dx dy;
0;;
fun cbVUIelementScrollBtnClick(eltstr, id, x, y , btn, p)=
let p -> [seltstr delta] in
(
if (seltstr.VUIE_trmScroll == nil) then nil else
(
_deltimer seltstr.VUIE_trmScroll;
set seltstr.VUIE_trmScroll = nil;
);
set seltstr.VUIE_trmScroll = _rfltimer _starttimer _channel 60 @cbVUIelementScrollTimer p;
);
0;;
fun cbVUIelementScrollBtnUnClick(eltstr, id, x, y , btn, seltstr)=
if (seltstr.VUIE_trmScroll == nil) then nil else
(
_deltimer seltstr.VUIE_trmScroll;
set seltstr.VUIE_trmScroll = nil;
);
0;;
fun VUImouseWheelMenuCb(eltstr, id, x, y, delta, menustr)=
VUIscrollMenu menustr delta * 10;
0;;
fun VUImouseMoveMenuCb(eltstr, id, x, y, btn, menustr)=
let menustr.VUIM_container -> contstr in
(
let switch contstr.VUICNT_strw.VUIW_vClickTrans id -> ct in
if ((contstr.VUICNT_lastFocusedElt != menustr.VUIM_element) && (contstr.VUICNT_lastFocusedElt.VUIE_parent != menustr.VUIM_element)) || (ct == nil) then nil else
let ct -> [tx ty] in
VUIscrollMenu menustr (if ((menustr.VUIM_iAlignMode == iVUIMNU_ALIGNRIGHT) || (menustr.VUIM_iAlignMode == iVUIMNU_ALIGNLEFT)) then ty else tx);
);
0;;
fun VUImouseWheelListCb(eltstr, id, x, y, delta, liststr)=
VUIscrollList liststr delta * 10;
0;;
fun VUImouseMoveListCb(eltstr, id, x, y, btn, liststr)=
let liststr.VUIL_container -> contstr in
(
let switch contstr.VUICNT_strw.VUIW_vClickTrans id -> ct in
if ((contstr.VUICNT_lastFocusedElt != liststr.VUIL_element) && (contstr.VUICNT_lastFocusedElt.VUIE_parent != liststr.VUIL_element)) || (ct == nil) then nil else
let ct -> [tx ty] in
VUIscrollList liststr ty;
);
0;;
fun VUIselectListElement(leltstr, state)=
let leltstr.VUILE_list -> liststr in
(
if (liststr.VUIL_bMultiSelect) then
(
set liststr.VUIL_lSelected = if (state) then leltstr::liststr.VUIL_lSelected else remove_from_list liststr.VUIL_lSelected leltstr;
)
else
(
let hd liststr.VUIL_lSelected -> oeltstr in
if (oeltstr == nil) then nil else
VUIsetElementCheckState oeltstr.VUILE_element 0;
//addLogMessage strcat "Select " leltstr.VUILE_element.VUIE_Text.VUIT_sContent;
set liststr.VUIL_lSelected = leltstr::nil;
);
//check
let leltstr.VUILE_element -> eltstr in
if (eltstr.VUIE_iCheckState == state) then nil else
(
set eltstr.VUIE_iCheckState = state;
if (eltstr.VUIE_resource == nil) || (state > (eltstr.VUIE_resource.VUIR_iNbCols - 1)) then nil else
(
set eltstr.VUIE_resource.VUIR_iCurCol = state;
VUIelementNeedUpdate eltstr 0;
);
);
exec leltstr.VUILE_cbSelect with [leltstr];
if (!liststr.VUIL_bMultiSelect && !state) then nil else
(
exec liststr.VUIL_cbSelect with [liststr liststr.VUIL_lSelected];
);
);
0;;
fun VUIselectListElementCb(eltstr, state, leltstr)=
VUIselectListElement leltstr state;
0;;
fun VUIcheckListElementCb(eltstr, state, leltstr)=
if (leltstr.VUILE_children == nil) then nil else
(
VUIunfoldListElement leltstr if (state > 0) then 1 else 0;
VUIelementNeedUpdate leltstr.VUILE_list.VUIL_element 0;
);
0;;
fun VUIsetContainerBackground(contstr, bgcolor, border, bdcolor, file, flags, nbstates, nbframes, framepersec)=
VUImakeResource contstr.VUICNT_buffer bgcolor border bdcolor file flags nbstates nil nbframes framepersec;
0;;
fun VUIsetContainerThemeCallback(contstr, cbfun)=
set contstr.VUICNT_cbThemeUpdate = cbfun;;
fun VUIsetContainerPostUpdateCallback(contstr, cbfun)=
set contstr.VUICNT_cbPostUpdate = cbfun;;
fun VUIsetContainerPreUpdateCallback(contstr, cbfun)=
set contstr.VUICNT_cbPreUpdate = cbfun;;
fun VUIsetContainerExternalBuffer(contstr, buffer)=
set contstr.VUICNT_extBuffer = buffer;;
fun VUIexecElementOut(eltstr, id, isover)=
if ((eltstr == nil) || eltstr.VUIE_iClick != 0) then nil else
(
if (eltstr.VUIE_resource.VUIR_iCurState == 3) then nil else
(
set eltstr.VUIE_resource.VUIR_iCurState = isover;
//update bitmap
if(eltstr.VUIE_resource.VUIR_iNbStates <= 0) then nil else
VUIelementNeedUpdate eltstr 0;
);
if (isover) then nil else
(
exec eltstr.VUIE_cbMouseOut with [eltstr];
//addLogMessage "Mouse out elt";
set eltstr.VUIE_container.VUICNT_lastMouseInElt = remove_idx_from_list eltstr.VUIE_container.VUICNT_lastMouseInElt id;
);
);
0;;
fun VUIConvertExternalCoords(contstr, x, y)=
if ((contstr.VUICNT_iMode == VUIC_EXTERNAL) && (contstr.VUICNT_extSize != nil)) then
let contstr.VUICNT_extSize -> [w h] in
let SO3WidgetGetSize contstr.VUICNT_strw.VUIW_widget -> [ww wh] in
if ((w != ww) || (h != wh)) then
[ftoi ((itof x) *. ((itof w) /. (itof ww))) ftoi ((itof y) *. ((itof h) /. (itof wh)))]
else
[x y]
else
[x y];;
fun cbVUImouseIn(widget, contstr)=
let 0 -> id in
if (!contstr.VUICNT_bVisible || (contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState == 3) || (contstr.VUICNT_buffer.VUIE_iClick != 0)) then nil else
(
//addLogMessage "Mouse in";
set contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState = 1;
//update bitmap
if(contstr.VUICNT_buffer.VUIE_resource.VUIR_iNbStates <= 0) then nil else
set contstr.VUICNT_bNeedUpdate = 1;
exec contstr.VUICNT_strw.VUIW_cbMouseIn with [contstr];
);
0;;
fun cbVUImouseOut(widget, contstr)=
let 0 -> id in
if (!contstr.VUICNT_bVisible || (contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState == 3) || (contstr.VUICNT_buffer.VUIE_iClick != 0)) then nil else
(
//addLogMessage "Mouse out";
let switch contstr.VUICNT_lastMouseInElt id -> feltstr in
VUIexecElementOut feltstr id 0;
set contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState = 0;
//update bitmap
if(contstr.VUICNT_buffer.VUIE_resource.VUIR_iNbStates <= 0) then nil else
VUIelementNeedUpdate contstr.VUICNT_buffer 0;
exec contstr.VUICNT_strw.VUIW_cbMouseOut with [contstr];
);
0;;
fun VUIunclickElement(eltstr, id, x, y, btn, isover)=
let eltstr.VUIE_container -> contstr in
let switch contstr.VUICNT_lastMouseClElt id -> celtstr in
(
let ftoi (32.0 /. fVUIPIXELDENSITY) -> tolerance in
let ftoi (10.0 /. fVUIPIXELDENSITY) -> trtolerance in
let switch contstr.VUICNT_strw.VUIW_vClickTrans id -> ct in
let if (ct == nil) then [0 0] else ct -> [ix iy] in
let contstr.VUICNT_strw.VUIW_view -> viewstr in
let V3DgetLastClickMove viewstr id -> lcm in
let if (contstr.VUICNT_iMode == VUIC_VR) || (lcm == nil) then [0 0] else lcm -> [mx my] in
(
if (((abs ix) < trtolerance) && ((abs iy) < trtolerance) && ((abs mx) < tolerance) && ((abs my) < tolerance)) then
(
//fullclick
if (eltstr != celtstr) then nil else
(
exec eltstr.VUIE_cbFullClick with [eltstr id x y btn];
VUIincElementCheckState eltstr;
);
0;
);
set contstr.VUICNT_strw.VUIW_tMouseInertia = [ix iy];
);
//update bitmap
if ((celtstr == nil) || (celtstr.VUIE_iClick == 0)) then nil else
(
set celtstr.VUIE_resource.VUIR_iCurState = 0;
set celtstr.VUIE_iClick = 0;
exec celtstr.VUIE_cbUnClick with [celtstr id x y btn];
set contstr.VUICNT_lastMouseClElt = remove_idx_from_list contstr.VUICNT_lastMouseClElt id;
if(celtstr.VUIE_resource.VUIR_iNbStates <= 0) then nil else
VUIelementNeedUpdate celtstr 0;
);
let switch contstr.VUICNT_lastMouseInElt id -> feltstr in
let if (eltstr == nil) then feltstr else eltstr -> eltstr in
(
set eltstr.VUIE_iClick = 0;
VUIexecElementOut eltstr id isover;
);
set contstr.VUICNT_strw.VUIW_vMousePos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vMousePos id;
set contstr.VUICNT_strw.VUIW_vClickTrans = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickTrans id;
let contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState -> lstate in
(
set contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState = isover;
//update bitmap
if(contstr.VUICNT_buffer.VUIE_resource.VUIR_iNbStates <= 0) then nil else
VUIelementNeedUpdate contstr.VUICNT_buffer 0;
if (lstate != 2) then nil else
exec contstr.VUICNT_strw.VUIW_cbUnClick with [contstr x y btn];
if (isover) then nil else
exec contstr.VUICNT_strw.VUIW_cbMouseOut with [contstr];
);
set contstr.VUICNT_buffer.VUIE_iClick = 0;
);
0;;
fun VUIclickElement(eltstr, id, x, y, btn)=
let eltstr.VUIE_container -> contstr in
if ((eltstr == nil) || (eltstr.VUIE_resource.VUIR_iCurState == 3)) then nil else
let 0 -> pushed in
(
if ((eltstr.VUIE_resource.VUIR_iCurState == 2) && (eltstr.VUIE_iClick != 0)) then nil else
set pushed = 1;
set eltstr.VUIE_iClick = eltstr.VUIE_iClick | btn;
set eltstr.VUIE_resource.VUIR_iCurState = 2;
//update bitmap
if(eltstr.VUIE_resource.VUIR_iNbStates <= 1) then nil else
VUIelementNeedUpdate eltstr 0;
if (!pushed) then nil else
(
set contstr.VUICNT_lastMouseClElt = remove_idx_from_list contstr.VUICNT_lastMouseClElt id;
set contstr.VUICNT_lastMouseClElt = [id eltstr]::contstr.VUICNT_lastMouseClElt;
exec eltstr.VUIE_cbClick with [eltstr id x y btn];
// force unclick if the click hide the element or the container
let if (!contstr.VUICNT_bVisible) then nil else VUIgetElementInCoord (revertlist contstr.VUICNT_lElements) x y -> feltstr in
if (feltstr == eltstr) then nil else
VUIunclickElement eltstr id x y btn 0;
);
VUIsetFocusedElement contstr eltstr;
if ((contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState == 2) && (contstr.VUICNT_buffer.VUIE_iClick != 0)) then nil else
set pushed = 1;
set contstr.VUICNT_buffer.VUIE_iClick = contstr.VUICNT_buffer.VUIE_iClick | btn;
set contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState = 2;
//update bitmap
if(contstr.VUICNT_buffer.VUIE_resource.VUIR_iNbStates <= 1) then nil else
VUIelementNeedUpdate contstr.VUICNT_buffer 0;
if (!pushed) then nil else
exec contstr.VUICNT_strw.VUIW_cbClick with [contstr x y btn];
);
0;;
fun cbVUIclick(widget, contstr, id, x, y, btn)=
let VUIConvertExternalCoords contstr x y -> [x y] in
if (!contstr.VUICNT_bVisible || (contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState == 3)) then nil else
(
//addLogMessage strcatn "Click in: "::(itoa x)::" "::(itoa y)::" "::(itoa btn)::nil;
let VUIgetElementInCoord (revertlist contstr.VUICNT_lElements) x y -> feltstr in
VUIclickElement feltstr id x y btn;
set contstr.VUICNT_strw.VUIW_vMousePos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vMousePos id;
set contstr.VUICNT_strw.VUIW_vClickTrans = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickTrans id;
set contstr.VUICNT_strw.VUIW_vClickPos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickPos id;
set contstr.VUICNT_strw.VUIW_vClickPos = [id [x y]]::contstr.VUICNT_strw.VUIW_vClickPos;
);
0;;
fun cbVUIunClick(widget, contstr, id, x, y, btn)=
let VUIConvertExternalCoords contstr x y -> [x y] in
if (!contstr.VUICNT_bVisible || (contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState == 3)) then nil else
let SO3WidgetIsMouseOver contstr.VUICNT_strw.VUIW_widget -> isover in
let VUIgetElementInCoord (revertlist contstr.VUICNT_lElements) x y -> feltstr in
let switch contstr.VUICNT_lastMouseClElt id -> celtstr in
let if (feltstr == nil) then celtstr else feltstr -> feltstr in
VUIunclickElement feltstr id x y btn (celtstr == feltstr);
set contstr.VUICNT_strw.VUIW_vClickPos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickPos id;
//SO3WidgetUnFocus contstr.VUICNT_strw.VUIW_widget;
0;;
fun VUImouseMoveElement(eltstr, id, x, y, btn)=
let eltstr.VUIE_container -> contstr in
let switch contstr.VUICNT_lastMouseInElt id -> feltstr in
(
if (feltstr == eltstr) then nil else
(
VUIexecElementOut feltstr id 0;
//check if the input is still there
let switch contstr.VUICNT_lastMouseInElt id -> feltstr in
if (eltstr == nil) || (feltstr != nil) || (eltstr.VUIE_resource.VUIR_bNeedUpdate) then nil else
(
if (eltstr.VUIE_resource.VUIR_iCurState == 3) then nil else
(
set eltstr.VUIE_resource.VUIR_iCurState = 1;
//update bitmap
if(eltstr.VUIE_resource.VUIR_iNbStates <= 0) then nil else
VUIelementNeedUpdate eltstr 0;
);
//addLogMessage strcat "Mouse in: " eltstr.VUIE_Text.VUIT_sContent;
set contstr.VUICNT_lastMouseInElt = [id eltstr]::contstr.VUICNT_lastMouseInElt;
//addLogMessage "Mouse in elt";
exec eltstr.VUIE_cbMouseIn with [eltstr];
);
);
let VUIgetScrollableElement contstr.VUICNT_lastFocusedElt -> scrollstr in
if ((scrollstr == nil) && (!contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_bMultiline)) then nil else
(
let switch contstr.VUICNT_strw.VUIW_vClickTrans id -> ct in
if (ct == nil) then nil else
let ct -> [tx ty] in
(
if (scrollstr != nil) then
let if (scrollstr.VUIE_iScrollMode & VUI_EltScrollV) then ty else 0 -> ty in
let if (scrollstr.VUIE_iScrollMode & VUI_EltScrollH) then tx else 0 -> tx in
VUIscrollElement scrollstr tx ty
else
VUIscrollText contstr.VUICNT_lastFocusedElt ty;
);
);
//call the wheel callback on the first parent found
let eltstr.VUIE_cbMouseMove -> cbfun in
(
let eltstr -> wstr in
while (cbfun == nil && wstr != nil) do
(
set wstr = wstr.VUIE_parent;
set cbfun = wstr.VUIE_cbMouseMove;
);
if (cbfun == nil) then nil else
exec cbfun with [eltstr id x y btn];
);
);
0;;
fun cbVUImouseMove(widget, contstr, id, x, y, btn)=
let VUIConvertExternalCoords contstr x y -> [x y] in
let SO3WidgetIsMouseOver contstr.VUICNT_strw.VUIW_widget -> isover in
let switch contstr.VUICNT_lastMouseInElt id -> feltstr in
if (!isover) then nil else
(
let switch contstr.VUICNT_strw.VUIW_vMousePos id -> mp in
let if (mp == nil) then [x y] else mp -> [mx my] in
if (btn == 0) then
(
set contstr.VUICNT_strw.VUIW_vClickTrans = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickTrans id;
)
else
(
let switch contstr.VUICNT_strw.VUIW_vClickPos id -> [ox oy] in
let if (id > 0) then 32 else 0 -> trtolerance in
(
set contstr.VUICNT_strw.VUIW_vClickTrans = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickTrans id;
if (((abs (x - ox)) < trtolerance) && ((abs (y - oy)) < trtolerance)) then nil else
set contstr.VUICNT_strw.VUIW_vClickTrans = [id [(x - mx) (y - my)]]::contstr.VUICNT_strw.VUIW_vClickTrans;
);
);
set contstr.VUICNT_strw.VUIW_vMousePos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vMousePos id;
set contstr.VUICNT_strw.VUIW_vMousePos = [id [x y]]::contstr.VUICNT_strw.VUIW_vMousePos;
//addLogMessage strcatn "Move in: "::(itoa x)::" "::(itoa y)::" "::(itoa btn)::nil;
let VUIgetElementInCoord (revertlist contstr.VUICNT_lElements) x y -> eltstr in
(
/*let if (eltstr.VUIE_iType == VUI_EltButton) then
"button"
else if (eltstr.VUIE_iType == VUI_EltEditText) then
"editText"
else if (eltstr.VUIE_iType == VUI_EltSelect) then
"select"
else if (eltstr.VUIE_iType == VUI_EltListElement) then
"listElement"
else if (eltstr.VUIE_iType == VUI_EltFrame) then
"frame"
else
nil
-> stype in
addLogMessage strcat "Mouse in: " stype;
*/
VUImouseMoveElement eltstr id x y btn;
if (eltstr != nil) then nil else
VUIexecElementOut feltstr id 0;
);
exec contstr.VUICNT_strw.VUIW_cbMouseMove with [contstr x y btn];
);
0;;
fun cbVUImouseWheel(widget, contstr, id, x, y, delta)=
let VUIConvertExternalCoords contstr x y -> [x y] in
let SO3WidgetIsMouseOver contstr.VUICNT_strw.VUIW_widget -> isover in
let switch contstr.VUICNT_lastMouseInElt id -> feltstr in
if (!isover || (feltstr == nil)) then nil else
(
//addLogMessage strcatn "Wheel in: "::(itoa x)::" "::(itoa y)::" "::(itoa delta)::nil;
if (VUIscrollText feltstr delta * 10) then nil else
(
//call the wheel callback on the first parent found
let feltstr.VUIE_cbMouseWheel -> cbfun in
(
let feltstr -> wstr in
while (cbfun == nil && wstr != nil) do
(
set wstr = wstr.VUIE_parent;
set cbfun = wstr.VUIE_cbMouseWheel;
);
if (cbfun != nil) then
(
exec cbfun with [feltstr id x y delta];
0;
)
else
(
let VUIgetScrollableElement contstr.VUICNT_lastFocusedElt -> scrollstr in
if !(scrollstr.VUIE_iScrollMode & VUI_EltScrollV) then nil else
VUIscrollElement scrollstr 0 delta * 10;
0;
);
);
);
);
0;;
fun cbVUITouchTimer(trm, contstr)=
_deltimer trm;
set contstr.VUICNT_strw.VUIW_trmTouchTimeOut = nil;
SO3WidgetInputDownEventCb contstr.VUICNT_strw.VUIW_widget @cbVUIclick contstr;
SO3WidgetInputUpEventCb contstr.VUICNT_strw.VUIW_widget @cbVUIunClick contstr;
SO3WidgetInputUpdateEventCb contstr.VUICNT_strw.VUIW_widget @cbVUImouseMove contstr;
0;;
fun cbVUITouchAdd(widget, contstr, id, x, y)=
//disable mouse input
if (contstr.VUICNT_strw.VUIW_trmTouchTimeOut == nil) then nil else
(
_deltimer contstr.VUICNT_strw.VUIW_trmTouchTimeOut;
set contstr.VUICNT_strw.VUIW_trmTouchTimeOut = nil;
);
SO3WidgetInputDownEventCb contstr.VUICNT_strw.VUIW_widget nil nil;
SO3WidgetInputUpEventCb contstr.VUICNT_strw.VUIW_widget nil nil;
SO3WidgetInputUpdateEventCb contstr.VUICNT_strw.VUIW_widget nil nil;
let VUIConvertExternalCoords contstr x y -> [x y] in
if (!contstr.VUICNT_bVisible || (contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState == 3)) then nil else
(
//addLogMessage strcatn "Click in: "::(itoa x)::" "::(itoa y)::" "::(itoa btn)::nil;
let VUIgetElementInCoord (revertlist contstr.VUICNT_lElements) x y -> feltstr in
VUIclickElement feltstr id x y 1;
set contstr.VUICNT_strw.VUIW_vClickTrans = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickTrans id;
set contstr.VUICNT_strw.VUIW_vMousePos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vMousePos id;
set contstr.VUICNT_strw.VUIW_vClickPos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickPos id;
set contstr.VUICNT_strw.VUIW_vClickPos = [id [x y]]::contstr.VUICNT_strw.VUIW_vClickPos;
);
0;;
fun cbVUITouchRemove(widget, contstr, id, x, y)=
let VUIConvertExternalCoords contstr x y -> [x y] in
if (!contstr.VUICNT_bVisible || (contstr.VUICNT_buffer.VUIE_resource.VUIR_iCurState == 3)) then nil else
let VUIgetElementInCoord (revertlist contstr.VUICNT_lElements) x y -> feltstr in
let switch contstr.VUICNT_lastMouseClElt id -> celtstr in
let if (feltstr == nil) then celtstr else feltstr -> feltstr in
VUIunclickElement feltstr id x y 1 0;
if (contstr.VUICNT_strw.VUIW_trmTouchTimeOut == nil) then nil else
_deltimer contstr.VUICNT_strw.VUIW_trmTouchTimeOut;
set contstr.VUICNT_strw.VUIW_vClickPos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickPos id;
set contstr.VUICNT_strw.VUIW_trmTouchTimeOut = _rfltimer _starttimer _channel 4000 @cbVUITouchTimer contstr;
0;;
fun cbVUITouchUpdate(widget, contstr, id, x, y, vx, vy)=
if (contstr.VUICNT_strw.VUIW_trmTouchTimeOut == nil) then nil else
_deltimer contstr.VUICNT_strw.VUIW_trmTouchTimeOut;
let VUIConvertExternalCoords contstr x y -> [x y] in
(
let switch contstr.VUICNT_strw.VUIW_vMousePos id -> mp in
let if (mp == nil) then [x y] else mp -> [mx my] in
(
set contstr.VUICNT_strw.VUIW_vClickTrans = remove_idx_from_list contstr.VUICNT_strw.VUIW_vClickTrans id;
set contstr.VUICNT_strw.VUIW_vClickTrans = [id [(x - mx) (y - my)]]::contstr.VUICNT_strw.VUIW_vClickTrans;
);
set contstr.VUICNT_strw.VUIW_vMousePos = remove_idx_from_list contstr.VUICNT_strw.VUIW_vMousePos id;
set contstr.VUICNT_strw.VUIW_vMousePos = [id [x y]]::contstr.VUICNT_strw.VUIW_vMousePos;
let VUIgetElementInCoord (revertlist contstr.VUICNT_lElements) x y -> eltstr in
(
VUImouseMoveElement eltstr id x y 1;
let switch contstr.VUICNT_lastMouseInElt id -> feltstr in
if (eltstr != nil) then nil else
VUIexecElementOut feltstr id 0;
);
exec contstr.VUICNT_strw.VUIW_cbMouseMove with [contstr x y 1];
);
0;;
fun cbVUIfocused(widget, contstr, state)=
if ((VUIdefVrKeyboard.VUIK_bVisible && (VUI_focusedContainer == contstr)) ||
(contstr == VUIdefVrKeyboard.VUIK_txtContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_upContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_symContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_numContainer) ||
(contstr == VUIdefVrKeyboard.VUIK_toolContainer)) then nil else
(
if (VUI_focusedContainer == contstr) then nil else
(
VUIsetFocusedElement VUI_focusedContainer nil;
exec VUI_focusedContainer.VUICNT_strw.VUIW_cbFocused with [VUI_focusedContainer 0];
);
if (state) then nil else
VUIsetFocusedElement contstr nil;
set VUI_focusedContainer = if (state) then contstr else nil;
exec contstr.VUICNT_strw.VUIW_cbFocused with [contstr state];
);
0;;
/* ********************************************************************************************* /
3D container
/ ********************************************************************************************* */
/*! @ingroup VUIApi
* \brief Get the offset of a 3d container to its center. Relative to the label size
*
* Prototype: fun [VUIcontainer] [F F]
*
* \param VUIcontainer : container
*
* \return [F F] : offset
**/
fun VUIget3DContainerOffset(contstr)=
let contstr.VUICNT_str3d -> vrcontstr in
vrcontstr.VUI3D_vOffset;;
/*! @ingroup VUIApi
* \brief Set the offset of a 3d container to its center. Relative to the label size
*
* Prototype: fun [VUIcontainer [F F]] I
*
* \param VUIcontainer : container
* \param [F F] : offset
*
* \return I : 0
**/
fun VUIset3DContainerOffset(contstr, offset)=
let contstr.VUICNT_str3d -> vrcontstr in
(
set vrcontstr.VUI3D_vOffset = offset;
let offset -> [xoff yoff] in
SO3ObjectSetPosition vrcontstr.VUI3D_plane [xoff yoff 0.0];
);
0;;
/*! @ingroup VUIApi
* \brief Get the Max auto scale of a 3d container
*
* Prototype: fun [VUIcontainer] F
*
* \param VUIcontainer : container
*
* \return F : max auto scale
**/
fun VUIget3DContainerMaxAutoScale(contstr)=
let contstr.VUICNT_str3d -> vrcontstr in
vrcontstr.VUI3D_fMaxAutoscaleDist;;
/*! @ingroup VUIApi
* \brief Set the Max auto scale of a 3d container
*
* Prototype: fun [VUIcontainer F] I
*
* \param VUIcontainer : container
* \param F : max auto scale
*
* \return I : 0
**/
fun VUIset3DContainerMaxAutoScale(contstr, scale)=
let contstr.VUICNT_str3d -> vrcontstr in
set vrcontstr.VUI3D_fMaxAutoscaleDist = scale;
0;;
/*! @ingroup VUIApi
* \brief Get the auto scale state of a 3d container
*
* Prototype: fun [VUIcontainer] I
*
* \param VUIcontainer : container
*
* \return I : Auto scale state
**/
fun VUIget3DContainerAutoScale(contstr)=
let contstr.VUICNT_str3d -> vrcontstr in
vrcontstr.VUI3D_bAutoScale;;
/*! @ingroup VUIApi
* \brief Set the auto scale state of a 3d container
*
* Prototype: fun [VUIcontainer I] I
*
* \param VUIcontainer : container
* \param I : auto scale state
*
* \return I : 0
**/
fun VUIset3DContainerAutoScale(contstr, state)=
let contstr.VUICNT_str3d -> vrcontstr in
set vrcontstr.VUI3D_bAutoScale = state;
0;;
/*! @ingroup VUIApi
* \brief Get the scale of a 3d container
*
* Prototype: fun [VUIcontainer] F
*
* \param VUIcontainer : container
*
* \return F : scale
**/
fun VUIget3DContainerScale(contstr)=
let contstr.VUICNT_str3d -> vrcontstr in
vrcontstr.VUI3D_fScale;;
/*! @ingroup VUIApi
* \brief Set the scale of a 3d container
*
* Prototype: fun [VUIcontainer F] I
*
* \param VUIcontainer : container
* \param F : scale
*
* \return I : 0
**/
fun VUIset3DContainerScale(contstr, scale)=
let contstr.VUICNT_str3d -> vrcontstr in
let SO3WidgetGetSize contstr.VUICNT_strw.VUIW_widget -> [w h] in
let 0.01 -> coef in
if scale == nil then nil else
(
set vrcontstr.VUI3D_fScale = scale;
if (vrcontstr.VUI3D_bAutoScale == 1) then nil else
SO3ObjectSetScale vrcontstr.VUI3D_node [(scale *. (itof w) *. coef) (scale *. (itof h) *. coef) (scale *. (itof h) *. coef)];
);
0;;
/*! @ingroup VUIApi
* \brief Set the orientation of a 3d container
*
* Prototype: fun [VUIcontainer [F F F F]] I
*
* \param VUIcontainer : container
* \param [F F F F] : quaternion
*
* \return I : 0
**/
fun VUIset3DContainerOrientation(contstr, quat)=
let contstr.VUICNT_str3d -> vrcontstr in
if quat == nil then nil else
(
if (vrcontstr.VUI3D_bAutoTarget == 1) then nil else
SO3ObjectSetOrientation vrcontstr.VUI3D_node quat;
);
0;;
/*! @ingroup VUIApi
* \brief Set the position of a 3d container
*
* Prototype: fun [VUIcontainer [F F F]] I
*
* \param VUIcontainer : container
* \param [F F F] : position
*
* \return I : 0
**/
fun VUIset3DContainerPosition(contstr, pos)=
let contstr.VUICNT_str3d -> vrcontstr in
if pos == nil then nil else
(
set vrcontstr.VUI3D_vPos = pos;
SO3ObjectSetPosition vrcontstr.VUI3D_node pos;
);
0;;
/*! @ingroup VUIApi
* \brief Get the position of a 3d container
*
* Prototype: fun [VUIcontainer] [F F F]
*
* \param VUIcontainer : container
*
* \return [F F F] : position
**/
fun VUIget3DContainerPosition(contstr)=
let contstr.VUICNT_str3d -> vrcontstr in
SO3ObjectGetGlobalPosition vrcontstr.VUI3D_node;;
/*! @ingroup VUIApi
* \brief Set the visibility of a 3d container
*
* Prototype: fun [VUIcontainer I] I
*
* \param VUIcontainer : container
* \param I : boolean (1: visible, 0: not visible)
*
* \return I : 0
**/
fun VUIset3DContainerVisible(contstr, visible)=
let contstr.VUICNT_str3d -> vrcontstr in
SO3ObjectSetVisible vrcontstr.VUI3D_plane visible 1;
0;;
/*! @ingroup VUIApi
* \brief Set the parent target to follow of a 3d container
*
* Prototype: fun [VUIcontainer SO3_OBJECT] I
*
* \param VUIcontainer : container
* \param SO3_OBJECT : parent object
*
* \return I : 0
**/
fun VUIset3DContainerParentTarget(contstr, target)=
set contstr.VUICNT_str3d.VUI3D_target = target;
0;;
/*! @ingroup VUIApi
* \brief Refresh the position / rotation / scale of a Vr container for the actual camera position
*
* Prototype: fun [V3Dsession VUIcontainer I] I
*
* \param V3Dsession : session
* \param VUIcontainer : container
* \param I : Z order
*
* \return I : 0
**/
fun VUIrefreshVrContainerPosition(sessionstr, contstr, contsize, scale, zorder)=
let V3DgetSessionView sessionstr -> viewstr in
let (V3DgetDefaultViewport viewstr) -> viewportstr in
let SO3ViewportGetCamera viewportstr.V3D_viewport -> camera in
let SO3ObjectGetGlobalPosition camera -> gpos in
let SO3ObjectGetGlobalOrientation camera -> gquat in
let SO3MathsQuatToEulerPYR gquat -> [ax ay az] in
let SO3MathsEulerPYRToQuat [0.0 ay 0.0] -> gquat in
let if (viewstr.V3D_bVRmode) then SO3MathsDegreeToRadian iVUIBASEVRFOV else (SO3CameraGetFOVy camera) *. 0.5 -> fovy in
let contsize -> [width height] in
let iVUIBASEVRDIST +. (0.01 *. (itof zorder)) -> dist in
let (dist *. (absf (tan fovy))) *. 2.0 -> ch in
let ch /. (itof iVUIBASEVRHEIGHT) -> pph in
let (minf pph (ch /. ((maxf width height) +. iVUIBASEVRMARGIN))) *. 100.0 *. scale -> nscale in // 50.0 margin
let SO3MathsQuatGetDirection gquat [0.0 0.0 (-.dist)] -> cdir in
let addVectorF gpos cdir -> pos in
(
SO3ObjectSetPosition contstr.VUICNT_str3d.VUI3D_node pos;
SO3ObjectSetOrientation contstr.VUICNT_str3d.VUI3D_node gquat;
VUIset3DContainerScale contstr nscale;
);
0;;
fun VUIupdate3DContainer(contstr, sessionstr)=
let contstr.VUICNT_str3d -> vrcontstr in
let sessionstr.V3D_sessionView -> viewstr in
let V3DgetDefaultViewport viewstr -> viewportstr in
let V3DgetViewportCamera viewportstr -> cam in
let if (viewstr.V3D_bVRmode) then 2.0 else 1.093 -> scalecoef in //Scale coefficient so the pixels of the texture match the pixels of the screen when fScale = 1.0 autoscale is on
(
if (!vrcontstr.VUI3D_bAutoTarget) then
(
if (vrcontstr.VUI3D_target == nil) then nil else
SO3ObjectSetGlobalOrientation vrcontstr.VUI3D_node SO3ObjectGetGlobalOrientation vrcontstr.VUI3D_target;
)
else
(
let if (viewstr.V3D_bVRmode) then
let SO3ObjectGetNodeFacingOrientation vrcontstr.VUI3D_node cam nil nil -> fquat in
let SO3MathsQuatToEulerPYR fquat -> [xdir ydir _] in
SO3MathsEulerPYRToQuat [xdir ydir 0.0]
else
SO3ObjectGetGlobalOrientation cam
-> dirquat in
SO3ObjectSetGlobalOrientation vrcontstr.VUI3D_node dirquat;
);
if (vrcontstr.VUI3D_target == nil) then nil else
let SO3ObjectGetGlobalPosition vrcontstr.VUI3D_target -> pos in
VUIset3DContainerPosition contstr pos;
if (vrcontstr.VUI3D_bAutoScale == 0) then nil else
(
let V3DgetViewportSize viewstr viewportstr -> [_ _ _ vh] in
let if (vh <= 0) then 1 else if (viewstr.V3D_bVRmode) then iVUIBASEVRHEIGHT else vh -> vh in
let V3DgetOrthographicMode cam -> ortho in
let if ortho then V3DgetOrthographicScale cam else 0.0 -> cscale in
let if (viewstr.V3D_bVRmode) then SO3MathsDegreeToRadian iVUIBASEVRFOV else (SO3CameraGetFOVy cam) -> fovy in
let if ((fovy <=. 0.0) || ortho) then 1.0 else fovy -> fovy in
let SO3ObjectGetGlobalPosition cam -> campos in
let SO3WidgetGetSize contstr.VUICNT_strw.VUIW_widget -> [w h] in
let if (cscale != 0.0) then
cscale *. scalecoef *. vrcontstr.VUI3D_fScale
else if (viewstr.V3D_bVRmode) then
getVectorDistanceF campos vrcontstr.VUI3D_vPos
else
let SO3ObjectGetGlobalOrientation cam -> camquat in
let normalizeVectorF (SO3MathsQuatGetDirection camquat [0.0 0.0 (-.1.0)]) -> dir in
(dotVectorF (subVectorF vrcontstr.VUI3D_vPos campos) dir)
-> dist in
let /*if (viewstr.V3D_bVRmode) then 0.5 *. vrcontstr.VUI3D_fMaxAutoscaleDist else*/ vrcontstr.VUI3D_fMaxAutoscaleDist -> maxScaleDist in
let if (maxScaleDist <=. 0.0) then dist else minf dist maxScaleDist -> dist in
let maxf 0.000001 (dist *. scalecoef *. vrcontstr.VUI3D_fScale *. fovy /. (itof vh)) -> cdist in
SO3ObjectSetScale vrcontstr.VUI3D_node [(itof w) *. cdist (itof h) *. cdist (itof h) *. cdist]; // Y scale needs to be set too for the Y offset to work correctly
);
);
0;;
/*! @ingroup VUIApi
* \brief Set a container inputs states
*
* Prototype: fun [VUIcontainer I] I
*
* \param VUIcontainer : container
* \param I : boolean (1: enable, 0: disable mouse / keyboard)
*
* \return I : 0
**/
fun VUIsetContainerInputsEnable(contstr, state)=
set contstr.VUICNT_strw.VUIW_bEnableInputs = state;
if (contstr.VUICNT_strw.VUIW_widget == nil) then nil else
SO3WidgetSetMouseEnable contstr.VUICNT_strw.VUIW_widget state;
0;;
/*! @ingroup VUIApi
* \brief Get a container inputs states
*
* Prototype: fun [VUIcontainer] I
*
* \param VUIcontainer : container
*
* \return I : boolean (1: enable, 0: disable mouse / keyboard)
**/
fun VUIgetContainerInputsEnable(contstr)=
contstr.VUICNT_strw.VUIW_bEnableInputs;;
fun VUIinitContainer(contstr)=
let contstr.VUICNT_strw -> contwstr in
if (contwstr == nil) then nil else
let V3DgetDefaultViewport contwstr.VUIW_view -> viewportstr in
let V3DgetViewportSize contwstr.VUIW_view viewportstr -> [_ _ vw vh] in
let if ((contstr.VUICNT_iSizeMode == VUI_ContSizeScale) && !contwstr.VUIW_bOnMaterial && !contwstr.VUIW_bExternal) then
set contstr.VUICNT_fScale = if (contwstr.VUIW_view.V3D_bVRmode) then fVUIGlobalScaleFactor else fVUIPIXELDENSITY
else
1.0
-> scale in
let contwstr.VUIW_vSize -> [w h] in
(
//create the widget if not available yet
if (contwstr.VUIW_widget != nil || contwstr.VUIW_bExternal) then nil else
let V3DgetDefaultSession contwstr.VUIW_view -> sessionstr in
(
//increment automatic name index
set VUI_NameIndex = VUI_NameIndex + 1;
if (contwstr.VUIW_bOnMaterial) then
(
set contstr.VUICNT_buffer.VUIE_tGlobalCoords = [0 0 (ftoi w) (ftoi h)];
set contstr.VUICNT_buffer.VUIE_tLocalCoords = [0 0 (ftoi w) (ftoi h)];
set contwstr.VUIW_widget = SO3BitmapWidgetCreateOnMaterial (V3DgetSession sessionstr) contwstr.VUIW_material (strcat "HUDCtrl" (itoa VUI_NameIndex)) (ftoi w) (ftoi h) contwstr.VUIW_iTechnique contwstr.VUIW_iPass contwstr.VUIW_iTexture;
if (contstr.VUICNT_str3d == nil) then nil else
VUIset3DContainerScale contstr contstr.VUICNT_str3d.VUI3D_fScale;
0;
)
else if (contwstr.VUIW_bOnBackground) then
(
let VUIcomputeWposSize contstr vw vh -> [px py pw ph] in
set contwstr.VUIW_widget = SO3BitmapWidgetCreateBackground (V3DgetSession sessionstr) viewportstr.V3D_viewport (strcat "HUDCtrl" (itoa VUI_NameIndex)) px py pw ph;
0;
)
else
(
let VUIcomputeWposSize contstr vw vh -> [px py pw ph] in
set contwstr.VUIW_widget = SO3BitmapWidgetCreate (V3DgetSession sessionstr) viewportstr.V3D_viewport (strcat "HUDCtrl" (itoa VUI_NameIndex)) px py pw ph contwstr.VUIW_iZorder;
0;
);
V3DaddWidgetControl viewportstr contwstr.VUIW_widget;
);
if (contwstr.VUIW_bOnMaterial || contwstr.VUIW_bExternal) then nil else
let VUIcomputeWposSize contstr vw vh -> [px py pw ph] in
(
SO3WidgetSetPosition contwstr.VUIW_widget px py;
SO3WidgetSetSize contwstr.VUIW_widget pw ph;
);
SO3WidgetEnterEventCb contwstr.VUIW_widget @cbVUImouseIn contstr;
SO3WidgetExitEventCb contwstr.VUIW_widget @cbVUImouseOut contstr;
SO3WidgetFocusEventCb contwstr.VUIW_widget @cbVUIfocused contstr;
SO3WidgetInputDownEventCb contwstr.VUIW_widget @cbVUIclick contstr;
SO3WidgetInputUpEventCb contwstr.VUIW_widget @cbVUIunClick contstr;
SO3WidgetInputUpdateEventCb contwstr.VUIW_widget @cbVUImouseMove contstr;
SO3WidgetInputWheelEventCb contwstr.VUIW_widget @cbVUImouseWheel contstr;
SO3WidgetTouchAddEventCb contwstr.VUIW_widget @cbVUITouchAdd contstr;
SO3WidgetTouchRemoveEventCb contwstr.VUIW_widget @cbVUITouchRemove contstr;
SO3WidgetTouchUpdateEventCb contwstr.VUIW_widget @cbVUITouchUpdate contstr;
SO3WidgetSetKeyboardEnable contwstr.VUIW_widget 0;
SO3WidgetSetMouseEnable contwstr.VUIW_widget contwstr.VUIW_bEnableInputs;
SO3WidgetSetTransparency contwstr.VUIW_widget 1;
if (contwstr.VUIW_bExternal) then nil else
(
SO3WidgetSetOpacity contwstr.VUIW_widget (itof contwstr.VUIW_iOpacity) *. 0.01;
SO3WidgetSetVisibility contwstr.VUIW_widget 0;
);
SO3WidgetSetTextureRatio contwstr.VUIW_widget contwstr.VUIW_fQuality;
SO3WidgetSetTopOnFocus contstr.VUICNT_strw.VUIW_widget contwstr.VUIW_bTopOnFocus;
SO3WidgetSetForeground contstr.VUICNT_strw.VUIW_widget contwstr.VUIW_bForeground;
//create / update bitmap buffer
VUIupdateContBuffer contstr;
);
0;;
fun VUIsetElementsResourceUpdateState(eltlist, state)=
if (eltlist == nil) then nil else
(
let hd eltlist -> eltstr in
(
set eltstr.VUIE_resource.VUIR_bEnable = state;
VUIsetElementsResourceUpdateState eltstr.VUIE_children state;
);
VUIsetElementsResourceUpdateState (tl eltlist) state;
);
0;;
fun VUIsetContainerResourcesUpdateState(contstr, state)=
set contstr.VUICNT_buffer.VUIE_resource.VUIR_bEnable = state;
VUIsetElementsResourceUpdateState contstr.VUICNT_lElements state;
0;;
fun VUIsetFocusedContainer(contstr)=
SO3WidgetSetFocus contstr.VUICNT_strw.VUIW_widget;
0;;
fun VUIsetContainerTopOnFocus(contstr, state)=
set contstr.VUICNT_strw.VUIW_bTopOnFocus = state;
if (contstr.VUICNT_strw.VUIW_widget == nil) then nil else
SO3WidgetSetTopOnFocus contstr.VUICNT_strw.VUIW_widget contstr.VUICNT_strw.VUIW_bTopOnFocus;
0;;
fun VUIsetContainerForeground(contstr, state)=
set contstr.VUICNT_strw.VUIW_bForeground = state;
if (contstr.VUICNT_strw.VUIW_widget == nil) then nil else
SO3WidgetSetForeground contstr.VUICNT_strw.VUIW_widget contstr.VUICNT_strw.VUIW_bForeground;
0;;
fun VUIshowContainerBase(contstr, state)=
if (contstr.VUICNT_bVisible == state) then nil else
(
set contstr.VUICNT_strw.VUIW_bFadeState = 0;
set contstr.VUICNT_strw.VUIW_iFadeCur = nil;
set contstr.VUICNT_strw.VUIW_iFadeTo = nil;
if (state) then
(
//compute the container visuals
VUIinitContainer contstr;
VUIshowContainerW contstr.VUICNT_strw state;
VUIset3DContainerVisible contstr state;
VUIsetContainerResourcesUpdateState contstr 1;
VUIelementNeedUpdate contstr.VUICNT_buffer 0;
set VUIcontainerEnableList = contstr::VUIcontainerEnableList;
VUIsetFocusedContainer contstr;
VUIsetFocusedElement contstr nil;
0;
)
else
(
set VUIcontainerEnableList = remove_from_list VUIcontainerEnableList contstr;
VUIshowContainerW contstr.VUICNT_strw 0;
VUIset3DContainerVisible contstr state;
VUIsetContainerResourcesUpdateState contstr 0;
//reset all over states
let contstr.VUICNT_lastMouseInElt -> l in
while (l != nil) do
(
let hd l -> [id eltstr] in
VUIexecElementOut eltstr id 0;
set l = tl l;
);
0;
);
set contstr.VUICNT_bVisible = state;
);
0;;
fun VUIsetContainerFadeSpeed(contstr, speed)=
let contstr.VUICNT_strw -> contwstr in
let if speed < 0 then 0 else speed -> speed in
if (contwstr == nil) then nil else
set contwstr.VUIW_iFadeSpeed = speed;
0;;
fun VUIgetContainerFadeSpeed(contstr)=
let contstr.VUICNT_strw -> contwstr in
if (contwstr == nil) then
0
else
contwstr.VUIW_iFadeSpeed;;
fun VUIfadeContainerIn(contstr, cbfun)=
if (contstr.VUICNT_bVisible) then nil else
let contstr.VUICNT_strw -> contwstr in
if (contwstr == nil) then nil else
(
VUIshowContainerBase contstr 1;
set contwstr.VUIW_bFadeState = 1;
set contwstr.VUIW_iFadeCur = 0.0;
set contwstr.VUIW_iFadeTo = itof contwstr.VUIW_iOpacity;
set contwstr.VUIW_cbFade = cbfun;
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetSetOpacity contwstr.VUIW_widget 0.0;
);
0;;
fun VUIfadeContainerOut(contstr, cbfun)=
if (!contstr.VUICNT_bVisible) then nil else
let contstr.VUICNT_strw -> contwstr in
if (contwstr == nil) then nil else
(
set contwstr.VUIW_bFadeState = 1;
set contwstr.VUIW_iFadeCur = if (contwstr.VUIW_iFadeCur == nil) then itof contwstr.VUIW_iOpacity else contwstr.VUIW_iFadeCur;
set contwstr.VUIW_iFadeTo = 0.0;
set contwstr.VUIW_cbFade = cbfun;
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetSetOpacity contwstr.VUIW_widget contwstr.VUIW_iFadeCur *. 0.01;
);
0;;
fun VUIshowContainerExt(contstr, state, cbfun)=
let contstr.VUICNT_strw -> contwstr in
if (contstr.VUICNT_bVisible == state) then nil else
(
if (state) then
(
VUIshowContainerBase contstr 1;
if ((contwstr == nil) || (contwstr.VUIW_iFadeSpeed == 0)) then nil else
(
set contwstr.VUIW_bFadeState = 1;
set contwstr.VUIW_iFadeCur = 0.0;
set contwstr.VUIW_iFadeTo = itof contwstr.VUIW_iOpacity;
set contwstr.VUIW_cbFade = cbfun;
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetSetOpacity contwstr.VUIW_widget 0.0;
set cbfun = nil;
);
0;
)
else
(
if ((contwstr == nil) || (contwstr.VUIW_iFadeSpeed == 0)) then
(
VUIshowContainerBase contstr 0;
0;
)
else
(
set contwstr.VUIW_bFadeState = 1;
set contwstr.VUIW_iFadeCur = if (contwstr.VUIW_iFadeCur == nil) then itof contwstr.VUIW_iOpacity else contwstr.VUIW_iFadeCur;
set contwstr.VUIW_iFadeTo = 0.0;
set contwstr.VUIW_cbFade = cbfun;
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetSetOpacity contwstr.VUIW_widget contwstr.VUIW_iFadeCur *. 0.01;
set cbfun = nil;
0;
);
0;
);
if (cbfun == nil) then nil else
exec cbfun with [contstr contstr.VUICNT_bVisible];
);
0;;
fun VUIshowContainer(contstr, state)=
VUIshowContainerExt contstr state nil;
0;;
fun VUIsetContainerOpacity(contstr, opacity)=
let contstr.VUICNT_strw -> contwstr in
if (contwstr == nil) then nil else
(
set contwstr.VUIW_iOpacity = opacity;
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetSetOpacity contwstr.VUIW_widget (itof opacity) *. 0.01;
);
0;;
/*! @ingroup v3DHUDApi
* \brief Create a 3D container for VR
*
* Prototype: fun [V3Dsession [F F] [F F] [I I] F I I I I I] VUIcontainer
*
* \param V3Dsession : the 3d scene structure
*
* \return VUIcontainer : the new 3D container
**/
fun VUIcreate3dContainer(sessionstr, groupstr, pos, offset, contsize, scale, autoscale, maxautoscaledist, autotarget, opacity, ontop)=
let V3DgetSessionView sessionstr -> viewstr in
let contsize -> [width height] in
let VUImakeContainer VUIC_3D groupstr -> contstr in
let VUImake3Dcont contstr sessionstr pos offset scale autoscale maxautoscaledist autotarget ontop -> vrcontstr in
let VUImakeWcont contstr viewstr 0.0 0.0 width height nil nil opacity 0 -> wcontstr in
(
set wcontstr.VUIW_bOnMaterial = 1;
set wcontstr.VUIW_material = vrcontstr.VUI3D_material;
set wcontstr.VUIW_iTechnique = 0;
set wcontstr.VUIW_iPass = 0;
set wcontstr.VUIW_iTexture = 0;
contstr;
);;
/*! @ingroup v3DHUDApi
* \brief Create a 3D container for VR
*
* Prototype: fun [V3Dsession [F F] [I I] F I I I] VUIcontainer
*
* \param V3Dsession : the 3d scene structure
*
* \return VUIcontainer : the new 3D container
**/
fun VUIcreateVrContainer(sessionstr, groupstr, offset, contsize, scale, opacity, ontop, zorder)=
let V3DgetSessionView sessionstr -> viewstr in
let (V3DgetDefaultViewport viewstr) -> viewportstr in
let SO3ViewportGetCamera viewportstr.V3D_viewport -> camera in
let SO3ObjectGetGlobalPosition camera -> gpos in
let SO3ObjectGetGlobalOrientation camera -> gquat in
let SO3MathsQuatToEulerPYR gquat -> [ax ay az] in
let SO3MathsEulerPYRToQuat [0.0 ay 0.0] -> gquat in
let if (viewstr.V3D_bVRmode) then SO3MathsDegreeToRadian iVUIBASEVRFOV else (SO3CameraGetFOVy camera) *. 0.5 -> fovy in
let contsize -> [width height] in
let iVUIBASEVRDIST +. (0.01 *. (itof zorder)) -> dist in
let (dist *. (absf (tan fovy))) *. 2.0 -> ch in
let ch /. (itof iVUIBASEVRHEIGHT) -> pph in
let (minf pph (ch /. ((maxf width height) +. iVUIBASEVRMARGIN))) *. 100.0 *. scale -> nscale in // 50.0 margin
let SO3MathsQuatGetDirection gquat [0.0 0.0 (-.dist)] -> cdir in
let addVectorF gpos cdir -> pos in
let VUImakeContainer VUIC_VR groupstr -> contstr in
let VUImake3Dcont contstr sessionstr pos offset nscale 0 0.0 0 ontop -> vrcontstr in
let VUImakeWcont contstr viewstr 0.0 0.0 width height nil nil opacity 0 -> wcontstr in
(
set wcontstr.VUIW_bOnMaterial = 1;
set wcontstr.VUIW_material = vrcontstr.VUI3D_material;
set wcontstr.VUIW_iTechnique = 0;
set wcontstr.VUIW_iPass = 0;
set wcontstr.VUIW_iTexture = 0;
SO3ObjectSetOrientation contstr.VUICNT_str3d.VUI3D_node gquat;
contstr;
);;
fun VUIcreateContainerOnMaterial(sessionstr, groupstr, material, technique, pass, texunit, size, opacity)=
let V3DgetSessionView sessionstr -> viewstr in
let VUImakeContainer VUIC_Material groupstr -> contstr in
let size -> [width height] in
let VUImakeWcont contstr viewstr 0.0 0.0 width height nil nil opacity 0 -> wcontstr in
(
set wcontstr.VUIW_bOnMaterial = 1;
set wcontstr.VUIW_material = material;
set wcontstr.VUIW_iTechnique = technique;
set wcontstr.VUIW_iPass = pass;
set wcontstr.VUIW_iTexture = texunit;
contstr;
);;
fun VUIcreateContainerOnBackground(viewstr, groupstr, pos, size, ratiosize, align, opacity)=
let VUImakeContainer VUIC_2D groupstr -> contstr in
let pos -> [xpos ypos] in
let size -> [width height] in
(
VUImakeWcont contstr viewstr xpos ypos width height ratiosize align opacity 100;
set contstr.VUICNT_strw.VUIW_bOnBackground = 1;
contstr;
);;
fun VUIcreateContainer(viewstr, groupstr, pos, size, ratiosize, align, opacity, zorder)=
let VUImakeContainer VUIC_2D groupstr -> contstr in
let pos -> [xpos ypos] in
let size -> [width height] in
(
VUImakeWcont contstr viewstr xpos ypos width height ratiosize align opacity zorder;
contstr;
);;
fun VUIcreateContainerFromWidget(viewstr, groupstr, widget, opacity)=
let VUImakeContainer VUIC_EXTERNAL groupstr -> contstr in
(
VUImakeWcont contstr viewstr 0.0 0.0 100.0 100.0 [0 0 1 1 0 0 0 0] [1 1] opacity 600;
set contstr.VUICNT_strw.VUIW_widget = widget;
set contstr.VUICNT_strw.VUIW_bExternal = 1;
let V3DgetDefaultViewport viewstr -> viewportstr in
V3DaddWidgetControl viewportstr contstr.VUICNT_strw.VUIW_widget;
contstr;
);;
fun VUIupdateContainerWidget(contstr)=
if (!contstr.VUICNT_strw.VUIW_bOnMaterial && !contstr.VUICNT_strw.VUIW_bExternal) then
(
let V3DgetDefaultViewport contstr.VUICNT_strw.VUIW_view -> viewportstr in
let V3DgetViewportSize contstr.VUICNT_strw.VUIW_view viewportstr -> [_ _ vw vh] in
let if (contstr.VUICNT_iSizeMode == VUI_ContSizeScale) then
set contstr.VUICNT_fScale = if (contstr.VUICNT_strw.VUIW_view.V3D_bVRmode) then fVUIGlobalScaleFactor else fVUIPIXELDENSITY
else
1.0
-> scale in
//let VUIscaleVec [vw vh] scale -> [vw vh] in
let VUIcomputeWposSize contstr vw vh -> [px py pw ph] in
(
SO3WidgetSetPosition contstr.VUICNT_strw.VUIW_widget px py;
SO3WidgetSetSize contstr.VUICNT_strw.VUIW_widget pw ph;
);
0;
)
else if (contstr.VUICNT_strw.VUIW_bOnMaterial) then
(
let contstr.VUICNT_strw.VUIW_vSize -> [nw nh] in
(
set contstr.VUICNT_buffer.VUIE_tGlobalCoords = [0 0 (ftoi nw) (ftoi nh)];
set contstr.VUICNT_buffer.VUIE_tLocalCoords = [0 0 (ftoi nw) (ftoi nh)];
SO3WidgetSetSize contstr.VUICNT_strw.VUIW_widget (ftoi nw) (ftoi nh);
);
if (contstr.VUICNT_str3d == nil) then nil else
VUIset3DContainerScale contstr contstr.VUICNT_str3d.VUI3D_fScale;
0;
)
else // external
(
let if (contstr.VUICNT_strw.VUIW_widget == nil) then
let contstr.VUICNT_strw.VUIW_vSize -> [sw sh] in
[(ftoi sw) (ftoi sh)]
else
SO3WidgetGetSize contstr.VUICNT_strw.VUIW_widget
-> [nw nh] in
(
set contstr.VUICNT_strw.VUIW_vSize = [itof nw itof nh];
set contstr.VUICNT_buffer.VUIE_tGlobalCoords = [0 0 nw nh];
set contstr.VUICNT_buffer.VUIE_tLocalCoords = [0 0 nw nh];
);
/*
let contstr.VUICNT_strw.VUIW_vSize -> [nw nh] in
(
set contstr.VUICNT_buffer.VUIE_tGlobalCoords = [0 0 (ftoi nw) (ftoi nh)];
set contstr.VUICNT_buffer.VUIE_tLocalCoords = [0 0 (ftoi nw) (ftoi nh)];
);
*/
if (contstr.VUICNT_str3d == nil) then nil else
VUIset3DContainerScale contstr contstr.VUICNT_str3d.VUI3D_fScale;
0;
);
VUIelementNeedUpdate contstr.VUICNT_buffer 1;
set contstr.VUICNT_bNeedResizeUpdate = 1;
0;;
fun VUIsetContainerClear(constr, state)=
set constr.VUICNT_bClearOnUpdate = state;;
fun VUIsetContainerSize(contstr, size, offsets)=
let 0 -> update in
(
if (size == nil) then nil else
(
let contstr.VUICNT_strw.VUIW_vSize -> [ow oh] in
let size -> [nw nh] in
if ((nw == ow) && (nh == oh)) then nil else
(
set contstr.VUICNT_strw.VUIW_vSize = size;
set update = 1;
);
);
if (offsets == nil) then nil else
(
let offsets -> [npw nph now noh] in
let contstr.VUICNT_strw.VUIW_tPercent -> [px py pw ph xo yo wo ho] in
if ((npw == pw) && (nph == ph) && (now == wo) && (noh == ho)) then nil else
(
set contstr.VUICNT_strw.VUIW_tPercent = [px py npw nph xo yo now noh];
set update = 1;
);
);
if (!update) then nil else
(
VUIupdateContainerWidget contstr;
if ((contstr.VUICNT_iMode != VUIC_VR) || (contstr.VUICNT_str3d == nil)) then nil else
(
let V3DgetSessionView contstr.VUICNT_str3d.VUI3D_session -> viewstr in
let (V3DgetDefaultViewport viewstr) -> viewportstr in
let SO3ViewportGetCamera viewportstr.V3D_viewport -> camera in
let SO3ObjectGetGlobalPosition camera -> gpos in
let SO3ObjectGetGlobalOrientation camera -> gquat in
let SO3MathsQuatToEulerPYR gquat -> [ax ay az] in
let SO3MathsEulerPYRToQuat [0.0 ay 0.0] -> gquat in
let if (viewstr.V3D_bVRmode) then SO3MathsDegreeToRadian iVUIBASEVRFOV else (SO3CameraGetFOVy camera) *. 0.5 -> fovy in
let contstr.VUICNT_strw.VUIW_vSize -> [width height] in
let iVUIBASEVRDIST +. (0.01 *. (itof contstr.VUICNT_str3d.VUI3D_iIndex)) -> dist in
let (dist *. (absf (tan fovy))) *. 2.0 -> ch in
let ch /. (itof iVUIBASEVRHEIGHT) -> pph in
let (minf pph (ch /. ((maxf width height) +. iVUIBASEVRMARGIN))) *. 100.0 -> nscale in // VUIset3DContainerScale * 0.01 // 50.0 margin
let SO3MathsQuatGetDirection gquat [0.0 0.0 (-.dist)] -> cdir in
let addVectorF gpos cdir -> pos in
(
VUIset3DContainerPosition contstr pos;
VUIset3DContainerScale contstr nscale;
);
);
);
);
0;;
fun VUIsetContainerPos(contstr, pos, align, offsets)=
if (pos == nil) then nil else
set contstr.VUICNT_strw.VUIW_vPos = pos;
if (align == nil) then nil else
set contstr.VUICNT_strw.VUIW_tAlign = align;
if (offsets == nil) then nil else
let offsets -> [npx npy nox noy] in
let contstr.VUICNT_strw.VUIW_tPercent -> [px py pw ph xo yo wo ho] in
set contstr.VUICNT_strw.VUIW_tPercent = [npx npy pw ph nox noy wo ho];
VUIupdateContainerWidget contstr;
0;;
fun VUIsetContainerQuality(contstr, quality)=
set contstr.VUICNT_strw.VUIW_fQuality = (itof quality) *. 0.01;
if (contstr.VUICNT_strw.VUIW_widget == nil) then nil else
SO3WidgetSetTextureRatio contstr.VUICNT_strw.VUIW_widget contstr.VUICNT_strw.VUIW_fQuality;
0;;
fun VUIset3dContainerMouseState(contstr, state)=
SO3ObjectSetMouseClick contstr.VUICNT_str3d.VUI3D_plane state;;
/* Container callbacks */
fun VUIsetContainerCbClick(contstr, cbfun)=
set contstr.VUICNT_strw.VUIW_cbClick = cbfun;
0;;
fun VUIsetContainerCbUnClick(contstr, cbfun)=
set contstr.VUICNT_strw.VUIW_cbUnClick = cbfun;
0;;
fun VUIsetContainerCbMouseMove(contstr, cbfun)=
set contstr.VUICNT_strw.VUIW_cbMouseMove = cbfun;
0;;
fun VUIsetContainerCbMouseIn(contstr, cbfun)=
set contstr.VUICNT_strw.VUIW_cbMouseIn = cbfun;
0;;
fun VUIsetContainerCbMouseOut(contstr, cbfun)=
set contstr.VUICNT_strw.VUIW_cbMouseOut = cbfun;
0;;
fun VUIsetContainerCbFocused(contstr, cbfun)=
set contstr.VUICNT_strw.VUIW_cbFocused = cbfun;
0;;
/* Element callbacks */
fun VUIsetElementCbCheck(eltstr, cbfun)=
set eltstr.VUIE_cbCheck = cbfun;
0;;
fun VUIsetElementCbClick(eltstr, cbfun)=
set eltstr.VUIE_cbClick = cbfun;
0;;
fun VUIsetElementCbUnClick(eltstr, cbfun)=
set eltstr.VUIE_cbUnClick = cbfun;
0;;
fun VUIsetElementCbFullClick(eltstr, cbfun)=
set eltstr.VUIE_cbFullClick = cbfun;
0;;
fun VUIsetElementCbMouseMove(eltstr, cbfun)=
set eltstr.VUIE_cbMouseMove = cbfun;
0;;
fun VUIsetElementCbMouseIn(eltstr, cbfun)=
set eltstr.VUIE_cbMouseIn = cbfun;
0;;
fun VUIsetElementCbMouseOut(eltstr, cbfun)=
set eltstr.VUIE_cbMouseOut = cbfun;
0;;
fun VUIsetElementCbFocused(eltstr, cbfun)=
set eltstr.VUIE_cbFocused = cbfun;
0;;
fun VUIsetElementCbValidate(eltstr, cbfun)=
set eltstr.VUIE_cbValidate = cbfun;
0;;
fun VUIsetElementCbKeyDown(eltstr, cbfun)=
set eltstr.VUIE_cbKeyDown = cbfun;
0;;
fun VUIsetElementCbKeyUp(eltstr, cbfun)=
set eltstr.VUIE_cbKeyUp = cbfun;
0;;
fun VUIsetElementCbPreDraw(eltstr, cbfun)=
set eltstr.VUIE_cbPreDraw = cbfun;
0;;
fun VUIsetElementCbDraw(eltstr, cbfun)=
set eltstr.VUIE_cbDraw = cbfun;
0;;
fun VUIsetElementCbPostDraw(eltstr, cbfun)=
set eltstr.VUIE_cbPostDraw = cbfun;
0;;
fun cbHUDgetDirectionKey(key, eltstr)=
if ((key == 331) || (key == 333) || (key == 328) || (key == 336)) then
(
let if (key == 331) then // left
-1
else if (key == 333) then // right
1
else if (key == 328) then // up
-2
else if (key == 336) then // down
2
else
0
-> dir in
if (dir == 0) then nil else
(
let VUIgetNextElement eltstr dir -> nfocused in
if (nfocused == nil) then 0 else
(
VUImouseMoveElement nfocused 0 0 0 0;
VUIsetFocusedElement nfocused.VUIE_container nfocused;
VUIsetElementFocusedBorder nfocused 2 0x0000ffff;
//addLogMessage "Mouse in elt";
exec nfocused.VUIE_cbMouseIn with [nfocused];
1;
);
);
)
else 0;;
/* General lib functions */
fun cbHUDKeyDown(viewstr, key, ascode)=
let 0 -> used in
(
//exec element cbkey
let VUIcontainerEnableList -> list in
let 0 -> found in
(
while ((list != nil) && !found) do
(
let hd list -> contstr in
let contstr.VUICNT_lastFocusedElt -> eltstr in
if (!contstr.VUICNT_strw.VUIW_bEnableInputs || !contstr.VUICNT_bVisible || (eltstr == nil) || (!eltstr.VUIE_bVisible) || (eltstr.VUIE_bIgnoreInput) || (eltstr.VUIE_cbKeyDown == nil)) then nil else
(
set used = exec eltstr.VUIE_cbKeyDown with [eltstr key];
set found = 1;
);
set list = tl list;
);
);
if (used) then nil else
(
if (key == 1) then // esc
(
if (VUI_focusedContainer == nil) then nil else
(
SO3WidgetUnFocus VUI_focusedContainer.VUICNT_strw.VUIW_widget;
if ((viewstr.V3D_bVRmode) && (VUI_focusedContainer.VUICNT_lastFocusedElt.VUIE_iType == VUI_EltEditText)) then
(
VUIhideVrKeyboard VUIdefVrKeyboard;
set used = 1;
0;
)
else if (((_platform != SCOL_PLATFORM_ANDROID) && (_platform != SCOL_PLATFORM_IOS)) || (VUI_focusedContainer.VUICNT_lastFocusedElt.VUIE_iType != VUI_EltEditText)) then nil else
(
_ShowSoftKeyboard 0;
set used = 1;
0;
);
set VUI_focusedContainer = nil;
);
0;
)
else
(
if (key == 58)|| (key == 325) || (key == 1) || (key == 329) || (key == 337) || (key == 338) || (key == 327) || (key == 335) || (key == 59) || (key == 60) ||
(key == 61) || (key == 62) || (key == 63) || (key == 64) || (key == 65) || (key == 66) || (key == 67) || (key == 87) || (key == 88)
then nil else
let VUIcontainerEnableList -> list in
let 0 -> found in
(
while ((list != nil) && !found) do
(
let hd list -> contstr in
let contstr.VUICNT_lastFocusedElt -> eltstr in
if (!contstr.VUICNT_strw.VUIW_bEnableInputs || !contstr.VUICNT_bVisible || (eltstr == nil)) then nil else
(
if ((eltstr != nil) && (eltstr.VUIE_iType == VUI_EltEditText)) then
(
let eltstr.VUIE_Text.VUIT_sContent -> txt in
if (((key == 28) || (key == 284)) && !eltstr.VUIE_Text.VUIT_bMultiline) then // enter
(
if (viewstr.V3D_bVRmode) then
(
VUIhideVrKeyboard VUIdefVrKeyboard;
0;
)
else if ((_platform != SCOL_PLATFORM_ANDROID) && (_platform != SCOL_PLATFORM_IOS)) then nil else
(
_ShowSoftKeyboard 0;
0;
);
exec eltstr.VUIE_cbValidate with [eltstr eltstr.VUIE_Text.VUIT_sContent 1];
0;
)
else if (((key == 28) || (key == 284)) && eltstr.VUIE_Text.VUIT_bMultiline) then
(
set eltstr.VUIE_Text.VUIT_sContent = strcat txt "\10";
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
0;
)
else if (key == 14) then // backspace
(
set eltstr.VUIE_Text.VUIT_sContent = substr txt 0 ((strlen txt) - 1);
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
0;
)
else if (key == 339) then // supp
(
set eltstr.VUIE_Text.VUIT_sContent = "";
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
0;
)
else if ((key == 28) || (key == 284)) then // ENTER
(
let eltstr.VUIE_tGlobalCoords -> [dx dy dw dh] in
let VUIunscaleCoords (if (VUI_DRAW_GLOBAL) then eltstr.VUIE_tDrawCoords else [dx dy dw dh 0 0]) eltstr.VUIE_container.VUICNT_fScale -> [px py pw ph] in
VUIclickElement eltstr 0 (px + (pw / 2)) (py + (ph / 2)) 1;
)
else if ((key == 331) || (key == 333) || (key == 328) || (key == 336)) then
(
cbHUDgetDirectionKey key eltstr;
)
else if ((key == 47) && (_keybdstate == 2)) then
(
let _GETclipBoardData -> cboard in
if (eltstr.VUIE_Text.VUIT_bNumberOnly && ((atof cboard) == nil)) then nil else
(
set eltstr.VUIE_Text.VUIT_sContent = strcat txt cboard;
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
);
0;
)
else if (ascode != 0) then
(
if (eltstr.VUIE_Text.VUIT_bNumberOnly && ((ascode < 45) || (ascode > 57) || (ascode == 47))) then nil else
(
set eltstr.VUIE_Text.VUIT_sContent = strcat txt (ctoa ascode);
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
);
0;
)
else nil;
// auto scroll
let eltstr.VUIE_Text.VUIT_tTextSize -> [tw th] in
let eltstr.VUIE_Text.VUIT_tScroll -> [sw sh] in
let eltstr.VUIE_Text.VUIT_tCoords -> [_ _ cw ch] in
let if tw < cw then 0 else (-(tw - cw)) -> offx in
let if th < ch then 0 else (-(th - ch)) -> offy in
(
set eltstr.VUIE_Text.VUIT_tScroll = [offx offy];
);
set used = 1;
VUIelementNeedUpdate eltstr 0;
)
else
(
set used = cbHUDgetDirectionKey key eltstr;
if (key != 28) then nil else // ENTER
(
let eltstr.VUIE_tGlobalCoords -> [dx dy dw dh] in
let VUIunscaleCoords (if (VUI_DRAW_GLOBAL) then eltstr.VUIE_tDrawCoords else [dx dy dw dh 0 0]) eltstr.VUIE_container.VUICNT_fScale -> [px py pw ph] in
VUIclickElement eltstr 0 (px + (pw / 2)) (py + (ph / 2)) 1;
set used = 1;
);
);
set found = 1;
);
set list = tl list;
);
if (found || (VUI_focusedContainer == nil)) then nil else
set used = cbHUDgetDirectionKey key (hd VUI_focusedContainer.VUICNT_lElements);
);
0;
);
);
used;
);;
fun cbHUDKeyUp(viewstr, key)=
let 0 -> used in
(
//exec element cbkey
let VUIcontainerEnableList -> list in
let 0 -> found in
(
while ((list != nil) && !found) do
(
let hd list -> contstr in
let contstr.VUICNT_lastFocusedElt -> eltstr in
if (!contstr.VUICNT_strw.VUIW_bEnableInputs || !contstr.VUICNT_bVisible || (eltstr == nil) || (!eltstr.VUIE_bVisible) || (eltstr.VUIE_bIgnoreInput) || (eltstr.VUIE_cbKeyUp == nil)) then nil else
(
set used = exec eltstr.VUIE_cbKeyUp with [eltstr key];
set found = 1;
);
set list = tl list;
);
);
if used || (key == 58) || (key == 328) || (key == 336) || (key == 331) || (key == 333) || (key == 325) || (key == 1) ||
(key == 329) || (key == 337) || (key == 338) || (key == 327) || (key == 335) || (key == 59) || (key == 60) ||
(key == 61) || (key == 62) || (key == 63) || (key == 64) || (key == 65) || (key == 66) || (key == 67) || (key == 87) || (key == 88)
then nil else
let VUIcontainerEnableList -> list in
let 0 -> found in
while ((list != nil) && !found) do
(
let hd list -> contstr in
let contstr.VUICNT_lastFocusedElt -> eltstr in
if (!contstr.VUICNT_strw.VUIW_bEnableInputs || !contstr.VUICNT_bVisible || (eltstr == nil)) then nil else
(
if (eltstr.VUIE_iType == VUI_EltEditText && eltstr.VUIE_Text.VUIT_bMultiline) then nil else
if (key != 28) then nil else // ENTER
(
VUIunclickElement eltstr 0 0 0 1 1;
set used = 1;
);
if (eltstr.VUIE_iType != VUI_EltEditText) then nil else
set used = 1;
set found = 1;
);
set list = tl list;
);
used;
);;
fun cbHUDresizeView(viewstr, width, height)=
VUIupdateScreenSensity viewstr;
let VUIcontainerEnableList -> list in
while (list != nil) do
(
let hd list -> contstr in
(
//update cont elements
if (contstr.VUICNT_strw.VUIW_bOnMaterial || contstr.VUICNT_strw.VUIW_bExternal) then nil else
VUIupdateContainerWidget contstr;
0;
);
set list = tl list;
);
0;;
fun cbHUDPreRender(sessionstr, etime)=
let VUIanimatedResourcesList -> list in
while (list != nil) do
(
let hd list -> resstr in
let resstr.VUIR_parent.VUIE_container -> contstr in
if (!resstr.VUIR_bEnable) then nil else
(
//text cursor
if ((resstr.VUIR_parent != contstr.VUICNT_lastFocusedElt) || (contstr.VUICNT_lastFocusedElt.VUIE_iType != VUI_EltEditText)) then nil else
(
let resstr.VUIR_iTick -> tick in
let if (tick != nil) then tick else 0 -> tick in
let set resstr.VUIR_iTick = tick + etime -> rtick in
if ((rtick / 1000) < (1000 / 2)) then nil else
(
if (resstr.VUIR_parent.VUIE_Text.VUIT_iCursor == 1) then
set resstr.VUIR_parent.VUIE_Text.VUIT_iCursor = 2
else
set resstr.VUIR_parent.VUIE_Text.VUIT_iCursor = 1;
set resstr.VUIR_parent.VUIE_Text.VUIT_bNeedUpdate = 1;
VUIelementNeedUpdate resstr.VUIR_parent 0;
set resstr.VUIR_iTick = 0;
);
);
//animated resources
if (resstr.VUIR_iNbFrames <= 1) then nil else
let resstr.VUIR_iTick -> tick in
let if (tick != nil) then tick else 0 -> tick in
(
//addLogMessage "Anim!";
let set resstr.VUIR_iTick = tick + etime -> rtick in
let if (resstr.VUIR_iFramesPerSecond <= 0) then 1 else resstr.VUIR_iFramesPerSecond -> fps in
if ((rtick / 1000) < (1000 / fps)) then nil else
(
set resstr.VUIR_iCurFrame = resstr.VUIR_iCurFrame + 1;
if (resstr.VUIR_iCurFrame < resstr.VUIR_iNbFrames) then nil else
set resstr.VUIR_iCurFrame = 0;
VUIelementNeedUpdate resstr.VUIR_parent 0;
set resstr.VUIR_iTick = 0;
);
0;
);
);
set list = tl list;
);
let VUIcontainerEnableList -> list in
while (list != nil) do
(
let hd list -> contstr in
(
if (!contstr.VUICNT_bVisible) then nil else
(
//fade in/out
if (!contstr.VUICNT_strw.VUIW_bFadeState) then nil else
(
let contstr.VUICNT_strw -> contwstr in
let contwstr.VUIW_iFadeTick -> tick in
let if (tick != nil) then tick else 0 -> tick in
let set contwstr.VUIW_iFadeTick = tick + etime -> rtick in
if ((rtick / 1000) < (1000 / 60)) then nil else //60 fps
(
let (itof rtick) /. (itof contwstr.VUIW_iFadeSpeed) *. 0.1 -> coef in
let if (contwstr.VUIW_iFadeCur <. contwstr.VUIW_iFadeTo) then 1 else 0 -> dir in
let if dir then
minf (contwstr.VUIW_iFadeCur +. coef) contwstr.VUIW_iFadeTo
else
maxf (contwstr.VUIW_iFadeCur -. coef) contwstr.VUIW_iFadeTo
-> nval in
(
set contwstr.VUIW_iFadeTick = 0;
set contwstr.VUIW_iFadeCur = nval;
if (contwstr.VUIW_bExternal) then nil else
SO3WidgetSetOpacity contwstr.VUIW_widget contwstr.VUIW_iFadeCur *. 0.01;
if (contwstr.VUIW_iFadeCur != contwstr.VUIW_iFadeTo) then nil else
(
if (dir || (contwstr.VUIW_iFadeCur >. 0.0)) then nil else
VUIshowContainerBase contstr 0;
set contwstr.VUIW_bFadeState = 0;
exec contwstr.VUIW_cbFade with [contstr contstr.VUICNT_bVisible];
);
);
);
);
let contstr.VUICNT_strw.VUIW_tMouseInertia -> [ix iy] in
(
if (ix == 0) && (iy == 0) then nil else
(
let contstr.VUICNT_strw.VUIW_iInertiaTick -> tick in
let if (tick != nil) then tick else 0 -> tick in
let set contstr.VUICNT_strw.VUIW_iInertiaTick = tick + etime -> rtick in
if ((rtick / 1000) < (1000 / 30)) then nil else
(
let if (ix > 0) then ix - 1 else if (ix < 0) then ix + 1 else 0 -> iax in
let if (iy > 0) then iy - 1 else if (iy < 0) then iy + 1 else 0 -> iay in
(
set contstr.VUICNT_strw.VUIW_tMouseInertia = [iax iay];
set contstr.VUICNT_strw.VUIW_iInertiaTick = 0;
let VUIgetScrollableElement contstr.VUICNT_lastFocusedElt -> scrollstr in
if (scrollstr != nil) then
let if (scrollstr.VUIE_iScrollMode & VUI_EltScrollV) then iay else 0 -> iay in
let if (scrollstr.VUIE_iScrollMode & VUI_EltScrollH) then iax else 0 -> iax in
VUIscrollElement scrollstr iax iay
else if (!contstr.VUICNT_lastFocusedElt.VUIE_Text.VUIT_bMultiline) then nil else
VUIscrollText contstr.VUICNT_lastFocusedElt iay;
if ((contstr.VUICNT_lastFocusedElt.VUIE_iType != VUI_EltList) && (contstr.VUICNT_lastFocusedElt.VUIE_iType != VUI_EltListElement)) then nil else
VUIelementNeedUpdate if (contstr.VUICNT_lastFocusedElt.VUIE_iType == VUI_EltListElement) then contstr.VUICNT_lastFocusedElt.VUIE_parent else contstr.VUICNT_lastFocusedElt 1;
);
);
);
if (!contstr.VUICNT_bNeedUpdate) then nil else
(
VUIupdateContBuffer contstr;
set contstr.VUICNT_bNeedUpdate = 0;
if (!contstr.VUICNT_bNeedResizeUpdate) then nil else
(
set contstr.VUICNT_bNeedResizeUpdate = 0;
VUIelementNeedUpdate contstr.VUICNT_buffer 1;
);
);
);
);
);
set list = tl list;
);
0;;
fun cbHUDPostRender(sessionstr)=
// update 3D position after all scene update
let VUIcontainerEnableList -> list in
while (list != nil) do
(
let hd list -> contstr in
(
if ((!contstr.VUICNT_bVisible) || (contstr.VUICNT_str3d == nil)) then nil else
VUIupdate3DContainer contstr sessionstr;
);
set list = tl list;
);
0;;
/* Controls */
fun VUIsetElementBorder(eltstr, border, color)=
let eltstr.VUIE_resource -> resstr in
(
set resstr.VUIR_iBorder = border;
set resstr.VUIR_bdColor = color;
);
VUIelementNeedUpdate eltstr 0;
0;;
fun VUIsetElementFocusedBorder(eltstr, border, color)=
let eltstr.VUIE_resource -> resstr in
(
set resstr.VUIR_iFocusedBorder = border;
set resstr.VUIR_bFocusedColor = color;
);
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIisFocusedElement(eltstr)=
let eltstr.VUIE_container.VUICNT_lastMouseInElt -> le in
let 0 -> found in
(
while ((le != nil) && !found) do
(
let hd le -> [_ feltstr] in
if (feltstr != eltstr) then nil else
set found = 1;
set le = tl le;
);
found;
);;
fun VUIsetElementState(eltstr, state)=
if (state > 0) then
if (VUIisFocusedElement eltstr) then
set eltstr.VUIE_resource.VUIR_iCurState = 1
else
set eltstr.VUIE_resource.VUIR_iCurState = 0
else
set eltstr.VUIE_resource.VUIR_iCurState = 3;
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIsetElementPos(eltstr, pos, align, offsets)=
if (pos == nil) then nil else
set eltstr.VUIE_vPos = pos;
if (align == nil) then nil else
set eltstr.VUIE_tAlign = align;
if (offsets == nil) then nil else
let offsets -> [npx npy nox noy] in
let eltstr.VUIE_tPercent -> [px py pw ph xo yo wo ho] in
set eltstr.VUIE_tPercent = [npx npy pw ph nox noy wo ho];
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIsetElementSize(eltstr, size, offsets)=
if (size == nil) then nil else
set eltstr.VUIE_vSize = size;
if (offsets == nil) then nil else
let offsets -> [npw nph now noh] in
let eltstr.VUIE_tPercent -> [px py pw ph xo yo wo ho] in
set eltstr.VUIE_tPercent = [px py npw nph xo yo now noh];
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIsetElementRatiosize(eltstr, ratiosize)=
set eltstr.VUIE_tPercent = ratiosize;
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIsetElementResource(eltstr, bgcolor, border, bdcolor, file, flags, nbstates, nbcols, nbframes, framepersec)=
VUImakeResource eltstr bgcolor border bdcolor file flags nbstates nbcols nbframes framepersec;;
fun VUIcreateFrame(contstr, parentstr, pos, size, ratiosize, align)=
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltFrame -> eltstr in
(
VUImakeResource eltstr nil nil nil nil nil nil nil nil nil;
eltstr;
);;
fun VUIcreateButtonExt(contstr, parentstr, pos, size, ratiosize, align, themeref)=
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltButton -> eltstr in
let VUIsplitThemeRef themeref -> [defname eltname] in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) defname -> defstr in
(
VUIsetElementTheme eltstr defstr eltname;
eltstr;
);;
fun VUIcreateButton(contstr, parentstr, pos, size, ratiosize, align)=
VUIcreateButtonExt contstr parentstr pos size ratiosize align "common/button";;
fun VUIsetElementScroll(eltstr, scrollflags)=
let eltstr.VUIE_tScroll -> [scx scy] in
(
set eltstr.VUIE_iScrollMode = scrollflags;
if !(eltstr.VUIE_iScrollMode & VUI_EltScrollV) then
(
if (eltstr.VUIE_scrollTop == nil) then nil else
VUIdestroyElement eltstr.VUIE_scrollTop;
set eltstr.VUIE_scrollTop = nil;
if (eltstr.VUIE_scrollBottom == nil) then nil else
VUIdestroyElement eltstr.VUIE_scrollBottom;
set eltstr.VUIE_scrollBottom = nil;
set eltstr.VUIE_tScroll = [scx 0];
set scx = 0;
)
else nil;
if !(eltstr.VUIE_iScrollMode & VUI_EltScrollH) then
(
if (eltstr.VUIE_scrollLeft == nil) then nil else
VUIdestroyElement eltstr.VUIE_scrollLeft;
set eltstr.VUIE_scrollLeft = nil;
if (eltstr.VUIE_scrollRight == nil) then nil else
VUIdestroyElement eltstr.VUIE_scrollRight;
set eltstr.VUIE_scrollRight = nil;
set eltstr.VUIE_tScroll = [0 scy];
set scy = 0;
)
else nil;
);
if (scrollflags) then
let VUIgetThemeDef (VUIgetContainerGroupTheme eltstr.VUIE_container) "common" -> defstr in
(
if !(scrollflags & VUI_EltScrollV) then nil else
(
if (eltstr.VUIE_scrollTop != nil) then nil else
(
set eltstr.VUIE_scrollTop = VUIcreateButton eltstr.VUIE_container eltstr [0.0 5.0] [48.0 16.0] [0 0 0 0 0 0 0 0] [1 0];
set eltstr.VUIE_scrollTop.VUIE_bVisible = 0;
VUIsetElementTheme eltstr.VUIE_scrollTop defstr "scrollUp";
VUIsetElementCbClick eltstr.VUIE_scrollTop mkfun6 @cbVUIelementScrollBtnClick [eltstr [0 10]];
VUIsetElementCbUnClick eltstr.VUIE_scrollTop mkfun6 @cbVUIelementScrollBtnUnClick eltstr;
);
if (eltstr.VUIE_scrollBottom != nil) then nil else
(
set eltstr.VUIE_scrollBottom = VUIcreateButton eltstr.VUIE_container eltstr [0.0 5.0] [48.0 16.0] [0 0 0 0 0 0 0 0] [1 2];
set eltstr.VUIE_scrollBottom.VUIE_bVisible = 0;
VUIsetElementTheme eltstr.VUIE_scrollBottom defstr "scrollDown";
VUIsetElementCbClick eltstr.VUIE_scrollBottom mkfun6 @cbVUIelementScrollBtnClick [eltstr [0 (-10)]];
VUIsetElementCbUnClick eltstr.VUIE_scrollBottom mkfun6 @cbVUIelementScrollBtnUnClick eltstr;
);
);
if !(scrollflags & VUI_EltScrollH) then nil else
(
if (eltstr.VUIE_scrollLeft != nil) then nil else
(
set eltstr.VUIE_scrollLeft = VUIcreateButton eltstr.VUIE_container eltstr [5.0 0.0] [16.0 49.0] [0 0 0 0 0 0 0 0] [0 1];
set eltstr.VUIE_scrollLeft.VUIE_bVisible = 0;
VUIsetElementTheme eltstr.VUIE_scrollLeft defstr "scrollLeft";
VUIsetElementCbClick eltstr.VUIE_scrollLeft mkfun6 @cbVUIelementScrollBtnClick [eltstr [10 0]];
VUIsetElementCbUnClick eltstr.VUIE_scrollLeft mkfun6 @cbVUIelementScrollBtnUnClick eltstr;
);
if (eltstr.VUIE_scrollRight != nil) then nil else
(
set eltstr.VUIE_scrollRight = VUIcreateButton eltstr.VUIE_container eltstr [5.0 0.0] [16.0 49.0] [0 0 0 0 0 0 0 0] [2 1];
set eltstr.VUIE_scrollRight.VUIE_bVisible = 0;
VUIsetElementTheme eltstr.VUIE_scrollRight defstr "scrollRight";
VUIsetElementCbClick eltstr.VUIE_scrollRight mkfun6 @cbVUIelementScrollBtnClick [eltstr [(-10) 0]];
VUIsetElementCbUnClick eltstr.VUIE_scrollRight mkfun6 @cbVUIelementScrollBtnUnClick eltstr;
);
);
)
else nil;
VUIelementNeedUpdate eltstr 1;
0;;
/* Elements Text */
fun VUIsetElementTextContent(eltstr, text)=
set eltstr.VUIE_Text.VUIT_sContent = if (text == nil) then "" else text;
set eltstr.VUIE_Text.VUIT_tScroll = [0 0];
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIsetElementTextNumberOnly(eltstr, state)=
set eltstr.VUIE_Text.VUIT_bNumberOnly = state;
0;;
fun VUIsetElementTextAlign(eltstr, align)=
set eltstr.VUIE_Text.VUIT_iAlign = align;
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIgetThemeFont(defstr, element)=
let VUIgetThemeElement defstr element -> ethstr in
let ethstr.VUITHE_font -> fthstr in
let if (fthstr == nil) then
(
set defstr = VUIgetThemeDef defstr.VUITHD_parent "common";
set element = "font";
let VUIgetThemeElement defstr element -> ethstr in
ethstr.VUITHE_font
)
else
fthstr
-> fthstr in
mkVUIfontInt [(VUIaddThemeFont fthstr) 1 [defstr.VUITHD_sName element]];;
fun VUIsetElementThemeFont(eltstr, themestr, defstr, element)=
if (eltstr.VUIE_Text.VUIT_font == nil) then nil else
(
VUIdelFont eltstr.VUIE_Text.VUIT_font.VUIFI_Font;
set eltstr.VUIE_Text.VUIT_font = nil;
);
let if (defstr != nil) then defstr else
if (eltstr.VUIE_iType == VUI_EltSelect || eltstr.VUIE_iType == VUI_EltListElement) then
VUIgetThemeDef themestr "list"
else
VUIgetThemeDef themestr "common"
-> defstr in
let VUIgetThemeElement defstr element -> ethstr in
let if (ethstr.VUITHE_font != nil) then [element ethstr] else
let if (eltstr.VUIE_iType == VUI_EltButton) then
"button"
else if (eltstr.VUIE_iType == VUI_EltEditText) then
"editText"
else if (eltstr.VUIE_iType == VUI_EltSelect) then
"select"
else if (eltstr.VUIE_iType == VUI_EltListElement) then
"listElement"
else
"font"
-> thname in
[thname VUIgetThemeElement defstr thname]
-> [thname ethstr] in
let ethstr.VUITHE_font -> fthstr in
(
set eltstr.VUIE_Text.VUIT_font = mkVUIfontInt[(VUIaddThemeFont fthstr) 1 [defstr.VUITHD_sName thname]];
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
//increment usecount
set eltstr.VUIE_Text.VUIT_font.VUIFI_Font.VUIF_iUsed = eltstr.VUIE_Text.VUIT_font.VUIFI_Font.VUIF_iUsed + 1;
);
0;;
fun VUIsetElementFont(eltstr, fontistr)=
if (fontistr == nil) then
(
VUIsetElementThemeFont eltstr (VUIgetContainerGroupTheme eltstr.VUIE_container) nil nil;
0;
)
else
(
if (eltstr.VUIE_Text.VUIT_font == nil) then nil else
VUIdelFont eltstr.VUIE_Text.VUIT_font.VUIFI_Font;
//increment usecount
set fontistr.VUIFI_Font.VUIF_iUsed = fontistr.VUIFI_Font.VUIF_iUsed + 1;
set eltstr.VUIE_Text.VUIT_font = fontistr;
0;
);
0;;
fun VUIsetElementText(eltstr, fontistr, text, pos, size, margin, align, sizeflags, multiline)=
if ((text == nil) && (eltstr.VUIE_iType != VUI_EltEditText)) then
(
if (eltstr.VUIE_Text.VUIT_scrollTop == nil) then nil else
VUIdestroyElement eltstr.VUIE_Text.VUIT_scrollTop;
if (eltstr.VUIE_Text.VUIT_scrollBottom == nil) then nil else
VUIdestroyElement eltstr.VUIE_Text.VUIT_scrollBottom;
set eltstr.VUIE_Text = nil;
set eltstr.VUIE_Text.VUIT_tScroll = [0 0];
0;
)
else
(
if (eltstr.VUIE_Text != nil) then nil else
set eltstr.VUIE_Text = mkVUIText [eltstr nil nil 0 0 [0 0] [0 0] [0 0] nil 0 1 [0 0] 0 [0 0] 0 0 nil nil nil 0];
VUIsetElementFont eltstr fontistr;
if (pos == nil) then nil else
set eltstr.VUIE_Text.VUIT_tPos = pos;
if (size == nil) then nil else
set eltstr.VUIE_Text.VUIT_tSize = size;
if (margin == nil) then nil else
set eltstr.VUIE_Text.VUIT_tMargin = margin;
if (align == nil) then nil else
set eltstr.VUIE_Text.VUIT_iAlign = align;
if (align == nil) then nil else
set eltstr.VUIE_Text.VUIT_iUpdateSize = sizeflags;
if (multiline == nil) then nil else
set eltstr.VUIE_Text.VUIT_bMultiline = multiline;
let if (text == nil) then "" else text -> text in
set eltstr.VUIE_Text.VUIT_sContent = text;
set eltstr.VUIE_Text.VUIT_tScroll = [0 0];
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
let VUIgetThemeDef (VUIgetContainerGroupTheme eltstr.VUIE_container) "common" -> defstr in
(
if (eltstr.VUIE_Text.VUIT_scrollTop != nil || !eltstr.VUIE_Text.VUIT_bMultiline) then nil else
(
set eltstr.VUIE_Text.VUIT_scrollTop = VUIcreateButton eltstr.VUIE_container eltstr [0.0 5.0] [48.0 16.0] [0 0 0 0 0 0 0 0] [1 0];
set eltstr.VUIE_Text.VUIT_scrollTop.VUIE_bVisible = 0;
VUIsetElementTheme eltstr.VUIE_Text.VUIT_scrollTop defstr "scrollUp";
VUIsetElementCbClick eltstr.VUIE_Text.VUIT_scrollTop mkfun6 @cbVUItextScrollBtnClick [eltstr.VUIE_Text 10];
VUIsetElementCbUnClick eltstr.VUIE_Text.VUIT_scrollTop mkfun6 @cbVUItextScrollBtnUnClick eltstr.VUIE_Text;
);
if (eltstr.VUIE_Text.VUIT_scrollBottom != nil || !eltstr.VUIE_Text.VUIT_bMultiline) then nil else
(
set eltstr.VUIE_Text.VUIT_scrollBottom = VUIcreateButton eltstr.VUIE_container eltstr [0.0 5.0] [48.0 16.0] [0 0 0 0 0 0 0 0] [1 2];
set eltstr.VUIE_Text.VUIT_scrollBottom.VUIE_bVisible = 0;
VUIsetElementTheme eltstr.VUIE_Text.VUIT_scrollBottom defstr "scrollDown";
VUIsetElementCbClick eltstr.VUIE_Text.VUIT_scrollBottom mkfun6 @cbVUItextScrollBtnClick [eltstr.VUIE_Text (-10)];
VUIsetElementCbUnClick eltstr.VUIE_Text.VUIT_scrollBottom mkfun6 @cbVUItextScrollBtnUnClick eltstr.VUIE_Text;
);
);
0;
);
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIsetElementTextPasswordState(eltstr, state)=
set eltstr.VUIE_Text.VUIT_bIsPassword = state;
VUIelementNeedUpdate eltstr 1;
0;;
fun VUIgetElementTextPasswordState(eltstr)=
eltstr.VUIE_Text.VUIT_bIsPassword;;
fun VUIgetElementText(eltstr)=
eltstr.VUIE_Text.VUIT_sContent;;
fun VUIgetElementResource(eltstr)=
eltstr.VUIE_resource;;
fun VUIgetElementContainer(eltstr)=
eltstr.VUIE_container;;
fun VUIcreateEditTextExt(contstr, parentstr, pos, size, ratiosize, align, fontstr, margin, text, multiline, themeref)=
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltEditText -> eltstr in
let VUIsplitThemeRef themeref -> [defname eltname] in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) defname -> defstr in
let if fontstr != nil then VUIcreateFontInterface fontstr else VUIgetThemeFont defstr eltname -> lbfontstr in
(
VUIsetElementTheme eltstr defstr eltname;
let if (multiline) then iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP else iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNCENTER -> alignflags in
VUIsetElementText eltstr lbfontstr text [0 0] [0 0] margin alignflags VUI_TextStatic multiline;
eltstr;
);;
fun VUIcreateEditText(contstr, parentstr, pos, size, ratiosize, align, fontstr, margin, text, multiline)=
VUIcreateEditTextExt contstr parentstr pos size ratiosize align fontstr margin text multiline "common/editText";;
/* Float value */
fun cbVUIfloatChange(eltstr, value, state, floatstr)=
let minf (maxf (atof value) floatstr.VUIF_fMin) floatstr.VUIF_fMax -> fvalue in
let G2DgetFtoA fvalue floatstr.VUIF_iNbDec -> avalue in
(
set floatstr.VUIF_fValue = fvalue;
set eltstr.VUIE_Text.VUIT_sContent = avalue;
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
);
VUIelementNeedUpdate eltstr 0;
exec floatstr.VUIF_cbChange with [floatstr floatstr.VUIF_fValue state];
0;;
fun cbVUIfloatBtnIncTimer(trm, p)=
let p -> [floatstr step] in
(
set floatstr.VUIF_fValue = floatstr.VUIF_fValue +. step;
cbVUIfloatChange floatstr.VUIF_etext (G2DgetFtoA floatstr.VUIF_fValue floatstr.VUIF_iNbDec) 0 floatstr;
);
0;;
fun cbVUIfloatBtnTimer(trm, p)=
_deltimer trm;
let p -> [floatstr step] in
(
set floatstr.VUIF_trm = _rfltimer _starttimer _channel 150 @cbVUIfloatBtnIncTimer p;
);
0;;
fun cbVUIfloatBtnClick(eltstr, id, x, y, btn, p)=
let p -> [floatstr step] in
(
//wait timer
if (floatstr.VUIF_trm == nil) then nil else
(
_deltimer floatstr.VUIF_trm;
set floatstr.VUIF_trm = nil;
);
set floatstr.VUIF_trm = _rfltimer _starttimer _channel 500 @cbVUIfloatBtnTimer p;
set floatstr.VUIF_fValue = floatstr.VUIF_fValue +. step;
cbVUIfloatChange floatstr.VUIF_etext (G2DgetFtoA floatstr.VUIF_fValue floatstr.VUIF_iNbDec) 1 floatstr;
);
0;;
fun cbVUIfloatBtnUnClick(eltstr, id, x, y, btn, floatstr)=
if (floatstr.VUIF_trm == nil) then nil else
(
_deltimer floatstr.VUIF_trm;
set floatstr.VUIF_trm = nil;
);
0;;
fun VUIsetFloatValue(floatstr, value)=
let minf (maxf value floatstr.VUIF_fMin) floatstr.VUIF_fMax -> fvalue in
let G2DgetFtoA fvalue floatstr.VUIF_iNbDec -> avalue in
(
set floatstr.VUIF_fValue = fvalue;
set floatstr.VUIF_etext.VUIE_Text.VUIT_sContent = avalue;
set floatstr.VUIF_etext.VUIE_Text.VUIT_bNeedUpdate = 1;
);
VUIelementNeedUpdate floatstr.VUIF_etext 0;
value;;
fun VUIgetFloatValue(floatstr)=
let atof floatstr.VUIF_etext.VUIE_Text.VUIT_sContent -> value in
let minf (maxf value floatstr.VUIF_fMin) floatstr.VUIF_fMax -> fvalue in
fvalue;;
fun VUIsetFloatMaxValue(floatstr, value)=
set floatstr.VUIF_fMax = value;
let minf (maxf floatstr.VUIF_fValue floatstr.VUIF_fMin) floatstr.VUIF_fMax -> fvalue in
let G2DgetFtoA fvalue floatstr.VUIF_iNbDec -> avalue in
(
set floatstr.VUIF_fValue = fvalue;
set floatstr.VUIF_etext.VUIE_Text.VUIT_sContent = avalue;
set floatstr.VUIF_etext.VUIE_Text.VUIT_bNeedUpdate = 1;
);
VUIelementNeedUpdate floatstr.VUIF_etext 0;
value;;
fun VUIsetFloatMinValue(floatstr, value)=
set floatstr.VUIF_fMin = value;
let minf (maxf floatstr.VUIF_fValue floatstr.VUIF_fMin) floatstr.VUIF_fMax -> fvalue in
let G2DgetFtoA fvalue floatstr.VUIF_iNbDec -> avalue in
(
set floatstr.VUIF_fValue = fvalue;
set floatstr.VUIF_etext.VUIE_Text.VUIT_sContent = avalue;
set floatstr.VUIF_etext.VUIE_Text.VUIT_bNeedUpdate = 1;
);
VUIelementNeedUpdate floatstr.VUIF_etext 0;
value;;
fun VUIcreateFloatExt(contstr, parentstr, pos, size, ratiosize, align, margin, minval, maxval, step, nbdec, value, themeref)=
let if (value == nil) then 0.0 else value -> value in
let minf (maxf value minval) maxval -> value in
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltFloatValue -> eltstr in
let VUImakeFloat contstr eltstr minval maxval step nbdec value -> floatstr in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) themeref -> defstr in
(
VUImakeResource eltstr nil nil nil nil nil nil nil nil nil;
let size -> [w h] in
let G2DgetFtoA value nbdec -> avalue in
(
set floatstr.VUIF_etext = VUIcreateEditTextExt contstr eltstr [0.0 0.0] [100.0 h] [0 0 1 0 0 0 (-90) 0] [1 1] nil margin avalue 0 (strcat themeref "/editTextNumber");
set floatstr.VUIF_etext.VUIE_Text.VUIT_iAlign = iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER;
VUIsetElementTextNumberOnly floatstr.VUIF_etext 1;
set floatstr.VUIF_prevBtn = VUIcreateButtonExt contstr eltstr [10.0 0.0] [30.0 30.0] [0 0 0 0 0 0 0 0] [0 1] (strcat themeref "/minusButton");
let VUIgetThemeFont defstr "minusButton" -> lbfontstr in
VUIsetElementText floatstr.VUIF_prevBtn lbfontstr "-" [0 0] [0 0] [0 0] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
set floatstr.VUIF_nextBtn = VUIcreateButtonExt contstr eltstr [10.0 0.0] [30.0 30.0] [0 0 0 0 0 0 0 0] [2 1] (strcat themeref "/plusButton");
let VUIgetThemeFont defstr "plusButton" -> lbfontstr in
VUIsetElementText floatstr.VUIF_nextBtn lbfontstr "+" [0 0] [0 0] [0 0] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
VUIsetElementCbClick floatstr.VUIF_prevBtn mkfun6 @cbVUIfloatBtnClick [floatstr (-. step)];
VUIsetElementCbClick floatstr.VUIF_nextBtn mkfun6 @cbVUIfloatBtnClick [floatstr step];
VUIsetElementCbUnClick floatstr.VUIF_prevBtn mkfun6 @cbVUIfloatBtnUnClick floatstr;
VUIsetElementCbUnClick floatstr.VUIF_nextBtn mkfun6 @cbVUIfloatBtnUnClick floatstr;
VUIsetElementCbValidate floatstr.VUIF_etext mkfun4 @cbVUIfloatChange floatstr;
set floatstr.VUIF_etext.VUIE_Text.VUIT_bNeedUpdate = 1;
);
floatstr;
);;
fun VUIcreateFloat(contstr, parentstr, pos, size, ratiosize, align, margin, minval, maxval, step, nbdec, value)=
VUIcreateFloatExt contstr parentstr pos size ratiosize align margin minval maxval step nbdec value "float";;
fun VUIdestroyFloat(floatstr)=
VUIdestroyElement floatstr.VUIF_element;
if (floatstr.VUIF_trm == nil) then nil else
(
_deltimer floatstr.VUIF_trm;
set floatstr.VUIF_trm = nil;
);
0;;
fun VUIsetFloatCbChange(floatstr, cbfun)=
set floatstr.VUIF_cbChange = cbfun;
0;;
/* Slider */
fun cbVUIsliderChange(sliderstr)=
exec sliderstr.VUISL_cbChange with [sliderstr sliderstr.VUISL_fValue];
0;;
fun VUIgetSliderPercentPos(sliderstr, x, y)=
let sliderstr.VUISL_slider -> eltstr in
let eltstr.VUIE_tGlobalCoords -> [dx dy dw dh] in
let VUIunscaleCoords (if (VUI_DRAW_GLOBAL) then eltstr.VUIE_tDrawCoords else [dx dy dw dh 0 0]) eltstr.VUIE_container.VUICNT_fScale -> [ex ey ew eh] in
let if (sliderstr.VUISL_iDirection == 0) then [x ex ew] else [(eh - y) ey eh] -> [pos epos esize] in
let sliderstr.VUISL_iCursorSize -> cs in
let esize - cs - 2 -> esize in
let if esize <= 0 then 1 else esize -> esize in
let pos - epos - cs / 2 - 1 -> pos in
let if pos < 0 then 0 else if pos > esize then esize else pos -> pos in
(itof ((pos) * 100)) /. (itof esize);;
fun VUIgetSliderClosestStep(sliderstr, value)=
let ftoi ((value -. sliderstr.VUISL_fMin) /. (if sliderstr.VUISL_fStep == 0.0 then 1.0 else sliderstr.VUISL_fStep)) -> nbsteps in
let round (sliderstr.VUISL_fMin +. (sliderstr.VUISL_fStep *. (itof nbsteps))) sliderstr.VUISL_iNbDec -> understep in
let round (minf (sliderstr.VUISL_fMin +. (sliderstr.VUISL_fStep *. (itof nbsteps + 1))) sliderstr.VUISL_fMax) sliderstr.VUISL_iNbDec -> overstep in
//let addLogMessage strcatnSep "min:"::(ftoa sliderstr.VUISL_fMin)::"max:"::(ftoa sliderstr.VUISL_fMax)::"step:"::(ftoa sliderstr.VUISL_fStep)::"value:"::(ftoa value)::"nbsteps:"::(itoa nbsteps)::"understep:"::(ftoa understep)::"overstep:"::(ftoa overstep)::nil " " -> _ in
if (value -. understep) <=. (overstep -. value) then
understep
else
overstep;;
fun VUIgetSliderPercentPosByValue(sliderstr, value)=
let (sliderstr.VUISL_fMax -. sliderstr.VUISL_fMin) -> div in
let if div == 0.0 then 1.0 else div -> div in
100.0 *.(value -. sliderstr.VUISL_fMin) /. div;;
fun VUIgetSliderValueByPercentPos(sliderstr, ppos)=
let sliderstr.VUISL_fMin +. ((sliderstr.VUISL_fMax -. sliderstr.VUISL_fMin) *. ppos /. 100.0) -> value in
if sliderstr.VUISL_fStep <=. 0.0 then
[value ppos]
else
let VUIgetSliderClosestStep sliderstr value -> fvalue in
let VUIgetSliderPercentPosByValue sliderstr fvalue -> nppos in
[fvalue nppos];;
fun VUIsetSlider(sliderstr, fvalue, ppos)=
set sliderstr.VUISL_fValue = fvalue;
let sliderstr.VUISL_iCursorSize -> cs in
let ftoi ((itof - cs) *. ppos /. 100.0) -> offset in
let if (sliderstr.VUISL_iDirection == 0) then
[[ppos 100.0] [1 1 (cs + offset) 0] [ppos 0.0] [1 0 offset 0]]
else
[[100.0 ppos] [1 1 0 (cs + offset)] [0.0 ppos] [0 1 0 offset]]
-> [fsize fratiosize cpos cratiosize] in
(
VUIsetElementSize sliderstr.VUISL_fill fsize fratiosize;
VUIsetElementPos sliderstr.VUISL_cursor cpos nil cratiosize;
);
if (sliderstr.VUISL_text == nil) then nil else
let G2DgetFtoA fvalue sliderstr.VUISL_iNbDec -> avalue in
VUIsetElementTextContent sliderstr.VUISL_text avalue;
0;;
fun VUIsetSliderValue(sliderstr, value)=
let minf (maxf value sliderstr.VUISL_fMin) sliderstr.VUISL_fMax -> fvalue in
let if sliderstr.VUISL_fStep <=. 0.0 then
fvalue
else
VUIgetSliderClosestStep sliderstr fvalue
-> fvalue in
let VUIgetSliderPercentPosByValue sliderstr fvalue -> ppos in
(
VUIsetSlider sliderstr fvalue ppos;
);
value;;
fun VUIgetSliderValue(sliderstr)=
sliderstr.VUISL_fValue;;
fun VUIsetSliderMaxValue(sliderstr, value)=
set sliderstr.VUISL_fMax = value;
let minf (maxf sliderstr.VUISL_fValue sliderstr.VUISL_fMin) sliderstr.VUISL_fMax -> fvalue in
let G2DgetFtoA fvalue sliderstr.VUISL_iNbDec -> avalue in
(
VUIsetSliderValue sliderstr fvalue;
);
value;;
fun VUIsetSliderMinValue(sliderstr, value)=
set sliderstr.VUISL_fMin = value;
let minf (maxf sliderstr.VUISL_fValue sliderstr.VUISL_fMin) sliderstr.VUISL_fMax -> fvalue in
(
VUIsetSliderValue sliderstr fvalue;
);
value;;
fun cbVUIsliderClick(eltstr, id, x, y, btn, sliderstr)=
let VUIgetSliderPercentPos sliderstr x y -> ppos in
let VUIgetSliderValueByPercentPos sliderstr ppos -> [fvalue ppos] in
(
set sliderstr.VUISL_bClicking = 1;
VUIsetSlider sliderstr fvalue ppos;
cbVUIsliderChange sliderstr;
);
0;;
fun cbVUIsliderMove(eltstr, id, x, y, btn, sliderstr)=
if (!sliderstr.VUISL_bClicking) then nil else
(
let VUIgetSliderPercentPos sliderstr x y -> ppos in
let VUIgetSliderValueByPercentPos sliderstr ppos -> [fvalue ppos] in
VUIsetSlider sliderstr fvalue ppos;
cbVUIsliderChange sliderstr;
);
0;;
fun cbVUIsliderUnClick(eltstr, id, x, y, btn, sliderstr)=
set sliderstr.VUISL_bClicking = 0;
0;;
fun cbVUIsliderKeyDown(eltstr, key, sliderstr)=
if (key != 333) && (key != 331) then 0 else
(
let if (key == 333) then 1.0 else (-.1.0) -> coef in
let sliderstr.VUISL_fValue +. (sliderstr.VUISL_fStep *. coef) -> nvalue in
VUIsetSliderValue sliderstr nvalue;
cbVUIsliderChange sliderstr;
1;
);;
fun cbVUIsliderKeyUp(eltstr, key, sliderstr)=
if (key != 333) && (key != 331) then 0 else
1;;
fun VUIcreateSliderExt(contstr, parentstr, pos, size, ratiosize, align, minval, maxval, step, nbdec, value, direction, cursorsize, textpos, themeref)=
let if (minval == maxval) then maxval +. 0.00001 else maxval -> maxval in
let if step <=. 0.0 then 0.00001 else step -> step in
let if (value == nil) then 0.0 else value -> value in
let minf (maxf value minval) maxval -> value in
let if (direction == nil || direction <= 0) then 0 else direction -> direction in
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltSlider -> eltstr in
let VUImakeSlider contstr eltstr minval maxval step nbdec value direction cursorsize textpos -> sliderstr in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) themeref -> defstr in
let VUIgetThemeFont defstr "sliderBackground" -> lbfontstr in
(
VUImakeResource eltstr nil nil nil nil nil nil nil nil nil;
let VUIgetTextSize lbfontstr.VUIFI_Font (G2DgetFtoA minval nbdec) nil iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [minw minh] in
let VUIgetTextSize lbfontstr.VUIFI_Font (G2DgetFtoA maxval nbdec) nil iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [maxw maxh] in
let [(max minw maxw) + 10 (max minh maxh) + 10] -> [tw th] in
let if textpos == 3 then
[(- tw) 0 [2 1]]
else if textpos == 4 then
[(- tw) 0 [0 1]]
else if textpos == 5 then
[0 (- th) [1 2]]
else if textpos == 6 then
[0 (- th) [1 0]]
else
[0 0 [1 1]]
-> [ow oh salign] in
(
set sliderstr.VUISL_slider = VUIcreateFrame contstr eltstr [0.0 0.0] [100.0 100.0] [0 0 1 1 0 0 ow oh] salign;
VUIsetElementTheme sliderstr.VUISL_slider defstr "sliderBackground";
set sliderstr.VUISL_fill = VUIcreateFrame contstr sliderstr.VUISL_slider [0.0 0.0] [100.0 100.0] [0 0 1 1 0 0 0 0] [0 2];
VUIsetElementTheme sliderstr.VUISL_fill defstr "sliderFill";
VUIsetElementIgnoreInput sliderstr.VUISL_fill 1;
let if (sliderstr.VUISL_iDirection == 0) then
[[(itof cursorsize) 100.0] [1 0 0 1 0 0 0 0]]
else
[[100.0 (itof cursorsize)] [0 1 1 0 0 0 0 0]]
-> [csize cratiosize] in
set sliderstr.VUISL_cursor = VUIcreateFrame contstr sliderstr.VUISL_slider [0.0 0.0] csize cratiosize [0 2];
VUIsetElementTheme sliderstr.VUISL_cursor defstr "sliderCursor";
VUIsetElementIgnoreInput sliderstr.VUISL_cursor 1;
if textpos == 0 then nil else
(
let if textpos == 1 || textpos == 2 then
[[1 1] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER]
else if textpos == 3 then
[[0 1] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNCENTER]
else if textpos == 4 then
[[2 1] iVUITEXT_HALIGNRIGHT|iVUITEXT_VALIGNCENTER]
else if textpos == 5 then
[[1 0] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNTOP]
else if textpos == 6 then
[[1 2] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNBOTTOM]
else
nil
-> [talign textalign] in
let if textpos == 2 then sliderstr.VUISL_cursor else eltstr -> tparent in
(
set sliderstr.VUISL_text = VUIcreateFrame contstr tparent [0.0 0.0] [(itof tw) (itof th)] [0 0 0 0 0 0 0 0] talign;
VUIsetElementText sliderstr.VUISL_text lbfontstr "" [0 0] [0 0] [5 5] textalign VUI_TextStatic 0;
VUIsetElementIgnoreInput sliderstr.VUISL_text 1;
);
);
VUIsetSliderValue sliderstr value;
VUIsetElementCbClick sliderstr.VUISL_slider mkfun6 @cbVUIsliderClick sliderstr;
VUIsetElementCbMouseMove sliderstr.VUISL_slider mkfun6 @cbVUIsliderMove sliderstr;
VUIsetElementCbUnClick sliderstr.VUISL_slider mkfun6 @cbVUIsliderUnClick sliderstr;
VUIsetElementCbKeyDown sliderstr.VUISL_slider mkfun3 @cbVUIsliderKeyDown sliderstr;
VUIsetElementCbKeyUp sliderstr.VUISL_slider mkfun3 @cbVUIsliderKeyUp sliderstr;
VUIsetElementCbKeyDown eltstr mkfun3 @cbVUIsliderKeyDown sliderstr;
VUIsetElementCbKeyUp eltstr mkfun3 @cbVUIsliderKeyUp sliderstr;
);
sliderstr;
);;
fun VUIcreateSlider(contstr, parentstr, pos, size, ratiosize, align, minval, maxval, step, nbdec, value, direction, cursorsize, textpos)=
VUIcreateSliderExt contstr parentstr pos size ratiosize align minval maxval step nbdec value direction cursorsize textpos "slider";;
fun VUIdestroySlider(sliderstr)=
VUIdestroyElement sliderstr.VUIF_element;
0;;
fun VUIsetSliderCbChange(sliderstr, cbfun)=
set sliderstr.VUISL_cbChange = cbfun;
0;;
/* List */
fun VUIgetListElement(liststr, value)=
VUIgetListElementByName liststr liststr.VUIL_lListElts value nil;;
fun VUIrenameListElement(lestr, label)=
set lestr.VUILE_sValue = label;
VUIsetElementTextContent lestr.VUILE_element label;
0;;
fun VUIaddListElement(liststr, parentstr, value, param, check)=
let VUImakeElement liststr.VUIL_container liststr.VUIL_element [0.0 0.0] [100.0 0.0] [0 0 1 0 0 0 0 0] [0 0] VUI_EltListElement -> eltstr in
let VUImakeListElement liststr eltstr parentstr value param -> lestr in
let VUIgetThemeDef (VUIgetContainerGroupTheme liststr.VUIL_container) liststr.VUIL_sThemeRef -> defstr in
(
VUIsetElementTheme eltstr defstr (if check then "listElementCheck" else "listElement");
let VUIcountListHierarchy lestr -> nboff in
let liststr.VUIL_tEltOffset -> [ofx ofy] in
let liststr.VUIL_tMargin -> [mx my] in
let eltstr.VUIE_tPercent -> [px py pw ph xo yo wo ho] in
(
set eltstr.VUIE_tPercent = [px py pw ph xo yo (wo - ((mx * 2) + (ofx * nboff))) ho];
set eltstr.VUIE_vPos = [(itof (mx + (ofx * nboff))) (itof (if ((sizelist liststr.VUIL_lListElts) == 0) then my else ofy))];
);
set eltstr.VUIE_cbCheck = mkfun3 @VUIselectListElementCb lestr;
if (parentstr == nil) then
(
set liststr.VUIL_lListElts = lcat liststr.VUIL_lListElts lestr::nil;
0;
)
else //create btn on parent
(
if (parentstr.VUILE_element.VUIE_children != nil) then nil else
let VUIcreateButton liststr.VUIL_container parentstr.VUILE_element [0.0 0.0] [24.0 24.0] [0 0 0 0 0 0 0 0] [0 1] -> treebtn in
(
VUIsetElementTheme treebtn defstr "treeButton";
set parentstr.VUILE_element.VUIE_Text.VUIT_tPos = [20 0]; // different from button size to avoid too big of a gap between arrow and text
set parentstr.VUILE_element.VUIE_Text.VUIT_bNeedUpdate = 1;
if (!parentstr.VUILE_iState) then nil else
VUIsetElementCheckState treebtn 1;
VUIsetElementCbCheck treebtn mkfun3 @VUIcheckListElementCb parentstr;
VUIelementNeedUpdate parentstr.VUILE_element 1;
);
0;
);
if (parentstr != nil) && (!parentstr.VUILE_iState) then
set eltstr.VUIE_bVisible = 0
else nil;
if (value == nil) then nil else
let VUIgetThemeFont defstr (if check then "listElementCheck" else "listElement") -> lbfontstr in
VUIsetElementText eltstr lbfontstr value [0 0] [0 0] [5 5] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
//force btns to be on last list elements
let liststr.VUIL_scrollUp.VUIE_parent -> father in
(
set father.VUIE_children = remove_from_list father.VUIE_children liststr.VUIL_scrollUp;
set father.VUIE_children = lcat father.VUIE_children liststr.VUIL_scrollUp::nil;
);
let liststr.VUIL_scrollDown.VUIE_parent -> father in
(
set father.VUIE_children = remove_from_list father.VUIE_children liststr.VUIL_scrollDown;
set father.VUIE_children = lcat father.VUIE_children liststr.VUIL_scrollDown::nil;
);
VUIelementNeedUpdate lestr.VUILE_list.VUIL_element 1;
lestr;
);;
fun VUIremoveListElement(lestr)=
set lestr.VUILE_list.VUIL_lSelected = remove_from_list lestr.VUILE_list.VUIL_lSelected lestr;
VUIdestroyElement lestr.VUILE_element;
if (lestr.VUILE_parent == nil) then
(
set lestr.VUILE_list.VUIL_lListElts = remove_from_list lestr.VUILE_list.VUIL_lListElts lestr;
0;
)
else
(
set lestr.VUILE_parent.VUILE_children = remove_from_list lestr.VUILE_parent.VUILE_children lestr;
if (((sizelist lestr.VUILE_parent.VUILE_children) > 0) || (lestr.VUILE_parent.VUILE_element.VUIE_children == nil)) then nil else
(
VUIdestroyElement hd lestr.VUILE_parent.VUILE_element.VUIE_children;
set lestr.VUILE_parent.VUILE_element.VUIE_Text.VUIT_tPos = [0 0];
set lestr.VUILE_parent.VUILE_element.VUIE_Text.VUIT_bNeedUpdate = 1;
VUIelementNeedUpdate lestr.VUILE_parent.VUILE_element 1;
);
0;
);
VUIelementNeedUpdate lestr.VUILE_list.VUIL_element 1;
0;;
fun VUIclearList(liststr)=
set liststr.VUIL_lSelected = nil;
set liststr.VUIL_lListElts = nil;
VUIelementNeedUpdate liststr.VUIL_element 1;
0;;
fun VUIcreateListExt(contstr, parentstr, pos, size, ratiosize, align, margin, multiselect, childoffset, themeref)=
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltList -> eltstr in
let VUImakeList contstr eltstr childoffset margin multiselect themeref -> liststr in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) "common" -> defstr in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) themeref -> listdefstr in
(
VUIsetElementTheme eltstr listdefstr "listBackground";
VUIsetElementCbDraw eltstr mkfun2 @VUIdrawListCb liststr;
set eltstr.VUIE_cbMouseWheel = mkfun6 @VUImouseWheelListCb liststr;
set eltstr.VUIE_cbMouseMove = mkfun6 @VUImouseMoveListCb liststr;
set liststr.VUIL_scrollUp = VUIcreateButton contstr eltstr [0.0 5.0] [48.0 16.0] [0 0 0 0 0 0 0 0] [1 0];
set liststr.VUIL_scrollDown = VUIcreateButton contstr eltstr [0.0 5.0] [48.0 16.0] [0 0 0 0 0 0 0 0] [1 2];
set liststr.VUIL_scrollUp.VUIE_bVisible = 0;
set liststr.VUIL_scrollDown.VUIE_bVisible = 0;
VUIsetElementTheme liststr.VUIL_scrollUp defstr "scrollUp";
VUIsetElementTheme liststr.VUIL_scrollDown defstr "scrollDown";
VUIsetElementCbClick liststr.VUIL_scrollUp mkfun6 @cbVUIlistScrollBtnClick [liststr 10];
VUIsetElementCbUnClick liststr.VUIL_scrollUp mkfun6 @cbVUIlistScrollBtnUnClick liststr;
VUIsetElementCbClick liststr.VUIL_scrollDown mkfun6 @cbVUIlistScrollBtnClick [liststr (-10)];
VUIsetElementCbUnClick liststr.VUIL_scrollDown mkfun6 @cbVUIlistScrollBtnUnClick liststr;
set contstr.VUICNT_bClearOnUpdate = 1;
liststr;
);;
fun VUIcreateList(contstr, parentstr, pos, size, ratiosize, align, margin, multiselect, childoffset)=
VUIcreateListExt contstr parentstr pos size ratiosize align margin multiselect childoffset "list";;
fun VUIdestroyList(liststr)=
VUIdestroyElement liststr.VUIL_element;
0;;
fun VUIsetListCbSelect(liststr, cbfun)=
set liststr.VUIL_cbSelect = cbfun;
0;;
fun VUIsetListElementCbSelect(eleltstr, cbfun)=
set eleltstr.VUILE_cbSelect = cbfun;
0;;
/* Select */
proto VUIshowSelectList = fun [VUISelect I] I;;
fun cbVUIselectShowList(eltstr, id, x, y, btn, selectstr)=
VUIshowSelectList selectstr if (selectstr.VUIS_list == nil) then 1 else 0;
0;;
fun cbVUIselectListElement(liststr, lelt, selectstr)=
let hd lelt -> leltstr in
(
set selectstr.VUIS_sValue = leltstr.VUILE_sValue;
VUIsetElementTextContent selectstr.VUIS_element leltstr.VUILE_sValue;
VUIshowSelectList selectstr 0;
exec selectstr.VUIS_cbSelect with [selectstr leltstr.VUILE_sValue];
);
0;;
fun VUIsetListElementsTextSize(liststr, eleltlist, mode)=
if (eleltlist == nil) then nil else
(
let hd eleltlist -> eleltstr in
(
set eleltstr.VUILE_element.VUIE_Text.VUIT_iUpdateSize = mode;
VUIsetListElementsTextSize liststr eleltstr.VUILE_children mode;
);
VUIsetListElementsTextSize liststr (tl eleltlist) mode;
);
0;;
fun VUIshowSelectList(selectstr, state)=
if (!state) then
(
VUIdestroyList selectstr.VUIS_list;
set selectstr.VUIS_list = nil;
0;
)
else
(
if (selectstr.VUIS_list != nil) then nil else
(
let selectstr.VUIS_element.VUIE_tGlobalCoords -> [dx dy dw dh] in
let selectstr.VUIS_tMargin -> [mw mh] in
let selectstr.VUIS_tEltOffset -> [ow oh] in
let sizelist selectstr.VUIS_lValues -> nbvalues in
let nbvalues * dh + (nbvalues - 1) * oh + mh * 2 -> h in
let selectstr.VUIS_container.VUICNT_buffer.VUIE_tGlobalCoords -> [_ _ _ ch] in
if (h > (ch - (dy + dh))) then
set selectstr.VUIS_list = VUIcreateListExt selectstr.VUIS_container selectstr.VUIS_element.VUIE_parent [(itof dx) (itof (dy + dh))] [(itof dw) 100.0] [0 0 0 1 0 0 0 (- (dy + dh))] [0 0] selectstr.VUIS_tMargin 0 selectstr.VUIS_tEltOffset selectstr.VUIS_sThemeRef
else
set selectstr.VUIS_list = VUIcreateListExt selectstr.VUIS_container selectstr.VUIS_element.VUIE_parent [(itof dx) (itof (dy + dh))] [(itof dw) (itof h)] [0 0 0 0 0 0 0 0] [0 0] selectstr.VUIS_tMargin 0 selectstr.VUIS_tEltOffset selectstr.VUIS_sThemeRef;
VUIsetListCbSelect selectstr.VUIS_list mkfun3 @cbVUIselectListElement selectstr;
let selectstr.VUIS_lValues -> lvalues in
while (lvalues != nil) do
(
let (hd lvalues) -> eval in
(
let VUIaddListElement selectstr.VUIS_list nil (hd lvalues) nil 1 -> eleltstr in
(
let if (strcmp eval selectstr.VUIS_sValue) || (eleltstr.VUILE_element.VUIE_resource == nil) || (1 > (eleltstr.VUILE_element.VUIE_resource.VUIR_iNbCols - 1)) then 0 else 1 -> state in
set eleltstr.VUILE_element.VUIE_resource.VUIR_iCurCol = state;
//set eleltstr.VUILE_element.VUIE_Text.VUIT_iUpdateSize = VUI_TextAuto;
);
);
set lvalues = tl lvalues;
);
/*VUImakeResource selectstr.VUIS_list.VUIL_element nil nil nil nil nil nil nil nil nil;
VUIupdateListElementsCoords selectstr.VUIS_list selectstr.VUIS_list.VUIL_lListElts [0 0];
let VUIgetListFullContentSize selectstr.VUIS_list 0 -> [tw th] in
set selectstr.VUIS_list.VUIL_element.VUIE_vSize = [(itof tw) 100.0];
VUIsetListElementsTextSize selectstr.VUIS_list selectstr.VUIS_list.VUIL_lListElts VUI_TextAutoHeight;
VUIshowElement liststr.VUIL_element 1;
*/
0;
);
);
0;;
fun VUIselectAddElement(selectstr, value)=
if (selectstr.VUIS_list == nil) then nil else
VUIaddListElement selectstr.VUIS_list nil value nil 0;
set selectstr.VUIS_lValues = lcat selectstr.VUIS_lValues value::nil;
0;;
fun VUIremoveSelectElement(selectstr, value)=
set selectstr.VUIS_lValues = remove_from_list selectstr.VUIS_lValues value;
if (selectstr.VUIS_list == nil) then nil else
let VUIgetListElement selectstr.VUIS_list value -> leltstr in
VUIremoveListElement leltstr;
0;;
fun VUIsetSelectElement(selectstr, value)=
if (selectstr.VUIS_list == nil) then nil else
let VUIgetListElement selectstr.VUIS_list value -> leltstr in
VUIselectListElement leltstr 1;
set selectstr.VUIS_sValue = value;
VUIsetElementTextContent selectstr.VUIS_element value;
0;;
fun VUIsetSelectElementByPos(selectstr, pos)=
let nth_list selectstr.VUIS_lValues pos -> value in
VUIsetSelectElement selectstr value;
0;;
fun VUIcreateSelectExt(contstr, parentstr, pos, size, ratiosize, align, lvalues, margin, childoffset, themeref)=
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltSelect -> eltstr in
let VUImakeSelect contstr eltstr lvalues margin childoffset themeref -> selectstr in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) themeref -> defstr in
(
VUIsetElementTheme eltstr defstr "field";
VUIsetElementCbFullClick eltstr mkfun6 @cbVUIselectShowList selectstr;
let hd lvalues -> defval in
let VUIgetThemeFont defstr "field" -> lbfontstr in
VUIsetElementText eltstr lbfontstr defval [0 0] [0 0] [5 5] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
set contstr.VUICNT_bClearOnUpdate = 1;
selectstr;
);;
fun VUIcreateSelect(contstr, parentstr, pos, size, ratiosize, align, lvalues, margin, childoffset)=
VUIcreateSelectExt contstr parentstr pos size ratiosize align lvalues margin childoffset "select";;
fun VUIdestroySelect(selectstr)=
VUIdestroyList selectstr.VUIS_list;
VUIdestroyElement selectstr.VUIS_element;
0;;
fun VUIsetSelectCbSelect(selectstr, cbfun)=
set selectstr.VUIS_cbSelect = cbfun;
0;;
/* Table */
fun VUIcomputeTableColumnData(nbcols, colwidths, border, cwcount, undefcount, j)=
if (j >= nbcols) then
[(mktab nbcols nil) cwcount undefcount]
else
(
let if colwidths.(j) <= 0 then
VUIcomputeTableColumnData nbcols colwidths border cwcount (undefcount + 1) (j + 1)
else
VUIcomputeTableColumnData nbcols colwidths border (cwcount + colwidths.(j)) undefcount (j + 1)
-> [columnsdatatab totalcw undefcw] in
let if undefcw <= 0 then
[0 0 cwcount 0]
else
let (undefcount * 100) / undefcw -> ppos in
let ((undefcount + 1) * 100) / undefcw - ppos -> pwidth in
let (undefcount * totalcw) / undefcw -> prevow in
let cwcount - prevow -> ox in
let ((undefcount + 1) * totalcw) / undefcw - prevow -> ow in
[ppos pwidth ox (-ow)]
-> [ppos pwidth ox ow] in
let if (j + 1) >= nbcols then 0 else border -> bo in
let if colwidths.(j) <= 0 then [ppos pwidth 1 1 ox (ow + bo)] else [ppos (colwidths.(j) + bo) 1 0 ox 0] -> columndata in
(
set columnsdatatab.j = columndata;
[columnsdatatab totalcw undefcw];
);
);;
fun VUIupdateTableLineHeight(linestr, lw, lh)=
let linestr.VUITBL_table -> tablestr in
let tablestr.VUITB_tTableSize -> [x _] in
let 0 -> maxh in
let 0 -> j in
(
while (j < x) do
(
let linestr.VUITBL_cells.j -> cell in
let VUIcomputeEposSize cell lw lh -> [_ _ cellwidth _] in
let cell.VUIE_Text -> textstr in
let textstr.VUIT_tMargin -> [mx my] in
let VUIgetTextSize textstr.VUIT_font.VUIFI_Font textstr.VUIT_sContent (cellwidth - 2 * mx) textstr.VUIT_iAlign -> [_ cellheight] in
let cellheight + 2 * my -> cellheight in
if (cellheight <= maxh) then nil else
set maxh = cellheight;
set j = j + 1;
);
set linestr.VUITBL_iHeight = maxh;
);;
fun VUIupdateTableVerticalLayout(tablestr)=
let tablestr.VUITB_element.VUIE_tGlobalCoords -> [_ _ tw th] in
let tablestr.VUITB_tTableSize -> [_ y] in
let 0 -> i in
let 0 -> linemaxh in
let 0 -> remainder in
let nil -> heightlist in
(
// update line needed height
while (i < y) do
(
let tablestr.VUITB_table.i -> linestr in
let VUIcomputeEposSize linestr.VUITBL_element tw th -> [_ _ lw lh] in
set heightlist = (VUIupdateTableLineHeight linestr lw lh)::heightlist;
set i = i + 1;
);
// compute line height to fill the table
set heightlist = quicksort heightlist @isSmallerI;
set i = 0;
while (i < y) do
(
set linemaxh = th / (y - i);
set remainder = th - (linemaxh * (y - i));
if ((hd heightlist) > linemaxh) then
(
set th = th - (hd heightlist);
set heightlist = tl heightlist;
set i = i + 1;
)
else
set i = y;
);
// set the lines position and height
set i = 0;
let 0 -> ly in
while (i < y) do
(
let tablestr.VUITB_table.i -> linestr in
let if linestr.VUITBL_iHeight > linemaxh then
linestr.VUITBL_iHeight
else
let if remainder > 0 then 1 else 0 -> correction in
(
set remainder = remainder - 1;
linemaxh + correction
)
-> height in
let if (i + 1) >= y then 0 else tablestr.VUITB_iBorder -> bo in
let linestr.VUITBL_element.VUIE_vPos -> [ex ey] in
let linestr.VUITBL_element.VUIE_vSize -> [ew eh] in
(
if ((itof ly) == ey) then nil else
VUIsetElementPos linestr.VUITBL_element [0.0 (itof ly)] nil nil;
if ((itof height) == eh) then nil else
VUIsetElementSize linestr.VUITBL_element [100.0 (itof (height + bo))] nil;
set ly = ly + height;
VUIupdateElementCoords linestr.VUITBL_element.VUIE_container linestr.VUITBL_element;
);
set i = i + 1;
);
);
0;;
fun cbVUItableDraw(eltstr, tablestr)=
VUIupdateTableVerticalLayout tablestr;
0;;
fun VUIgetTableCell(tablestr, x, y)=
let tablestr.VUITB_tTableSize -> [tx ty] in
if (x < 0) || (x >= tx) || (y < 0) || (y >= ty) then nil else
tablestr.VUITB_table.(y).VUITBL_cells.(x);;
fun VUIgetTableCellText(tablestr, x, y)=
let tablestr.VUITB_tTableSize -> [tx ty] in
if (x < 0) || (x >= tx) || (y < 0) || (y >= ty) then nil else
VUIgetElementText tablestr.VUITB_table.(y).VUITBL_cells.(x);;
fun VUIgetTable(tablestr)=
let tablestr.VUITB_tTableSize -> [x y] in
let mktab y nil -> table in
(
let 0 -> i in
while (i < y) do
(
set table.(i) = mktab x "";
let 0 -> j in
while (j < x) do
(
set table.(i).(j) = VUIgetElementText tablestr.VUITB_table.(i).VUITBL_cells.(j);
set j = j + 1;
);
set i = i + 1;
);
table;
);;
fun cbVUItableChange(tablestr, x, y)=
let VUIgetTableCell tablestr x y -> cell in
let VUIgetTableCellText tablestr x y -> text in
exec tablestr.VUITB_cbChange with [tablestr cell x y text];
0;;
fun VUIsetTableCellText(tablestr, x, y, content)=
let tablestr.VUITB_tTableSize -> [tx ty] in
if (x < 0) || (x >= tx) || (y < 0) || (y >= ty) then nil else
(
VUIsetElementTextContent tablestr.VUITB_table.(y).VUITBL_cells.(x) content;
cbVUItableChange tablestr x y;
);
0;;
fun VUIsetTable(tablestr, content)=
let tablestr.VUITB_tTableSize -> [x y] in
let sizetab content -> nbline in
let 0 -> i in
while (i < y && i < nbline) do
(
let sizetab content.(i) -> nbcol in
let 0 -> j in
while (j < x && j < nbcol) do
(
VUIsetElementTextContent tablestr.VUITB_table.(i).VUITBL_cells.(j) content.(i).(j);
cbVUItableChange tablestr j i;
set j = j + 1;
);
set i = i + 1;
);
0;;
fun VUIsetTableFont(tablestr, font)=
let VUIcreateFontInterface font -> fontistr in
let tablestr.VUITB_tTableSize -> [x y] in
let 0 -> i in
while (i < y) do
(
let 0 -> j in
while (j < x) do
(
VUIsetElementFont tablestr.VUITB_table.(i).VUITBL_cells.(j) fontistr;
set j = j + 1;
);
set i = i + 1;
);
0;;
fun VUIsetTableResource(tablestr, bgcolor, border, bdcolor, file, flags/*, nbstates, nbcols, nbframes, framepersec*/)=
let tablestr.VUITB_tTableSize -> [x y] in
let 0 -> i in
(
while (i < y) do
(
let 0 -> j in
while (j < x) do
(
VUIsetElementResource tablestr.VUITB_table.(i).VUITBL_cells.(j) bgcolor border bdcolor file flags nil nil nil nil/*nbstates nbcols nbframes framepersec*/;
set j = j + 1;
);
set i = i + 1;
);
if (border == tablestr.VUITB_iBorder) then nil else
let VUIcomputeTableColumnData x tablestr.VUITB_colWidth border 0 0 0 -> [coldata _ _] in
(
set tablestr.VUITB_iBorder = border;
set i = 0;
while (i < y) do
(
let 0 -> j in
while (j < x) do
(
let coldata.j -> [cx cw px pw ox ow] in
(
VUIsetElementPos tablestr.VUITB_table.(i).VUITBL_cells.(j) [(itof cx) 0.0] nil [px 0 ox 0];
VUIsetElementSize tablestr.VUITB_table.(i).VUITBL_cells.(j) [(itof cw) 100.0] [pw 1 ow 0];
);
set j = j + 1;
);
set i = i + 1;
);
);
);
0;;
fun VUIcreateTableExt(contstr, parentstr, pos, size, ratiosize, align, margin, tablesize, colwidths, font, textalign, themeref)=
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltTable -> eltstr in
let VUIsplitThemeRef themeref -> [defname eltname] in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) defname -> defstr in
let VUIgetThemeElement defstr eltname -> ethstr in
let ethstr.VUITHE_res -> rthstr in
let rthstr.VUITHR_iBorder -> border in
let VUImakeTable contstr eltstr tablesize colwidths border -> tablestr in
let tablesize -> [tx ty] in
let VUIcomputeTableColumnData tx colwidths border 0 0 0 -> [coldata _ _] in
let if font != nil then VUIcreateFontInterface font else VUIgetThemeFont defstr eltname -> lbfontstr in
(
VUImakeResource eltstr 0xffffff00 nil nil nil nil nil nil nil nil;
VUIsetElementScroll eltstr VUI_EltScrollH|VUI_EltScrollV;
// create lines and cells
let 0 -> i in
while (i < ty) do
(
let tablestr.VUITB_table.i -> linestr in
let 0 -> j in
(
set linestr.VUITBL_element = VUIcreateFrame contstr tablestr.VUITB_element [0.0 0.0] [100.0 0.0] [0 0 1 0 0 0 0 0] [0 0];
while (j < tx) do
(
let coldata.j -> [cx cw px pw ox ow] in
set linestr.VUITBL_cells.j = VUIcreateFrame contstr linestr.VUITBL_element [(itof cx) 0.0] [(itof cw) 100.0] [px 0 pw 1 ox 0 ow 0] [0 0];
VUIsetElementTheme linestr.VUITBL_cells.j defstr "tableCell";
//VUIsetElementResource linestr.VUITBL_cells.j 0xffffff00 border bcolor nil nil nil nil nil nil;
VUIsetElementText linestr.VUITBL_cells.j lbfontstr "" nil nil margin textalign VUI_TextStatic 1;
set j = j + 1;
);
);
set i = i + 1;
);
VUIsetElementCbPreDraw eltstr mkfun2 @cbVUItableDraw tablestr;
tablestr;
);;
fun VUIcreateTable(contstr, parentstr, pos, size, ratiosize, align, margin, tablesize, colwidths, font, textalign)=
VUIcreateTableExt contstr parentstr pos size ratiosize align margin tablesize colwidths font textalign "common/tableCell";;
fun VUIdestroyTable(tablestr)=
VUIdestroyElement tablestr.VUITB_element;
0;;
fun VUIsetTableCbChange(tablestr, cbfun)=
set tablestr.VUITB_cbChange = cbfun;
0;;
/* Menu */
proto VUIshowMenuList = fun [VUIBtnMenu I] I;;
fun cbVUImenuShowList(eltstr, id, x, y, btn, bmenustr)=
let bmenustr.VUIMB_parent -> menustr in
(
if ((menustr.VUIM_selectedBtn == nil) || (menustr.VUIM_selectedBtn == bmenustr)) then nil else
(
VUIshowMenuList menustr.VUIM_selectedBtn 0;
set menustr.VUIM_selectedBtn = nil;
);
let if (bmenustr.VUIMB_list == nil) then 1 else 0 -> state in
(
VUIshowMenuList bmenustr state;
if (!state) then
set menustr.VUIM_selectedBtn = nil
else
set menustr.VUIM_selectedBtn = bmenustr;
);
);
//addLogMessage strcat "Menu Select : " bmenustr.VUIMB_sValue;
exec bmenustr.VUIMB_cbSelect with [bmenustr];
0;;
fun cbVUImenuButtonIn(eltstr, bmenustr)=
if (!bmenustr.VUIMB_iMode || (bmenustr.VUIMB_tooltip != nil) || (bmenustr.VUIMB_sValue == nil)) then nil else
(
let bmenustr.VUIMB_element.VUIE_container -> constr in
let VUIgetThemeDef (VUIgetContainerGroupTheme eltstr.VUIE_container) "common" -> defstr in
let VUIgetThemeFont defstr "bubble" -> lbfontstr in
let VUIgetTextSize lbfontstr.VUIFI_Font bmenustr.VUIMB_sValue 0 iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [ttw tth] in
(
//Show bubble
//let bmenustr.VUIMB_element.VUIE_tGlobalCoords -> [dx dy dw dh] in
//let [dx + (dw / 2) dy + (dh / 2)] -> [dx dy] in
let hd constr.VUICNT_strw.VUIW_vMousePos -> [id [dx dy]] in
let VUIunscaleCoords2 constr.VUICNT_buffer.VUIE_tGlobalCoords constr.VUICNT_fScale -> [_ _ cw ch] in
let if ((dx + ttw + 10) <= cw) then dx else dx - (ttw + 10) -> px in
let if ((dy + tth + 10) <= ch) then dy else dy - (tth + 10) -> py in
set bmenustr.VUIMB_tooltip = VUIcreateFrame constr nil [(itof px) (itof py)] [0.0 0.0] [0 0 0 0 0 0 0 0] [0 0];
VUIsetElementIgnoreInput bmenustr.VUIMB_tooltip 1;
VUIsetElementTheme bmenustr.VUIMB_tooltip defstr "bubble";
VUIsetElementText bmenustr.VUIMB_tooltip lbfontstr bmenustr.VUIMB_sValue [0 0] [0 0] [0 0] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextAuto 0;
VUIelementNeedUpdate bmenustr.VUIMB_element 0;
);
);
0;;
fun cbVUImenuButtonOut(eltstr, bmenustr)=
if (bmenustr.VUIMB_tooltip == nil) then nil else
(
VUIdestroyElement bmenustr.VUIMB_tooltip;
set bmenustr.VUIMB_tooltip = nil;
VUIelementNeedUpdate bmenustr.VUIMB_element 0;
);
0;;
fun cbVUIselectMenuElement(eleltstr, smenustr)=
//search for parent with the menu button
let if (smenustr.VUIMS_btnMenu == nil) then
let nil -> btnmenu in
let smenustr -> smenu in
(
while (btnmenu == nil && smenu != nil) do
(
set btnmenu = smenu.VUIMS_btnMenu;
set smenu = smenu.VUIMS_parent;
);
btnmenu;
)
else
smenustr.VUIMS_btnMenu
-> btnmenustr in
(
VUIshowMenuList btnmenustr 0;
set btnmenustr.VUIMB_parent.VUIM_selectedBtn = nil;
);
if (!smenustr.VUIMS_bCheck) then nil else
set smenustr.VUIMS_iCheckState = !smenustr.VUIMS_iCheckState;
//addLogMessage strcat "SubMenu Select : " smenustr.VUIMS_sValue;
exec smenustr.VUIMS_cbSelect with [smenustr];
0;;
fun VUIfillSubMenu(bmenustr, eleltstr, smstrlist)=
if (smstrlist == nil) then nil else
(
let hd smstrlist -> smenustr in
let VUIaddListElement bmenustr.VUIMB_list eleltstr smenustr.VUIMS_sValue nil smenustr.VUIMS_bCheck -> neleltstr in
(
VUIsetListElementCbSelect neleltstr mkfun2 @cbVUIselectMenuElement smenustr;
let if (neleltstr.VUILE_element.VUIE_resource == nil) || (smenustr.VUIMS_iCheckState > (neleltstr.VUILE_element.VUIE_resource.VUIR_iNbCols - 1)) then 0 else smenustr.VUIMS_iCheckState -> state in
set neleltstr.VUILE_element.VUIE_resource.VUIR_iCurCol = state;
set neleltstr.VUILE_element.VUIE_Text.VUIT_iUpdateSize = VUI_TextAuto;
VUIfillSubMenu bmenustr neleltstr smenustr.VUIMS_lChildren;
if (!bmenustr.VUIMB_bUnfoldChildren || neleltstr.VUILE_children == nil) then nil else
VUIunfoldListElement neleltstr 1;
);
VUIfillSubMenu bmenustr eleltstr (tl smstrlist);
);
0;;
fun VUIshowMenuList(bmenustr, state)=
let bmenustr.VUIMB_parent -> menustr in
if (!state) then
(
VUIdestroyList bmenustr.VUIMB_list;
set bmenustr.VUIMB_list = nil;
0;
)
else
(
if (bmenustr.VUIMB_list != nil) || (bmenustr.VUIMB_lSubMenus == nil) then nil else
(
set bmenustr.VUIMB_list = VUIcreateListExt menustr.VUIM_container nil [0.0 0.0] [100.0 100.0] [0 0 0 0 0 0 0 0] [0 0] [0 0] 0 menustr.VUIM_tEltOffset menustr.VUIM_sThemeRef;
VUIfillSubMenu bmenustr nil bmenustr.VUIMB_lSubMenus;
//update to get the max element width
VUIupdateListElementsCoords bmenustr.VUIMB_list bmenustr.VUIMB_list.VUIL_lListElts [0 0];
let VUIgetListFullContentSize bmenustr.VUIMB_list 1 -> [tw th] in
let bmenustr.VUIMB_element.VUIE_tLocalCoords -> [dx dy dw dh] in
let menustr.VUIM_tEltOffset -> [ox oy] in
let menustr.VUIM_iAlignMode -> alignmode in
let VUIscaleVec SO3WidgetGetSize menustr.VUIM_container.VUICNT_strw.VUIW_widget menustr.VUIM_container.VUICNT_fScale -> [cw ch] in
let if (alignmode == iVUIMNU_ALIGNRIGHT) then
[[((cw - dx) + ox) (dy + oy)] [2 0]]
else if (alignmode == iVUIMNU_ALIGNTOP) then
[[(dx + ox) (dy + dh + oy)] [0 0]]
else if (alignmode == iVUIMNU_ALIGNBOTTOM) then
[[(dx + ox) ((ch - dy) + oy)] [0 2]]
else
[[(dx + dw + ox) (dy + oy)] [0 0]]
-> [[bx by] balign] in
let [(min tw (cw - bx)) (min th (ch - by))] -> [wp hp] in //warning th can be wrong if the width in less than tw
(
//addLogMessage strcatn "pos : "::(itoa bx)::" "::(itoa by)::nil;
set bmenustr.VUIMB_list.VUIL_element.VUIE_vPos = [(itof bx) (itof by)];
set bmenustr.VUIMB_list.VUIL_element.VUIE_tAlign = balign;
set bmenustr.VUIMB_list.VUIL_element.VUIE_vSize = [(itof wp) (itof hp)];
);
VUIsetListElementsTextSize bmenustr.VUIMB_list bmenustr.VUIMB_list.VUIL_lListElts VUI_TextAutoHeight;
0;
);
);
VUIelementNeedUpdate bmenustr.VUIMB_parent.VUIM_element 1;
0;;
fun VUIaddSubMenu(bmenustr, smenustr, value, check)=
VUImakeSubMenu bmenustr smenustr value check;;
fun VUIaddMenuButton(menustr, size, value, mode, unfold)=
let VUImakeElement menustr.VUIM_container menustr.VUIM_element [0.0 0.0] size [0 0 0 0 0 0 0 0] [0 0] VUI_EltBtnMenu -> eltstr in
let VUImakeBtnMenu menustr eltstr value mode unfold -> bmenustr in
(
VUIsetElementCbFullClick eltstr mkfun6 @cbVUImenuShowList bmenustr;
if ((value == nil) || mode) then nil else
let VUIgetThemeDef (VUIgetContainerGroupTheme menustr.VUIM_container) menustr.VUIM_sThemeRef -> defstr in
(
VUIsetElementTheme eltstr defstr "menuButton";
let VUIgetThemeFont defstr "menuButton" -> lbfontstr in
let size -> [w h] in
let if (w == 0.0 && h == 0.0) then VUI_TextAuto else if (h == 0.0) then VUI_TextAutoHeight else VUI_TextStatic -> tmode in
VUIsetElementText eltstr lbfontstr value [0 0] [0 0] [5 5] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNCENTER tmode 0;
);
// bubble events
if (!mode) then nil else
(
VUIsetElementCbMouseIn eltstr mkfun2 @cbVUImenuButtonIn bmenustr;
VUIsetElementCbMouseOut eltstr mkfun2 @cbVUImenuButtonOut bmenustr;
);
//force btns to be on last list elements
let menustr.VUIM_scrollMinus.VUIE_parent -> father in
(
set father.VUIE_children = remove_from_list father.VUIE_children menustr.VUIM_scrollMinus;
set father.VUIE_children = lcat father.VUIE_children menustr.VUIM_scrollMinus::nil;
);
let menustr.VUIM_scrollPlus.VUIE_parent -> father in
(
set father.VUIE_children = remove_from_list father.VUIE_children menustr.VUIM_scrollPlus;
set father.VUIE_children = lcat father.VUIE_children menustr.VUIM_scrollPlus::nil;
);
bmenustr;
);;
fun VUIcreateMenuExt(contstr, parentstr, pos, size, ratiosize, align, margin, childoffset, alignmode, themeref)=
let VUImakeElement contstr parentstr pos size ratiosize align VUI_EltMenu -> eltstr in
let VUImakeMenu contstr eltstr margin childoffset alignmode themeref -> menustr in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) "common" -> defstr in
let VUIgetThemeDef (VUIgetContainerGroupTheme contstr) themeref -> menudefstr in
(
VUIsetElementTheme eltstr menudefstr "menuBackground";
VUIsetElementCbDraw eltstr mkfun2 @VUIdrawMenuCb menustr;
set eltstr.VUIE_cbMouseWheel = mkfun6 @VUImouseWheelMenuCb menustr;
set eltstr.VUIE_cbMouseMove = mkfun6 @VUImouseMoveMenuCb menustr;
let margin -> [mx my] in
let if (alignmode == iVUIMNU_ALIGNRIGHT) then
[[(itof (mx + 6)) (itof my)] [48.0 16.0] [2 0] "scrollUp"]
else if (alignmode == iVUIMNU_ALIGNTOP) then
[[(itof mx) (itof (my + 6))] [16.0 49.0] [0 0] "scrollLeft"]
else if (alignmode == iVUIMNU_ALIGNBOTTOM) then
[[(itof mx) (itof (my + 6))] [16.0 49.0] [0 2] "scrollLeft"]
else
[[(itof (mx + 6)) (itof my)] [48.0 16.0] [0 0] "scrollUp"]
-> [bpos bsize balign bstyle] in
(
set menustr.VUIM_scrollPlus = VUIcreateButton contstr eltstr bpos bsize [0 0 0 0 0 0 0 0] balign;
VUIsetElementTheme menustr.VUIM_scrollPlus defstr bstyle;
);
let margin -> [mx my] in
let if (alignmode == iVUIMNU_ALIGNRIGHT) then
[[(itof (mx + 6)) (itof my)] [48.0 16.0] [2 2] "scrollDown"]
else if (alignmode == iVUIMNU_ALIGNTOP) then
[[(itof mx) (itof (my + 6))] [16.0 49.0] [2 0] "scrollRight"]
else if (alignmode == iVUIMNU_ALIGNBOTTOM) then
[[(itof mx) (itof (my + 6))] [16.0 49.0] [2 2] "scrollRight"]
else
[[(itof (mx + 6)) (itof my)] [48.0 16.0] [0 2] "scrollDown"]
-> [bpos bsize balign bstyle] in
(
set menustr.VUIM_scrollMinus = VUIcreateButton contstr eltstr bpos bsize [0 0 0 0 0 0 0 0] balign;
VUIsetElementTheme menustr.VUIM_scrollMinus defstr bstyle;
);
set menustr.VUIM_scrollPlus.VUIE_bVisible = 0;
set menustr.VUIM_scrollMinus.VUIE_bVisible = 0;
VUIsetElementCbClick menustr.VUIM_scrollPlus mkfun6 @cbVUImenuScrollBtnClick [menustr 10];
VUIsetElementCbUnClick menustr.VUIM_scrollPlus mkfun6 @cbVUImenuScrollBtnUnClick menustr;
VUIsetElementCbClick menustr.VUIM_scrollMinus mkfun6 @cbVUImenuScrollBtnClick [menustr (-10)];
VUIsetElementCbUnClick menustr.VUIM_scrollMinus mkfun6 @cbVUImenuScrollBtnUnClick menustr;
set contstr.VUICNT_bClearOnUpdate = 1;
VUIsetFocusedElement contstr eltstr;
menustr;
);;
fun VUIcreateMenu(contstr, parentstr, pos, size, ratiosize, align, margin, childoffset, alignmode)=
VUIcreateMenuExt contstr parentstr pos size ratiosize align margin childoffset alignmode "menu";;
fun VUIdestroyMenu(menustr)=
let menustr.VUIM_lBtnMenus -> lbtns in
while (lbtns != nil) do
(
let hd lbtns -> bmenustr in
(
if (bmenustr.VUIMB_tooltip == nil) then nil else
(
VUIdestroyElement bmenustr.VUIMB_tooltip;
set bmenustr.VUIMB_tooltip = nil;
);
VUIdestroyList bmenustr.VUIMB_list;
set bmenustr.VUIMB_list = nil;
);
set lbtns = tl lbtns;
);
VUIdestroyElement menustr.VUIM_element;
0;;
fun VUIsetCbMenuButton(bmenustr, cbfun)=
set bmenustr.VUIMB_cbSelect = cbfun;
0;;
fun VUIsetCbSubMenu(smenustr, cbfun)=
set smenustr.VUIMS_cbSelect = cbfun;
0;;
/* Dialog Box */
fun VUIdestroyDialogBox(dlgstr)=
VUIdestroyContainer dlgstr.VUIDLG_container;
0;;
fun cbVUIDlgClick(eltstr, id, x, y, btn, p)=
let p -> [dlgstr state] in
(
exec dlgstr.VUIDLG_cbValidate with [dlgstr state];
VUIdestroyDialogBox dlgstr;
);
0;;
fun VUIcomputeDialogBoxSize(viewstr, themestr, title, text, isbtn)=
let VUIgetThemeDef themestr "dialogBox" -> defstr in
let VUIgetViewSize viewstr -> [cvw cvh] in
let if (title == nil) then nil else VUIgetThemeFont defstr "title" -> tlfontstr in
let if (tlfontstr == nil) then
[0 0]
else
let VUIgetTextSize tlfontstr.VUIFI_Font title 0 iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP -> [tlw tlh] in
[tlw tlh + 5]
-> [tlw tlh] in
let if (isbtn) then
let VUIgetThemeFont defstr "okButton" -> bokfontstr in
let VUIgetThemeElement defstr "okButton" -> bokthm in
let VUIgetThemeFont defstr "cancelButton" -> bcfontstr in
let VUIgetThemeElement defstr "cancelButton" -> bcthm in
let VUIgetTextSize bokfontstr.VUIFI_Font "!" 0 iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [_ obtnh] in
let VUIgetTextSize bcfontstr.VUIFI_Font "!" 0 iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [_ cbtnh] in
(max (obtnh + (bokthm.VUITHE_res.VUITHR_iBorder * 2)) (cbtnh + (bcthm.VUITHE_res.VUITHR_iBorder * 2))) + 15
else
0
-> btnh in
let [(cvw - 20 - 30) (cvh - 20 - 30 - btnh - tlh)] -> [maxvw maxvh] in
let VUIgetThemeFont defstr "label" -> lbfontstr in
let VUIgetTextSize lbfontstr.VUIFI_Font text 0 iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [ttw tth] in
let min 1024 maxvw -> maxw in
let if (ttw > maxw) then VUIgetTextSize lbfontstr.VUIFI_Font text maxw iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER else [ttw tth] -> [ttw tth] in
let [(min (max (max ttw tlw) 200) maxvw) (min (max tth lbfontstr.VUIFI_Font.VUIF_iFontSize) maxvh)] -> [ttw tth] in
[tlw tlh ttw tth btnh];;
fun VUIupdateDialogBoxSize(viewstr, dlgstr)=
let if (dlgstr.VUIDLG_okBtn == nil && dlgstr.VUIDLG_cancelBtn == nil) then 0 else 1 -> isbtn in
let VUIcomputeDialogBoxSize viewstr (VUIgetContainerGroupTheme dlgstr.VUIDLG_container) (VUIgetElementText dlgstr.VUIDLG_title) (VUIgetElementText dlgstr.VUIDLG_frame) isbtn -> [tlw tlh ttw tth btnh] in
let dlgstr.VUIDLG_title.VUIE_vSize -> [ptlw ptlh] in
let dlgstr.VUIDLG_container.VUICNT_strw.VUIW_vSize -> [pttw ptth] in
(
let itof (ttw + 30) -> nttw in
let itof (10 + tlh + tth + 20 + btnh) -> ntth in
if (nttw == pttw && ntth == ptth) then nil else
VUIsetContainerSize dlgstr.VUIDLG_container [nttw ntth] nil;
if (tlh == (ftoi ptlh)) then nil else
(
VUIsetElementSize dlgstr.VUIDLG_title [100.0 (itof tlh)] nil;
VUIsetElementSize dlgstr.VUIDLG_frame nil [1 1 (-20) (-(10 + tlh + 10 + btnh))];
VUIsetElementPos dlgstr.VUIDLG_frame [0.0 (itof (10 + tlh))] nil nil;
);
);
0;;
fun cbVUIDlgBoxThemeUpdate(contstr, p)=
let p -> [dlgstr viewstr] in
VUIupdateDialogBoxSize viewstr dlgstr;
0;;
fun VUIcreateDialogBoxExt(viewstr, groupstr, title, text, oklabel, cancellabel, opacity, vr, cbfun, themeref)=
let VUIgetThemeDef (VUIgetGroupTheme groupstr) themeref -> defstr in
let if (title == nil) then nil else VUIgetThemeFont defstr "title" -> tlfontstr in
let VUIgetThemeFont defstr "label" -> lbfontstr in
let if (oklabel == nil && cancellabel == nil) then 0 else 1 -> isbtn in
let VUIcomputeDialogBoxSize viewstr (VUIgetGroupTheme groupstr) title text isbtn -> [tlw tlh ttw tth btnh] in
let [(itof (ttw + 30)) (itof (10 + tlh + tth + 20 + btnh))] -> [nw nh] in
let if (!vr) then
VUIcreateContainer viewstr groupstr [0.0 0.0] [nw nh] [0 0 0 0 0 0 0 0] [1 1] opacity 650
else
VUIcreateVrContainer (V3DgetDefaultSession viewstr) groupstr [0.0 0.0] [nw nh] 1.0 opacity 1 10
-> contstr in
let mkVUIDlg [contstr nil nil nil nil cbfun] -> dlgstr in
(
//addLogMessage strcatn "dlg size : "::(itoa ttw)::" "::(itoa tlh + tth)::nil;
VUIsetElementTheme contstr.VUICNT_buffer defstr "background";
if (title == nil) then nil else
(
set dlgstr.VUIDLG_title = VUIcreateFrame contstr nil [0.0 10.0] [100.0 (itof tlh)] [0 0 1 0 10 10 (-20) 0] [1 0];
VUIsetElementText dlgstr.VUIDLG_title tlfontstr title [0 0] [0 0] [0 0] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP VUI_TextStatic 1;
);
set dlgstr.VUIDLG_frame = VUIcreateFrame contstr nil [0.0 (itof (10 + tlh))] [100.0 100.0] [0 0 1 1 10 10 (-20) (-(10 + tlh + 10 + btnh))] [1 0];
VUIsetElementText dlgstr.VUIDLG_frame lbfontstr text [0 0] [0 0] [0 0] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextStatic 1;
if (oklabel == nil) then nil else
(
let if (cancellabel == nil) then [0.0 10.0] else [-.20.0 10.0] -> pos in
set dlgstr.VUIDLG_okBtn = VUIcreateButton contstr nil pos [30.0 30.0] [1 0 1 0 0 0 0 0] [1 2];
VUIsetElementTheme dlgstr.VUIDLG_okBtn defstr "okButton";
let VUIgetThemeFont defstr "okButton" -> bfontstr in
(
VUIsetElementText dlgstr.VUIDLG_okBtn bfontstr oklabel [0 0] [0 0] [2 2] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
);
VUIsetElementCbFullClick dlgstr.VUIDLG_okBtn mkfun6 @cbVUIDlgClick [dlgstr 1];
);
if (cancellabel == nil) then nil else
(
let if (oklabel == nil) then [0.0 10.0] else [20.0 10.0] -> pos in
set dlgstr.VUIDLG_cancelBtn = VUIcreateButton contstr nil pos [30.0 30.0] [1 0 1 0 0 0 0 0] [1 2];
VUIsetElementTheme dlgstr.VUIDLG_cancelBtn defstr "cancelButton";
let VUIgetThemeFont defstr "cancelButton" -> bfontstr in
(
VUIsetElementText dlgstr.VUIDLG_cancelBtn bfontstr cancellabel [0 0] [0 0] [2 2] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
);
VUIsetElementCbFullClick dlgstr.VUIDLG_cancelBtn mkfun6 @cbVUIDlgClick [dlgstr 0];
);
VUIsetContainerThemeCallback contstr mkfun2 @cbVUIDlgBoxThemeUpdate [dlgstr viewstr];
VUIsetContainerForeground contstr 1;
VUIsetContainerTopOnFocus contstr 1;
VUIshowContainer contstr 1;
VUIsetFocusedContainer contstr;
VUIsetFocusedElement contstr nil;
dlgstr;
);;
fun VUIcreateDialogBox(viewstr, title, text, oklabel, cancellabel, opacity, vr, cbfun)=
VUIcreateDialogBoxExt viewstr nil title text oklabel cancellabel opacity vr cbfun "dialogBox";;
fun VUIcreateDialogExt(viewstr, groupstr, size, title, oklabel, cancellabel, opacity, vr, cbfun, themeref)=
let VUIgetThemeDef (VUIgetGroupTheme groupstr) themeref -> defstr in
let if (title == nil) then nil else VUIgetThemeFont defstr "title" -> tlfontstr in
let if (tlfontstr == nil) then
[0 0]
else
let VUIgetTextSize tlfontstr.VUIFI_Font title 0 iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP -> [tlw tlh] in
[tlw tlh + 5]
-> [tlw tlh] in
let size -> [sw sh] in
let if (oklabel == nil && cancellabel == nil) then 0 else
let VUIgetThemeFont defstr "okButton" -> bokfontstr in
let VUIgetThemeElement defstr "okButton" -> bokthm in
let VUIgetThemeFont defstr "cancelButton" -> bcfontstr in
let VUIgetThemeElement defstr "cancelButton" -> bcthm in
let VUIgetTextSize bokfontstr.VUIFI_Font "!" 0 iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [_ obtnh] in
let VUIgetTextSize bcfontstr.VUIFI_Font "!" 0 iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER -> [_ cbtnh] in
(max (obtnh + (bokthm.VUITHE_res.VUITHR_iBorder * 2)) (cbtnh + (bcthm.VUITHE_res.VUITHR_iBorder * 2))) + 15
-> btnh in
let VUIgetViewSize viewstr -> [cvw cvh] in
let [(cvw - 20 - 30) (cvh - 30 - btnh - tlh)] -> [maxvw maxvh] in
let [(min (max (max sw tlw) 200) maxvw) (min (max sh 70) maxvh)] -> [ttw tth] in
let [(itof (ttw + 30)) (itof (tth + btnh + tlh))] -> [nw nh] in
let if (!vr) then
VUIcreateContainer viewstr groupstr [0.0 0.0] [nw nh] [0 0 0 0 0 0 0 0] [1 1] opacity 650
else
VUIcreateVrContainer (V3DgetDefaultSession viewstr) groupstr [0.0 0.0] [nw nh] 1.0 opacity 1 10
-> contstr in
let mkVUIDlg [contstr nil nil nil nil cbfun] -> dlgstr in
(
//addLogMessage strcatn "dlg size : "::(itoa nw)::" "::(itoa nh)::nil;
VUIsetElementTheme contstr.VUICNT_buffer defstr "background";
if (title == nil) then nil else
(
set dlgstr.VUIDLG_title = VUIcreateFrame contstr nil [0.0 10.0] [100.0 (itof tlh)] [0 0 1 0 10 10 (-20) 0] [1 0];
VUIsetElementText dlgstr.VUIDLG_title tlfontstr title [0 0] [0 0] [0 0] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP VUI_TextStatic 1;
);
set dlgstr.VUIDLG_frame = VUIcreateFrame contstr nil [0.0 (itof (10 + tlh))] [100.0 100.0] [0 0 1 1 10 10 (-20) (-(10 + tlh + 10 + btnh))] [1 0];
if (oklabel == nil) then nil else
(
let if (cancellabel == nil) then [0.0 10.0] else [-.20.0 10.0] -> pos in
set dlgstr.VUIDLG_okBtn = VUIcreateButton contstr nil pos [30.0 30.0] [1 0 1 0 0 0 0 0] [1 2];
VUIsetElementTheme dlgstr.VUIDLG_okBtn defstr "okButton";
let VUIgetThemeFont defstr "okButton" -> bfontstr in
VUIsetElementText dlgstr.VUIDLG_okBtn bfontstr oklabel [0 0] [0 0] [2 2] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
VUIsetElementCbFullClick dlgstr.VUIDLG_okBtn mkfun6 @cbVUIDlgClick [dlgstr 1];
);
if (cancellabel == nil) then nil else
(
let if (oklabel == nil) then [0.0 10.0] else [20.0 10.0] -> pos in
set dlgstr.VUIDLG_cancelBtn = VUIcreateButton contstr nil pos [30.0 30.0] [1 0 1 0 0 0 0 0] [1 2];
VUIsetElementTheme dlgstr.VUIDLG_cancelBtn defstr "cancelButton";
let VUIgetThemeFont defstr "cancelButton" -> bfontstr in
VUIsetElementText dlgstr.VUIDLG_cancelBtn bfontstr cancellabel [0 0] [0 0] [2 2] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextAutoHeight 0;
VUIsetElementCbFullClick dlgstr.VUIDLG_cancelBtn mkfun6 @cbVUIDlgClick [dlgstr 0];
);
VUIsetContainerForeground contstr 1;
VUIsetContainerTopOnFocus contstr 1;
VUIsetFocusedContainer contstr;
VUIsetFocusedElement contstr nil;
dlgstr;
);;
fun VUIcreateDialog(viewstr, size, title, oklabel, cancellabel, opacity, vr, cbfun)=
VUIcreateDialogExt viewstr nil size title oklabel cancellabel opacity vr cbfun "dialogBox";;
fun VUIgetDialogFrame(dlgstr)=
dlgstr.VUIDLG_frame;;
fun VUIgetDialogTitle(dlgstr)=
dlgstr.VUIDLG_title;;
fun VUIsetDialogTitle(dlgstr, title)=
if (title != nil) then
(
if (dlgstr.VUIDLG_title == nil) then
(
let VUIgetContainerGroupTheme dlgstr.VUIDLG_container -> themestr in
let VUIgetThemeDef themestr "dialogBox" -> defstr in
let VUIgetThemeFont defstr "title" -> tlfontstr in
let if (dlgstr.VUIDLG_okBtn == nil && dlgstr.VUIDLG_cancelBtn == nil) then 0 else 1 -> isbtn in
let VUIcomputeDialogBoxSize dlgstr.VUIDLG_container.VUICNT_strw.VUIW_view themestr title dlgstr.VUIDLG_frame.VUIE_Text.VUIT_sContent isbtn -> [tlw tlh ttw tth btnh] in
(
set dlgstr.VUIDLG_title = VUIcreateFrame dlgstr.VUIDLG_container nil [0.0 10.0] [100.0 (itof tlh)] [0 0 1 0 10 10 (-20) 0] [1 0];
VUIsetElementText dlgstr.VUIDLG_title tlfontstr title [0 0] [0 0] [0 0] iVUITEXT_HALIGNLEFT|iVUITEXT_VALIGNTOP VUI_TextStatic 1;
);
)
else
VUIsetElementTextContent dlgstr.VUIDLG_title title;
0;
)
else
(
VUIdestroyElement dlgstr.VUIDLG_title;
set dlgstr.VUIDLG_title = nil;
0;
);
0;;
fun VUIsetDialogText(dlgstr, text)=
VUIsetElementTextContent dlgstr.VUIDLG_frame text;;
fun VUIshowDialog(dlgstr, state)=
VUIshowContainer dlgstr.VUIDLG_container state;
0;;
/* VR Keyboard */
fun cbVUIKeyBtnClick(eltstr, id, x, y , btn, p)=
let p -> [keybstr viewstr [txt sc as]] in
(
cbV3DviewKeyDown nil viewstr sc as;
if (sc == 0) then
(
if (keybstr.VUIK_symContainer.VUICNT_bVisible) then
(
VUIshowContainer keybstr.VUIK_txtContainer 1;
VUIshowContainer keybstr.VUIK_symContainer 0;
VUIshowContainer keybstr.VUIK_upContainer 0;
)
else
(
VUIshowContainer keybstr.VUIK_txtContainer 0;
VUIshowContainer keybstr.VUIK_symContainer 1;
VUIshowContainer keybstr.VUIK_upContainer 0;
);
0;
)
else if (sc == 404) then
(
if (keybstr.VUIK_upContainer.VUICNT_bVisible) then
(
VUIshowContainer keybstr.VUIK_txtContainer 1;
VUIshowContainer keybstr.VUIK_symContainer 0;
VUIshowContainer keybstr.VUIK_upContainer 0;
)
else
(
VUIshowContainer keybstr.VUIK_txtContainer 0;
VUIshowContainer keybstr.VUIK_symContainer 0;
VUIshowContainer keybstr.VUIK_upContainer 1;
);
0;
)
else if (sc == 1) then
(
VUIhideVrKeyboard keybstr;
0;
)
else nil;
);
0;;
fun cbVUIKeyBtnUnClick(eltstr, id, x, y, btn, p)=
let p -> [keybstr viewstr [txt sc as]] in
cbV3DviewKeyUp nil viewstr sc;
0;;
/*! @ingroup v3DHUDApi
* \brief Create a 3D keyboard for VR
*
* Prototype: fun [V3Dsession F I] VUIkeyboard
*
* \param V3Dsession : the 3d scene structure
*
* \return VUIkeyboard : the new 3D keyboard
**/
fun VUIcreateVrKeyboard(sessionstr, groupstr, scale, opacity)=
let VUImakeKeyboard sessionstr groupstr 0 -> keybstr in
let V3DgetSessionView sessionstr -> viewstr in
let [0.0 0.0 0.0] -> pos in
let 32 -> step in
let 4 -> margin in
let 2 -> tmargin in
let (4 * step) + (5 * margin) -> kbh in
let (10 * step) + (11 * margin) -> txtkbw in
let (3 * step) + (4 * margin) -> numkbw in
let (2 * step) + (2 * margin) -> toolkbw in
let VUImakeContainer VUIC_VR groupstr -> txtcontstr in
let VUImake3Dcont txtcontstr sessionstr pos [0.0 (-.0.15)] scale 0 0.0 0 1 -> txtvrcontstr in
let VUImakeWcont txtcontstr viewstr 0.0 0.0 (itof txtkbw) (itof kbh) nil nil opacity 0 -> txtwcontstr in
let VUImakeContainer VUIC_VR groupstr -> upcontstr in
let VUImake3Dcont upcontstr sessionstr pos [0.0 (-.0.15)] scale 0 0.0 0 1 -> upvrcontstr in
let VUImakeWcont upcontstr viewstr 0.0 0.0 (itof txtkbw) (itof kbh) nil nil opacity 0 -> upwcontstr in
let VUImakeContainer VUIC_VR groupstr -> symcontstr in
let VUImake3Dcont symcontstr sessionstr pos [0.0 (-.0.15)] scale 0 0.0 0 1 -> symvrcontstr in
let VUImakeWcont symcontstr viewstr 0.0 0.0 (itof txtkbw) (itof kbh) nil nil opacity 0 -> symwcontstr in
let VUImakeContainer VUIC_VR groupstr -> numcontstr in
let VUImake3Dcont numcontstr sessionstr pos [(-.2.15) (-.0.15)] scale 0 0.0 0 1 -> numvrcontstr in
let VUImakeWcont numcontstr viewstr 0.0 0.0 (itof numkbw) (itof kbh) nil nil opacity 0 -> numwcontstr in
let VUImakeContainer VUIC_VR groupstr -> toolcontstr in
let VUImake3Dcont toolcontstr sessionstr pos [3.07 (-.0.15)] scale 0 0.0 0 1 -> toolvrcontstr in
let VUImakeWcont toolcontstr viewstr 0.0 0.0 (itof toolkbw) (itof kbh) nil nil opacity 0 -> toolwcontstr in
let VUIgetThemeDef (VUIgetGroupTheme groupstr) "keyboard" -> defstr in
(
VUIsetElementTheme txtcontstr.VUICNT_buffer defstr "background";
VUIsetElementTheme upcontstr.VUICNT_buffer defstr "background";
VUIsetElementTheme symcontstr.VUICNT_buffer defstr "background";
VUIsetElementTheme numcontstr.VUICNT_buffer defstr "background";
VUIsetElementTheme toolcontstr.VUICNT_buffer defstr "background";
VUIsetContainerClear txtcontstr 0;
VUIsetContainerClear upcontstr 0;
VUIsetContainerClear symcontstr 0;
VUIsetContainerClear numcontstr 0;
VUIsetContainerClear toolcontstr 0;
set txtwcontstr.VUIW_bOnMaterial = 1;
set txtwcontstr.VUIW_material = txtvrcontstr.VUI3D_material;
set txtwcontstr.VUIW_iTechnique = 0;
set txtwcontstr.VUIW_iPass = 0;
set txtwcontstr.VUIW_iTexture = 0;
set keybstr.VUIK_txtContainer = txtcontstr;
set upwcontstr.VUIW_bOnMaterial = 1;
set upwcontstr.VUIW_material = upvrcontstr.VUI3D_material;
set upwcontstr.VUIW_iTechnique = 0;
set upwcontstr.VUIW_iPass = 0;
set upwcontstr.VUIW_iTexture = 0;
set keybstr.VUIK_upContainer = upcontstr;
set symwcontstr.VUIW_bOnMaterial = 1;
set symwcontstr.VUIW_material = symvrcontstr.VUI3D_material;
set symwcontstr.VUIW_iTechnique = 0;
set symwcontstr.VUIW_iPass = 0;
set symwcontstr.VUIW_iTexture = 0;
set keybstr.VUIK_symContainer = symcontstr;
set numwcontstr.VUIW_bOnMaterial = 1;
set numwcontstr.VUIW_material = numvrcontstr.VUI3D_material;
set numwcontstr.VUIW_iTechnique = 0;
set numwcontstr.VUIW_iPass = 0;
set numwcontstr.VUIW_iTexture = 0;
set keybstr.VUIK_numContainer = numcontstr;
set toolwcontstr.VUIW_bOnMaterial = 1;
set toolwcontstr.VUIW_material = toolvrcontstr.VUI3D_material;
set toolwcontstr.VUIW_iTechnique = 0;
set toolwcontstr.VUIW_iPass = 0;
set toolwcontstr.VUIW_iTexture = 0;
set keybstr.VUIK_toolContainer = toolcontstr;
let lVUIKeyTxt -> ltxt in
let 0 -> cw in
let 0 -> ch in
let step -> laststep in
while (ltxt != nil) do
(
let hd ltxt -> [txt sc as uas] in
let (struppercase strdup txt) -> utxt in
let if (sc == 404) then
"capkey"
else "key"
-> keythm in
let if (sc == 57) then //space
(step * 6) + (margin * 5)
else
step
-> nextstep in
(
if (sc < 0) then
(
while (sc < 0) do
(
if ((cw + margin + nextstep) < txtkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + nextstep;
set laststep = nextstep;
set nextstep = step;
set sc = sc + 1;
);
)
else
(
if ((cw + margin + nextstep) < txtkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + margin;
let VUIcreateButton txtcontstr nil [(itof cw) (itof ch)] [(itof nextstep) (itof step)] [0 0 0 0 0 0 0 0] [0 0] -> btnstr in
let VUIcreateButton upcontstr nil [(itof cw) (itof ch)] [(itof nextstep) (itof step)] [0 0 0 0 0 0 0 0] [0 0] -> ubtnstr in
(
VUIsetElementTheme btnstr defstr keythm;
VUIsetElementTheme ubtnstr defstr keythm;
if ((strcmp keythm "key") || (sc == 57)) then nil else
(
VUIsetElementText btnstr nil txt [0 0] [nextstep step] [0 tmargin] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextStatic 0;
VUIsetElementText ubtnstr nil utxt [0 0] [nextstep step] [0 tmargin] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextStatic 0;
);
VUIsetElementCbClick btnstr mkfun6 @cbVUIKeyBtnClick [keybstr viewstr [txt sc as]];
VUIsetElementCbUnClick btnstr mkfun6 @cbVUIKeyBtnUnClick [keybstr viewstr [txt sc as]];
VUIsetElementCbClick ubtnstr mkfun6 @cbVUIKeyBtnClick [keybstr viewstr [txt sc uas]];
VUIsetElementCbUnClick ubtnstr mkfun6 @cbVUIKeyBtnUnClick [keybstr viewstr [txt sc uas]];
set cw = cw + nextstep;
set laststep = nextstep;
);
);
);
set ltxt = tl ltxt;
);
let lVUIKeySym -> lsym in
let 0 -> cw in
let 0 -> ch in
let step -> laststep in
while (lsym != nil) do
(
let hd lsym -> [txt sc as] in
let (struppercase strdup txt) -> utxt in
let if (sc == 404) then
"capkey"
else "key"
-> keythm in
let if (sc == 57) then //space
(step * 6) + (margin * 5)
else
step
-> nextstep in
(
if (sc < 0) then
(
while (sc < 0) do
(
if ((cw + margin + nextstep) < txtkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + nextstep;
set laststep = nextstep;
set nextstep = step;
set sc = sc + 1;
);
)
else
(
if ((cw + margin + nextstep) < txtkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + margin;
let VUIcreateButton symcontstr nil [(itof cw) (itof ch)] [(itof nextstep) (itof step)] [0 0 0 0 0 0 0 0] [0 0] -> btnstr in
(
VUIsetElementTheme btnstr defstr keythm;
if ((strcmp keythm "key") || (sc == 57)) then nil else
(
VUIsetElementText btnstr nil txt [0 0] [nextstep step] [0 tmargin] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextStatic 0;
);
VUIsetElementCbClick btnstr mkfun6 @cbVUIKeyBtnClick [keybstr viewstr [txt sc as]];
VUIsetElementCbUnClick btnstr mkfun6 @cbVUIKeyBtnUnClick [keybstr viewstr [txt sc as]];
set cw = cw + nextstep;
set laststep = nextstep;
);
);
);
set lsym = tl lsym;
);
let lVUIKeyNum -> lnum in
let 0 -> cw in
let 0 -> ch in
while (lnum != nil) do
(
let hd lnum -> [txt sc as] in
(
if (sc < 0) then
(
while (sc < 0) do
(
if ((cw + margin + step) < numkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + step;
set sc = sc + 1;
);
)
else
(
if ((cw + margin + step) < numkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + margin;
let VUIcreateButton numcontstr nil [(itof cw) (itof ch)] [(itof step) (itof step)] [0 0 0 0 0 0 0 0] [0 0] -> btnstr in
(
VUIsetElementTheme btnstr defstr "key";
VUIsetElementText btnstr nil txt [0 0] [step step] [0 tmargin] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextStatic 0;
VUIsetElementCbClick btnstr mkfun6 @cbVUIKeyBtnClick [keybstr viewstr [txt sc as]];
VUIsetElementCbUnClick btnstr mkfun6 @cbVUIKeyBtnUnClick [keybstr viewstr [txt sc as]];
set cw = cw + step;
);
);
);
set lnum = tl lnum;
);
let lVUIKeyTool -> ltool in
let 0 -> cw in
let 0 -> ch in
while (ltool != nil) do
(
let hd ltool -> [txt sc as] in
let if (sc == 14) then
"delkey"
else if (sc == 28) then
"enterkey"
else if (sc == 339) then
"clearkey"
else if (sc == 1) then
"hidekey"
else "key"
-> keythm in
(
if (sc < 0) then
(
while (sc < 0) do
(
if ((cw + margin + step) < toolkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + step;
set sc = sc + 1;
);
)
else
(
if ((cw + margin + (step * 2)) < toolkbw) then nil else
(
set ch = ch + step;
set cw = 0;
);
if (cw != 0) then nil else
set ch = ch + margin;
set cw = cw + margin;
let VUIcreateButton toolcontstr nil [(itof cw) (itof ch)] [(itof (step * 2)) (itof step)] [0 0 0 0 0 0 0 0] [0 0] -> btnstr in
(
VUIsetElementTheme btnstr defstr keythm;
if (strcmp keythm "key") then nil else
VUIsetElementText btnstr nil txt [0 0] [(step * 2) step] [0 tmargin] iVUITEXT_HALIGNCENTER|iVUITEXT_VALIGNCENTER VUI_TextStatic 0;
VUIsetElementCbClick btnstr mkfun6 @cbVUIKeyBtnClick [keybstr viewstr [txt sc as]];
VUIsetElementCbUnClick btnstr mkfun6 @cbVUIKeyBtnUnClick [keybstr viewstr [txt sc as]];
set cw = cw + (step * 2);
);
);
);
set ltool = tl ltool;
);
keybstr;
);;
/*! @ingroup v3DHUDApi
* \brief Show a 3D keyboard for VR
*
* Prototype: fun [VUIkeyboard I] VUIkeyboard
* \param VUIkeyboard : the virtual keyboard
* \param I : keyboard mode 0 default, 1 text, 2 numeric
*
* \return VUIkeyboard : the 3D keyboard
**/
fun VUIshowVrKeyboard(keybstr, mode)=
// compute position
let V3DgetSessionView keybstr.VUIK_session -> viewstr in
let (V3DgetDefaultViewport viewstr) -> viewportstr in
let SO3ViewportGetCamera viewportstr.V3D_viewport -> camera in
let SO3ObjectGetGlobalPosition camera -> gpos in
let SO3ObjectGetGlobalOrientation camera -> gquat in
let SO3MathsQuatToEulerPYR gquat -> [ax ay az] in
let SO3MathsEulerPYRToQuat [(-.0.785398) ay 0.0] -> gquat in
let if (viewstr.V3D_bVRmode) then SO3MathsDegreeToRadian iVUIBASEVRFOV else (SO3CameraGetFOVy camera) *. 0.5 -> fovy in
let 0.8 -> dist in
let (dist *. (absf (tan fovy))) *. 2.0 -> ch in
let ch /. (itof iVUIBASEVRHEIGHT) -> pph in
let (minf pph (ch /. ((itof iVUIBASEVRHEIGHT) +. iVUIBASEVRMARGIN))) *. 100.0 -> nscale in // 50.0 margin
let SO3MathsQuatGetDirection gquat [0.0 0.0 (-.dist)] -> cdir in
let addVectorF gpos cdir -> pos in
(
VUIset3DContainerPosition keybstr.VUIK_txtContainer pos;
VUIset3DContainerScale keybstr.VUIK_txtContainer nscale;
VUIset3DContainerOrientation keybstr.VUIK_txtContainer gquat;
VUIset3DContainerPosition keybstr.VUIK_upContainer pos;
VUIset3DContainerScale keybstr.VUIK_upContainer nscale;
VUIset3DContainerOrientation keybstr.VUIK_upContainer gquat;
VUIset3DContainerPosition keybstr.VUIK_symContainer pos;
VUIset3DContainerScale keybstr.VUIK_symContainer nscale;
VUIset3DContainerOrientation keybstr.VUIK_symContainer gquat;
VUIset3DContainerPosition keybstr.VUIK_numContainer pos;
VUIset3DContainerScale keybstr.VUIK_numContainer nscale;
VUIset3DContainerOrientation keybstr.VUIK_numContainer gquat;
VUIset3DContainerPosition keybstr.VUIK_toolContainer pos;
VUIset3DContainerScale keybstr.VUIK_toolContainer nscale;
VUIset3DContainerOrientation keybstr.VUIK_toolContainer gquat;
if (mode == 2) then
VUIset3DContainerOffset keybstr.VUIK_numContainer [0.0 (-.0.15)]
else
VUIset3DContainerOffset keybstr.VUIK_numContainer [(-.2.15) (-.0.15)];
VUIshowContainer keybstr.VUIK_txtContainer if (mode < 2) then 1 else 0;
VUIshowContainer keybstr.VUIK_upContainer 0;
VUIshowContainer keybstr.VUIK_symContainer 0;
VUIshowContainer keybstr.VUIK_numContainer if (mode != 1) then 1 else 0;
VUIshowContainer keybstr.VUIK_toolContainer 1;
set keybstr.VUIK_iMode = mode;
set keybstr.VUIK_bVisible = 1;
keybstr;
);;
/*! @ingroup v3DHUDApi
* \brief Hide a 3D keyboard for VR
*
* Prototype: fun [VUIkeyboard] VUIkeyboard
*
* \param VUIkeyboard : the virtual keyboard
*
* \return VUIkeyboard : the 3D keyboard
**/
fun VUIhideVrKeyboard(keybstr)=
if (!keybstr.VUIK_bVisible) then nil else
(
VUIshowContainer keybstr.VUIK_txtContainer 0;
VUIshowContainer keybstr.VUIK_upContainer 0;
VUIshowContainer keybstr.VUIK_symContainer 0;
VUIshowContainer keybstr.VUIK_numContainer 0;
VUIshowContainer keybstr.VUIK_toolContainer 0;
set keybstr.VUIK_bVisible = 0;
if (VUI_focusedContainer == nil) then nil else
(
VUIsetFocusedElement VUI_focusedContainer nil;
exec VUI_focusedContainer.VUICNT_strw.VUIW_cbFocused with [VUI_focusedContainer 0];
);
);
keybstr;;
/*! @ingroup v3DHUDApi
* \brief Destroy a 3D keyboard for VR
*
* Prototype: fun [VUIkeyboard] I
*
* \param VUIkeyboard : the virtual keyboard
*
* \return I : 0
**/
fun VUIdestroyVrKeyboard(keybstr)=
VUIdestroyContainer keybstr.VUIK_txtContainer;
VUIdestroyContainer keybstr.VUIK_upContainer;
VUIdestroyContainer keybstr.VUIK_symContainer;
VUIdestroyContainer keybstr.VUIK_numContainer;
VUIdestroyContainer keybstr.VUIK_toolContainer;
set keybstr.VUIK_txtContainer = nil;
set keybstr.VUIK_upContainer = nil;
set keybstr.VUIK_symContainer = nil;
set keybstr.VUIK_numContainer = nil;
set keybstr.VUIK_toolContainer = nil;
0;;
/* ************************ */
/* GLOBAL GROUPS FUNCTIONS */
/* ************************ */
/*! @ingroup v3DHUDApi
* \brief create a container group
*
* Prototype: fun [VUItheme] VUIcontainerGroup
*
* \param VUItheme : the theme
*
* \return VUIcontainerGroup : the new container group
**/
fun VUIcreateContainerGroup(themestr)=
mkVUIcontainerGroup [themestr nil];;
/* ************************ */
/* GLOBAL THEME FUNCTIONS */
/* ************************ */
/*! @ingroup v3DHUDApi
* \brief search base theme ref with "_"
*
* Prototype: fun [S] S
*
* \param S : the theme reference
*
* \return S : the base theme reference
**/
fun VUIgetThemerefPrefix(ref)=
let strfind "_" ref 0 -> p in
if (p == nil) then nil else
substr ref 0 p;;
/*! @ingroup v3DHUDApi
* \brief get theme path from theme name
*
* Prototype: fun [S] S
*
* \param S : the theme name
*
* \return S : the theme path
**/
fun VUIgetThemePath(basename)=
if (!strcmp basename "default") then
VUI_defTheme
else
let strreplace basename " " "_" -> basename in
strcatn VUI_USER_THEME_FOLDER::"/"::basename::"/"::basename::".uith"::nil;;
/*! @ingroup v3DHUDApi
* \brief reload theme resources on an element
*
* Prototype: fun [VUIelement] I
*
* \param VUIelement : the element structure
*
* \return I : 0
**/
fun VUIreloadElementThemeResource(eltstr, themestr)=
if (eltstr.VUIE_resource.VUIR_bFromTheme != 1) then nil else
let eltstr.VUIE_resource.VUIR_tThemeInfos -> [sdef sname] in
let switchstr themestr.VUITH_lDefinitions sdef -> defstr in
let if (defstr == nil) then VUIgetThemeDef themestr VUIgetThemerefPrefix sdef else defstr -> defstr in
(
VUIsetElementTheme eltstr defstr sname;
if (eltstr.VUIE_resource.VUIR_oBuffer == nil) then nil else
(
_DSalphaBitmap eltstr.VUIE_resource.VUIR_oBuffer;
set eltstr.VUIE_resource.VUIR_oBuffer = nil;
);
VUIelementNeedUpdate eltstr 1;
);
if (eltstr.VUIE_Text.VUIT_font.VUIFI_bFromTheme != 1) then nil else
let eltstr.VUIE_Text.VUIT_font.VUIFI_tThemeInfos -> [sdef sname] in
let VUIgetThemeDef themestr sdef -> defstr in
let if (defstr == nil) then VUIgetThemeDef themestr VUIgetThemerefPrefix sdef else defstr -> defstr in
(
VUIdelFont eltstr.VUIE_Text.VUIT_font.VUIFI_Font;
let VUIgetThemeFont defstr sname -> nfontstr in
set eltstr.VUIE_Text.VUIT_font = nfontstr;
set eltstr.VUIE_Text.VUIT_font.VUIFI_Font.VUIF_iUsed = eltstr.VUIE_Text.VUIT_font.VUIFI_Font.VUIF_iUsed + 1;
if (eltstr.VUIE_resource.VUIR_oBuffer == nil) then nil else
(
_DSalphaBitmap eltstr.VUIE_resource.VUIR_oBuffer;
set eltstr.VUIE_resource.VUIR_oBuffer = nil;
);
set eltstr.VUIE_Text.VUIT_bNeedUpdate = 1;
);
let eltstr.VUIE_children -> l in
while (l != nil) do
(
VUIreloadElementThemeResource hd l themestr;
set l = tl l;
);
VUIelementNeedUpdate eltstr 1;
0;;
/*! @ingroup v3DHUDApi
* \brief reload theme resources
*
* Prototype: fun [] I
*
* \return I : 0
**/
fun VUIreloadThemeResources()=
let VUIcontainerAllList -> list in
while (list != nil) do
(
let hd list -> contstr in
let VUIgetContainerGroupTheme contstr -> themestr in
(
VUIreloadElementThemeResource contstr.VUICNT_buffer themestr;
let contstr.VUICNT_lElements -> leltstr in
while (leltstr != nil) do
(
VUIreloadElementThemeResource hd leltstr themestr;
set leltstr = tl leltstr;
);
if (contstr.VUICNT_cbThemeUpdate == nil) then nil else
exec contstr.VUICNT_cbThemeUpdate with [contstr];
);
set list = tl list;
);
0;;
fun VUIreloadGroupThemeResources(groupstr)=
let VUIgetGroupTheme groupstr -> themestr in
let groupstr.VUICG_lcntList -> list in
while (list != nil) do
(
let hd list -> contstr in
(
VUIreloadElementThemeResource contstr.VUICNT_buffer themestr;
let contstr.VUICNT_lElements -> leltstr in
while (leltstr != nil) do
(
VUIreloadElementThemeResource hd leltstr themestr;
set leltstr = tl leltstr;
);
if (contstr.VUICNT_cbThemeUpdate == nil) then nil else
exec contstr.VUICNT_cbThemeUpdate with [contstr];
);
set list = tl list;
);
0;;
/*! @ingroup v3DHUDApi
* \brief change the current theme
*
* Prototype: fun [S] I
*
* \param S : the theme file path
*
* \return I : 0
**/
fun VUIsetGroupTheme(groupstr, file)=
if ((_checkpack file) == nil) then nil else
set groupstr.VUICG_thm = VUIloadTheme file;
VUIreloadGroupThemeResources groupstr;
0;;
/*! @ingroup v3DHUDApi
* \brief change the current theme
*
* Prototype: fun [S] I
*
* \param S : the theme file path
*
* \return I : 0
**/
fun VUIsetTheme(file)=
let if ((_checkpack file) == nil) then VUI_defTheme else file -> thfile in
set VUIdefaultTheme = VUIloadTheme thfile;
VUIreloadThemeResources;
0;;
/* *************************** */
/* GLOBAL VUI INIT FUNCTIONS */
/* *************************** */
/* Init */
fun VUIsetEnable(sessionstr, state)=
if (state) then
(
VUIinit sessionstr;
V3DsetCbHUDPreRender sessionstr @cbHUDPreRender;
V3DsetCbHUDPostRender sessionstr @cbHUDPostRender;
V3DsetCbResizeHUDView sessionstr.V3D_sessionView @cbHUDresizeView;
V3DsetCbKeyDownHUD sessionstr.V3D_sessionView @cbHUDKeyDown;
V3DsetCbKeyUpHUD sessionstr.V3D_sessionView @cbHUDKeyUp;
)
else
(
V3DsetCbHUDPreRender sessionstr nil;
V3DsetCbHUDPostRender sessionstr nil;
V3DsetCbResizeHUDView sessionstr.V3D_sessionView nil;
V3DsetCbKeyDownHUD sessionstr.V3D_sessionView nil;
V3DsetCbKeyUpHUD sessionstr.V3D_sessionView nil;
);
0;;
fun VUIsetGlobalScaleFactor(sessionstr, scale)=
set fVUIGlobalScaleFactor = 1.0 /. scale;
let V3DgetSessionView sessionstr -> viewstr in
VUIupdateScreenSensity viewstr;
if (VUIdefVrKeyboard == nil) then nil else
(
let VUIdefVrKeyboard.VUIK_group -> groupstr in
(
VUIdestroyVrKeyboard VUIdefVrKeyboard;
set VUIdefVrKeyboard = VUIcreateVrKeyboard sessionstr groupstr 1.0 100;
);
);
0;;
fun VUIinit(sessionstr)=
if (VUI_STARTED) then nil else
(
set VUI_STARTED = 1;
set VUI_defResWin = strcat sV3DDEFAULTRESOURCESPATH VUI_defResWin;
set VUI_defResBtn = strcat sV3DDEFAULTRESOURCESPATH VUI_defResBtn;
set VUI_defResTxt = strcat sV3DDEFAULTRESOURCESPATH VUI_defResTxt;
set VUI_defResListElt = strcat sV3DDEFAULTRESOURCESPATH VUI_defResListElt;
set VUI_defResListEltCheck = strcat sV3DDEFAULTRESOURCESPATH VUI_defResListEltCheck;
set VUI_defResTreeBtn = strcat sV3DDEFAULTRESOURCESPATH VUI_defResTreeBtn;
set VUI_defResScrollBtn = strcat sV3DDEFAULTRESOURCESPATH VUI_defResScrollBtn;
set VUI_defResCheckBtn = strcat sV3DDEFAULTRESOURCESPATH VUI_defResCheckBtn;
set VUI_defTheme = strcat sV3DDEFAULTRESOURCESPATH VUI_defTheme;
set VUI_BT_FONT_PATH = strcat sV3DDEFAULTRESOURCESPATH VUI_BT_FONT_PATH;
let V3DgetSessionView sessionstr -> viewstr in
VUIupdateScreenSensity viewstr;
SO3GroupCreate (V3DgetSession sessionstr) sVUIResourcesGroup;
set VUIdefaultTheme = VUIloadTheme VUI_defTheme;
set VUIdefVrKeyboard = VUIcreateVrKeyboard sessionstr nil 1.0 100;
);
0;;
fun VUIreset(sessionstr)=
if (!VUI_STARTED) then
(
VUIinit sessionstr;
0;
)
else
(
set fVUIGlobalScaleFactor = 1.0;
let V3DgetSessionView sessionstr -> viewstr in
VUIupdateScreenSensity viewstr;
//cleanup group
SO3GroupDelete (V3DgetSession sessionstr) sVUIResourcesGroup;
SO3GroupCreate (V3DgetSession sessionstr) sVUIResourcesGroup;
set VUIdefaultTheme = VUIloadTheme VUI_defTheme;
if (VUIdefVrKeyboard == nil) then nil else
(
VUIdestroyVrKeyboard VUIdefVrKeyboard;
set VUIdefVrKeyboard = VUIcreateVrKeyboard sessionstr nil 1.0 100;
);
0;
);
0;;