diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 07:05:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-06 07:05:34 +0300 |
commit | 7613d36b2afed5f3dd460fd817b443b5645be234 (patch) | |
tree | b7673164ec5241539fc383a6438789ebc6941ed9 /source/blender/editors/curve | |
parent | a1fed1e268aa3bd6ad32acf751022e5f12db0233 (diff) |
bugfix [#25046] Bold and Italics checkboxes for Text objects seem to do nothing
- Part of this report is a misunderstanding, but there was no access to bold/italic fonts.
- Added rna access and changed the operators to use only rna properties.
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r-- | source/blender/editors/curve/editfont.c | 95 |
1 files changed, 34 insertions, 61 deletions
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index b23cc8bf3a3..ef49abd4dbd 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1625,7 +1625,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; @@ -1642,68 +1642,63 @@ static int open_cancel(bContext *UNUSED(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_tag_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 *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 && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir; - + 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); @@ -1729,48 +1724,27 @@ void FONT_OT_open(wmOperatorType *ot) } /******************* 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, FO_BUILTIN_NAME)==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, FO_BUILTIN_NAME)==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_tag_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; } @@ -1783,7 +1757,6 @@ void FONT_OT_unlink(wmOperatorType *ot) /* api callbacks */ ot->exec= font_unlink_exec; - ot->poll= font_unlink_poll; } |