MCPcopy Create free account
hub / github.com/MyGUI/mygui / getCursorPosition

Method getCursorPosition

MyGUIEngine/src/MyGUI_TextView.cpp:282–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280 }
281
282 size_t TextView::getCursorPosition(const IntPoint& _value) const
283 {
284 size_t result = 0;
285 int top = 0;
286
287 for (VectorLineInfo::const_iterator line = mLineInfo.begin(); line != mLineInfo.end(); ++line)
288 {
289 bool lastline = line + 1 == mLineInfo.end();
290
291 // наша строчка
292 if (top + mFontHeight <= _value.top && !lastline)
293 {
294 top += mFontHeight;
295 result += line->count + 1;
296 }
297 else
298 {
299 float left = (float)line->offset;
300 int count = 0;
301
302 // ищем символ
303 for (const auto& sym : line->symbols)
304 {
305 if (sym.isColour())
306 continue;
307
308 float fullAdvance = sym.getAdvance() + sym.getBearingX();
309 if (left + fullAdvance / 2.0f > _value.left)
310 {
311 break;
312 }
313 left += fullAdvance;
314 count++;
315 }
316
317 result += count;
318 break;
319 }
320 }
321
322 return result;
323 }
324
325 IntPoint TextView::getCursorPoint(size_t _position) const
326 {

Callers 5

notifyMousePressedMethod · 0.45
notifyMouseDragMethod · 0.45
onKeyButtonPressedMethod · 0.45
frameEnteredMethod · 0.45

Calls 5

isColourMethod · 0.80
getAdvanceMethod · 0.80
getBearingXMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected