Okay so I can't fix Pango as the behavior is hardcoded in (https://git.gnome.org/browse/pango/tree/pango/pango-layout.c?id=f4cbd27f4e5bf8490ea411190d41813e14f12165#n4204); just write some documentation and get rid of the old APIs entirely.

This commit is contained in:
Pietro Gagliardi 2017-02-09 19:20:35 -05:00
parent b96114e02d
commit 92d996f148
1 changed files with 22 additions and 24 deletions

View File

@ -121,12 +121,6 @@ struct uiDrawTextLayoutLineMetrics {
// TODO trailing whitespace?
};
_UI_ENUM(uiDrawTextLayoutHitTestPosition) {
uiDrawTextLayoutHitTestPositionBefore,
uiDrawTextLayoutHitTestPositionInside,
uiDrawTextLayoutHitTestPositionAfter,
};
struct uiDrawTextLayoutHitTestResult {
// The byte position of the character at the given point.
size_t Pos;
@ -142,10 +136,6 @@ struct uiDrawTextLayoutHitTestResult {
uiDrawTextLayoutHitTestPosition XPosition;
uiDrawTextLayoutHitTestPosition YPosition;
double CaretX;
double CaretY;
// CaretWidth is decided by uiDrawCaret().
double CaretHeight;
// TODO?
// int InTrailingWhitespace;
// TODO?
@ -155,16 +145,6 @@ struct uiDrawTextLayoutHitTestResult {
// or just have offsets instead? in addition?
};
struct uiDrawTextLayoutByteRangeRectangle {
int Line;
double X;
double Y;
double Width;
double Height;
size_t RealStart;
size_t RealEnd;
};
// TODO
// - allow creating a layout out of a substring
// - allow marking compositon strings
@ -173,6 +153,7 @@ struct uiDrawTextLayoutByteRangeRectangle {
// - uiDrawTextLayoutHeightForWidth() (returns the height that a layout would need to be to display the entire string at a given width)
// - uiDrawTextLayoutRangeForSize() (returns what substring would fit in a given size)
// - uiDrawTextLayoutNewWithHeight() (limits amount of string used by the height)
// - some function to fix up a range (for text editing)
_UI_EXTERN uiDrawTextLayout *uiDrawNewTextLayout(uiAttributedString *s, uiDrawFontDescriptor *defaultFont, double width);
_UI_EXTERN void uiDrawFreeTextLayout(uiDrawTextLayout *tl);
_UI_EXTERN void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y);
@ -180,11 +161,28 @@ _UI_EXTERN void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, dou
_UI_EXTERN int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl);
_UI_EXTERN void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end);
_UI_EXTERN void uiDrawTextLayoutLineGetMetrics(uiDrawTextLayout *tl, int line, uiDrawTextLayoutLineMetrics *m);
//TODO _UI_EXTERN void uiDrawTextLayoutHitTest(uiDrawTextLayout *tl, double x, double y, uiDrawTextLayoutHitTestResult *result);
//TODO _UI_EXTERN void uiDrawTextLayoutByteRangeToRectangle(uiDrawTextLayout *tl, size_t start, size_t end, uiDrawTextLayoutByteRangeRectangle *r);
// TODO draw only a line?
// TODO other layout-specific attributes (alignment, wrapping, etc.)?
// TODO number of lines visible for clipping rect, range visible for clipping rect?
// TODO rewrite all this documentation
// uiDrawTextLayoutHitTest() returns the byte offset and line closest
// to the given point. The point is relative to the top-left of the layout.
// If the point is outside the layout itself, the closest point is chosen;
// this allows the function to be used for cursor positioning with the
// mouse. Do keep the returned line in mind if used in this way; the
// user might click on the end of a line, at which point the cursor
// might be at the trailing edge of the last grapheme on the line
// (subject to the operating system's APIs).
_UI_EXTERN void uiDrawTextLayoutHitTest(uiDrawTextLayout *tl, double x, double y, size_t *pos, int *line);
// uiDrawTextLayoutByteLocationInLine() returns the point offset
// into the given line that the given byte position stands. This is
// relative to the line's X position (as returned by
// uiDrawTextLayoutLineGetMetrics()), which in turn is relative to
// the top-left of the layout. This function can be used for cursor
// positioning: if start and end are the start and end of the line
// (as returned by uiDrawTextLayoutLineByteRange()), you will get
// the correct offset, even if pos is at the end of the line. If pos is not
// in the range [start, end], a negative value will be returned,
// indicating you need to move the cursor to another line.
_UI_EXTERN double uiDrawTextLayoutByteLocationInLine(uiDrawTextLayout *tl, size_t pos, int line);