diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-14 03:51:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-14 03:51:21 +0400 |
commit | 3580d6229a2c2ee5815ff76665d4bb014eacfb99 (patch) | |
tree | 24a38ec45f417458760875c20d10914e4aa5c973 /source | |
parent | 03e638d1285b2a26902230772ae9261406fd6658 (diff) |
- text3d was missing menu items for toggling bold/underline/italic/smallcaps.
- made smallcaps use a temp flag so caps can still have the smallcaps flag.
- utility function for getting the char from a font. find_vfont_char(), was inline in ~5 places.
- removed CU_STYLE mix of flags only used in one place, not needed. removed 'style' from rna too.
- fix for some warnings.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 81 | ||||
-rw-r--r-- | source/blender/editors/curve/curve_ops.c | 7 | ||||
-rw-r--r-- | source/blender/editors/curve/editfont.c | 15 | ||||
-rw-r--r-- | source/blender/gpu/gpu_buffers.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_curve_types.h | 13 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 20 |
7 files changed, 60 insertions, 78 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index d07bd2ba8e5..a99f2599f66 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -427,12 +427,12 @@ VFont *load_vfont(char *name) static VFont *which_vfont(Curve *cu, CharInfo *info) { - switch(info->flag & CU_STYLE) { - case CU_BOLD: + switch(info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { + case CU_CHINFO_BOLD: if (cu->vfontb) return(cu->vfontb); else return(cu->vfont); - case CU_ITALIC: + case CU_CHINFO_ITALIC: if (cu->vfonti) return(cu->vfonti); else return(cu->vfont); - case (CU_BOLD|CU_ITALIC): + case (CU_CHINFO_BOLD|CU_CHINFO_ITALIC): if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont); default: return(cu->vfont); @@ -450,6 +450,17 @@ VFont *get_builtin_font(void) return load_vfont("<builtin>"); } +static VChar *find_vfont_char(VFontData *vfd, intptr_t character) +{ + VChar *che= NULL; + + for(che = vfd->characters.first; che; che = che->next) { + if(che->index == character) + break; + } + return che; /* NULL if not found */ +} + static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, int charidx, short mat_nr) { Nurb *nu2; @@ -524,14 +535,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float si= (float)sin(rot); co= (float)cos(rot); - // Find the correct character from the font - che = vfd->characters.first; - while(che) - { - if(che->index == character) - break; - che = che->next; - } + che= find_vfont_char(vfd, character); // Select the glyph data if(che) @@ -598,7 +602,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float } bezt2 = nu2->bezt; - if(info->flag & CU_SMALLCAPS) { + if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) { const float sca= cu->smallcaps_scale; for (i= nu2->pntsu; i > 0; i--) { fp= bezt2->vec[0]; @@ -656,7 +660,7 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info) if(che == NULL) { return 0.0f; } - else if(info->flag & CU_SMALLCAPS) { + else if(info->flag & CU_CHINFO_SMALLCAPS_CHECK) { return che->width * cu->smallcaps_scale; } else { @@ -745,7 +749,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) oldvfont = NULL; - for (i=0; i<slen; i++) custrinfo[i].flag &= ~CU_WRAP; + for (i=0; i<slen; i++) custrinfo[i].flag &= ~(CU_CHINFO_WRAP|CU_CHINFO_SMALLCAPS_CHECK); if (cu->selboxes) MEM_freeN(cu->selboxes); cu->selboxes = NULL; @@ -760,26 +764,19 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) che = vfd->characters.first; info = &(custrinfo[i]); ascii = mem[i]; - if(info->flag & CU_SMALLCAPS) { + if(info->flag & CU_CHINFO_SMALLCAPS) { ascii = towupper(ascii); if(mem[i] != ascii) { mem[i]= ascii; - } - else { - info->flag &= ~CU_SMALLCAPS; /* could have a different way to not scale caps */ + info->flag |= CU_CHINFO_SMALLCAPS_CHECK; } } vfont = which_vfont(cu, info); if(vfont==NULL) break; - - // Find the character - while(che) { - if(che->index == ascii) - break; - che = che->next; - } + + che= find_vfont_char(vfd, ascii); /* * The character wasn't in the current curve base so load it @@ -791,12 +788,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) } /* Try getting the character again from the list */ - che = vfd->characters.first; - while(che) { - if(che->index == ascii) - break; - che = che->next; - } + che= find_vfont_char(vfd, ascii); /* No VFont found */ if (vfont==0) { @@ -833,13 +825,13 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) i = j-1; xof = ct->xof; ct[1].dobreak = 1; - custrinfo[i+1].flag |= CU_WRAP; + custrinfo[i+1].flag |= CU_CHINFO_WRAP; goto makebreak; } if (chartransdata[j].dobreak) { // fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]); ct->dobreak= 1; - custrinfo[i+1].flag |= CU_WRAP; + custrinfo[i+1].flag |= CU_CHINFO_WRAP; ct -= 1; cnr -= 1; i--; @@ -1047,14 +1039,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) /* rotate around center character */ ascii = mem[i]; - - // Find the character - che = vfd->characters.first; - while(che) { - if(che->index == ascii) - break; - che = che->next; - } + + che= find_vfont_char(vfd, ascii); twidth = char_width(cu, che, info); @@ -1180,22 +1166,17 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if(cha != '\n' && cha != '\r') buildchar(cu, cha, info, ct->xof, ct->yof, ct->rot, i); - if ((info->flag & CU_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) { + if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) { float ulwidth, uloverlap= 0.0f; if ( (i<(slen-1)) && (mem[i+1] != '\n') && (mem[i+1] != '\r') && - ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_UNDERLINE)) && ((custrinfo[i+1].flag & CU_WRAP)==0) + ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i+1].flag & CU_CHINFO_WRAP)==0) ) { uloverlap = xtrax + 0.1; } // Find the character, the characters has to be in the memory already // since character checking has been done earlier already. - che = vfd->characters.first; - while(che) { - if(che->index == cha) - break; - che = che->next; - } + che= find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); ulwidth = cu->fsize * ((twidth* (1.0+(info->kern/40.0)))+uloverlap); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 026a10c013c..8f826d318b6 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -147,9 +147,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf) keymap->poll= ED_operator_editfont; /* only set in editmode font, by space_view3d listener */ - RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_BOLD); - RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_ITALIC); - RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", UKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_UNDERLINE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_BOLD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_ITALIC); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", UKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_UNDERLINE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", PKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_SMALLCAPS); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_SEL); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_SEL); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 7d5af54b640..69ba432e778 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -611,9 +611,10 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */ /******************* set style operator ********************/ static EnumPropertyItem style_items[]= { - {CU_BOLD, "BOLD", 0, "Bold", ""}, - {CU_ITALIC, "ITALIC", 0, "Italic", ""}, - {CU_UNDERLINE, "UNDERLINE", 0, "Underline", ""}, + {CU_CHINFO_BOLD, "BOLD", 0, "Bold", ""}, + {CU_CHINFO_ITALIC, "ITALIC", 0, "Italic", ""}, + {CU_CHINFO_UNDERLINE, "UNDERLINE", 0, "Underline", ""}, + {CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""}, {0, NULL, 0, NULL, NULL}}; static int set_style(bContext *C, int style, int clear) @@ -664,7 +665,7 @@ void FONT_OT_style_set(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "style", style_items, CU_BOLD, "Style", "Style to set selection to."); + RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to."); RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear style rather than setting it."); } @@ -702,7 +703,7 @@ void FONT_OT_style_toggle(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_enum(ot->srna, "style", style_items, CU_BOLD, "Style", "Style to set selection to."); + RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to."); } /******************* copy text operator ********************/ @@ -862,7 +863,7 @@ static int move_cursor(bContext *C, int type, int select) if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; while(cu->pos>0) { if(ef->textbuf[cu->pos-1]=='\n') break; - if(ef->textbufinfo[cu->pos-1].flag & CU_WRAP ) break; + if(ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break; cu->pos--; } cursmove=FO_CURS; @@ -873,7 +874,7 @@ static int move_cursor(bContext *C, int type, int select) while(cu->pos<cu->len) { if(ef->textbuf[cu->pos]==0) break; if(ef->textbuf[cu->pos]=='\n') break; - if(ef->textbufinfo[cu->pos].flag & CU_WRAP ) break; + if(ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break; cu->pos++; } cursmove=FO_CURS; diff --git a/source/blender/gpu/gpu_buffers.h b/source/blender/gpu/gpu_buffers.h index 983133a6d4b..75e596935a3 100644 --- a/source/blender/gpu/gpu_buffers.h +++ b/source/blender/gpu/gpu_buffers.h @@ -50,6 +50,7 @@ struct DerivedMesh; struct GHash; +struct DMGridData; /* V - vertex, N - normal, T - uv, C - color F - float, UB - unsigned byte */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 506ce94b763..abbdbb4ac27 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -68,6 +68,7 @@ #include "GPU_extensions.h" #include "GPU_material.h" #include "GPU_draw.h" +#include "gpu_buffers.h" #include "smoke_API.h" diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 2c4c6019556..d27ab8f125d 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -324,12 +324,13 @@ typedef enum eBezTriple_KeyframeType { /* *************** CHARINFO **************** */ /* flag */ -#define CU_STYLE (1+2) -#define CU_BOLD 1 -#define CU_ITALIC 2 -#define CU_UNDERLINE 4 -#define CU_WRAP 8 /* wordwrap occured here */ -#define CU_SMALLCAPS 16 +/* note: CU_CHINFO_WRAP and CU_CHINFO_SMALLCAPS_TEST are set dynamically */ +#define CU_CHINFO_BOLD (1<<0) +#define CU_CHINFO_ITALIC (1<<1) +#define CU_CHINFO_UNDERLINE (1<<2) +#define CU_CHINFO_WRAP (1<<3) /* wordwrap occured here */ +#define CU_CHINFO_SMALLCAPS (1<<4) +#define CU_CHINFO_SMALLCAPS_CHECK (1<<5) /* set at runtime, checks if case switching is needed */ #endif diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index b2d0e64bebf..d8bc683ae12 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -878,33 +878,29 @@ static void rna_def_charinfo(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Text Character Format", "Text character formatting settings"); /* flags */ - prop= RNA_def_property(srna, "style", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STYLE); - RNA_def_property_ui_text(prop, "Style", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "bold", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BOLD); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD); RNA_def_property_ui_text(prop, "Bold", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "italic", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_ITALIC); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC); RNA_def_property_ui_text(prop, "Italic", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "underline", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UNDERLINE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE); RNA_def_property_ui_text(prop, "Underline", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_WRAP); + /* probably there is no reason to expose this */ + /* prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP); RNA_def_property_ui_text(prop, "Wrap", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */ prop= RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMALLCAPS); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_SMALLCAPS); RNA_def_property_ui_text(prop, "Small Caps", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } |