SO3Engine
SO3Widget.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#include "SO3Renderer/SO3Root.h"
37#include <OgreBitwise.h>
38#include <boost/algorithm/string.hpp>
39
40namespace SO3
41{
42
43 unsigned int prevPOW2(unsigned int x)
44 {
45 if (x == 0)
46 {
47 return 0;
48 }
49 // x--; Uncomment this, if you want a strictly less than 'x' result.
50 x |= (x >> 1);
51 x |= (x >> 2);
52 x |= (x >> 4);
53 x |= (x >> 8);
54 x |= (x >> 16);
55 return x - (x >> 1);
56 }
57
58 SWidget::SWidget() : SData(""), isOverlayed(false), is2DRect(false)
59 {
60 // Forbiden, private constructor
61 }
62
63 SWidget::SWidget(SScene* targetScene, const std::string& widgetName, const int& xPos, const int& yPos, const unsigned short& widgetWidth, const unsigned short& widgetHeight, SViewPort* targetViewport, const unsigned int& widgetZOrder, const std::string& widgetType) : SData(widgetName), isOverlayed(true), is2DRect(false)
64 {
65 StandardConstructor(targetScene, xPos, yPos, widgetWidth, widgetHeight, widgetZOrder, targetViewport, widgetType);
66 if (widgetType != "BitmapWidget")
68
69 CreateMaterial();
70 CreateOverlay();
71 }
72
73 SWidget::SWidget(SScene* targetScene, const std::string& widgetName, const int& xPos, const int& yPos, const unsigned short& widgetWidth, const unsigned short& widgetHeight, SViewPort* targetViewport, const std::string& widgetType) : SData(widgetName), isOverlayed(false), is2DRect(true)
74 {
75 StandardConstructor(targetScene, xPos, yPos, widgetWidth, widgetHeight, 0, targetViewport, widgetType);
76
77 if (widgetType != "BitmapWidget")
79
80 CreateMaterial();
81 Create2D();
82 }
83
84 SWidget::SWidget(SScene* targetScene, const std::string& widgetName, const unsigned short& widgetWidth, const unsigned short& widgetHeight, SMaterial* targetMaterial, const unsigned short& targetTechnique, const unsigned short& targetPass, const unsigned short& targetTextureUnit, const std::string& widgetType) : SData(widgetName), isOverlayed(false), is2DRect(false)
85 {
86 StandardConstructor(targetScene, 0, 0, widgetWidth, widgetHeight, 0, 0, widgetType);
87
88 // Let the material know that a widget will modify it's internal data.
89 // Warning, an exception can be fired here.
90 originalMaterial = targetMaterial;
91 //if (targetMaterial->GetAssociatedWidget() == 0)
92 targetMaterial->SetAssociatedWidget(this);
93
94 ogreTargetMaterial = targetMaterial->getOgreMaterialPointer();
95
96 //update generated materials
97 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
98
99 ogreTargetMaterialPass = ogreTargetMaterial->getTechnique(targetTechnique)->getPass(targetPass);
100 ogreTargetTextureUnit = ogreTargetMaterialPass->getTextureUnitState(targetTextureUnit);
101
102 matData.oSceneBlendingS = ogreTargetMaterialPass->getSourceBlendFactor();
103 matData.oSceneBlendingD = ogreTargetMaterialPass->getDestBlendFactor();
104 matData.oDepthWrite = ogreTargetMaterialPass->getDepthWriteEnabled();
105
106 ogreOriginalTextureUnit = OGRE_NEW Ogre::TextureUnitState(*ogreTargetTextureUnit);
107 renderingTextureUnit = OGRE_NEW Ogre::TextureUnitState(*ogreTargetTextureUnit);
108
109 // Create texture AFTER storing original material and texture informations
110 if (widgetType != "BitmapWidget")
111 {
113 }
114 }
115
116 void SWidget::StandardConstructor(SScene* targetScene, const int& xPos, const int& yPos, const unsigned short& widgetWidth, const unsigned short& widgetHeight, const unsigned int& widgetZOrder, SViewPort* targetViewport, const std::string& widgetType)
117 {
118 // Default Init
119 type = widgetType;
120 leftPos = xPos;
121 topPos = yPos;
122 width = widgetWidth;
123 height = widgetHeight;
124 leftOffset = 0.0f;
125 topOffset = 0.0f;
126 scene = targetScene;
127 viewport = targetViewport;
129 renderingTexture.reset();
130 renderingTextureUnit = 0;
131 ogreOriginalTextureUnit = 0;
132 mTextureWidth = 0;
133 mTextureHeight = 0;
134 textureRatio = 1.0f;
135 baseResourceName = std::string(SO3_INTERNAL_RESOURCE_GROUP) + "/Widgets/" + widgetType;
136 compensateNPOT = false;
137 ogreTargetTextureUnit = 0;
138 ogreTargetMaterialPass = 0;
139 topOnFocus = false;
140 isPriorized = false;
141 originalMaterial = 0;
142 mouseIsOver = 0;
143 opacity = 1.0f;
144 isTransparent = false;
145 mouseEnable = true;
146 keyboardEnable = true;
147 forceRenderingUpdate = false;
148 transparentIgnorePixels = isOverlayed;
149 transparentTresholdColor = (transparentIgnorePixels) ? 0.04f : 0.0f;
150 updateOnFocusOnly = false;
151 mStereoMode = StereoMode::MONO;
152 mVisible = true;
153
154 // 2D rect stuff
155 ogre2dRect = 0;
156 ogre2dNode = 0;
157 widthScale = 1.0f;
158 heightScale = 1.0f;
159
160 // Overlay stuff
161 zOrder = widgetZOrder;
162 ogreOverlay = 0;
163 ogreOverlayPanel = 0;
164 ogreOverlayMaterial.reset();
165 }
166
168 {
169 // For overlayed widget only
170 if (isOverlayed)
171 {
172 DestroyOverlay();
173 DestroyMaterial();
174 }
175 else if (is2DRect)
176 {
177 Destroy2D();
178 DestroyMaterial();
179 }
180 else
181 {
182 // Reset the original texture name if the widget was created on an existing material
183 if (ogreOriginalTextureUnit)
184 {
185 //update generated materials
186 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
187
188 if (mVisible)
189 {
190 Ogre::LayerBlendModeEx bmode = ogreOriginalTextureUnit->getAlphaBlendMode();
191 ogreTargetTextureUnit->setAlphaOperation(bmode.operation, bmode.source1, bmode.source2, bmode.alphaArg1, bmode.alphaArg2, bmode.factor);
192 ogreTargetTextureUnit->setTextureFiltering(ogreOriginalTextureUnit->getTextureFiltering(Ogre::FT_MIN), ogreOriginalTextureUnit->getTextureFiltering(Ogre::FT_MAG), ogreOriginalTextureUnit->getTextureFiltering(Ogre::FT_MIP));
193
194 ogreTargetTextureUnit->removeAllEffects();
195 Ogre::TextureUnitState::EffectMap effects = ogreOriginalTextureUnit->getEffects();
196 Ogre::TextureUnitState::EffectMap::const_iterator it;
197 for (it = effects.begin(); it != effects.end(); it++)
198 {
199 Ogre::TextureUnitState::TextureEffect effect = it->second;
200 ogreTargetTextureUnit->addEffect(effect);
201 }
202 ogreTargetMaterialPass->setSceneBlending(matData.oSceneBlendingS, matData.oSceneBlendingD);
203 ogreTargetMaterialPass->setDepthWriteEnabled(matData.oDepthWrite);
204
205 try
206 {
207 if (!ogreOriginalTextureUnit->_getTexturePtr())
208 ogreTargetTextureUnit->setBlank();
209 else
210 ogreTargetTextureUnit->setTexture(ogreOriginalTextureUnit->_getTexturePtr());
211 }
212 catch (Ogre::Exception &)
213 {
214 ogreTargetTextureUnit->setTextureName("blackpix.jpg");
215 }
216
217 //Reset materials
218 SMaterial::CleanUpGeneratedTechniques(ogreTargetMaterial.get());
219 }
220
221 OGRE_DELETE(ogreOriginalTextureUnit);
222 OGRE_DELETE(renderingTextureUnit);
223 }
224 }
225
226 // Free rendering texture
227 DestroyTexture();
228
229 if (isOverlayed)
230 SWidgetManager::getSingleton().UpdateWidgetsZOrder(); // Recalculate zOrder of all widgets without this one.
231 else if (!is2DRect)
232 originalMaterial->SetAssociatedWidget(0); // Remove reference to this widget of the material
233 }
234
235 void SWidget::SetCurrentViewport(Ogre::Viewport* vp)
236 {
238 }
239
241 {
242 return scene;
243 }
244
245 std::string SWidget::GetType()
246 {
247 return type;
248 }
249
251 {
252 return compensateNPOT;
253 }
254
255 unsigned short SWidget::GetWidth()
256 {
257 return width;
258 }
259
260 unsigned short SWidget::GetHeight()
261 {
262 return height;
263 }
264
269
270 void SWidget::SetSize(const unsigned short& newWidth, const unsigned short& newHeight)
271 {
272 SetSize(SPoint<unsigned short>(newWidth, newHeight));
273 }
274
276 {
277 if ((width == newSize.x) && (height == newSize.y))
278 return;
279
280 width = newSize.x;
281 height = newSize.y;
283
284 if (ogreOverlay != 0)
285 {
286 ogreOverlayPanel->setDimensions(width, height);
287
288 xCoef.y = width;
289 yCoef.y = height;
290 }
291
292 if (ogre2dRect != 0)
293 {
294 if (currentViewport->getActualWidth() > 5 || currentViewport->getActualHeight() > 5)
295 {
296 Ogre::Real wcoef = 2.0f / currentViewport->getActualWidth();
297 Ogre::Real hcoef = 2.0f / currentViewport->getActualHeight();
298 Ogre::Real w = wcoef * width;
299 Ogre::Real h = hcoef * height;
300 Ogre::Real l = (wcoef * leftPos) - 1.0f;
301 Ogre::Real t = 1.0f - (hcoef * topPos);
302 Ogre::Real r = ((wcoef * leftPos) + w) - 1.0f;
303 Ogre::Real b = 1.0f - ((hcoef * topPos) + h);
304 xCoef.x = l;
305 xCoef.y = r;
306 yCoef.x = t;
307 yCoef.y = b;
308 }
309
310 Ogre::Real l = (xCoef.x * widthScale) + leftOffset;
311 Ogre::Real r = (xCoef.y * widthScale) + leftOffset;
312 Ogre::Real t = (yCoef.x * heightScale) + topOffset;
313 Ogre::Real b = (yCoef.y * heightScale) + topOffset;
314 ogre2dRect->setCorners(l, t, r, b, false);
315
316 Ogre::AxisAlignedBox aabInf;
317 aabInf.setInfinite();
318 ogre2dRect->setBoundingBox(aabInf);
319 };
320 }
321
323 {
324 if ((ogreOverlay != 0) || (ogre2dRect != 0))
325 {
326 return SPoint<int>(leftPos, topPos);
327 }
328 else
329 return SPoint<int>(0, 0);
330 }
331
332 void SWidget::SetPosition(const int& xPos, const int& yPos)
333 {
334 SetPosition(SPoint<int>(xPos, yPos));
335 }
336
337 void SWidget::SetLeftOffset(const float left)
338 {
339 leftOffset = left;
341 }
342
343 void SWidget::SetTopOffset(const float top)
344 {
345 topOffset = top;
347 }
348
350 {
351 SPoint<int> rpos;
352 if (ogreOverlay != 0 || ogre2dRect != 0)
353 {
354 rpos.x = leftPos + (static_cast<int>((float)(currentViewport->getActualWidth() <= 1) ? 1.0f : currentViewport->getActualWidth() * widthScale * leftOffset)) + ((width - static_cast<int>((float)width * widthScale)) / 2);
355 rpos.y = topPos + (static_cast<int>((float)(currentViewport->getActualHeight() <= 1) ? 1.0f : currentViewport->getActualHeight() * heightScale * topOffset)) + ((height - static_cast<int>((float)height * heightScale)) / 2);
356 }
357 else
358 {
359 rpos = GetPosition();
360 }
361
362 return rpos;
363 }
364
366 {
368 if (ogreOverlay != 0 || ogre2dRect != 0)
369 {
370 rsize.x = static_cast<unsigned short>((float)width * widthScale);
371 rsize.y = static_cast<unsigned short>((float)height * heightScale);
372 }
373 else
374 {
375 rsize = GetSize();
376 }
377
378 return rsize;
379 }
380
381 void SWidget::SetPosition(const SPoint<int>& newPosition)
382 {
383 if (ogreOverlay != 0)
384 {
385 leftPos = newPosition.x;
386 topPos = newPosition.y;
387 ogreOverlay->setScale(1.0f, 1.0f);
388 ogreOverlayPanel->_setLeft(0.0f);
389 ogreOverlayPanel->_setTop(0.0f);
390 ogreOverlayPanel->setPosition(static_cast<Ogre::Real> (leftPos), static_cast<Ogre::Real> (topPos));
391
392 if ((leftOffset != 0.0) || (topOffset != 0.0))
393 {
394 //update the real position
395 if (!SRoot::getSingletonPtr()->isDeviceLost())
396 ogreOverlayPanel->_update();
397
398 if (leftOffset != 0.0)
399 {
400 Ogre::Real cleft = ogreOverlayPanel->_getLeft();
401 ogreOverlayPanel->_setLeft(cleft + leftOffset);
402 }
403
404 if (topOffset != 0.0)
405 {
406 Ogre::Real ctop = ogreOverlayPanel->_getTop();
407 ogreOverlayPanel->_setTop(ctop + topOffset);
408 }
409 }
410
411 xCoef = Ogre::Vector2(ogreOverlayPanel->getLeft(), ogreOverlayPanel->getWidth());
412 yCoef = Ogre::Vector2(ogreOverlayPanel->getTop(), ogreOverlayPanel->getHeight());
413
414 //reapply scale
415 ogreOverlay->setScale(widthScale, heightScale);
416 }
417
418 if (ogre2dRect != 0)
419 {
420 leftPos = newPosition.x;
421 topPos = newPosition.y;
422
423 if (currentViewport->getActualWidth() > 5 || currentViewport->getActualHeight() > 5)
424 {
425 Ogre::Real wcoef = 2.0f / currentViewport->getActualWidth();
426 Ogre::Real hcoef = 2.0f / currentViewport->getActualHeight();
427 Ogre::Real w = wcoef * width;
428 Ogre::Real h = hcoef * height;
429 Ogre::Real l = (wcoef * leftPos) - 1.0f;
430 Ogre::Real t = 1.0f - (hcoef * topPos);
431 Ogre::Real r = ((wcoef * leftPos) + w) - 1.0f;
432 Ogre::Real b = 1.0f - ((hcoef * topPos) + h);
433 xCoef.x = l;
434 xCoef.y = r;
435 yCoef.x = t;
436 yCoef.y = b;
437 }
438
439 Ogre::Real l = (xCoef.x * widthScale) + leftOffset;
440 Ogre::Real r = (xCoef.y * widthScale) + leftOffset;
441 Ogre::Real t = (yCoef.x * heightScale) + topOffset;
442 Ogre::Real b = (yCoef.y * heightScale) + topOffset;
443 ogre2dRect->setCorners(l, t, r, b, false);
444
445 Ogre::AxisAlignedBox aabInf;
446 aabInf.setInfinite();
447 ogre2dRect->setBoundingBox(aabInf);
448 }
449 }
450
452 {
453 return textureRatio;
454 }
455
456 void SWidget::SetTextureRatio(const float& newRatio)
457 {
458 if (textureRatio != newRatio)
459 {
460 textureRatio = newRatio;
461
462 if (type != "BitmapWidget")
464 }
465 }
466
467 void SWidget::Move(const SPoint<int>& relativeMove)
468 {
469 // Move the widget
470 SetPosition(SPoint<int>(leftPos + relativeMove.x, topPos + relativeMove.y));
471 }
472
473 void SWidget::SetScale(const float width, const float height)
474 {
475 widthScale = width;
476 heightScale = height;
477
478 // Scale the widget
479 if (ogreOverlay != 0)
480 ogreOverlay->setScale(widthScale, heightScale);
481 else if (ogre2dRect != 0)
482 {
484 }
485 }
486
488 {
489 return SPoint<float>(widthScale, heightScale);
490 }
491
492 void SWidget::SetZOrder(const unsigned short& newWidgetOrder)
493 {
494 zOrder = newWidgetOrder;
495
496 // Update other widgets if needed.
497 if (isOverlayed)
499 }
500
501 unsigned short SWidget::GetZOrder()
502 {
503 return zOrder;
504 }
505
506 void SWidget::CreateTexture(bool alpha)
507 {
508 // Erase existing texture (texture reset in case of re-creation).
509 DestroyTexture();
510
511 const Ogre::RenderSystemCapabilities* caps = SRoot::getSingleton().GetOgreRenderSystem()->getCapabilities();
512
513 if (caps && (!caps->hasCapability(Ogre::RSC_NON_POWER_OF_2_TEXTURES)))
514 compensateNPOT = true;
515
516 if (type != "BitmapWidget")
517 {
518 if (compensateNPOT)
519 {
520 mTextureWidth = Ogre::Bitwise::firstPO2From(static_cast <unsigned short>(width * textureRatio)) / 2;
521 mTextureHeight = Ogre::Bitwise::firstPO2From(static_cast <unsigned short>(height * textureRatio)) / 2;
522 }
523 else
524 {
525 mTextureWidth = static_cast <unsigned short>(width * textureRatio);
526 mTextureHeight = static_cast <unsigned short>(height * textureRatio);
527 }
528 }
529 else
530 {
531 if (compensateNPOT)
532 {
533 mTextureWidth = Ogre::Bitwise::firstPO2From(static_cast <unsigned short>(mTextureWidth * textureRatio));
534 mTextureHeight = Ogre::Bitwise::firstPO2From(static_cast <unsigned short>(mTextureHeight * textureRatio));
535
536#if defined(ANDROID) || defined(APPLE_IOS) || defined(RPI)
537 if (mTextureWidth > 512 || mTextureHeight > 512)
538 {
541 }
542#endif
543 }
544 else
545 {
546 mTextureWidth = static_cast <unsigned short>(mTextureWidth * textureRatio);
547 mTextureHeight = static_cast <unsigned short>(mTextureHeight * textureRatio);
548 }
549 }
550
551 // Check if size is not null
552 mTextureWidth = std::max<unsigned short>(mTextureWidth, 1);
553 mTextureHeight = std::max<unsigned short>(mTextureHeight, 1);
554
555 // no too high texture size
556 /*if (compensateNPOT)
557 {
558 mTextureWidth = std::min<unsigned short>(mTextureWidth, 768);
559 mTextureHeight = std::min<unsigned short>(mTextureHeight, 768);
560 }*/
561
562 MMechostr(MSKDEBUG, ">>>> Widget texture creation : %ix%i", mTextureWidth, mTextureHeight);
563 // Create the texture
564 try
565 {
566 Ogre::PixelFormat format = Ogre::PF_A8R8G8B8;
567 SRoot::getSingleton().GetRttPixelFormat(format, alpha);
568
569/*#if defined(APPLE_IOS)
570 Ogre::PixelFormat format = ((alpha == false) && Ogre::TextureManager::getSingleton().isFormatSupported(Ogre::TEX_TYPE_2D, Ogre::PF_BYTE_RGB, Ogre::TU_DYNAMIC)) ? Ogre::PF_BYTE_RGB : Ogre::PF_BYTE_RGBA;
571#else
572 Ogre::PixelFormat format = ((alpha == false) && Ogre::TextureManager::getSingleton().isFormatSupported(Ogre::TEX_TYPE_2D, Ogre::PF_BYTE_BGR, Ogre::TU_DYNAMIC)) ? Ogre::PF_BYTE_BGR : Ogre::PF_BYTE_BGRA;
573#endif*/
574 std::string grpName = (ogreTargetTextureUnit != 0) ? ogreTargetTextureUnit->getParent()->getResourceGroup() : SO3_INTERNAL_RESOURCE_GROUP;
575 renderingTexture = Ogre::TextureManager::getSingleton().createManual(baseResourceName + "/Texture/" + name, grpName, Ogre::TEX_TYPE_2D, mTextureWidth, mTextureHeight, 0, format, Ogre::TU_DYNAMIC, this);
576 }
577 catch (Ogre::Exception &e)
578 {
579 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage("An exception has occurred: " + e.getDescription());
580 renderingTexture.reset();
581 }
582
584 {
585 // Initialise pixel buffer
586 Ogre::HardwarePixelBufferSharedPtr pixelBuffer = renderingTexture->getBuffer();
587 pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
588 const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
589 unsigned int textureDepth = Ogre::PixelUtil::getNumElemBytes(pixelBox.format);
590 unsigned int texturePitch = (pixelBox.rowPitch*textureDepth);
591 memset(pixelBox.data, 0, mTextureHeight*texturePitch);
592 pixelBuffer->unlock();
593
594 // Apply on existing material
595 if (ogreTargetTextureUnit != 0)
596 {
597 //apply on backup for hide
598 renderingTextureUnit->setTextureName(baseResourceName + "/Texture/" + name);
599 renderingTextureUnit->setTexture(renderingTexture);
600 renderingTextureUnit->removeAllEffects();
601
602#ifndef APPLE_IOS
603 renderingTextureUnit->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
604#else
605 renderingTextureUnit->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
606 renderingTextureUnit->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
607#endif
608
609 if (mVisible)
610 {
611 ogreTargetTextureUnit->removeAllEffects();
612#ifndef APPLE_IOS
613 ogreTargetTextureUnit->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
614#else
615 ogreTargetTextureUnit->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
616 ogreTargetTextureUnit->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
617#endif
618 if (!renderingTexture)
619 ogreTargetTextureUnit->setBlank();
620 else
621 ogreTargetTextureUnit->setTexture(renderingTexture);
622
623 //update generated materials
624 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
625 }
626
627 //remove generated techniques to let them update
628 Ogre::Material* mat = ogreTargetTextureUnit->getParent()->getParent()->getParent();
629 std::vector<Ogre::Technique*> techs = mat->getTechniques();
630 for (unsigned int i = 0; i < techs.size(); i++)
631 {
632 if (techs[i]->getSchemeName().find("/Ssao/") != Ogre::String::npos)
633 mat->removeTechnique(i);
634 }
635 }
636 else
637 {
638 if (ogreOverlayMaterial)
639 {
640 if (!renderingTexture)
641 ogreOverlayMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setBlank();
642 else
643 ogreOverlayMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTexture(renderingTexture);
644 }
645 }
646 }
647 }
648
649 void SWidget::DestroyTexture()
650 {
651 // Destroy internal rendering texture
653 {
654 renderingTexture->unload();
655 //renderingTexture->setManuallyLoaded(false);
656 // Tell the texture manager that we want to unload the texture, and set the shared pointer to null ask for texture total destruction.
657 Ogre::TextureManager::getSingleton().remove(renderingTexture->getHandle());
658 renderingTexture.reset();
659 }
660 }
661
662 void SWidget::CreateOverlay()
663 {
664 assert(ogreOverlayMaterial);
665
666 // Erase existing panels and overlays (reset in case of re-creation).
667 DestroyOverlay();
668
669 // Create overlay.
670 ogreOverlayPanel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", baseResourceName + "/Overlays/Panels/" + name));
671 ogreOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
672 ogreOverlayPanel->setMaterialName(ogreOverlayMaterial->getName());
673 ogreOverlayPanel->setDimensions(width, height);
674
675 ogreOverlay = Ogre::OverlayManager::getSingleton().create(baseResourceName + "/Overlays/" + name);
676 ogreOverlay->add2D(ogreOverlayPanel);
677
678 SetPosition(SPoint<int>(leftPos, topPos));
679 ogreOverlay->show();
680 }
681
682 void SWidget::DestroyOverlay()
683 {
684 if (ogreOverlayPanel != 0)
685 {
686 Ogre::OverlayManager::getSingleton().destroyOverlayElement(ogreOverlayPanel);
687 ogreOverlayPanel = 0;
688 }
689
690 if (ogreOverlay != 0)
691 {
692 Ogre::OverlayManager::getSingleton().destroy(ogreOverlay);
693 ogreOverlay = 0;
694 }
695 }
696
697 void SWidget::Create2D()
698 {
699 assert(ogreOverlayMaterial);
700
701 // Erase existing 2D rect (reset in case of re-creation).
702 Destroy2D();
703
704 // Create overlay.
705 ogre2dRect = new Ogre::Rectangle2D(true);
706 SetPosition(SPoint<int>(leftPos, topPos));
707 ogre2dRect->setMaterial(ogreOverlayMaterial);
708 ogre2dRect->setCastShadows(false);
709
710 // Render the background before everything else
711 ogre2dRect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
712
713 // Use infinite AAB to always stay visible
714 Ogre::AxisAlignedBox aabInf;
715 aabInf.setInfinite();
716 ogre2dRect->setBoundingBox(aabInf);
717 ogre2dRect->setVisibilityFlags(1 << 11);
718
719 // Attach background to the scene
720 ogre2dNode = scene->GetOgreScenePointer()->getRootSceneNode()->createChildSceneNode(baseResourceName + "/Background/" + name);
721 ogre2dNode->attachObject(ogre2dRect);
722
723 ogre2dRect->setRenderingDistance(0.0f);
724 ogre2dRect->setRenderingMinPixelSize(0.0f);
725 }
726
727 void SWidget::Destroy2D()
728 {
729 if (ogre2dRect != 0)
730 {
731 ogre2dRect->detachFromParent();
732 scene->GetOgreScenePointer()->getRootSceneNode()->removeChild(ogre2dNode);
733 scene->GetOgreScenePointer()->destroySceneNode(ogre2dNode);
734 delete(ogre2dRect);
735 ogre2dRect = 0;
736 ogre2dNode = 0;
737 }
738 }
739
740 void SWidget::CreateMaterial()
741 {
742 assert((isOverlayed == true) || (is2DRect == true));
743
744 // Erase existing material (reset in case of re-creation).
745 DestroyMaterial();
746
747 // Create the material that will be use by the overlay panel
748 ogreOverlayMaterial = Ogre::MaterialManager::getSingleton().create(baseResourceName + "/Overlays/Panels/Materials/" + name, SO3_INTERNAL_RESOURCE_GROUP);
749 Ogre::Pass* matPass = ogreOverlayMaterial->getTechnique(0)->getPass(0);
750 renderingTextureUnit = matPass->createTextureUnitState();
751
752#ifndef APPLE_IOS
753 renderingTextureUnit->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
754 renderingTextureUnit->setTextureFiltering(Ogre::TFO_BILINEAR);
755#else
756 renderingTextureUnit->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
757 renderingTextureUnit->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
758#endif
759
760 //set shaders
761 try
762 {
763 matPass->setVertexProgram("SO3/VS/OVERLAY", true);
764 matPass->setFragmentProgram("SO3/FP/OVERLAY", true);
765 }
766 catch (Ogre::Exception &e)
767 {
768 MMechostr(MSKDEBUG, "Warning : Overlay programm not found : %s", e.what());
769 }
770
771 try
772 {
773 if (!renderingTexture)
774 renderingTextureUnit->setTextureName("blackpix.jpg");
775 else
776 renderingTextureUnit->setTexture(renderingTexture);
777
778 renderingTextureUnit->setNumMipmaps(0);
779 }
780 catch (Ogre::Exception&)
781 {
782 }
783
784 if (is2DRect)
785 {
786 matPass->setDepthCheckEnabled(false);
787 matPass->setDepthWriteEnabled(false);
788 matPass->setLightingEnabled(false);
789 ogreOverlayMaterial->setReceiveShadows(false);
790 }
791
792 ApplyMaterialParameters(matPass, renderingTextureUnit);
793 }
794
795 void SWidget::DestroyMaterial()
796 {
797 if (ogreOverlayMaterial)
798 {
799 SMaterial::CleanUpGeneratedTechniques(ogreOverlayMaterial.get());
800 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
801
802 // Tell the material manager that we want to unload the material, and set the shared pointer to null ask for material total destruction.
803 ogreOverlayMaterial->unload();
804 Ogre::MaterialManager::getSingletonPtr()->remove(ogreOverlayMaterial->getHandle());
805 ogreOverlayMaterial.reset();
806 renderingTextureUnit = 0;
807 }
808 }
809
810 void SWidget::ApplyMaterialParameters(Ogre::Pass* materialPassToModify, Ogre::TextureUnitState* materialTextureUnitToModify)
811 {
812 assert((materialPassToModify != 0) && (materialTextureUnitToModify != 0));
813 //keep last param for material hide / show and use ogreTargetTextureUnit to check;
814 if (isOverlayed || is2DRect || ((isTransparent || (opacity != 1.0f)) && (materialPassToModify->getTextureUnitStateIndex(materialTextureUnitToModify) == 0)))
815 {
816 if (mVisible || isOverlayed || is2DRect)
817 {
818 materialPassToModify->setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);
819 materialPassToModify->setDepthWriteEnabled(false);
820 }
821 }
822 else
823 {
824 if (isOverlayed || is2DRect || mVisible)
825 materialPassToModify->setSceneBlending((isTransparent || (opacity != 1.0f)) ? Ogre::SBT_TRANSPARENT_ALPHA : Ogre::SBT_REPLACE);
826
827 if (!isTransparent && (opacity == 1.0f) && (!is2DRect))
828 if (materialPassToModify->getTextureUnitStateIndex(materialTextureUnitToModify) == 0)
829 {
830 if (mVisible || isOverlayed)
831 materialPassToModify->setDepthWriteEnabled(true);
832 }
833 }
834
835 if (isOverlayed || is2DRect || mVisible)
836 {
837#ifndef APPLE_IOS
838 materialTextureUnitToModify->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
839 materialTextureUnitToModify->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
840#else
841 materialTextureUnitToModify->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
842 materialTextureUnitToModify->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
843#endif
844 }
845
846 if (isOverlayed || is2DRect)
847 {
848 try
849 {
850 if (materialPassToModify->hasFragmentProgram())
851 {
852 Ogre::GpuProgramParametersSharedPtr fparams = materialPassToModify->getFragmentProgramParameters();
853 fparams->setNamedConstant("opacity", opacity);
854 }
855 }
856 catch (Ogre::Exception &)
857 {
858 //error
859 }
860 }
861 else // custom material
862 {
863 if (mVisible)
864 {
865 materialTextureUnitToModify->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);
866 }
867 }
868 }
869
870 void SWidget::loadResource(Ogre::Resource* resource)
871 {
872 /*Ogre::Texture* tex = static_cast<Ogre::Texture*>(resource);
873 tex->setTextureType(Ogre::TEX_TYPE_2D);
874 tex->setWidth(mTextureWidth);
875 tex->setHeight(mTextureHeight);
876 tex->setNumMipmaps(0);
877 tex->setFormat(Ogre::PF_BYTE_BGRA);
878 tex->setUsage(Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
879 tex->createInternalResources();*/
881 }
882
883 void SWidget::_SetOgreOverlayZOrder(const unsigned short& overlayZOrder)
884 {
885 assert(ogreOverlay != 0);
886 ogreOverlay->setZOrder(overlayZOrder);
887 }
888
889 void SWidget::SetTopOnFocus(const bool& enableWidgetTopOnFocus)
890 {
891 topOnFocus = enableWidgetTopOnFocus;
892 }
893
895 {
896 return topOnFocus;
897 }
898
899 void SWidget::SetForeground(const bool& enableWidgetForeground)
900 {
901 isPriorized = enableWidgetForeground;
903 }
904
906 {
907 return isPriorized;
908 }
909
914
916 {
917 if (this == SWidgetManager::getSingleton().GetFocusedWidget())
919 }
920
922 {
923 if (SWidgetManager::getSingleton().GetFocusedWidget() == this)
924 return true;
925 else
926 return false;
927 }
928
930 {
931 return mouseIsOver;
932 }
933
935 {
936 bool found = false;
937 for (unsigned int i = 0; i < inputIndexes.size() && !found; i++)
938 found = (inputIndexes[i] == id) ? true : false;
939
940 return found;
941 }
942
943 void SWidget::SetInputOver(int id, bool state)
944 {
945 if (state)
946 {
947 if (!GetInputOver(id))
948 inputIndexes.push_back(id);
949 }
950 else
951 {
952 bool found = false;
953 for (unsigned int i = 0; i < inputIndexes.size() && !found; i++)
954 {
955 found = (inputIndexes[i] == id) ? true : false;
956 if (found)
957 inputIndexes.erase(inputIndexes.begin() + i);
958 }
959 }
960 mouseIsOver = (inputIndexes.size() > 0) ? true : false;
961 }
962
963 void SWidget::SetOpacity(const float& widgetOpacity)
964 {
965 // Bound opacity values between 0 and 1.
966 if (widgetOpacity > 1.0f)
967 opacity = 1.0f;
968 else if (widgetOpacity < 0)
969 opacity = 0.0f;
970 else
971 opacity = widgetOpacity;
972
973 if ((isOverlayed) || (is2DRect))
974 {
975 ApplyMaterialParameters(ogreOverlayMaterial->getTechnique(0)->getPass(0), renderingTextureUnit);
976 }
977 else
978 {
979 ApplyMaterialParameters(ogreTargetMaterialPass, ogreTargetTextureUnit);
980 //update generated materials
981 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
982 }
983 }
984
986 {
987 return opacity;
988 }
989
990 void SWidget::Show(const bool& fade, const unsigned short& fadeDurationMS)
991 {
992 if (mVisible)
993 return;
994
995 mVisible = true;
996
997 if (isOverlayed)
998 {
999 ogreOverlay->show();
1000 }
1001 else if (is2DRect)
1002 {
1003 ogre2dRect->setVisible(true);
1004 }
1005 else
1006 {
1007 // Reset the original texture name if the widget was created on an existing material
1008 if (ogreOriginalTextureUnit)
1009 {
1010 if (ogreTargetTextureUnit != 0)
1011 {
1012 Ogre::LayerBlendModeEx bmode = renderingTextureUnit->getAlphaBlendMode();
1013 ogreTargetTextureUnit->setAlphaOperation(bmode.operation, bmode.source1, bmode.source2, bmode.alphaArg1, bmode.alphaArg2, bmode.factor);
1014 ogreTargetTextureUnit->setTextureFiltering(renderingTextureUnit->getTextureFiltering(Ogre::FT_MIN), renderingTextureUnit->getTextureFiltering(Ogre::FT_MAG), renderingTextureUnit->getTextureFiltering(Ogre::FT_MIP));
1015
1016 ogreTargetTextureUnit->removeAllEffects();
1017 Ogre::TextureUnitState::EffectMap effects = renderingTextureUnit->getEffects();
1018 Ogre::TextureUnitState::EffectMap::const_iterator it;
1019 for (it = effects.begin(); it != effects.end(); it++)
1020 {
1021 Ogre::TextureUnitState::TextureEffect effect = it->second;
1022 ogreTargetTextureUnit->addEffect(effect);
1023 }
1024
1025 if (!renderingTextureUnit->_getTexturePtr())
1026 ogreTargetTextureUnit->setBlank();
1027 else
1028 ogreTargetTextureUnit->setTexture(renderingTextureUnit->_getTexturePtr());
1029
1030 ApplyMaterialParameters(ogreTargetMaterialPass, ogreTargetTextureUnit);
1031 }
1032
1033 //update generated materials
1034 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
1035 }
1036 }
1037
1038 // Unfocus this widget if it's the last focused.
1039 if (this == SWidgetManager::getSingleton().GetFocusedWidget())
1041 }
1042
1043 void SWidget::Hide(const bool& fade, const unsigned short& fadeDurationMS)
1044 {
1045 if (!mVisible)
1046 return;
1047
1048 if (isOverlayed)
1049 {
1050 ogreOverlay->hide();
1051 }
1052 else if (is2DRect)
1053 {
1054 ogre2dRect->setVisible(false);
1055 }
1056 else
1057 {
1058 if (ogreOriginalTextureUnit)
1059 {
1060 Ogre::LayerBlendModeEx bmode = ogreOriginalTextureUnit->getAlphaBlendMode();
1061 ogreTargetTextureUnit->setAlphaOperation(bmode.operation, bmode.source1, bmode.source2, bmode.alphaArg1, bmode.alphaArg2, bmode.factor);
1062 ogreTargetTextureUnit->setTextureFiltering(ogreOriginalTextureUnit->getTextureFiltering(Ogre::FT_MIN), ogreOriginalTextureUnit->getTextureFiltering(Ogre::FT_MAG), ogreOriginalTextureUnit->getTextureFiltering(Ogre::FT_MIP));
1063
1064 ogreTargetTextureUnit->removeAllEffects();
1065 Ogre::TextureUnitState::EffectMap effects = ogreOriginalTextureUnit->getEffects();
1066 Ogre::TextureUnitState::EffectMap::const_iterator it;
1067 for (it = effects.begin(); it != effects.end(); it++)
1068 {
1069 Ogre::TextureUnitState::TextureEffect effect = it->second;
1070 ogreTargetTextureUnit->addEffect(effect);
1071 }
1072
1073 ogreTargetMaterialPass->setSceneBlending(matData.oSceneBlendingS, matData.oSceneBlendingD);
1074 ogreTargetMaterialPass->setDepthWriteEnabled(matData.oDepthWrite);
1075
1076 try
1077 {
1078 if (!ogreOriginalTextureUnit->_getTexturePtr())
1079 ogreTargetTextureUnit->setBlank();
1080 else
1081 ogreTargetTextureUnit->setTexture(ogreOriginalTextureUnit->_getTexturePtr());
1082 }
1083 catch(Ogre::Exception &)
1084 {
1085 ogreTargetTextureUnit->setTextureName("blackpix.jpg");
1086 }
1087
1088 //update generated materials
1089 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
1090 }
1091 }
1092 mVisible = false;
1093 }
1094
1096 {
1097 return mVisible;
1098 }
1099
1100 void SWidget::SetTransparency(const bool& enableTransparency)
1101 {
1102 if (enableTransparency != isTransparent)
1103 {
1104 isTransparent = enableTransparency;
1105 SetTransparencyImpl(isTransparent);
1106
1107 if ((isOverlayed) || (is2DRect))
1108 {
1109 ApplyMaterialParameters(ogreOverlayMaterial->getTechnique(0)->getPass(0), renderingTextureUnit);
1110 }
1111 else
1112 {
1113 ApplyMaterialParameters(ogreTargetMaterialPass, ogreTargetTextureUnit);
1114 //update generated materials
1115 SRoot::getSingletonPtr()->RemoveGeneratedMaterial(ogreTargetMaterial.get());
1116 }
1117 }
1118 }
1119
1121 {
1122 return isTransparent;
1123 }
1124
1125 void SWidget::SetKeyboardEnable(const bool& enableKeyboardOnWidget)
1126 {
1127 keyboardEnable = enableKeyboardOnWidget;
1128 SetKeyboardEnableImpl(enableKeyboardOnWidget);
1129 }
1130
1132 {
1133 return keyboardEnable;
1134 }
1135
1136 void SWidget::SetMouseEnable(const bool& enableMouseOnWidget)
1137 {
1138 mouseEnable = enableMouseOnWidget;
1139 SetMouseEnableImpl(enableMouseOnWidget);
1140 }
1141
1143 {
1144 return mouseEnable;
1145 }
1146
1147 std::string SWidget::CheckUrl(const std::string& url)
1148 {
1149 std::string httpPrefix = "http://";
1150 std::string httpsPrefix = "https://";
1151 std::string ftpPrefix = "ftp://";
1152 std::string filePrefix = "file://";
1153
1154 std::string urlString = url;
1155 boost::to_lower(urlString);
1156
1157 // Add "http://" if needed.
1158 if ((urlString.substr(0, httpPrefix.length()) != httpPrefix)
1159 && (urlString.substr(0, httpsPrefix.length()) != httpsPrefix)
1160 && (urlString.substr(0, ftpPrefix.length()) != ftpPrefix)
1161 && (urlString.substr(0, filePrefix.length()) != filePrefix))
1162 {
1163 urlString = httpPrefix + url;
1164 }
1165 else
1166 {
1167 urlString = url;
1168 }
1169
1170 return urlString;
1171 }
1172
1173 void SWidget::SetIgnoreTransparentPixels(const bool& widgetIgnoreTransparentPixels, const float& tresholdColor)
1174 {
1175 transparentIgnorePixels = widgetIgnoreTransparentPixels;
1176 transparentTresholdColor = tresholdColor;
1177 }
1178
1180 {
1181 return transparentIgnorePixels;
1182 }
1183
1188
1190 {
1191 return updateOnFocusOnly;
1192 }
1193
1194 void SWidget::SetUpdateOnFocusOnly(const bool& activate)
1195 {
1196 updateOnFocusOnly = activate;
1197 }
1198
1200 {
1201 return isOverlayed;
1202 }
1203
1205 {
1206 return is2DRect;
1207 }
1208
1210 {
1211 return mStereoMode != StereoMode::MONO;
1212 }
1213
1215 {
1216 if (mStereoMode == state)
1217 return;
1218
1219 mStereoMode = state;
1220 if (mStereoMode != StereoMode::MONO)
1221 {
1222 SetStereoEye();
1223 }
1224 else
1225 {
1226 if (isOverlayed)
1227 ogreOverlayPanel->setUV(0.0f, 0.0f, 1.0f, 1.0f);
1228 else if (is2DRect)
1229 ogre2dRect->setDefaultUVs();
1230 }
1231 }
1232
1233 void SWidget::SetStereoEye(bool isleft)
1234 {
1235 if (mStereoMode != StereoMode::MONO)
1236 {
1237 if (mStereoMode == StereoMode::SBS)
1238 {
1239 if (isOverlayed)
1240 {
1241 if (isleft)
1242 ogreOverlayPanel->setUV(0.0f, 0.0f, 0.5f, 1.0f);
1243 else
1244 ogreOverlayPanel->setUV(0.5f, 0.0f, 1.0f, 1.0f);
1245 }
1246 else if (is2DRect)
1247 {
1248 if (isleft)
1249 ogre2dRect->setUVs(Ogre::Vector2(0.0f, 0.0f), Ogre::Vector2(0.0f, 1.0f), Ogre::Vector2(0.5f, 0.0f), Ogre::Vector2(0.5f, 1.0f));
1250 else
1251 ogre2dRect->setUVs(Ogre::Vector2(0.5f, 0.0f), Ogre::Vector2(0.5f, 1.0f), Ogre::Vector2(1.0f, 0.0f), Ogre::Vector2(1.0f, 1.0f));
1252 }
1253 }
1254 else if (mStereoMode == StereoMode::TB)
1255 {
1256 if (isOverlayed)
1257 {
1258 if (isleft)
1259 ogreOverlayPanel->setUV(0.0f, 0.0f, 1.0f, 0.5f);
1260 else
1261 ogreOverlayPanel->setUV(0.0f, 0.5f, 1.0f, 1.0f);
1262 }
1263 else if (is2DRect)
1264 {
1265 if (isleft)
1266 ogre2dRect->setUVs(Ogre::Vector2(0.0f, 0.0f), Ogre::Vector2(0.0f, 0.5f), Ogre::Vector2(1.0f, 0.0f), Ogre::Vector2(1.0f, 0.5f));
1267 else
1268 ogre2dRect->setUVs(Ogre::Vector2(0.0f, 0.5f), Ogre::Vector2(0.0f, 1.0f), Ogre::Vector2(1.0f, 0.5f), Ogre::Vector2(1.0f, 1.0f));
1269 }
1270 }
1271 else if (mStereoMode == StereoMode::BT)
1272 {
1273 if (isOverlayed)
1274 {
1275 if (isleft)
1276 ogreOverlayPanel->setUV(0.0f, 0.5f, 1.0f, 1.0f);
1277 else
1278 ogreOverlayPanel->setUV(0.0f, 0.0f, 1.0f, 0.5f);
1279 }
1280 else if (is2DRect)
1281 {
1282 if (isleft)
1283 ogre2dRect->setUVs(Ogre::Vector2(0.0f, 0.5f), Ogre::Vector2(0.0f, 1.0f), Ogre::Vector2(1.0f, 0.5f), Ogre::Vector2(1.0f, 1.0f));
1284 else
1285 ogre2dRect->setUVs(Ogre::Vector2(0.0f, 0.0f), Ogre::Vector2(0.0f, 0.5f), Ogre::Vector2(1.0f, 0.0f), Ogre::Vector2(1.0f, 0.5f));
1286 }
1287 }
1288 }
1289 }
1290
1292 {
1293 return 0;
1294 }
1295
1296}
void * HCURSOR
Definition SO3Android.h:60
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
std::string name
Definition SO3DataScol.h:44
void SetAssociatedWidget(SWidget *newAssociatedWidget)
void CleanUpGeneratedTechniques()
Ogre::MaterialPtr getOgreMaterialPointer()
NUMERIC_TYPE y
Definition SO3Point.h:40
NUMERIC_TYPE x
Definition SO3Point.h:39
bool GetRttPixelFormat(Ogre::PixelFormat &format, bool alpha=false, bool floattex=false)
Definition SO3Root.cpp:650
Ogre::RenderSystem * GetOgreRenderSystem()
Definition SO3Root.cpp:865
void RemoveGeneratedMaterial(Ogre::Material *mat)
Definition SO3Root.cpp:2343
static SRoot & getSingleton()
Definition SO3Root.cpp:116
static SRoot * getSingletonPtr()
Definition SO3Root.cpp:111
Ogre::SceneManager * GetOgreScenePointer()
Definition SO3Scene.cpp:449
Ogre::Viewport * GetOgreViewPortPointer()
Ogre::SceneBlendFactor oSceneBlendingD
Definition SO3Widget.h:68
Ogre::SceneBlendFactor oSceneBlendingS
Definition SO3Widget.h:67
bool GetIsStereo()
virtual void SetSizeImpl(const unsigned short &newWidth, const unsigned short &newHeight)=0
bool forceRenderingUpdate
Definition SO3Widget.h:89
bool GetMouseEnable()
Ogre::Vector2 yCoef
Definition SO3Widget.h:93
void SetScale(const float width, const float height)
unsigned short GetHeight()
unsigned short GetWidth()
virtual void loadResource(Ogre::Resource *resource)
float GetTextureRatio()
float topOffset
Definition SO3Widget.h:79
bool GetInputOver(int id)
virtual void SetMouseEnableImpl(const bool &enableMouseOnWidget)=0
bool GetIsOverlayed()
virtual void SetTransparencyImpl(const bool &enableTransparency)=0
void SetUpdateOnFocusOnly(const bool &activate)
bool GetIs2DRect()
SPoint< int > GetRealPixelPosition()
bool GetForeground()
void SetStereoEye(bool isleft=true)
float transparentTresholdColor
Definition SO3Widget.h:90
bool GetMouseOver()
Ogre::Vector2 xCoef
Definition SO3Widget.h:92
bool HasFocus()
void Move(const SPoint< int > &relativeMove)
void Show(const bool &fade=false, const unsigned short &fadeDurationMS=300)
void SetTopOffset(const float top)
float GetIgnoreTransparentPixelsTreshold()
SPoint< int > GetPosition()
void TakeFocus()
bool GetTopOnFocus()
void SetMouseEnable(const bool &enableMouseOnWidget)
std::string CheckUrl(const std::string &url)
unsigned short width
Definition SO3Widget.h:80
bool GetKeyboardEnable()
void Hide(const bool &fade=false, const unsigned short &fadeDurationMS=300)
void SetInputOver(int id, bool state)
Ogre::TexturePtr renderingTexture
Definition SO3Widget.h:88
float GetOpacity()
void SetTransparency(const bool &enableTransparency)
unsigned short height
Definition SO3Widget.h:81
void SetKeyboardEnable(const bool &enableKeyboardOnWidget)
void SetTopOnFocus(const bool &enableWidgetTopOnFocus)
void SetPosition(const int &xPos, const int &yPos)
virtual ~SWidget()
bool GetTransparency()
bool IsCompensateNPOT() const
Ogre::Viewport * currentViewport
Definition SO3Widget.h:87
unsigned short mTextureWidth
The actual texture width allocated in ogre.
Definition SO3Widget.h:82
void SetTextureRatio(const float &newRatio)
SViewPort * viewport
Definition SO3Widget.h:86
void SetOpacity(const float &widgetOpacity)
bool compensateNPOT
Use to indicate if the texture size has be rounded to an exact pow2.
Definition SO3Widget.h:91
bool GetVisible()
void SetZOrder(const unsigned short &newWidgetOrder)
SScene * scene
Definition SO3Widget.h:85
float textureRatio
Texture ratio compared to widget size, usually 1.0.
Definition SO3Widget.h:84
std::string baseResourceName
Definition SO3Widget.h:75
void ReleaseFocus()
bool GetIgnoreTransparentPixels()
void SetForeground(const bool &enableWidgetForeground)
unsigned short mTextureHeight
The actual texture height allocated in ogre.
Definition SO3Widget.h:83
std::string GetType()
void CreateTexture(bool alpha=true)
void SetStereo(StereoMode state)
unsigned short GetZOrder()
void SetLeftOffset(const float left)
virtual void SetKeyboardEnableImpl(const bool &enableKeyboardOnWidget)=0
float leftOffset
Definition SO3Widget.h:78
void SetSize(const unsigned short &newWidth, const unsigned short &newHeight)
SPoint< unsigned short > GetSize()
void SetCurrentViewport(Ogre::Viewport *vp)
SScene * GetParentScene()
virtual HCURSOR GetCurrentMouseCursor()
SPoint< float > GetScale()
bool GetUpdateOnFocusOnly()
SPoint< unsigned short > GetRealPixelSize()
void SetIgnoreTransparentPixels(const bool &widgetIgnoreTransparentPixels, const float &tresholdColor=0.0f)
void UpdateFocusedWidget(SWidget *focusTargetedWidget)
static SWidgetManager & getSingleton()
unsigned int prevPOW2(unsigned int x)
Definition SO3Widget.cpp:43