- make duplis real wasnt redrawing
authorCampbell Barton <ideasman42@gmail.com>
Tue, 13 Jul 2010 22:21:59 +0000 (22:21 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 13 Jul 2010 22:21:59 +0000 (22:21 +0000)
- small caps option for titles (doing manually is quite painful to watch).

release/scripts/ui/properties_data_curve.py
release/scripts/ui/space_sequencer.py
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/font.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/object/object_add.c
source/blender/makesdna/DNA_curve_types.h
source/blender/makesrna/intern/rna_curve.c

index 8ab0243ed3ed88a5b7449af42881ddb7f7e80056..8c02754ecac10124e1c8b24e046b8ca7600b4228 100644 (file)
@@ -308,10 +308,13 @@ class DATA_PT_font(DataButtonsPanel):
 
         split = layout.split()
 
-        col = split.column(align=True)
-        col.label(text="Underline:")
-        col.prop(text, "ul_position", text="Position")
-        col.prop(text, "ul_height", text="Thickness")
+        col = split.column()
+        colsub = col.column(align=True)
+        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()
@@ -319,6 +322,7 @@ class DATA_PT_font(DataButtonsPanel):
         col.prop(char, "bold")
         col.prop(char, "italic")
         col.prop(char, "underline")
+        col.prop(char, "use_small_caps")
 #       col.prop(char, "style")
 #       col.prop(char, "wrap")
 
index a41b5fe5262ab83c21d9de693b48e464ba19e001..97d84b77e18f91b494ecfb96d3479d4fcf6832c7 100644 (file)
@@ -373,7 +373,7 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel):
         row.label(text="Final Length: %s" % bpy.utils.smpte_from_frame(strip.frame_final_length))
         row = col.row()
         row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_length)
-        row.label(text="Strip Position: %d" % (frame_current - strip.frame_start))
+        row.label(text="Playhead: %d" % (frame_current - strip.frame_start))
 
         col.label(text="Frame Offset %d:%d" % (strip.frame_offset_start, strip.frame_offset_end))
         col.label(text="Frame Still %d:%d" % (strip.frame_still_start, strip.frame_still_end))
index a01ee15dde1c9c6282fce95dfa9b699da788021b..2e645592229cb39e895096477d8070d726b09659 100644 (file)
@@ -138,6 +138,7 @@ Curve *add_curve(char *name, int type)
        cu->fsize= 1.0;
        cu->ulheight = 0.05;    
        cu->texflag= CU_AUTOSPACE;
+       cu->smallcaps_scale= 0.75f;
        cu->twist_mode= CU_TWIST_MINIMUM;       // XXX: this one seems to be the best one in most cases, at least for curve deform...
        
        cu->bb= unit_boundbox();
index 01f2b57de710d4af2eeadcd99f91b2f5eb12979f..d07bd2ba8e52984aff54e68673dfe6dc11a3c0e0 100644 (file)
@@ -1,4 +1,4 @@
-/*  font.c     
+/*  font.c
  *  
  * 
  * $Id$
@@ -34,6 +34,7 @@
 #include <math.h>
 #include <stdlib.h>
 #include <wchar.h>
+#include <wctype.h>
 
 #include "MEM_guardedalloc.h"
 
@@ -597,9 +598,23 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
                        }
                        bezt2 = nu2->bezt;
 
+                       if(info->flag & CU_SMALLCAPS) {
+                               const float sca= cu->smallcaps_scale;
+                               for (i= nu2->pntsu; i > 0; i--) {
+                                       fp= bezt2->vec[0];
+                                       fp[0] *= sca;
+                                       fp[1] *= sca;
+                                       fp[3] *= sca;
+                                       fp[4] *= sca;
+                                       fp[6] *= sca;
+                                       fp[7] *= sca;
+                                       bezt2++;
+                               }
+                       }
+                       bezt2 = nu2->bezt;
+
                        for (i= nu2->pntsu; i > 0; i--) {
                                fp= bezt2->vec[0];
-
                                fp[0]= (fp[0]+ofsx)*fsize;
                                fp[1]= (fp[1]+ofsy)*fsize;
                                fp[3]= (fp[3]+ofsx)*fsize;
@@ -635,6 +650,20 @@ int BKE_font_getselection(Object *ob, int *start, int *end)
        }
 }
 
+static float char_width(Curve *cu, VChar *che, CharInfo *info)
+{
+       // The character wasn't found, propably ascii = 0, then the width shall be 0 as well
+       if(che == NULL) {
+               return 0.0f;
+       }
+       else if(info->flag & CU_SMALLCAPS) {
+               return che->width * cu->smallcaps_scale;
+       }
+       else {
+               return che->width;
+       }
+}
+
 struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) 
 {
        VFont *vfont, *oldvfont;
@@ -729,8 +758,18 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
        makebreak:
                // Characters in the list
                che = vfd->characters.first;
-               ascii = mem[i];
                info = &(custrinfo[i]);
+               ascii = mem[i];
+               if(info->flag & CU_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 */
+                       }
+               }
+
                vfont = which_vfont(cu, info);
                
                if(vfont==NULL) break;
