forked from bartvdbraak/blender
code cleanup: BKE_ naming, also make bpy.data.images.load() always load a new image. (not use existing one)
This commit is contained in:
parent
299ff91ea1
commit
34b18fcbc1
@ -71,17 +71,17 @@ typedef struct EditFont {
|
||||
} EditFont;
|
||||
|
||||
|
||||
void BKE_font_register_builtin(void *mem, int size);
|
||||
void BKE_vfont_builtin_register(void *mem, int size);
|
||||
|
||||
void BKE_vfont_free(struct VFont *sc);
|
||||
void free_ttfont(void);
|
||||
struct VFont *get_builtin_font(void);
|
||||
struct VFont *load_vfont(struct Main *bmain, const char *name);
|
||||
struct TmpFont *vfont_find_tmpfont(struct VFont *vfont);
|
||||
void BKE_vfont_free_global_ttf(void);
|
||||
struct VFont *BKE_vfont_builtin_get(void);
|
||||
struct VFont *BKE_vfont_load(struct Main *bmain, const char *name);
|
||||
struct TmpFont *BKE_vfont_find_tmpfont(struct VFont *vfont);
|
||||
|
||||
struct chartrans *BKE_text_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode);
|
||||
struct chartrans *BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode);
|
||||
|
||||
int BKE_font_getselection(struct Object *ob, int *start, int *end);
|
||||
int BKE_vfont_select_get(struct Object *ob, int *start, int *end);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ struct anim *openanim(const char *name, int flags, int streamindex);
|
||||
|
||||
void image_de_interlace(struct Image *ima, int odd);
|
||||
|
||||
void make_local_image(struct Image *ima);
|
||||
void BKE_image_make_local(struct Image *ima);
|
||||
|
||||
void tag_image_time(struct Image *ima);
|
||||
void free_old_images(void);
|
||||
@ -130,8 +130,10 @@ struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser);
|
||||
struct ImBuf *BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **lock_r);
|
||||
void BKE_image_release_ibuf(struct Image *ima, void *lock);
|
||||
|
||||
/* returns a new image or NULL if it can't load */
|
||||
struct Image *BKE_image_load(const char *filepath);
|
||||
/* returns existing Image when filename/type is same (frame optional) */
|
||||
struct Image *BKE_add_image_file(const char *name);
|
||||
struct Image *BKE_image_load_exists(const char *filepath);
|
||||
|
||||
/* adds image, adds ibuf, generates color or pattern */
|
||||
struct Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]);
|
||||
|
@ -45,14 +45,14 @@ struct SpaceText;
|
||||
void BKE_text_free (struct Text *text);
|
||||
void txt_set_undostate (int u);
|
||||
int txt_get_undostate (void);
|
||||
struct Text* add_empty_text (const char *name);
|
||||
struct Text* BKE_text_add (const char *name);
|
||||
int txt_extended_ascii_as_utf8(char **str);
|
||||
int reopen_text (struct Text *text);
|
||||
struct Text* add_text (const char *file, const char *relpath);
|
||||
int BKE_text_reload (struct Text *text);
|
||||
struct Text* BKE_text_load (const char *file, const char *relpath);
|
||||
struct Text* BKE_text_copy (struct Text *ta);
|
||||
void BKE_text_unlink (struct Main *bmain, struct Text *text);
|
||||
void clear_text(struct Text *text);
|
||||
void write_text(struct Text *text, const char *str);
|
||||
void BKE_text_clear (struct Text *text);
|
||||
void BKE_text_write (struct Text *text, const char *str);
|
||||
|
||||
char* txt_to_buf (struct Text *text);
|
||||
void txt_clean_text (struct Text *text);
|
||||
|
@ -1545,7 +1545,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
|
||||
|
||||
/* in par the family name is stored, use this to find the other objects */
|
||||
|
||||
chartransdata= BKE_text_to_curve(G.main, scene, par, FO_DUPLI);
|
||||
chartransdata= BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI);
|
||||
if (chartransdata==NULL) return;
|
||||
|
||||
cu= par->data;
|
||||
|
@ -175,7 +175,7 @@ Curve *BKE_curve_add(const char *name, int type)
|
||||
cu->bb= BKE_boundbox_alloc_unit();
|
||||
|
||||
if (type==OB_FONT) {
|
||||
cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= get_builtin_font();
|
||||
cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= BKE_vfont_builtin_get();
|
||||
cu->vfont->id.us+=4;
|
||||
cu->str= MEM_mallocN(12, "str");
|
||||
BLI_strncpy(cu->str, "Text", 12);
|
||||
|
@ -1271,7 +1271,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
if (cu->path) free_path(cu->path);
|
||||
cu->path= NULL;
|
||||
|
||||
if (ob->type==OB_FONT) BKE_text_to_curve(G.main, scene, ob, 0);
|
||||
if (ob->type==OB_FONT) BKE_vfont_to_curve(G.main, scene, ob, 0);
|
||||
|
||||
if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
|
||||
|
||||
|
@ -93,7 +93,7 @@ void BKE_vfont_free(struct VFont *vf)
|
||||
static void *builtin_font_data= NULL;
|
||||
static int builtin_font_size= 0;
|
||||
|
||||
void BKE_font_register_builtin(void *mem, int size)
|
||||
void BKE_vfont_builtin_register(void *mem, int size)
|
||||
{
|
||||
builtin_font_data= mem;
|
||||
builtin_font_size= size;
|
||||
@ -115,7 +115,7 @@ static PackedFile *get_builtin_packedfile(void)
|
||||
}
|
||||
}
|
||||
|
||||
void free_ttfont(void)
|
||||
void BKE_vfont_free_global_ttf(void)
|
||||
{
|
||||
struct TmpFont *tf;
|
||||
|
||||
@ -127,7 +127,7 @@ void free_ttfont(void)
|
||||
BLI_freelistN(&ttfdata);
|
||||
}
|
||||
|
||||
struct TmpFont *vfont_find_tmpfont(VFont *vfont)
|
||||
struct TmpFont *BKE_vfont_find_tmpfont(VFont *vfont)
|
||||
{
|
||||
struct TmpFont *tmpfnt = NULL;
|
||||
|
||||
@ -151,7 +151,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
|
||||
if (vfont==NULL) return NULL;
|
||||
|
||||
// Try finding the font from font list
|
||||
tmpfnt = vfont_find_tmpfont(vfont);
|
||||
tmpfnt = BKE_vfont_find_tmpfont(vfont);
|
||||
|
||||
// And then set the data
|
||||
if (!vfont->data) {
|
||||
@ -210,7 +210,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
|
||||
return vfont->data;
|
||||
}
|
||||
|
||||
VFont *load_vfont(Main *bmain, const char *name)
|
||||
VFont *BKE_vfont_load(Main *bmain, const char *name)
|
||||
{
|
||||
char filename[FILE_MAXFILE];
|
||||
VFont *vfont= NULL;
|
||||
@ -290,7 +290,7 @@ static VFont *which_vfont(Curve *cu, CharInfo *info)
|
||||
}
|
||||
}
|
||||
|
||||
VFont *get_builtin_font(void)
|
||||
VFont *BKE_vfont_builtin_get(void)
|
||||
{
|
||||
VFont *vf;
|
||||
|
||||
@ -298,7 +298,7 @@ VFont *get_builtin_font(void)
|
||||
if (strcmp(vf->name, FO_BUILTIN_NAME)==0)
|
||||
return vf;
|
||||
|
||||
return load_vfont(G.main, FO_BUILTIN_NAME);
|
||||
return BKE_vfont_load(G.main, FO_BUILTIN_NAME);
|
||||
}
|
||||
|
||||
static VChar *find_vfont_char(VFontData *vfd, intptr_t character)
|
||||
@ -487,7 +487,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo
|
||||
}
|
||||
}
|
||||
|
||||
int BKE_font_getselection(Object *ob, int *start, int *end)
|
||||
int BKE_vfont_select_get(Object *ob, int *start, int *end)
|
||||
{
|
||||
Curve *cu= ob->data;
|
||||
|
||||
@ -520,7 +520,7 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info)
|
||||
}
|
||||
}
|
||||
|
||||
struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int mode)
|
||||
struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode)
|
||||
{
|
||||
VFont *vfont, *oldvfont;
|
||||
VFontData *vfd= NULL;
|
||||
@ -605,7 +605,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
|
||||
|
||||
if (cu->selboxes) MEM_freeN(cu->selboxes);
|
||||
cu->selboxes = NULL;
|
||||
if (BKE_font_getselection(ob, &selstart, &selend))
|
||||
if (BKE_vfont_select_get(ob, &selstart, &selend))
|
||||
cu->selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes");
|
||||
|
||||
tb = &(cu->tb[0]);
|
||||
|
@ -327,7 +327,7 @@ static void extern_local_image(Image *UNUSED(ima))
|
||||
* match id_make_local pattern. */
|
||||
}
|
||||
|
||||
void make_local_image(struct Image *ima)
|
||||
void BKE_image_make_local(struct Image *ima)
|
||||
{
|
||||
Main *bmain= G.main;
|
||||
Tex *tex;
|
||||
@ -505,19 +505,14 @@ void BKE_image_merge(Image *dest, Image *source)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* checks if image was already loaded, then returns same image */
|
||||
/* otherwise creates new. */
|
||||
/* does not load ibuf itself */
|
||||
/* pass on optional frame for #name images */
|
||||
Image *BKE_add_image_file(const char *name)
|
||||
Image *BKE_image_load(const char *filepath)
|
||||
{
|
||||
Image *ima;
|
||||
int file, len;
|
||||
const char *libname;
|
||||
char str[FILE_MAX], strtest[FILE_MAX];
|
||||
char str[FILE_MAX];
|
||||
|
||||
BLI_strncpy(str, name, sizeof(str));
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
BLI_path_abs(str, G.main->name);
|
||||
|
||||
/* exists? */
|
||||
@ -525,6 +520,33 @@ Image *BKE_add_image_file(const char *name)
|
||||
if (file== -1) return NULL;
|
||||
close(file);
|
||||
|
||||
/* create a short library name */
|
||||
len= strlen(filepath);
|
||||
|
||||
while (len > 0 && filepath[len - 1] != '/' && filepath[len - 1] != '\\') len--;
|
||||
libname= filepath+len;
|
||||
|
||||
ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE);
|
||||
BLI_strncpy(ima->name, filepath, sizeof(ima->name));
|
||||
|
||||
if (BLI_testextensie_array(filepath, imb_ext_movie))
|
||||
ima->source= IMA_SRC_MOVIE;
|
||||
|
||||
return ima;
|
||||
}
|
||||
|
||||
/* checks if image was already loaded, then returns same image */
|
||||
/* otherwise creates new. */
|
||||
/* does not load ibuf itself */
|
||||
/* pass on optional frame for #name images */
|
||||
Image *BKE_image_load_exists(const char *filepath)
|
||||
{
|
||||
Image *ima;
|
||||
char str[FILE_MAX], strtest[FILE_MAX];
|
||||
|
||||
BLI_strncpy(str, filepath, sizeof(str));
|
||||
BLI_path_abs(str, G.main->name);
|
||||
|
||||
/* first search an identical image */
|
||||
for (ima= G.main->image.first; ima; ima= ima->id.next) {
|
||||
if (ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) {
|
||||
@ -533,7 +555,7 @@ Image *BKE_add_image_file(const char *name)
|
||||
|
||||
if (BLI_path_cmp(strtest, str)==0) {
|
||||
if (ima->anim==NULL || ima->id.us==0) {
|
||||
BLI_strncpy(ima->name, name, sizeof(ima->name)); /* for stringcode */
|
||||
BLI_strncpy(ima->name, filepath, sizeof(ima->name)); /* for stringcode */
|
||||
ima->id.us++; /* officially should not, it doesn't link here! */
|
||||
if (ima->ok==0)
|
||||
ima->ok= IMA_OK;
|
||||
@ -543,21 +565,8 @@ Image *BKE_add_image_file(const char *name)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* add new image */
|
||||
|
||||
/* create a short library name */
|
||||
len= strlen(name);
|
||||
|
||||
while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\') len--;
|
||||
libname= name+len;
|
||||
|
||||
ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE);
|
||||
BLI_strncpy(ima->name, name, sizeof(ima->name));
|
||||
|
||||
if (BLI_testextensie_array(name, imb_ext_movie))
|
||||
ima->source= IMA_SRC_MOVIE;
|
||||
|
||||
return ima;
|
||||
return BKE_image_load(filepath);
|
||||
}
|
||||
|
||||
static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4])
|
||||
|
@ -212,7 +212,7 @@ int id_make_local(ID *id, int test)
|
||||
if (!test) make_local_texture((Tex *)id);
|
||||
return 1;
|
||||
case ID_IM:
|
||||
if (!test) make_local_image((Image *)id);
|
||||
if (!test) BKE_image_make_local((Image *)id);
|
||||
return 1;
|
||||
case ID_LT:
|
||||
if (!test) {
|
||||
|
@ -180,7 +180,7 @@ void BKE_text_free(Text *text)
|
||||
#endif
|
||||
}
|
||||
|
||||
Text *add_empty_text(const char *name)
|
||||
Text *BKE_text_add(const char *name)
|
||||
{
|
||||
Main *bmain= G.main;
|
||||
Text *ta;
|
||||
@ -278,7 +278,7 @@ static void cleanup_textline(TextLine * tl)
|
||||
tl->len+= txt_extended_ascii_as_utf8(&tl->line);
|
||||
}
|
||||
|
||||
int reopen_text(Text *text)
|
||||
int BKE_text_reload(Text *text)
|
||||
{
|
||||
FILE *fp;
|
||||
int i, llen, len;
|
||||
@ -373,7 +373,7 @@ int reopen_text(Text *text)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Text *add_text(const char *file, const char *relpath)
|
||||
Text *BKE_text_load(const char *file, const char *relpath)
|
||||
{
|
||||
Main *bmain= G.main;
|
||||
FILE *fp;
|
||||
@ -593,7 +593,7 @@ void BKE_text_unlink(Main *bmain, Text *text)
|
||||
text->id.us= 0;
|
||||
}
|
||||
|
||||
void clear_text(Text *text) /* called directly from rna */
|
||||
void BKE_text_clear(Text *text) /* called directly from rna */
|
||||
{
|
||||
int oldstate;
|
||||
|
||||
@ -606,7 +606,7 @@ void clear_text(Text *text) /* called directly from rna */
|
||||
txt_make_dirty(text);
|
||||
}
|
||||
|
||||
void write_text(Text *text, const char *str) /* called directly from rna */
|
||||
void BKE_text_write(Text *text, const char *str) /* called directly from rna */
|
||||
{
|
||||
int oldstate;
|
||||
|
||||
|
@ -297,7 +297,7 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode)
|
||||
struct TmpFont *tf;
|
||||
|
||||
// Find the correct FreeType font
|
||||
tf= vfont_find_tmpfont(vfont);
|
||||
tf= BKE_vfont_find_tmpfont(vfont);
|
||||
|
||||
// What, no font found. Something strange here
|
||||
if (!tf) return FALSE;
|
||||
|
@ -2955,7 +2955,7 @@ static void direct_link_text(FileData *fd, Text *text)
|
||||
|
||||
#if 0
|
||||
if (text->flags & TXT_ISEXT) {
|
||||
reopen_text(text);
|
||||
BKE_text_reload(text);
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
|
@ -921,7 +921,7 @@ bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
|
||||
|
||||
BLI_split_dir_part(filename, dir, sizeof(dir));
|
||||
BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str());
|
||||
Image *ima = BKE_add_image_file(full_path);
|
||||
Image *ima = BKE_image_load_exists(full_path);
|
||||
if (!ima) {
|
||||
fprintf(stderr, "Cannot create image.\n");
|
||||
return true;
|
||||
|
@ -275,7 +275,7 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re
|
||||
if (mode == FO_EDIT)
|
||||
update_string(cu);
|
||||
|
||||
BKE_text_to_curve(bmain, scene, obedit, mode);
|
||||
BKE_vfont_to_curve(bmain, scene, obedit, mode);
|
||||
|
||||
if (recalc)
|
||||
DAG_id_tag_update(obedit->data, 0);
|
||||
@ -449,7 +449,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float
|
||||
obedit->loc[2] += offset[2];
|
||||
|
||||
cu= obedit->data;
|
||||
cu->vfont= get_builtin_font();
|
||||
cu->vfont= BKE_vfont_builtin_get();
|
||||
cu->vfont->id.us++;
|
||||
|
||||
for (tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, a++)
|
||||
@ -556,7 +556,7 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */
|
||||
int offset = 0;
|
||||
int getfrom;
|
||||
|
||||
direction = BKE_font_getselection(obedit, &selstart, &selend);
|
||||
direction = BKE_vfont_select_get(obedit, &selstart, &selend);
|
||||
if (direction) {
|
||||
int size;
|
||||
if (ins) offset = 1;
|
||||
@ -593,7 +593,7 @@ static int set_style(bContext *C, const int style, const int clear)
|
||||
EditFont *ef= cu->editfont;
|
||||
int i, selstart, selend;
|
||||
|
||||
if (!BKE_font_getselection(obedit, &selstart, &selend))
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
for (i=selstart; i<=selend; i++) {
|
||||
@ -644,7 +644,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op)
|
||||
Curve *cu= obedit->data;
|
||||
int style, clear, selstart, selend;
|
||||
|
||||
if (!BKE_font_getselection(obedit, &selstart, &selend))
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
style= RNA_enum_get(op->ptr, "style");
|
||||
@ -679,7 +679,7 @@ static void copy_selection(Object *obedit)
|
||||
{
|
||||
int selstart, selend;
|
||||
|
||||
if (BKE_font_getselection(obedit, &selstart, &selend)) {
|
||||
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
|
||||
Curve *cu= obedit->data;
|
||||
EditFont *ef= cu->editfont;
|
||||
|
||||
@ -718,7 +718,7 @@ static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
int selstart, selend;
|
||||
|
||||
if (!BKE_font_getselection(obedit, &selstart, &selend))
|
||||
if (!BKE_vfont_select_get(obedit, &selstart, &selend))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
copy_selection(obedit);
|
||||
@ -901,7 +901,7 @@ static int move_cursor(bContext *C, int type, int select)
|
||||
struct Main *bmain= CTX_data_main(C);
|
||||
cu->selstart = cu->selend = 0;
|
||||
update_string(cu);
|
||||
BKE_text_to_curve(bmain, scene, obedit, FO_SELCHANGE);
|
||||
BKE_vfont_to_curve(bmain, scene, obedit, FO_SELCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1121,7 +1121,7 @@ static int delete_exec(bContext *C, wmOperator *op)
|
||||
if (cu->len == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if (BKE_font_getselection(obedit, &selstart, &selend)) {
|
||||
if (BKE_vfont_select_get(obedit, &selstart, &selend)) {
|
||||
if (type == DEL_NEXT_SEL) type= DEL_SELECTION;
|
||||
else if (type == DEL_PREV_SEL) type= DEL_SELECTION;
|
||||
}
|
||||
@ -1634,7 +1634,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
|
||||
char filepath[FILE_MAX];
|
||||
RNA_string_get(op->ptr, "filepath", filepath);
|
||||
|
||||
font= load_vfont(bmain, filepath);
|
||||
font= BKE_vfont_load(bmain, filepath);
|
||||
|
||||
if (!font) {
|
||||
if (op->customdata) MEM_freeN(op->customdata);
|
||||
@ -1726,7 +1726,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
builtin_font = get_builtin_font();
|
||||
builtin_font = BKE_vfont_builtin_get();
|
||||
|
||||
RNA_id_pointer_create(&builtin_font->id, &idptr);
|
||||
RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr);
|
||||
|
@ -507,7 +507,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
char *str;
|
||||
|
||||
/* create new text-block to write to */
|
||||
txt = add_empty_text("Recent Reports");
|
||||
txt = BKE_text_add("Recent Reports");
|
||||
|
||||
/* convert entire list to a display string, and add this to the text-block
|
||||
* - if commandline debug option enabled, show debug reports too
|
||||
@ -516,7 +516,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
str = BKE_reports_string(reports, (G.debug & G_DEBUG) ? RPT_DEBUG : RPT_INFO);
|
||||
|
||||
if (str) {
|
||||
write_text(txt, str);
|
||||
BKE_text_write(txt, str);
|
||||
MEM_freeN(str);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@ -652,7 +652,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
|
||||
}
|
||||
|
||||
if (text == NULL) {
|
||||
text = add_text(filepath, bmain->name);
|
||||
text = BKE_text_load(filepath, bmain->name);
|
||||
}
|
||||
|
||||
if (text == NULL) {
|
||||
|
@ -556,7 +556,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
char path[FILE_MAX];
|
||||
|
||||
RNA_string_get(op->ptr, "filepath", path);
|
||||
ima = BKE_add_image_file(path);
|
||||
ima = BKE_image_load_exists(path);
|
||||
}
|
||||
else {
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
|
@ -885,7 +885,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
|
||||
cu1->vfontbi = cu->vfontbi;
|
||||
id_us_plus((ID *)cu1->vfontbi);
|
||||
|
||||
BKE_text_to_curve(bmain, scene, base->object, 0); /* needed? */
|
||||
BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */
|
||||
|
||||
|
||||
BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
|
||||
|
@ -190,7 +190,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
EditFont *ef = ((Curve *)ob->data)->editfont;
|
||||
int i, selstart, selend;
|
||||
|
||||
if (ef && BKE_font_getselection(ob, &selstart, &selend)) {
|
||||
if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) {
|
||||
for (i = selstart; i <= selend; i++)
|
||||
ef->textbufinfo[i].mat_nr = ob->actcol;
|
||||
}
|
||||
|
@ -833,7 +833,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
|
||||
|
||||
errno = 0;
|
||||
|
||||
ima = BKE_add_image_file(str);
|
||||
ima = BKE_image_load_exists(str);
|
||||
|
||||
if (!ima) {
|
||||
if (op->customdata) MEM_freeN(op->customdata);
|
||||
|
@ -3408,7 +3408,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
|
||||
|
||||
errno= 0;
|
||||
|
||||
ima= BKE_add_image_file(path);
|
||||
ima= BKE_image_load_exists(path);
|
||||
|
||||
if (!ima) {
|
||||
BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format");
|
||||
|
@ -167,7 +167,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
PointerRNA ptr, idptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
text = add_empty_text("Text");
|
||||
text = BKE_text_add("Text");
|
||||
|
||||
/* hook into UI */
|
||||
uiIDContextProperty(C, &ptr, &prop);
|
||||
@ -236,7 +236,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
|
||||
|
||||
RNA_string_get(op->ptr, "filepath", str);
|
||||
|
||||
text = add_text(str, G.main->name);
|
||||
text = BKE_text_load(str, G.main->name);
|
||||
|
||||
if (!text) {
|
||||
if (op->customdata) MEM_freeN(op->customdata);
|
||||
@ -320,7 +320,7 @@ static int text_reload_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Text *text = CTX_data_edit_text(C);
|
||||
|
||||
if (!reopen_text(text)) {
|
||||
if (!BKE_text_reload(text)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Could not reopen file");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
@ -6647,7 +6647,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
|
||||
setlinestyle(0);
|
||||
|
||||
|
||||
if (BKE_font_getselection(ob, &selstart, &selend) && cu->selboxes) {
|
||||
if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) {
|
||||
float selboxw;
|
||||
|
||||
cpack(0xffffff);
|
||||
|
@ -3094,7 +3094,7 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU
|
||||
char path[FILE_MAX];
|
||||
|
||||
RNA_string_get(op->ptr, "filepath", path);
|
||||
ima = BKE_add_image_file(path);
|
||||
ima = BKE_image_load_exists(path);
|
||||
}
|
||||
else if (RNA_struct_property_is_set(op->ptr, "name")) {
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
|
@ -269,7 +269,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag)
|
||||
if (ob->type == OB_FONT) {
|
||||
Curve *cu = ob->data;
|
||||
freedisplist(&cu->disp);
|
||||
BKE_text_to_curve(sce, ob, CU_LEFT);
|
||||
BKE_vfont_to_curve(sce, ob, CU_LEFT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -278,7 +278,7 @@ Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char
|
||||
Image *ima;
|
||||
|
||||
errno = 0;
|
||||
ima = BKE_add_image_file(filepath);
|
||||
ima = BKE_image_load(filepath);
|
||||
|
||||
if (!ima)
|
||||
BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath,
|
||||
@ -347,7 +347,7 @@ VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepat
|
||||
VFont *font;
|
||||
|
||||
errno = 0;
|
||||
font = load_vfont(bmain, filepath);
|
||||
font = BKE_vfont_load(bmain, filepath);
|
||||
|
||||
if (!font)
|
||||
BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath,
|
||||
@ -443,7 +443,7 @@ void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker
|
||||
|
||||
Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name)
|
||||
{
|
||||
return add_empty_text(name);
|
||||
return BKE_text_add(name);
|
||||
}
|
||||
void rna_Main_texts_remove(Main *bmain, Text *text)
|
||||
{
|
||||
@ -457,7 +457,7 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath
|
||||
Text *txt;
|
||||
|
||||
errno = 0;
|
||||
txt = add_text(filepath, bmain->name);
|
||||
txt = BKE_text_load(filepath, bmain->name);
|
||||
|
||||
if (!txt)
|
||||
BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath,
|
||||
|
@ -37,13 +37,13 @@
|
||||
|
||||
static void rna_Text_clear(Text *text)
|
||||
{
|
||||
clear_text(text);
|
||||
BKE_text_clear(text);
|
||||
WM_main_add_notifier(NC_TEXT|NA_EDITED, text);
|
||||
}
|
||||
|
||||
static void rna_Text_write(Text *text, const char *str)
|
||||
{
|
||||
write_text(text, str);
|
||||
BKE_text_write(text, str);
|
||||
WM_main_add_notifier(NC_TEXT|NA_EDITED, text);
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
|
||||
char tstr[FILE_MAX];
|
||||
int success = 0;
|
||||
|
||||
free_ttfont(); /* still weird... what does it here? */
|
||||
BKE_vfont_free_global_ttf(); /* still weird... what does it here? */
|
||||
|
||||
G.relbase_valid = 0;
|
||||
if (!from_memory) {
|
||||
|
@ -360,7 +360,7 @@ void WM_exit_ext(bContext *C, const short do_python)
|
||||
// BIF_freeRetarget();
|
||||
BIF_freeTemplates(C);
|
||||
|
||||
free_ttfont(); /* bke_font.h */
|
||||
BKE_vfont_free_global_ttf(); /* bke_font.h */
|
||||
|
||||
free_openrecent();
|
||||
|
||||
|
@ -1270,7 +1270,7 @@ int main(int argc, const char **argv)
|
||||
#endif
|
||||
|
||||
/* background render uses this font too */
|
||||
BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);
|
||||
BKE_vfont_builtin_register(datatoc_Bfont, datatoc_Bfont_size);
|
||||
|
||||
/* Initialize ffmpeg if built in, also needed for bg mode if videos are
|
||||
* rendered via ffmpeg */
|
||||
|
@ -870,7 +870,7 @@ int main(int argc, char** argv)
|
||||
if (domeWarp)
|
||||
{
|
||||
//XXX to do: convert relative to absolute path
|
||||
domeText= add_text(domeWarp, "");
|
||||
domeText= BKE_text_load(domeWarp, "");
|
||||
if (!domeText)
|
||||
printf("error: invalid warpdata text file - %s\n", domeWarp);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user