00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 00026 #include "OgreBorderPanelGuiElement.h" 00027 #include "OgreMaterialManager.h" 00028 #include "OgreMaterial.h" 00029 #include "OgreStringConverter.h" 00030 #include "OgreOverlayManager.h" 00031 #include "OgreHardwareBufferManager.h" 00032 #include "OgreHardwareVertexBuffer.h" 00033 #include "OgreHardwareIndexBuffer.h" 00034 #include "OgreException.h" 00035 #include "OgreRenderQueue.h" 00036 00037 namespace Ogre { 00038 //--------------------------------------------------------------------- 00039 String BorderPanelGuiElement::msTypeName = "BorderPanel"; 00040 BorderPanelGuiElement::CmdBorderSize BorderPanelGuiElement::msCmdBorderSize; 00041 BorderPanelGuiElement::CmdBorderMaterial BorderPanelGuiElement::msCmdBorderMaterial; 00042 BorderPanelGuiElement::CmdBorderLeftUV BorderPanelGuiElement::msCmdBorderLeftUV; 00043 BorderPanelGuiElement::CmdBorderTopUV BorderPanelGuiElement::msCmdBorderTopUV; 00044 BorderPanelGuiElement::CmdBorderBottomUV BorderPanelGuiElement::msCmdBorderBottomUV; 00045 BorderPanelGuiElement::CmdBorderRightUV BorderPanelGuiElement::msCmdBorderRightUV; 00046 BorderPanelGuiElement::CmdBorderTopLeftUV BorderPanelGuiElement::msCmdBorderTopLeftUV; 00047 BorderPanelGuiElement::CmdBorderBottomLeftUV BorderPanelGuiElement::msCmdBorderBottomLeftUV; 00048 BorderPanelGuiElement::CmdBorderTopRightUV BorderPanelGuiElement::msCmdBorderTopRightUV; 00049 BorderPanelGuiElement::CmdBorderBottomRightUV BorderPanelGuiElement::msCmdBorderBottomRightUV; 00050 00051 #define BCELL_UV(x) (x * 4 * 2) 00052 #define POSITION_BINDING 0 00053 #define TEXCOORD_BINDING 1 00054 //--------------------------------------------------------------------- 00055 BorderPanelGuiElement::BorderPanelGuiElement(const String& name) 00056 : PanelGuiElement(name), 00057 mLeftBorderSize(0), 00058 mRightBorderSize(0), 00059 mTopBorderSize(0), 00060 mBottomBorderSize(0), 00061 mPixelLeftBorderSize(0), 00062 mPixelRightBorderSize(0), 00063 mPixelTopBorderSize(0), 00064 mPixelBottomBorderSize(0), 00065 mpBorderMaterial(0), 00066 mBorderRenderable(0) 00067 { 00068 if (createParamDictionary("BorderPanelGuiElement")) 00069 { 00070 addBaseParameters(); 00071 } 00072 } 00073 //--------------------------------------------------------------------- 00074 BorderPanelGuiElement::~BorderPanelGuiElement() 00075 { 00076 delete mRenderOp2.vertexData; 00077 delete mRenderOp2.indexData; 00078 delete mBorderRenderable; 00079 } 00080 //--------------------------------------------------------------------- 00081 void BorderPanelGuiElement::initialise(void) 00082 { 00083 PanelGuiElement::initialise(); 00084 00085 // superclass will handle the interior panel area 00086 00087 // Setup render op in advance 00088 mRenderOp2.vertexData = new VertexData(); 00089 mRenderOp2.vertexData->vertexCount = 4 * 8; // 8 cells, can't necessarily share vertices cos 00090 // texcoords may differ 00091 mRenderOp2.vertexData->vertexStart = 0; 00092 00093 // Vertex declaration 00094 VertexDeclaration* decl = mRenderOp2.vertexData->vertexDeclaration; 00095 // Position and texture coords each have their own buffers to allow 00096 // each to be edited separately with the discard flag 00097 decl->addElement(POSITION_BINDING, 0, VET_FLOAT3, VES_POSITION); 00098 decl->addElement(TEXCOORD_BINDING, 0, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0); 00099 00100 // Vertex buffer #1, position 00101 HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton() 00102 .createVertexBuffer( 00103 decl->getVertexSize(POSITION_BINDING), 00104 mRenderOp2.vertexData->vertexCount, 00105 HardwareBuffer::HBU_STATIC_WRITE_ONLY); 00106 // bind position 00107 VertexBufferBinding* binding = mRenderOp2.vertexData->vertexBufferBinding; 00108 binding->setBinding(POSITION_BINDING, vbuf); 00109 00110 // Vertex buffer #2, texcoords 00111 vbuf = HardwareBufferManager::getSingleton() 00112 .createVertexBuffer( 00113 decl->getVertexSize(TEXCOORD_BINDING), 00114 mRenderOp2.vertexData->vertexCount, 00115 HardwareBuffer::HBU_STATIC_WRITE_ONLY, true); 00116 // bind texcoord 00117 binding->setBinding(TEXCOORD_BINDING, vbuf); 00118 00119 mRenderOp2.operationType = RenderOperation::OT_TRIANGLE_LIST; 00120 mRenderOp2.useIndexes = true; 00121 // Index data 00122 mRenderOp2.indexData = new IndexData(); 00123 mRenderOp2.indexData->indexCount = 8 * 6; 00124 mRenderOp2.indexData->indexStart = 0; 00125 00126 /* Each cell is 00127 0-----2 00128 | /| 00129 | / | 00130 |/ | 00131 1-----3 00132 */ 00133 mRenderOp2.indexData->indexBuffer = HardwareBufferManager::getSingleton(). 00134 createIndexBuffer( 00135 HardwareIndexBuffer::IT_16BIT, 00136 mRenderOp2.indexData->indexCount, 00137 HardwareBuffer::HBU_STATIC_WRITE_ONLY); 00138 00139 ushort* pIdx = static_cast<ushort*>( 00140 mRenderOp2.indexData->indexBuffer->lock( 00141 0, 00142 mRenderOp2.indexData->indexBuffer->getSizeInBytes(), 00143 HardwareBuffer::HBL_DISCARD) ); 00144 00145 for (int cell = 0; cell < 8; ++cell) 00146 { 00147 ushort base = cell * 4; 00148 *pIdx++ = base; 00149 *pIdx++ = base + 1; 00150 *pIdx++ = base + 2; 00151 00152 *pIdx++ = base + 2; 00153 *pIdx++ = base + 1; 00154 *pIdx++ = base + 3; 00155 } 00156 00157 mRenderOp2.indexData->indexBuffer->unlock(); 00158 00159 // Create sub-object for rendering border 00160 mBorderRenderable = new BorderRenderable(this); 00161 } 00162 //--------------------------------------------------------------------- 00163 void BorderPanelGuiElement::addBaseParameters(void) 00164 { 00165 PanelGuiElement::addBaseParameters(); 00166 ParamDictionary* dict = getParamDictionary(); 00167 00168 dict->addParameter(ParameterDef("border_size", 00169 "The sizes of the borders relative to the screen size, in the order " 00170 "left, right, top, bottom." 00171 , PT_STRING), 00172 &msCmdBorderSize); 00173 dict->addParameter(ParameterDef("border_material", 00174 "The material to use for the border." 00175 , PT_STRING), 00176 &msCmdBorderMaterial); 00177 dict->addParameter(ParameterDef("border_topleft_uv", 00178 "The texture coordinates for the top-left corner border texture. 2 sets of uv values, " 00179 "one for the top-left corner, the other for the bottom-right corner." 00180 , PT_STRING), 00181 &msCmdBorderTopLeftUV); 00182 dict->addParameter(ParameterDef("border_topright_uv", 00183 "The texture coordinates for the top-right corner border texture. 2 sets of uv values, " 00184 "one for the top-left corner, the other for the bottom-right corner." 00185 , PT_STRING), 00186 &msCmdBorderTopRightUV); 00187 dict->addParameter(ParameterDef("border_bottomright_uv", 00188 "The texture coordinates for the bottom-right corner border texture. 2 sets of uv values, " 00189 "one for the top-left corner, the other for the bottom-right corner." 00190 , PT_STRING), 00191 &msCmdBorderBottomRightUV); 00192 dict->addParameter(ParameterDef("border_bottomleft_uv", 00193 "The texture coordinates for the bottom-left corner border texture. 2 sets of uv values, " 00194 "one for the top-left corner, the other for the bottom-right corner." 00195 , PT_STRING), 00196 &msCmdBorderBottomLeftUV); 00197 dict->addParameter(ParameterDef("border_left_uv", 00198 "The texture coordinates for the left edge border texture. 2 sets of uv values, " 00199 "one for the top-left corner, the other for the bottom-right corner." 00200 , PT_STRING), 00201 &msCmdBorderLeftUV); 00202 dict->addParameter(ParameterDef("border_top_uv", 00203 "The texture coordinates for the top edge border texture. 2 sets of uv values, " 00204 "one for the top-left corner, the other for the bottom-right corner." 00205 , PT_STRING), 00206 &msCmdBorderTopUV); 00207 dict->addParameter(ParameterDef("border_right_uv", 00208 "The texture coordinates for the right edge border texture. 2 sets of uv values, " 00209 "one for the top-left corner, the other for the bottom-right corner." 00210 , PT_STRING), 00211 &msCmdBorderRightUV); 00212 dict->addParameter(ParameterDef("border_bottom_uv", 00213 "The texture coordinates for the bottom edge border texture. 2 sets of uv values, " 00214 "one for the top-left corner, the other for the bottom-right corner." 00215 , PT_STRING), 00216 &msCmdBorderBottomUV); 00217 00218 } 00219 //--------------------------------------------------------------------- 00220 void BorderPanelGuiElement::setBorderSize(Real size) 00221 { 00222 if (mMetricsMode == GMM_PIXELS) 00223 { 00224 mPixelLeftBorderSize = mPixelRightBorderSize = 00225 mPixelTopBorderSize = mPixelBottomBorderSize = size; 00226 } 00227 else 00228 { 00229 mLeftBorderSize = mRightBorderSize = 00230 mTopBorderSize = mBottomBorderSize = size; 00231 } 00232 mGeomPositionsOutOfDate = true; 00233 } 00234 //--------------------------------------------------------------------- 00235 void BorderPanelGuiElement::setBorderSize(Real sides, Real topAndBottom) 00236 { 00237 if (mMetricsMode == GMM_PIXELS) 00238 { 00239 mPixelLeftBorderSize = mPixelRightBorderSize = sides; 00240 mPixelTopBorderSize = mPixelBottomBorderSize = topAndBottom; 00241 } 00242 else 00243 { 00244 mLeftBorderSize = mRightBorderSize = sides; 00245 mTopBorderSize = mBottomBorderSize = topAndBottom; 00246 } 00247 mGeomPositionsOutOfDate = true; 00248 00249 00250 } 00251 //--------------------------------------------------------------------- 00252 void BorderPanelGuiElement::setBorderSize(Real left, Real right, Real top, Real bottom) 00253 { 00254 if (mMetricsMode == GMM_PIXELS) 00255 { 00256 mPixelLeftBorderSize = left; 00257 mPixelRightBorderSize = right; 00258 mPixelTopBorderSize = top; 00259 mPixelBottomBorderSize = bottom; 00260 } 00261 else 00262 { 00263 mLeftBorderSize = left; 00264 mRightBorderSize = right; 00265 mTopBorderSize = top; 00266 mBottomBorderSize = bottom; 00267 } 00268 mGeomPositionsOutOfDate = true; 00269 } 00270 //--------------------------------------------------------------------- 00271 Real BorderPanelGuiElement::getLeftBorderSize(void) const 00272 { 00273 if (mMetricsMode == GMM_PIXELS) 00274 { 00275 return mPixelLeftBorderSize; 00276 } 00277 else 00278 { 00279 return mLeftBorderSize; 00280 } 00281 } 00282 //--------------------------------------------------------------------- 00283 Real BorderPanelGuiElement::getRightBorderSize(void) const 00284 { 00285 if (mMetricsMode == GMM_PIXELS) 00286 { 00287 return mPixelRightBorderSize; 00288 } 00289 else 00290 { 00291 return mRightBorderSize; 00292 } 00293 } 00294 //--------------------------------------------------------------------- 00295 Real BorderPanelGuiElement::getTopBorderSize(void) const 00296 { 00297 if (mMetricsMode == GMM_PIXELS) 00298 { 00299 return mPixelTopBorderSize; 00300 } 00301 else 00302 { 00303 return mTopBorderSize; 00304 } 00305 } 00306 //--------------------------------------------------------------------- 00307 Real BorderPanelGuiElement::getBottomBorderSize(void) const 00308 { 00309 if (mMetricsMode == GMM_PIXELS) 00310 { 00311 return mPixelBottomBorderSize; 00312 } 00313 else 00314 { 00315 return mBottomBorderSize; 00316 } 00317 } 00318 //--------------------------------------------------------------------- 00319 void BorderPanelGuiElement::setCellUV(BorderCellIndex idx, Real& u1, 00320 Real& v1, Real& u2, Real& v2) 00321 { 00322 /* Each cell is 00323 0-----2 00324 | /| 00325 | / | 00326 |/ | 00327 1-----3 00328 */ 00329 // No choice but to lock / unlock each time here, but lock only small sections 00330 00331 HardwareVertexBufferSharedPtr vbuf = 00332 mRenderOp2.vertexData->vertexBufferBinding->getBuffer(TEXCOORD_BINDING); 00333 // Can't use discard since this discards whole buffer 00334 Real* pUV = static_cast<Real*>( 00335 vbuf->lock( 00336 BCELL_UV(idx) * sizeof(Real), 00337 sizeof(Real)*8, 00338 HardwareBuffer::HBL_NORMAL) ); 00339 00340 *pUV++ = u1; *pUV++ = v1; 00341 *pUV++ = u1; *pUV++ = v2; 00342 *pUV++ = u2; *pUV++ = v1; 00343 *pUV++ = u2; *pUV++ = v2; 00344 00345 vbuf->unlock(); 00346 00347 } 00348 //--------------------------------------------------------------------- 00349 String BorderPanelGuiElement::getCellUVString(BorderCellIndex idx) const 00350 { 00351 /* Each cell is 00352 0-----2 00353 | /| 00354 | / | 00355 |/ | 00356 1-----3 00357 */ 00358 // No choice but to lock / unlock each time here, but lock only small sections 00359 00360 HardwareVertexBufferSharedPtr vbuf = 00361 mRenderOp2.vertexData->vertexBufferBinding->getBuffer(TEXCOORD_BINDING); 00362 // Lock just the portion we need in read-only mode 00363 // Can't use discard since this discards whole buffer 00364 Real* pUV = static_cast<Real*>( 00365 vbuf->lock( 00366 BCELL_UV(idx) * sizeof(Real), 00367 sizeof(Real)*8, 00368 HardwareBuffer::HBL_READ_ONLY) ); 00369 00370 String ret = StringConverter::toString(pUV[0]) + " " + 00371 StringConverter::toString(pUV[1]) + " " + 00372 StringConverter::toString(pUV[6]) + " " + 00373 StringConverter::toString(pUV[7]); 00374 vbuf->unlock(); 00375 return ret; 00376 } 00377 //--------------------------------------------------------------------- 00378 void BorderPanelGuiElement::setLeftBorderUV(Real u1, Real v1, Real u2, Real v2) 00379 { 00380 setCellUV(BCELL_LEFT, u1, v1, u2, v2); 00381 } 00382 //--------------------------------------------------------------------- 00383 void BorderPanelGuiElement::setRightBorderUV(Real u1, Real v1, Real u2, Real v2) 00384 { 00385 setCellUV(BCELL_RIGHT, u1, v1, u2, v2); 00386 } 00387 //--------------------------------------------------------------------- 00388 void BorderPanelGuiElement::setTopBorderUV(Real u1, Real v1, Real u2, Real v2) 00389 { 00390 setCellUV(BCELL_TOP, u1, v1, u2, v2); 00391 } 00392 //--------------------------------------------------------------------- 00393 void BorderPanelGuiElement::setBottomBorderUV(Real u1, Real v1, Real u2, Real v2) 00394 { 00395 setCellUV(BCELL_BOTTOM, u1, v1, u2, v2); 00396 } 00397 //--------------------------------------------------------------------- 00398 void BorderPanelGuiElement::setTopLeftBorderUV(Real u1, Real v1, Real u2, Real v2) 00399 { 00400 setCellUV(BCELL_TOP_LEFT, u1, v1, u2, v2); 00401 } 00402 //--------------------------------------------------------------------- 00403 void BorderPanelGuiElement::setTopRightBorderUV(Real u1, Real v1, Real u2, Real v2) 00404 { 00405 setCellUV(BCELL_TOP_RIGHT, u1, v1, u2, v2); 00406 } 00407 //--------------------------------------------------------------------- 00408 void BorderPanelGuiElement::setBottomLeftBorderUV(Real u1, Real v1, Real u2, Real v2) 00409 { 00410 setCellUV(BCELL_BOTTOM_LEFT, u1, v1, u2, v2); 00411 } 00412 //--------------------------------------------------------------------- 00413 void BorderPanelGuiElement::setBottomRightBorderUV(Real u1, Real v1, Real u2, Real v2) 00414 { 00415 setCellUV(BCELL_BOTTOM_RIGHT, u1, v1, u2, v2); 00416 } 00417 00418 //--------------------------------------------------------------------- 00419 String BorderPanelGuiElement::getLeftBorderUVString() const 00420 { 00421 return getCellUVString(BCELL_LEFT); 00422 } 00423 //--------------------------------------------------------------------- 00424 String BorderPanelGuiElement::getRightBorderUVString() const 00425 { 00426 return getCellUVString(BCELL_RIGHT); 00427 } 00428 //--------------------------------------------------------------------- 00429 String BorderPanelGuiElement::getTopBorderUVString() const 00430 { 00431 return getCellUVString(BCELL_TOP); 00432 } 00433 //--------------------------------------------------------------------- 00434 String BorderPanelGuiElement::getBottomBorderUVString() const 00435 { 00436 return getCellUVString(BCELL_BOTTOM); 00437 } 00438 //--------------------------------------------------------------------- 00439 String BorderPanelGuiElement::getTopLeftBorderUVString() const 00440 { 00441 return getCellUVString(BCELL_TOP_LEFT); 00442 } 00443 //--------------------------------------------------------------------- 00444 String BorderPanelGuiElement::getTopRightBorderUVString() const 00445 { 00446 return getCellUVString(BCELL_TOP_RIGHT); 00447 } 00448 //--------------------------------------------------------------------- 00449 String BorderPanelGuiElement::getBottomLeftBorderUVString() const 00450 { 00451 return getCellUVString(BCELL_BOTTOM_LEFT); 00452 } 00453 //--------------------------------------------------------------------- 00454 String BorderPanelGuiElement::getBottomRightBorderUVString() const 00455 { 00456 return getCellUVString(BCELL_BOTTOM_RIGHT); 00457 } 00458 00459 00460 00461 00462 00463 //--------------------------------------------------------------------- 00464 void BorderPanelGuiElement::setBorderMaterialName(const String& name) 00465 { 00466 mBorderMaterialName = name; 00467 mpBorderMaterial = (Material*)MaterialManager::getSingleton().getByName(name); 00468 if (!mpBorderMaterial) 00469 Except( Exception::ERR_ITEM_NOT_FOUND, "Could not find material " + name, 00470 "BorderPanelGuiElement::setBorderMaterialName" ); 00471 mpBorderMaterial->load(); 00472 // Set some prerequisites to be sure 00473 mpBorderMaterial->setLightingEnabled(false); 00474 mpBorderMaterial->setDepthCheckEnabled(false); 00475 00476 } 00477 //--------------------------------------------------------------------- 00478 const String& BorderPanelGuiElement::getBorderMaterialName(void) const 00479 { 00480 return mBorderMaterialName; 00481 } 00482 //--------------------------------------------------------------------- 00483 void BorderPanelGuiElement::updatePositionGeometry(void) 00484 { 00485 /* 00486 Grid is like this: 00487 +--+---------------+--+ 00488 |0 | 1 |2 | 00489 +--+---------------+--+ 00490 | | | | 00491 | | | | 00492 |3 | center |4 | 00493 | | | | 00494 +--+---------------+--+ 00495 |5 | 6 |7 | 00496 +--+---------------+--+ 00497 */ 00498 // Convert positions into -1, 1 coordinate space (homogenous clip space) 00499 // Top / bottom also need inverting since y is upside down 00500 Real left[8], right[8], top[8], bottom[8]; 00501 // Horizontal 00502 left[0] = left[3] = left[5] = _getDerivedLeft() * 2 - 1; 00503 left[1] = left[6] = right[0] = right[3] = right[5] = left[0] + (mLeftBorderSize * 2); 00504 right[2] = right[4] = right[7] = left[0] + (mWidth * 2); 00505 left[2] = left[4] = left[7] = right[1] = right[6] = right[2] - (mRightBorderSize * 2); 00506 // Vertical 00507 top[0] = top[1] = top[2] = -((_getDerivedTop() * 2) - 1); 00508 top[3] = top[4] = bottom[0] = bottom[1] = bottom[2] = top[0] - (mTopBorderSize * 2); 00509 bottom[5] = bottom[6] = bottom[7] = top[0] - (mHeight * 2); 00510 top[5] = top[6] = top[7] = bottom[3] = bottom[4] = bottom[5] + (mBottomBorderSize * 2); 00511 00512 // Lock the whole position buffer in discard mode 00513 HardwareVertexBufferSharedPtr vbuf = 00514 mRenderOp2.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING); 00515 Real* pPos = static_cast<Real*>( 00516 vbuf->lock(HardwareBuffer::HBL_DISCARD) ); 00517 for (ushort cell = 0; cell < 8; ++cell) 00518 { 00519 /* 00520 0-----2 00521 | /| 00522 | / | 00523 |/ | 00524 1-----3 00525 */ 00526 *pPos++ = left[cell]; 00527 *pPos++ = top[cell]; 00528 *pPos++ = -1; 00529 00530 *pPos++ = left[cell]; 00531 *pPos++ = bottom[cell]; 00532 *pPos++ = -1; 00533 00534 *pPos++ = right[cell]; 00535 *pPos++ = top[cell]; 00536 *pPos++ = -1; 00537 00538 *pPos++ = right[cell]; 00539 *pPos++ = bottom[cell]; 00540 *pPos++ = -1; 00541 00542 } 00543 vbuf->unlock(); 00544 00545 // Also update center geometry 00546 // NB don't use superclass because we need to make it smaller because of border 00547 vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(POSITION_BINDING); 00548 pPos = static_cast<Real*>( 00549 vbuf->lock(HardwareBuffer::HBL_DISCARD) ); 00550 // Use cell 1 and 3 to determine positions 00551 *pPos++ = left[1]; 00552 *pPos++ = top[3]; 00553 *pPos++ = -1; 00554 00555 *pPos++ = left[1]; 00556 *pPos++ = bottom[3]; 00557 *pPos++ = -1; 00558 00559 *pPos++ = right[1]; 00560 *pPos++ = top[3]; 00561 *pPos++ = -1; 00562 00563 *pPos++ = right[1]; 00564 *pPos++ = bottom[3]; 00565 *pPos++ = -1; 00566 00567 vbuf->unlock(); 00568 00569 } 00570 //--------------------------------------------------------------------- 00571 void BorderPanelGuiElement::_updateRenderQueue(RenderQueue* queue) 00572 { 00573 // Add self twice to the queue 00574 // Have to do this to allow 2 materials 00575 if (mVisible) 00576 { 00577 00578 // Add outer 00579 queue->addRenderable(mBorderRenderable, RENDER_QUEUE_OVERLAY, mZOrder); 00580 00581 // do inner last so the border artifacts don't overwrite the children 00582 // Add inner 00583 PanelGuiElement::_updateRenderQueue(queue); 00584 } 00585 } 00586 //----------------------------------------------------------------------- 00587 void BorderPanelGuiElement::setMetricsMode(GuiMetricsMode gmm) 00588 { 00589 PanelGuiElement::setMetricsMode(gmm); 00590 if (gmm == GMM_PIXELS) 00591 { 00592 mPixelBottomBorderSize = mBottomBorderSize; 00593 mPixelLeftBorderSize = mLeftBorderSize; 00594 mPixelRightBorderSize = mRightBorderSize; 00595 mPixelTopBorderSize = mTopBorderSize; 00596 } 00597 } 00598 //----------------------------------------------------------------------- 00599 void BorderPanelGuiElement::_update(void) 00600 { 00601 if (mMetricsMode == GMM_PIXELS && 00602 (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)) 00603 { 00604 // Recalc border size 00605 Real vpWidth, vpHeight; 00606 vpWidth = (Real) (OverlayManager::getSingleton().getViewportWidth()); 00607 vpHeight = (Real) (OverlayManager::getSingleton().getViewportHeight()); 00608 00609 mLeftBorderSize = (Real) mPixelLeftBorderSize / vpWidth; 00610 mRightBorderSize = (Real) mPixelRightBorderSize / vpWidth; 00611 mTopBorderSize = (Real) mPixelTopBorderSize / vpHeight; 00612 mBottomBorderSize = (Real) mPixelBottomBorderSize / vpHeight; 00613 mGeomPositionsOutOfDate = true; 00614 } 00615 PanelGuiElement::_update(); 00616 00617 } 00618 //----------------------------------------------------------------------- 00619 //--------------------------------------------------------------------- 00620 //--------------------------------------------------------------------- 00621 // Command objects 00622 //--------------------------------------------------------------------- 00623 //----------------------------------------------------------------------- 00624 String BorderPanelGuiElement::CmdBorderSize::doGet(const void* target) const 00625 { 00626 const BorderPanelGuiElement* t = static_cast<const BorderPanelGuiElement*>(target); 00627 return String( 00628 StringConverter::toString(t->getLeftBorderSize()) + " " + 00629 StringConverter::toString(t->getRightBorderSize()) + " " + 00630 StringConverter::toString(t->getTopBorderSize()) + " " + 00631 StringConverter::toString(t->getBottomBorderSize()) ); 00632 } 00633 void BorderPanelGuiElement::CmdBorderSize::doSet(void* target, const String& val) 00634 { 00635 std::vector<String> vec = val.split(); 00636 00637 static_cast<BorderPanelGuiElement*>(target)->setBorderSize( 00638 StringConverter::parseReal(vec[0]), 00639 StringConverter::parseReal(vec[1]), 00640 StringConverter::parseReal(vec[2]), 00641 StringConverter::parseReal(vec[3]) 00642 ); 00643 } 00644 //----------------------------------------------------------------------- 00645 String BorderPanelGuiElement::CmdBorderMaterial::doGet(const void* target) const 00646 { 00647 // No need right now.. 00648 return static_cast<const BorderPanelGuiElement*>(target)->getBorderMaterialName(); 00649 } 00650 void BorderPanelGuiElement::CmdBorderMaterial::doSet(void* target, const String& val) 00651 { 00652 std::vector<String> vec = val.split(); 00653 00654 static_cast<BorderPanelGuiElement*>(target)->setBorderMaterialName(val); 00655 } 00656 //----------------------------------------------------------------------- 00657 String BorderPanelGuiElement::CmdBorderBottomLeftUV::doGet(const void* target) const 00658 { 00659 // No need right now.. 00660 return static_cast<const BorderPanelGuiElement*>(target)->getBottomLeftBorderUVString(); 00661 } 00662 void BorderPanelGuiElement::CmdBorderBottomLeftUV::doSet(void* target, const String& val) 00663 { 00664 std::vector<String> vec = val.split(); 00665 00666 static_cast<BorderPanelGuiElement*>(target)->setBottomLeftBorderUV( 00667 StringConverter::parseReal(vec[0]), 00668 StringConverter::parseReal(vec[1]), 00669 StringConverter::parseReal(vec[2]), 00670 StringConverter::parseReal(vec[3]) 00671 ); 00672 } 00673 //----------------------------------------------------------------------- 00674 String BorderPanelGuiElement::CmdBorderBottomRightUV::doGet(const void* target) const 00675 { 00676 // No need right now.. 00677 return static_cast<const BorderPanelGuiElement*>(target)->getBottomRightBorderUVString(); 00678 } 00679 void BorderPanelGuiElement::CmdBorderBottomRightUV::doSet(void* target, const String& val) 00680 { 00681 std::vector<String> vec = val.split(); 00682 00683 static_cast<BorderPanelGuiElement*>(target)->setBottomRightBorderUV( 00684 StringConverter::parseReal(vec[0]), 00685 StringConverter::parseReal(vec[1]), 00686 StringConverter::parseReal(vec[2]), 00687 StringConverter::parseReal(vec[3]) 00688 ); 00689 } 00690 //----------------------------------------------------------------------- 00691 String BorderPanelGuiElement::CmdBorderTopLeftUV::doGet(const void* target) const 00692 { 00693 // No need right now.. 00694 return static_cast<const BorderPanelGuiElement*>(target)->getTopLeftBorderUVString(); 00695 } 00696 void BorderPanelGuiElement::CmdBorderTopLeftUV::doSet(void* target, const String& val) 00697 { 00698 std::vector<String> vec = val.split(); 00699 00700 static_cast<BorderPanelGuiElement*>(target)->setTopLeftBorderUV( 00701 StringConverter::parseReal(vec[0]), 00702 StringConverter::parseReal(vec[1]), 00703 StringConverter::parseReal(vec[2]), 00704 StringConverter::parseReal(vec[3]) 00705 ); 00706 } 00707 //----------------------------------------------------------------------- 00708 String BorderPanelGuiElement::CmdBorderTopRightUV::doGet(const void* target) const 00709 { 00710 // No need right now.. 00711 return static_cast<const BorderPanelGuiElement*>(target)->getTopRightBorderUVString(); 00712 } 00713 void BorderPanelGuiElement::CmdBorderTopRightUV::doSet(void* target, const String& val) 00714 { 00715 std::vector<String> vec = val.split(); 00716 00717 static_cast<BorderPanelGuiElement*>(target)->setTopRightBorderUV( 00718 StringConverter::parseReal(vec[0]), 00719 StringConverter::parseReal(vec[1]), 00720 StringConverter::parseReal(vec[2]), 00721 StringConverter::parseReal(vec[3]) 00722 ); 00723 } 00724 //----------------------------------------------------------------------- 00725 String BorderPanelGuiElement::CmdBorderLeftUV::doGet(const void* target) const 00726 { 00727 // No need right now.. 00728 return static_cast<const BorderPanelGuiElement*>(target)->getLeftBorderUVString(); 00729 } 00730 void BorderPanelGuiElement::CmdBorderLeftUV::doSet(void* target, const String& val) 00731 { 00732 std::vector<String> vec = val.split(); 00733 00734 static_cast<BorderPanelGuiElement*>(target)->setLeftBorderUV( 00735 StringConverter::parseReal(vec[0]), 00736 StringConverter::parseReal(vec[1]), 00737 StringConverter::parseReal(vec[2]), 00738 StringConverter::parseReal(vec[3]) 00739 ); 00740 } 00741 //----------------------------------------------------------------------- 00742 String BorderPanelGuiElement::CmdBorderRightUV::doGet(const void* target) const 00743 { 00744 // No need right now.. 00745 return static_cast<const BorderPanelGuiElement*>(target)->getRightBorderUVString(); 00746 } 00747 void BorderPanelGuiElement::CmdBorderRightUV::doSet(void* target, const String& val) 00748 { 00749 std::vector<String> vec = val.split(); 00750 00751 static_cast<BorderPanelGuiElement*>(target)->setRightBorderUV( 00752 StringConverter::parseReal(vec[0]), 00753 StringConverter::parseReal(vec[1]), 00754 StringConverter::parseReal(vec[2]), 00755 StringConverter::parseReal(vec[3]) 00756 ); 00757 } 00758 //----------------------------------------------------------------------- 00759 String BorderPanelGuiElement::CmdBorderTopUV::doGet(const void* target) const 00760 { 00761 // No need right now.. 00762 return static_cast<const BorderPanelGuiElement*>(target)->getTopBorderUVString(); 00763 } 00764 void BorderPanelGuiElement::CmdBorderTopUV::doSet(void* target, const String& val) 00765 { 00766 std::vector<String> vec = val.split(); 00767 00768 static_cast<BorderPanelGuiElement*>(target)->setTopBorderUV( 00769 StringConverter::parseReal(vec[0]), 00770 StringConverter::parseReal(vec[1]), 00771 StringConverter::parseReal(vec[2]), 00772 StringConverter::parseReal(vec[3]) 00773 ); 00774 } 00775 //----------------------------------------------------------------------- 00776 String BorderPanelGuiElement::CmdBorderBottomUV::doGet(const void* target) const 00777 { 00778 // No need right now.. 00779 return static_cast<const BorderPanelGuiElement*>(target)->getBottomBorderUVString(); 00780 } 00781 void BorderPanelGuiElement::CmdBorderBottomUV::doSet(void* target, const String& val) 00782 { 00783 std::vector<String> vec = val.split(); 00784 00785 static_cast<BorderPanelGuiElement*>(target)->setBottomBorderUV( 00786 StringConverter::parseReal(vec[0]), 00787 StringConverter::parseReal(vec[1]), 00788 StringConverter::parseReal(vec[2]), 00789 StringConverter::parseReal(vec[3]) 00790 ); 00791 } 00792 //--------------------------------------------------------------------- 00793 const String& BorderPanelGuiElement::getTypeName(void) const 00794 { 00795 return msTypeName; 00796 } 00797 00798 00799 00800 } 00801
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:03 2004