/* ------------------------------------------------------------------------------------- User Interface ------------------------------------------------------------------------------------- Author: Josh Kirklin (Ortu) http://joshkirklin.com | http://github.com/ortu- ------------------------------------------------------------------------------------- Contributors: ------------------------------------------------------------------------------------- License: Source in this file is released under the terms of the MIT License: https://opensource.org/licenses/MIT Copyright(c) 2018 Josh Kirklin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------------- Description: Provides handling for the construction and management of GUI components, as well as handling of various generic user input events such as detection of mouseclicks and keypress under the scope of the UI. Does not provide handling for game controls such as character and camera movement which are more specific to individual games and game mechanics. See Control Module. ******************************************* */ //Declare UI ----------------------------------------------------------- type UI_type_borderData size as string color as integer endtype type UI_type_sizeData isPercent as integer value as integer endtype type UI_type_stylePropertyData positionAlignH as string //left|right|center positionAlignV as string //top|bottom|center position as string //relative|absolute top as string //#px|#% left as string //#px|#% paddingTop as string //#px|#% paddingBottom as string //#px|#% paddingLeft as string //#px|#% paddingRight as string //#px|#% width as string //#px|#% height as string //#px|#% borderTop as UI_type_borderData borderBottom as UI_type_borderData borderLeft as UI_type_borderData borderRight as UI_type_borderData //TODO: borderImage as UI_type_imageData marginTop as string //TODO: not implemented in update / resolve position marginBottom as string //TODO: not implemented in update / resolve position marginRight as string //TODO: not implemented in update / resolve position marginLeft as string //TODO: not implemented in update / resolve position minWidth as string //TODO: not implemented in update / resolve position maxWidth as string //TODO: not implemented in update / resolve position minHeight as string //TODO: not implemented in update / resolve position maxHeight as string //TODO: not implemented in update / resolve position backgroundColor as integer backgroundOpacity as integer //% as 0-100 backgroundImage as string //filepath backgroundRepeat as string //no-repeat|repeat|repeat-x|repeat-y|cover backgroundAlignH as string //left|right|center backgroundAlignV as string //top|bottom|center display as string //visible|hidden :: inheritable opacity as integer //% as 0-100 :: inheritable zIndex as integer // 0 = top most, 10000 = back most :: inheritable cursor as string // :: inheritable color as integer // :: inheritable font as string // font name :: inheritable fontSize as integer // :: inheritable textDecoration as string //none|bold|italic|underline :: inheritable textTransform as string //upper|lower|capitalize :: inheritable textIndent as string //#px|#% first line indent :: inheritable textAlignH as string //left|right|center :: inheritable textAlignV as string //top|bottom|center :: inheritable rotation as integer //angle as 0-360 :: inheritable _finalX as integer //final resolved px coord :: private _finalY as integer //final resolved px coord :: private _finalW as integer _finalH as integer _innerX as integer _innerY as integer _innerW as integer _innerH as integer _isResolved as integer _flowPropertyEnabled as integer _visualPropertyEnabled as integer endtype type UI_type_stylePropData defaults as UI_type_stylePropertyData lastColor as integer lastFont as integer lastFontSize as integer endtype type UI_type_statusData mouseMode as string //ui|gameplay|disabled keyMode as string //ui|gameplay|disabled mouseModeForced as string keyModeForced as string inputMark as integer inputReady as integer lastUpdate as integer endtype type UI_type_elementDragData isActive as integer dragElementIndex as integer targetElementIndex as integer offsetX as integer offsetY as integer endtype type UI_type_transitionData elementIndex as integer prop as string initVal as string targetVal as string duration as integer start as integer callback as string endtype type STATIC_CLASS_UI styleProp as UI_type_stylePropData status as UI_type_statusData elementDrag as UI_type_elementDragData parsedSizeData as UI_type_sizeData elementList as CLASS_ElementUI[] styleClassList as CLASS_StyleClassUI[] selectBoxList as string[] transitionList as UI_type_transitionData[] resultElements as integer[] //index of element within elementList[] endtype //Declare ElementUI ----------------------------------------------------------- type CLASS_ElementUI id as string name as string tag as string parent as integer //as index of element parentID as string //element ID name to relink when elements are removed. styleClassIndex as integer //unlike parent, we need to keep the class name in addition to the class index for use with getElementsByClassName styleClass as string //currently only handles 1 class assignment per element. style as UI_type_stylePropertyData resolvedStyle as UI_type_stylePropertyData value as string scrollX as integer scrollY as integer onPress as string //name of callback function to execute on event onRelease as string onMouseIn as string onMouseOut as string mouseIsOver as integer //mouse curser is within element bounds? pressIsHeld as integer //mouseclick or hotkey press is held down? keyBind as integer //key id to act as hotkey to trigger onPress event enableEvents as integer //0 disabled | 1 enabled mouse | 2 enabled keybind | 3 enabled mouse and keybind | 4 enable drag and drop holdPause as integer //gameplay is paused while element is visible holdMouseFocus as integer //gameplay ignores mouse input while element is visible holdKeyFocus as integer //gameplay ignores key input while element is visible selectedIndex as integer /* if this is > -1, value will refer to the index of the select box list in UI_selectBoxes[] which is a list of csv strings. selectedIndex then indicates which split string contains the element's final value. UI_selectBoxes[0] = "1,2,3,4,5" e.value = 0 e.selectedIndex = 3 print ElementUI_getSelectedValue(e.value, e.selectedIndex) >> "4" */ //TODO: enableMove as integer //0-disabled | 1-freely drag around within parent bounds | 2-freely drag parent around within parent's parent bounds | 3-drag and drop from sockets enableSize as integer //grabbing an edge (2px?) or border will allow to resize the width/height isDirty as integer endtype //Declare StyleClassUI ----------------------------------------------------------- type CLASS_StyleClassUI className as string style as UI_type_stylePropertyData endtype //Init --------------------------------------------------------------------------- //=================================== GLOBAL UI as STATIC_CLASS_UI // ================================== //flow props #CONSTANT BIT_UI_StyleProp_positionAlignH 1 #CONSTANT BIT_UI_StyleProp_positionAlignV 2 #CONSTANT BIT_UI_StyleProp_position 4 #CONSTANT BIT_UI_StyleProp_top 8 #CONSTANT BIT_UI_StyleProp_left 16 #CONSTANT BIT_UI_StyleProp_paddingTop 32 #CONSTANT BIT_UI_StyleProp_paddingBottom 64 #CONSTANT BIT_UI_StyleProp_paddingLeft 128 #CONSTANT BIT_UI_StyleProp_paddingRight 256 #CONSTANT BIT_UI_StyleProp_width 512 #CONSTANT BIT_UI_StyleProp_height 1024 #CONSTANT BIT_UI_StyleProp_borderTop 2048 #CONSTANT BIT_UI_StyleProp_borderBottom 4096 #CONSTANT BIT_UI_StyleProp_borderLeft 8192 #CONSTANT BIT_UI_StyleProp_borderRight 16384 #CONSTANT BIT_UI_StyleProp_borderImage 32768 #CONSTANT BIT_UI_StyleProp_marginTop 65536 #CONSTANT BIT_UI_StyleProp_marginBottom 131072 #CONSTANT BIT_UI_StyleProp_marginLeft 262144 #CONSTANT BIT_UI_StyleProp_marginRight 524288 #CONSTANT BIT_UI_StyleProp_minWidth 1048576 #CONSTANT BIT_UI_StyleProp_maxWidth 2097152 #CONSTANT BIT_UI_StyleProp_minHeight 4194304 #CONSTANT BIT_UI_StyleProp_maxHeight 8388608 //visual props #CONSTANT BIT_UI_StyleProp_backgroundColor 1 #CONSTANT BIT_UI_StyleProp_backgroundOpacity 2 #CONSTANT BIT_UI_StyleProp_backgroundImage 4 #CONSTANT BIT_UI_StyleProp_backgroundRepeat 8 #CONSTANT BIT_UI_StyleProp_backgroundAlignH 16 #CONSTANT BIT_UI_StyleProp_backgroundAlignV 32 #CONSTANT BIT_UI_StyleProp_display 64 #CONSTANT BIT_UI_StyleProp_opacity 128 #CONSTANT BIT_UI_StyleProp_zIndex 256 #CONSTANT BIT_UI_StyleProp_cursor 512 #CONSTANT BIT_UI_StyleProp_color 1024 #CONSTANT BIT_UI_StyleProp_font 2048 #CONSTANT BIT_UI_StyleProp_fontSize 4096 #CONSTANT BIT_UI_StyleProp_textDecoration 8192 #CONSTANT BIT_UI_StyleProp_textTransform 16384 #CONSTANT BIT_UI_StyleProp_textIndent 32768 #CONSTANT BIT_UI_StyleProp_textAlignH 65536 #CONSTANT BIT_UI_StyleProp_textAlignV 131072 #CONSTANT BIT_UI_StyleProp_rotation 262144 #CONSTANT FOREACH_UI_elementList for i_UI_elementList = 0 to UI.elementList.length #CONSTANT THIS_ElementUI UI.elementList[i_UI_elementList] #CONSTANT FOREACH_UI_styleClassList for i_UI_styleClassList = 0 to UI.styleClassList.length #CONSTANT THIS_StyleClass UI.styleClassList[i_UI_styleClassList] //Module Functions --------------------------------------------------------------- function UI_init() //init defaults UI.styleProp.defaults.positionAlignH = "left" UI.styleProp.defaults.positionAlignV = "top" UI.styleProp.defaults.position = "relative" UI.styleProp.defaults.top = "0px" UI.styleProp.defaults.left = "0px" UI.styleProp.defaults.paddingTop = "0px" UI.styleProp.defaults.paddingBottom = "0px" UI.styleProp.defaults.paddingLeft = "0px" UI.styleProp.defaults.paddingRight = "0px" UI.styleProp.defaults.width = "100%" UI.styleProp.defaults.height = "100%" UI.styleProp.defaults.borderTop.size = "0px" UI.styleProp.defaults.borderTop.color = 0x00000000 UI.styleProp.defaults.borderBottom.size = "0px" UI.styleProp.defaults.borderBottom.color = 0x00000000 UI.styleProp.defaults.borderRight.size = "0px" UI.styleProp.defaults.borderRight.color = 0x00000000 UI.styleProp.defaults.borderLeft.size = "0px" UI.styleProp.defaults.borderLeft.color = 0x00000000 //UI.styleProp.defaults.borderImage as UI_type_imageData UI.styleProp.defaults.marginTop = "0px" UI.styleProp.defaults.marginBottom = "0px" UI.styleProp.defaults.marginRight = "0px" UI.styleProp.defaults.marginLeft = "0px" UI.styleProp.defaults.minWidth = "0px" UI.styleProp.defaults.maxWidth = "0px" UI.styleProp.defaults.minHeight = "0px" UI.styleProp.defaults.maxHeight = "0px" UI.styleProp.defaults.backgroundColor = 0x00000000 UI.styleProp.defaults.backgroundOpacity = 100 UI.styleProp.defaults.backgroundImage = "" UI.styleProp.defaults.backgroundRepeat = "no-repeat" UI.styleProp.defaults.backgroundAlignH = "left" UI.styleProp.defaults.backgroundAlignV = "top" UI.styleProp.defaults.display = "visible" UI.styleProp.defaults.opacity = 100 UI.styleProp.defaults.zIndex = 10 UI.styleProp.defaults.cursor = "default" UI.styleProp.defaults.color = 0xffffffff UI.styleProp.defaults.font = "Arial" UI.styleProp.defaults.fontSize = 18 UI.styleProp.defaults.textDecoration = "none" UI.styleProp.defaults.textTransform = "none" UI.styleProp.defaults.textIndent = "0px" UI.styleProp.defaults.textAlignH = "left" UI.styleProp.defaults.textAlignV = "top" UI.styleProp.defaults.rotation = 0 //init status UI.status.mouseMode = "gameplay" UI.status.keyMode = "gameplay" UI.status.inputMark = System.timing.timer UI.status.lastUpdate = System.timing.timer //init root element ("window") tElement as CLASS_ElementUI tElement.id = "root" tElement.style = UI.styleProp.defaults tElement.style.width = Str(App.config.screenWidth) + "px" //must use pixel not % as root provides the basis for % calculation of all children tElement.style.height = Str(App.config.screenHeight) + "px" tElement.resolvedStyle = tElement.style tElementIndex = UI_addElement(tElement, "") //register updates App_addUpdate("UI_updatePageFlow", "", TRUE) App_addUpdate("UI_getInterfaceInput", "UI_updatePageFlow", TRUE) //input requires updated flow: if element visibility or position changes, interaction/events may change endfunction function UI_load(rDoc as string) tAttr as string parentID as string rDoc = "ui/partials/" + rDoc + ".xml" System_log("ui.agc", 3, "ui", "Loading UI: " + rDoc) XML_loadFile(rDoc) System_log("ui.agc", 2, "ui", " > Got " + str(XML.elementList.length + 1) + " XML elements") for i = 0 to XML.elementList.length select XML.elementList[i].tagName case "element": parentID = XML_getAttributeValue(XML.elementList[i].parent, "id") tElement as CLASS_ElementUI //set defaults tElement.styleClassIndex = -1 tElement.selectedIndex = -1 tElement.keyBind = -1 tElement.style.positionAlignH = UI.styleProp.defaults.positionAlignH tElement.style.positionAlignV = UI.styleProp.defaults.positionAlignV tElement.style.position = UI.styleProp.defaults.position tElement.style.top = UI.styleProp.defaults.top tElement.style.left = UI.styleProp.defaults.left tElement.style.paddingTop = UI.styleProp.defaults.paddingTop tElement.style.paddingBottom = UI.styleProp.defaults.paddingBottom tElement.style.paddingLeft = UI.styleProp.defaults.paddingLeft tElement.style.paddingRight = UI.styleProp.defaults.paddingRight tElement.style.width = UI.styleProp.defaults.width tElement.style.height = UI.styleProp.defaults.height tElement.style.borderTop.size = UI.styleProp.defaults.borderTop.size tElement.style.borderTop.color = UI.styleProp.defaults.borderTop.color tElement.style.borderBottom.size = UI.styleProp.defaults.borderBottom.size tElement.style.borderBottom.color = UI.styleProp.defaults.borderBottom.color tElement.style.borderRight.size = UI.styleProp.defaults.borderRight.size tElement.style.borderRight.color = UI.styleProp.defaults.borderRight.color tElement.style.borderLeft.size = UI.styleProp.defaults.borderLeft.size tElement.style.borderLeft.color = UI.styleProp.defaults.borderLeft.color //style.borderImage as UI_type_imageData tElement.style.marginTop = UI.styleProp.defaults.marginTop tElement.style.marginBottom = UI.styleProp.defaults.marginBottom tElement.style.marginRight = UI.styleProp.defaults.marginRight tElement.style.marginLeft = UI.styleProp.defaults.marginLeft tElement.style.minWidth = UI.styleProp.defaults.minWidth tElement.style.maxWidth = UI.styleProp.defaults.maxWidth tElement.style.minHeight = UI.styleProp.defaults.minHeight tElement.style.maxHeight = UI.styleProp.defaults.maxHeight tElement.style.backgroundColor = UI.styleProp.defaults.backgroundColor tElement.style.backgroundOpacity = UI.styleProp.defaults.backgroundOpacity tElement.style.backgroundImage = UI.styleProp.defaults.backgroundImage tElement.style.backgroundRepeat = UI.styleProp.defaults.backgroundRepeat tElement.style.backgroundAlignH = UI.styleProp.defaults.backgroundAlignH tElement.style.backgroundAlignV = UI.styleProp.defaults.backgroundAlignV tElement.style.display = UI.styleProp.defaults.display tElement.style.opacity = UI.styleProp.defaults.opacity tElement.style.zIndex = UI.styleProp.defaults.zIndex tElement.style.cursor = UI.styleProp.defaults.cursor tElement.style.color = UI.styleProp.defaults.color tElement.style.font = UI.styleProp.defaults.font tElement.style.fontSize = UI.styleProp.defaults.fontSize tElement.style.textDecoration = UI.styleProp.defaults.textDecoration tElement.style.textTransform = UI.styleProp.defaults.textTransform tElement.style.textIndent = UI.styleProp.defaults.textIndent tElement.style.textAlignH = UI.styleProp.defaults.textAlignH tElement.style.textAlignV = UI.styleProp.defaults.textAlignV tElement.style.rotation = UI.styleProp.defaults.rotation //apply doc tElement.id = XML_getAttributeValue(i, "id") tElement.name = XML_getAttributeValue(i, "name") tElement.tag = XML_getAttributeValue(i, "type") tElement.styleClass = XML_getAttributeValue(i, "class") tElement.value = XML_getAttributeValue(i, "value") tElement.onPress = XML_getAttributeValue(i, "onPress") tElement.onRelease = XML_getAttributeValue(i, "onRelease") tElement.onMouseIn = XML_getAttributeValue(i, "onMouseIn") tElement.onMouseOut = XML_getAttributeValue(i, "onMouseOut") tElement.keyBind = val(XML_getAttributeValue(i, "keyBind")) tElement.enableEvents = val(XML_getAttributeValue(i, "enableEvents")) tElement.holdPause = val(XML_getAttributeValue(i, "holdPause")) tElement.holdMouseFocus = val(XML_getAttributeValue(i, "holdMouseFocus")) tElement.holdKeyFocus = val(XML_getAttributeValue(i, "holdKeyFocus")) tElementIndex = UI_addElement(tElement, parentID) endcase case "element_style": totalCountAttrs = XML_getAttributeCount(i) if totalCountAttrs > -1 for a = 0 to totalCountAttrs tAttr = XML_getAttributeByIndex(i, a) UI_element_setStyleProp(tElementIndex, tAttr, XML_getAttributeValue(i, tAttr)) next a endif endcase case "class": System_log("ui.agc", 1, "ui", " > load ui : process new class") tClass as CLASS_StyleClassUI //set defaults tClass.style.positionAlignH = UI.styleProp.defaults.positionAlignH tClass.style.positionAlignV = UI.styleProp.defaults.positionAlignV tClass.style.position = UI.styleProp.defaults.position tClass.style.top = UI.styleProp.defaults.top tClass.style.left = UI.styleProp.defaults.left tClass.style.paddingTop = UI.styleProp.defaults.paddingTop tClass.style.paddingBottom = UI.styleProp.defaults.paddingBottom tClass.style.paddingLeft = UI.styleProp.defaults.paddingLeft tClass.style.paddingRight = UI.styleProp.defaults.paddingRight tClass.style.width = UI.styleProp.defaults.width tClass.style.height = UI.styleProp.defaults.height tClass.style.borderTop.size = UI.styleProp.defaults.borderTop.size tClass.style.borderTop.color = UI.styleProp.defaults.borderTop.color tClass.style.borderBottom.size = UI.styleProp.defaults.borderBottom.size tClass.style.borderBottom.color = UI.styleProp.defaults.borderBottom.color tClass.style.borderRight.size = UI.styleProp.defaults.borderRight.size tClass.style.borderRight.color = UI.styleProp.defaults.borderRight.color tClass.style.borderLeft.size = UI.styleProp.defaults.borderLeft.size tClass.style.borderLeft.color = UI.styleProp.defaults.borderLeft.color //style.borderImage as UI_type_imageData tClass.style.marginTop = UI.styleProp.defaults.marginTop tClass.style.marginBottom = UI.styleProp.defaults.marginBottom tClass.style.marginRight = UI.styleProp.defaults.marginRight tClass.style.marginLeft = UI.styleProp.defaults.marginLeft tClass.style.minWidth = UI.styleProp.defaults.minWidth tClass.style.maxWidth = UI.styleProp.defaults.maxWidth tClass.style.minHeight = UI.styleProp.defaults.minHeight tClass.style.maxHeight = UI.styleProp.defaults.maxHeight tClass.style.backgroundColor = UI.styleProp.defaults.backgroundColor tClass.style.backgroundOpacity = UI.styleProp.defaults.backgroundOpacity tClass.style.backgroundImage = UI.styleProp.defaults.backgroundImage tClass.style.backgroundRepeat = UI.styleProp.defaults.backgroundRepeat tClass.style.backgroundAlignH = UI.styleProp.defaults.backgroundAlignH tClass.style.backgroundAlignV = UI.styleProp.defaults.backgroundAlignV tClass.style.display = UI.styleProp.defaults.display tClass.style.opacity = UI.styleProp.defaults.opacity tClass.style.zIndex = UI.styleProp.defaults.zIndex tClass.style.cursor = UI.styleProp.defaults.cursor tClass.style.color = UI.styleProp.defaults.color tClass.style.font = UI.styleProp.defaults.font tClass.style.fontSize = UI.styleProp.defaults.fontSize tClass.style.textDecoration = UI.styleProp.defaults.textDecoration tClass.style.textTransform = UI.styleProp.defaults.textTransform tClass.style.textIndent = UI.styleProp.defaults.textIndent tClass.style.textAlignH = UI.styleProp.defaults.textAlignH tClass.style.textAlignV = UI.styleProp.defaults.textAlignV tClass.style.rotation = UI.styleProp.defaults.rotation tClass.className = XML_getAttributeValue(i, "name") System_log("ui.agc", 1, "ui", " className: " + tClass.className) tStyleClassIndex = UI_addStyleClass(tClass) endcase case "class_style": System_log("ui.agc", 1, "ui", "add class_style") totalCountAttrs = XML_getAttributeCount(i) if totalCountAttrs > -1 for a = 0 to totalCountAttrs tAttr = XML_getAttributeByIndex(i, a) System_log("ui.agc", 1, "ui", " attr: " + tAttr + " : " + XML_getAttributeValue(i, tAttr)) UI_StyleClass_setStyleProp(tStyleClassIndex, tAttr, XML_getAttributeValue(i, tAttr)) next a endif endcase case "repeater": endcase endselect next i endfunction function UI_unload() UI.styleClassList.length = -1 UI.elementList.length = -1 tElement as CLASS_ElementUI tElement.id = "root" tElement.style.width = Str(App.config.screenWidth) + "px" tElement.style.height = Str(App.config.screenHeight) + "px" tElement.resolvedStyle = tElement.style tElementIndex = UI_addElement(tElement, "") endfunction function UI_loadMedia() for i = 0 to UI.styleClassList.length if UI.styleClassList[i].style.backgroundImage > "" Media_getImageNumber(UI.styleClassList[i].style.backgroundImage, 1.0, 1.0) endif next i FOREACH_UI_elementList if THIS_ElementUI.style.backgroundImage > "" Media_getImageNumber(THIS_ElementUI.style.backgroundImage, 1.0, 1.0) endif next i_UI_elementList endfunction //Updates ==================================================================================================================================================== function UI_updatePageFlow() startTime = GetMilliseconds() dirtyCount = 0 if UI.elementList.length = 0 exitfunction endif UI_updateTransitions() UI_elementList_resetResolvedStyleProps() //----- resolve styling and page flow ---------------------- keepResolvingDeferred = TRUE while keepResolvingDeferred keepResolvingDeferred = FALSE FOREACH_UI_elementList if i_UI_elementList = 0 then inc i_UI_elementList //skip root resolveThis = TRUE //skip if already resolved if THIS_ElementUI.resolvedStyle._isResolved resolveThis = FALSE endif //defer is parent is not yet resolved if resolveThis if UI.elementList[THIS_ElementUI.parent].resolvedStyle._isResolved = FALSE resolveThis = FALSE keepResolvingDeferred = TRUE endif endif //resolve it if resolveThis System_log("ui.agc", 1, "ui", " begin resolve: " + str(THIS_ElementUI.resolvedStyle._innerW) + ", " + str(THIS_ElementUI.resolvedStyle._innerH)) //apply inherited styling UI_elementList_applyInheritedStyleProps(i_UI_elementList, THIS_ElementUI.parent) System_log("ui.agc", 1, "ui", " resolved inherit: " + THIS_ElementUI.resolvedStyle.width + ", " + THIS_ElementUI.resolvedStyle.height) //apply styleClass styling //TODO: allow multiple styleClasses if THIS_ElementUI.styleClassIndex > -1 UI_elementList_applyClassStyleProps(i_UI_elementList, THIS_ElementUI.styleClassIndex) System_log("ui.agc", 1, "ui", " resolved class: " + THIS_ElementUI.resolvedStyle.width + ", " + THIS_ElementUI.resolvedStyle.height) endif //apply inline styling UI_elementList_applyElementStyleProps(i_UI_elementList) System_log("ui.agc", 1, "ui", " resolved inline: " + THIS_ElementUI.resolvedStyle.width + ", " + THIS_ElementUI.resolvedStyle.height) //resolve flow and finalize UI_elementList_resolveFlowValues(i_UI_elementList, THIS_ElementUI.parent) System_log("ui.agc", 1, "ui", " resolved final: " + str(THIS_ElementUI.resolvedStyle._innerW) + ", " + str(THIS_ElementUI.resolvedStyle._innerH)) endif next i_UI_elementList endwhile endTime = GetMilliseconds() System_log("ui.agc", 3, "ui", "UI update Resolve: " + str(endTime - startTime) + "ms") startTime = GetMilliseconds() //----- render UI ---------------------- FOREACH_UI_elementList if i_UI_elementList = 0 then inc i_UI_elementList //skip root if THIS_ElementUI.resolvedStyle.display = "visible" if THIS_ElementUI.isDirty or THIS_ElementUI.value > "" System_log("ui.agc", 1, "ui", " renderUI: " + THIS_ElementUI.id + " needs render update.") //get flow data borderSizeT = val(THIS_ElementUI.resolvedStyle.borderTop.size) borderSizeB = val(THIS_ElementUI.resolvedStyle.borderBottom.size) borderSizeR = val(THIS_ElementUI.resolvedStyle.borderRight.size) borderSizeL = val(THIS_ElementUI.resolvedStyle.borderLeft.size) finalX = THIS_ElementUI.resolvedStyle._finalX finalY = THIS_ElementUI.resolvedStyle._finalY finalW = THIS_ElementUI.resolvedStyle._finalW finalH = THIS_ElementUI.resolvedStyle._finalH contentX = THIS_ElementUI.resolvedStyle._innerX contentY = THIS_ElementUI.resolvedStyle._innerY contentW = THIS_ElementUI.resolvedStyle._innerW contentH = THIS_ElementUI.resolvedStyle._innerH //draw element background if THIS_ElementUI.resolvedStyle.backgroundOpacity > 0 //TODO: overflow and repeat, for now just visible/no-repeat if THIS_ElementUI.resolvedStyle.backgroundImage = "" tImgFile as string tImgFile = Media_makeColorImage(finalW, finalH, THIS_ElementUI.resolvedStyle.backgroundColor, THIS_ElementUI.resolvedStyle.backgroundColor, THIS_ElementUI.resolvedStyle.backgroundColor, THIS_ElementUI.resolvedStyle.backgroundColor, TRUE) UI_element_setStyleProp(i_UI_elementList, "background-image", tImgFile) THIS_ElementUI.resolvedStyle.backgroundImage = tImgFile endif tImgNum = Media_getImageNumber(THIS_ElementUI.resolvedStyle.backgroundImage, 1.0, 1.0) if not GetSpriteExists(i_UI_elementList) CreateSprite(i_UI_elementList, tImgNum) endif SetSpriteImage(i_UI_elementList, tImgNum) SetSpriteScale(i_UI_elementList, contentW / GetImageWidth(tImgNum), contentH / GetImageHeight(tImgNum)) SetSpritePosition(i_UI_elementList, contentX, contentY) SetSpriteColorAlpha(i_UI_elementList, (THIS_ElementUI.resolvedStyle.backgroundOpacity * 0.01 * 255)) SetSpriteDepth(i_UI_elementList, THIS_ElementUI.resolvedStyle.zIndex) SetSpriteAngle(i_UI_elementList, THIS_ElementUI.resolvedStyle.rotation) endif //draw borders //TODO: use sprite, apply backgroundOpacity if borderSizeT > 0 then DrawBox( finalX, finalY, (finalX + finalW), (finalY + borderSizeT), THIS_ElementUI.resolvedStyle.borderTop.color, THIS_ElementUI.resolvedStyle.borderTop.color, THIS_ElementUI.resolvedStyle.borderTop.color, THIS_ElementUI.resolvedStyle.borderTop.color, TRUE ) if borderSizeB > 0 then DrawBox( finalX, (finalY + finalH - borderSizeB), (finalX + finalW), (finalY + finalH), THIS_ElementUI.resolvedStyle.borderBottom.color, THIS_ElementUI.resolvedStyle.borderBottom.color, THIS_ElementUI.resolvedStyle.borderBottom.color, THIS_ElementUI.resolvedStyle.borderBottom.color, TRUE ) if borderSizeR > 0 then DrawBox( (finalX + finalW - borderSizeR), (finalY + borderSizeT), (finalX + finalW), (finalY + finalH - borderSizeB), THIS_ElementUI.resolvedStyle.borderRight.color, THIS_ElementUI.resolvedStyle.borderRight.color, THIS_ElementUI.resolvedStyle.borderRight.color, THIS_ElementUI.resolvedStyle.borderRight.color, TRUE) if borderSizeL > 0 then DrawBox( finalX, (finalY + borderSizeT), (finalX + borderSizeL), (finalY + finalH - borderSizeB), THIS_ElementUI.resolvedStyle.borderLeft.color, THIS_ElementUI.resolvedStyle.borderLeft.color, THIS_ElementUI.resolvedStyle.borderLeft.color, THIS_ElementUI.resolvedStyle.borderLeft.color, TRUE) endif //draw text if THIS_ElementUI.value > "" System_log("ui.agc", 1, "ui", " renderUI: " + THIS_ElementUI.id + " is rendering text") if not getTextExists(i_UI_elementList) createText(i_UI_elementList, THIS_ElementUI.value) endif SetTextString(i_UI_elementList, THIS_ElementUI.value) SetTextMaxWidth(i_UI_elementList, contentW) SetTextSize(i_UI_elementList, THIS_ElementUI.resolvedStyle.fontSize) SetTextColor(i_UI_elementList, GetColorRed(THIS_ElementUI.resolvedStyle.color), GetColorGreen(THIS_ElementUI.resolvedStyle.color), GetColorBlue(THIS_ElementUI.resolvedStyle.color), (THIS_ElementUI.resolvedStyle.opacity * 0.01 * 255)) SetTextDepth(i_UI_elementList, (THIS_ElementUI.resolvedStyle.zIndex - 1)) textPosH = 0 textPosV = 0 select THIS_ElementUI.resolvedStyle.textAlignH case "left": SetTextAlignment(i_UI_elementList, 0) textPosH = finalX endcase case "center": SetTextAlignment(i_UI_elementList, 1) textPosH = finalX + (finalW * 0.5) endcase case "right" : SetTextAlignment(i_UI_elementList, 2) textPosH = finalX + finalW endcase endselect select THIS_ElementUI.resolvedStyle.textAlignV case "top": textPosV = finalY endcase case "center": textPosV = finalY + (finalH * 0.5) - (GetTextTotalHeight(i_UI_elementList) * 0.5) endcase case "bottom": textPosV = finalY + finalH - GetTextTotalHeight(i_UI_elementList) endcase endselect SetTextPosition(i_UI_elementList, textPosH, textPosV) SetTextAngle(i_UI_elementList, (THIS_ElementUI.resolvedStyle.rotation)) //TODO: inline links and style changes (span color/italic/bold etc) endif endif if THIS_ElementUI.isDirty System_log("ui.agc", 1, "ui", " renderUI: " + THIS_ElementUI.id + " was dirty now clean.") THIS_ElementUI.isDirty = FALSE inc dirtyCount endif next i_UI_elementList endTime = GetMilliseconds() System_log("ui.agc", 3, "ui", "UI update Render: " + str(endTime - startTime) + "ms : processed " + str(dirtyCount) + "/" + str(UI.elementList.length)) endfunction function UI_getInterfaceInput() if abs(System.timing.timer - UI.status.inputMark) > 200 UI.status.inputReady = TRUE else UI.status.inputReady = FALSE endif if System.timing.pauseHold && BIT_System_pauseHoldUI System.timing.pauseHold = System.timing.pauseHold ~~ BIT_System_pauseHoldUI endif if UI.elementList.length < 1 then exitfunction //check pause and input focus FOREACH_UI_elementList if i_UI_elementList = 0 then inc i_UI_elementList //skip root if THIS_ElementUI.resolvedStyle.display = "hidden" then inc i_UI_elementList if i_UI_elementList > UI.elementList.length then exitfunction if THIS_ElementUI.holdPause System.timing.pauseHold = System.timing.pauseHold || BIT_System_pauseHoldUI endif if THIS_ElementUI.holdMouseFocus UI.status.mouseMode = "ui" endif if THIS_ElementUI.holdKeyFocus UI.status.keyMode = "ui" endif if System.timing.pauseHold && BIT_System_pauseHoldUI if UI.status.mouseMode = "ui" and UI.status.keyMode = "ui" exit endif endif next i_UI_elementList if UI.status.mouseMode = "ui" SetRawMouseVisible(1) else SetRawMouseVisible(0) endif //check events if UI.status.inputReady FOREACH_UI_elementList if i_UI_elementList = 0 then inc i_UI_elementList //skip root //mouse events if UI.status.mouseMode = "ui" if THIS_ElementUI.resolvedStyle.display <> "hidden" if THIS_ElementUI.enableEvents = 1 or THIS_ElementUI.enableEvents = 3 or (THIS_ElementUI.enableEvents = 4 and UI.elementDrag.isActive) oldPressHold = THIS_ElementUI.pressIsHeld oldMouseOver = THIS_ElementUI.mouseIsOver THIS_ElementUI.pressIsHeld = FALSE THIS_ElementUI.mouseIsOver = FALSE //if this element is the actively dragging element, enforce mouseOver if UI.elementDrag.dragElementIndex = i_UI_elementList oldMouseOver = TRUE THIS_ElementUI.mouseIsOver = TRUE endif //detect mouseOver x1 = THIS_ElementUI.resolvedStyle._innerX x2 = x1 + THIS_ElementUI.resolvedStyle._innerW y1 = THIS_ElementUI.resolvedStyle._innerY y2 = y1 + THIS_ElementUI.resolvedStyle._innerH if Math2d_isPointInBox(System.mouse.posX, System.mouse.posY, x1, y1, x2, y2) //mouse is within the element THIS_ElementUI.mouseIsOver = TRUE if oldMouseOver = FALSE //new mouseIn if THIS_ElementUI.onMouseIn <> "" App_callFunction(THIS_ElementUI.onMouseIn, str(i_UI_elementList)) exitfunction endif endif //handle press if GetBit(1, System.input[ENUM_KEY_MOUSEL]) THIS_ElementUI.pressIsHeld = TRUE if oldPressHold = FALSE //new press UI.status.inputMark = System.timing.timer if THIS_ElementUI.onPress <> "" App_callFunction(THIS_ElementUI.onPress, str(i_UI_elementList)) exitfunction endif endif else if oldPressHold = TRUE //new release if THIS_ElementUI.onRelease <> "" App_callFunction(THIS_ElementUI.onRelease, str(i_UI_elementList)) exitfunction endif endif endif endif //detect mouseOut if oldMouseOver = TRUE and THIS_ElementUI.mouseIsOver = FALSE if THIS_ElementUI.onMouseOut <> "" App_callFunction(THIS_ElementUI.onMouseOut, str(i_UI_elementList)) exitfunction endif endif endif else //element is hidden, if mouse was over, trigger mouseOut if THIS_ElementUI.mouseIsOver THIS_ElementUI.mouseIsOver = FALSE THIS_ElementUI.pressIsHeld = FALSE if THIS_ElementUI.onMouseOut <> "" App_callFunction(THIS_ElementUI.onMouseOut, str(i_UI_elementList)) exitfunction endif endif endif else //mouse is bound to gameplay, if mouse was over, trigger mouse out if THIS_ElementUI.mouseIsOver THIS_ElementUI.mouseIsOver = FALSE THIS_ElementUI.pressIsHeld = FALSE if THIS_ElementUI.onMouseOut <> "" App_callFunction(THIS_ElementUI.onMouseOut, str(i_UI_elementList)) exitfunction endif endif endif //key events if UI.status.keyMode = "ui" //STUB: //this handles things like entering text into a chatbox where keys should not trigger regular ui events or character control //this would include such events as enter key to finalize an input, escape to cancel an input etc //alphanumerics go to entry buffer, and buffer content will be applied to the active element's value. else //check keybinds if THIS_ElementUI.enableEvents = 2 or THIS_ElementUI.enableEvents = 3 oldPressHold = THIS_ElementUI.pressIsHeld THIS_ElementUI.pressIsHeld = FALSE if THIS_ElementUI.keyBind > 0 if GetBit(1, System.input[ENUM_KEY_MOUSEL]) THIS_ElementUI.pressIsHeld = TRUE if oldPressHold = FALSE //new press if THIS_ElementUI.onPress <> "" App_callFunction(THIS_ElementUI.onPress, str(i_UI_elementList)) exitfunction endif endif else if oldPressHold = TRUE //new release if THIS_ElementUI.onRelease <> "" App_callFunction(THIS_ElementUI.onRelease, str(i_UI_elementList)) exitfunction endif endif endif endif endif endif next i_UI_elementList endif endfunction function UI_updateTransitions() GCcount = 0 GCindex = -1 tElapsed as float tInit as float tTarget as float tVal as float for i = 0 to UI.transitionList.length tElapsed = System.timing.timer - UI.transitionList[i].start * 1.0 if FindString(UI.transitionList[i].initVal, "px") tInit = val(left(UI.transitionList[i].initVal, len(UI.transitionList[i].initVal) - 2)) else if FindString(UI.transitionList[i].initVal, "%") tInit = val(left(UI.transitionList[i].initVal, len(UI.transitionList[i].initVal) - 1)) else tInit = val(UI.transitionList[i].initVal) endif endif if FindString(UI.transitionList[i].targetVal, "px") tTarget = val(left(UI.transitionList[i].targetVal, len(UI.transitionList[i].targetVal) - 2)) else if FindString(UI.transitionList[i].targetVal, "%") tTarget = val(left(UI.transitionList[i].targetVal, len(UI.transitionList[i].targetVal) - 1)) else tTarget = val(UI.transitionList[i].targetVal) endif endif if tElapsed < UI.transitionList[i].duration tVal = tInit + (((tTarget - tInit) / UI.transitionList[i].duration) * tElapsed) UI_element_setStyleProp(UI.transitionList[i].elementIndex, UI.transitionList[i].prop, str(tVal)) if tTarget > tInit if tVal >= tTarget if UI.transitionList[i].callback > "" App_callFunction(UI.transitionList[i].callback, str(UI.transitionList[i].elementIndex)) endif UI.transitionList[i].elementIndex = -1 inc GCcount GCindex = i endif else if tVal <= tTarget if UI.transitionList[i].callback > "" App_callFunction(UI.transitionList[i].callback, str(UI.transitionList[i].elementIndex)) endif UI.transitionList[i].elementIndex = -1 inc GCcount GCindex = i endif endif else UI_element_setStyleProp(UI.transitionList[i].elementIndex, UI.transitionList[i].prop, UI.transitionList[i].targetVal) if UI.transitionList[i].callback > "" App_callFunction(UI.transitionList[i].callback, str(UI.transitionList[i].elementIndex)) endif UI.transitionList[i].elementIndex = -1 inc GCcount GCindex = i endif next i if GCcount > 0 if GCcount > 1 for c = 1 to GCcount for i = 0 to UI.transitionList.length if UI.transitionList[i].elementIndex = -1 UI.transitionList.remove(i) exit endif next i next c else UI.transitionList.remove(i) endif endif endfunction function UI_fadeScreen(rR as integer, rG as integer, rB as integer, rA as integer, rTime as float) tSprite = CreateSprite(0) SetSpriteTransparency(tSprite, 1) SetSpriteSize(tSprite, App.config.screenWidth, App.config.screenHeight) fadeLoading as float tMark = GetMilliseconds() if rA > 0 SetSpriteColor(tSprite, rR, rG, rB, 0) fadeLoading = 0.0 while fadeLoading < 255.0 //UI_updatePageFlow() fadeLoading = 0.0 + ((255.0 / rTime) * abs(GetMilliseconds() - tMark)) SetSpriteColorAlpha(tSprite, fadeLoading) if fadeLoading >= 255.0 exit endif sync() endwhile else SetSpriteColor(tSprite, rR, rG, rB, 255) fadeLoading = 255.0 while fadeLoading > 0.0 //UI_updatePageFlow() fadeLoading = 255.0 - ((255.0 / rTime) * abs(GetMilliseconds() - tMark)) SetSpriteColorAlpha(tSprite, fadeLoading) if fadeLoading <= 0.0 exit endif sync() endwhile endif DeleteSprite(tSprite) endfunction function UI_parseSizeData(rData as string) lastChar as string if rData = "" rData = "0px" endif lastChar = right(rData, 1) if lastChar = "%" UI.parsedSizeData.isPercent = TRUE UI.parsedSizeData.value = val(left(rData, len(rData) - 1)) else if lastChar = "x" UI.parsedSizeData.isPercent = FALSE UI.parsedSizeData.value = val(left(rData, len(rData) - 2)) else UI.parsedSizeData.isPercent = FALSE UI.parsedSizeData.value = val(rData) endif endif endfunction function UI_elementList_resetResolvedStyleProps() UI.elementList[0].isDirty = FALSE FOREACH_UI_elementList if UI.elementList[THIS_ElementUI.parent].isDirty THIS_ElementUI.isDirty = TRUE System_log("ui.agc", 1, "ui", " resetResolved: parent " + THIS_ElementUI.parentID + " is dirty, set this " + THIS_ElementUI.id + " to dirty.") endif if THIS_ElementUI.isDirty System_log("ui.agc", 1, "ui", " resetResolved: " + THIS_ElementUI.id + " is dirty, reset props to default") THIS_ElementUI.resolvedStyle.positionAlignH = UI.styleProp.defaults.positionAlignH THIS_ElementUI.resolvedStyle.positionAlignV = UI.styleProp.defaults.positionAlignV THIS_ElementUI.resolvedStyle.position = UI.styleProp.defaults.position THIS_ElementUI.resolvedStyle.top = UI.styleProp.defaults.top THIS_ElementUI.resolvedStyle.left = UI.styleProp.defaults.left THIS_ElementUI.resolvedStyle.paddingTop = UI.styleProp.defaults.paddingTop THIS_ElementUI.resolvedStyle.paddingBottom = UI.styleProp.defaults.paddingBottom THIS_ElementUI.resolvedStyle.paddingLeft = UI.styleProp.defaults.paddingLeft THIS_ElementUI.resolvedStyle.paddingRight = UI.styleProp.defaults.paddingRight THIS_ElementUI.resolvedStyle.width = UI.styleProp.defaults.width THIS_ElementUI.resolvedStyle.height = UI.styleProp.defaults.height THIS_ElementUI.resolvedStyle.borderTop.size = UI.styleProp.defaults.borderTop.size THIS_ElementUI.resolvedStyle.borderTop.color = UI.styleProp.defaults.borderTop.color THIS_ElementUI.resolvedStyle.borderBottom.size = UI.styleProp.defaults.borderBottom.size THIS_ElementUI.resolvedStyle.borderBottom.color = UI.styleProp.defaults.borderBottom.color THIS_ElementUI.resolvedStyle.borderRight.size = UI.styleProp.defaults.borderRight.size THIS_ElementUI.resolvedStyle.borderRight.color = UI.styleProp.defaults.borderRight.color THIS_ElementUI.resolvedStyle.borderLeft.size = UI.styleProp.defaults.borderLeft.size THIS_ElementUI.resolvedStyle.borderLeft.color = UI.styleProp.defaults.borderLeft.color //THIS_ElementUI.resolvedStyle. = //UI.styleProp.defaults.borderImage as UI_type_imageData THIS_ElementUI.resolvedStyle.marginTop = UI.styleProp.defaults.marginTop THIS_ElementUI.resolvedStyle.marginBottom = UI.styleProp.defaults.marginBottom THIS_ElementUI.resolvedStyle.marginRight = UI.styleProp.defaults.marginRight THIS_ElementUI.resolvedStyle.marginLeft = UI.styleProp.defaults.marginLeft THIS_ElementUI.resolvedStyle.minWidth = UI.styleProp.defaults.minWidth THIS_ElementUI.resolvedStyle.maxWidth = UI.styleProp.defaults.maxWidth THIS_ElementUI.resolvedStyle.minHeight = UI.styleProp.defaults.minHeight THIS_ElementUI.resolvedStyle.maxHeight = UI.styleProp.defaults.maxHeight THIS_ElementUI.resolvedStyle.backgroundColor = UI.styleProp.defaults.backgroundColor THIS_ElementUI.resolvedStyle.backgroundOpacity = UI.styleProp.defaults.backgroundOpacity THIS_ElementUI.resolvedStyle.backgroundImage = UI.styleProp.defaults.backgroundImage THIS_ElementUI.resolvedStyle.backgroundRepeat = UI.styleProp.defaults.backgroundRepeat THIS_ElementUI.resolvedStyle.backgroundAlignH = UI.styleProp.defaults.backgroundAlignH THIS_ElementUI.resolvedStyle.backgroundAlignV = UI.styleProp.defaults.backgroundAlignV THIS_ElementUI.resolvedStyle.display = UI.styleProp.defaults.display THIS_ElementUI.resolvedStyle.opacity = UI.styleProp.defaults.opacity THIS_ElementUI.resolvedStyle.zIndex = UI.styleProp.defaults.zIndex THIS_ElementUI.resolvedStyle.cursor = UI.styleProp.defaults.cursor THIS_ElementUI.resolvedStyle.color = UI.styleProp.defaults.color THIS_ElementUI.resolvedStyle.font = UI.styleProp.defaults.font THIS_ElementUI.resolvedStyle.fontSize = UI.styleProp.defaults.fontSize THIS_ElementUI.resolvedStyle.textDecoration = UI.styleProp.defaults.textDecoration THIS_ElementUI.resolvedStyle.textTransform = UI.styleProp.defaults.textTransform THIS_ElementUI.resolvedStyle.textIndent = UI.styleProp.defaults.textIndent THIS_ElementUI.resolvedStyle.textAlignH = UI.styleProp.defaults.textAlignH THIS_ElementUI.resolvedStyle.textAlignV = UI.styleProp.defaults.textAlignV THIS_ElementUI.resolvedStyle.rotation = UI.styleProp.defaults.rotation THIS_ElementUI.resolvedStyle._isResolved = FALSE endif next i_UI_elementList `root element is always = app window dimensions, this provides context for all child % UI.elementList[0].resolvedStyle.width = str(App.config.screenWidth) UI.elementList[0].resolvedStyle.height = str(App.config.screenHeight) UI.elementList[0].resolvedStyle._finalX = 0 UI.elementList[0].resolvedStyle._finalY = 0 UI.elementList[0].resolvedStyle._finalW = App.config.screenWidth UI.elementList[0].resolvedStyle._finalH = App.config.screenHeight UI.elementList[0].resolvedStyle._innerX = 0 UI.elementList[0].resolvedStyle._innerY = 0 UI.elementList[0].resolvedStyle._innerW = App.config.screenWidth UI.elementList[0].resolvedStyle._innerH = App.config.screenHeight UI.elementList[0].resolvedStyle._isResolved = TRUE endfunction function UI_elementList_applyInheritedStyleProps(i_UI_elementList as integer, rParentIndex as integer) THIS_ElementUI.resolvedStyle.display = UI.elementList[rParentIndex].resolvedStyle.display THIS_ElementUI.resolvedStyle.opacity = UI.elementList[rParentIndex].resolvedStyle.opacity THIS_ElementUI.resolvedStyle.zIndex = UI.elementList[rParentIndex].resolvedStyle.zIndex THIS_ElementUI.resolvedStyle.cursor = UI.elementList[rParentIndex].resolvedStyle.cursor THIS_ElementUI.resolvedStyle.color = UI.elementList[rParentIndex].resolvedStyle.color THIS_ElementUI.resolvedStyle.font = UI.elementList[rParentIndex].resolvedStyle.font THIS_ElementUI.resolvedStyle.fontSize = UI.elementList[rParentIndex].resolvedStyle.fontSize THIS_ElementUI.resolvedStyle.textDecoration = UI.elementList[rParentIndex].resolvedStyle.textDecoration THIS_ElementUI.resolvedStyle.textTransform = UI.elementList[rParentIndex].resolvedStyle.textTransform THIS_ElementUI.resolvedStyle.textIndent = UI.elementList[rParentIndex].resolvedStyle.textIndent THIS_ElementUI.resolvedStyle.textAlignH = UI.elementList[rParentIndex].resolvedStyle.textAlignH THIS_ElementUI.resolvedStyle.textAlignV = UI.elementList[rParentIndex].resolvedStyle.textAlignV THIS_ElementUI.resolvedStyle.rotation = UI.elementList[rParentIndex].resolvedStyle.rotation endfunction function UI_elementList_applyClassStyleProps(i_UI_elementList as integer, i_UI_styleClassList as integer) System_log("ui.agc", 1, "ui", "resolve styleClassProps for " + THIS_ElementUI.id + " parent " + str(THIS_ElementUI.parent) + " style " + str(i_UI_styleClassList) + " " + THIS_StyleClass.className + " " + THIS_StyleClass.style.width + ", " + THIS_StyleClass.style.height) //flow properties: if BIT_UI_StyleProp_positionAlignH && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.positionAlignH = THIS_StyleClass.style.positionAlignH endif if BIT_UI_StyleProp_positionAlignV && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.positionAlignV = THIS_StyleClass.style.positionAlignV endif if BIT_UI_StyleProp_position && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.position = THIS_StyleClass.style.position endif if BIT_UI_StyleProp_top && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.top = THIS_StyleClass.style.top endif if BIT_UI_StyleProp_left && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.left = THIS_StyleClass.style.left endif if BIT_UI_StyleProp_paddingTop && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingTop = THIS_StyleClass.style.paddingTop endif if BIT_UI_StyleProp_paddingBottom && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingBottom = THIS_StyleClass.style.paddingBottom endif if BIT_UI_StyleProp_paddingLeft && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingLeft = THIS_StyleClass.style.paddingLeft endif if BIT_UI_StyleProp_paddingRight && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingRight = THIS_StyleClass.style.paddingRight endif if BIT_UI_StyleProp_width && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.width = THIS_StyleClass.style.width endif if BIT_UI_StyleProp_height && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.height = THIS_StyleClass.style.height endif if BIT_UI_StyleProp_borderTop && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderTop.size = THIS_StyleClass.style.borderTop.size THIS_ElementUI.resolvedStyle.borderTop.color = THIS_StyleClass.style.borderTop.color endif if BIT_UI_StyleProp_borderBottom && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderBottom.size = THIS_StyleClass.style.borderBottom.size THIS_ElementUI.resolvedStyle.borderBottom.color = THIS_StyleClass.style.borderBottom.color endif if BIT_UI_StyleProp_borderLeft && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderLeft.size = THIS_StyleClass.style.borderLeft.size THIS_ElementUI.resolvedStyle.borderLeft.color = THIS_StyleClass.style.borderLeft.color endif if BIT_UI_StyleProp_borderRight && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderRight.size = THIS_StyleClass.style.borderRight.size THIS_ElementUI.resolvedStyle.borderRight.color = THIS_StyleClass.style.borderRight.color endif /* if BIT_UI_StyleProp_borderImage && THIS_StyleClass.style._flowPropertyEnabled endif */ if BIT_UI_StyleProp_marginTop && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginTop = THIS_StyleClass.style.marginTop endif if BIT_UI_StyleProp_marginBottom && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginBottom = THIS_StyleClass.style.marginBottom endif if BIT_UI_StyleProp_marginLeft && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginLeft = THIS_StyleClass.style.marginLeft endif if BIT_UI_StyleProp_marginRight && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginRight = THIS_StyleClass.style.marginRight endif if BIT_UI_StyleProp_minWidth && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.minWidth = THIS_StyleClass.style.minWidth endif if BIT_UI_StyleProp_maxWidth && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.maxWidth = THIS_StyleClass.style.maxWidth endif if BIT_UI_StyleProp_minHeight && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.minHeight = THIS_StyleClass.style.minHeight endif if BIT_UI_StyleProp_maxHeight && THIS_StyleClass.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.maxHeight = THIS_StyleClass.style.maxHeight endif //visual properties: if BIT_UI_StyleProp_backgroundColor && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundColor = THIS_StyleClass.style.backgroundColor endif if BIT_UI_StyleProp_backgroundOpacity && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundOpacity = THIS_StyleClass.style.backgroundOpacity endif if BIT_UI_StyleProp_backgroundImage && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundImage = THIS_StyleClass.style.backgroundImage endif if BIT_UI_StyleProp_backgroundRepeat && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundRepeat = THIS_StyleClass.style.backgroundRepeat endif if BIT_UI_StyleProp_backgroundAlignH && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundAlignH = THIS_StyleClass.style.backgroundAlignH endif if BIT_UI_StyleProp_backgroundAlignV && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundAlignV = THIS_StyleClass.style.backgroundAlignV endif if BIT_UI_StyleProp_display && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.display = THIS_StyleClass.style.display endif if BIT_UI_StyleProp_opacity && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.opacity = THIS_StyleClass.style.opacity endif if BIT_UI_StyleProp_zIndex && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.zIndex = THIS_StyleClass.style.zIndex endif if BIT_UI_StyleProp_cursor && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.cursor = THIS_StyleClass.style.cursor endif if BIT_UI_StyleProp_color && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.color = THIS_StyleClass.style.color endif if BIT_UI_StyleProp_font && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.font = THIS_StyleClass.style.font endif if BIT_UI_StyleProp_fontSize && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.fontSize = THIS_StyleClass.style.fontSize endif if BIT_UI_StyleProp_textDecoration && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textDecoration = THIS_StyleClass.style.textDecoration endif if BIT_UI_StyleProp_textTransform && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textTransform = THIS_StyleClass.style.textTransform endif if BIT_UI_StyleProp_textIndent && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textIndent = THIS_StyleClass.style.textIndent endif if BIT_UI_StyleProp_textAlignH && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textAlignH = THIS_StyleClass.style.textAlignH endif if BIT_UI_StyleProp_textAlignV && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textAlignV = THIS_StyleClass.style.textAlignV endif if BIT_UI_StyleProp_rotation && THIS_StyleClass.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.rotation = THIS_StyleClass.style.rotation endif endfunction function UI_elementList_applyElementStyleProps(i_UI_elementList as integer) //flow properties: if BIT_UI_StyleProp_positionAlignH && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.positionAlignH = THIS_ElementUI.style.positionAlignH endif if BIT_UI_StyleProp_positionAlignV && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.positionAlignV = THIS_ElementUI.style.positionAlignV endif if BIT_UI_StyleProp_position && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.position = THIS_ElementUI.style.position endif if BIT_UI_StyleProp_top && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.top = THIS_ElementUI.style.top endif if BIT_UI_StyleProp_left && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.left = THIS_ElementUI.style.left endif if BIT_UI_StyleProp_paddingTop && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingTop = THIS_ElementUI.style.paddingTop endif if BIT_UI_StyleProp_paddingBottom && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingBottom = THIS_ElementUI.style.paddingBottom endif if BIT_UI_StyleProp_paddingLeft && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingLeft = THIS_ElementUI.style.paddingLeft endif if BIT_UI_StyleProp_paddingRight && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.paddingRight = THIS_ElementUI.style.paddingRight endif if BIT_UI_StyleProp_width && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.width = THIS_ElementUI.style.width endif if BIT_UI_StyleProp_height && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.height = THIS_ElementUI.style.height endif if BIT_UI_StyleProp_borderTop && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderTop.size = THIS_ElementUI.style.borderTop.size THIS_ElementUI.resolvedStyle.borderTop.color = THIS_ElementUI.style.borderTop.color endif if BIT_UI_StyleProp_borderBottom && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderBottom.size = THIS_ElementUI.style.borderBottom.size THIS_ElementUI.resolvedStyle.borderBottom.color = THIS_ElementUI.style.borderBottom.color endif if BIT_UI_StyleProp_borderLeft && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderLeft.size = THIS_ElementUI.style.borderLeft.size THIS_ElementUI.resolvedStyle.borderLeft.color = THIS_ElementUI.style.borderLeft.color endif if BIT_UI_StyleProp_borderRight && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.borderRight.size = THIS_ElementUI.style.borderRight.size THIS_ElementUI.resolvedStyle.borderRight.color = THIS_ElementUI.style.borderRight.color endif /* if BIT_UI_StyleProp_borderImage && THIS_ElementUI.style._flowPropertyEnabled endif */ if BIT_UI_StyleProp_marginTop && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginTop = THIS_ElementUI.style.marginTop endif if BIT_UI_StyleProp_marginBottom && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginBottom = THIS_ElementUI.style.marginBottom endif if BIT_UI_StyleProp_marginLeft && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginLeft = THIS_ElementUI.style.marginLeft endif if BIT_UI_StyleProp_marginRight && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.marginRight = THIS_ElementUI.style.marginRight endif if BIT_UI_StyleProp_minWidth && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.minWidth = THIS_ElementUI.style.minWidth endif if BIT_UI_StyleProp_maxWidth && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.maxWidth = THIS_ElementUI.style.maxWidth endif if BIT_UI_StyleProp_minHeight && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.minHeight = THIS_ElementUI.style.minHeight endif if BIT_UI_StyleProp_maxHeight && THIS_ElementUI.style._flowPropertyEnabled THIS_ElementUI.resolvedStyle.maxHeight = THIS_ElementUI.style.maxHeight endif //visual properties: if BIT_UI_StyleProp_backgroundColor && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundColor = THIS_ElementUI.style.backgroundColor endif if BIT_UI_StyleProp_backgroundOpacity && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundOpacity = THIS_ElementUI.style.backgroundOpacity endif if BIT_UI_StyleProp_backgroundImage && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundImage = THIS_ElementUI.style.backgroundImage endif if BIT_UI_StyleProp_backgroundRepeat && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundRepeat = THIS_ElementUI.style.backgroundRepeat endif if BIT_UI_StyleProp_backgroundAlignH && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundAlignH = THIS_ElementUI.style.backgroundAlignH endif if BIT_UI_StyleProp_backgroundAlignV && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.backgroundAlignV = THIS_ElementUI.style.backgroundAlignV endif if BIT_UI_StyleProp_display && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.display = THIS_ElementUI.style.display endif if BIT_UI_StyleProp_opacity && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.opacity = THIS_ElementUI.style.opacity endif if BIT_UI_StyleProp_zIndex && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.zIndex = THIS_ElementUI.style.zIndex endif if BIT_UI_StyleProp_cursor && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.cursor = THIS_ElementUI.style.cursor endif if BIT_UI_StyleProp_color && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.color = THIS_ElementUI.style.color endif if BIT_UI_StyleProp_font && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.font = THIS_ElementUI.style.font endif if BIT_UI_StyleProp_fontSize && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.fontSize = THIS_ElementUI.style.fontSize endif if BIT_UI_StyleProp_textDecoration && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textDecoration = THIS_ElementUI.style.textDecoration endif if BIT_UI_StyleProp_textTransform && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textTransform = THIS_ElementUI.style.textTransform endif if BIT_UI_StyleProp_textIndent && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textIndent = THIS_ElementUI.style.textIndent endif if BIT_UI_StyleProp_textAlignH && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textAlignH = THIS_ElementUI.style.textAlignH endif if BIT_UI_StyleProp_textAlignV && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.textAlignV = THIS_ElementUI.style.textAlignV endif if BIT_UI_StyleProp_rotation && THIS_ElementUI.style._visualPropertyEnabled THIS_ElementUI.resolvedStyle.rotation = THIS_ElementUI.style.rotation endif endfunction function UI_elementList_resolveFlowValues(i_UI_elementList as integer, rParentIndex as integer) //if position: absolute; use root as parent if THIS_ElementUI.resolvedStyle.position = "absolute" rParentIndex = 0 endif //get parent values parentW = val(UI.elementList[rParentIndex].resolvedStyle.width) parentH = val(UI.elementList[rParentIndex].resolvedStyle.height) parentContentW = UI.elementList[rParentIndex].resolvedStyle._innerW parentContentH = UI.elementList[rParentIndex].resolvedStyle._innerH parentX = UI.elementList[rParentIndex].resolvedStyle._finalX parentY = UI.elementList[rParentIndex].resolvedStyle._finalY parentContentX = UI.elementList[rParentIndex].resolvedStyle._innerX parentContentY = UI.elementList[rParentIndex].resolvedStyle._innerY //get element values //width UI_parseSizeData(THIS_ElementUI.resolvedStyle.width) resolvedW = UI.parsedSizeData.value if left(THIS_ElementUI.resolvedStyle.minWidth, 1) <> "0" UI_parseSizeData(THIS_ElementUI.resolvedStyle.minWidth) minW = UI.parsedSizeData.value if resolvedW < minW then resolvedW = minW endif if left(THIS_ElementUI.resolvedStyle.maxWidth, 1) <> "0" UI_parseSizeData(THIS_ElementUI.resolvedStyle.maxWidth) maxW = UI.parsedSizeData.value if resolvedW > maxW then resolvedW = maxW endif resolvedContentW = resolvedW if UI.parsedSizeData.isPercent //remove parent padding from child final width if child width is % of parent //NOTE: when the parent was resolved, it's padding gets added to its width making the resolved width larger than its content width. // child % needs to look at the parents final content width. tFactor# = UI.parsedSizeData.value * 0.01 resolvedW = parentContentW * tFactor# resolvedContentW = resolvedW endif //height UI_parseSizeData(THIS_ElementUI.resolvedStyle.height) resolvedH = UI.parsedSizeData.value if left(THIS_ElementUI.resolvedStyle.minHeight, 1) <> "0" UI_parseSizeData(THIS_ElementUI.resolvedStyle.minHeight) minH = UI.parsedSizeData.value if resolvedH < minH then resolvedH = minH endif if left(THIS_ElementUI.resolvedStyle.maxHeight, 1) <> "0" UI_parseSizeData(THIS_ElementUI.resolvedStyle.maxHeight) maxH = UI.parsedSizeData.value if resolvedH > maxH then resolvedH = maxH endif resolvedContentH = resolvedH if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedH = parentContentH * tFactor# resolvedContentH = resolvedH endif //TODO: handle overflow: visible|hidden|scroll //padding UI_parseSizeData(THIS_ElementUI.resolvedStyle.paddingTop) resolvedPadT = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedPadT = parentContentH * tFactor# inc resolvedH, resolvedPadT endif UI_parseSizeData(THIS_ElementUI.resolvedStyle.paddingBottom) resolvedPadB = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedPadB = parentContentH * tFactor# inc resolvedH, resolvedPadB endif UI_parseSizeData(THIS_ElementUI.resolvedStyle.paddingRight) resolvedPadR = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedPadR = parentContentW * tFactor# inc resolvedW, resolvedPadR endif UI_parseSizeData(THIS_ElementUI.resolvedStyle.paddingLeft) resolvedPadL = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedPadL = parentContentW * tFactor# inc resolvedW, resolvedPadL endif //margin UI_parseSizeData(THIS_ElementUI.resolvedStyle.marginTop) resolvedMargT = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedMargT = parentContentH * tFactor# endif UI_parseSizeData(THIS_ElementUI.resolvedStyle.marginBottom) resolvedMargB = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedMargB = parentContentH * tFactor# endif UI_parseSizeData(THIS_ElementUI.resolvedStyle.marginRight) resolvedMargR = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedMargR = parentContentW * tFactor# endif UI_parseSizeData(THIS_ElementUI.resolvedStyle.marginLeft) resolvedMargL = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedMargL = parentContentW * tFactor# endif //border-width //NOTE: per css spec, border cannot be assigned as % UI_parseSizeData(THIS_ElementUI.resolvedStyle.borderTop.size) resolvedBorderT = UI.parsedSizeData.value UI_parseSizeData(THIS_ElementUI.resolvedStyle.borderBottom.size) resolvedBorderB = UI.parsedSizeData.value UI_parseSizeData(THIS_ElementUI.resolvedStyle.borderRight.size) resolvedBorderR = UI.parsedSizeData.value UI_parseSizeData(THIS_ElementUI.resolvedStyle.borderLeft.size) resolvedBorderL = UI.parsedSizeData.value //text-indent UI_parseSizeData(THIS_ElementUI.resolvedStyle.textIndent) resolvedTextIndent = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedTextIndent = parentContentW * tFactor# endif if UI.elementDrag.isActive and UI.elementDrag.dragElementIndex = i_UI_elementList resolvedTop = 0 resolvedLeft = 0 resolvedX = System.mouse.posX - UI.elementDrag.offsetX resolvedY = System.mouse.posY - UI.elementDrag.offsetY else //position offsets UI_parseSizeData(THIS_ElementUI.resolvedStyle.top) resolvedTop = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedTop = parentContentH * tFactor# endif UI_parseSizeData(THIS_ElementUI.resolvedStyle.left) resolvedLeft = UI.parsedSizeData.value if UI.parsedSizeData.isPercent tFactor# = UI.parsedSizeData.value * 0.01 resolvedLeft = parentContentW * tFactor# endif //final coordinates select THIS_ElementUI.resolvedStyle.positionAlignH case "left": resolvedX = parentContentX + resolvedMargL + resolvedBorderL + resolvedLeft endcase case "right": resolvedX = (parentContentX + parentContentW) - (resolvedMargR + resolvedW + resolvedBorderR) + resolvedLeft endcase case "center": resolvedX = (parentContentX + (parentContentW * 0.5)) - (resolvedMargR + (resolvedW * 0.5) + resolvedBorderR) + resolvedLeft endcase endselect select THIS_ElementUI.resolvedStyle.positionAlignV case "top": resolvedY = parentContentY + resolvedMargT + resolvedBorderT + resolvedTop endcase case "bottom": resolvedY = (parentContentY + parentContentH) - (resolvedMargB + resolvedH + resolvedBorderB) + resolvedTop endcase case "center": resolvedY = (parentContentY + (parentContentH * 0.5)) - (resolvedMargB + (resolvedH * 0.5) + resolvedBorderB) + resolvedTop endcase endselect endif //apply to resolvedStyle THIS_ElementUI.resolvedStyle.width = str(resolvedW) THIS_ElementUI.resolvedStyle.height = str(resolvedH) THIS_ElementUI.resolvedStyle.paddingTop = str(resolvedPadT) THIS_ElementUI.resolvedStyle.paddingBottom = str(resolvedPadB) THIS_ElementUI.resolvedStyle.paddingRight = str(resolvedPadR) THIS_ElementUI.resolvedStyle.paddingLeft = str(resolvedPadL) THIS_ElementUI.resolvedStyle.marginTop = str(resolvedMargT) THIS_ElementUI.resolvedStyle.marginBottom = str(resolvedMargB) THIS_ElementUI.resolvedStyle.marginRight = str(resolvedMargR) THIS_ElementUI.resolvedStyle.marginLeft = str(resolvedMargL) THIS_ElementUI.resolvedStyle.borderTop.size = str(resolvedBorderT) THIS_ElementUI.resolvedStyle.borderBottom.size = str(resolvedBorderB) THIS_ElementUI.resolvedStyle.borderRight.size = str(resolvedBorderR) THIS_ElementUI.resolvedStyle.borderLeft.size = str(resolvedBorderL) THIS_ElementUI.resolvedStyle.textIndent = str(resolvedTextIndent) THIS_ElementUI.resolvedStyle.top = str(resolvedTop) THIS_ElementUI.resolvedStyle.left = str(resolvedLeft) THIS_ElementUI.resolvedStyle._finalX = resolvedX THIS_ElementUI.resolvedStyle._finalY = resolvedY THIS_ElementUI.resolvedStyle._finalW = resolvedW THIS_ElementUI.resolvedStyle._finalH = resolvedH THIS_ElementUI.resolvedStyle._innerX = resolvedX + resolvedPadL THIS_ElementUI.resolvedStyle._innerY = resolvedY + resolvedPadT THIS_ElementUI.resolvedStyle._innerW = resolvedContentW THIS_ElementUI.resolvedStyle._innerH = resolvedContentH THIS_ElementUI.resolvedStyle._isResolved = TRUE //enforce hide if parent is hidden if UI.elementList[rParentIndex].resolvedStyle.display = "hidden" THIS_ElementUI.resolvedStyle.display = "hidden" endif if THIS_ElementUI.resolvedStyle.display = "hidden" if GetSpriteVisible(i_UI_elementList) SetSpriteVisible(i_UI_elementList, FALSE) endif if GetTextVisible(i_UI_elementList) SetTextVisible(i_UI_elementList, FALSE) endif else if GetSpriteVisible(i_UI_elementList) = FALSE SetSpriteVisible(i_UI_elementList, TRUE) endif if GetTextVisible(i_UI_elementList) = FALSE SetTextVisible(i_UI_elementList, TRUE) endif endif endfunction //Element Functions ==================================================================================================================================================== function ElementUI_init(tElement ref as CLASS_ElementUI) //set defaults tElement.styleClassIndex = -1 tElement.selectedIndex = -1 tElement.keyBind = -1 tElement.isDirty = TRUE UI.elementList[tElement.parent].isDirty = TRUE System_log("ui.agc", 1, "ui", " initialize element: set parent " + tElement.parentID + " to dirty, set this " + tElement.id + " to dirty.") tElement.style.positionAlignH = UI.styleProp.defaults.positionAlignH tElement.style.positionAlignV = UI.styleProp.defaults.positionAlignV tElement.style.position = UI.styleProp.defaults.position tElement.style.top = UI.styleProp.defaults.top tElement.style.left = UI.styleProp.defaults.left tElement.style.paddingTop = UI.styleProp.defaults.paddingTop tElement.style.paddingBottom = UI.styleProp.defaults.paddingBottom tElement.style.paddingLeft = UI.styleProp.defaults.paddingLeft tElement.style.paddingRight = UI.styleProp.defaults.paddingRight tElement.style.width = UI.styleProp.defaults.width tElement.style.height = UI.styleProp.defaults.height tElement.style.borderTop.size = UI.styleProp.defaults.borderTop.size tElement.style.borderTop.color = UI.styleProp.defaults.borderTop.color tElement.style.borderBottom.size = UI.styleProp.defaults.borderBottom.size tElement.style.borderBottom.color = UI.styleProp.defaults.borderBottom.color tElement.style.borderRight.size = UI.styleProp.defaults.borderRight.size tElement.style.borderRight.color = UI.styleProp.defaults.borderRight.color tElement.style.borderLeft.size = UI.styleProp.defaults.borderLeft.size tElement.style.borderLeft.color = UI.styleProp.defaults.borderLeft.color //style.borderImage as UI_type_imageData tElement.style.marginTop = UI.styleProp.defaults.marginTop tElement.style.marginBottom = UI.styleProp.defaults.marginBottom tElement.style.marginRight = UI.styleProp.defaults.marginRight tElement.style.marginLeft = UI.styleProp.defaults.marginLeft tElement.style.minWidth = UI.styleProp.defaults.minWidth tElement.style.maxWidth = UI.styleProp.defaults.maxWidth tElement.style.minHeight = UI.styleProp.defaults.minHeight tElement.style.maxHeight = UI.styleProp.defaults.maxHeight tElement.style.backgroundColor = UI.styleProp.defaults.backgroundColor tElement.style.backgroundOpacity = UI.styleProp.defaults.backgroundOpacity tElement.style.backgroundImage = UI.styleProp.defaults.backgroundImage tElement.style.backgroundRepeat = UI.styleProp.defaults.backgroundRepeat tElement.style.backgroundAlignH = UI.styleProp.defaults.backgroundAlignH tElement.style.backgroundAlignV = UI.styleProp.defaults.backgroundAlignV tElement.style.display = UI.styleProp.defaults.display tElement.style.opacity = UI.styleProp.defaults.opacity tElement.style.zIndex = UI.styleProp.defaults.zIndex tElement.style.cursor = UI.styleProp.defaults.cursor tElement.style.color = UI.styleProp.defaults.color tElement.style.font = UI.styleProp.defaults.font tElement.style.fontSize = UI.styleProp.defaults.fontSize tElement.style.textDecoration = UI.styleProp.defaults.textDecoration tElement.style.textTransform = UI.styleProp.defaults.textTransform tElement.style.textIndent = UI.styleProp.defaults.textIndent tElement.style.textAlignH = UI.styleProp.defaults.textAlignH tElement.style.textAlignV = UI.styleProp.defaults.textAlignV tElement.style.rotation = UI.styleProp.defaults.rotation endfunction function UI_setElementParent(rElement ref as CLASS_ElementUI, rParentID as string) if rParentID > "" FOREACH_UI_elementList if THIS_ElementUI.id = rParentID rElement.parent = i_UI_elementList rElement.parentID = rParentID rElement.isDirty = TRUE THIS_ElementUI.isDirty = TRUE System_log("ui.agc", 1, "ui", " set element parent: set parent " + THIS_ElementUI.id + " to dirty, set this " + rElement.id + " to dirty.") exit endif next i_UI_elementList endif endfunction function UI_addElement(rElement as CLASS_ElementUI, rParentID as string) res = -1 //append to parent UI_setElementParent(rElement, rParentID) //get styleClass index if rElement.styleClass > "" FOREACH_UI_styleClassList if THIS_StyleClass.className = rElement.styleClass rElement.styleClassIndex = i_UI_styleClassList exit endif next i_UI_styleClassList endif UI.elementList.insert(rElement) res = UI.elementList.length endfunction res function UI_cleanElementList() GCcount = 0 GCindex = -1 FOREACH_UI_elementList if THIS_ElementUI.id = "GC_THIS" inc GCcount GCindex = i_UI_elementList endif next i_UI_elementList if GCcount > 0 if GCcount > 1 for c = 1 to GCcount FOREACH_UI_elementList if THIS_ElementUI.id = "GC_THIS" UI.elementList.remove(i_UI_elementList) exit endif next i_UI_elementList next c else UI.elementList.remove(GCindex) endif endif //relink parent index references for tElementIndex = 1 to UI.elementList.length if UI.elementList[tElementIndex].parentID > "" FOREACH_UI_elementList if THIS_ElementUI.id = UI.elementList[tElementIndex].parentID UI.elementList[tElementIndex].parent = i_UI_elementList exit endif next i_UI_elementList else UI.elementList[tElementIndex].parent = 0 endif next tElementIndex endfunction function UI_removeElementByIndex(rElementIndex as integer) tElementID as string tElementID = UI.elementList[rElementIndex].id UI.elementList[rElementIndex].id = "GC_THIS" UI.elementList[rElementIndex].parentID = "GC_THIS" //recurse the children keepLooking = TRUE while keepLooking keepLooking = FALSE FOREACH_UI_elementList if THIS_ElementUI.parentID = tElementID keepLooking = TRUE UI_removeElementByIndex(i_UI_elementList) exit endif next i_UI_elementList endwhile UI_cleanElementList() endfunction function UI_getElementById(rID as string) res = -1 FOREACH_UI_elementList if THIS_ElementUI.id = rID res = i_UI_elementList exitfunction res endif next i_UI_elementList endfunction res function UI_getElementsByName(rName as string) UI.resultElements.length = -1 FOREACH_UI_elementList if THIS_ElementUI.name = rName UI.resultElements.insert(i_UI_elementList) endif next i_UI_elementList endfunction function UI_getElementsByTagName(rName as string) UI.resultElements.length = -1 FOREACH_UI_elementList if THIS_ElementUI.tag = rName UI.resultElements.insert(i_UI_elementList) endif next i_UI_elementList endfunction function UI_getElementsByClassName(rName as string) UI.resultElements.length = -1 FOREACH_UI_elementList if THIS_ElementUI.styleClass = rName UI.resultElements.insert(i_UI_elementList) endif next i_UI_elementList endfunction function UI_element_setStyleClass(rElementIndex as integer, rStyleClass as string) System_log("ui.agc", 1, "ui", "> set styleClass to element : GET styleClassIndex: " + rStyleClass) FOREACH_UI_styleClassList if THIS_StyleClass.className = rStyleClass UI.elementList[rElementIndex].styleClassIndex = i_UI_styleClassList UI.elementList[rElementIndex].styleClass = rStyleClass UI.elementList[rElementIndex].isDirty = TRUE UI.elementList[UI.elementList[rElementIndex].parent].isDirty = TRUE System_log("ui.agc", 1, "ui", " set style class: set parent " + UI.elementList[rElementIndex].parentID + " to dirty, set this " + UI.elementList[rElementIndex].id + " to dirty.") System_log("ui.agc", 1, "ui", " > Found styleClassIndex: " + rStyleClass + " " + str(i_UI_styleClassList) + " :: set to dirty") exitfunction endif next i_UI_styleClassList System_log("ui.agc", 1, "ui", " > Failed to find styleClassIndex: " + rStyleClass) endfunction function UI_element_hide(rElementIndex as string) //this is a callback helper for transitions UI_element_setStyleProp(val(rElementIndex), "display", "hidden") endfunction function UI_element_setStyleProp(i_UI_elementList as integer, rProp as string, rValue as string) THIS_ElementUI.isDirty = TRUE UI.elementList[THIS_ElementUI.parent].isDirty = TRUE System_log("ui.agc", 1, "ui", " set style prop: set parent " + THIS_ElementUI.parentID + " to dirty, set this " + THIS_ElementUI.id + " to dirty.") if FindString(rProp, "color") <> 0 rValue = str(ParseColor(rValue)) endif select rProp //flow properties: case "position-alignH": THIS_ElementUI.style.positionAlignH = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_positionAlignH endcase case "position-alignV": THIS_ElementUI.style.positionAlignV = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_positionAlignV endcase case "position": THIS_ElementUI.style.position = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_position endcase case "top": THIS_ElementUI.style.top = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_top endcase case "left": THIS_ElementUI.style.left = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_left endcase case "padding": THIS_ElementUI.style.paddingTop = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingTop THIS_ElementUI.style.paddingBottom = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingBottom THIS_ElementUI.style.paddingLeft = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingLeft THIS_ElementUI.style.paddingRight = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingRight endcase case "padding-top": THIS_ElementUI.style.paddingTop = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingTop endcase case "padding-bottom": THIS_ElementUI.style.paddingBottom = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingBottom endcase case "padding-left": THIS_ElementUI.style.paddingLeft = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingLeft endcase case "padding-right": THIS_ElementUI.style.paddingRight = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingRight endcase case "width": THIS_ElementUI.style.width = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_width endcase case "height": THIS_ElementUI.style.height = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_height endcase case "border-width": THIS_ElementUI.style.borderTop.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop THIS_ElementUI.style.borderBottom.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom THIS_ElementUI.style.borderLeft.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft THIS_ElementUI.style.borderRight.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase case "border-top-width": THIS_ElementUI.style.borderTop.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop endcase case "border-bottom-width": THIS_ElementUI.style.borderBottom.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom endcase case "border-left-width": THIS_ElementUI.style.borderLeft.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft endcase case "border-right-width": THIS_ElementUI.style.borderRight.size = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase case "border-color": THIS_ElementUI.style.borderTop.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop THIS_ElementUI.style.borderBottom.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom THIS_ElementUI.style.borderLeft.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft THIS_ElementUI.style.borderRight.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase case "border-top-color": THIS_ElementUI.style.borderTop.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop endcase case "border-bottom-color": THIS_ElementUI.style.borderBottom.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom endcase case "border-left-color": THIS_ElementUI.style.borderLeft.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft endcase case "border-right-color": THIS_ElementUI.style.borderRight.color = val(rValue) THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase //TODO: border image case "margin": THIS_ElementUI.style.marginTop = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginTop THIS_ElementUI.style.marginBottom = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginBottom THIS_ElementUI.style.marginLeft = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginLeft THIS_ElementUI.style.marginRight = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginRight endcase case "margin-top": THIS_ElementUI.style.marginTop = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginTop endcase case "margin-bottom": THIS_ElementUI.style.marginBottom = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginBottom endcase case "margin-left": THIS_ElementUI.style.marginLeft = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginLeft endcase case "margin-right": THIS_ElementUI.style.marginRight = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_marginRight endcase case "min-width": THIS_ElementUI.style.minWidth = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_minWidth endcase case "max-width": THIS_ElementUI.style.maxWidth = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_maxWidth endcase case "min-height": THIS_ElementUI.style.minHeight = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_minHeight endcase case "max-height": THIS_ElementUI.style.maxHeight = rValue THIS_ElementUI.style._flowPropertyEnabled = THIS_ElementUI.style._flowPropertyEnabled || BIT_UI_StyleProp_maxHeight endcase //visual properties: case "background-color": THIS_ElementUI.style.backgroundColor = val(rValue) THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundColor endcase case "background-opacity": THIS_ElementUI.style.backgroundOpacity = val(rValue) THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundOpacity endcase case "background-image": THIS_ElementUI.style.backgroundImage = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundImage if BIT_UI_StyleProp_backgroundOpacity && THIS_ElementUI.style._visualPropertyEnabled = FALSE THIS_ElementUI.style.backgroundOpacity = 100 THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundOpacity endif /* if GetSpriteExists(i_UI_elementList) tImgNum = Media_getImageNumber(rValue, 1.0, 1.0) SetSpriteScale(i_UI_elementList, THIS_ElementUI.resolvedStyle._innerW / GetImageWidth(tImgNum), THIS_ElementUI.resolvedStyle._innerH / GetImageHeight(tImgNum)) endif */ endcase case "background-repeat": THIS_ElementUI.style.backgroundRepeat = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundRepeat endcase case "background-alignH": THIS_ElementUI.style.backgroundAlignH = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundAlignH endcase case "background-alignV": THIS_ElementUI.style.backgroundAlignV = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundAlignV endcase case "display": THIS_ElementUI.style.display = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_display endcase case "opacity": THIS_ElementUI.style.opacity = val(rValue) THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_opacity endcase case "z-index": THIS_ElementUI.style.zIndex = val(rValue) THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_zIndex endcase case "cursor": THIS_ElementUI.style.cursor = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_cursor endcase case "color": THIS_ElementUI.style.color = val(rValue) THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_color endcase case "font": THIS_ElementUI.style.font = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_font endcase case "font-size": THIS_ElementUI.style.fontSize = val(rValue) THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_fontSize endcase case "text-decoration": THIS_ElementUI.style.textDecoration = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_textDecoration endcase case "text-transform": THIS_ElementUI.style.textTransform = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_textTransform endcase case "text-indent": THIS_ElementUI.style.textIndent = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_textIndent endcase case "text-alignH": THIS_ElementUI.style.textAlignH = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_textAlignH endcase case "text-alignV": THIS_ElementUI.style.textAlignV = rValue THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_textAlignV endcase case "rotation": THIS_ElementUI.style.rotation = val(rValue) THIS_ElementUI.style._visualPropertyEnabled = THIS_ElementUI.style._visualPropertyEnabled || BIT_UI_StyleProp_rotation endcase endselect endfunction //Style Functions ==================================================================================================================================================== function UI_addStyleClass(rStyleClass as CLASS_StyleClassUI) UI.styleClassList.insert(rStyleClass) System_log("ui.agc", 1, "ui", " > added style class " + rStyleClass.className) endfunction UI.styleClassList.length function UI_getStyleClassByName(rName as string) res as integer res = -1 FOREACH_UI_styleClassList if THIS_StyleClass.className = rName res = i_UI_styleClassList exitfunction res endif next i_UI_styleClassList endfunction res function UI_StyleClass_setStyleProp(i_UI_styleClassList as integer, rProp as string, rValue as string) if FindString(rProp, "color") <> 0 rValue = str(ParseColor(rValue)) endif select rProp //flow properties case "position-alignH": THIS_StyleClass.style.positionAlignH = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_positionAlignH endcase case "position-alignV": THIS_StyleClass.style.positionAlignV = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_positionAlignV endcase case "position": THIS_StyleClass.style.position = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_position endcase case "top": THIS_StyleClass.style.top = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_top endcase case "left": THIS_StyleClass.style.left = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_left endcase case "padding": THIS_StyleClass.style.paddingTop = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingTop THIS_StyleClass.style.paddingBottom = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingBottom THIS_StyleClass.style.paddingLeft = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingLeft THIS_StyleClass.style.paddingRight = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingRight endcase case "padding-top": THIS_StyleClass.style.paddingTop = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingTop endcase case "padding-bottom": THIS_StyleClass.style.paddingBottom = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingBottom endcase case "padding-left": THIS_StyleClass.style.paddingLeft = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingLeft endcase case "padding-right": THIS_StyleClass.style.paddingRight = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_paddingRight endcase case "width": THIS_StyleClass.style.width = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_width endcase case "height": THIS_StyleClass.style.height = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_height endcase case "border-width": THIS_StyleClass.style.borderTop.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop THIS_StyleClass.style.borderBottom.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom THIS_StyleClass.style.borderLeft.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft THIS_StyleClass.style.borderRight.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase case "border-top-width": THIS_StyleClass.style.borderTop.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop endcase case "border-bottom-width": THIS_StyleClass.style.borderBottom.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom endcase case "border-left-width": THIS_StyleClass.style.borderLeft.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft endcase case "border-right-width": THIS_StyleClass.style.borderRight.size = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase case "border-color": THIS_StyleClass.style.borderTop.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop THIS_StyleClass.style.borderBottom.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom THIS_StyleClass.style.borderLeft.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft THIS_StyleClass.style.borderRight.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase case "border-top-color": THIS_StyleClass.style.borderTop.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderTop endcase case "border-bottom-color": THIS_StyleClass.style.borderBottom.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderBottom endcase case "border-left-color": THIS_StyleClass.style.borderLeft.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderLeft endcase case "border-right-color": THIS_StyleClass.style.borderRight.color = val(rValue) THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_borderRight endcase //TODO: border image case "margin": THIS_StyleClass.style.marginTop = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginTop THIS_StyleClass.style.marginBottom = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginBottom THIS_StyleClass.style.marginLeft = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginLeft THIS_StyleClass.style.marginRight = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginRight endcase case "margin-top": THIS_StyleClass.style.marginTop = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginTop endcase case "margin-bottom": THIS_StyleClass.style.marginBottom = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginBottom endcase case "margin-left": THIS_StyleClass.style.marginLeft = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginLeft endcase case "margin-right": THIS_StyleClass.style.marginRight = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_marginRight endcase case "min-width": THIS_StyleClass.style.minWidth = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_minWidth endcase case "max-width": THIS_StyleClass.style.maxWidth = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_maxWidth endcase case "min-height": THIS_StyleClass.style.minHeight = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_minHeight endcase case "max-height": THIS_StyleClass.style.maxHeight = rValue THIS_StyleClass.style._flowPropertyEnabled = THIS_StyleClass.style._flowPropertyEnabled || BIT_UI_StyleProp_maxHeight endcase //visual properties: case "background-color": THIS_StyleClass.style.backgroundColor = val(rValue) THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundColor endcase case "background-opacity": THIS_StyleClass.style.backgroundOpacity = val(rValue) THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundOpacity endcase case "background-image": THIS_StyleClass.style.backgroundImage = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundImage if BIT_UI_StyleProp_backgroundOpacity && THIS_StyleClass.style._visualPropertyEnabled = FALSE THIS_StyleClass.style.backgroundOpacity = 100 THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundOpacity endif /* TODO: we don't have any specific element here, we may need to not apply scale when changing the bg image, but instead check for a change when resolving during updates if GetSpriteExists(i_UI_elementList) tImgNum = Media_getImageNumber(rValue, 1.0, 1.0) SetSpriteScale(i_UI_elementList, THIS_ElementUI.resolvedStyle._innerW / GetImageWidth(tImgNum), THIS_ElementUI.resolvedStyle._innerH / GetImageHeight(tImgNum)) endif */ endcase case "background-repeat": THIS_StyleClass.style.backgroundRepeat = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundRepeat endcase case "background-alignH": THIS_StyleClass.style.backgroundAlignH = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundAlignH endcase case "background-alignV": THIS_StyleClass.style.backgroundAlignV = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_backgroundAlignV endcase case "display": THIS_StyleClass.style.display = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_display endcase case "opacity": THIS_StyleClass.style.opacity = val(rValue) THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_opacity endcase case "z-index": THIS_StyleClass.style.zIndex = val(rValue) THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_zIndex endcase case "cursor": THIS_StyleClass.style.cursor = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_cursor endcase case "color": THIS_StyleClass.style.color = val(rValue) THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_color endcase case "font": THIS_StyleClass.style.font = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_font endcase case "font-size": THIS_StyleClass.style.fontSize = val(rValue) THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_fontSize endcase case "text-decoration": THIS_StyleClass.style.textDecoration = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_textDecoration endcase case "text-transform": THIS_StyleClass.style.textTransform = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_textTransform endcase case "text-indent": THIS_StyleClass.style.textIndent = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_textIndent endcase case "text-alignH": THIS_StyleClass.style.textAlignH = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_textAlignH endcase case "text-alignV": THIS_StyleClass.style.textAlignV = rValue THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_textAlignV endcase case "rotation": THIS_StyleClass.style.rotation = val(rValue) THIS_StyleClass.style._visualPropertyEnabled = THIS_StyleClass.style._visualPropertyEnabled || BIT_UI_StyleProp_rotation endcase endselect endfunction