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:
Diffstat (limited to 'source/blender/editors/curve/editfont.c')
-rw-r--r--source/blender/editors/curve/editfont.c151
1 files changed, 69 insertions, 82 deletions
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index ae79c0b0053..44fec631441 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -40,6 +40,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
+#include "BLI_utildefines.h"
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
@@ -265,18 +266,18 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re
BKE_text_to_curve(scene, obedit, mode);
if(recalc)
- DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
}
/********************** insert lorem operator *********************/
-static int insert_lorem_exec(bContext *C, wmOperator *op)
+static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit= CTX_data_edit_object(C);
- char *p, *p2;
+ const char *p, *p2;
int i;
- static char *lastlorem;
+ static const char *lastlorem;
if(lastlorem)
p= lastlorem;
@@ -299,7 +300,7 @@ static int insert_lorem_exec(bContext *C, wmOperator *op)
insert_into_textbuf(obedit, '\n');
insert_into_textbuf(obedit, '\n');
- DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
@@ -325,7 +326,7 @@ void FONT_OT_insert_lorem(wmOperatorType *ot)
/* note this handles both ascii and utf8 unicode, previously
* there were 3 functions that did effectively the same thing. */
-static int paste_file(bContext *C, ReportList *reports, char *filename)
+static int paste_file(bContext *C, ReportList *reports, const char *filename)
{
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
@@ -383,7 +384,7 @@ static int paste_file_exec(bContext *C, wmOperator *op)
return retval;
}
-static int paste_file_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int paste_file_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
if(RNA_property_is_set(op->ptr, "filepath"))
return paste_file_exec(C, op);
@@ -414,9 +415,9 @@ void FONT_OT_file_paste(wmOperatorType *ot)
/******************* paste buffer operator ********************/
-static int paste_buffer_exec(bContext *C, wmOperator *op)
+static int paste_buffer_exec(bContext *C, wmOperator *UNUSED(op))
{
- char *filename;
+ const char *filename;
#ifdef WIN32
filename= "C:\\windows\\temp\\cutbuf.txt";
@@ -626,7 +627,7 @@ static int set_style(bContext *C, int style, int clear)
ef->textbufinfo[i].flag |= style;
}
- DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
+ DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
@@ -714,7 +715,7 @@ static void copy_selection(Object *obedit)
}
}
-static int copy_text_exec(bContext *C, wmOperator *op)
+static int copy_text_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit= CTX_data_edit_object(C);
@@ -737,7 +738,7 @@ void FONT_OT_text_copy(wmOperatorType *ot)
/******************* cut text operator ********************/
-static int cut_text_exec(bContext *C, wmOperator *op)
+static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
@@ -1220,7 +1221,7 @@ static int insert_text_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
char *inserted_utf8;
- wchar_t *inserted_text, first;
+ wchar_t *inserted_text;
int a, len;
if(!RNA_property_is_set(op->ptr, "text"))
@@ -1231,7 +1232,6 @@ static int insert_text_exec(bContext *C, wmOperator *op)
inserted_text= MEM_callocN(sizeof(wchar_t)*(len+1), "FONT_insert_text");
utf8towchar(inserted_text, inserted_utf8);
- first= inserted_text[0];
for(a=0; a<len; a++)
insert_into_textbuf(obedit, inserted_text[a]);
@@ -1259,6 +1259,12 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
if(RNA_property_is_set(op->ptr, "text"))
return insert_text_exec(C, op);
+
+ if(RNA_property_is_set(op->ptr, "accent")) {
+ if(cu->len!=0 && cu->pos>0)
+ accentcode= 1;
+ return OPERATOR_FINISHED;
+ }
/* tab should exit editmode, but we allow it to be typed using modifier keys */
if(event==TABKEY) {
@@ -1333,6 +1339,9 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt)
RNA_string_set(op->ptr, "text", inserted_utf8);
}
+ /* reset property? */
+ accentcode= 0;
+
return OPERATOR_FINISHED;
}
@@ -1353,6 +1362,7 @@ void FONT_OT_text_insert(wmOperatorType *ot)
/* properties */
RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position.");
+ RNA_def_boolean(ot->srna, "accent", 0, "Accent mode", "Next typed character will strike through previous, for special character input.");
}
@@ -1367,7 +1377,7 @@ static int textbox_poll(bContext *C)
return 1;
}
-static int textbox_add_exec(bContext *C, wmOperator *op)
+static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit= CTX_data_active_object(C);
Curve *cu= obedit->data;
@@ -1585,7 +1595,7 @@ void FONT_OT_case_set(wmOperatorType *ot)
/********************** toggle case operator *********************/
-static int toggle_case_exec(bContext *C, wmOperator *op)
+static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *obedit= CTX_data_edit_object(C);
Curve *cu= obedit->data;
@@ -1625,7 +1635,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot)
/* **************** Open Font ************** */
-static void open_init(bContext *C, wmOperator *op)
+static void font_ui_template_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
@@ -1633,7 +1643,7 @@ static void open_init(bContext *C, wmOperator *op)
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
}
-static int open_cancel(bContext *C, wmOperator *op)
+static int open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata= NULL;
@@ -1642,67 +1652,66 @@ static int open_cancel(bContext *C, wmOperator *op)
static int open_exec(bContext *C, wmOperator *op)
{
- Object *ob = CTX_data_active_object(C);
- Curve *cu;
VFont *font;
PropertyPointerRNA *pprop;
PointerRNA idptr;
char str[FILE_MAX];
-
RNA_string_get(op->ptr, "filepath", str);
font = load_vfont(str);
-
+
if(!font) {
if(op->customdata) MEM_freeN(op->customdata);
return OPERATOR_CANCELLED;
}
-
+
if(!op->customdata)
- open_init(C, op);
+ font_ui_template_init(C, op);
/* hook into UI */
pprop= op->customdata;
-
+
if(pprop->prop) {
/* when creating new ID blocks, use is already 1, but RNA
* pointer se also increases user, so this compensates it */
font->id.us--;
-
+
RNA_id_pointer_create(&font->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
RNA_property_update(C, &pprop->ptr, pprop->prop);
- } else if(ob && ob->type == OB_FONT) {
- cu = ob->data;
- id_us_min(&cu->vfont->id);
- cu->vfont = font;
}
-
- DAG_id_flush_update(ob->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA|NA_EDITED, ob->data);
-
+
MEM_freeN(op->customdata);
-
+
return OPERATOR_FINISHED;
}
-static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
- Object *ob = CTX_data_active_object(C);
- Curve *cu;
VFont *font=NULL;
char *path;
- if (ob && ob->type == OB_FONT) {
- cu = ob->data;
- font = cu->vfont;
+
+ PointerRNA idptr;
+ PropertyPointerRNA *pprop;
+
+ font_ui_template_init(C, op);
+
+ /* hook into UI */
+ pprop= op->customdata;
+
+ if(pprop->prop) {
+ idptr= RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop);
+ font= idptr.id.data;
}
- path = (font && font->name)? font->name: U.fontdir;
-
+
+ path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir;
+
+ if(!RNA_property_is_set(op->ptr, "relative_path"))
+ RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
+
if(RNA_property_is_set(op->ptr, "filepath"))
return open_exec(C, op);
-
- open_init(C, op);
-
+
RNA_string_set(op->ptr, "filepath", path);
WM_event_add_fileselect(C, op);
@@ -1724,52 +1733,31 @@ void FONT_OT_open(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
}
/******************* delete operator *********************/
-static int font_unlink_poll(bContext *C)
-{
- Object *ob = CTX_data_active_object(C);
- Curve *cu;
-
- if (!ED_operator_object_active_editable(C) ) return 0;
- if (ob->type != OB_FONT) return 0;
-
- cu = ob->data;
- if (cu && strcmp(cu->vfont->name, "<builtin>")==0) return 0;
- return 1;
-}
static int font_unlink_exec(bContext *C, wmOperator *op)
{
- Object *ob = CTX_data_active_object(C);
- Curve *cu;
- VFont *font, *builtin_font;
-
- cu = ob->data;
- font = cu->vfont;
+ VFont *builtin_font;
+
+ PointerRNA idptr;
+ PropertyPointerRNA pprop;
+
+ uiIDContextProperty(C, &pprop.ptr, &pprop.prop);
- if (!font) {
- BKE_report(op->reports, RPT_ERROR, "No font datablock available to unlink.");
+ if(pprop.prop==NULL) {
+ BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink");
return OPERATOR_CANCELLED;
}
-
- if (strcmp(font->name, "<builtin>")==0) {
- BKE_report(op->reports, RPT_WARNING, "Can't unlink the default builtin font.");
- return OPERATOR_FINISHED;
- }
- /* revert back to builtin font */
builtin_font = get_builtin_font();
- cu->vfont = builtin_font;
- id_us_plus(&cu->vfont->id);
- id_us_min(&font->id);
-
- DAG_id_flush_update(ob->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA|NA_EDITED, ob->data);
-
+ RNA_id_pointer_create(&builtin_font->id, &idptr);
+ RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr);
+ RNA_property_update(C, &pprop.ptr, pprop.prop);
+
return OPERATOR_FINISHED;
}
@@ -1782,7 +1770,6 @@ void FONT_OT_unlink(wmOperatorType *ot)
/* api callbacks */
ot->exec= font_unlink_exec;
- ot->poll= font_unlink_poll;
}
@@ -1839,7 +1826,7 @@ static void *get_undoFont(bContext *C)
}
/* and this is all the undo system needs to know */
-void undo_push_font(bContext *C, char *name)
+void undo_push_font(bContext *C, const char *name)
{
undo_editmode_push(C, name, get_undoFont, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL);
}