Cleanup: API naming use BKE_undo_ prefix

This commit is contained in:
Campbell Barton 2015-04-18 15:41:12 +02:00
parent 38bea4e86c
commit 252b0cf5d2
14 changed files with 72 additions and 66 deletions

View File

@ -93,15 +93,15 @@ int blender_test_break(void);
#define BKE_UNDO_STR_MAX 64
/* global undo */
extern void BKE_write_undo(struct bContext *C, const char *name);
extern void BKE_undo_step(struct bContext *C, int step);
extern void BKE_undo_name(struct bContext *C, const char *name);
extern int BKE_undo_valid(const char *name);
extern void BKE_reset_undo(void);
extern void BKE_undo_number(struct bContext *C, int nr);
extern const char *BKE_undo_get_name(int nr, int *active);
extern bool BKE_undo_save_file(const char *filename);
extern struct Main *BKE_undo_get_main(struct Scene **scene);
extern void BKE_undo_write(struct bContext *C, const char *name);
extern void BKE_undo_step(struct bContext *C, int step);
extern void BKE_undo_name(struct bContext *C, const char *name);
extern bool BKE_undo_is_valid(const char *name);
extern void BKE_undo_reset(void);
extern void BKE_undo_number(struct bContext *C, int nr);
extern const char *BKE_undo_get_name(int nr, bool *r_active);
extern bool BKE_undo_save_file(const char *filename);
extern struct Main *BKE_undo_get_main(struct Scene **r_scene);
/* copybuffer */
void BKE_copybuffer_begin(struct Main *bmain);

View File

@ -687,7 +687,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
}
/* name can be a dynamic string */
void BKE_write_undo(bContext *C, const char *name)
void BKE_undo_write(bContext *C, const char *name)
{
uintptr_t maxmem, totmem, memused;
int nr /*, success */ /* UNUSED */;
@ -821,7 +821,7 @@ void BKE_undo_step(bContext *C, int step)
}
}
void BKE_reset_undo(void)
void BKE_undo_reset(void)
{
UndoElem *uel;
@ -854,7 +854,7 @@ void BKE_undo_name(bContext *C, const char *name)
}
/* name optional */
int BKE_undo_valid(const char *name)
bool BKE_undo_is_valid(const char *name)
{
if (name) {
UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name));
@ -866,15 +866,16 @@ int BKE_undo_valid(const char *name)
/* get name of undo item, return null if no item with this index */
/* if active pointer, set it to 1 if true */
const char *BKE_undo_get_name(int nr, int *active)
const char *BKE_undo_get_name(int nr, bool *r_active)
{
UndoElem *uel = BLI_findlink(&undobase, nr);
if (active) *active = 0;
if (r_active) *r_active = false;
if (uel) {
if (active && uel == curundo)
*active = 1;
if (r_active && (uel == curundo)) {
*r_active = true;
}
return uel->name;
}
return NULL;
@ -940,15 +941,16 @@ bool BKE_undo_save_file(const char *filename)
}
/* sets curscene */
Main *BKE_undo_get_main(Scene **scene)
Main *BKE_undo_get_main(Scene **r_scene)
{
Main *mainp = NULL;
BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL);
if (bfd) {
mainp = bfd->main;
if (scene)
*scene = bfd->curscene;
if (r_scene) {
*r_scene = bfd->curscene;
}
MEM_freeN(bfd);
}

View File

@ -46,9 +46,9 @@ typedef bool (*UndoCleanupCb)(struct bContext *C, struct ListBase *lb);
int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name);
void ED_undo_paint_step_num(struct bContext *C, int type, int num);
const char *ED_undo_paint_get_name(struct bContext *C, int type, int nr, int *active);
const char *ED_undo_paint_get_name(struct bContext *C, int type, int nr, bool *r_active);
void ED_undo_paint_free(void);
int ED_undo_paint_valid(int type, const char *name);
bool ED_undo_paint_is_valid(int type, const char *name);
bool ED_undo_paint_empty(int type);
void ED_undo_paint_push_begin(int type, const char *name, UndoRestoreCb restore, UndoFreeCb free, UndoCleanupCb cleanup);
void ED_undo_paint_push_end(int type);

View File

@ -66,9 +66,9 @@ void PE_undo_push(struct Scene *scene, const char *str);
void PE_undo_step(struct Scene *scene, int step);
void PE_undo(struct Scene *scene);
void PE_redo(struct Scene *scene);
int PE_undo_valid(struct Scene *scene);
bool PE_undo_is_valid(struct Scene *scene);
void PE_undo_number(struct Scene *scene, int nr);
const char *PE_undo_get_name(struct Scene *scene, int nr, int *active);
const char *PE_undo_get_name(struct Scene *scene, int nr, bool *r_active);
#endif /* __ED_PARTICLE_H__ */

