Revision: 30288
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30288
Author:   campbellbarton
Date:     2010-07-14 01:51:21 +0200 (Wed, 14 Jul 2010)

Log Message:
-----------
- 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.

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

Modified: trunk/blender/doc/blender.1.py
===================================================================
--- trunk/blender/doc/blender.1.py      2010-07-13 22:26:45 UTC (rev 30287)
+++ trunk/blender/doc/blender.1.py      2010-07-13 23:51:21 UTC (rev 30288)
@@ -31,12 +31,12 @@
     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 @@
 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 @@
             l = l[1:] # remove first whitespace (tab)
 
             fw('%s\n' % man_format(l))
-    
+
     else:
         if not l.strip():
             fw('.br\n')

Modified: trunk/blender/release/scripts/modules/rna_info.py
===================================================================
--- trunk/blender/release/scripts/modules/rna_info.py   2010-07-13 22:26:45 UTC 
(rev 30287)
+++ trunk/blender/release/scripts/modules/rna_info.py   2010-07-13 23:51:21 UTC 
(rev 30288)
@@ -631,6 +631,8 @@
         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:

Modified: trunk/blender/release/scripts/op/presets.py
===================================================================
--- trunk/blender/release/scripts/op/presets.py 2010-07-13 22:26:45 UTC (rev 
30287)
+++ trunk/blender/release/scripts/op/presets.py 2010-07-13 23:51:21 UTC (rev 
30288)
@@ -27,8 +27,8 @@
     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="")
 

Modified: trunk/blender/release/scripts/ui/properties_data_curve.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_data_curve.py   2010-07-13 
22:26:45 UTC (rev 30287)
+++ trunk/blender/release/scripts/ui/properties_data_curve.py   2010-07-13 
23:51:21 UTC (rev 30288)
@@ -313,8 +313,6 @@
         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 @@
         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):

Modified: trunk/blender/release/scripts/ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/ui/space_view3d.py    2010-07-13 22:26:45 UTC 
(rev 30287)
+++ trunk/blender/release/scripts/ui/space_view3d.py    2010-07-13 23:51:21 UTC 
(rev 30288)
@@ -1707,7 +1707,14 @@
 
         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"
 

Modified: trunk/blender/source/blender/blenkernel/intern/font.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/font.c       2010-07-13 
22:26:45 UTC (rev 30287)
+++ trunk/blender/source/blender/blenkernel/intern/font.c       2010-07-13 
23:51:21 UTC (rev 30288)
@@ -427,12 +427,12 @@
 
 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 @@
        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 @@
        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 @@
                        }
                        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 @@
        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 @@
 
        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,27 +764,20 @@
                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;
+                               info->flag |= CU_CHINFO_SMALLCAPS_CHECK;
                        }
-                       else {
-                               info->flag &= ~CU_SMALLCAPS; /* could have a 
different way to not scale caps */
-                       }
                }
 
                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
                 * But if the font is <builtin> then do not try loading since
@@ -791,12 +788,7 @@
                }
 
                /* 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 @@
                                        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 @@
                                
                                /* 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 @@
                                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);

Modified: trunk/blender/source/blender/editors/curve/curve_ops.c
===================================================================
--- trunk/blender/source/blender/editors/curve/curve_ops.c      2010-07-13 
22:26:45 UTC (rev 30287)
+++ trunk/blender/source/blender/editors/curve/curve_ops.c      2010-07-13 
23:51:21 UTC (rev 30288)
@@ -147,9 +147,10 @@

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to