diff --git a/darwin/attrstr.m b/darwin/attrstr.m index 63539702..c3b8b0b3 100644 --- a/darwin/attrstr.m +++ b/darwin/attrstr.m @@ -386,9 +386,9 @@ static void applyAndFreeFontAttributes(struct foreachParams *p) } static const CTTextAlignment ctaligns[] = { - [uiDrawTextLayoutAlignLeft] = kCTTextAlignmentLeft, - [uiDrawTextLayoutAlignCenter] = kCTTextAlignmentCenter, - [uiDrawTextLayoutAlignRight] = kCTTextAlignmentRight, + [uiDrawTextAlignLeft] = kCTTextAlignmentLeft, + [uiDrawTextAlignCenter] = kCTTextAlignmentCenter, + [uiDrawTextAlignRight] = kCTTextAlignmentRight, }; static CTParagraphStyleRef mkParagraphStyle(uiDrawTextLayoutParams *p) diff --git a/examples/drawtext/attributes.c b/examples/drawtext/attributes.c index f15ba070..ed3cb973 100644 --- a/examples/drawtext/attributes.c +++ b/examples/drawtext/attributes.c @@ -906,7 +906,7 @@ struct example *mkAttributesExample(void) setupAttributedString(); params.String = attrstr; params.DefaultFont = &defaultFont; - params.Align = uiDrawTextLayoutAlignLeft; + params.Align = uiDrawTextAlignLeft; return &attributesExample; } diff --git a/examples/drawtext/basic.c b/examples/drawtext/basic.c index 1ddbbe6c..ede973b3 100644 --- a/examples/drawtext/basic.c +++ b/examples/drawtext/basic.c @@ -259,7 +259,7 @@ struct example *mkBasicExample(void) attrstr = uiNewAttributedString(text); params.String = attrstr; params.DefaultFont = &defaultFont; - params.Align = uiDrawTextLayoutAlignLeft; + params.Align = uiDrawTextAlignLeft; return &basicExample; } diff --git a/examples/drawtext/emptystr_hittest.c b/examples/drawtext/emptystr_hittest.c index 5542e469..fba386d8 100644 --- a/examples/drawtext/emptystr_hittest.c +++ b/examples/drawtext/emptystr_hittest.c @@ -201,7 +201,7 @@ static void changeFont(uiFontButton *b, void *data) static void changeTextAlign(uiCombobox *c, void *data) { // note the order of the items added below - params.Align = (uiDrawTextLayoutAlign) uiComboboxSelected(textAlign); + params.Align = (uiDrawTextAlign) uiComboboxSelected(textAlign); redraw(); } @@ -248,7 +248,7 @@ struct example *mkEmptyStringExample(void) attrstr = uiNewAttributedString(text); params.String = attrstr; params.DefaultFont = &defaultFont; - params.Align = uiDrawTextLayoutAlignLeft; + params.Align = uiDrawTextAlignLeft; return &hitTestExample; } diff --git a/examples/drawtext/hittest.c b/examples/drawtext/hittest.c index f5252388..ce0685d1 100644 --- a/examples/drawtext/hittest.c +++ b/examples/drawtext/hittest.c @@ -210,7 +210,7 @@ static void changeFont(uiFontButton *b, void *data) static void changeTextAlign(uiCombobox *c, void *data) { // note the order of the items added below - params.Align = (uiDrawTextLayoutAlign) uiComboboxSelected(textAlign); + params.Align = (uiDrawTextAlign) uiComboboxSelected(textAlign); redraw(); } @@ -257,7 +257,7 @@ struct example *mkHitTestExample(void) attrstr = uiNewAttributedString(text); params.String = attrstr; params.DefaultFont = &defaultFont; - params.Align = uiDrawTextLayoutAlignLeft; + params.Align = uiDrawTextAlignLeft; return &hitTestExample; } diff --git a/ui_attrstr.h b/ui_attrstr.h index 096267ea..fef4f26f 100644 --- a/ui_attrstr.h +++ b/ui_attrstr.h @@ -34,7 +34,8 @@ _UI_ENUM(uiAttribute) { uiAttributeUnderlineColor, // enum uiDrawUnderlineColor // TODO note these are copied - // TODO figure out how we're going to deal with being able to edit features over time... + // TODO add a function to uiAttributedString to get an attribute's value at a specific index or in a specific range, so we can edit + // (TODO related to above: what about memory?) uiAttributeFeatures, // use Features }; @@ -52,11 +53,9 @@ _UI_ENUM(uiDrawUnderlineColor) { uiDrawUnderlineColorAuxiliary, // for instance, the color used by smart replacements on OS X }; -// TODO rename? typedef struct uiOpenTypeFeatures uiOpenTypeFeatures; // TODO pass the feature set? typedef uiForEach (*uiOpenTypeFeaturesForEachFunc)(char a, char b, char c, char d, uint32_t value, void *data); -// TODO detailed constructor? _UI_EXTERN uiOpenTypeFeatures *uiNewOpenTypeFeatures(void); _UI_EXTERN void uiFreeOpenTypeFeatures(uiOpenTypeFeatures *otf); // TODO put above Free? @@ -80,10 +79,10 @@ struct uiAttributeSpec { double G; double B; double A; - const uiOpenTypeFeatures *Features; // TODO rename to OpenTypeFeatures? + const uiOpenTypeFeatures *Features; }; -// TODO make the spec const in a way that doesn't allow fields to be modified? +// TODO how would we make spec const in this case, to prevent fields from being modified? typedef uiForEach (*uiAttributedStringForEachAttributeFunc)(uiAttributedString *s, uiAttributeSpec *spec, size_t start, size_t end, void *data); // @role uiAttributedString constructor @@ -139,7 +138,6 @@ _UI_ENUM(uiDrawTextItalic) { uiDrawTextItalicItalic, }; -// TODO realign this so that Normal == 0? _UI_ENUM(uiDrawTextStretch) { uiDrawTextStretchUltraCondensed, uiDrawTextStretchExtraCondensed, @@ -164,18 +162,17 @@ typedef struct uiDrawTextLayout uiDrawTextLayout; typedef struct uiDrawTextLayoutParams uiDrawTextLayoutParams; typedef struct uiDrawTextLayoutLineMetrics uiDrawTextLayoutLineMetrics; -// TODO drop the Layout from this? -_UI_ENUM(uiDrawTextLayoutAlign) { - uiDrawTextLayoutAlignLeft, - uiDrawTextLayoutAlignCenter, - uiDrawTextLayoutAlignRight, +_UI_ENUM(uiDrawTextAlign) { + uiDrawTextAlignLeft, + uiDrawTextAlignCenter, + uiDrawTextAlignRight, }; struct uiDrawTextLayoutParams { uiAttributedString *String; uiDrawFontDescriptor *DefaultFont; double Width; - uiDrawTextLayoutAlign Align; + uiDrawTextAlign Align; }; // Height will equal ParagraphSpacingBefore + LineHeightSpace + Ascent + Descent + Leading + LineSpacing + ParagraphSpacing. @@ -253,10 +250,11 @@ _UI_EXTERN double uiDrawTextLayoutByteLocationInLine(uiDrawTextLayout *tl, size_ _UI_EXTERN void uiDrawCaret(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout, size_t pos, int *line); // TODO allow blinking +// TODO allow secondary carets typedef struct uiFontButton uiFontButton; #define uiFontButton(this) ((uiFontButton *) (this)) -// TODO have a function that sets an entire font descriptor to a range in a uiAttributedString at once? +// TODO have a function that sets an entire font descriptor to a range in a uiAttributedString at once, for SetFont? _UI_EXTERN void uiFontButtonFont(uiFontButton *b, uiDrawFontDescriptor *desc); // TOOD SetFont, mechanics _UI_EXTERN void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data); diff --git a/unix/drawtext.c b/unix/drawtext.c index 6acb848a..373702cd 100644 --- a/unix/drawtext.c +++ b/unix/drawtext.c @@ -95,9 +95,9 @@ static void computeLineMetrics(uiDrawTextLayout *tl) } static const PangoAlignment pangoAligns[] = { - [uiDrawTextLayoutAlignLeft] = PANGO_ALIGN_LEFT, - [uiDrawTextLayoutAlignCenter] = PANGO_ALIGN_CENTER, - [uiDrawTextLayoutAlignRight] = PANGO_ALIGN_RIGHT, + [uiDrawTextAlignLeft] = PANGO_ALIGN_LEFT, + [uiDrawTextAlignCenter] = PANGO_ALIGN_CENTER, + [uiDrawTextAlignRight] = PANGO_ALIGN_RIGHT, }; uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *p) diff --git a/windows/drawtext.cpp b/windows/drawtext.cpp index 275420da..f173f471 100644 --- a/windows/drawtext.cpp +++ b/windows/drawtext.cpp @@ -134,10 +134,10 @@ static void computeLineInfo(uiDrawTextLayout *tl) } // TODO should be const but then I can't operator[] on it; the real solution is to find a way to do designated array initializers in C++11 but I do not know enough C++ voodoo to make it work (it is possible but no one else has actually done it before) -static std::map dwriteAligns = { - { uiDrawTextLayoutAlignLeft, DWRITE_TEXT_ALIGNMENT_LEADING }, - { uiDrawTextLayoutAlignCenter, DWRITE_TEXT_ALIGNMENT_CENTER }, - { uiDrawTextLayoutAlignRight, DWRITE_TEXT_ALIGNMENT_TRAILING }, +static std::map dwriteAligns = { + { uiDrawTextAlignLeft, DWRITE_TEXT_ALIGNMENT_LEADING }, + { uiDrawTextAlignCenter, DWRITE_TEXT_ALIGNMENT_CENTER }, + { uiDrawTextAlignRight, DWRITE_TEXT_ALIGNMENT_TRAILING }, }; uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *p)