View File

@ -60,7 +60,7 @@ int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op);
void ED_undo_operator_repeat_cb(struct bContext *C, void *arg_op, void *arg_unused);
void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg_unused);
int ED_undo_valid(const struct bContext *C, const char *undoname);
bool ED_undo_is_valid(const struct bContext *C, const char *undoname);
/* undo_editmode.c */
void undo_editmode_push(struct bContext *C, const char *name,

View File

@ -4445,7 +4445,7 @@ void PE_undo_step(Scene *scene, int step)
DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
}
int PE_undo_valid(Scene *scene)
bool PE_undo_is_valid(Scene *scene)
{
PTCacheEdit *edit= PE_get_current(scene, OBACT);
@ -4496,18 +4496,19 @@ void PE_undo_number(Scene *scene, int nr)
/* get name of undo item, return null if no item with this index */
/* if active pointer, set it to 1 if true */
const char *PE_undo_get_name(Scene *scene, int nr, int *active)
const char *PE_undo_get_name(Scene *scene, int nr, bool *r_active)
{
PTCacheEdit *edit= PE_get_current(scene, OBACT);
PTCacheUndo *undo;
if (active) *active= 0;
if (r_active) *r_active = false;
if (edit) {
undo= BLI_findlink(&edit->undo, nr);
if (undo) {
if (active && undo==edit->curundo)
*active= 1;
if (r_active && (undo == edit->curundo)) {
*r_active = true;
}
return undo->name;
}
}

View File

@ -331,32 +331,33 @@ void ED_undo_paint_step_num(bContext *C, int type, int step)
undo_step_num(C, &MeshUndoStack, step);
}
static char *undo_stack_get_name(UndoStack *stack, int nr, int *active)
static char *undo_stack_get_name(UndoStack *stack, int nr, bool *r_active)
{
UndoElem *uel;
if (active) *active = 0;
if (r_active) *r_active = false;
uel = BLI_findlink(&stack->elems, nr);
if (uel) {
if (active && uel == stack->current)
*active = 1;
if (r_active && (uel == stack->current)) {
*r_active = true;
}
return uel->name;
}
return NULL;
}
const char *ED_undo_paint_get_name(bContext *C, int type, int nr, int *active)
const char *ED_undo_paint_get_name(bContext *C, int type, int nr, bool *r_active)
{
if (type == UNDO_PAINT_IMAGE) {
undo_stack_cleanup(&ImageUndoStack, C);
return undo_stack_get_name(&ImageUndoStack, nr, active);
return undo_stack_get_name(&ImageUndoStack, nr, r_active);
}
else if (type == UNDO_PAINT_MESH) {
undo_stack_cleanup(&MeshUndoStack, C);
return undo_stack_get_name(&MeshUndoStack, nr, active);
return undo_stack_get_name(&MeshUndoStack, nr, r_active);
}
return NULL;
}
@ -379,7 +380,7 @@ bool ED_undo_paint_empty(int type)
return false;
}
int ED_undo_paint_valid(int type, const char *name)
bool ED_undo_paint_is_valid(int type, const char *name)
{
UndoStack *stack;

View File

@ -315,7 +315,7 @@ void undo_editmode_name(bContext *C, const char *undoname)
}
/* undoname optionally, if NULL it just checks for existing undo steps */
int undo_editmode_valid(const char *undoname)
bool undo_editmode_is_valid(const char *undoname)
{
if (undoname) {
UndoElem *uel;
@ -332,19 +332,20 @@ int undo_editmode_valid(const char *undoname)
/* get name of undo item, return null if no item with this index */
/* if active pointer, set it to 1 if true */
const char *undo_editmode_get_name(bContext *C, int nr, int *active)
const char *undo_editmode_get_name(bContext *C, int nr, bool *r_active)
{
UndoElem *uel;
/* prevent wrong numbers to be returned */
undo_clean_stack(C);
if (active) *active = 0;
if (r_active) *r_active = false;
uel = BLI_findlink(&undobase, nr);
if (uel) {
if (active && uel == curundo)
*active = 1;
if (r_active && (uel == curundo)) {
*r_active = true;
}
return uel->name;
}
return NULL;

View File

@ -108,7 +108,7 @@ void ED_undo_push(bContext *C, const char *str)
/* do nothing for now */
}
else {
BKE_write_undo(C, str);
BKE_undo_write(C, str);
}
if (wm->file_saved) {
@ -244,7 +244,7 @@ void ED_undo_pop_op(bContext *C, wmOperator *op)
}
/* name optionally, function used to check for operator redo panel */
int ED_undo_valid(const bContext *C, const char *undoname)
bool ED_undo_is_valid(const bContext *C, const char *undoname)
{
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
@ -263,7 +263,7 @@ int ED_undo_valid(const bContext *C, const char *undoname)
}
else if (obedit) {
if (OB_TYPE_SUPPORT_EDITMODE(obedit->type)) {
return undo_editmode_valid(undoname);
return undo_editmode_is_valid(undoname);
}
}
else {
@ -271,19 +271,19 @@ int ED_undo_valid(const bContext *C, const char *undoname)
/* if below tests fail, global undo gets executed */
if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
if (ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname))
if (ED_undo_paint_is_valid(UNDO_PAINT_IMAGE, undoname))
return 1;
}
else if (obact && obact->mode & OB_MODE_SCULPT) {
if (ED_undo_paint_valid(UNDO_PAINT_MESH, undoname))
if (ED_undo_paint_is_valid(UNDO_PAINT_MESH, undoname))
return 1;
}
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
return PE_undo_valid(CTX_data_scene(C));
return PE_undo_is_valid(CTX_data_scene(C));
}
if (U.uiflag & USER_GLOBALUNDO) {
return BKE_undo_valid(undoname);
return BKE_undo_is_valid(undoname);
}
}
return 0;
@ -487,7 +487,8 @@ static int get_undo_system(bContext *C)
static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem)
{
EnumPropertyItem item_tmp = {0}, *item = NULL;
int active, i = 0;
int i = 0;
bool active;
while (true) {
const char *name = NULL;

View File

@ -35,12 +35,12 @@
/* internal exports only */
/* editmode_undo.c */
void undo_editmode_name (struct bContext *C, const char *undoname);
int undo_editmode_valid (const char *undoname);
const char *undo_editmode_get_name (struct bContext *C, int nr, int *active);
void *undo_editmode_get_prev (struct Object *ob);
void undo_editmode_step (struct bContext *C, int step);
void undo_editmode_number (struct bContext *C, int nr);
void undo_editmode_name(struct bContext *C, const char *undoname);
bool undo_editmode_is_valid(const char *undoname);
const char *undo_editmode_get_name(struct bContext *C, int nr, bool *r_active);
void *undo_editmode_get_prev(struct Object *ob);
void undo_editmode_step(struct bContext *C, int step);
void undo_editmode_number(struct bContext *C, int nr);
#endif /* __UTIL_INTERN_H__ */

View File

@ -506,13 +506,13 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
}
#endif
BKE_reset_undo();
BKE_write_undo(C, "original"); /* save current state */
BKE_undo_reset();
BKE_undo_write(C, "original"); /* save current state */
success = true;
}
else if (retval == BKE_READ_EXOTIC_OK_OTHER)
BKE_write_undo(C, "Import file");
BKE_undo_write(C, "Import file");
else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) {
BKE_reportf(reports, RPT_ERROR, "Cannot read file '%s': %s", filepath,
errno ? strerror(errno) : TIP_("unable to open the file"));
@ -660,8 +660,8 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c
// refresh_interface_font();
// undo_editmode_clear();
BKE_reset_undo();
BKE_write_undo(C, "original"); /* save current state */
BKE_undo_reset();
BKE_undo_write(C, "original"); /* save current state */
ED_editors_init(C);
DAG_on_visible_update(CTX_data_main(C), true);

View File

@ -407,7 +407,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
wmWindow *win;
if (!G.background) {
if ((U.uiflag2 & USER_KEEP_SESSION) || BKE_undo_valid(NULL)) {
if ((U.uiflag2 & USER_KEEP_SESSION) || BKE_undo_is_valid(NULL)) {
/* save the undo state as quit.blend */
char filename[FILE_MAX];
bool has_edited;
@ -517,7 +517,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
GPU_exit();
}
BKE_reset_undo();
BKE_undo_reset();
ED_file_exit(); /* for fsmenu */

View File

@ -1404,7 +1404,7 @@ bool WM_operator_check_ui_enabled(const bContext *C, const char *idname)
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = CTX_data_scene(C);
return !(ED_undo_valid(C, idname) == 0 || WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY));
return !((ED_undo_is_valid(C, idname) == false) || WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY));
}
wmOperator *WM_operator_last_redo(const bContext *C)

View File

@ -1369,8 +1369,8 @@ static int load_file(int UNUSED(argc), const char **argv, void *data)
BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
/* happens for the UI on file reading too (huh? (ton))*/
// XXX BKE_reset_undo();
// BKE_write_undo("original"); /* save current state */
// XXX BKE_undo_reset();
// BKE_undo_write("original"); /* save current state */
}
else {
/* we are not running in background mode here, but start blender in UI mode with