- text3d was missing menu items for toggling bold/underline/italic/smallcaps.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 13 Jul 2010 23:51:21 +0000 (23:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 13 Jul 2010 23:51:21 +0000 (23:51 +0000)
- 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.

12 files changed:
doc/blender.1.py
release/scripts/modules/rna_info.py
release/scripts/op/presets.py
release/scripts/ui/properties_data_curve.py
release/scripts/ui/space_view3d.py
source/blender/blenkernel/intern/font.c
source/blender/editors/curve/curve_ops.c
source/blender/editors/curve/editfont.c
source/blender/gpu/gpu_buffers.h
source/blender/gpu/intern/gpu_draw.c
source/blender/makesdna/DNA_curve_types.h
source/blender/makesrna/intern/rna_curve.c

index c77e5ccbc3ded1b10c0b4b2f87c77bcd96a1ab3a..576b58758cdc50e0eec0254bc3dcf0d5f81e4c78 100644 (file)
@@ -31,12 +31,12 @@ def man_format(data):
     data = data.replace("-", "\\-")
     data = data.replace("\t", "    ")
     # data = data.replace("$", "\\fI")
-    
+
     data_ls = []
     for w in data.split():
         if w.startswith("$"):
             w = "\\fI" + w[1:] + "\\fR"
-           
+
         data_ls.append(w)
 
     data = data[:len(data) - len(data.lstrip())] + " ".join(data_ls)
@@ -90,16 +90,16 @@ lines = [line.rstrip() for line in blender_help.split("\n")]
 while lines:
     l = lines.pop(0)
     if l.startswith("Environment Variables:"):
-        fw('.SH "ENVIRONMENT VARIABLES"\n') 
+        fw('.SH "ENVIRONMENT VARIABLES"\n')
     elif l.endswith(":"): # one line
-        fw('.SS "%s"\n\n' % l) 
+        fw('.SS "%s"\n\n' % l)
     elif l.startswith("-") or l.startswith("/"): # can be multi line
 
         fw('.TP\n')
         fw('.B %s\n' % man_format(l))
-        
+
         while lines:
-            # line with no 
+            # line with no
             if lines[0].strip() and len(lines[0].lstrip()) == len(lines[0]): # no white space
                 break
 
@@ -112,7 +112,7 @@ while lines:
             l = l[1:] # remove first whitespace (tab)
 
             fw('%s\n' % man_format(l))
-    
+
     else:
         if not l.strip():
             fw('.br\n')
index 9c2a268894967d3e6c4de35420e96f6e7ff5440a..3fd70fedd8c57698dab850d52c5bb659dbb54848 100644 (file)
@@ -631,6 +631,8 @@ if __name__ == "__main__":
         props = [(prop.identifier, prop) for prop in v.properties]
         
         for prop_id, prop in sorted(props):
+            if prop.type == 'boolean':
+                continue
             data += "%s.%s -> %s:    %s%s    %s\n" % (struct_id_str, prop.identifier, prop.identifier, prop.type, ", (read-only)" if prop.is_readonly else "", prop.description)
 
     if bpy.app.background:
index 9552a5e678504e19e93617c281973cbdd069936d..f80c5e69ddd2be15eee5af3afdc9a152c71c8af5 100644 (file)
@@ -27,8 +27,8 @@ class AddPresetBase(bpy.types.Operator):
     subclasses must define
      - preset_values
      - preset_subdir '''
-    bl_idname = "script.add_preset_base"
-    bl_label = "Add a Python Preset"
+    # bl_idname = "script.preset_base_add"
+    bl_label = "Add a Python Preset"
 
     name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen=64, default="")
 
index 8c02754ecac10124e1c8b24e046b8ca7600b4228..fd836f5e5d49239ce0398659d97ad08b99e6a757 100644 (file)
@@ -313,8 +313,6 @@ class DATA_PT_font(DataButtonsPanel):
         colsub.label(text="Underline:")
         colsub.prop(text, "ul_position", text="Position")
         colsub.prop(text, "ul_height", text="Thickness")
-        col.label(text="")
-        col.prop(text, "small_caps_scale", text="Small Caps")
 
         if wide_ui:
             col = split.column()
@@ -322,9 +320,13 @@ class DATA_PT_font(DataButtonsPanel):
         col.prop(char, "bold")
         col.prop(char, "italic")
         col.prop(char, "underline")
+        
+        split = layout.split()
+        col = split.column()
+        col.prop(text, "small_caps_scale", text="Small Caps")
+        
+        col = split.column()
         col.prop(char, "use_small_caps")
-#       col.prop(char, "style")
-#       col.prop(char, "wrap")
 
 
 class DATA_PT_paragraph(DataButtonsPanel):
index 6860739bd031e08f2eae0d45d1bc75dd640e1da0..bab3695a0b6fc90c3ffe4a13e6d7ee0963ab4906 100644 (file)
@@ -1707,6 +1707,13 @@ class VIEW3D_MT_edit_text(bpy.types.Menu):
 
         layout.menu("VIEW3D_MT_edit_text_chars")
 
+        layout.separator()
+        
+        layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
+        layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
+        layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
+        layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
+
 
 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
     bl_label = "Special Characters"
index d07bd2ba8e52984aff54e68673dfe6dc11a3c0e0..a99f2599f660aa04b56279dee74a64e0e3238c7d 100644 (file)
@@ -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);
index 026a10c013cdd7a676c57c848f72db942667a17a..8f826d318b6957aaf46d9c6f9b0d5030ad58f1fd 100644 (file)
@@ -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);
index 7d5af54b640d393e11a3314114ba1e19f51328b3..69ba432e77831c6c9fdc4af06ce06d2c98554e00 100644 (file)
@@ -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;
index 983133a6d4b5ace385fa69e8ff9a9a9b8c2de391..75e596935a31909078b8c6945aa02d410e10ed5b 100644 (file)
@@ -50,6 +50,7 @@
 
 struct DerivedMesh;
 struct GHash;
+struct DMGridData;
 
 /* V - vertex, N - normal, T - uv, C - color
    F - float, UB - unsigned byte */
index 506ce94b763ff42773115fc1d982d86fcf7cf41c..abbdbb4ac27757a525c123b45a697956ce4663f7 100644 (file)
@@ -68,6 +68,7 @@
 #include "GPU_extensions.h"
 #include "GPU_material.h"
 #include "GPU_draw.h"
+#include "gpu_buffers.h"
 
 #include "smoke_API.h"
 
index 2c4c60195565e8e977b7ec8d064595750ea30abf..d27ab8f125d821d90f955906a186503f35042ffc 100644 (file)
@@ -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
 
index b2d0e64bebfd83a835da0676b049c9b980129fca..d8bc683ae120cca15958333bc8343f5ef4bff4a7 100644 (file)
@@ -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");
 }