Decided what I need to do.
This commit is contained in:
parent
bb52275686
commit
c336063b65
|
@ -276,6 +276,8 @@ void uiDrawTextLayoutLineGetMetrics(uiDrawTextLayout *tl, int line, uiDrawTextLa
|
|||
*m = tl->lineMetrics[line];
|
||||
}
|
||||
|
||||
// TODO note that in some cases lines can overlap slightly
|
||||
// in our case, we read lines first to last and use their bottommost point (Y + Height) to determine where the next line should start for hit-testing
|
||||
void uiDrawTextLayoutHitTest(uiDrawTextLayout *tl, double x, double y, uiDrawTextLayoutHitTestResult *result)
|
||||
{
|
||||
CFIndex i;
|
||||
|
@ -288,7 +290,8 @@ void uiDrawTextLayoutHitTest(uiDrawTextLayout *tl, double x, double y, uiDrawTex
|
|||
|
||||
ltop = tl->lineMetrics[i].Y;
|
||||
lbottom = ltop + tl->lineMetrics[i].Height;
|
||||
if (y >= ltop && y < lbottom)
|
||||
// y will already >= ltop at this point since the past lbottom should == (or at least >=, see above) ltop
|
||||
if (y < lbottom)
|
||||
break;
|
||||
}
|
||||
result->YPosition = uiDrawTextLayoutHitTestPositionInside;
|
||||
|
@ -298,6 +301,7 @@ void uiDrawTextLayoutHitTest(uiDrawTextLayout *tl, double x, double y, uiDrawTex
|
|||
}
|
||||
} else {
|
||||
i = 0;
|
||||
// TODO what if the first line crosses into the negatives?
|
||||
result->YPosition = uiDrawTextLayoutHitTestPositionBefore;
|
||||
}
|
||||
result->Line = i;
|
||||
|
@ -314,7 +318,7 @@ void uiDrawTextLayoutHitTest(uiDrawTextLayout *tl, double x, double y, uiDrawTex
|
|||
}
|
||||
|
||||
line = (CTLineRef) CFArrayGetValueAtIndex(tl->lines, i);
|
||||
// TODO copy the part from the docs about this point
|
||||
// TODO copy the part from the docs about this point (TODO what point?)
|
||||
pos = CTLineGetStringIndexForPosition(line, CGPointMake(x, 0));
|
||||
if (pos == kCFNotFound) {
|
||||
// TODO
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
static const char *text =
|
||||
"Each of the glyphs an end user interacts with are called graphemes. "
|
||||
//TODO "If you enter a byte range in the text boxes below and click the button, you can see the blue box move to surround that byte range, as well as what the actual byte range necessary is. "
|
||||
//TODO "You'll also see the index of the first grapheme; uiAttributedString has facilities for converting between UTF-8 code points and grapheme indices. "
|
||||
"If you enter a byte range in the text boxes below and click the button, you can see the blue box move to surround that byte range, as well as what the actual byte range necessary is. "
|
||||
"You'll also see the index of the first grapheme; uiAttributedString has facilities for converting between UTF-8 code points and grapheme indices. "
|
||||
"Additionally, click on the string to move the caret. Watch the status text at the bottom change too. "
|
||||
"That being said: "
|
||||
"\xC3\x93O\xCC\x81 (combining accents) "
|
||||
|
|
Loading…
Reference in New Issue