[Bf-committers] Text to 3d objects Patch - Version 2
Johnny Matthews
johnny.matthews at gmail.com
Wed Feb 23 18:02:14 CET 2005
Here is a 2nd try at a patch for multi-lines to 3d objects in the text
editor. This patch does not change the code, it just cleans up the UI to
make a sub menu for 3d objects to text. -> One Object or One Object per
line.
Stivs, if you could check this over for inclusion, that would be
awesome! I have commit rights, but Ton said you were text module owner.
Johnny
-------------- next part --------------
Index: source/blender/include/BSE_headerbuttons.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BSE_headerbuttons.h,v
retrieving revision 1.16
diff -u -r1.16 BSE_headerbuttons.h
--- source/blender/include/BSE_headerbuttons.h 19 Sep 2004 19:27:57 -0000 1.16
+++ source/blender/include/BSE_headerbuttons.h 23 Feb 2005 16:25:39 -0000
@@ -108,6 +108,9 @@
void do_headerbuttons(short event);
+/* header_text.c */
+void do_text_editmenu_to3dmenu(void *arg, int event);
+
/* header_info.c */
void do_info_add_meshmenu(void *arg, int event);
void do_info_add_curvemenu(void *arg, int event);
Index: source/blender/src/editfont.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editfont.c,v
retrieving revision 1.16
diff -u -r1.16 editfont.c
--- source/blender/src/editfont.c 22 Dec 2004 19:21:45 -0000 1.16
+++ source/blender/src/editfont.c 23 Feb 2005 15:19:26 -0000
@@ -312,6 +312,54 @@
}
+void txt_export_to_objects(struct Text *text)
+{
+ ID *id;
+ Curve *cu;
+ struct TextLine *tmp, *curline;
+ int nchars;
+
+ if(!text) return;
+
+ id = (ID *)text;
+
+ if (G.obedit && G.obedit->type==OB_FONT) return;
+ check_editmode(OB_FONT);
+
+ curline = text->lines.first;
+ while(curline){
+
+ nchars = 0;
+ add_object(OB_FONT);
+
+ base_init_from_view3d(BASACT, G.vd);
+ G.obedit= BASACT->object;
+ where_is_object(G.obedit);
+
+ cu= G.obedit->data;
+
+ cu->vfont= get_builtin_font();
+ cu->vfont->id.us++;
+
+ nchars = strlen(curline->line) + 1;
+
+ if(cu->str) MEM_freeN(cu->str);
+
+ cu->str= MEM_mallocN(nchars+4, "str");
+
+ strcpy(cu->str, curline->line);
+ cu->len= strlen(curline->line);
+ cu->pos= cu->len;
+
+ make_editText();
+ exit_editmode(1);
+
+ curline = curline->next;
+ }
+ allqueue(REDRAWVIEW3D, 0);
+}
+
+
void do_textedit(unsigned short event, short val, char _ascii)
{
Curve *cu;
Index: source/blender/src/header_text.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/header_text.c,v
retrieving revision 1.21
diff -u -r1.21 header_text.c
--- source/blender/src/header_text.c 14 Nov 2004 13:37:29 -0000 1.21
+++ source/blender/src/header_text.c 23 Feb 2005 16:34:31 -0000
@@ -272,9 +272,6 @@
case 9:
txt_find_panel(st,0);
break;
- case 10:
- txt_export_to_object(text);
- break;
default:
break;
}
@@ -456,6 +453,38 @@
return block;
}
+
+/* action executed after clicking in Object to 3d Sub Menu */
+void do_text_editmenu_to3dmenu(void *arg, int event)
+{
+ SpaceText *st= curarea->spacedata.first;
+ Text *text= st->text;
+
+ switch(event) {
+ case 1: txt_export_to_object(text); break;
+ case 2: txt_export_to_objects(text); break;
+ }
+ allqueue(REDRAWVIEW3D, 0);
+}
+
+/* Object to 3d Sub Menu */
+static uiBlock *text_editmenu_to3dmenu(void *arg_unused)
+{
+ uiBlock *block;
+ short yco = 20, menuwidth = 120;
+
+ block= uiNewBlock(&curarea->uiblocks, "do_text_editmenu_to3dmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
+ uiBlockSetButmFunc(block, do_text_editmenu_to3dmenu, NULL);
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "One Object | Alt-M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "One Object Per Line", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
+
+ uiBlockSetDirection(block, UI_RIGHT);
+ uiTextBoundsBlock(block, 60);
+ return block;
+}
+
+
/* Edit menu */
static uiBlock *text_editmenu(void *arg_unused)
{
@@ -480,7 +509,7 @@
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find...|Alt Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Again|Alt F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert to 3D Text|Alt M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
+ uiDefIconTextBlockBut(block, text_editmenu_to3dmenu, NULL, ICON_RIGHTARROW_THIN, "Text to 3d Object", 0, yco-=20, 120, 19, "");
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
More information about the Bf-committers
mailing list