static cxInt cxEventSetView(lua_State *L) { CX_LUA_DEF_THIS(cxView); cxConstChars viewid = NULL; lua_getfield(L, 2, "view"); if(lua_isstring(L, -1)){ viewid = lua_tostring(L, -1); } lua_pop(L, 1); cxView pview = cxViewRootGet(this, viewid); CX_RETURN(pview == NULL, 0); lua_getfield(L, 2, "scale"); if(lua_isstring(L, -1)){ cxVec2f vscale = pview->scale; cxReadFloats(lua_tostring(L, -1), &vscale.x); cxViewSetScale(pview, vscale); } lua_pop(L, 1); lua_getfield(L, 2, "size"); if(lua_isstring(L, -1)){ cxSize2f vsize = pview->size; cxReadFloats(lua_tostring(L, -1), &vsize.w); cxViewSetSize(pview, vsize); } lua_pop(L, 1); lua_getfield(L, 2, "position"); if(lua_isstring(L, -1)){ cxVec2f vposition = pview->position; cxReadFloats(lua_tostring(L, -1), &vposition.x); cxViewSetPos(pview, vposition); } lua_pop(L, 1); lua_getfield(L, 2, "degress"); if(lua_isnumber(L, -1)){ cxViewSetDegrees(pview, lua_tonumber(L, -1)); } lua_pop(L, 1); lua_getfield(L, 2, "anchor"); if(lua_isstring(L, -1)){ cxVec2f vanchor = pview->anchor; cxReadFloats(lua_tostring(L, -1), &vanchor.x); cxViewSetAnchor(pview, vanchor); } lua_pop(L, 1); return 0; }
void cxViewReadAttr(cxReaderAttrInfo *info) { cxObjectReadAttr(info); cxView this = info->object; //fixscale cxViewSetFixScale(this, cxXMLReadVec2fAttr(info, "cxView.fixScale", this->fixscale)); //rect cxViewRootReadRectToView(info); //resize cxViewRootReadAutoResize(info); //cropping cxViewSetCropping(this,cxXMLReadBoolAttr(info, "cxView.cropping", this->isCropping)); //top cxViewSetTop(this, cxXMLReadBoolAttr(info, "cxView.hideTop", this->hideTop)); //anchor cxViewSetAnchor(this, cxXMLReadVec2fAttr(info, "cxView.anchor", this->anchor)); //scale cxViewSetScale(this, cxXMLReadVec2fAttr(info, "cxView.scale", this->scale)); //color cxColor4f color = cxXMLReadColor4fAttr(info, "cxView.color", this->color); cxViewSetColor(this, cxColor3fv(color.r, color.g, color.b)); cxViewSetAlpha(this, cxXMLReadFloatAttr(info, "cxView.alpha", color.a)); //visible cxViewSetVisible(this, cxXMLReadBoolAttr(info, "cxView.visible", this->isVisible)); //debug border cxViewSetBorder(this, cxXMLReadBoolAttr(info, "cxView.border", this->isBorder)); //rotate raxis cxViewSetRaxis(this, cxXMLReadVec3fAttr(info, "cxView.raxis", this->raxis)); //rotate angle cxViewSetAngle(this, cxXMLReadFloatAttr(info, "cxView.angle", this->angle)); //rotate degress cxViewSetDegrees(this, cxXMLReadFloatAttr(info, "cxView.degrees", kmRadiansToDegrees(this->angle))); //Chipmunk support cxViewCheckChipmunkSupport(info); //cxAtlas support this->supportAtlasSet = cxXMLReadBoolAttr(info, "cxAtlasSet.support", false); //view event cxXMLAppendEvent(info, this, cxView, onEnter); cxXMLAppendEvent(info, this, cxView, onExit); cxXMLAppendEvent(info, this, cxView, onUpdate); cxXMLAppendEvent(info, this, cxView, onResize); cxXMLAppendEvent(info, this, cxView, onLayout); cxXMLAppendEvent(info, this, cxView, onDirty); }