[Orxonox-commit 7192] r11809 - in code/branches/cegui0.8_ogre1.9: data/gui/scripts src/libraries/core

landauf at orxonox.net landauf at orxonox.net
Sat Feb 24 16:58:39 CET 2018


Author: landauf
Date: 2018-02-24 16:58:39 +0100 (Sat, 24 Feb 2018)
New Revision: 11809

Modified:
   code/branches/cegui0.8_ogre1.9/data/gui/scripts/GUITools.lua
   code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.cc
   code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.h
Log:
added work around for a bug in cegui 0.8 (the cegui lua scripts expect a "Font*" pointer to call getTextExtent(), but cegui 0.8 only returns "const Font*")

Modified: code/branches/cegui0.8_ogre1.9/data/gui/scripts/GUITools.lua
===================================================================
--- code/branches/cegui0.8_ogre1.9/data/gui/scripts/GUITools.lua	2018-02-24 15:00:22 UTC (rev 11808)
+++ code/branches/cegui0.8_ogre1.9/data/gui/scripts/GUITools.lua	2018-02-24 15:58:39 UTC (rev 11809)
@@ -30,9 +30,14 @@
     local size = {}
 
     local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
-    local height = window:getFont():getLineSpacing() + window:getUnclippedOuterRect():get():getHeight() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getHeight()
-    local width =  window:getFont():getTextExtent(window:getText()) + window:getUnclippedOuterRect():get():getWidth() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getWidth()
 
+    local lineSpacing = window:getFont():getLineSpacing()
+    --local textExtent = window:getFont():getTextExtent(window:getText())
+    local textExtent = orxonox.GUIManager:getFontTextExtent(window:getFont(), window:getText()) -- workaround for bug in cegui lua scripts
+    
+    local height = lineSpacing + window:getUnclippedOuterRect():get():getHeight() - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getHeight()
+    local width  = textExtent  + window:getUnclippedOuterRect():get():getWidth()  - lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window):getWidth()
+
     table.insert(size, height)
     table.insert(size, width)
     return size

Modified: code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.cc	2018-02-24 15:00:22 UTC (rev 11808)
+++ code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.cc	2018-02-24 15:58:39 UTC (rev 11809)
@@ -971,4 +971,8 @@
 #endif
     }
 
+    /*static*/ float GUIManager::getFontTextExtent(const CEGUI::Font* font, const std::string& text, float x_scale)
+    {
+        return font->getTextExtent(text, x_scale);
+    }
 }

Modified: code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.h	2018-02-24 15:00:22 UTC (rev 11808)
+++ code/branches/cegui0.8_ogre1.9/src/libraries/core/GUIManager.h	2018-02-24 15:58:39 UTC (rev 11809)
@@ -142,6 +142,7 @@
         static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); // tolua_export
         static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); // tolua_export
         static void addFontHelper(const std::string& name, int size, const std::string& fontName); // tolua_export
+        static float getFontTextExtent(const CEGUI::Font* font, const std::string& text, float x_scale = 1.0f); // tolua_export
 
         static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export
 



More information about the Orxonox-commit mailing list