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
path: root/source
diff options
context:
space:
mode:
authorJohnny Matthews <johnny.matthews@gmail.com>2005-02-24 22:22:31 +0300
committerJohnny Matthews <johnny.matthews@gmail.com>2005-02-24 22:22:31 +0300
commit5519157c86df8de08e31fe0ccf588b402ec11f30 (patch)
treea84ca790d269f4d70ba4b056225e4fd607687076 /source
parent386f390ab8ae9a13b1b31fa4cd5a0f01546415eb (diff)
This is an initial commit for inserting a text file as one 3d text object per line. The function for making the objects aligned to the screen needs to be added, since right now it is aligning rotation to the screen but translation is not right since I am adding an offset to the non-viewport location of the objects. That offset just needs to be translated to screen first.
Diffstat (limited to 'source')
-rw-r--r--source/blender/include/BSE_headerbuttons.h3
-rw-r--r--source/blender/src/editfont.c67
-rw-r--r--source/blender/src/header_text.c37
3 files changed, 103 insertions, 4 deletions
diff --git a/source/blender/include/BSE_headerbuttons.h b/source/blender/include/BSE_headerbuttons.h
index b843fde5307..8642f2b7635 100644
--- a/source/blender/include/BSE_headerbuttons.h
+++ b/source/blender/include/BSE_headerbuttons.h
@@ -108,6 +108,9 @@ void do_view3d_buttons(short event);
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);
diff --git a/source/blender/src/editfont.c b/source/blender/src/editfont.c
index fec40995a2c..2c5be982b7a 100644
--- a/source/blender/src/editfont.c
+++ b/source/blender/src/editfont.c
@@ -52,6 +52,7 @@
#include "DNA_vfont_types.h"
#include "DNA_scene_types.h"
#include "DNA_text_types.h"
+#include "DNA_view3d_types.h"
#include "BKE_displist.h"
#include "BKE_font.h"
@@ -312,6 +313,72 @@ void txt_export_to_object(struct Text *text)
}
+void txt_export_to_objects(struct Text *text)
+{
+ ID *id;
+ Curve *cu;
+ struct TextLine *tmp, *curline;
+ int nchars;
+ int linNum = 0;
+
+ 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){
+ /*skip lines with no text, but still make space for them*/
+ if(curline->line[0] == '\0'){
+ linNum++;
+ curline = curline->next;
+ continue;
+ }
+
+
+ nchars = 0;
+ add_object(OB_FONT);
+
+ base_init_from_view3d(BASACT, G.vd);
+ G.obedit= BASACT->object;
+ where_is_object(G.obedit);
+
+
+ /* Do the translation */
+
+ G.obedit->loc[1] -= linNum;
+
+ /* End Translation */
+
+
+ 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);
+
+ linNum++;
+ curline = curline->next;
+ }
+ allqueue(REDRAWVIEW3D, 0);
+}
+
+
void do_textedit(unsigned short event, short val, char _ascii)
{
Curve *cu;
diff --git a/source/blender/src/header_text.c b/source/blender/src/header_text.c
index fecf97988bf..36900d34e60 100644
--- a/source/blender/src/header_text.c
+++ b/source/blender/src/header_text.c
@@ -272,9 +272,6 @@ static void do_text_editmenu(void *arg, int event)
case 9:
txt_find_panel(st,0);
break;
- case 10:
- txt_export_to_object(text);
- break;
default:
break;
}
@@ -456,6 +453,38 @@ static uiBlock *text_formatmenu(void *arg_unused)
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 @@ static uiBlock *text_editmenu(void *arg_unused)
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);