MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getTextPosition

Method getTextPosition

Engine/source/gui/controls/guiMLTextCtrl.cpp:1078–1108  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1076
1077//--------------------------------------------------------------------------
1078S32 GuiMLTextCtrl::getTextPosition(const Point2I& localCoords)
1079{
1080 AssertFatal(mAwake, "Can't get the text position of a sleeping control.");
1081 if(mDirty)
1082 reflow();
1083
1084 for(Line *walk = mLineList; walk; walk = walk->next)
1085 {
1086 if((S32)localCoords.y < (S32)walk->y)
1087 return walk->textStart;
1088
1089 if(localCoords.y >= walk->y && localCoords.y < walk->y + walk->height)
1090 {
1091 for(Atom *awalk = walk->atomList; awalk; awalk = awalk->next)
1092 {
1093 if(localCoords.x < awalk->xStart)
1094 return awalk->textStart;
1095 if(localCoords.x >= awalk->xStart + awalk->width)
1096 continue;
1097 // it's in the text block...
1098 GFont *font = awalk->style->font->fontRes;
1099
1100 const UTF16 *tmp16 = mTextBuffer.getPtr() + awalk->textStart;
1101 U32 bp = font->getBreakPos(tmp16, awalk->len, localCoords.x - awalk->xStart, false);
1102 return awalk->textStart + bp;
1103 }
1104 return walk->textStart + walk->len;
1105 }
1106 }
1107 return mTextBuffer.length() - 1;
1108}
1109
1110//--------------------------------------------------------------------------
1111GuiMLTextCtrl::Font *GuiMLTextCtrl::allocFont(const char *faceName, U32 faceNameLen, U32 size)

Callers

nothing calls this directly

Calls 3

getBreakPosMethod · 0.80
getPtrMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected