Ver código fonte

fixed TextField::getGlyphAt

dmuratshin 10 anos atrás
pai
commit
2ba07fe0e1

+ 1 - 1
oxygine/src/TextField.cpp

@@ -195,7 +195,7 @@ namespace oxygine
         return _style.breakLongWords;
     }
 
-    const text::Symbol* TextField::getSymbolAt(int pos) const
+    text::Symbol* TextField::getSymbolAt(int pos) const
     {
         return const_cast<TextField*>(this)->getRootNode()->getSymbol(pos);
     }

+ 1 - 1
oxygine/src/TextField.h

@@ -37,7 +37,7 @@ namespace oxygine
         TextStyle::HorizontalAlign  getHAlign() const;
         bool                        getMultiline() const;
         bool                        getBreakLongWords() const;
-        const text::Symbol*         getSymbolAt(int pos) const;
+        text::Symbol*               getSymbolAt(int pos) const;
 
         /**Overwrites TextStyle Vertical align*/
         void setVAlign(TextStyle::VerticalAlign align);

+ 4 - 4
oxygine/src/text_utils/Node.cpp

@@ -72,13 +72,13 @@ namespace oxygine
             }
         }
 
-        const Symbol* Node::getSymbol(int& pos) const
+        Symbol* Node::getSymbol(int& pos)
         {
             Node* node = _firstChild;
             while (node)
             {
                 int num = 0;
-                const Symbol* res = node->getSymbol(pos);
+                Symbol* res = node->getSymbol(pos);
                 if (res)
                     return res;
                 node = node->_nextSibling;
@@ -134,9 +134,9 @@ namespace oxygine
             }
         }
 
-        const Symbol* TextNode::getSymbol(int& pos) const
+        Symbol* TextNode::getSymbol(int& pos)
         {
-            if ((int)_data.size() < pos)
+            if ((int)_data.size() > pos)
                 return &_data[pos];
             pos -= _data.size();
             return Node::getSymbol(pos);

+ 2 - 2
oxygine/src/text_utils/Node.h

@@ -48,7 +48,7 @@ namespace oxygine
             void resize(Aligner& rd);
             void finalPass(Aligner& rd);
             void drawChildren(DrawContext& dc);
-            virtual const Symbol* getSymbol(int& pos) const;
+            virtual Symbol* getSymbol(int& pos);
 
             virtual void draw(DrawContext& dc);
 
@@ -73,7 +73,7 @@ namespace oxygine
             void _finalPass(Aligner& rd);
             void draw(DrawContext& dc);
 
-            const Symbol* getSymbol(int& pos) const OVERRIDE;
+            Symbol* getSymbol(int& pos) OVERRIDE;
 
 #ifdef OX_DEBUG
             std::string _text;//only for debug