@@ -780,11 +819,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                        return 0;
                }
 
-               // The character wasn't found, propably ascii = 0, then the width shall be 0 as well
-               if(!che)
-                       twidth = 0;
-               else
-                       twidth = che->width;
+               twidth = char_width(cu, che, info);
 
                // Calculate positions
                if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w) {
@@ -881,10 +916,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                        else wsfac = 1.0;
                        
                        // Set the width of the character
-                       if(!che)
-                               twidth = 0;
-                       else 
-                               twidth = che->width;
+                       twidth = char_width(cu, che, info);
 
                        xof += (twidth*wsfac*(1.0+(info->kern/40.0)) ) + xtrax;
                        
@@ -1024,10 +1056,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                                        che = che->next;
                                }
        
-                               if(che)
-                                       twidth = che->width;
-                               else
-                                       twidth = 0;
+                               twidth = char_width(cu, che, info);
                                
                                dtime= distfac*0.35f*twidth;    /* why not 0.5? */
                                dtime= distfac*0.5f*twidth;     /* why not 0.5? */
@@ -1167,8 +1196,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                                                        break;
                                                che = che->next;
                                        }
-                                       
-                                       if(!che) twidth =0; else twidth=che->width;
+
+                                       twidth = char_width(cu, che, info);
                                        ulwidth = cu->fsize * ((twidth* (1.0+(info->kern/40.0)))+uloverlap);
                                        build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05)*cu->fsize, 
                                                                        ct->xof*cu->fsize + ulwidth, 
index 4309163fe7a5226f032c8c062f2e7476f7049fe1..7f24c416526fd7325e86bdbf4f9ca8fb04450900 100644 (file)
@@ -10953,6 +10953,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                tex->saturation= 1.0f;
                }
 
+               {
+                       Curve *cu;
+                       for(cu= main->curve.first; cu; cu= cu->id.next) {
+                               cu->smallcaps_scale= 0.75f;
+                       }
+               }
+
                for (scene= main->scene.first; scene; scene=scene->id.next) {
                        if(scene) {
                                Sequence *seq;
index 2299207eaa92116f074f4bef3928a65c3e0b4e21..5fa643200f4a39098edc923532cad3b07f1c6a43 100644 (file)
@@ -1008,6 +1008,7 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op)
        DAG_scene_sort(scene);
        DAG_ids_flush_update(0);
        WM_event_add_notifier(C, NC_SCENE, scene);
+       WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL);
        
        return OPERATOR_FINISHED;
 }
index 4819455fac6b6eedd6820b84309054aa40351af9..2c4c60195565e8e977b7ec8d064595750ea30abf 100644 (file)
@@ -177,7 +177,7 @@ typedef struct Curve {
        short texflag, pad1; /* keep a short because of give_obdata_texspace() */
 
        short drawflag, twist_mode,  pad[2];
-       float twist_smooth, pad2;
+       float twist_smooth, smallcaps_scale;
 
        short pathlen, totcol;
        short flag, bevresol;
@@ -329,6 +329,7 @@ typedef enum eBezTriple_KeyframeType {
 #define CU_ITALIC              2
 #define CU_UNDERLINE   4
 #define CU_WRAP                        8       /* wordwrap occured here */
+#define CU_SMALLCAPS   16
 
 #endif
 
index 09a0af9830f8ab34d3dc8073c6f14d53c468f1f5..b2d0e64bebfd83a835da0676b049c9b980129fca 100644 (file)
@@ -730,6 +730,12 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna)
        RNA_def_property_ui_text(prop, "Font size", "");
        RNA_def_property_update(prop, 0, "rna_Curve_update_data");
        
+       prop= RNA_def_property(srna, "small_caps_scale", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "smallcaps_scale");
+       RNA_def_property_ui_range(prop, 0, 1.0, 0.1, 0);
+       RNA_def_property_ui_text(prop, "Small Caps", "Scale of small capitals");
+       RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
        prop= RNA_def_property(srna, "line_dist", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "linedist");
        RNA_def_property_range(prop, 0.0f, 10.0f);
@@ -896,6 +902,11 @@ static void rna_def_charinfo(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_WRAP);
        RNA_def_property_ui_text(prop, "Wrap", "");
        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_ui_text(prop, "Small Caps", "");
+       RNA_def_property_update(prop, 0, "rna_Curve_update_data");
 }
 
 static void rna_def_surface(BlenderRNA *brna)