Browse Source

Text, Text3D: unsigned to signed, fix some warnings (#2956)

Related: https://github.com/urho3d/Urho3D/issues/2940
1vanK 3 years ago
parent
commit
0af6d8c7f9

+ 38 - 38
Source/Urho3D/AngelScript/Generated_Members.h

@@ -22976,13 +22976,13 @@ template <class T> void RegisterMembers_Text(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "bool GetAutoLocalizable() const", AS_METHODPR(T, GetAutoLocalizable, () const, bool), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool get_autoLocalizable() const", AS_METHODPR(T, GetAutoLocalizable, () const, bool), AS_CALL_THISCALL);
 
-    // Vector2 Text::GetCharPosition(unsigned index)
-    engine->RegisterObjectMethod(className, "Vector2 GetCharPosition(uint)", AS_METHODPR(T, GetCharPosition, (unsigned), Vector2), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "Vector2 get_charPositions(uint)", AS_METHODPR(T, GetCharPosition, (unsigned), Vector2), AS_CALL_THISCALL);
+    // Vector2 Text::GetCharPosition(i32 index)
+    engine->RegisterObjectMethod(className, "Vector2 GetCharPosition(int)", AS_METHODPR(T, GetCharPosition, (i32), Vector2), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Vector2 get_charPositions(int)", AS_METHODPR(T, GetCharPosition, (i32), Vector2), AS_CALL_THISCALL);
 
-    // Vector2 Text::GetCharSize(unsigned index)
-    engine->RegisterObjectMethod(className, "Vector2 GetCharSize(uint)", AS_METHODPR(T, GetCharSize, (unsigned), Vector2), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "Vector2 get_charSizes(uint)", AS_METHODPR(T, GetCharSize, (unsigned), Vector2), AS_CALL_THISCALL);
+    // Vector2 Text::GetCharSize(i32 index)
+    engine->RegisterObjectMethod(className, "Vector2 GetCharSize(int)", AS_METHODPR(T, GetCharSize, (i32), Vector2), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Vector2 get_charSizes(int)", AS_METHODPR(T, GetCharSize, (i32), Vector2), AS_CALL_THISCALL);
 
     // const Color& Text::GetEffectColor() const
     engine->RegisterObjectMethod(className, "const Color& GetEffectColor() const", AS_METHODPR(T, GetEffectColor, () const, const Color&), AS_CALL_THISCALL);
@@ -23014,13 +23014,13 @@ template <class T> void RegisterMembers_Text(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "float GetFontSize() const", AS_METHODPR(T, GetFontSize, () const, float), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "float get_fontSize() const", AS_METHODPR(T, GetFontSize, () const, float), AS_CALL_THISCALL);
 
-    // unsigned Text::GetNumChars() const
-    engine->RegisterObjectMethod(className, "uint GetNumChars() const", AS_METHODPR(T, GetNumChars, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_numChars() const", AS_METHODPR(T, GetNumChars, () const, unsigned), AS_CALL_THISCALL);
+    // i32 Text::GetNumChars() const
+    engine->RegisterObjectMethod(className, "int GetNumChars() const", AS_METHODPR(T, GetNumChars, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_numChars() const", AS_METHODPR(T, GetNumChars, () const, i32), AS_CALL_THISCALL);
 
-    // unsigned Text::GetNumRows() const
-    engine->RegisterObjectMethod(className, "uint GetNumRows() const", AS_METHODPR(T, GetNumRows, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_numRows() const", AS_METHODPR(T, GetNumRows, () const, unsigned), AS_CALL_THISCALL);
+    // i32 Text::GetNumRows() const
+    engine->RegisterObjectMethod(className, "int GetNumRows() const", AS_METHODPR(T, GetNumRows, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_numRows() const", AS_METHODPR(T, GetNumRows, () const, i32), AS_CALL_THISCALL);
 
     // float Text::GetRowHeight() const
     engine->RegisterObjectMethod(className, "float GetRowHeight() const", AS_METHODPR(T, GetRowHeight, () const, float), AS_CALL_THISCALL);
@@ -23030,17 +23030,17 @@ template <class T> void RegisterMembers_Text(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "float GetRowSpacing() const", AS_METHODPR(T, GetRowSpacing, () const, float), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "float get_rowSpacing() const", AS_METHODPR(T, GetRowSpacing, () const, float), AS_CALL_THISCALL);
 
-    // float Text::GetRowWidth(unsigned index) const
-    engine->RegisterObjectMethod(className, "float GetRowWidth(uint) const", AS_METHODPR(T, GetRowWidth, (unsigned) const, float), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "float get_rowWidths(uint) const", AS_METHODPR(T, GetRowWidth, (unsigned) const, float), AS_CALL_THISCALL);
+    // float Text::GetRowWidth(i32 index) const
+    engine->RegisterObjectMethod(className, "float GetRowWidth(int) const", AS_METHODPR(T, GetRowWidth, (i32) const, float), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "float get_rowWidths(int) const", AS_METHODPR(T, GetRowWidth, (i32) const, float), AS_CALL_THISCALL);
 
-    // unsigned Text::GetSelectionLength() const
-    engine->RegisterObjectMethod(className, "uint GetSelectionLength() const", AS_METHODPR(T, GetSelectionLength, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_selectionLength() const", AS_METHODPR(T, GetSelectionLength, () const, unsigned), AS_CALL_THISCALL);
+    // i32 Text::GetSelectionLength() const
+    engine->RegisterObjectMethod(className, "int GetSelectionLength() const", AS_METHODPR(T, GetSelectionLength, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_selectionLength() const", AS_METHODPR(T, GetSelectionLength, () const, i32), AS_CALL_THISCALL);
 
-    // unsigned Text::GetSelectionStart() const
-    engine->RegisterObjectMethod(className, "uint GetSelectionStart() const", AS_METHODPR(T, GetSelectionStart, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_selectionStart() const", AS_METHODPR(T, GetSelectionStart, () const, unsigned), AS_CALL_THISCALL);
+    // i32 Text::GetSelectionStart() const
+    engine->RegisterObjectMethod(className, "int GetSelectionStart() const", AS_METHODPR(T, GetSelectionStart, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_selectionStart() const", AS_METHODPR(T, GetSelectionStart, () const, i32), AS_CALL_THISCALL);
 
     // const String& Text::GetText() const
     engine->RegisterObjectMethod(className, "const String& GetText() const", AS_METHODPR(T, GetText, () const, const String&), AS_CALL_THISCALL);
@@ -23101,8 +23101,8 @@ template <class T> void RegisterMembers_Text(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "void SetRowSpacing(float)", AS_METHODPR(T, SetRowSpacing, (float), void), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_rowSpacing(float)", AS_METHODPR(T, SetRowSpacing, (float), void), AS_CALL_THISCALL);
 
-    // void Text::SetSelection(unsigned start, unsigned length = M_MAX_UNSIGNED)
-    engine->RegisterObjectMethod(className, "void SetSelection(uint, uint = M_MAX_UNSIGNED)", AS_METHODPR(T, SetSelection, (unsigned, unsigned), void), AS_CALL_THISCALL);
+    // void Text::SetSelection(i32 start, i32 length = M_MAX_INT)
+    engine->RegisterObjectMethod(className, "void SetSelection(int, int = M_MAX_INT)", AS_METHODPR(T, SetSelection, (i32, i32), void), AS_CALL_THISCALL);
 
     // void Text::SetText(const String& text)
     engine->RegisterObjectMethod(className, "void SetText(const String&in)", AS_METHODPR(T, SetText, (const String&), void), AS_CALL_THISCALL);
@@ -23133,13 +23133,13 @@ template <class T> void RegisterMembers_Text3D(asIScriptEngine* engine, const ch
 {
     RegisterMembers_Drawable<T>(engine, className);
 
-    // Vector2 Text3D::GetCharPosition(unsigned index)
-    engine->RegisterObjectMethod(className, "Vector2 GetCharPosition(uint)", AS_METHODPR(T, GetCharPosition, (unsigned), Vector2), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "Vector2 get_charPositions(uint)", AS_METHODPR(T, GetCharPosition, (unsigned), Vector2), AS_CALL_THISCALL);
+    // Vector2 Text3D::GetCharPosition(i32 index)
+    engine->RegisterObjectMethod(className, "Vector2 GetCharPosition(int)", AS_METHODPR(T, GetCharPosition, (i32), Vector2), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Vector2 get_charPositions(int)", AS_METHODPR(T, GetCharPosition, (i32), Vector2), AS_CALL_THISCALL);
 
-    // Vector2 Text3D::GetCharSize(unsigned index)
-    engine->RegisterObjectMethod(className, "Vector2 GetCharSize(uint)", AS_METHODPR(T, GetCharSize, (unsigned), Vector2), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "Vector2 get_charSizes(uint)", AS_METHODPR(T, GetCharSize, (unsigned), Vector2), AS_CALL_THISCALL);
+    // Vector2 Text3D::GetCharSize(i32 index)
+    engine->RegisterObjectMethod(className, "Vector2 GetCharSize(int)", AS_METHODPR(T, GetCharSize, (i32), Vector2), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Vector2 get_charSizes(int)", AS_METHODPR(T, GetCharSize, (i32), Vector2), AS_CALL_THISCALL);
 
     // const Color& Text3D::GetColor(Corner corner) const
     engine->RegisterObjectMethod(className, "const Color& GetColor(Corner) const", AS_METHODPR(T, GetColor, (Corner) const, const Color&), AS_CALL_THISCALL);
@@ -23198,13 +23198,13 @@ template <class T> void RegisterMembers_Text3D(asIScriptEngine* engine, const ch
     // ResourceRef Text3D::GetMaterialAttr() const
     engine->RegisterObjectMethod(className, "ResourceRef GetMaterialAttr() const", AS_METHODPR(T, GetMaterialAttr, () const, ResourceRef), AS_CALL_THISCALL);
 
-    // unsigned Text3D::GetNumChars() const
-    engine->RegisterObjectMethod(className, "uint GetNumChars() const", AS_METHODPR(T, GetNumChars, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_numChars() const", AS_METHODPR(T, GetNumChars, () const, unsigned), AS_CALL_THISCALL);
+    // i32 Text3D::GetNumChars() const
+    engine->RegisterObjectMethod(className, "int GetNumChars() const", AS_METHODPR(T, GetNumChars, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_numChars() const", AS_METHODPR(T, GetNumChars, () const, i32), AS_CALL_THISCALL);
 
-    // unsigned Text3D::GetNumRows() const
-    engine->RegisterObjectMethod(className, "uint GetNumRows() const", AS_METHODPR(T, GetNumRows, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_numRows() const", AS_METHODPR(T, GetNumRows, () const, unsigned), AS_CALL_THISCALL);
+    // i32 Text3D::GetNumRows() const
+    engine->RegisterObjectMethod(className, "int GetNumRows() const", AS_METHODPR(T, GetNumRows, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_numRows() const", AS_METHODPR(T, GetNumRows, () const, i32), AS_CALL_THISCALL);
 
     // float Text3D::GetOpacity() const
     engine->RegisterObjectMethod(className, "float GetOpacity() const", AS_METHODPR(T, GetOpacity, () const, float), AS_CALL_THISCALL);
@@ -23218,9 +23218,9 @@ template <class T> void RegisterMembers_Text3D(asIScriptEngine* engine, const ch
     engine->RegisterObjectMethod(className, "float GetRowSpacing() const", AS_METHODPR(T, GetRowSpacing, () const, float), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "float get_rowSpacing() const", AS_METHODPR(T, GetRowSpacing, () const, float), AS_CALL_THISCALL);
 
-    // int Text3D::GetRowWidth(unsigned index) const
-    engine->RegisterObjectMethod(className, "int GetRowWidth(uint) const", AS_METHODPR(T, GetRowWidth, (unsigned) const, int), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "int get_rowWidths(uint) const", AS_METHODPR(T, GetRowWidth, (unsigned) const, int), AS_CALL_THISCALL);
+    // int Text3D::GetRowWidth(i32 index) const
+    engine->RegisterObjectMethod(className, "int GetRowWidth(int) const", AS_METHODPR(T, GetRowWidth, (i32) const, int), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_rowWidths(int) const", AS_METHODPR(T, GetRowWidth, (i32) const, int), AS_CALL_THISCALL);
 
     // const String& Text3D::GetText() const
     engine->RegisterObjectMethod(className, "const String& GetText() const", AS_METHODPR(T, GetText, () const, const String&), AS_CALL_THISCALL);

+ 10 - 10
Source/Urho3D/UI/LineEdit.cpp

@@ -196,8 +196,8 @@ void LineEdit::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifier
     case KEY_C:
         if (textCopyable_ && qualifiers & QUAL_CTRL)
         {
-            unsigned start = text_->GetSelectionStart();
-            unsigned length = text_->GetSelectionLength();
+            i32 start = text_->GetSelectionStart();
+            i32 length = text_->GetSelectionLength();
 
             if (text_->GetSelectionLength())
                 GetSubsystem<UI>()->SetClipboardText(line_.SubstringUTF8(start, length));
@@ -224,8 +224,8 @@ void LineEdit::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifier
                 // Remove selected text first
                 if (text_->GetSelectionLength() > 0)
                 {
-                    unsigned start = text_->GetSelectionStart();
-                    unsigned length = text_->GetSelectionLength();
+                    i32 start = text_->GetSelectionStart();
+                    i32 length = text_->GetSelectionLength();
                     if (start + length < line_.LengthUTF8())
                         line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
                     else
@@ -321,8 +321,8 @@ void LineEdit::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifier
             else
             {
                 // If a selection exists, erase it
-                unsigned start = text_->GetSelectionStart();
-                unsigned length = text_->GetSelectionLength();
+                i32 start = text_->GetSelectionStart();
+                i32 length = text_->GetSelectionLength();
                 if (start + length < line_.LengthUTF8())
                     line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
                 else
@@ -368,8 +368,8 @@ void LineEdit::OnKey(Key key, MouseButtonFlags buttons, QualifierFlags qualifier
             else
             {
                 // If a selection exists, erase it
-                unsigned start = text_->GetSelectionStart();
-                unsigned length = text_->GetSelectionLength();
+                i32 start = text_->GetSelectionStart();
+                i32 length = text_->GetSelectionLength();
                 if (start + length < line_.LengthUTF8())
                     line_ = line_.SubstringUTF8(0, start) + line_.SubstringUTF8(start + length);
                 else
@@ -439,8 +439,8 @@ void LineEdit::OnTextInput(const String& text)
         else
         {
             // If a selection exists, erase it first
-            unsigned start = text_->GetSelectionStart();
-            unsigned length = text_->GetSelectionLength();
+            i32 start = text_->GetSelectionStart();
+            i32 length = text_->GetSelectionLength();
             if (start + length < line_.LengthUTF8())
                 line_ = line_.SubstringUTF8(0, start) + newText + line_.SubstringUTF8(start + length);
             else

+ 32 - 26
Source/Urho3D/UI/Text.cpp

@@ -113,7 +113,7 @@ void Text::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData,
     // If face uses mutable glyphs mechanism, reacquire glyphs before rendering to make sure they are in the texture
     else if (face->HasMutableGlyphs())
     {
-        for (unsigned i = 0; i < printText_.Size(); ++i)
+        for (i32 i = 0; i < printText_.Size(); ++i)
             face->GetGlyph(printText_[i]);
     }
 
@@ -128,7 +128,7 @@ void Text::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData,
 
         Vector2 currentStart = charLocations_[selectionStart_].position_;
         Vector2 currentEnd = currentStart;
-        for (unsigned i = selectionStart_; i < selectionStart_ + selectionLength_; ++i)
+        for (i32 i = selectionStart_; i < selectionStart_ + selectionLength_; ++i)
         {
             // Check if row changes, and start a new quad in that case
             if (charLocations_[i].size_ != Vector2::ZERO)
@@ -158,7 +158,7 @@ void Text::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData,
     // Text batch
     TextEffect textEffect = font_->IsSDFFont() ? TE_NONE : textEffect_;
     const Vector<SharedPtr<Texture2D>>& textures = face->GetTextures();
-    for (unsigned n = 0; n < textures.Size() && n < pageGlyphLocations_.Size(); ++n)
+    for (i32 n = 0; n < textures.Size() && n < pageGlyphLocations_.Size(); ++n)
     {
         // One batch per texture/page
         UIBatch pageBatch(this, BLEND_ALPHA, currentScissor, textures[n], &vertexData);
@@ -349,8 +349,9 @@ void Text::HandleChangeLanguage(StringHash eventType, VariantMap& eventData)
     UpdateText();
 }
 
-void Text::SetSelection(unsigned start, unsigned length)
+void Text::SetSelection(i32 start, i32 length)
 {
+    assert(start >= 0 && length >= 0);
     selectionStart_ = start;
     selectionLength_ = length;
     ValidateSelection();
@@ -392,13 +393,15 @@ void Text::SetEffectDepthBias(float bias)
     effectDepthBias_ = bias;
 }
 
-float Text::GetRowWidth(unsigned index) const
+float Text::GetRowWidth(i32 index) const
 {
+    assert(index >= 0);
     return index < rowWidths_.Size() ? rowWidths_[index] : 0;
 }
 
-Vector2 Text::GetCharPosition(unsigned index)
+Vector2 Text::GetCharPosition(i32 index)
 {
+    assert(index >= 0);
     if (charLocationsDirty_)
         UpdateCharLocations();
     if (charLocations_.Empty())
@@ -409,8 +412,9 @@ Vector2 Text::GetCharPosition(unsigned index)
     return charLocations_[index].position_;
 }
 
-Vector2 Text::GetCharSize(unsigned index)
+Vector2 Text::GetCharSize(i32 index)
 {
+    assert(index >= 0);
     if (charLocationsDirty_)
         UpdateCharLocations();
     if (charLocations_.Size() < 2)
@@ -488,19 +492,19 @@ void Text::UpdateText(bool onResize)
         {
             printText_ = unicodeText_;
             printToText_.Resize(printText_.Size());
-            for (unsigned i = 0; i < printText_.Size(); ++i)
+            for (i32 i = 0; i < printText_.Size(); ++i)
                 printToText_[i] = i;
         }
         else
         {
             int maxWidth = GetWidth();
-            unsigned nextBreak = 0;
-            unsigned lineStart = 0;
+            i32 nextBreak = 0;
+            i32 lineStart = 0;
             printToText_.Clear();
 
-            for (unsigned i = 0; i < unicodeText_.Size(); ++i)
+            for (i32 i = 0; i < unicodeText_.Size(); ++i)
             {
-                unsigned j;
+                i32 j;
                 u32 c = unicodeText_[i];
 
                 if (c != '\n')
@@ -512,7 +516,7 @@ void Text::UpdateText(bool onResize)
                         int futureRowWidth = rowWidth;
                         for (j = i; j < unicodeText_.Size(); ++j)
                         {
-                            unsigned d = unicodeText_[j];
+                            c32 d = unicodeText_[j];
                             if (d == ' ' || d == '\n')
                             {
                                 nextBreak = j;
@@ -592,7 +596,7 @@ void Text::UpdateText(bool onResize)
 
         rowWidth = 0;
 
-        for (unsigned i = 0; i < printText_.Size(); ++i)
+        for (i32 i = 0; i < printText_.Size(); ++i)
         {
             c32 c = printText_[i];
 
@@ -668,20 +672,20 @@ void Text::UpdateCharLocations()
     auto rowHeight = RoundToInt(rowSpacing_ * rowHeight_);
 
     // Store position & size of each character, and locations per texture page
-    unsigned numChars = unicodeText_.Size();
+    i32 numChars = unicodeText_.Size();
     charLocations_.Resize(numChars + 1);
     pageGlyphLocations_.Resize(face->GetTextures().Size());
-    for (unsigned i = 0; i < pageGlyphLocations_.Size(); ++i)
+    for (i32 i = 0; i < pageGlyphLocations_.Size(); ++i)
         pageGlyphLocations_[i].Clear();
 
     IntVector2 offset = font_->GetTotalGlyphOffset(fontSize_);
 
-    unsigned rowIndex = 0;
-    unsigned lastFilled = 0;
+    i32 rowIndex = 0;
+    i32 lastFilled = 0;
     float x = Round(GetRowStartPosition(rowIndex) + offset.x_);
     float y = Round(offset.y_);
 
-    for (unsigned i = 0; i < printText_.Size(); ++i)
+    for (i32 i = 0; i < printText_.Size(); ++i)
     {
         CharLocation loc;
         loc.position_ = Vector2(x, y);
@@ -712,7 +716,7 @@ void Text::UpdateCharLocations()
             lastFilled = printToText_[i];
 
         // Fill gaps in case characters were skipped from printing
-        for (unsigned j = lastFilled; j <= printToText_[i]; ++j)
+        for (i32 j = lastFilled; j <= printToText_[i]; ++j)
             charLocations_[j] = loc;
         lastFilled = printToText_[i] + 1;
     }
@@ -725,7 +729,7 @@ void Text::UpdateCharLocations()
 
 void Text::ValidateSelection()
 {
-    unsigned textLength = unicodeText_.Size();
+    i32 textLength = unicodeText_.Size();
 
     if (textLength)
     {
@@ -741,8 +745,10 @@ void Text::ValidateSelection()
     }
 }
 
-int Text::GetRowStartPosition(unsigned rowIndex) const
+int Text::GetRowStartPosition(i32 rowIndex) const
 {
+    assert(rowIndex >= 0);
+
     float rowWidth = 0;
 
     if (rowIndex < rowWidths_.Size())
@@ -770,14 +776,14 @@ int Text::GetRowStartPosition(unsigned rowIndex) const
 void Text::ConstructBatch(UIBatch& pageBatch, const PODVector<GlyphLocation>& pageGlyphLocation, float dx, float dy, Color* color,
     float depthBias)
 {
-    unsigned startDataSize = pageBatch.vertexData_->Size();
+    i32 startDataSize = pageBatch.vertexData_->Size();
 
     if (!color)
         pageBatch.SetDefaultColor();
     else
         pageBatch.SetColor(*color);
 
-    for (unsigned i = 0; i < pageGlyphLocation.Size(); ++i)
+    for (i32 i = 0; i < pageGlyphLocation.Size(); ++i)
     {
         const GlyphLocation& glyphLocation = pageGlyphLocation[i];
         const FontGlyph& glyph = *glyphLocation.glyph_;
@@ -787,8 +793,8 @@ void Text::ConstructBatch(UIBatch& pageBatch, const PODVector<GlyphLocation>& pa
 
     if (depthBias != 0.0f)
     {
-        unsigned dataSize = pageBatch.vertexData_->Size();
-        for (unsigned i = startDataSize; i < dataSize; i += UI_VERTEX_SIZE)
+        i32 dataSize = pageBatch.vertexData_->Size();
+        for (i32 i = startDataSize; i < dataSize; i += UI_VERTEX_SIZE)
             pageBatch.vertexData_->At(i + 2) += depthBias;
     }
 }

+ 12 - 12
Source/Urho3D/UI/Text.h

@@ -104,7 +104,7 @@ public:
     /// @property
     void SetAutoLocalizable(bool enable);
     /// Set selection. When length is not provided, select until the text ends.
-    void SetSelection(unsigned start, unsigned length = M_MAX_UNSIGNED);
+    void SetSelection(i32 start, i32 length = M_MAX_INT);
     /// Clear selection.
     void ClearSelection();
     /// Set text effect.
@@ -153,11 +153,11 @@ public:
 
     /// Return selection start.
     /// @property
-    unsigned GetSelectionStart() const { return selectionStart_; }
+    i32 GetSelectionStart() const { return selectionStart_; }
 
     /// Return selection length.
     /// @property
-    unsigned GetSelectionLength() const { return selectionLength_; }
+    i32 GetSelectionLength() const { return selectionLength_; }
 
     /// Return text effect.
     /// @property
@@ -185,21 +185,21 @@ public:
 
     /// Return number of rows.
     /// @property
-    unsigned GetNumRows() const { return rowWidths_.Size(); }
+    i32 GetNumRows() const { return rowWidths_.Size(); }
 
     /// Return number of characters.
     /// @property
-    unsigned GetNumChars() const { return unicodeText_.Size(); }
+    i32 GetNumChars() const { return unicodeText_.Size(); }
 
     /// Return width of row by index.
     /// @property{get_rowWidths}
-    float GetRowWidth(unsigned index) const;
+    float GetRowWidth(i32 index) const;
     /// Return position of character by index relative to the text element origin.
     /// @property{get_charPositions}
-    Vector2 GetCharPosition(unsigned index);
+    Vector2 GetCharPosition(i32 index);
     /// Return size of character by index.
     /// @property{get_charSizes}
-    Vector2 GetCharSize(unsigned index);
+    Vector2 GetCharSize(i32 index);
 
     /// Set text effect Z bias. Zero by default, adjusted only in 3D mode.
     void SetEffectDepthBias(float bias);
@@ -226,7 +226,7 @@ protected:
     /// Validate text selection to be within the text.
     void ValidateSelection();
     /// Return row start X position.
-    int GetRowStartPosition(unsigned rowIndex) const;
+    int GetRowStartPosition(i32 rowIndex) const;
     /// Construct batch.
     void ConstructBatch
         (UIBatch& pageBatch, const PODVector<GlyphLocation>& pageGlyphLocation, float dx = 0, float dy = 0, Color* color = nullptr,
@@ -249,9 +249,9 @@ protected:
     /// Char positions dirty flag.
     bool charLocationsDirty_;
     /// Selection start.
-    unsigned selectionStart_;
+    i32 selectionStart_;
     /// Selection length.
-    unsigned selectionLength_;
+    i32 selectionLength_;
     /// Text effect.
     TextEffect textEffect_;
     /// Text effect shadow offset.
@@ -271,7 +271,7 @@ protected:
     /// Text modified into printed form.
     PODVector<c32> printText_;
     /// Mapping of printed form back to original char indices.
-    PODVector<unsigned> printToText_;
+    PODVector<i32> printToText_;
     /// Row widths.
     PODVector<float> rowWidths_;
     /// Glyph locations per each texture in the font.

+ 14 - 11
Source/Urho3D/UI/Text3D.cpp

@@ -100,13 +100,13 @@ void Text3D::UpdateBatches(const FrameInfo& frame)
     if (faceCameraMode_ != FC_NONE || fixedScreenSize_)
         CalculateFixedScreenSize(frame);
 
-    for (unsigned i = 0; i < batches_.Size(); ++i)
+    for (i32 i = 0; i < batches_.Size(); ++i)
     {
         batches_[i].distance_ = distance_;
         batches_[i].worldTransform_ = faceCameraMode_ != FC_NONE ? &customWorldTransform_ : &node_->GetWorldTransform();
     }
 
-    for (unsigned i = 0; i < uiBatches_.Size(); ++i)
+    for (i32 i = 0; i < uiBatches_.Size(); ++i)
     {
         if (uiBatches_[i].texture_ && uiBatches_[i].texture_->IsDataLost())
         {
@@ -132,7 +132,7 @@ void Text3D::UpdateGeometry(const FrameInfo& frame)
 
     if (geometryDirty_)
     {
-        for (unsigned i = 0; i < batches_.Size() && i < uiBatches_.Size(); ++i)
+        for (i32 i = 0; i < batches_.Size() && i < uiBatches_.Size(); ++i)
         {
             Geometry* geometry = geometries_[i];
             geometry->SetDrawRange(TRIANGLE_LIST, 0, 0, uiBatches_[i].vertexStart_ / UI_VERTEX_SIZE,
@@ -142,7 +142,7 @@ void Text3D::UpdateGeometry(const FrameInfo& frame)
 
     if ((geometryDirty_ || vertexBuffer_->IsDataLost()) && uiVertexData_.Size())
     {
-        unsigned vertexCount = uiVertexData_.Size() / UI_VERTEX_SIZE;
+        i32 vertexCount = uiVertexData_.Size() / UI_VERTEX_SIZE;
         if (vertexBuffer_->GetVertexCount() != vertexCount)
             vertexBuffer_->SetSize(vertexCount, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1);
         vertexBuffer_->SetData(&uiVertexData_[0]);
@@ -451,28 +451,31 @@ int Text3D::GetRowHeight() const
     return text_.GetRowHeight();
 }
 
-unsigned Text3D::GetNumRows() const
+i32 Text3D::GetNumRows() const
 {
     return text_.GetNumRows();
 }
 
-unsigned Text3D::GetNumChars() const
+i32 Text3D::GetNumChars() const
 {
     return text_.GetNumChars();
 }
 
-int Text3D::GetRowWidth(unsigned index) const
+int Text3D::GetRowWidth(i32 index) const
 {
+    assert(index >= 0);
     return text_.GetRowWidth(index);
 }
 
-Vector2 Text3D::GetCharPosition(unsigned index)
+Vector2 Text3D::GetCharPosition(i32 index)
 {
+    assert(index >= 0);
     return text_.GetCharPosition(index);
 }
 
-Vector2 Text3D::GetCharSize(unsigned index)
+Vector2 Text3D::GetCharSize(i32 index)
 {
+    assert(index >= 0);
     return text_.GetCharSize(index);
 }
 
@@ -596,7 +599,7 @@ void Text3D::UpdateTextBatches()
     {
         boundingBox_.Clear();
 
-        for (unsigned i = 0; i < uiVertexData_.Size(); i += UI_VERTEX_SIZE)
+        for (i32 i = 0; i < uiVertexData_.Size(); i += UI_VERTEX_SIZE)
         {
             Vector3& position = *(reinterpret_cast<Vector3*>(&uiVertexData_[i]));
             position += offset;
@@ -620,7 +623,7 @@ void Text3D::UpdateTextMaterials(bool forceUpdate)
     batches_.Resize(uiBatches_.Size());
     geometries_.Resize(uiBatches_.Size());
 
-    for (unsigned i = 0; i < batches_.Size(); ++i)
+    for (i32 i = 0; i < batches_.Size(); ++i)
     {
         if (!geometries_[i])
         {

+ 5 - 5
Source/Urho3D/UI/Text3D.h

@@ -159,19 +159,19 @@ public:
     int GetRowHeight() const;
     /// Return number of rows.
     /// @property
-    unsigned GetNumRows() const;
+    i32 GetNumRows() const;
     /// Return number of characters.
     /// @property
-    unsigned GetNumChars() const;
+    i32 GetNumChars() const;
     /// Return width of row by index.
     /// @property{get_rowWidths}
-    int GetRowWidth(unsigned index) const;
+    int GetRowWidth(i32 index) const;
     /// Return position of character by index relative to the text element origin.
     /// @property{get_charPositions}
-    Vector2 GetCharPosition(unsigned index);
+    Vector2 GetCharPosition(i32 index);
     /// Return size of character by index.
     /// @property{get_charSizes}
-    Vector2 GetCharSize(unsigned index);
+    Vector2 GetCharSize(i32 index);
     /// Return corner color.
     /// @property{get_colors}
     const Color& GetColor(Corner corner) const;