Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-01-07 10:04:19 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-07 10:12:24 +0400
commit4a372102c708ee5a53af5b70a4efec30f2d87b6f (patch)
treeeaade6762caf6c44172f8f871ef114c54385474b /source/blender/blenkernel
parenta97180046b447016c683aaececd45f28c8550d03 (diff)
Text3d: move text selection boxes from Curve to EditFont struct
resolves T38079
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_font.h8
-rw-r--r--source/blender/blenkernel/intern/curve.c5
-rw-r--r--source/blender/blenkernel/intern/font.c36
3 files changed, 29 insertions, 20 deletions
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h
index 769771363ec..d7c40e8e719 100644
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@ -53,18 +53,20 @@ struct CharTrans {
char dobreak;
};
-typedef struct SelBox {
+typedef struct EditFontSelBox {
float x, y, w, h;
float rot;
-} SelBox;
+} EditFontSelBox;
-typedef struct EditFont {
+typedef struct EditFont {
wchar_t *copybuf;
struct CharInfo *copybufinfo;
wchar_t *textbuf;
struct CharInfo *textbufinfo;
+ /* array of rectangles & rotation */
+ EditFontSelBox *selboxes;
float textcurs[4][2];
/* positional vars relative to the textbuf, textbufinfo (not utf8 bytes)
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index d1dde91feb6..4898832d97c 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -112,12 +112,12 @@ void BKE_curve_editfont_free(Curve *cu)
MEM_freeN(ef->copybuf);
if (ef->copybufinfo)
MEM_freeN(ef->copybufinfo);
+ if (ef->selboxes)
+ MEM_freeN(ef->selboxes);
MEM_freeN(ef);
cu->editfont = NULL;
}
-
- MEM_SAFE_FREE(cu->selboxes);
}
void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb)
@@ -224,7 +224,6 @@ Curve *BKE_curve_copy(Curve *cu)
cun->editnurb = NULL;
cun->editfont = NULL;
- cun->selboxes = NULL;
cun->lastsel = NULL;
#if 0 // XXX old animation system
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index a70ab000a32..454db17b649 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -502,6 +502,7 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Scene *scene, Object *ob, int mode,
{
Curve *cu = ob->data;
EditFont *ef = cu->editfont;
+ EditFontSelBox *selboxes = NULL;
VFont *vfont, *oldvfont;
VFontData *vfd = NULL;
CharInfo *info = NULL, *custrinfo;
@@ -562,6 +563,18 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Scene *scene, Object *ob, int mode,
if (cu->tb == NULL)
cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "TextBox compat");
+ if (ef) {
+ if (ef->selboxes)
+ MEM_freeN(ef->selboxes);
+
+ if (BKE_vfont_select_get(ob, &selstart, &selend))
+ ef->selboxes = MEM_callocN((selend - selstart + 1) * sizeof(EditFontSelBox), "font selboxes");
+ else
+ ef->selboxes = NULL;
+
+ selboxes = ef->selboxes;
+ }
+
/* calc offset and rotation of each char */
ct = chartransdata = MEM_callocN((slen + 1) * sizeof(struct CharTrans), "buildtext");
@@ -583,11 +596,6 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Scene *scene, Object *ob, int mode,
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;
- if (BKE_vfont_select_get(ob, &selstart, &selend))
- cu->selboxes = MEM_callocN((selend - selstart + 1) * sizeof(SelBox), "font selboxes");
-
tb = &(cu->tb[0]);
curbox = 0;
for (i = 0; i <= slen; i++) {
@@ -729,7 +737,7 @@ makebreak:
xof = cu->xof + tabfac;
}
else {
- SelBox *sb = NULL;
+ EditFontSelBox *sb = NULL;
float wsfac;
ct->xof = xof;
@@ -737,8 +745,8 @@ makebreak:
ct->linenr = lnr;
ct->charnr = cnr++;
- if (cu->selboxes && (i >= selstart) && (i <= selend)) {
- sb = &(cu->selboxes[i - selstart]);
+ if (selboxes && (i >= selstart) && (i <= selend)) {
+ sb = &selboxes[i - selstart];
sb->y = yof * cu->fsize - linedist * cu->fsize * 0.1f;
sb->h = linedist * cu->fsize;
sb->w = xof * cu->fsize;
@@ -929,9 +937,9 @@ makebreak:
ct->xof = vec[0] + si * yof;
ct->yof = vec[1] + co * yof;
- if (cu->selboxes && (i >= selstart) && (i <= selend)) {
- SelBox *sb;
- sb = &(cu->selboxes[i - selstart]);
+ if (selboxes && (i >= selstart) && (i <= selend)) {
+ EditFontSelBox *sb;
+ sb = &selboxes[i - selstart];
sb->rot = -ct->rot;
}
@@ -940,12 +948,12 @@ makebreak:
}
}
- if (cu->selboxes) {
+ if (selboxes) {
ct = chartransdata;
for (i = 0; i <= selend; i++, ct++) {
if (i >= selstart) {
- cu->selboxes[i - selstart].x = ct->xof * cu->fsize;
- cu->selboxes[i - selstart].y = ct->yof * cu->fsize;
+ selboxes[i - selstart].x = ct->xof * cu->fsize;
+ selboxes[i - selstart].y = ct->yof * cu->fsize;
}
}
}