style cleanup

This commit is contained in:
Campbell Barton
2012-03-28 11:53:18 +00:00
parent ca8d262e89
commit ed61bfc9a6
13 changed files with 1621 additions and 1618 deletions

View File

@@ -59,19 +59,19 @@
static void console_line_color(unsigned char fg[3], int type)
{
switch(type) {
case CONSOLE_LINE_OUTPUT:
UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg);
break;
case CONSOLE_LINE_INPUT:
UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg);
break;
case CONSOLE_LINE_INFO:
UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg);
break;
case CONSOLE_LINE_ERROR:
UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg);
break;
switch (type) {
case CONSOLE_LINE_OUTPUT:
UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg);
break;
case CONSOLE_LINE_INPUT:
UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg);
break;
case CONSOLE_LINE_INFO:
UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg);
break;
case CONSOLE_LINE_ERROR:
UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg);
break;
}
}
@@ -93,11 +93,11 @@ typedef struct ConsoleDrawContext {
void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy)
{
/* fake the edit line being in the scroll buffer */
ConsoleLine *cl= sc->history.last;
cl_dummy->type= CONSOLE_LINE_INPUT;
cl_dummy->len= cl_dummy->len_alloc= strlen(sc->prompt) + cl->len;
cl_dummy->len_alloc= cl_dummy->len + 1;
cl_dummy->line= MEM_mallocN(cl_dummy->len_alloc, "cl_dummy");
ConsoleLine *cl = sc->history.last;
cl_dummy->type = CONSOLE_LINE_INPUT;
cl_dummy->len = cl_dummy->len_alloc = strlen(sc->prompt) + cl->len;
cl_dummy->len_alloc = cl_dummy->len + 1;
cl_dummy->line = MEM_mallocN(cl_dummy->len_alloc, "cl_dummy");
memcpy(cl_dummy->line, sc->prompt, (cl_dummy->len_alloc - cl->len));
memcpy(cl_dummy->line + ((cl_dummy->len_alloc - cl->len)) - 1, cl->line, cl->len + 1);
BLI_addtail(&sc->scrollback, cl_dummy);
@@ -116,73 +116,73 @@ void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dumm
/* console textview callbacks */
static int console_textview_begin(TextViewContext *tvc)
{
SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
tvc->lheight= sc->lheight;
tvc->sel_start= sc->sel_start;
tvc->sel_end= sc->sel_end;
SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
tvc->lheight = sc->lheight;
tvc->sel_start = sc->sel_start;
tvc->sel_end = sc->sel_end;
/* iterator */
tvc->iter= sc->scrollback.last;
tvc->iter = sc->scrollback.last;
return (tvc->iter != NULL);
}
static void console_textview_end(TextViewContext *tvc)
{
SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
(void)sc;
}
static int console_textview_step(TextViewContext *tvc)
{
return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL);
return ((tvc->iter = (void *)((Link *)tvc->iter)->prev) != NULL);
}
static int console_textview_line_get(struct TextViewContext *tvc, const char **line, int *len)
{
ConsoleLine *cl= (ConsoleLine *)tvc->iter;
*line= cl->line;
*len= cl->len;
ConsoleLine *cl = (ConsoleLine *)tvc->iter;
*line = cl->line;
*len = cl->len;
return 1;
}
static int console_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char UNUSED(bg[3]))
{
ConsoleLine *cl_iter= (ConsoleLine *)tvc->iter;
ConsoleLine *cl_iter = (ConsoleLine *)tvc->iter;
/* annoying hack, to draw the prompt */
if (tvc->iter_index == 0) {
const SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
const ConsoleLine *cl= (ConsoleLine *)sc->history.last;
const int prompt_len= strlen(sc->prompt);
const int cursor_loc= cl->cursor + prompt_len;
const SpaceConsole *sc = (SpaceConsole *)tvc->arg1;
const ConsoleLine *cl = (ConsoleLine *)sc->history.last;
const int prompt_len = strlen(sc->prompt);
const int cursor_loc = cl->cursor + prompt_len;
int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN};
int pen[2];
xy[1] += tvc->lheight/6;
xy[1] += tvc->lheight / 6;
/* account for wrapping */
if (cl->len < tvc->console_width) {
/* simple case, no wrapping */
pen[0]= tvc->cwidth * cursor_loc;
pen[1]= -2;
pen[0] = tvc->cwidth * cursor_loc;
pen[1] = -2;
}
else {
/* wrap */
pen[0]= tvc->cwidth * (cursor_loc % tvc->console_width);
pen[1]= -2 + (((cl->len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight);
pen[0] = tvc->cwidth * (cursor_loc % tvc->console_width);
pen[1] = -2 + (((cl->len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight);
}
/* cursor */
UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, fg);
glColor3ubv(fg);
glRecti( (xy[0] + pen[0]) - 1,
(xy[1] + pen[1]),
(xy[0] + pen[0]) + 1,
(xy[1] + pen[1] + tvc->lheight)
);
glRecti((xy[0] + pen[0]) - 1,
(xy[1] + pen[1]),
(xy[0] + pen[0]) + 1,
(xy[1] + pen[1] + tvc->lheight)
);
}
console_line_color(fg, cl_iter->type);
@@ -193,33 +193,33 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha
static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick)
{
ConsoleLine cl_dummy= {NULL};
int ret= 0;
ConsoleLine cl_dummy = {NULL};
int ret = 0;
View2D *v2d= &ar->v2d;
View2D *v2d = &ar->v2d;
TextViewContext tvc= {0};
TextViewContext tvc = {0};
tvc.begin= console_textview_begin;
tvc.end= console_textview_end;
tvc.begin = console_textview_begin;
tvc.end = console_textview_end;
tvc.step= console_textview_step;
tvc.line_get= console_textview_line_get;
tvc.line_color= console_textview_line_color;
tvc.step = console_textview_step;
tvc.line_get = console_textview_line_get;
tvc.line_color = console_textview_line_color;
tvc.arg1= sc;
tvc.arg2= NULL;
tvc.arg1 = sc;
tvc.arg2 = NULL;
/* view */
tvc.sel_start= sc->sel_start;
tvc.sel_end= sc->sel_end;
tvc.lheight= sc->lheight;
tvc.sel_start = sc->sel_start;
tvc.sel_end = sc->sel_end;
tvc.lheight = sc->lheight;
tvc.ymin = v2d->cur.ymin;
tvc.ymax = v2d->cur.ymax;
tvc.winx= ar->winx;
tvc.winx = ar->winx;
console_scrollback_prompt_begin(sc, &cl_dummy);
ret= textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
console_scrollback_prompt_end(sc, &cl_dummy);
return ret;
@@ -240,12 +240,12 @@ int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar)
int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, int mval[2])
{
int pos_pick= 0;
void *mouse_pick= NULL;
int pos_pick = 0;
void *mouse_pick = NULL;
int mval_clamp[2];
mval_clamp[0]= CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx-(CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN));
mval_clamp[1]= CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy-CONSOLE_DRAW_MARGIN);
mval_clamp[0] = CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN));
mval_clamp[1] = CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy - CONSOLE_DRAW_MARGIN);
console_textview_main__internal(sc, ar, 0, mval_clamp, &mouse_pick, &pos_pick);
return pos_pick;

View File

@@ -57,16 +57,16 @@
/* so when we type - the view scrolls to the bottom */
static void console_scroll_bottom(ARegion *ar)
{
View2D *v2d= &ar->v2d;
View2D *v2d = &ar->v2d;
v2d->cur.ymin = 0.0;
v2d->cur.ymax =(float)v2d->winy;
v2d->cur.ymax = (float)v2d->winy;
}
static void console_textview_update_rect(SpaceConsole *sc, ARegion *ar)
{
View2D *v2d= &ar->v2d;
View2D *v2d = &ar->v2d;
UI_view2d_totRect_set(v2d, ar->winx-1, console_textview_height(sc, ar));
UI_view2d_totRect_set(v2d, ar->winx - 1, console_textview_height(sc, ar));
}
static void console_select_offset(SpaceConsole *sc, const int offset)
@@ -92,21 +92,21 @@ static void console_scrollback_limit(SpaceConsole *sc)
{
int tot;
if (U.scrollback < 32) U.scrollback= 256; // XXX - save in user defaults
if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults
for (tot= BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--)
for (tot = BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--)
console_scrollback_free(sc, sc->scrollback.first);
}
static ConsoleLine * console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
{
ConsoleLine *cl;
for (cl= sc->history.last; cl; cl= cl->prev) {
if (cl==cl_ignore)
for (cl = sc->history.last; cl; cl = cl->prev) {
if (cl == cl_ignore)
continue;
if (strcmp(str, cl->line)==0)
if (strcmp(str, cl->line) == 0)
return cl;
}
@@ -118,9 +118,9 @@ static int console_line_cursor_set(ConsoleLine *cl, int cursor)
{
int cursor_new;
if (cursor < 0) cursor_new = 0;
else if (cursor > cl->len) cursor_new = cl->len;
else cursor_new = cursor;
if (cursor < 0) cursor_new = 0;
else if (cursor > cl->len) cursor_new = cl->len;
else cursor_new = cursor;
if (cursor_new == cl->cursor) {
return FALSE;
@@ -136,7 +136,7 @@ static void console_lb_debug__internal(ListBase *lb)
ConsoleLine *cl;
printf("%d: ", BLI_countlist(lb));
for (cl= lb->first; cl; cl= cl->next)
for (cl = lb->first; cl; cl = cl->next)
printf("<%s> ", cl->line);
printf("\n");
@@ -144,7 +144,7 @@ static void console_lb_debug__internal(ListBase *lb)
static void console_history_debug(const bContext *C)
{
SpaceConsole *sc= CTX_wm_space_console(C);
SpaceConsole *sc = CTX_wm_space_console(C);
console_lb_debug__internal(&sc->history);
@@ -153,20 +153,20 @@ static void console_history_debug(const bContext *C)
static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from)
{
ConsoleLine *ci= MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
if (from) {
ci->line= BLI_strdup(from->line);
ci->len= strlen(ci->line);
ci->len_alloc= ci->len;
ci->line = BLI_strdup(from->line);
ci->len = strlen(ci->line);
ci->len_alloc = ci->len;
ci->cursor= from->cursor;
ci->type= from->type;
ci->cursor = from->cursor;
ci->type = from->type;
}
else {
ci->line= MEM_callocN(64, "console-in-line");
ci->len_alloc= 64;
ci->len= 0;
ci->line = MEM_callocN(64, "console-in-line");
ci->len_alloc = 64;
ci->len = 0;
}
BLI_addtail(lb, ci);
@@ -175,7 +175,7 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from)
static ConsoleLine *console_history_add(const bContext *C, ConsoleLine *from)
{
SpaceConsole *sc= CTX_wm_space_console(C);
SpaceConsole *sc = CTX_wm_space_console(C);
return console_lb_add__internal(&sc->history, from);
}
@@ -183,7 +183,7 @@ static ConsoleLine *console_history_add(const bContext *C, ConsoleLine *from)
#if 0 /* may use later ? */
static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
{
SpaceConsole *sc= CTX_wm_space_console(C);
SpaceConsole *sc = CTX_wm_space_console(C);
return console_lb_add__internal(&sc->scrollback, from);
}
@@ -191,9 +191,9 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, int own)
{
ConsoleLine *ci= MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
if (own) ci->line= str;
else ci->line= BLI_strdup(str);
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
if (own) ci->line = str;
else ci->line = BLI_strdup(str);
ci->len = ci->len_alloc = strlen(str);
@@ -206,17 +206,17 @@ ConsoleLine *console_history_add_str(SpaceConsole *sc, char *str, int own)
}
ConsoleLine *console_scrollback_add_str(SpaceConsole *sc, char *str, int own)
{
ConsoleLine *ci= console_lb_add_str__internal(&sc->scrollback, str, own);
ConsoleLine *ci = console_lb_add_str__internal(&sc->scrollback, str, own);
console_select_offset(sc, ci->len + 1);
return ci;
}
ConsoleLine *console_history_verify(const bContext *C)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ConsoleLine *ci= sc->history.last;
if (ci==NULL)
ci= console_history_add(C, NULL);
SpaceConsole *sc = CTX_wm_space_console(C);
ConsoleLine *ci = sc->history.last;
if (ci == NULL)
ci = console_history_add(C, NULL);
return ci;
}
@@ -226,13 +226,13 @@ static void console_line_verify_length(ConsoleLine *ci, int len)
{
/* resize the buffer if needed */
if (len >= ci->len_alloc) {
int new_len= len * 2; /* new length */
char *new_line= MEM_callocN(new_len, "console line");
int new_len = len * 2; /* new length */
char *new_line = MEM_callocN(new_len, "console line");
memcpy(new_line, ci->line, ci->len);
MEM_freeN(ci->line);
ci->line= new_line;
ci->len_alloc= new_len;
ci->line = new_line;
ci->len_alloc = new_len;
}
}
@@ -240,18 +240,18 @@ static int console_line_insert(ConsoleLine *ci, char *str)
{
int len = strlen(str);
if (len>0 && str[len-1]=='\n') {/* stop new lines being pasted at the end of lines */
str[len-1]= '\0';
if (len > 0 && str[len - 1] == '\n') { /* stop new lines being pasted at the end of lines */
str[len - 1] = '\0';
len--;
}
if (len==0)
if (len == 0)
return 0;
console_line_verify_length(ci, len + ci->len);
memmove(ci->line+ci->cursor+len, ci->line+ci->cursor, (ci->len - ci->cursor)+1);
memcpy(ci->line+ci->cursor, str, len);
memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1);
memcpy(ci->line + ci->cursor, str, len);
ci->len += len;
ci->cursor += len;
@@ -262,74 +262,75 @@ static int console_line_insert(ConsoleLine *ci, char *str)
/* static funcs for text editing */
/* similar to the text editor, with some not used. keep compatible */
static EnumPropertyItem console_move_type_items[]= {
static EnumPropertyItem console_move_type_items[] = {
{LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
{LINE_END, "LINE_END", 0, "Line End", ""},
{PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
{NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
{PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
{NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
static int console_move_exec(bContext *C, wmOperator *op)
{
ConsoleLine *ci= console_history_verify(C);
ConsoleLine *ci = console_history_verify(C);
int type= RNA_enum_get(op->ptr, "type");
int done= 0;
int type = RNA_enum_get(op->ptr, "type");
int done = 0;
int pos;
switch (type) {
case LINE_BEGIN:
case LINE_BEGIN:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_PREV,
STRCUR_JUMP_ALL);
done = console_line_cursor_set(ci, pos);
break;
case LINE_END:
break;
case LINE_END:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_NEXT,
STRCUR_JUMP_ALL);
done = console_line_cursor_set(ci, pos);
break;
case PREV_CHAR:
break;
case PREV_CHAR:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_PREV,
STRCUR_JUMP_NONE);
done = console_line_cursor_set(ci, pos);
break;
case NEXT_CHAR:
break;
case NEXT_CHAR:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_NEXT,
STRCUR_JUMP_NONE);
done = console_line_cursor_set(ci, pos);
break;
break;
/* - if the character is a delimiter then skip delimiters (including white space)
* - when jump over the word */
case PREV_WORD:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_PREV,
STRCUR_JUMP_DELIM);
done = console_line_cursor_set(ci, pos);
break;
case NEXT_WORD:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_NEXT,
STRCUR_JUMP_DELIM);
done = console_line_cursor_set(ci, pos);
break;
/* - if the character is a delimiter then skip delimiters (including white space)
* - when jump over the word */
case PREV_WORD:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_PREV,
STRCUR_JUMP_DELIM);
done = console_line_cursor_set(ci, pos);
break;
case NEXT_WORD:
pos = ci->cursor;
BLI_str_cursor_step_utf8(ci->line, ci->len,
&pos, STRCUR_DIR_NEXT,
STRCUR_JUMP_DELIM);
done = console_line_cursor_set(ci, pos);
break;
}
if (done) {
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
ED_area_tag_redraw(sa);
console_scroll_bottom(ar);
@@ -357,26 +358,26 @@ void CONSOLE_OT_move(wmOperatorType *ot)
#define TAB_LENGTH 4
static int console_insert_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
ConsoleLine *ci= console_history_verify(C);
char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0);
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
ConsoleLine *ci = console_history_verify(C);
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0);
int len;
// XXX, alligned tab key hack
if (str[0]=='\t' && str[1]=='\0') {
len= TAB_LENGTH - (ci->cursor % TAB_LENGTH);
if (str[0] == '\t' && str[1] == '\0') {
len = TAB_LENGTH - (ci->cursor % TAB_LENGTH);
MEM_freeN(str);
str= MEM_mallocN(len + 1, "insert_exec");
str = MEM_mallocN(len + 1, "insert_exec");
memset(str, ' ', len);
str[len]= '\0';
str[len] = '\0';
}
len= console_line_insert(ci, str);
len = console_line_insert(ci, str);
MEM_freeN(str);
if (len==0) {
if (len == 0) {
return OPERATOR_CANCELLED;
}
else {
@@ -401,8 +402,8 @@ static int console_insert_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
else {
char str[2];
str[0]= event->ascii;
str[1]= '\0';
str[0] = event->ascii;
str[1] = '\0';
RNA_string_set(op->ptr, "text", str);
}
@@ -430,42 +431,43 @@ void CONSOLE_OT_insert(wmOperatorType *ot)
}
static EnumPropertyItem console_delete_type_items[]= {
static EnumPropertyItem console_delete_type_items[] = {
{DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
{DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
// {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
// {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
static int console_delete_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
ConsoleLine *ci= console_history_verify(C);
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
ConsoleLine *ci = console_history_verify(C);
const short type= RNA_enum_get(op->ptr, "type");
const short type = RNA_enum_get(op->ptr, "type");
int done = 0;
if (ci->len==0) {
if (ci->len == 0) {
return OPERATOR_CANCELLED;
}
switch(type) {
case DEL_NEXT_CHAR:
if (ci->cursor < ci->len) {
memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1);
ci->len--;
done= 1;
}
break;
case DEL_PREV_CHAR:
if (ci->cursor > 0) {
ci->cursor--; /* same as above */
memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1);
ci->len--;
done= 1;
}
break;
switch (type) {
case DEL_NEXT_CHAR:
if (ci->cursor < ci->len) {
memmove(ci->line + ci->cursor, ci->line + ci->cursor + 1, (ci->len - ci->cursor) + 1);
ci->len--;
done = 1;
}
break;
case DEL_PREV_CHAR:
if (ci->cursor > 0) {
ci->cursor--; /* same as above */
memmove(ci->line + ci->cursor, ci->line + ci->cursor + 1, (ci->len - ci->cursor) + 1);
ci->len--;
done = 1;
}
break;
}
if (!done) {
@@ -503,11 +505,11 @@ void CONSOLE_OT_delete(wmOperatorType *ot)
/* the python exec operator uses this */
static int console_clear_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
short scrollback= RNA_boolean_get(op->ptr, "scrollback");
short history= RNA_boolean_get(op->ptr, "history");
short scrollback = RNA_boolean_get(op->ptr, "scrollback");
short history = RNA_boolean_get(op->ptr, "history");
/*ConsoleLine *ci= */ console_history_verify(C);
@@ -548,42 +550,42 @@ void CONSOLE_OT_clear(wmOperatorType *ot)
/* the python exec operator uses this */
static int console_history_cycle_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
ConsoleLine *ci= console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */
short reverse= RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
int prev_len= ci->len;
ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */
short reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
int prev_len = ci->len;
/* keep a copy of the line above so when history is cycled
* this is the only function that needs to know about the double-up */
if (ci->prev) {
ConsoleLine *ci_prev= (ConsoleLine *)ci->prev;
ConsoleLine *ci_prev = (ConsoleLine *)ci->prev;
if (strcmp(ci->line, ci_prev->line)==0)
if (strcmp(ci->line, ci_prev->line) == 0)
console_history_free(sc, ci_prev);
}
if (reverse) { /* last item in mistory */
ci= sc->history.last;
ci = sc->history.last;
BLI_remlink(&sc->history, ci);
BLI_addhead(&sc->history, ci);
}
else {
ci= sc->history.first;
ci = sc->history.first;
BLI_remlink(&sc->history, ci);
BLI_addtail(&sc->history, ci);
}
{ /* add a duplicate of the new arg and remove all other instances */
{ /* add a duplicate of the new arg and remove all other instances */
ConsoleLine *cl;
while ((cl= console_history_find(sc, ci->line, ci)))
while ((cl = console_history_find(sc, ci->line, ci)))
console_history_free(sc, cl);
console_history_add(C, (ConsoleLine *)sc->history.last);
}
ci= sc->history.last;
ci = sc->history.last;
console_select_offset(sc, ci->len - prev_len);
/* could be wrapped so update scroll rect */
@@ -614,28 +616,28 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot)
/* the python exec operator uses this */
static int console_history_append_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
ScrArea *sa= CTX_wm_area(C);
ConsoleLine *ci= console_history_verify(C);
char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */
int cursor= RNA_int_get(op->ptr, "current_character");
short rem_dupes= RNA_boolean_get(op->ptr, "remove_duplicates");
int prev_len= ci->len;
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
ConsoleLine *ci = console_history_verify(C);
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */
int cursor = RNA_int_get(op->ptr, "current_character");
short rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates");
int prev_len = ci->len;
if (rem_dupes) {
ConsoleLine *cl;
while ((cl= console_history_find(sc, ci->line, ci)))
while ((cl = console_history_find(sc, ci->line, ci)))
console_history_free(sc, cl);
if (strcmp(str, ci->line)==0) {
if (strcmp(str, ci->line) == 0) {
MEM_freeN(str);
return OPERATOR_FINISHED;
}
}
ci= console_history_add_str(sc, str, 1); /* own the string */
ci = console_history_add_str(sc, str, 1); /* own the string */
console_select_offset(sc, ci->len - prev_len);
console_line_cursor_set(ci, cursor);
@@ -671,17 +673,17 @@ void CONSOLE_OT_history_append(wmOperatorType *ot)
/* the python exec operator uses this */
static int console_scrollback_append_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
ConsoleLine *ci;
char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */
int type= RNA_enum_get(op->ptr, "type");
char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */
int type = RNA_enum_get(op->ptr, "type");
console_history_verify(C);
ci= console_scrollback_add_str(sc, str, 1); /* own the string */
ci->type= type;
ci = console_scrollback_add_str(sc, str, 1); /* own the string */
ci->type = type;
console_scrollback_limit(sc);
@@ -700,10 +702,10 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
{
/* defined in DNA_space_types.h */
static EnumPropertyItem console_line_type_items[] = {
{CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""},
{CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
{CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
{CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
{CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""},
{CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
{CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
{CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
{0, NULL, 0, NULL, NULL}};
/* identifiers */
@@ -723,20 +725,20 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc= CTX_wm_space_console(C);
SpaceConsole *sc = CTX_wm_space_console(C);
DynStr *buf_dyn= BLI_dynstr_new();
DynStr *buf_dyn = BLI_dynstr_new();
char *buf_str;
ConsoleLine *cl;
int sel[2];
int offset= 0;
int offset = 0;
ConsoleLine cl_dummy= {NULL};
ConsoleLine cl_dummy = {NULL};
#if 0
/* copy whole file */
for (cl= sc->scrollback.first; cl; cl= cl->next) {
for (cl = sc->scrollback.first; cl; cl = cl->next) {
BLI_dynstr_append(buf_dyn, cl->line);
BLI_dynstr_append(buf_dyn, "\n");
}
@@ -747,23 +749,23 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
console_scrollback_prompt_begin(sc, &cl_dummy);
for (cl= sc->scrollback.first; cl; cl= cl->next) {
for (cl = sc->scrollback.first; cl; cl = cl->next) {
offset += cl->len + 1;
}
if (offset==0) {
if (offset == 0) {
console_scrollback_prompt_end(sc, &cl_dummy);
return OPERATOR_CANCELLED;
}
offset -= 1;
sel[0]= offset - sc->sel_end;
sel[1]= offset - sc->sel_start;
sel[0] = offset - sc->sel_end;
sel[1] = offset - sc->sel_start;
for (cl= sc->scrollback.first; cl; cl= cl->next) {
for (cl = sc->scrollback.first; cl; cl = cl->next) {
if (sel[0] <= cl->len && sel[1] >= 0) {
int sta= MAX2(sel[0], 0);
int end= MIN2(sel[1], cl->len);
int sta = MAX2(sel[0], 0);
int end = MIN2(sel[1], cl->len);
if (BLI_dynstr_get_len(buf_dyn))
BLI_dynstr_append(buf_dyn, "\n");
@@ -775,7 +777,7 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
sel[1] -= cl->len + 1;
}
buf_str= BLI_dynstr_get_cstring(buf_dyn);
buf_str = BLI_dynstr_get_cstring(buf_dyn);
BLI_dynstr_free(buf_dyn);
WM_clipboard_text_set(buf_str, 0);
@@ -803,28 +805,28 @@ void CONSOLE_OT_copy(wmOperatorType *ot)
static int console_paste_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
ConsoleLine *ci= console_history_verify(C);
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
ConsoleLine *ci = console_history_verify(C);
char *buf_str= WM_clipboard_text_get(0);
char *buf_str = WM_clipboard_text_get(0);
char *buf_step, *buf_next;
if (buf_str==NULL)
if (buf_str == NULL)
return OPERATOR_CANCELLED;
buf_step= buf_str;
buf_step = buf_str;
while ((buf_next=buf_step) && buf_next[0] != '\0') {
buf_step= strchr(buf_next, '\n');
while ((buf_next = buf_step) && buf_next[0] != '\0') {
buf_step = strchr(buf_next, '\n');
if (buf_step) {
*buf_step= '\0';
*buf_step = '\0';
buf_step++;
}
if (buf_next != buf_str) {
WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL);
ci= console_history_verify(C);
ci = console_history_verify(C);
}
console_select_offset(sc, console_line_insert(ci, buf_next));
@@ -863,10 +865,10 @@ typedef struct SetConsoleCursor {
static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleCursor *scu, int mval[2], int UNUSED(sel))
{
int pos;
pos= console_char_pick(sc, ar, mval);
pos = console_char_pick(sc, ar, mval);
if (scu->sel_init == INT_MAX) {
scu->sel_init= pos;
scu->sel_init = pos;
sc->sel_start = sc->sel_end = pos;
return;
}
@@ -886,17 +888,17 @@ static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleC
static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ARegion *ar= CTX_wm_region(C);
SetConsoleCursor *scu= op->customdata;
SpaceConsole *sc = CTX_wm_space_console(C);
ARegion *ar = CTX_wm_region(C);
SetConsoleCursor *scu = op->customdata;
int mval[2];
int sel_prev[2];
mval[0]= event->mval[0];
mval[1]= event->mval[1];
mval[0] = event->mval[0];
mval[1] = event->mval[1];
sel_prev[0]= sc->sel_start;
sel_prev[1]= sc->sel_end;
sel_prev[0] = sc->sel_start;
sel_prev[1] = sc->sel_end;
console_cursor_set_to_pos(sc, ar, scu, mval, TRUE);
@@ -909,7 +911,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *eve
static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op)
{
// SpaceConsole *sc= CTX_wm_space_console(C);
SetConsoleCursor *scu= op->customdata;
SetConsoleCursor *scu = op->customdata;
#if 0
if (txt_has_sel(text)) {
@@ -924,15 +926,15 @@ static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op)
static int console_modal_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceConsole *sc= CTX_wm_space_console(C);
SpaceConsole *sc = CTX_wm_space_console(C);
// ARegion *ar= CTX_wm_region(C);
SetConsoleCursor *scu;
op->customdata= MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor");
scu= op->customdata;
op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor");
scu = op->customdata;
scu->sel_old[0]= sc->sel_start;
scu->sel_old[1]= sc->sel_end;
scu->sel_old[0] = sc->sel_start;
scu->sel_old[1] = sc->sel_end;
scu->sel_init = INT_MAX;
@@ -945,7 +947,7 @@ static int console_modal_select_invoke(bContext *C, wmOperator *op, wmEvent *eve
static int console_modal_select(bContext *C, wmOperator *op, wmEvent *event)
{
switch(event->type) {
switch (event->type) {
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE:

View File

@@ -54,7 +54,7 @@
#include "UI_resources.h"
#include "UI_view2d.h"
#include "console_intern.h" // own include
#include "console_intern.h" // own include
/* ******************** default callbacks for console space ***************** */
@@ -63,32 +63,32 @@ static SpaceLink *console_new(const bContext *UNUSED(C))
ARegion *ar;
SpaceConsole *sconsole;
sconsole= MEM_callocN(sizeof(SpaceConsole), "initconsole");
sconsole->spacetype= SPACE_CONSOLE;
sconsole = MEM_callocN(sizeof(SpaceConsole), "initconsole");
sconsole->spacetype = SPACE_CONSOLE;
sconsole->lheight= 14;
sconsole->lheight = 14;
/* header */
ar= MEM_callocN(sizeof(ARegion), "header for console");
ar = MEM_callocN(sizeof(ARegion), "header for console");
BLI_addtail(&sconsole->regionbase, ar);
ar->regiontype= RGN_TYPE_HEADER;
ar->alignment= RGN_ALIGN_BOTTOM;
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_BOTTOM;
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for text");
ar = MEM_callocN(sizeof(ARegion), "main area for text");
BLI_addtail(&sconsole->regionbase, ar);
ar->regiontype= RGN_TYPE_WINDOW;
ar->regiontype = RGN_TYPE_WINDOW;
/* keep in sync with info */
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
ar->v2d.align |= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */
ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
ar->v2d.keepofs |= V2D_LOCKOFS_X;
ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS;
ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
//ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
@@ -99,7 +99,7 @@ static SpaceLink *console_new(const bContext *UNUSED(C))
/* not spacelink itself */
static void console_free(SpaceLink *sl)
{
SpaceConsole *sc= (SpaceConsole*) sl;
SpaceConsole *sc = (SpaceConsole *) sl;
while (sc->scrollback.first)
console_scrollback_free(sc, sc->scrollback.first);
@@ -117,13 +117,13 @@ static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)
static SpaceLink *console_duplicate(SpaceLink *sl)
{
SpaceConsole *sconsolen= MEM_dupallocN(sl);
SpaceConsole *sconsolen = MEM_dupallocN(sl);
/* clear or remove stuff from old */
/* TODO - duplicate?, then we also need to duplicate the py namespace */
sconsolen->scrollback.first= sconsolen->scrollback.last= NULL;
sconsolen->history.first= sconsolen->history.last= NULL;
sconsolen->scrollback.first = sconsolen->scrollback.last = NULL;
sconsolen->history.first = sconsolen->history.last = NULL;
return (SpaceLink *)sconsolen;
}
@@ -136,13 +136,13 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
wmKeyMap *keymap;
ListBase *lb;
const float prev_y_min= ar->v2d.cur.ymin; /* so re-sizing keeps the cursor visible */
const float prev_y_min = ar->v2d.cur.ymin; /* so re-sizing keeps the cursor visible */
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
/* always keep the bottom part of the view aligned, less annoying */
if (prev_y_min != ar->v2d.cur.ymin) {
const float cur_y_range= ar->v2d.cur.ymax - ar->v2d.cur.ymin;
const float cur_y_range = ar->v2d.cur.ymax - ar->v2d.cur.ymin;
ar->v2d.cur.ymin = prev_y_min;
ar->v2d.cur.ymax = prev_y_min + cur_y_range;
}
@@ -152,7 +152,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
/* add drop boxes */
lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
WM_event_add_dropbox_handler(&ar->handlers, lb);
}
@@ -163,7 +163,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
{
// SpaceConsole *sc= CTX_wm_space_console(C);
if (drag->type==WM_DRAG_ID)
if (drag->type == WM_DRAG_ID)
return 1;
return 0;
}
@@ -171,10 +171,10 @@ static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event
static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
{
char text[64];
ID *id= drag->poin;
ID *id = drag->poin;
char id_esc[(sizeof(id->name) - 2) * 2];
BLI_strescape(id_esc, id->name+2, sizeof(id_esc));
BLI_strescape(id_esc, id->name + 2, sizeof(id_esc));
BLI_snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc);
@@ -185,14 +185,14 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
{
// SpaceConsole *sc= CTX_wm_space_console(C);
if (drag->type==WM_DRAG_PATH)
if (drag->type == WM_DRAG_PATH)
return 1;
return 0;
}
static void path_drop_copy(wmDrag *drag, wmDropBox *drop)
{
char pathname[FILE_MAX+2];
char pathname[FILE_MAX + 2];
BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path);
RNA_string_set(drop->ptr, "text", pathname);
}
@@ -201,7 +201,7 @@ static void path_drop_copy(wmDrag *drag, wmDropBox *drop)
/* this region dropbox definition */
static void console_dropboxes(void)
{
ListBase *lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy);
WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy);
@@ -212,11 +212,11 @@ static void console_dropboxes(void)
static void console_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceConsole *sc= CTX_wm_space_console(C);
View2D *v2d= &ar->v2d;
SpaceConsole *sc = CTX_wm_space_console(C);
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
if (sc->scrollback.first==NULL)
if (sc->scrollback.first == NULL)
WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
/* clear and setup matrix */
@@ -235,7 +235,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -355,7 +355,7 @@ static void console_main_area_listener(ARegion *ar, wmNotifier *wmn)
// SpaceInfo *sinfo= sa->spacedata.first;
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SPACE:
if (wmn->data == ND_SPACE_CONSOLE) { /* generic redraw request */
ED_region_tag_redraw(ar);
@@ -367,41 +367,41 @@ static void console_main_area_listener(ARegion *ar, wmNotifier *wmn)
/* only called once, from space/spacetypes.c */
void ED_spacetype_console(void)
{
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype console");
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console");
ARegionType *art;
st->spaceid= SPACE_CONSOLE;
st->spaceid = SPACE_CONSOLE;
strncpy(st->name, "Console", BKE_ST_MAXNAME);
st->new= console_new;
st->free= console_free;
st->init= console_init;
st->duplicate= console_duplicate;
st->operatortypes= console_operatortypes;
st->keymap= console_keymap;
st->dropboxes= console_dropboxes;
st->new = console_new;
st->free = console_free;
st->init = console_init;
st->duplicate = console_duplicate;
st->operatortypes = console_operatortypes;
st->keymap = console_keymap;
st->dropboxes = console_dropboxes;
/* regions: main window */
art= MEM_callocN(sizeof(ARegionType), "spacetype console region");
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
art->regionid = RGN_TYPE_WINDOW;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
art->init= console_main_area_init;
art->draw= console_main_area_draw;
art->listener= console_main_area_listener;
art->init = console_main_area_init;
art->draw = console_main_area_draw;
art->listener = console_main_area_listener;
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art= MEM_callocN(sizeof(ARegionType), "spacetype console region");
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey= HEADERY;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
art->init= console_header_area_init;
art->draw= console_header_area_draw;
art->init = console_header_area_init;
art->draw = console_header_area_draw;
BLI_addhead(&st->regiontypes, art);

View File

@@ -71,96 +71,95 @@
#include "image_intern.h"
#define B_REDR 1
#define B_IMAGECHANGED 2
#define B_NOP 0
#define B_TWINANIM 5
#define B_SIMAGETILE 6
#define B_IDNAME 10
#define B_FACESEL_PAINT_TEST 11
#define B_SIMA_RECORD 12
#define B_SIMA_PLAY 13
#define B_REDR 1
#define B_IMAGECHANGED 2
#define B_NOP 0
#define B_TWINANIM 5
#define B_SIMAGETILE 6
#define B_IDNAME 10
#define B_FACESEL_PAINT_TEST 11
#define B_SIMA_RECORD 12
#define B_SIMA_PLAY 13
#define B_SIMANOTHING 16
#define B_SIMABRUSHCHANGE 17
#define B_SIMABRUSHBROWSE 18
#define B_SIMABRUSHLOCAL 19
#define B_SIMABRUSHDELETE 20
#define B_KEEPDATA 21
#define B_SIMABTEXBROWSE 22
#define B_SIMABTEXDELETE 23
#define B_VPCOLSLI 24
#define B_SIMACLONEBROWSE 25
#define B_SIMACLONEDELETE 26
#define B_SIMANOTHING 16
#define B_SIMABRUSHCHANGE 17
#define B_SIMABRUSHBROWSE 18
#define B_SIMABRUSHLOCAL 19
#define B_SIMABRUSHDELETE 20
#define B_KEEPDATA 21
#define B_SIMABTEXBROWSE 22
#define B_SIMABTEXDELETE 23
#define B_VPCOLSLI 24
#define B_SIMACLONEBROWSE 25
#define B_SIMACLONEDELETE 26
/* proto */
static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, char *str)
{
int ofs= 0;
int ofs = 0;
str[0]= 0;
str[0] = 0;
if (ima==NULL) return;
if (ima == NULL) return;
if (ibuf==NULL) {
ofs+= sprintf(str, "Can't Load Image");
if (ibuf == NULL) {
ofs += sprintf(str, "Can't Load Image");
}
else {
if (ima->source==IMA_SRC_MOVIE) {
ofs+= sprintf(str, "Movie");
if (ima->source == IMA_SRC_MOVIE) {
ofs += sprintf(str, "Movie");
if (ima->anim)
ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN));
ofs += sprintf(str + ofs, "%d frs", IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN));
}
else
ofs+= sprintf(str, "Image");
ofs += sprintf(str, "Image");
ofs+= sprintf(str+ofs, ": size %d x %d,", ibuf->x, ibuf->y);
ofs += sprintf(str + ofs, ": size %d x %d,", ibuf->x, ibuf->y);
if (ibuf->rect_float) {
if (ibuf->channels!=4) {
ofs+= sprintf(str+ofs, "%d float channel(s)", ibuf->channels);
if (ibuf->channels != 4) {
ofs += sprintf(str + ofs, "%d float channel(s)", ibuf->channels);
}
else if (ibuf->planes == R_IMF_PLANES_RGBA)
ofs+= sprintf(str+ofs, " RGBA float");
ofs += sprintf(str + ofs, " RGBA float");
else
ofs+= sprintf(str+ofs, " RGB float");
ofs += sprintf(str + ofs, " RGB float");
}
else {
if (ibuf->planes == R_IMF_PLANES_RGBA)
ofs+= sprintf(str+ofs, " RGBA byte");
ofs += sprintf(str + ofs, " RGBA byte");
else
ofs+= sprintf(str+ofs, " RGB byte");
ofs += sprintf(str + ofs, " RGB byte");
}
if (ibuf->zbuf || ibuf->zbuf_float)
ofs+= sprintf(str+ofs, " + Z");
ofs += sprintf(str + ofs, " + Z");
if (ima->source==IMA_SRC_SEQUENCE) {
char *file= BLI_last_slash(ibuf->name);
if (file==NULL) file= ibuf->name;
else file++;
ofs+= sprintf(str+ofs, ", %s", file);
if (ima->source == IMA_SRC_SEQUENCE) {
char *file = BLI_last_slash(ibuf->name);
if (file == NULL) file = ibuf->name;
else file++;
ofs += sprintf(str + ofs, ", %s", file);
}
}
/* the frame number, even if we cant */
if (ima->source==IMA_SRC_SEQUENCE) {
if (ima->source == IMA_SRC_SEQUENCE) {
/* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0);
ofs+= sprintf(str+ofs, ", Frame: %d", framenr);
const int framenr = BKE_image_user_get_frame(iuser, CFRA, 0);
ofs += sprintf(str + ofs, ", Frame: %d", framenr);
}
(void)ofs;
}
/* gets active viewer user */
struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
{
struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree){
bNode *node;
if (ntree)
for (node= ntree->nodes.first; node; node= node->next)
if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
for (node = ntree->nodes.first; node; node = node->next)
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
if (node->flag & NODE_DO_OUTPUT)
return node->storage;
return NULL;
@@ -173,13 +172,13 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
static int image_panel_poll(const bContext *C, PanelType *UNUSED(pt))
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
ImBuf *ibuf;
void *lock;
int result;
ibuf= ED_space_image_acquire_buffer(sima, &lock);
result= ibuf && ibuf->rect_float;
ibuf = ED_space_image_acquire_buffer(sima, &lock);
result = ibuf && ibuf->rect_float;
ED_space_image_release_buffer(sima, lock);
return result;
@@ -187,21 +186,21 @@ static int image_panel_poll(const bContext *C, PanelType *UNUSED(pt))
static void image_panel_curves(const bContext *C, Panel *pa)
{
bScreen *sc= CTX_wm_screen(C);
SpaceImage *sima= CTX_wm_space_image(C);
bScreen *sc = CTX_wm_screen(C);
SpaceImage *sima = CTX_wm_space_image(C);
ImBuf *ibuf;
PointerRNA simaptr;
int levels;
void *lock;
ibuf= ED_space_image_acquire_buffer(sima, &lock);
ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
if (sima->cumap==NULL)
sima->cumap= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
if (sima->cumap == NULL)
sima->cumap = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
/* curvemap black/white levels only works for RGBA */
levels= (ibuf->channels==4);
levels = (ibuf->channels == 4);
RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &simaptr);
uiTemplateCurveMapping(pa->layout, &simaptr, "curve", 'c', levels, 0);
@@ -215,19 +214,19 @@ static void image_panel_curves(const bContext *C, Panel *pa)
* otherwise refresh preview
*
* XXX if you put this back, also check XXX in image_main_area_draw() */
*/
* /
void image_preview_event(int event)
{
int exec= 0;
int exec = 0;
if (event==0) {
if (event == 0) {
G.scene->r.scemode &= ~R_COMP_CROP;
exec= 1;
exec = 1;
}
else {
if (image_preview_active(curarea, NULL, NULL)) {
G.scene->r.scemode |= R_COMP_CROP;
exec= 1;
exec = 1;
}
else
G.scene->r.scemode &= ~R_COMP_CROP;
@@ -238,16 +237,16 @@ void image_preview_event(int event)
ntreeCompositTagGenerators(G.scene->nodetree);
G.afbreek= 0;
G.scene->nodetree->timecursor= set_timecursor;
G.scene->nodetree->test_break= blender_test_break;
G.afbreek = 0;
G.scene->nodetree->timecursor = set_timecursor;
G.scene->nodetree->test_break = blender_test_break;
BIF_store_spare();
ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, 1); /* 1 is do_previews */
ntreeCompositExecTree(G.scene->nodetree, &G.scene->r, 1); /* 1 is do_previews */
G.scene->nodetree->timecursor= NULL;
G.scene->nodetree->test_break= NULL;
G.scene->nodetree->timecursor = NULL;
G.scene->nodetree->test_break = NULL;
scrarea_do_windraw(curarea);
waitcursor(0);
@@ -260,21 +259,21 @@ void image_preview_event(int event)
/* nothing drawn here, we use it to store values */
static void preview_cb(struct ScrArea *sa, struct uiBlock *block)
{
SpaceImage *sima= sa->spacedata.first;
SpaceImage *sima = sa->spacedata.first;
rctf dispf;
rcti *disprect= &G.scene->r.disprect;
int winx= (G.scene->r.size*G.scene->r.xsch)/100;
int winy= (G.scene->r.size*G.scene->r.ysch)/100;
rcti *disprect = &G.scene->r.disprect;
int winx = (G.scene->r.size * G.scene->r.xsch) / 100;
int winy = (G.scene->r.size * G.scene->r.ysch) / 100;
int mval[2];
if (G.scene->r.mode & R_BORDER) {
winx*= (G.scene->r.border.xmax - G.scene->r.border.xmin);
winy*= (G.scene->r.border.ymax - G.scene->r.border.ymin);
winx *= (G.scene->r.border.xmax - G.scene->r.border.xmin);
winy *= (G.scene->r.border.ymax - G.scene->r.border.ymin);
}
/* while dragging we need to update the rects, otherwise it doesn't end with correct one */
BLI_init_rctf(&dispf, 15.0f, (block->maxx - block->minx)-15.0f, 15.0f, (block->maxy - block->miny)-15.0f);
BLI_init_rctf(&dispf, 15.0f, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f);
ui_graphics_to_window_rct(sa->win, &dispf, disprect);
/* correction for gla draw */
@@ -283,9 +282,9 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block)
calc_image_view(sima, 'p');
// printf("winrct %d %d %d %d\n", disprect->xmin, disprect->ymin,disprect->xmax, disprect->ymax);
/* map to image space coordinates */
mval[0]= disprect->xmin; mval[1]= disprect->ymin;
mval[0] = disprect->xmin; mval[1] = disprect->ymin;
areamouseco_to_ipoco(v2d, mval, &dispf.xmin, &dispf.ymin);
mval[0]= disprect->xmax; mval[1]= disprect->ymax;
mval[0] = disprect->xmax; mval[1] = disprect->ymax;
areamouseco_to_ipoco(v2d, mval, &dispf.xmax, &dispf.ymax);
/* map to render coordinates */
@@ -304,43 +303,43 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block)
static int is_preview_allowed(ScrArea *cur)
{
SpaceImage *sima= cur->spacedata.first;
SpaceImage *sima = cur->spacedata.first;
ScrArea *sa;
/* check if another areawindow has preview set */
for (sa=G.curscreen->areabase.first; sa; sa= sa->next) {
if (sa!=cur && sa->spacetype==SPACE_IMAGE) {
for (sa = G.curscreen->areabase.first; sa; sa = sa->next) {
if (sa != cur && sa->spacetype == SPACE_IMAGE) {
if (image_preview_active(sa, NULL, NULL))
return 0;
}
}
/* check image type */
if (sima->image==NULL || sima->image->type!=IMA_TYPE_COMPOSITE)
if (sima->image == NULL || sima->image->type != IMA_TYPE_COMPOSITE)
return 0;
return 1;
}
static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVIEW
static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVIEW
{
uiBlock *block;
SpaceImage *sima= sa->spacedata.first;
SpaceImage *sima = sa->spacedata.first;
int ofsx, ofsy;
if (is_preview_allowed(sa)==0) {
if (is_preview_allowed(sa) == 0) {
rem_blockhandler(sa, IMAGE_HANDLER_PREVIEW);
G.scene->r.scemode &= ~R_COMP_CROP; /* quite weak */
G.scene->r.scemode &= ~R_COMP_CROP; /* quite weak */
return;
}
block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl);
uiSetPanelHandler(IMAGE_HANDLER_PREVIEW); // for close and esc
ofsx= -150+(sa->winx/2)/sima->blockscale;
ofsy= -100+(sa->winy/2)/sima->blockscale;
if (uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200)==0) return;
ofsx = -150 + (sa->winx / 2) / sima->blockscale;
ofsy = -100 + (sa->winy / 2) / sima->blockscale;
if (uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200) == 0) return;
uiBlockSetDrawExtraFunc(block, preview_cb);
@@ -355,13 +354,13 @@ static char *slot_menu(void)
char *str;
int a, slot;
str= MEM_callocN(IMA_MAX_RENDER_SLOT*32, "menu slots");
str = MEM_callocN(IMA_MAX_RENDER_SLOT * 32, "menu slots");
strcpy(str, "Slot %t");
a= strlen(str);
a = strlen(str);
for (slot=0; slot<IMA_MAX_RENDER_SLOT; slot++)
a += sprintf(str+a, "|Slot %d %%x%d", slot+1, slot);
for (slot = 0; slot < IMA_MAX_RENDER_SLOT; slot++)
a += sprintf(str + a, "|Slot %d %%x%d", slot + 1, slot);
return str;
}
@@ -370,24 +369,24 @@ static char *slot_menu(void)
static char *layer_menu(RenderResult *rr, short *UNUSED(curlay))
{
RenderLayer *rl;
int len= 64 + 32*BLI_countlist(&rr->layers);
short a, nr= 0;
char *str= MEM_callocN(len, "menu layers");
int len = 64 + 32 * BLI_countlist(&rr->layers);
short a, nr = 0;
char *str = MEM_callocN(len, "menu layers");
strcpy(str, "Layer %t");
a= strlen(str);
a = strlen(str);
/* compo result */
if (rr->rectf) {
a+= sprintf(str+a, "|Composite %%x0");
nr= 1;
a += sprintf(str + a, "|Composite %%x0");
nr = 1;
}
else if (rr->rect32) {
a+= sprintf(str+a, "|Sequence %%x0");
nr= 1;
a += sprintf(str + a, "|Sequence %%x0");
nr = 1;
}
for (rl= rr->layers.first; rl; rl= rl->next, nr++) {
a+= sprintf(str+a, "|%s %%x%d", rl->name, nr);
for (rl = rr->layers.first; rl; rl = rl->next, nr++) {
a += sprintf(str + a, "|%s %%x%d", rl->name, nr);
}
/* no curlay clip here, on render (redraws) the amount of layers can be 1 fir single-layer render */
@@ -399,34 +398,34 @@ static char *layer_menu(RenderResult *rr, short *UNUSED(curlay))
static char *pass_menu(RenderLayer *rl, short *curpass)
{
RenderPass *rpass;
int len= 64 + 32*(rl?BLI_countlist(&rl->passes):1);
short a, nr= 0;
char *str= MEM_callocN(len, "menu layers");
int len = 64 + 32 * (rl ? BLI_countlist(&rl->passes) : 1);
short a, nr = 0;
char *str = MEM_callocN(len, "menu layers");
strcpy(str, "Pass %t");
a= strlen(str);
a = strlen(str);
/* rendered results don't have a Combined pass */
if (rl==NULL || rl->rectf) {
a+= sprintf(str+a, "|Combined %%x0");
nr= 1;
if (rl == NULL || rl->rectf) {
a += sprintf(str + a, "|Combined %%x0");
nr = 1;
}
if (rl)
for (rpass= rl->passes.first; rpass; rpass= rpass->next, nr++)
a+= sprintf(str+a, "|%s %%x%d", rpass->name, nr);
for (rpass = rl->passes.first; rpass; rpass = rpass->next, nr++)
a += sprintf(str + a, "|%s %%x%d", rpass->name, nr);
if (*curpass >= nr)
*curpass= 0;
*curpass = 0;
return str;
}
static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v)
{
Scene *scene= CTX_data_scene(C);
Image *ima= ima_v;
ImageUser *iuser= iuser_v;
Scene *scene = CTX_data_scene(C);
Image *ima = ima_v;
ImageUser *iuser = iuser_v;
if (ima->anim) {
iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN);
@@ -437,70 +436,70 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v)
/* 5 layer button callbacks... */
static void image_multi_cb(bContext *C, void *rr_v, void *iuser_v)
{
ImageUser *iuser= iuser_v;
ImageUser *iuser = iuser_v;
BKE_image_multilayer_index(rr_v, iuser);
WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
}
static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v)
{
RenderResult *rr= rr_v;
ImageUser *iuser= iuser_v;
int tot= BLI_countlist(&rr->layers);
RenderResult *rr = rr_v;
ImageUser *iuser = iuser_v;
int tot = BLI_countlist(&rr->layers);
if (rr->rectf || rr->rect32)
tot++; /* fake compo/sequencer layer */
tot++; /* fake compo/sequencer layer */
if (iuser->layer<tot-1) {
if (iuser->layer < tot - 1) {
iuser->layer++;
BKE_image_multilayer_index(rr, iuser);
WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
}
}
static void image_multi_declay_cb(bContext *C, void *rr_v, void *iuser_v)
{
ImageUser *iuser= iuser_v;
ImageUser *iuser = iuser_v;
if (iuser->layer>0) {
if (iuser->layer > 0) {
iuser->layer--;
BKE_image_multilayer_index(rr_v, iuser);
WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
}
}
static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v)
{
RenderResult *rr= rr_v;
ImageUser *iuser= iuser_v;
RenderLayer *rl= BLI_findlink(&rr->layers, iuser->layer);
RenderResult *rr = rr_v;
ImageUser *iuser = iuser_v;
RenderLayer *rl = BLI_findlink(&rr->layers, iuser->layer);
if (rl) {
int tot= BLI_countlist(&rl->passes);
int tot = BLI_countlist(&rl->passes);
if (rr->rectf || rr->rect32)
tot++; /* fake compo/sequencer layer */
tot++; /* fake compo/sequencer layer */
if (iuser->pass<tot-1) {
if (iuser->pass < tot - 1) {
iuser->pass++;
BKE_image_multilayer_index(rr, iuser);
WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
}
}
}
static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v)
{
ImageUser *iuser= iuser_v;
ImageUser *iuser = iuser_v;
if (iuser->pass>0) {
if (iuser->pass > 0) {
iuser->pass--;
BKE_image_multilayer_index(rr_v, iuser);
WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
}
}
#if 0
static void image_freecache_cb(bContext *C, void *ima_v, void *unused)
{
Scene *scene= CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
BKE_image_free_anim_ibufs(ima_v, scene->r.cfra);
WM_event_add_notifier(C, NC_IMAGE, ima_v);
}
@@ -509,47 +508,47 @@ static void image_freecache_cb(bContext *C, void *ima_v, void *unused)
#if 0
static void image_user_change(bContext *C, void *iuser_v, void *unused)
{
Scene *scene= CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
BKE_image_user_calc_imanr(iuser_v, scene->r.cfra, 0);
}
#endif
static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, short *render_slot)
{
uiBlock *block= uiLayoutGetBlock(layout);
uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but;
RenderLayer *rl= NULL;
RenderLayer *rl = NULL;
int wmenu1, wmenu2, wmenu3, layer;
char *strp;
uiLayoutRow(layout, 1);
/* layer menu is 1/3 larger than pass */
wmenu1= (2*w)/5;
wmenu2= (3*w)/5;
wmenu3= (3*w)/6;
wmenu1 = (2 * w) / 5;
wmenu2 = (3 * w) / 5;
wmenu3 = (3 * w) / 6;
/* menu buts */
if (render_slot) {
strp= slot_menu();
but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, UI_UNIT_Y, render_slot, 0,0,0,0, "Select Slot");
strp = slot_menu();
but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, UI_UNIT_Y, render_slot, 0, 0, 0, 0, "Select Slot");
uiButSetFunc(but, image_multi_cb, rr, iuser);
MEM_freeN(strp);
}
if (rr) {
strp= layer_menu(rr, &iuser->layer);
but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, UI_UNIT_Y, &iuser->layer, 0,0,0,0, "Select Layer");
strp = layer_menu(rr, &iuser->layer);
but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, UI_UNIT_Y, &iuser->layer, 0, 0, 0, 0, "Select Layer");
uiButSetFunc(but, image_multi_cb, rr, iuser);
MEM_freeN(strp);
layer = iuser->layer;
if (rr->rectf || rr->rect32)
layer--; /* fake compo/sequencer layer */
layer--; /* fake compo/sequencer layer */
rl= BLI_findlink(&rr->layers, layer); /* return NULL is meant to be */
strp= pass_menu(rl, &iuser->pass);
but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu3, UI_UNIT_Y, &iuser->pass, 0,0,0,0, "Select Pass");
rl = BLI_findlink(&rr->layers, layer); /* return NULL is meant to be */
strp = pass_menu(rl, &iuser->pass);
but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu3, UI_UNIT_Y, &iuser->pass, 0, 0, 0, 0, "Select Pass");
uiButSetFunc(but, image_multi_cb, rr, iuser);
MEM_freeN(strp);
}
@@ -557,32 +556,32 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image
static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, short *render_slot)
{
uiBlock *block= uiLayoutGetBlock(layout);
uiBlock *block = uiLayoutGetBlock(layout);
uiLayout *row;
uiBut *but;
const float dpi_fac= UI_DPI_FAC;
const float dpi_fac = UI_DPI_FAC;
row= uiLayoutRow(layout, 1);
row = uiLayoutRow(layout, 1);
if (rr==NULL || iuser==NULL)
if (rr == NULL || iuser == NULL)
return;
if (rr->layers.first==NULL) {
if (rr->layers.first == NULL) {
uiItemL(row, "No Layers in Render Result", ICON_NONE);
return;
}
/* decrease, increase arrows */
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Layer");
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 17, 20, NULL, 0, 0, 0, 0, "Previous Layer");
uiButSetFunc(but, image_multi_declay_cb, rr, iuser);
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Layer");
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 18, 20, NULL, 0, 0, 0, 0, "Next Layer");
uiButSetFunc(but, image_multi_inclay_cb, rr, iuser);
uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot);
/* decrease, increase arrows */
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Pass");
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 17, 20, NULL, 0, 0, 0, 0, "Previous Pass");
uiButSetFunc(but, image_multi_decpass_cb, rr, iuser);
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Pass");
but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 18, 20, NULL, 0, 0, 0, 0, "Next Pass");
uiButSetFunc(but, image_multi_incpass_cb, rr, iuser);
uiBlockEndAlign(block);
@@ -599,11 +598,11 @@ typedef struct RNAUpdateCb {
static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
{
RNAUpdateCb *cb= (RNAUpdateCb*)arg_cb;
RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb;
/* ideally this would be done by RNA itself, but there we have
* no image user available, so we just update this flag here */
cb->iuser->ok= 1;
* no image user available, so we just update this flag here */
cb->iuser->ok = 1;
/* we call update here on the pointer property, this way the
* owner of the image pointer can still define it's own update
@@ -619,7 +618,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
Image *ima;
ImageUser *iuser;
ImBuf *ibuf;
Scene *scene= CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
uiLayout *row, *split, *col;
uiBlock *block;
uiBut *but;
@@ -629,7 +628,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
if (!ptr->data)
return;
prop= RNA_struct_find_property(ptr, propname);
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
printf("%s: property not found: %s.%s\n",
__func__, RNA_struct_identifier(ptr->type), propname);
@@ -642,16 +641,16 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
return;
}
block= uiLayoutGetBlock(layout);
block = uiLayoutGetBlock(layout);
imaptr= RNA_property_pointer_get(ptr, prop);
ima= imaptr.data;
iuser= userptr->data;
imaptr = RNA_property_pointer_get(ptr, prop);
ima = imaptr.data;
iuser = userptr->data;
cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
cb->ptr= *ptr;
cb->prop= prop;
cb->iuser= iuser;
cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
cb->ptr = *ptr;
cb->prop = prop;
cb->iuser = iuser;
uiLayoutSetContextPointer(layout, "edit_image", &imaptr);
@@ -662,37 +661,37 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);
if (ima->source == IMA_SRC_VIEWER) {
ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock);
ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
image_info(scene, iuser, ima, ibuf, str);
BKE_image_release_ibuf(ima, lock);
uiItemL(layout, ima->id.name+2, ICON_NONE);
uiItemL(layout, ima->id.name + 2, ICON_NONE);
uiItemL(layout, str, ICON_NONE);
if (ima->type==IMA_TYPE_COMPOSITE) {
if (ima->type == IMA_TYPE_COMPOSITE) {
// XXX not working yet
#if 0
iuser= ntree_get_active_iuser(scene->nodetree);
iuser = ntree_get_active_iuser(scene->nodetree);
if (iuser) {
uiBlockBeginAlign(block);
uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10,120,100,20, 0, 0, 0, 0, 0, "");
uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110,120,100,20, 0, 0, 0, 0, 0, "");
but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210,120,100,20, 0, 0, 0, 0, 0, "");
uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, "");
uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, "");
but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");
uiButSetFunc(but, image_freecache_cb, ima, NULL);
if (iuser->frames)
BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
else strcpy(str, "Frames:");
uiBlockBeginAlign(block);
uiDefButI(block, NUM, imagechanged, str, 10, 90,150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
uiDefButI(block, NUM, imagechanged, "StartFr:", 160,90,150,20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie");
uiDefButI(block, NUM, imagechanged, str, 10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie");
}
#endif
}
else if (ima->type==IMA_TYPE_R_RESULT) {
else if (ima->type == IMA_TYPE_R_RESULT) {
/* browse layer/passes */
Render *re= RE_GetRender(scene->id.name);
RenderResult *rr= RE_AcquireResultRead(re);
Render *re = RE_GetRender(scene->id.name);
RenderResult *rr = RE_AcquireResultRead(re);
uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot);
RE_ReleaseResult(re);
}
@@ -701,22 +700,22 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE);
if (ima->source != IMA_SRC_GENERATED) {
row= uiLayoutRow(layout, 1);
row = uiLayoutRow(layout, 1);
if (ima->packedfile)
uiItemO(row, "", ICON_PACKAGE, "image.unpack");
else
uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
row= uiLayoutRow(row, 0);
uiLayoutSetEnabled(row, ima->packedfile==NULL);
row = uiLayoutRow(row, 0);
uiLayoutSetEnabled(row, ima->packedfile == NULL);
uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
}
// XXX what was this for?
#if 0
/* check for re-render, only buttons */
if (imagechanged==B_IMAGECHANGED) {
/* check for re-render, only buttons */
if (imagechanged == B_IMAGECHANGED) {
if (iuser->flag & IMA_ANIM_REFRESHED) {
iuser->flag &= ~IMA_ANIM_REFRESHED;
WM_event_add_notifier(C, NC_IMAGE, ima);
@@ -725,12 +724,12 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
#endif
/* multilayer? */
if (ima->type==IMA_TYPE_MULTILAYER && ima->rr) {
if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL);
}
else if (ima->source != IMA_SRC_GENERATED) {
if (compact == 0) {
ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock);
ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
image_info(scene, iuser, ima, ibuf, str);
BKE_image_release_ibuf(ima, lock);
uiItemL(layout, str, ICON_NONE);
@@ -741,15 +740,15 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
if (compact == 0) { /* background image view doesnt need these */
uiItemS(layout);
split= uiLayoutSplit(layout, 0, 0);
split = uiLayoutSplit(layout, 0, 0);
col= uiLayoutColumn(split, 0);
col = uiLayoutColumn(split, 0);
uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE);
row= uiLayoutRow(col, 0);
row = uiLayoutRow(col, 0);
uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields"));
uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
row= uiLayoutRow(layout, 0);
row = uiLayoutRow(layout, 0);
uiItemR(row, &imaptr, "use_premultiply", 0, NULL, ICON_NONE);
uiItemR(row, &imaptr, "use_color_unpremultiply", 0, NULL, ICON_NONE);
}
@@ -758,32 +757,32 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
uiItemS(layout);
split= uiLayoutSplit(layout, 0, 0);
split = uiLayoutSplit(layout, 0, 0);
col= uiLayoutColumn(split, 0);
col = uiLayoutColumn(split, 0);
BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr);
uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE);
if (ima->anim) {
block= uiLayoutGetBlock(col);
but = uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X*2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence");
block = uiLayoutGetBlock(col);
but = uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X * 2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence");
uiButSetFunc(but, set_frames_cb, ima, iuser);
}
uiItemR(col, userptr, "frame_start", 0, "Start", ICON_NONE);
uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE);
col= uiLayoutColumn(split, 0);
row= uiLayoutRow(col, 0);
col = uiLayoutColumn(split, 0);
row = uiLayoutRow(col, 0);
uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields"));
uiItemR(row, userptr, "fields_per_frame", 0, "Fields", ICON_NONE);
uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE);
uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE);
}
else if (ima->source==IMA_SRC_GENERATED) {
split= uiLayoutSplit(layout, 0, 0);
else if (ima->source == IMA_SRC_GENERATED) {
split = uiLayoutSplit(layout, 0, 0);
col= uiLayoutColumn(split, 1);
col = uiLayoutColumn(split, 1);
uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
@@ -791,7 +790,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
}
}
}
uiBlockSetNFunc(block, NULL, NULL, NULL);
}
@@ -801,32 +800,32 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
{
ImageFormatData *imf= imfptr->data;
ID *id= imfptr->id.data;
const int depth_ok= BKE_imtype_valid_depths(imf->imtype);
ImageFormatData *imf = imfptr->data;
ID *id = imfptr->id.data;
const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
/* some settings depend on this being a scene thats rendered */
const short is_render_out= (id && GS(id->name) == ID_SCE);
const short is_render_out = (id && GS(id->name) == ID_SCE);
uiLayout *col, *row, *split, *sub;
col= uiLayoutColumn(layout, 0);
col = uiLayoutColumn(layout, 0);
split= uiLayoutSplit(col, 0.5f, 0);
split = uiLayoutSplit(col, 0.5f, 0);
uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE);
sub= uiLayoutRow(split, 0);
sub = uiLayoutRow(split, 0);
uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, "Color", ICON_NONE);
/* only display depth setting if multiple depths can be used */
if ((ELEM6(depth_ok,
R_IMF_CHAN_DEPTH_1,
R_IMF_CHAN_DEPTH_8,
R_IMF_CHAN_DEPTH_12,
R_IMF_CHAN_DEPTH_16,
R_IMF_CHAN_DEPTH_24,
R_IMF_CHAN_DEPTH_32)) == 0)
R_IMF_CHAN_DEPTH_1,
R_IMF_CHAN_DEPTH_8,
R_IMF_CHAN_DEPTH_12,
R_IMF_CHAN_DEPTH_16,
R_IMF_CHAN_DEPTH_24,
R_IMF_CHAN_DEPTH_32)) == 0)
{
row= uiLayoutRow(col, 0);
row = uiLayoutRow(col, 0);
uiItemR(row, imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
}
@@ -842,7 +841,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
}
row= uiLayoutRow(col, 0);
row = uiLayoutRow(col, 0);
if (BKE_imtype_supports_zbuf(imf->imtype)) {
uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE);
}
@@ -852,7 +851,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
}
if (imf->imtype == R_IMF_IMTYPE_JP2) {
row= uiLayoutRow(col, 0);
row = uiLayoutRow(col, 0);
uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE);
uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE);
@@ -873,7 +872,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr)
void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
{
Scene *scene= CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
Render *re;
RenderResult *rr;
@@ -882,7 +881,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser
const float dpi_fac = UI_DPI_FAC;
re = RE_GetRender(scene->id.name);
rr = RE_AcquireResultRead(re);
uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL);
uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL);
RE_ReleaseResult(re);
}
}
@@ -891,25 +890,25 @@ void image_buttons_register(ARegionType *art)
{
PanelType *pt;
pt= MEM_callocN(sizeof(PanelType), "spacetype image panel curves");
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel curves");
strcpy(pt->idname, "IMAGE_PT_curves");
strcpy(pt->label, "Curves");
pt->draw= image_panel_curves;
pt->poll= image_panel_poll;
pt->draw = image_panel_curves;
pt->poll = image_panel_poll;
pt->flag |= PNL_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
pt= MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
strcpy(pt->idname, "IMAGE_PT_gpencil");
strcpy(pt->label, "Grease Pencil");
pt->draw= gpencil_panel_standard;
pt->draw = gpencil_panel_standard;
BLI_addtail(&art->paneltypes, pt);
}
static int image_properties(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= image_has_buttons_region(sa);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = image_has_buttons_region(sa);
if (ar)
ED_region_toggle_hidden(C, ar);
@@ -932,8 +931,8 @@ void IMAGE_OT_properties(wmOperatorType *ot)
static int image_scopes(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= image_has_scope_region(sa);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = image_has_scope_region(sa);
if (ar)
ED_region_toggle_hidden(C, ar);

View File

@@ -85,7 +85,7 @@ static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
* NOTE: if float buffer changes, we have to manually remove the rect
*/
if (ibuf->rect_float && (ibuf->rect==NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
if (ibuf->rect_float && (ibuf->rect == NULL || (ibuf->userflags & IB_RECT_INVALID)) ) {
if (color_manage) {
if (ima && ima->source == IMA_SRC_VIEWER)
ibuf->profile = IB_PROFILE_LINEAR_RGB;
@@ -101,7 +101,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
{
RenderResult *rr;
rr= BKE_image_acquire_renderresult(scene, ima);
rr = BKE_image_acquire_renderresult(scene, ima);
if (rr && rr->text) {
ED_region_info_draw(ar, rr->text, 1, 0.25);
@@ -115,7 +115,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
{
char str[256];
float dx= 6;
float dx = 6;
/* text colors */
/* XXX colored text not allowed in Blender UI */
#if 0
@@ -127,10 +127,10 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
unsigned char green[3] = {255, 255, 255};
unsigned char blue[3] = {255, 255, 255};
#endif
float hue=0, sat=0, val=0, lum=0, u=0, v=0;
float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0;
float col[4], finalcol[4];
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
/* noisy, high contrast make impossible to read if lower alpha is used. */
@@ -149,7 +149,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
if (zp) {
glColor3ub(255, 255, 255);
BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff));
BLF_position(blf_mono_font, dx, 6, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
dx += BLF_width(blf_mono_font, str);
@@ -211,19 +211,19 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
}
/* color rectangle */
if (channels==1) {
if (channels == 1) {
if (fp) {
col[0] = col[1] = col[2] = fp[0];
}
else if (cp) {
col[0] = col[1] = col[2] = (float)cp[0]/255.0f;
col[0] = col[1] = col[2] = (float)cp[0] / 255.0f;
}
else {
col[0] = col[1] = col[2] = 0.0f;
}
col[3] = 1.0f;
}
else if (channels==3) {
else if (channels == 3) {
if (fp) {
copy_v3_v3(col, fp);
}
@@ -235,7 +235,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
}
col[3] = 1.0f;
}
else if (channels==4) {
else if (channels == 4) {
if (fp)
copy_v4_v4(col, fp);
else if (cp) {
@@ -262,8 +262,8 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
glBegin(GL_QUADS);
glVertex2f(dx, 3);
glVertex2f(dx, 17);
glVertex2f(dx+30, 17);
glVertex2f(dx+30, 3);
glVertex2f(dx + 30, 17);
glVertex2f(dx + 30, 3);
glEnd();
/* draw outline */
@@ -271,8 +271,8 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
glBegin(GL_LINE_LOOP);
glVertex2f(dx, 3);
glVertex2f(dx, 17);
glVertex2f(dx+30, 17);
glVertex2f(dx+30, 3);
glVertex2f(dx + 30, 17);
glVertex2f(dx + 30, 3);
glEnd();
dx += 35;
@@ -284,8 +284,8 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v);
}
else if (cp) {
rgb_to_hsv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &hue, &sat, &val);
rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v);
rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &hue, &sat, &val);
rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &lum, &u, &v);
}
BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
@@ -304,8 +304,8 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v);
}
else if (cp) {
rgb_to_hsv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &hue, &sat, &val);
rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v);
rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[1] / 255.0f, (float)cp[2] / 255.0f, &hue, &sat, &val);
rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[1] / 255.0f, (float)cp[2] / 255.0f, &lum, &u, &v);
}
BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
@@ -336,7 +336,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
static void draw_image_grid(ARegion *ar, float zoomx, float zoomy)
{
float gridsize, gridstep= 1.0f/32.0f;
float gridsize, gridstep = 1.0f / 32.0f;
float fac, blendfac;
int x1, y1, x2, y2;
@@ -348,47 +348,47 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy)
glRectf(x1, y1, x2, y2);
/* gridsize adapted to zoom level */
gridsize= 0.5f*(zoomx+zoomy);
if (gridsize<=0.0f) return;
gridsize = 0.5f * (zoomx + zoomy);
if (gridsize <= 0.0f) return;
if (gridsize<1.0f) {
while (gridsize<1.0f) {
gridsize*= 4.0f;
gridstep*= 4.0f;
if (gridsize < 1.0f) {
while (gridsize < 1.0f) {
gridsize *= 4.0f;
gridstep *= 4.0f;
}
}
else {
while (gridsize>=4.0f) {
gridsize/= 4.0f;
gridstep/= 4.0f;
while (gridsize >= 4.0f) {
gridsize /= 4.0f;
gridstep /= 4.0f;
}
}
/* the fine resolution level */
blendfac= 0.25f*gridsize - floorf(0.25f*gridsize);
blendfac = 0.25f * gridsize - floorf(0.25f * gridsize);
CLAMP(blendfac, 0.0f, 1.0f);
UI_ThemeColorShade(TH_BACK, (int)(20.0f*(1.0f-blendfac)));
UI_ThemeColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac)));
fac= 0.0f;
fac = 0.0f;
glBegin(GL_LINES);
while (fac<1.0f) {
glVertex2f(x1, y1*(1.0f-fac) + y2*fac);
glVertex2f(x2, y1*(1.0f-fac) + y2*fac);
glVertex2f(x1*(1.0f-fac) + x2*fac, y1);
glVertex2f(x1*(1.0f-fac) + x2*fac, y2);
fac+= gridstep;
while (fac < 1.0f) {
glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
fac += gridstep;
}
/* the large resolution level */
UI_ThemeColor(TH_BACK);
fac= 0.0f;
while (fac<1.0f) {
glVertex2f(x1, y1*(1.0f-fac) + y2*fac);
glVertex2f(x2, y1*(1.0f-fac) + y2*fac);
glVertex2f(x1*(1.0f-fac) + x2*fac, y1);
glVertex2f(x1*(1.0f-fac) + x2*fac, y2);
fac+= 4.0f*gridstep;
fac = 0.0f;
while (fac < 1.0f) {
glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac);
glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac);
glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1);
glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2);
fac += 4.0f * gridstep;
}
glEnd();
}
@@ -406,11 +406,11 @@ static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, uns
static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, float *rectf)
{
float *trectf= MEM_mallocN(rectx*recty*4, "temp");
float *trectf = MEM_mallocN(rectx * recty * 4, "temp");
int a, b;
for (a= rectx*recty -1, b= 4*a+3; a>=0; a--, b-=4)
trectf[a]= rectf[b];
for (a = rectx * recty - 1, b = 4 * a + 3; a >= 0; a--, b -= 4)
trectf[a] = rectf[b];
glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf);
MEM_freeN(trectf);
@@ -449,26 +449,26 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec
float bias, scale, *rectf, clipend;
int a;
if (scene->camera && scene->camera->type==OB_CAMERA) {
bias= ((Camera *)scene->camera->data)->clipsta;
clipend= ((Camera *)scene->camera->data)->clipend;
scale= 1.0f/(clipend-bias);
if (scene->camera && scene->camera->type == OB_CAMERA) {
bias = ((Camera *)scene->camera->data)->clipsta;
clipend = ((Camera *)scene->camera->data)->clipend;
scale = 1.0f / (clipend - bias);
}
else {
bias= 0.1f;
scale= 0.01f;
clipend= 100.0f;
bias = 0.1f;
scale = 0.01f;
clipend = 100.0f;
}
rectf= MEM_mallocN(rectx*recty*4, "temp");
for (a= rectx*recty -1; a>=0; a--) {
if (rect_float[a]>clipend)
rectf[a]= 0.0f;
else if (rect_float[a]<bias)
rectf[a]= 1.0f;
rectf = MEM_mallocN(rectx * recty * 4, "temp");
for (a = rectx * recty - 1; a >= 0; a--) {
if (rect_float[a] > clipend)
rectf[a] = 0.0f;
else if (rect_float[a] < bias)
rectf[a] = 1.0f;
else {
rectf[a]= 1.0f - (rect_float[a]-bias)*scale;
rectf[a]*= rectf[a];
rectf[a] = 1.0f - (rect_float[a] - bias) * scale;
rectf[a] *= rectf[a];
}
}
glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, rectf);
@@ -491,20 +491,20 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image
if (sima->flag & SI_SHOW_ALPHA) {
if (ibuf->rect)
sima_draw_alpha_pixels(x, y, ibuf->x, ibuf->y, ibuf->rect);
else if (ibuf->rect_float && ibuf->channels==4)
else if (ibuf->rect_float && ibuf->channels == 4)
sima_draw_alpha_pixelsf(x, y, ibuf->x, ibuf->y, ibuf->rect_float);
}
else if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1))) {
else if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) {
if (ibuf->zbuf)
sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf);
else if (ibuf->zbuf_float)
sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float);
else if (ibuf->channels==1)
else if (ibuf->channels == 1)
sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float);
}
else {
if (sima->flag & SI_USE_ALPHA) {
fdrawcheckerboard(x, y, x + ibuf->x*zoomx, y + ibuf->y*zoomy);
fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -536,17 +536,17 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty,
/* the right offset in rectot */
rt= ibuf->rect+ (starty*ibuf->x+ startx);
rt = ibuf->rect + (starty * ibuf->x + startx);
len= (endx-startx);
heigth= (endy-starty);
len = (endx - startx);
heigth = (endy - starty);
rp=rectmain= MEM_mallocN(heigth*len*sizeof(int), "rect");
rp = rectmain = MEM_mallocN(heigth * len * sizeof(int), "rect");
for (y=0; y<heigth; y++) {
memcpy(rp, rt, len*4);
rt+= ibuf->x;
rp+= len;
for (y = 0; y < heigth; y++) {
memcpy(rp, rt, len * 4);
rt += ibuf->x;
rp += len;
}
return rectmain;
}
@@ -558,28 +558,28 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
/* verify valid values, just leave this a while */
if (ima->xrep<1) return;
if (ima->yrep<1) return;
if (ima->xrep < 1) return;
if (ima->yrep < 1) return;
glPixelZoom(zoomx, zoomy);
if (sima->curtile >= ima->xrep*ima->yrep)
sima->curtile = ima->xrep*ima->yrep - 1;
if (sima->curtile >= ima->xrep * ima->yrep)
sima->curtile = ima->xrep * ima->yrep - 1;
/* create char buffer from float if needed */
image_verify_buffer_float(ima, ibuf, color_manage);
/* retrieve part of image buffer */
dx= ibuf->x/ima->xrep;
dy= ibuf->y/ima->yrep;
sx= (sima->curtile % ima->xrep)*dx;
sy= (sima->curtile / ima->xrep)*dy;
rect= get_part_from_ibuf(ibuf, sx, sy, sx+dx, sy+dy);
dx = ibuf->x / ima->xrep;
dy = ibuf->y / ima->yrep;
sx = (sima->curtile % ima->xrep) * dx;
sy = (sima->curtile / ima->xrep) * dy;
rect = get_part_from_ibuf(ibuf, sx, sy, sx + dx, sy + dy);
/* draw repeated */
for (sy=0; sy+dy<=ibuf->y; sy+= dy) {
for (sx=0; sx+dx<=ibuf->x; sx+= dx) {
UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx/(float)ibuf->x, fy + (float)sy/(float)ibuf->y, &x, &y);
for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
for (sx = 0; sx + dx <= ibuf->x; sx += dx) {
UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y);
glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect);
}
@@ -592,18 +592,18 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene,
static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
{
const double time_current= PIL_check_seconds_timer();
const double time_current = PIL_check_seconds_timer();
const int xmax= ceil(ar->v2d.cur.xmax);
const int ymax= ceil(ar->v2d.cur.ymax);
const int xmin= floor(ar->v2d.cur.xmin);
const int ymin= floor(ar->v2d.cur.ymin);
const int xmax = ceil(ar->v2d.cur.xmax);
const int ymax = ceil(ar->v2d.cur.ymax);
const int xmin = floor(ar->v2d.cur.xmin);
const int ymin = floor(ar->v2d.cur.ymin);
int x;
for (x=xmin; x<xmax; x++) {
for (x = xmin; x < xmax; x++) {
int y;
for (y=ymin; y<ymax; y++) {
for (y = ymin; y < ymax; y++) {
if (ima && (ima->tpageflag & IMA_TILES))
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
else
@@ -624,13 +624,13 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d)
/* draw in View2D space? */
if (onlyv2d) {
/* assume that UI_view2d_ortho(C) has been called... */
SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C);
SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
/* draw grease-pencil ('image' strokes) */
//if (sima->flag & SI_DISPGP)
draw_gpencil_2dimage(C, ibuf);
draw_gpencil_2dimage(C, ibuf);
ED_space_image_release_buffer(sima, lock);
}
@@ -640,7 +640,7 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d)
/* draw grease-pencil ('screen' strokes) */
//if (sima->flag & SI_DISPGP)
draw_gpencil_view2d(C, 0);
draw_gpencil_view2d(C, 0);
}
}
@@ -648,24 +648,24 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d)
#if 0
static void draw_image_view_tool(Scene *scene)
{
ToolSettings *settings= scene->toolsettings;
Brush *brush= settings->imapaint.brush;
ToolSettings *settings = scene->toolsettings;
Brush *brush = settings->imapaint.brush;
int mval[2];
float radius;
int draw= 0;
int draw = 0;
if (brush) {
if (settings->imapaint.flag & IMAGEPAINT_DRAWING) {
if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL_DRAWING)
draw= 1;
draw = 1;
}
else if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL)
draw= 1;
draw = 1;
if (draw) {
getmouseco_areawin(mval);
radius= brush_size(brush)*G.sima->zoom;
radius = brush_size(brush) * G.sima->zoom;
fdrawXORcirc(mval[0], mval[1], radius);
if (brush->innerradius != 1.0) {
@@ -687,24 +687,24 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh
if (!brush || !brush->clone.image)
return NULL;
ibuf= BKE_image_get_ibuf(brush->clone.image, NULL);
ibuf = BKE_image_get_ibuf(brush->clone.image, NULL);
if (!ibuf || !ibuf->rect)
return NULL;
rect= MEM_dupallocN(ibuf->rect);
rect = MEM_dupallocN(ibuf->rect);
if (!rect)
return NULL;
*width= ibuf->x;
*height= ibuf->y;
*width = ibuf->x;
*height = ibuf->y;
size= (*width)*(*height);
alpha= (unsigned char)255*brush->clone.alpha;
cp= rect;
size = (*width) * (*height);
alpha = (unsigned char)255 * brush->clone.alpha;
cp = rect;
while (size-- > 0) {
cp[3]= alpha;
cp[3] = alpha;
cp += 4;
}
@@ -717,12 +717,12 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo
int x, y, w, h;
unsigned char *clonerect;
brush= paint_brush(&scene->toolsettings->imapaint.paint);
brush = paint_brush(&scene->toolsettings->imapaint.paint);
if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
/* this is not very efficient, but glDrawPixels doesn't allow
* drawing with alpha */
clonerect= get_alpha_clone_image(scene, &w, &h);
clonerect = get_alpha_clone_image(scene, &w, &h);
if (clonerect) {
UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y);
@@ -759,28 +759,28 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
ED_image_aspect(sima->image, &xuser_asp, &yuser_asp);
/* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */
if (sima->image->type==IMA_TYPE_COMPOSITE) {
ImageUser *iuser= ntree_get_active_iuser(scene->nodetree);
if (sima->image->type == IMA_TYPE_COMPOSITE) {
ImageUser *iuser = ntree_get_active_iuser(scene->nodetree);
if (iuser) {
BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0);
sima->iuser= *iuser;
sima->iuser = *iuser;
}
}
/* and we check for spare */
ibuf= ED_space_image_buffer(sima);
ibuf = ED_space_image_buffer(sima);
}
#endif
/* retrieve the image and information about it */
ima= ED_space_image(sima);
ima = ED_space_image(sima);
ED_space_image_zoom(sima, ar, &zoomx, &zoomy);
ibuf= ED_space_image_acquire_buffer(sima, &lock);
ibuf = ED_space_image_acquire_buffer(sima, &lock);
show_viewer= (ima && ima->source == IMA_SRC_VIEWER);
show_render= (show_viewer && ima->type == IMA_TYPE_R_RESULT);
show_viewer = (ima && ima->source == IMA_SRC_VIEWER);
show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT);
/* draw the image or grid */
if (ibuf==NULL)
if (ibuf == NULL)
draw_image_grid(ar, zoomx, zoomy);
else if (sima->flag & SI_DRAW_TILE)
draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy);
@@ -797,12 +797,12 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
/* XXX integrate this code */
#if 0
if (ibuf) {
float xoffs=0.0f, yoffs= 0.0f;
float xoffs = 0.0f, yoffs = 0.0f;
if (image_preview_active(sa, &xim, &yim)) {
xoffs= scene->r.disprect.xmin;
yoffs= scene->r.disprect.ymin;
glColor3ub(0,0,0);
xoffs = scene->r.disprect.xmin;
yoffs = scene->r.disprect.ymin;
glColor3ub(0, 0, 0);
calc_image_view(sima, 'f');
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
glRectf(0.0f, 0.0f, 1.0f, 1.0f);

View File

@@ -84,10 +84,10 @@
static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float location[2])
{
float oldzoom= sima->zoom;
float oldzoom = sima->zoom;
int width, height;
sima->zoom= zoom;
sima->zoom = zoom;
if (sima->zoom < 0.1f || sima->zoom > 4.0f) {
/* check zoom limits */
@@ -97,11 +97,11 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
height *= sima->zoom;
if ((width < 4) && (height < 4))
sima->zoom= oldzoom;
sima->zoom = oldzoom;
else if ((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom)
sima->zoom= oldzoom;
sima->zoom = oldzoom;
else if ((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom)
sima->zoom= oldzoom;
sima->zoom = oldzoom;
}
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
@@ -110,17 +110,17 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
ED_space_image_size(sima, &width, &height);
ED_space_image_aspect(sima, &aspx, &aspy);
w= width*aspx;
h= height*aspy;
w = width * aspx;
h = height * aspy;
sima->xof+= ((location[0]-0.5f)*w-sima->xof)*(sima->zoom-oldzoom)/sima->zoom;
sima->yof+= ((location[1]-0.5f)*h-sima->yof)*(sima->zoom-oldzoom)/sima->zoom;
sima->xof += ((location[0] - 0.5f) * w - sima->xof) * (sima->zoom - oldzoom) / sima->zoom;
sima->yof += ((location[1] - 0.5f) * h - sima->yof) * (sima->zoom - oldzoom) / sima->zoom;
}
}
static void sima_zoom_set_factor(SpaceImage *sima, ARegion *ar, float zoomfac, float location[2])
{
sima_zoom_set(sima, ar, sima->zoom*zoomfac, location);
sima_zoom_set(sima, ar, sima->zoom * zoomfac, location);
}
#if 0 // currently unused
@@ -132,8 +132,8 @@ static int image_poll(bContext *C)
static int space_image_buffer_exists_poll(bContext *C)
{
SpaceImage *sima= CTX_wm_space_image(C);
if (sima && sima->spacetype==SPACE_IMAGE)
SpaceImage *sima = CTX_wm_space_image(C);
if (sima && sima->spacetype == SPACE_IMAGE)
if (ED_space_image_has_buffer(sima))
return 1;
return 0;
@@ -142,14 +142,14 @@ static int space_image_buffer_exists_poll(bContext *C)
static int space_image_file_exists_poll(bContext *C)
{
if (space_image_buffer_exists_poll(C)) {
Main *bmain= CTX_data_main(C);
SpaceImage *sima= CTX_wm_space_image(C);
Main *bmain = CTX_data_main(C);
SpaceImage *sima = CTX_wm_space_image(C);
ImBuf *ibuf;
void *lock;
int ret= FALSE;
int ret = FALSE;
char name[FILE_MAX];
ibuf= ED_space_image_acquire_buffer(sima, &lock);
ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
BLI_strncpy(name, ibuf->name, FILE_MAX);
BLI_path_abs(name, bmain->name);
@@ -161,7 +161,7 @@ static int space_image_file_exists_poll(bContext *C)
CTX_wm_operator_poll_msg_set(C, "image path can't be written to");
}
else {
ret= TRUE;
ret = TRUE;
}
}
ED_space_image_release_buffer(sima, lock);
@@ -173,19 +173,19 @@ static int space_image_file_exists_poll(bContext *C)
static int space_image_poll(bContext *C)
{
SpaceImage *sima= CTX_wm_space_image(C);
if (sima && sima->spacetype==SPACE_IMAGE && sima->image)
SpaceImage *sima = CTX_wm_space_image(C);
if (sima && sima->spacetype == SPACE_IMAGE && sima->image)
return 1;
return 0;
}
int space_image_main_area_poll(bContext *C)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
// XXX ARegion *ar= CTX_wm_region(C);
if (sima)
return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW);
return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW);
return 0;
}
@@ -193,7 +193,7 @@ int space_image_main_area_poll(bContext *C)
/* For IMAGE_OT_curves_point_set to avoid sampling when in uv smooth mode */
int space_image_main_area_not_uv_brush_poll(bContext *C)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings;
if (sima && !toolsettings->uvsculpt)
@@ -204,8 +204,8 @@ int space_image_main_area_not_uv_brush_poll(bContext *C)
static int space_image_image_sample_poll(bContext *C)
{
SpaceImage *sima= CTX_wm_space_image(C);
Object *obedit= CTX_data_edit_object(C);
SpaceImage *sima = CTX_wm_space_image(C);
Object *obedit = CTX_data_edit_object(C);
ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings;
if (obedit) {
@@ -224,29 +224,29 @@ typedef struct ViewPanData {
static void image_view_pan_init(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
ViewPanData *vpd;
op->customdata= vpd= MEM_callocN(sizeof(ViewPanData), "ImageViewPanData");
op->customdata = vpd = MEM_callocN(sizeof(ViewPanData), "ImageViewPanData");
WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR);
vpd->x= event->x;
vpd->y= event->y;
vpd->xof= sima->xof;
vpd->yof= sima->yof;
vpd->event_type= event->type;
vpd->x = event->x;
vpd->y = event->y;
vpd->xof = sima->xof;
vpd->yof = sima->yof;
vpd->event_type = event->type;
WM_event_add_modal_handler(C, op);
}
static void image_view_pan_exit(bContext *C, wmOperator *op, int cancel)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewPanData *vpd= op->customdata;
SpaceImage *sima = CTX_wm_space_image(C);
ViewPanData *vpd = op->customdata;
if (cancel) {
sima->xof= vpd->xof;
sima->yof= vpd->yof;
sima->xof = vpd->xof;
sima->yof = vpd->yof;
ED_region_tag_redraw(CTX_wm_region(C));
}
@@ -256,7 +256,7 @@ static void image_view_pan_exit(bContext *C, wmOperator *op, int cancel)
static int image_view_pan_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
float offset[2];
RNA_float_get_array(op->ptr, "offset", offset);
@@ -280,11 +280,11 @@ static int image_view_pan_exec(bContext *C, wmOperator *op)
static int image_view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
if (event->type == MOUSEPAN) {
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
float offset[2];
offset[0]= (event->x - event->prevx)/sima->zoom;
offset[1]= (event->y - event->prevy)/sima->zoom;
offset[0] = (event->x - event->prevx) / sima->zoom;
offset[1] = (event->y - event->prevy) / sima->zoom;
RNA_float_set_array(op->ptr, "offset", offset);
image_view_pan_exec(C, op);
@@ -298,21 +298,21 @@ static int image_view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int image_view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewPanData *vpd= op->customdata;
SpaceImage *sima = CTX_wm_space_image(C);
ViewPanData *vpd = op->customdata;
float offset[2];
switch(event->type) {
switch (event->type) {
case MOUSEMOVE:
sima->xof= vpd->xof;
sima->yof= vpd->yof;
offset[0]= (vpd->x - event->x)/sima->zoom;
offset[1]= (vpd->y - event->y)/sima->zoom;
sima->xof = vpd->xof;
sima->yof = vpd->yof;
offset[0] = (vpd->x - event->x) / sima->zoom;
offset[1] = (vpd->y - event->y) / sima->zoom;
RNA_float_set_array(op->ptr, "offset", offset);
image_view_pan_exec(C, op);
break;
default:
if (event->type==vpd->event_type && event->val==KM_RELEASE) {
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
image_view_pan_exit(C, op, 0);
return OPERATOR_FINISHED;
}
@@ -346,7 +346,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
/* properties */
RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX,
"Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX);
"Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX);
}
/********************** view zoom operator *********************/
@@ -360,17 +360,17 @@ typedef struct ViewZoomData {
static void image_view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
ViewZoomData *vpd;
op->customdata= vpd= MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData");
op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ImageViewZoomData");
WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR);
vpd->x= event->x;
vpd->y= event->y;
vpd->zoom= sima->zoom;
vpd->event_type= event->type;
vpd->x = event->x;
vpd->y = event->y;
vpd->zoom = sima->zoom;
vpd->event_type = event->type;
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &vpd->location[0], &vpd->location[1]);
@@ -379,11 +379,11 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel)
{
SpaceImage *sima= CTX_wm_space_image(C);
ViewZoomData *vpd= op->customdata;
SpaceImage *sima = CTX_wm_space_image(C);
ViewZoomData *vpd = op->customdata;
if (cancel) {
sima->zoom= vpd->zoom;
sima->zoom = vpd->zoom;
ED_region_tag_redraw(CTX_wm_region(C));
}
@@ -393,8 +393,8 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel)
static int image_view_zoom_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
sima_zoom_set_factor(sima, ar, RNA_float_get(op->ptr, "factor"), NULL);
@@ -415,15 +415,15 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op)
static int image_view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
if (event->type == MOUSEZOOM) {
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
float factor, location[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
factor= 1.0f + (event->x-event->prevx+event->y-event->prevy)/300.0f;
factor = 1.0f + (event->x - event->prevx + event->y - event->prevy) / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
sima_zoom_set(sima, ar, sima->zoom*factor, location);
sima_zoom_set(sima, ar, sima->zoom * factor, location);
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
@@ -436,20 +436,20 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int image_view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
ViewZoomData *vpd= op->customdata;
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
ViewZoomData *vpd = op->customdata;
float factor;
switch(event->type) {
switch (event->type) {
case MOUSEMOVE:
factor= 1.0f + (vpd->x-event->x+vpd->y-event->y)/300.0f;
factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
sima_zoom_set(sima, ar, vpd->zoom*factor, vpd->location);
sima_zoom_set(sima, ar, vpd->zoom * factor, vpd->location);
ED_region_tag_redraw(CTX_wm_region(C));
break;
default:
if (event->type==vpd->event_type && event->val==KM_RELEASE) {
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
image_view_zoom_exit(C, op, 0);
return OPERATOR_FINISHED;
}
@@ -483,7 +483,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot)
/* properties */
RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX,
"Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX);
"Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX);
}
/********************** NDOF operator *********************/
@@ -499,10 +499,10 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *
if (event->type != NDOF_MOTION)
return OPERATOR_CANCELLED;
else {
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata;
wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
float dt = ndof->dt;
/* tune these until it feels right */
@@ -557,14 +557,14 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
int width, height;
/* retrieve state */
sima= CTX_wm_space_image(C);
ar= CTX_wm_region(C);
sima = CTX_wm_space_image(C);
ar = CTX_wm_region(C);
ED_space_image_size(sima, &width, &height);
ED_space_image_aspect(sima, &aspx, &aspy);
w= width*aspx;
h= height*aspy;
w = width * aspx;
h = height * aspy;
/* check if the image will fit in the image with zoom==1 */
width = ar->winrct.xmax - ar->winrct.xmin + 1;
@@ -572,14 +572,14 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
/* find the zoom value that will fit the image in the image space */
zoomx= width/w;
zoomy= height/h;
sima_zoom_set(sima, ar, 1.0f/power_of_2(1/MIN2(zoomx, zoomy)), NULL);
zoomx = width / w;
zoomy = height / h;
sima_zoom_set(sima, ar, 1.0f / power_of_2(1 / MIN2(zoomx, zoomy)), NULL);
}
else
sima_zoom_set(sima, ar, 1.0f, NULL);
sima->xof= sima->yof= 0.0f;
sima->xof = sima->yof = 0.0f;
ED_region_tag_redraw(CTX_wm_region(C));
@@ -610,32 +610,32 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
int width, height;
/* retrieve state */
sima= CTX_wm_space_image(C);
ar= CTX_wm_region(C);
scene= CTX_data_scene(C);
obedit= CTX_data_edit_object(C);
sima = CTX_wm_space_image(C);
ar = CTX_wm_region(C);
scene = CTX_data_scene(C);
obedit = CTX_data_edit_object(C);
ima= ED_space_image(sima);
ima = ED_space_image(sima);
ED_space_image_size(sima, &width, &height);
ED_image_aspect(ima, &aspx, &aspy);
width= width*aspx;
height= height*aspy;
width = width * aspx;
height = height * aspy;
/* get bounds */
if (!ED_uvedit_minmax(scene, ima, obedit, min, max))
return OPERATOR_CANCELLED;
/* adjust offset and zoom */
sima->xof= (int)(((min[0] + max[0])*0.5f - 0.5f)*width);
sima->yof= (int)(((min[1] + max[1])*0.5f - 0.5f)*height);
sima->xof = (int)(((min[0] + max[0]) * 0.5f - 0.5f) * width);
sima->yof = (int)(((min[1] + max[1]) * 0.5f - 0.5f) * height);
d[0]= max[0] - min[0];
d[1]= max[1] - min[1];
size= 0.5f*MAX2(d[0], d[1])*MAX2(width, height)/256.0f;
d[0] = max[0] - min[0];
d[1] = max[1] - min[1];
size = 0.5f * MAX2(d[0], d[1]) * MAX2(width, height) / 256.0f;
if (size<=0.01f) size= 0.01f;
sima_zoom_set(sima, ar, 0.7f/size, NULL);
if (size <= 0.01f) size = 0.01f;
sima_zoom_set(sima, ar, 0.7f / size, NULL);
ED_region_tag_redraw(CTX_wm_region(C));
@@ -662,8 +662,8 @@ void IMAGE_OT_view_selected(wmOperatorType *ot)
static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
RNA_float_get_array(op->ptr, "location", location);
@@ -677,7 +677,7 @@ static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
static int image_view_zoom_in_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
@@ -703,8 +703,8 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot)
static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
RNA_float_get_array(op->ptr, "location", location);
@@ -718,7 +718,7 @@ static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
static int image_view_zoom_out_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
ARegion *ar = CTX_wm_region(C);
float location[2];
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
@@ -746,14 +746,14 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot)
static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
sima_zoom_set(sima, ar, RNA_float_get(op->ptr, "ratio"), NULL);
/* ensure pixel exact locations for draw */
sima->xof= (int)sima->xof;
sima->yof= (int)sima->yof;
sima->xof = (int)sima->xof;
sima->yof = (int)sima->yof;
/* XXX notifier? */
#if 0
@@ -781,7 +781,7 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot)
/* properties */
RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX,
"Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
"Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
}
/**************** load/replace/save callbacks ******************/
@@ -797,34 +797,34 @@ static void image_open_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
uiIDContextProperty(C, &pprop->ptr, &pprop->prop);
}
static int image_open_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata= NULL;
op->customdata = NULL;
return OPERATOR_CANCELLED;
}
static int image_open_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C); /* XXX other space types can call */
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
ImageUser *iuser= NULL;
SpaceImage *sima = CTX_wm_space_image(C); /* XXX other space types can call */
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
ImageUser *iuser = NULL;
PropertyPointerRNA *pprop;
PointerRNA idptr;
Image *ima= NULL;
Image *ima = NULL;
char str[FILE_MAX];
RNA_string_get(op->ptr, "filepath", str);
/* default to frame 1 if there's no scene in context */
errno= 0;
errno = 0;
ima= BKE_add_image_file(str);
ima = BKE_add_image_file(str);
if (!ima) {
if (op->customdata) MEM_freeN(op->customdata);
@@ -836,7 +836,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
image_open_init(C, op);
/* hook into UI */
pprop= op->customdata;
pprop = op->customdata;
if (pprop->prop) {
/* when creating new ID blocks, use is already 1, but RNA
@@ -849,27 +849,27 @@ static int image_open_exec(bContext *C, wmOperator *op)
}
else if (sima) {
ED_space_image_set(sima, scene, obedit, ima);
iuser= &sima->iuser;
iuser = &sima->iuser;
}
else {
Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (tex && tex->type==TEX_IMAGE)
iuser= &tex->iuser;
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (tex && tex->type == TEX_IMAGE)
iuser = &tex->iuser;
}
/* initialize because of new image */
if (iuser) {
iuser->sfra= 1;
iuser->offset= 0;
iuser->fie_ima= 2;
iuser->sfra = 1;
iuser->offset = 0;
iuser->fie_ima = 2;
}
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(C);
BKE_image_signal(ima, iuser, IMA_SIGNAL_RELOAD);
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
MEM_freeN(op->customdata);
@@ -878,22 +878,22 @@ static int image_open_exec(bContext *C, wmOperator *op)
static int image_open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
SpaceImage *sima= CTX_wm_space_image(C); /* XXX other space types can call */
char *path=U.textudir;
Image *ima= NULL;
SpaceImage *sima = CTX_wm_space_image(C); /* XXX other space types can call */
char *path = U.textudir;
Image *ima = NULL;
if (sima) {
ima= sima->image;
ima = sima->image;
}
if (ima==NULL) {
Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (tex && tex->type==TEX_IMAGE)
ima= tex->ima;
if (ima == NULL) {
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (tex && tex->type == TEX_IMAGE)
ima = tex->ima;
}
if (ima)
path= ima->name;
path = ima->name;
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return image_open_exec(C, op);
@@ -919,17 +919,17 @@ void IMAGE_OT_open(wmOperatorType *ot)
ot->cancel = image_open_cancel;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************** replace image operator ********************/
static int image_replace_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
char str[FILE_MAX];
if (!sima->image)
@@ -941,22 +941,22 @@ static int image_replace_exec(bContext *C, wmOperator *op)
BLI_strncpy(sima->image->name, str, sizeof(sima->image->name));
if (BLI_testextensie_array(str, imb_ext_movie))
sima->image->source= IMA_SRC_MOVIE;
sima->image->source = IMA_SRC_MOVIE;
else
sima->image->source= IMA_SRC_FILE;
sima->image->source = IMA_SRC_FILE;
/* XXX unpackImage frees image buffers */
ED_preview_kill_jobs(C);
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD);
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, sima->image);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
return OPERATOR_FINISHED;
}
static int image_replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
if (!sima->image)
return OPERATOR_CANCELLED;
@@ -965,7 +965,7 @@ static int image_replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
return image_replace_exec(C, op);
if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
RNA_boolean_set(op->ptr, "relative_path", (strncmp(sima->image->name, "//", 2))==0);
RNA_boolean_set(op->ptr, "relative_path", (strncmp(sima->image->name, "//", 2)) == 0);
image_filesel(C, op, sima->image->name);
@@ -984,10 +984,10 @@ void IMAGE_OT_replace(wmOperatorType *ot)
ot->poll = space_image_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************** save image as operator ********************/
@@ -1002,16 +1002,16 @@ typedef struct {
static void save_image_options_defaults(SaveImageOptions *simopts)
{
memset(&simopts->im_format, 0, sizeof(simopts->im_format));
simopts->im_format.planes= R_IMF_PLANES_RGB;
simopts->im_format.imtype= R_IMF_IMTYPE_PNG;
simopts->im_format.quality= 90;
simopts->im_format.compress= 90;
simopts->filepath[0]= '\0';
simopts->im_format.planes = R_IMF_PLANES_RGB;
simopts->im_format.imtype = R_IMF_IMTYPE_PNG;
simopts->im_format.quality = 90;
simopts->im_format.compress = 90;
simopts->filepath[0] = '\0';
}
static char imtype_best_depth(ImBuf *ibuf, const char imtype)
{
const char depth_ok= BKE_imtype_valid_depths(imtype);
const char depth_ok = BKE_imtype_valid_depths(imtype);
if (ibuf->rect_float) {
if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32;
@@ -1033,27 +1033,27 @@ static char imtype_best_depth(ImBuf *ibuf, const char imtype)
static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path)
{
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
Image *ima= sima->image;
short is_depth_set= FALSE;
Image *ima = sima->image;
short is_depth_set = FALSE;
simopts->im_format.planes= ibuf->planes;
simopts->im_format.planes = ibuf->planes;
if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) {
/* imtype */
simopts->im_format= scene->r.im_format;
is_depth_set= TRUE;
simopts->im_format = scene->r.im_format;
is_depth_set = TRUE;
}
else if (ima->source == IMA_SRC_GENERATED) {
simopts->im_format.imtype= R_IMF_IMTYPE_PNG;
simopts->im_format.imtype = R_IMF_IMTYPE_PNG;
}
else {
simopts->im_format.imtype= BKE_ftype_to_imtype(ibuf->ftype);
simopts->im_format.imtype = BKE_ftype_to_imtype(ibuf->ftype);
}
//simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */
simopts->im_format.quality= ibuf->ftype & 0xff;
simopts->im_format.quality = ibuf->ftype & 0xff;
BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath));
@@ -1061,21 +1061,21 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
/* unlikely but just in case */
if (ELEM3(simopts->im_format.planes, R_IMF_PLANES_BW, R_IMF_PLANES_RGB, R_IMF_PLANES_RGBA) == 0) {
simopts->im_format.planes= R_IMF_PLANES_RGBA;
simopts->im_format.planes = R_IMF_PLANES_RGBA;
}
/* depth, account for float buffer and format support */
if (is_depth_set == FALSE) {
simopts->im_format.depth= imtype_best_depth(ibuf, simopts->im_format.imtype);
simopts->im_format.depth = imtype_best_depth(ibuf, simopts->im_format.imtype);
}
/* some formats don't use quality so fallback to scenes quality */
if (simopts->im_format.quality == 0) {
simopts->im_format.quality= scene->r.im_format.quality;
simopts->im_format.quality = scene->r.im_format.quality;
}
/* check for empty path */
if (guess_path && simopts->filepath[0]==0) {
if (guess_path && simopts->filepath[0] == 0) {
if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) {
BLI_strncpy(simopts->filepath, "//untitled", FILE_MAX);
}
@@ -1094,7 +1094,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op)
{
if (op->customdata) {
simopts->im_format= *(ImageFormatData *)op->customdata;
simopts->im_format = *(ImageFormatData *)op->customdata;
}
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -1106,7 +1106,7 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op
static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
{
if (op->customdata) {
*(ImageFormatData *)op->customdata= simopts->im_format;
*(ImageFormatData *)op->customdata = simopts->im_format;
}
RNA_string_set(op->ptr, "filepath", simopts->filepath);
@@ -1116,15 +1116,15 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
/* ima->name and ibuf->name should end up the same */
static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
{
Image *ima= ED_space_image(sima);
Image *ima = ED_space_image(sima);
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
const char *relbase= ID_BLEND_PATH(CTX_data_main(C), &ima->id);
const short relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
const short save_copy= (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
short ok= FALSE;
const char *relbase = ID_BLEND_PATH(CTX_data_main(C), &ima->id);
const short relative = (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
const short save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
short ok = FALSE;
/* old global to ensure a 2nd save goes to same dir */
BLI_strncpy(G.ima, simopts->filepath, sizeof(G.ima));
@@ -1133,27 +1133,27 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
if (ima->type == IMA_TYPE_R_RESULT) {
/* enforce user setting for RGB or RGBA, but skip BW */
if (simopts->im_format.planes==R_IMF_PLANES_RGBA) {
ibuf->planes= R_IMF_PLANES_RGBA;
if (simopts->im_format.planes == R_IMF_PLANES_RGBA) {
ibuf->planes = R_IMF_PLANES_RGBA;
}
else if (simopts->im_format.planes==R_IMF_PLANES_RGB) {
ibuf->planes= R_IMF_PLANES_RGB;
else if (simopts->im_format.planes == R_IMF_PLANES_RGB) {
ibuf->planes = R_IMF_PLANES_RGB;
}
}
else {
/* TODO, better solution, if a 24bit image is painted onto it may contain alpha */
if (ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */
/* checks each pixel, not ideal */
ibuf->planes= BKE_alphatest_ibuf(ibuf) ? 32 : 24;
ibuf->planes = BKE_alphatest_ibuf(ibuf) ? 32 : 24;
}
}
if (simopts->im_format.imtype==R_IMF_IMTYPE_MULTILAYER) {
Scene *scene= CTX_data_scene(C);
RenderResult *rr= BKE_image_acquire_renderresult(scene, ima);
if (simopts->im_format.imtype == R_IMF_IMTYPE_MULTILAYER) {
Scene *scene = CTX_data_scene(C);
RenderResult *rr = BKE_image_acquire_renderresult(scene, ima);
if (rr) {
RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.quality);
ok= TRUE;
ok = TRUE;
}
else {
BKE_report(op->reports, RPT_ERROR, "Did not write, no Multilayer Image");
@@ -1162,11 +1162,11 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
}
else {
if (BKE_write_ibuf_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
ok= TRUE;
ok = TRUE;
}
}
if (ok) {
if (ok) {
if (!save_copy) {
if (do_newpath) {
BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name));
@@ -1176,8 +1176,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
ibuf->userflags &= ~IB_BITMAPDIRTY;
/* change type? */
if (ima->type==IMA_TYPE_R_RESULT) {
ima->type= IMA_TYPE_IMAGE;
if (ima->type == IMA_TYPE_R_RESULT) {
ima->type = IMA_TYPE_IMAGE;
/* workaround to ensure the render result buffer is no longer used
* by this image, otherwise can crash when a new render result is
@@ -1191,9 +1191,9 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat))
IMB_freezbuffloatImBuf(ibuf);
}
if ( ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
ima->source= IMA_SRC_FILE;
ima->type= IMA_TYPE_IMAGE;
if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) {
ima->source = IMA_SRC_FILE;
ima->type = IMA_TYPE_IMAGE;
}
/* only image path, never ibuf */
@@ -1207,7 +1207,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
}
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, sima->image);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
WM_cursor_wait(0);
}
@@ -1219,13 +1219,13 @@ static void image_save_as_free(wmOperator *op)
{
if (op->customdata) {
MEM_freeN(op->customdata);
op->customdata= NULL;
op->customdata = NULL;
}
}
static int image_save_as_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
SaveImageOptions simopts;
save_image_options_defaults(&simopts);
@@ -1245,7 +1245,7 @@ static int image_save_as_exec(bContext *C, wmOperator *op)
static int image_save_as_check(bContext *UNUSED(C), wmOperator *op)
{
ImageFormatData *imf= op->customdata;
ImageFormatData *imf = op->customdata;
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
if (BKE_add_image_extension(filepath, imf->imtype)) {
@@ -1257,9 +1257,9 @@ static int image_save_as_check(bContext *UNUSED(C), wmOperator *op)
static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = ED_space_image(sima);
Scene *scene= CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
SaveImageOptions simopts;
if (RNA_struct_property_is_set(op->ptr, "filepath"))
@@ -1274,7 +1274,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
RNA_boolean_set(op->ptr, "copy", TRUE);
}
op->customdata= MEM_mallocN(sizeof(simopts.im_format), __func__);
op->customdata = MEM_mallocN(sizeof(simopts.im_format), __func__);
memcpy(op->customdata, &simopts.im_format, sizeof(simopts.im_format));
image_filesel(C, op, simopts.filepath);
@@ -1291,7 +1291,7 @@ static int image_save_as_cancel(bContext *UNUSED(C), wmOperator *op)
static int image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)
{
const char *prop_id= RNA_property_identifier(prop);
const char *prop_id = RNA_property_identifier(prop);
return !(strcmp(prop_id, "filepath") == 0 ||
strcmp(prop_id, "directory") == 0 ||
@@ -1303,8 +1303,8 @@ static int image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop)
static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
{
uiLayout *layout= op->layout;
ImageFormatData *imf= op->customdata;
uiLayout *layout = op->layout;
ImageFormatData *imf = op->customdata;
PointerRNA ptr;
/* image template */
@@ -1333,20 +1333,20 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
ot->poll = space_image_buffer_exists_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender");
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
}
/******************** save image operator ********************/
static int image_save_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
Scene *scene= CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
SaveImageOptions simopts;
if (save_image_options_init(&simopts, sima, scene, FALSE) == 0)
@@ -1375,44 +1375,44 @@ void IMAGE_OT_save(wmOperatorType *ot)
ot->poll = space_image_file_exists_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/******************* save sequence operator ********************/
static int image_save_sequence_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
SpaceImage *sima= CTX_wm_space_image(C);
Main *bmain = CTX_data_main(C);
SpaceImage *sima = CTX_wm_space_image(C);
ImBuf *ibuf;
int tot= 0;
int tot = 0;
char di[FILE_MAX], fi[FILE_MAX];
if (sima->image==NULL)
if (sima->image == NULL)
return OPERATOR_CANCELLED;
if (sima->image->source!=IMA_SRC_SEQUENCE) {
if (sima->image->source != IMA_SRC_SEQUENCE) {
BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences");
return OPERATOR_CANCELLED;
}
if (sima->image->type==IMA_TYPE_MULTILAYER) {
if (sima->image->type == IMA_TYPE_MULTILAYER) {
BKE_report(op->reports, RPT_ERROR, "Can't save multilayer sequences");
return OPERATOR_CANCELLED;
}
/* get total */
for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next)
for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next)
if (ibuf->userflags & IB_BITMAPDIRTY)
tot++;
if (tot==0) {
if (tot == 0) {
BKE_report(op->reports, RPT_WARNING, "No images have been changed");
return OPERATOR_CANCELLED;
}
/* get a filename for menu */
for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next)
for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next)
if (ibuf->userflags & IB_BITMAPDIRTY)
break;
@@ -1421,7 +1421,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_INFO, "%d Image(s) will be saved in %s", tot, di);
for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) {
for (ibuf = sima->image->ibufs.first; ibuf; ibuf = ibuf->next) {
if (ibuf->userflags & IB_BITMAPDIRTY) {
char name[FILE_MAX];
BLI_strncpy(name, ibuf->name, sizeof(name));
@@ -1452,15 +1452,15 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot)
ot->poll = space_image_buffer_exists_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/******************** reload image operator ********************/
static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
{
Image *ima= CTX_data_edit_image(C);
SpaceImage *sima= CTX_wm_space_image(C);
Image *ima = CTX_data_edit_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
if (!ima)
return OPERATOR_CANCELLED;
@@ -1469,9 +1469,9 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op))
ED_preview_kill_jobs(C);
// XXX other users?
BKE_image_signal(ima, (sima)? &sima->iuser: NULL, IMA_SIGNAL_RELOAD);
BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD);
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
return OPERATOR_FINISHED;
}
@@ -1499,28 +1499,28 @@ static int image_new_exec(bContext *C, wmOperator *op)
Image *ima;
PointerRNA ptr, idptr;
PropertyRNA *prop;
char name[MAX_ID_NAME-2];
char name[MAX_ID_NAME - 2];
float color[4];
int width, height, floatbuf, uvtestgrid, alpha;
/* retrieve state */
sima= CTX_wm_space_image(C);
scene= CTX_data_scene(C);
obedit= CTX_data_edit_object(C);
sima = CTX_wm_space_image(C);
scene = CTX_data_scene(C);
obedit = CTX_data_edit_object(C);
RNA_string_get(op->ptr, "name", name);
width= RNA_int_get(op->ptr, "width");
height= RNA_int_get(op->ptr, "height");
floatbuf= RNA_boolean_get(op->ptr, "float");
uvtestgrid= RNA_boolean_get(op->ptr, "uv_test_grid");
width = RNA_int_get(op->ptr, "width");
height = RNA_int_get(op->ptr, "height");
floatbuf = RNA_boolean_get(op->ptr, "float");
uvtestgrid = RNA_boolean_get(op->ptr, "uv_test_grid");
RNA_float_get_array(op->ptr, "color", color);
alpha= RNA_boolean_get(op->ptr, "alpha");
alpha = RNA_boolean_get(op->ptr, "alpha");
if (!floatbuf && scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
linearrgb_to_srgb_v3_v3(color, color);
if (!alpha)
color[3]= 1.0f;
color[3] = 1.0f;
ima = BKE_add_image_size(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color);
@@ -1543,7 +1543,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
ED_space_image_set(sima, scene, obedit, ima);
// XXX other users?
BKE_image_signal(ima, (sima)? &sima->iuser: NULL, IMA_SIGNAL_USER_NEW_IMAGE);
BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
return OPERATOR_FINISHED;
}
@@ -1558,7 +1558,7 @@ static int image_new_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
void IMAGE_OT_new(wmOperatorType *ot)
{
PropertyRNA *prop;
static float default_color[4]= {0.0f, 0.0f, 0.0f, 1.0f};
static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
/* identifiers */
ot->name = "New Image";
@@ -1573,10 +1573,10 @@ void IMAGE_OT_new(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_string(ot->srna, "name", "untitled", MAX_ID_NAME-2, "Name", "Image datablock name");
RNA_def_string(ot->srna, "name", "untitled", MAX_ID_NAME - 2, "Name", "Image datablock name");
RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384);
RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384);
prop= RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
prop = RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, default_color);
RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
RNA_def_boolean(ot->srna, "uv_test_grid", 0, "UV Test Grid", "Fill the image with a grid for UV map testing");
@@ -1587,39 +1587,39 @@ void IMAGE_OT_new(wmOperatorType *ot)
static int image_invert_poll(bContext *C)
{
Image *ima= CTX_data_edit_image(C);
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
Image *ima = CTX_data_edit_image(C);
ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL);
if ( ibuf != NULL )
if (ibuf != NULL)
return 1;
return 0;
}
static int image_invert_exec(bContext *C, wmOperator *op)
{
Image *ima= CTX_data_edit_image(C);
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
Image *ima = CTX_data_edit_image(C);
ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL);
// flags indicate if this channel should be inverted
const short r= RNA_boolean_get(op->ptr, "invert_r");
const short g= RNA_boolean_get(op->ptr, "invert_g");
const short b= RNA_boolean_get(op->ptr, "invert_b");
const short a= RNA_boolean_get(op->ptr, "invert_a");
const short r = RNA_boolean_get(op->ptr, "invert_r");
const short g = RNA_boolean_get(op->ptr, "invert_g");
const short b = RNA_boolean_get(op->ptr, "invert_b");
const short a = RNA_boolean_get(op->ptr, "invert_a");
int i;
if ( ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup
if (ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup
return OPERATOR_CANCELLED;
/* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */
if (ibuf->rect_float) {
float *fp = (float *) ibuf->rect_float;
for ( i = ibuf->x * ibuf->y; i > 0; i--, fp+=4 ) {
if ( r ) fp[0] = 1.0f - fp[0];
if ( g ) fp[1] = 1.0f - fp[1];
if ( b ) fp[2] = 1.0f - fp[2];
if ( a ) fp[3] = 1.0f - fp[3];
for (i = ibuf->x * ibuf->y; i > 0; i--, fp += 4) {
if (r) fp[0] = 1.0f - fp[0];
if (g) fp[1] = 1.0f - fp[1];
if (b) fp[2] = 1.0f - fp[2];
if (a) fp[3] = 1.0f - fp[3];
}
if (ibuf->rect) {
@@ -1629,11 +1629,11 @@ static int image_invert_exec(bContext *C, wmOperator *op)
else if (ibuf->rect) {
char *cp = (char *) ibuf->rect;
for ( i = ibuf->x * ibuf->y; i > 0; i--, cp+=4 ) {
if ( r ) cp[0] = 255 - cp[0];
if ( g ) cp[1] = 255 - cp[1];
if ( b ) cp[2] = 255 - cp[2];
if ( a ) cp[3] = 255 - cp[3];
for (i = ibuf->x * ibuf->y; i > 0; i--, cp += 4) {
if (r) cp[0] = 255 - cp[0];
if (g) cp[1] = 255 - cp[1];
if (b) cp[2] = 255 - cp[2];
if (a) cp[3] = 255 - cp[3];
}
}
else {
@@ -1644,7 +1644,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID;
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
return OPERATOR_FINISHED;
}
@@ -1665,22 +1665,22 @@ void IMAGE_OT_invert(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "invert_a", 0, "Alpha", "Invert Alpha Channel");
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************* pack operator *********************/
static int image_pack_test(bContext *C, wmOperator *op)
{
Image *ima= CTX_data_edit_image(C);
int as_png= RNA_boolean_get(op->ptr, "as_png");
Image *ima = CTX_data_edit_image(C);
int as_png = RNA_boolean_get(op->ptr, "as_png");
if (!ima)
return 0;
if (!as_png && ima->packedfile)
return 0;
if (ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) {
if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported");
return 0;
}
@@ -1690,10 +1690,10 @@ static int image_pack_test(bContext *C, wmOperator *op)
static int image_pack_exec(bContext *C, wmOperator *op)
{
struct Main *bmain= CTX_data_main(C);
Image *ima= CTX_data_edit_image(C);
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
int as_png= RNA_boolean_get(op->ptr, "as_png");
struct Main *bmain = CTX_data_main(C);
Image *ima = CTX_data_edit_image(C);
ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL);
int as_png = RNA_boolean_get(op->ptr, "as_png");
if (!image_pack_test(C, op))
return OPERATOR_CANCELLED;
@@ -1706,27 +1706,27 @@ static int image_pack_exec(bContext *C, wmOperator *op)
if (as_png)
BKE_image_memorypack(ima);
else
ima->packedfile= newPackedFile(op->reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
ima->packedfile = newPackedFile(op->reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
return OPERATOR_FINISHED;
}
static int image_pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
Image *ima= CTX_data_edit_image(C);
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
Image *ima = CTX_data_edit_image(C);
ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL);
uiPopupMenu *pup;
uiLayout *layout;
int as_png= RNA_boolean_get(op->ptr, "as_png");
int as_png = RNA_boolean_get(op->ptr, "as_png");
if (!image_pack_test(C, op))
return OPERATOR_CANCELLED;
if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) {
pup= uiPupMenuBegin(C, "OK", ICON_QUESTION);
layout= uiPupMenuLayout(pup);
pup = uiPupMenuBegin(C, "OK", ICON_QUESTION);
layout = uiPupMenuLayout(pup);
uiItemBooleanO(layout, "Can't pack edited image from disk. Pack as internal PNG?", ICON_NONE, op->idname, "as_png", 1);
uiPupMenuEnd(C, pup);
@@ -1748,7 +1748,7 @@ void IMAGE_OT_pack(wmOperatorType *ot)
ot->invoke = image_pack_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "as_png", 0, "Pack As PNG", "Pack image as lossless PNG");
@@ -1758,12 +1758,12 @@ void IMAGE_OT_pack(wmOperatorType *ot)
static int image_unpack_exec(bContext *C, wmOperator *op)
{
Image *ima= CTX_data_edit_image(C);
int method= RNA_enum_get(op->ptr, "method");
Image *ima = CTX_data_edit_image(C);
int method = RNA_enum_get(op->ptr, "method");
/* find the suppplied image by name */
if (RNA_struct_property_is_set(op->ptr, "id")) {
char imaname[MAX_ID_NAME-2];
char imaname[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "id", imaname);
ima = BLI_findstring(&CTX_data_main(C)->image, imaname, offsetof(ID, name) + 2);
if (!ima) ima = CTX_data_edit_image(C);
@@ -1772,7 +1772,7 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
if (!ima || !ima->packedfile)
return OPERATOR_CANCELLED;
if (ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) {
if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
return OPERATOR_CANCELLED;
}
@@ -1785,14 +1785,14 @@ static int image_unpack_exec(bContext *C, wmOperator *op)
unpackImage(op->reports, ima, method);
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
return OPERATOR_FINISHED;
}
static int image_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
Image *ima= CTX_data_edit_image(C);
Image *ima = CTX_data_edit_image(C);
if (RNA_struct_property_is_set(op->ptr, "id"))
return image_unpack_exec(C, op);
@@ -1800,7 +1800,7 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
if (!ima || !ima->packedfile)
return OPERATOR_CANCELLED;
if (ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) {
if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) {
BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
return OPERATOR_CANCELLED;
}
@@ -1808,7 +1808,7 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even
if (G.fileflags & G_AUTOPACK)
BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save");
unpack_menu(C, "IMAGE_OT_unpack", ima->id.name+2, ima->name, "textures", ima->packedfile);
unpack_menu(C, "IMAGE_OT_unpack", ima->id.name + 2, ima->name, "textures", ima->packedfile);
return OPERATOR_FINISHED;
}
@@ -1825,11 +1825,11 @@ void IMAGE_OT_unpack(wmOperatorType *ot)
ot->invoke = image_unpack_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "method", unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack");
RNA_def_string(ot->srna, "id", "", MAX_ID_NAME-2, "Image Name", "Image datablock name to unpack"); /* XXX, weark!, will fail with library, name collisions */
RNA_def_string(ot->srna, "id", "", MAX_ID_NAME - 2, "Image Name", "Image datablock name to unpack"); /* XXX, weark!, will fail with library, name collisions */
}
/******************** sample image operator ********************/
@@ -1855,7 +1855,7 @@ typedef struct ImageSampleInfo {
static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
{
ImageSampleInfo *info= arg_info;
ImageSampleInfo *info = arg_info;
if (info->draw) {
/* no color management needed for images (color_manage=0) */
ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
@@ -1864,11 +1864,11 @@ static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_
static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
ImageSampleInfo *info= op->customdata;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
ImageSampleInfo *info = op->customdata;
float fx, fy;
if (ibuf == NULL) {
@@ -1878,62 +1878,62 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy);
if (fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) {
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
float *fp;
unsigned char *cp;
int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y);
int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
CLAMP(x, 0, ibuf->x-1);
CLAMP(y, 0, ibuf->y-1);
CLAMP(x, 0, ibuf->x - 1);
CLAMP(y, 0, ibuf->y - 1);
info->x= x;
info->y= y;
info->draw= 1;
info->channels= ibuf->channels;
info->x = x;
info->y = y;
info->draw = 1;
info->channels = ibuf->channels;
info->colp= NULL;
info->colfp= NULL;
info->zp= NULL;
info->zfp= NULL;
info->colp = NULL;
info->colfp = NULL;
info->zp = NULL;
info->zfp = NULL;
if (ibuf->rect) {
cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x);
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
info->col[0]= cp[0];
info->col[1]= cp[1];
info->col[2]= cp[2];
info->col[3]= cp[3];
info->colp= info->col;
info->col[0] = cp[0];
info->col[1] = cp[1];
info->col[2] = cp[2];
info->col[3] = cp[3];
info->colp = info->col;
info->colf[0]= (float)cp[0]/255.0f;
info->colf[1]= (float)cp[1]/255.0f;
info->colf[2]= (float)cp[2]/255.0f;
info->colf[3]= (float)cp[3]/255.0f;
info->colfp= info->colf;
info->colf[0] = (float)cp[0] / 255.0f;
info->colf[1] = (float)cp[1] / 255.0f;
info->colf[2] = (float)cp[2] / 255.0f;
info->colf[3] = (float)cp[3] / 255.0f;
info->colfp = info->colf;
}
if (ibuf->rect_float) {
fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x));
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
info->colf[0]= fp[0];
info->colf[1]= fp[1];
info->colf[2]= fp[2];
info->colf[3]= fp[3];
info->colfp= info->colf;
info->colf[0] = fp[0];
info->colf[1] = fp[1];
info->colf[2] = fp[2];
info->colf[3] = fp[3];
info->colfp = info->colf;
}
if (ibuf->zbuf) {
info->z= ibuf->zbuf[y*ibuf->x + x];
info->zp= &info->z;
info->z = ibuf->zbuf[y * ibuf->x + x];
info->zp = &info->z;
}
if (ibuf->zbuf_float) {
info->zf= ibuf->zbuf_float[y*ibuf->x + x];
info->zfp= &info->zf;
info->zf = ibuf->zbuf_float[y * ibuf->x + x];
info->zfp = &info->zf;
}
if (sima->cumap && ibuf->channels==4) {
if (sima->cumap && ibuf->channels == 4) {
/* we reuse this callback for set curves point operators */
if (RNA_struct_find_property(op->ptr, "point")) {
int point= RNA_enum_get(op->ptr, "point");
int point = RNA_enum_get(op->ptr, "point");
if (point == 1) {
curvemapping_set_black_white(sima->cumap, NULL, info->colfp);
@@ -1951,22 +1951,22 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
// XXX node curve integration ..
#if 0
{
ScrArea *sa, *cur= curarea;
ScrArea *sa, *cur = curarea;
node_curvemap_sample(fp); /* sends global to node editor */
for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
if (sa->spacetype==SPACE_NODE) {
node_curvemap_sample(fp); /* sends global to node editor */
for (sa = G.curscreen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_NODE) {
areawinset(sa->win);
scrarea_do_windraw(sa);
}
}
node_curvemap_sample(NULL); /* clears global in node editor */
curarea= cur;
node_curvemap_sample(NULL); /* clears global in node editor */
curarea = cur;
}
#endif
}
else
info->draw= 0;
info->draw = 0;
ED_space_image_release_buffer(sima, lock);
ED_area_tag_redraw(CTX_wm_area(C));
@@ -1974,7 +1974,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
static void image_sample_exit(bContext *C, wmOperator *op)
{
ImageSampleInfo *info= op->customdata;
ImageSampleInfo *info = op->customdata;
ED_region_draw_cb_exit(info->art, info->draw_handle);
ED_area_tag_redraw(CTX_wm_area(C));
@@ -1983,17 +1983,17 @@ static void image_sample_exit(bContext *C, wmOperator *op)
static int image_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
ImageSampleInfo *info;
if (!ED_space_image_has_buffer(sima))
return OPERATOR_CANCELLED;
info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
info->art= ar->type;
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
info->art = ar->type;
info->draw_handle = ED_region_draw_cb_activate(ar->type, image_sample_draw, info, REGION_DRAW_POST_PIXEL);
op->customdata= info;
op->customdata = info;
image_sample_apply(C, op, event);
@@ -2004,7 +2004,7 @@ static int image_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int image_sample_modal(bContext *C, wmOperator *op, wmEvent *event)
{
switch(event->type) {
switch (event->type) {
case LEFTMOUSE:
case RIGHTMOUSE: // XXX hardcoded
image_sample_exit(C, op);
@@ -2042,18 +2042,18 @@ void IMAGE_OT_sample(wmOperatorType *ot)
/******************** sample line operator ********************/
static int image_sample_line_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
ARegion *ar= CTX_wm_region(C);
Scene *scene= CTX_data_scene(C);
int x_start= RNA_int_get(op->ptr, "xstart");
int y_start= RNA_int_get(op->ptr, "ystart");
int x_end= RNA_int_get(op->ptr, "xend");
int y_end= RNA_int_get(op->ptr, "yend");
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
int x_start = RNA_int_get(op->ptr, "xstart");
int y_start = RNA_int_get(op->ptr, "ystart");
int x_end = RNA_int_get(op->ptr, "xend");
int y_end = RNA_int_get(op->ptr, "yend");
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
Histogram *hist= &sima->sample_line_hist;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
Histogram *hist = &sima->sample_line_hist;
float x1f, y1f, x2f, y2f;
int x1, y1, x2, y2;
@@ -2074,26 +2074,26 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view(&ar->v2d, x_start, y_start, &x1f, &y1f);
UI_view2d_region_to_view(&ar->v2d, x_end, y_end, &x2f, &y2f);
x1= 0.5f+ x1f*ibuf->x;
x2= 0.5f+ x2f*ibuf->x;
y1= 0.5f+ y1f*ibuf->y;
y2= 0.5f+ y2f*ibuf->y;
x1 = 0.5f + x1f * ibuf->x;
x2 = 0.5f + x2f * ibuf->x;
y1 = 0.5f + y1f * ibuf->y;
y2 = 0.5f + y2f * ibuf->y;
hist->channels = 3;
hist->x_resolution = 256;
hist->xmax = 1.0f;
hist->ymax = 1.0f;
for (i=0; i<256; i++) {
x= (int)(0.5f + x1 + (float)i*(x2-x1)/255.0f);
y= (int)(0.5f + y1 + (float)i*(y2-y1)/255.0f);
for (i = 0; i < 256; i++) {
x = (int)(0.5f + x1 + (float)i * (x2 - x1) / 255.0f);
y = (int)(0.5f + y1 + (float)i * (y2 - y1) / 255.0f);
if (x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) {
hist->data_luma[i] = hist->data_r[i] = hist->data_g[i]= hist->data_b[i] = 0.0f;
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
hist->data_luma[i] = hist->data_r[i] = hist->data_g[i] = hist->data_b[i] = 0.0f;
}
else {
if (ibuf->rect_float) {
fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x));
fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
linearrgb_to_srgb_v3_v3(rgb, fp);
@@ -2106,11 +2106,11 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
hist->data_luma[i] = rgb_to_luma(rgb);
}
else if (ibuf->rect) {
cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x);
hist->data_r[i] = (float)cp[0]/255.0f;
hist->data_g[i] = (float)cp[1]/255.0f;
hist->data_b[i] = (float)cp[2]/255.0f;
hist->data_luma[i] = (float)rgb_to_luma_byte(cp)/255.0f;
cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
hist->data_r[i] = (float)cp[0] / 255.0f;
hist->data_g[i] = (float)cp[1] / 255.0f;
hist->data_b[i] = (float)cp[2] / 255.0f;
hist->data_luma[i] = (float)rgb_to_luma_byte(cp) / 255.0f;
}
}
}
@@ -2124,7 +2124,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
static int image_sample_line_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
if (!ED_space_image_has_buffer(sima))
return OPERATOR_CANCELLED;
@@ -2155,17 +2155,18 @@ void IMAGE_OT_sample_line(wmOperatorType *ot)
void IMAGE_OT_curves_point_set(wmOperatorType *ot)
{
static EnumPropertyItem point_items[]= {
static EnumPropertyItem point_items[] = {
{0, "BLACK_POINT", 0, "Black Point", ""},
{1, "WHITE_POINT", 0, "White Point", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
/* identifiers */
ot->name = "Set Curves Point";
ot->idname = "IMAGE_OT_curves_point_set";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* api callbacks */
ot->invoke = image_sample_invoke;
@@ -2187,9 +2188,9 @@ typedef struct RecordCompositeData {
static int image_record_composite_apply(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
RecordCompositeData *rcd= op->customdata;
Scene *scene= CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
RecordCompositeData *rcd = op->customdata;
Scene *scene = CTX_data_scene(C);
ImBuf *ibuf;
WM_timecursor(CTX_wm_window(C), scene->r.cfra);
@@ -2199,11 +2200,11 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
BKE_image_all_free_anim_ibufs(scene->r.cfra);
ntreeCompositTagAnimated(scene->nodetree);
ntreeCompositExecTree(scene->nodetree, &scene->r, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */
ntreeCompositExecTree(scene->nodetree, &scene->r, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */
ED_area_tag_redraw(CTX_wm_area(C));
ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
ibuf = BKE_image_get_ibuf(sima->image, &sima->iuser);
/* save memory in flipbooks */
if (ibuf)
imb_freerectfloatImBuf(ibuf);
@@ -2215,8 +2216,8 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
static int image_record_composite_init(bContext *C, wmOperator *op)
{
SpaceImage *sima= CTX_wm_space_image(C);
Scene *scene= CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
RecordCompositeData *rcd;
if (sima->iuser.frames < 2)
@@ -2224,30 +2225,30 @@ static int image_record_composite_init(bContext *C, wmOperator *op)
if (scene->nodetree == NULL)
return 0;
op->customdata= rcd= MEM_callocN(sizeof(RecordCompositeData), "ImageRecordCompositeData");
op->customdata = rcd = MEM_callocN(sizeof(RecordCompositeData), "ImageRecordCompositeData");
rcd->old_cfra= scene->r.cfra;
rcd->sfra= sima->iuser.sfra;
rcd->efra= sima->iuser.sfra + sima->iuser.frames-1;
scene->r.cfra= rcd->sfra;
rcd->old_cfra = scene->r.cfra;
rcd->sfra = sima->iuser.sfra;
rcd->efra = sima->iuser.sfra + sima->iuser.frames - 1;
scene->r.cfra = rcd->sfra;
return 1;
}
static void image_record_composite_exit(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
SpaceImage *sima= CTX_wm_space_image(C);
RecordCompositeData *rcd= op->customdata;
Scene *scene = CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
RecordCompositeData *rcd = op->customdata;
scene->r.cfra= rcd->old_cfra;
scene->r.cfra = rcd->old_cfra;
WM_cursor_restore(CTX_wm_window(C));
if (rcd->timer)
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rcd->timer);
WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, sima->image);
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image);
// XXX play_anim(0);
// XXX allqueue(REDRAWNODE, 1);
@@ -2275,8 +2276,8 @@ static int image_record_composite_invoke(bContext *C, wmOperator *op, wmEvent *U
if (!image_record_composite_init(C, op))
return OPERATOR_CANCELLED;
rcd= op->customdata;
rcd->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.0f);
rcd = op->customdata;
rcd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.0f);
WM_event_add_modal_handler(C, op);
if (!image_record_composite_apply(C, op))
@@ -2287,9 +2288,9 @@ static int image_record_composite_invoke(bContext *C, wmOperator *op, wmEvent *U
static int image_record_composite_modal(bContext *C, wmOperator *op, wmEvent *event)
{
RecordCompositeData *rcd= op->customdata;
RecordCompositeData *rcd = op->customdata;
switch(event->type) {
switch (event->type) {
case TIMER:
if (rcd->timer == event->customdata) {
if (!image_record_composite_apply(C, op)) {
@@ -2330,38 +2331,38 @@ void IMAGE_OT_record_composite(wmOperatorType *ot)
static int image_cycle_render_slot_poll(bContext *C)
{
Image *ima= CTX_data_edit_image(C);
Image *ima = CTX_data_edit_image(C);
return (ima && ima->type == IMA_TYPE_R_RESULT);
}
static int image_cycle_render_slot_exec(bContext *C, wmOperator *op)
{
Image *ima= CTX_data_edit_image(C);
int a, slot, cur= ima->render_slot;
const short use_reverse= RNA_boolean_get(op->ptr, "reverse");
Image *ima = CTX_data_edit_image(C);
int a, slot, cur = ima->render_slot;
const short use_reverse = RNA_boolean_get(op->ptr, "reverse");
for (a=1; a<IMA_MAX_RENDER_SLOT; a++) {
slot= (cur + (use_reverse ? -a:a))%IMA_MAX_RENDER_SLOT;
if (slot<0) slot+=IMA_MAX_RENDER_SLOT;
for (a = 1; a < IMA_MAX_RENDER_SLOT; a++) {
slot = (cur + (use_reverse ? -a : a)) % IMA_MAX_RENDER_SLOT;
if (slot < 0) slot += IMA_MAX_RENDER_SLOT;
if (ima->renders[slot] || slot == ima->last_render_slot) {
ima->render_slot= slot;
ima->render_slot = slot;
break;
}
else if ((slot - 1) == ima->last_render_slot && slot < IMA_MAX_RENDER_SLOT) {
ima->render_slot= slot;
ima->render_slot = slot;
break;
}
}
if (a == IMA_MAX_RENDER_SLOT)
ima->render_slot= ((cur == 1)? 0: 1);
ima->render_slot = ((cur == 1) ? 0 : 1);
WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL);
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
/* no undo push for browsing existing */
if (ima->renders[ima->render_slot] || ima->render_slot==ima->last_render_slot)
if (ima->renders[ima->render_slot] || ima->render_slot == ima->last_render_slot)
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -2378,7 +2379,7 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot)
ot->poll = image_cycle_render_slot_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "reverse", 0, "Cycle in Reverse", "");
}
@@ -2396,8 +2397,8 @@ void ED_image_update_frame(const Main *mainp, int cfra)
Tex *tex;
/* texture users */
for (tex= mainp->tex.first; tex; tex= tex->id.next) {
if (tex->type==TEX_IMAGE && tex->ima) {
for (tex = mainp->tex.first; tex; tex = tex->id.next) {
if (tex->type == TEX_IMAGE && tex->ima) {
if (ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
if (tex->iuser.flag & IMA_ANIM_ALWAYS)
BKE_image_user_calc_frame(&tex->iuser, cfra, 0);
@@ -2406,30 +2407,30 @@ void ED_image_update_frame(const Main *mainp, int cfra)
}
/* image window, compo node users */
for (wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */
for (win= wm->windows.first; win; win= win->next) {
for (wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
for (win = wm->windows.first; win; win = win->next) {
ScrArea *sa;
for (sa= win->screen->areabase.first; sa; sa= sa->next) {
if (sa->spacetype==SPACE_VIEW3D) {
View3D *v3d= sa->spacedata.first;
for (sa = win->screen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_VIEW3D) {
View3D *v3d = sa->spacedata.first;
BGpic *bgpic;
for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next)
for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next)
if (bgpic->iuser.flag & IMA_ANIM_ALWAYS)
BKE_image_user_calc_frame(&bgpic->iuser, cfra, 0);
}
else if (sa->spacetype==SPACE_IMAGE) {
SpaceImage *sima= sa->spacedata.first;
else if (sa->spacetype == SPACE_IMAGE) {
SpaceImage *sima = sa->spacedata.first;
if (sima->iuser.flag & IMA_ANIM_ALWAYS)
BKE_image_user_calc_frame(&sima->iuser, cfra, 0);
}
else if (sa->spacetype==SPACE_NODE) {
SpaceNode *snode= sa->spacedata.first;
if ((snode->treetype==NTREE_COMPOSIT) && (snode->nodetree)) {
else if (sa->spacetype == SPACE_NODE) {
SpaceNode *snode = sa->spacedata.first;
if ((snode->treetype == NTREE_COMPOSIT) && (snode->nodetree)) {
bNode *node;
for (node= snode->nodetree->nodes.first; node; node= node->next) {
if (node->id && node->type==CMP_NODE_IMAGE) {
Image *ima= (Image *)node->id;
ImageUser *iuser= node->storage;
for (node = snode->nodetree->nodes.first; node; node = node->next) {
if (node->id && node->type == CMP_NODE_IMAGE) {
Image *ima = (Image *)node->id;
ImageUser *iuser = node->storage;
if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE))
if (iuser->flag & IMA_ANIM_ALWAYS)
BKE_image_user_calc_frame(iuser, cfra, 0);

View File

@@ -90,21 +90,21 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i
/* change the space ima after because uvedit_face_visible uses the space ima
* to check if the face is displayed in UV-localview */
sima->image= ima;
sima->image = ima;
if (ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)
if (ima == NULL || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)
sima->flag &= ~SI_DRAWTOOL;
if (sima->image)
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
if (sima->image && sima->image->id.us==0)
sima->image->id.us= 1;
if (sima->image && sima->image->id.us == 0)
sima->image->id.us = 1;
if (obedit)
WM_main_add_notifier(NC_GEOM|ND_DATA, obedit->data);
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
WM_main_add_notifier(NC_SPACE|ND_SPACE_IMAGE, NULL);
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
}
ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
@@ -113,11 +113,11 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
if (sima && sima->image) {
#if 0
if (sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare())
if (sima->image->type == IMA_TYPE_R_RESULT && BIF_show_render_spare())
return BIF_render_spare_imbuf();
else
#endif
ibuf= BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r);
ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r);
if (ibuf && (ibuf->rect || ibuf->rect_float))
return ibuf;
@@ -138,8 +138,8 @@ int ED_space_image_has_buffer(SpaceImage *sima)
void *lock;
int has_buffer;
ibuf= ED_space_image_acquire_buffer(sima, &lock);
has_buffer= (ibuf != NULL);
ibuf = ED_space_image_acquire_buffer(sima, &lock);
has_buffer = (ibuf != NULL);
ED_space_image_release_buffer(sima, lock);
return has_buffer;
@@ -147,19 +147,19 @@ int ED_space_image_has_buffer(SpaceImage *sima)
void ED_image_size(Image *ima, int *width, int *height)
{
ImBuf *ibuf= NULL;
ImBuf *ibuf = NULL;
void *lock;
if (ima)
ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
*width= ibuf->x;
*height= ibuf->y;
*width = ibuf->x;
*height = ibuf->y;
}
else {
*width= 256;
*height= 256;
*width = 256;
*height = 256;
}
if (ima)
@@ -168,20 +168,20 @@ void ED_image_size(Image *ima, int *width, int *height)
void ED_space_image_size(SpaceImage *sima, int *width, int *height)
{
Scene *scene= sima->iuser.scene;
Scene *scene = sima->iuser.scene;
ImBuf *ibuf;
void *lock;
ibuf= ED_space_image_acquire_buffer(sima, &lock);
ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
*width= ibuf->x;
*height= ibuf->y;
*width = ibuf->x;
*height = ibuf->y;
}
else if (sima->image && sima->image->type==IMA_TYPE_R_RESULT && scene) {
else if (sima->image && sima->image->type == IMA_TYPE_R_RESULT && scene) {
/* not very important, just nice */
*width= (scene->r.xsch*scene->r.size)/100;
*height= (scene->r.ysch*scene->r.size)/100;
*width = (scene->r.xsch * scene->r.size) / 100;
*height = (scene->r.ysch * scene->r.size) / 100;
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
*width *= (scene->r.border.xmax - scene->r.border.xmin);
@@ -192,8 +192,8 @@ void ED_space_image_size(SpaceImage *sima, int *width, int *height)
/* I know a bit weak... but preview uses not actual image size */
// XXX else if (image_preview_active(sima, width, height));
else {
*width= 256;
*height= 256;
*width = 256;
*height = 256;
}
ED_space_image_release_buffer(sima, lock);
@@ -201,14 +201,14 @@ void ED_space_image_size(SpaceImage *sima, int *width, int *height)
void ED_image_aspect(Image *ima, float *aspx, float *aspy)
{
*aspx= *aspy= 1.0;
*aspx = *aspy = 1.0;
if ((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
(ima->aspx==0.0f || ima->aspy==0.0f))
(ima->aspx == 0.0f || ima->aspy == 0.0f))
return;
/* x is always 1 */
*aspy = ima->aspy/ima->aspx;
*aspy = ima->aspy / ima->aspx;
}
void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
@@ -222,8 +222,8 @@ void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoo
ED_space_image_size(sima, &width, &height);
*zoomx= (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width);
*zoomy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height);
*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
}
void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
@@ -237,12 +237,12 @@ void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
*aspy *= (float)h;
if (*aspx < *aspy) {
*aspy= *aspy / *aspx;
*aspx= 1.0f;
*aspy = *aspy / *aspx;
*aspx = 1.0f;
}
else {
*aspx= *aspx / *aspy;
*aspy= 1.0f;
*aspx = *aspx / *aspy;
*aspy = 1.0f;
}
}
@@ -308,16 +308,16 @@ int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
static void image_scopes_tag_refresh(ScrArea *sa)
{
SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
ARegion *ar;
/* only while histogram is visible */
for (ar=sa->regionbase.first; ar; ar=ar->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN)
return;
}
sima->scopes.ok=0;
sima->scopes.ok = 0;
}
@@ -327,20 +327,20 @@ ARegion *image_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
if (ar) return ar;
/* add subdiv level; after header */
ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
if (ar==NULL) return NULL;
if (ar == NULL) return NULL;
arnew= MEM_callocN(sizeof(ARegion), "buttons for image");
arnew = MEM_callocN(sizeof(ARegion), "buttons for image");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype= RGN_TYPE_UI;
arnew->alignment= RGN_ALIGN_LEFT;
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_LEFT;
arnew->flag = RGN_FLAG_HIDDEN;
@@ -351,20 +351,20 @@ ARegion *image_has_scope_region(ScrArea *sa)
{
ARegion *ar, *arnew;
ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
if (ar) return ar;
/* add subdiv level; after buttons */
ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
/* is error! */
if (ar==NULL) return NULL;
if (ar == NULL) return NULL;
arnew= MEM_callocN(sizeof(ARegion), "scopes for image");
arnew = MEM_callocN(sizeof(ARegion), "scopes for image");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype= RGN_TYPE_PREVIEW;
arnew->alignment= RGN_ALIGN_RIGHT;
arnew->regiontype = RGN_TYPE_PREVIEW;
arnew->alignment = RGN_ALIGN_RIGHT;
arnew->flag = RGN_FLAG_HIDDEN;
@@ -380,46 +380,46 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
ARegion *ar;
SpaceImage *simage;
simage= MEM_callocN(sizeof(SpaceImage), "initimage");
simage->spacetype= SPACE_IMAGE;
simage->zoom= 1;
simage->lock= 1;
simage->iuser.ok= 1;
simage->iuser.fie_ima= 2;
simage->iuser.frames= 100;
simage = MEM_callocN(sizeof(SpaceImage), "initimage");
simage->spacetype = SPACE_IMAGE;
simage->zoom = 1;
simage->lock = 1;
simage->iuser.ok = 1;
simage->iuser.fie_ima = 2;
simage->iuser.frames = 100;
scopes_new(&simage->scopes);
simage->sample_line_hist.height= 100;
simage->sample_line_hist.height = 100;
/* header */
ar= MEM_callocN(sizeof(ARegion), "header for image");
ar = MEM_callocN(sizeof(ARegion), "header for image");
BLI_addtail(&simage->regionbase, ar);
ar->regiontype= RGN_TYPE_HEADER;
ar->alignment= RGN_ALIGN_BOTTOM;
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_BOTTOM;
/* buttons/list view */
ar= MEM_callocN(sizeof(ARegion), "buttons for image");
ar = MEM_callocN(sizeof(ARegion), "buttons for image");
BLI_addtail(&simage->regionbase, ar);
ar->regiontype= RGN_TYPE_UI;
ar->alignment= RGN_ALIGN_LEFT;
ar->regiontype = RGN_TYPE_UI;
ar->alignment = RGN_ALIGN_LEFT;
ar->flag = RGN_FLAG_HIDDEN;
/* scopes */
ar= MEM_callocN(sizeof(ARegion), "buttons for image");
ar = MEM_callocN(sizeof(ARegion), "buttons for image");
BLI_addtail(&simage->regionbase, ar);
ar->regiontype= RGN_TYPE_PREVIEW;
ar->alignment= RGN_ALIGN_RIGHT;
ar->regiontype = RGN_TYPE_PREVIEW;
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for image");
ar = MEM_callocN(sizeof(ARegion), "main area for image");
BLI_addtail(&simage->regionbase, ar);
ar->regiontype= RGN_TYPE_WINDOW;
ar->regiontype = RGN_TYPE_WINDOW;
return (SpaceLink *)simage;
}
@@ -427,7 +427,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
/* not spacelink itself */
static void image_free(SpaceLink *sl)
{
SpaceImage *simage= (SpaceImage*) sl;
SpaceImage *simage = (SpaceImage *) sl;
if (simage->cumap)
curvemapping_free(simage->cumap);
@@ -438,7 +438,7 @@ static void image_free(SpaceLink *sl)
/* spacetype; init callback, add handlers */
static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
{
ListBase *lb= WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
/* add drop boxes */
WM_event_add_dropbox_handler(&sa->handlers, lb);
@@ -447,11 +447,11 @@ static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
static SpaceLink *image_duplicate(SpaceLink *sl)
{
SpaceImage *simagen= MEM_dupallocN(sl);
SpaceImage *simagen = MEM_dupallocN(sl);
/* clear or remove stuff from old */
if (simagen->cumap)
simagen->cumap= curvemapping_copy(simagen->cumap);
simagen->cumap = curvemapping_copy(simagen->cumap);
scopes_new(&simagen->scopes);
@@ -548,8 +548,8 @@ static void image_keymap(struct wmKeyConfig *keyconf)
/* dropboxes */
static int image_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
{
if (drag->type==WM_DRAG_PATH)
if (ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
if (drag->type == WM_DRAG_PATH)
if (ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
return 1;
return 0;
}
@@ -563,7 +563,7 @@ static void image_drop_copy(wmDrag *drag, wmDropBox *drop)
/* area+region dropbox definition */
static void image_dropboxes(void)
{
ListBase *lb= WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy);
}
@@ -573,21 +573,21 @@ static void image_dropboxes(void)
static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
{
Scene *scene = CTX_data_scene(C);
SpaceImage *sima= CTX_wm_space_image(C);
Object *obedit= CTX_data_edit_object(C);
SpaceImage *sima = CTX_wm_space_image(C);
Object *obedit = CTX_data_edit_object(C);
Image *ima;
ima= ED_space_image(sima);
ima = ED_space_image(sima);
if (sima->iuser.flag & IMA_ANIM_ALWAYS)
BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0);
/* check if we have to set the image from the editmesh */
if (ima && (ima->source==IMA_SRC_VIEWER || sima->pin));
if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) ;
else if (obedit && obedit->type == OB_MESH) {
Mesh *me= (Mesh*)obedit->data;
struct BMEditMesh *em= me->edit_btmesh;
int sloppy= 1; /* partially selected face is ok */
Mesh *me = (Mesh *)obedit->data;
struct BMEditMesh *em = me->edit_btmesh;
int sloppy = 1; /* partially selected face is ok */
if (scene_use_new_shading_nodes(scene)) {
/* new shading system, get image from material */
@@ -598,7 +598,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
ED_object_get_active_image(obedit, efa->mat_nr, &node_ima, NULL, NULL);
if (node_ima)
sima->image= node_ima;
sima->image = node_ima;
}
}
else {
@@ -606,16 +606,16 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
MTexPoly *tf;
if (em && EDBM_mtexpoly_check(em)) {
sima->image= NULL;
sima->image = NULL;
tf = EDBM_mtexpoly_active_get(em, NULL, TRUE); /* partially selected face is ok */
if (tf) {
/* don't need to check for pin here, see above */
sima->image= tf->tpage;
sima->image = tf->tpage;
if (sima->flag & SI_EDITTILE);
else sima->curtile= tf->tile;
if (sima->flag & SI_EDITTILE) ;
else sima->curtile = tf->tile;
}
}
}
@@ -624,12 +624,12 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
static void image_listener(ScrArea *sa, wmNotifier *wmn)
{
SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SCENE:
switch(wmn->data) {
switch (wmn->data) {
case ND_FRAME:
image_scopes_tag_refresh(sa);
ED_area_tag_refresh(sa);
@@ -659,7 +659,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_GEOM:
switch(wmn->data) {
switch (wmn->data) {
case ND_DATA:
case ND_SELECT:
image_scopes_tag_refresh(sa);
@@ -669,8 +669,8 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn)
}
case NC_OBJECT:
{
Object *ob= (Object *)wmn->reference;
switch(wmn->data) {
Object *ob = (Object *)wmn->reference;
switch (wmn->data) {
case ND_TRANSFORM:
case ND_MODIFIER:
if (ob && (ob->mode & OB_MODE_EDIT) && sima->lock && (sima->flag & SI_DRAWSHADOW)) {
@@ -687,13 +687,13 @@ const char *image_context_dir[] = {"edit_image", NULL};
static int image_context(const bContext *C, const char *member, bContextDataResult *result)
{
SpaceImage *sima= CTX_wm_space_image(C);
SpaceImage *sima = CTX_wm_space_image(C);
if (CTX_data_dir(member)) {
CTX_data_dir_set(result, image_context_dir);
}
else if (CTX_data_equals(member, "edit_image")) {
CTX_data_id_pointer_set(result, (ID*)ED_space_image(sima));
CTX_data_id_pointer_set(result, (ID *)ED_space_image(sima));
return 1;
}
@@ -705,24 +705,24 @@ static int image_context(const bContext *C, const char *member, bContextDataResu
/* sets up the fields of the View2D from zoom and offset */
static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
{
Image *ima= ED_space_image(sima);
Image *ima = ED_space_image(sima);
float x1, y1, w, h;
int width, height, winx, winy;
#if 0
if (image_preview_active(curarea, &width, &height));
if (image_preview_active(curarea, &width, &height)) ;
else
#endif
ED_space_image_size(sima, &width, &height);
w= width;
h= height;
w = width;
h = height;
if (ima)
h *= ima->aspy/ima->aspx;
h *= ima->aspy / ima->aspx;
winx= ar->winrct.xmax - ar->winrct.xmin + 1;
winy= ar->winrct.ymax - ar->winrct.ymin + 1;
winx = ar->winrct.xmax - ar->winrct.xmin + 1;
winy = ar->winrct.ymax - ar->winrct.ymin + 1;
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
@@ -734,19 +734,19 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
ar->v2d.mask.ymax = winy;
/* which part of the image space do we see? */
x1= ar->winrct.xmin+(winx-sima->zoom*w)/2.0f;
y1= ar->winrct.ymin+(winy-sima->zoom*h)/2.0f;
x1 = ar->winrct.xmin + (winx - sima->zoom * w) / 2.0f;
y1 = ar->winrct.ymin + (winy - sima->zoom * h) / 2.0f;
x1-= sima->zoom*sima->xof;
y1-= sima->zoom*sima->yof;
x1 -= sima->zoom * sima->xof;
y1 -= sima->zoom * sima->yof;
/* relative display right */
ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1)/sima->zoom);
ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx/sima->zoom);
ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1) / sima->zoom);
ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sima->zoom);
/* relative display left */
ar->v2d.cur.ymin = ((ar->winrct.ymin-(float)y1)/sima->zoom);
ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy/sima->zoom);
ar->v2d.cur.ymin = ((ar->winrct.ymin - (float)y1) / sima->zoom);
ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sima->zoom);
/* normalize 0.0..1.0 */
ar->v2d.cur.xmin /= w;
@@ -784,11 +784,11 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
static void image_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceImage *sima= CTX_wm_space_image(C);
Object *obact= CTX_data_active_object(C);
Object *obedit= CTX_data_edit_object(C);
Scene *scene= CTX_data_scene(C);
View2D *v2d= &ar->v2d;
SpaceImage *sima = CTX_wm_space_image(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
View2D *v2d = &ar->v2d;
//View2DScrollers *scrollers;
float col[3];
@@ -801,7 +801,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* put scene context variable in iuser */
sima->iuser.scene= scene;
sima->iuser.scene = scene;
/* we set view2d from own zoom and offset each time */
image_main_area_set_view2d(sima, ar);
@@ -825,7 +825,7 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
/* scrollers? */
#if 0
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
#endif
@@ -834,11 +834,11 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
static void image_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SCREEN:
if (wmn->data==ND_GPENCIL)
if (wmn->data == ND_GPENCIL)
ED_region_tag_redraw(ar);
break;
break;
}
}
@@ -863,13 +863,13 @@ static void image_buttons_area_draw(const bContext *C, ARegion *ar)
static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SCREEN:
if (wmn->data==ND_GPENCIL)
if (wmn->data == ND_GPENCIL)
ED_region_tag_redraw(ar);
break;
case NC_BRUSH:
if (wmn->action==NA_EDITED)
if (wmn->action == NA_EDITED)
ED_region_tag_redraw(ar);
break;
case NC_TEXTURE:
@@ -896,12 +896,12 @@ static void image_scope_area_init(wmWindowManager *wm, ARegion *ar)
static void image_scope_area_draw(const bContext *C, ARegion *ar)
{
SpaceImage *sima= CTX_wm_space_image(C);
Scene *scene= CTX_data_scene(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
void *lock;
ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
if (ibuf) {
scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT );
scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
}
ED_space_image_release_buffer(sima, lock);
@@ -911,9 +911,9 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar)
static void image_scope_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SCENE:
switch(wmn->data) {
switch (wmn->data) {
case ND_MODE:
case ND_RENDER_RESULT:
case ND_COMPO_RESULT:
@@ -947,9 +947,9 @@ static void image_header_area_draw(const bContext *C, ARegion *ar)
static void image_header_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SCENE:
switch(wmn->data) {
switch (wmn->data) {
case ND_MODE:
case ND_TOOLSETTINGS:
ED_region_tag_redraw(ar);
@@ -957,7 +957,7 @@ static void image_header_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_GEOM:
switch(wmn->data) {
switch (wmn->data) {
case ND_DATA:
case ND_SELECT:
ED_region_tag_redraw(ar);
@@ -972,64 +972,64 @@ static void image_header_area_listener(ARegion *ar, wmNotifier *wmn)
/* only called once, from space/spacetypes.c */
void ED_spacetype_image(void)
{
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype image");
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype image");
ARegionType *art;
st->spaceid= SPACE_IMAGE;
st->spaceid = SPACE_IMAGE;
strncpy(st->name, "Image", BKE_ST_MAXNAME);
st->new= image_new;
st->free= image_free;
st->init= image_init;
st->duplicate= image_duplicate;
st->operatortypes= image_operatortypes;
st->keymap= image_keymap;
st->dropboxes= image_dropboxes;
st->refresh= image_refresh;
st->listener= image_listener;
st->context= image_context;
st->new = image_new;
st->free = image_free;
st->init = image_init;
st->duplicate = image_duplicate;
st->operatortypes = image_operatortypes;
st->keymap = image_keymap;
st->dropboxes = image_dropboxes;
st->refresh = image_refresh;
st->listener = image_listener;
st->context = image_context;
/* regions: main window */
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_WINDOW;
art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_GPENCIL;
art->init= image_main_area_init;
art->draw= image_main_area_draw;
art->listener= image_main_area_listener;
art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
art->init = image_main_area_init;
art->draw = image_main_area_draw;
art->listener = image_main_area_listener;
BLI_addhead(&st->regiontypes, art);
/* regions: listview/buttons */
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_UI;
art->prefsizex= 220; // XXX
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
art->listener= image_buttons_area_listener;
art->init= image_buttons_area_init;
art->draw= image_buttons_area_draw;
art->prefsizex = 220; // XXX
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = image_buttons_area_listener;
art->init = image_buttons_area_init;
art->draw = image_buttons_area_draw;
BLI_addhead(&st->regiontypes, art);
image_buttons_register(art);
ED_uvedit_buttons_register(art);
/* regions: statistics/scope buttons */
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_PREVIEW;
art->prefsizex= 220; // XXX
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
art->listener= image_scope_area_listener;
art->init= image_scope_area_init;
art->draw= image_scope_area_draw;
art->prefsizex = 220; // XXX
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = image_scope_area_listener;
art->init = image_scope_area_init;
art->draw = image_scope_area_draw;
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey= HEADERY;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
art->listener= image_header_area_listener;
art->init= image_header_area_init;
art->draw= image_header_area_draw;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->listener = image_header_area_listener;
art->init = image_header_area_init;
art->draw = image_header_area_draw;
BLI_addhead(&st->regiontypes, art);

View File

@@ -66,42 +66,42 @@
static void info_report_color(unsigned char *fg, unsigned char *bg, Report *report, int bool)
{
if (report->flag & SELECT) {
fg[0]=255; fg[1]=255; fg[2]=255;
fg[0] = 255; fg[1] = 255; fg[2] = 255;
if (bool) {
bg[0]=96; bg[1]=128; bg[2]=255;
bg[0] = 96; bg[1] = 128; bg[2] = 255;
}
else {
bg[0]=90; bg[1]=122; bg[2]=249;
bg[0] = 90; bg[1] = 122; bg[2] = 249;
}
}
else {
fg[0]=0; fg[1]=0; fg[2]=0;
fg[0] = 0; fg[1] = 0; fg[2] = 0;
if (report->type & RPT_ERROR_ALL) {
if (bool) { bg[0]=220; bg[1]=0; bg[2]=0; }
else { bg[0]=214; bg[1]=0; bg[2]=0; }
if (bool) { bg[0] = 220; bg[1] = 0; bg[2] = 0; }
else { bg[0] = 214; bg[1] = 0; bg[2] = 0; }
}
else if (report->type & RPT_WARNING_ALL) {
if (bool) { bg[0]=220; bg[1]=128; bg[2]=96; }
else { bg[0]=214; bg[1]=122; bg[2]=90; }
if (bool) { bg[0] = 220; bg[1] = 128; bg[2] = 96; }
else { bg[0] = 214; bg[1] = 122; bg[2] = 90; }
}
#if 0 // XXX: this looks like the selected color, so don't use this
else if (report->type & RPT_OPERATOR_ALL) {
if (bool) { bg[0]=96; bg[1]=128; bg[2]=255; }
else { bg[0]=90; bg[1]=122; bg[2]=249; }
if (bool) { bg[0] = 96; bg[1] = 128; bg[2] = 255; }
else { bg[0] = 90; bg[1] = 122; bg[2] = 249; }
}
#endif
else if (report->type & RPT_INFO_ALL) {
if (bool) { bg[0]=0; bg[1]=170; bg[2]=0; }
else { bg[0]=0; bg[1]=164; bg[2]=0; }
if (bool) { bg[0] = 0; bg[1] = 170; bg[2] = 0; }
else { bg[0] = 0; bg[1] = 164; bg[2] = 0; }
}
else if (report->type & RPT_DEBUG_ALL) {
if (bool) { bg[0]=196; bg[1]=196; bg[2]=196; }
else { bg[0]=190; bg[1]=190; bg[2]=190; }
if (bool) { bg[0] = 196; bg[1] = 196; bg[2] = 196; }
else { bg[0] = 190; bg[1] = 190; bg[2] = 190; }
}
else {
if (bool) { bg[0]=120; bg[1]=120; bg[2]=120; }
else { bg[0]=114; bg[1]=114; bg[2]=114; }
if (bool) { bg[0] = 120; bg[1] = 120; bg[2] = 120; }
else { bg[0] = 114; bg[1] = 114; bg[2] = 114; }
}
}
}
@@ -110,24 +110,24 @@ static void info_report_color(unsigned char *fg, unsigned char *bg, Report *repo
#ifdef USE_INFO_NEWLINE
static void report_textview_init__internal(TextViewContext *tvc)
{
Report *report= (Report *)tvc->iter;
const char *str= report->message;
const char *next_str= strchr(str + tvc->iter_char, '\n');
Report *report = (Report *)tvc->iter;
const char *str = report->message;
const char *next_str = strchr(str + tvc->iter_char, '\n');
if (next_str) {
tvc->iter_char_next= (int)(next_str - str);
tvc->iter_char_next = (int)(next_str - str);
}
else {
tvc->iter_char_next= report->len;
tvc->iter_char_next = report->len;
}
}
static int report_textview_skip__internal(TextViewContext *tvc)
{
SpaceInfo *sinfo= (SpaceInfo *)tvc->arg1;
const int report_mask= info_report_mask(sinfo);
while (tvc->iter && (((Report *)tvc->iter)->type & report_mask)==0) {
tvc->iter= (void *)((Link *)tvc->iter)->prev;
SpaceInfo *sinfo = (SpaceInfo *)tvc->arg1;
const int report_mask = info_report_mask(sinfo);
while (tvc->iter && (((Report *)tvc->iter)->type & report_mask) == 0) {
tvc->iter = (void *)((Link *)tvc->iter)->prev;
}
return (tvc->iter != NULL);
}
@@ -137,23 +137,23 @@ static int report_textview_skip__internal(TextViewContext *tvc)
static int report_textview_begin(TextViewContext *tvc)
{
// SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
ReportList *reports= (ReportList *)tvc->arg2;
ReportList *reports = (ReportList *)tvc->arg2;
tvc->lheight= 14; //sc->lheight;
tvc->sel_start= 0;
tvc->sel_end= 0;
tvc->lheight = 14; //sc->lheight;
tvc->sel_start = 0;
tvc->sel_end = 0;
/* iterator */
tvc->iter= reports->list.last;
tvc->iter = reports->list.last;
glClearColor(120.0/255.0, 120.0/255.0, 120.0/255.0, 1.0);
glClearColor(120.0 / 255.0, 120.0 / 255.0, 120.0 / 255.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
#ifdef USE_INFO_NEWLINE
tvc->iter_tmp= 0;
tvc->iter_tmp = 0;
if (tvc->iter && report_textview_skip__internal(tvc)) {
/* init the newline iterator */
tvc->iter_char= 0;
tvc->iter_char = 0;
report_textview_init__internal(tvc);
return TRUE;
@@ -175,14 +175,14 @@ static void report_textview_end(TextViewContext *UNUSED(tvc))
static int report_textview_step(TextViewContext *tvc)
{
/* simple case, but no newline support */
Report *report= (Report *)tvc->iter;
Report *report = (Report *)tvc->iter;
if (report->len <= tvc->iter_char_next) {
tvc->iter= (void *)((Link *)tvc->iter)->prev;
tvc->iter = (void *)((Link *)tvc->iter)->prev;
if (tvc->iter && report_textview_skip__internal(tvc)) {
tvc->iter_tmp++;
tvc->iter_char= 0; /* reset start */
tvc->iter_char = 0; /* reset start */
report_textview_init__internal(tvc);
return TRUE;
@@ -193,7 +193,7 @@ static int report_textview_step(TextViewContext *tvc)
}
else {
/* step to the next newline */
tvc->iter_char= tvc->iter_char_next + 1;
tvc->iter_char = tvc->iter_char_next + 1;
report_textview_init__internal(tvc);
return TRUE;
@@ -202,15 +202,15 @@ static int report_textview_step(TextViewContext *tvc)
static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len)
{
Report *report= (Report *)tvc->iter;
*line= report->message + tvc->iter_char;
*len= tvc->iter_char_next - tvc->iter_char;
Report *report = (Report *)tvc->iter;
*line = report->message + tvc->iter_char;
*len = tvc->iter_char_next - tvc->iter_char;
return 1;
}
static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3])
{
Report *report= (Report *)tvc->iter;
Report *report = (Report *)tvc->iter;
info_report_color(fg, bg, report, tvc->iter_tmp % 2);
return TVC_LINE_FG | TVC_LINE_BG;
}
@@ -220,27 +220,27 @@ static int report_textview_line_color(struct TextViewContext *tvc, unsigned char
static int report_textview_step(TextViewContext *tvc)
{
SpaceInfo *sinfo= (SpaceInfo *)tvc->arg1;
const int report_mask= info_report_mask(sinfo);
SpaceInfo *sinfo = (SpaceInfo *)tvc->arg1;
const int report_mask = info_report_mask(sinfo);
do {
tvc->iter= (void *)((Link *)tvc->iter)->prev;
} while (tvc->iter && (((Report *)tvc->iter)->type & report_mask)==0);
tvc->iter = (void *)((Link *)tvc->iter)->prev;
} while (tvc->iter && (((Report *)tvc->iter)->type & report_mask) == 0);
return (tvc->iter != NULL);
}
static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len)
{
Report *report= (Report *)tvc->iter;
*line= report->message;
*len= report->len;
Report *report = (Report *)tvc->iter;
*line = report->message;
*len = report->len;
return 1;
}
static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3])
{
Report *report= (Report *)tvc->iter;
Report *report = (Report *)tvc->iter;
info_report_color(fg, bg, report, tvc->iter_tmp % 2);
return TVC_LINE_FG | TVC_LINE_BG;
}
@@ -251,41 +251,41 @@ static int report_textview_line_color(struct TextViewContext *tvc, unsigned char
static int info_textview_main__internal(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick)
{
int ret= 0;
int ret = 0;
View2D *v2d= &ar->v2d;
View2D *v2d = &ar->v2d;
TextViewContext tvc= {0};
tvc.begin= report_textview_begin;
tvc.end= report_textview_end;
TextViewContext tvc = {0};
tvc.begin = report_textview_begin;
tvc.end = report_textview_end;
tvc.step= report_textview_step;
tvc.line_get= report_textview_line_get;
tvc.line_color= report_textview_line_color;
tvc.step = report_textview_step;
tvc.line_get = report_textview_line_get;
tvc.line_color = report_textview_line_color;
tvc.arg1= sinfo;
tvc.arg2= reports;
tvc.arg1 = sinfo;
tvc.arg2 = reports;
/* view */
tvc.sel_start= 0;
tvc.sel_end= 0;
tvc.lheight= 14; //sc->lheight;
tvc.sel_start = 0;
tvc.sel_end = 0;
tvc.lheight = 14; //sc->lheight;
tvc.ymin = v2d->cur.ymin;
tvc.ymax = v2d->cur.ymax;
tvc.winx= ar->winx;
tvc.winx = ar->winx;
ret= textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick);
return ret;
}
void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int mouse_y)
{
void *mouse_pick= NULL;
void *mouse_pick = NULL;
int mval[2];
mval[0]= 0;
mval[1]= mouse_y;
mval[0] = 0;
mval[1] = mouse_y;
info_textview_main__internal(sinfo, ar, reports, 0, mval, &mouse_pick, NULL);
return (void *)mouse_pick;

View File

@@ -70,7 +70,7 @@
static int pack_all_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
Main *bmain = CTX_data_main(C);
packAll(bmain, op->reports);
G.fileflags |= G_AUTOPACK;
@@ -80,14 +80,14 @@ static int pack_all_exec(bContext *C, wmOperator *op)
static int pack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
Main *bmain= CTX_data_main(C);
Main *bmain = CTX_data_main(C);
Image *ima;
ImBuf *ibuf;
// first check for dirty images
for (ima=bmain->image.first; ima; ima=ima->id.next) {
for (ima = bmain->image.first; ima; ima = ima->id.next) {
if (ima->ibufs.first) { /* XXX FIX */
ibuf= BKE_image_get_ibuf(ima, NULL);
ibuf = BKE_image_get_ibuf(ima, NULL);
if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
break;
@@ -113,7 +113,7 @@ void FILE_OT_pack_all(wmOperatorType *ot)
ot->invoke = pack_all_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************* unpack all operator *********************/
@@ -129,10 +129,10 @@ static const EnumPropertyItem unpack_all_method_items[] = {
static int unpack_all_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
int method= RNA_enum_get(op->ptr, "method");
Main *bmain = CTX_data_main(C);
int method = RNA_enum_get(op->ptr, "method");
if (method != PF_KEEP) unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */
if (method != PF_KEEP) unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */
G.fileflags &= ~G_AUTOPACK;
return OPERATOR_FINISHED;
@@ -140,7 +140,7 @@ static int unpack_all_exec(bContext *C, wmOperator *op)
static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
Main *bmain= CTX_data_main(C);
Main *bmain = CTX_data_main(C);
uiPopupMenu *pup;
uiLayout *layout;
char title[64];
@@ -159,8 +159,8 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
else
BLI_snprintf(title, sizeof(title), "Unpack %d files", count);
pup= uiPupMenuBegin(C, title, ICON_NONE);
layout= uiPupMenuLayout(pup);
pup = uiPupMenuBegin(C, title, ICON_NONE);
layout = uiPupMenuLayout(pup);
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
uiItemsEnumO(layout, "FILE_OT_unpack_all", "method");
@@ -181,7 +181,7 @@ void FILE_OT_unpack_all(wmOperatorType *ot)
ot->invoke = unpack_all_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "method", unpack_all_method_items, PF_USE_LOCAL, "Method", "How to unpack");
@@ -191,7 +191,7 @@ void FILE_OT_unpack_all(wmOperatorType *ot)
static int make_paths_relative_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
Main *bmain = CTX_data_main(C);
if (!G.relbase_valid) {
BKE_report(op->reports, RPT_WARNING, "Can't set relative paths with an unsaved blend file");
@@ -216,14 +216,14 @@ void FILE_OT_make_paths_relative(wmOperatorType *ot)
ot->exec = make_paths_relative_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************* make paths absolute operator *********************/
static int make_paths_absolute_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
Main *bmain = CTX_data_main(C);
if (!G.relbase_valid) {
BKE_report(op->reports, RPT_WARNING, "Can't set absolute paths with an unsaved blend file");
@@ -248,14 +248,14 @@ void FILE_OT_make_paths_absolute(wmOperatorType *ot)
ot->exec = make_paths_absolute_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************* report missing files operator *********************/
static int report_missing_files_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
Main *bmain = CTX_data_main(C);
/* run the missing file check */
checkMissingFiles(bmain, op->reports);
@@ -280,8 +280,8 @@ void FILE_OT_report_missing_files(wmOperatorType *ot)
static int find_missing_files_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
const char *searchpath= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
Main *bmain = CTX_data_main(C);
const char *searchpath = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
findMissingFiles(bmain, searchpath, op->reports);
MEM_freeN((void *)searchpath);
@@ -306,7 +306,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
ot->invoke = find_missing_files_invoke;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
@@ -321,44 +321,45 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
* inactive regions, so use this for now. --matt
*/
#define INFO_TIMEOUT 5.0f
#define INFO_COLOR_TIMEOUT 3.0f
#define ERROR_TIMEOUT 10.0f
#define ERROR_COLOR_TIMEOUT 6.0f
#define COLLAPSE_TIMEOUT 0.25f
#define INFO_TIMEOUT 5.0f
#define INFO_COLOR_TIMEOUT 3.0f
#define ERROR_TIMEOUT 10.0f
#define ERROR_COLOR_TIMEOUT 6.0f
#define COLLAPSE_TIMEOUT 0.25f
static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
wmWindowManager *wm= CTX_wm_manager(C);
ReportList *reports= CTX_wm_reports(C);
wmWindowManager *wm = CTX_wm_manager(C);
ReportList *reports = CTX_wm_reports(C);
Report *report;
ReportTimerInfo *rti;
float progress=0.0, color_progress=0.0;
float progress = 0.0, color_progress = 0.0;
float neutral_col[3] = {0.35, 0.35, 0.35};
float neutral_grey= 0.6;
float timeout=0.0, color_timeout=0.0;
int send_note= 0;
float neutral_grey = 0.6;
float timeout = 0.0, color_timeout = 0.0;
int send_note = 0;
/* escape if not our timer */
if ( (reports->reporttimer==NULL) ||
(reports->reporttimer != event->customdata) ||
((report= BKE_reports_last_displayable(reports))==NULL) /* may have been deleted */
) {
if ((reports->reporttimer == NULL) ||
(reports->reporttimer != event->customdata) ||
((report = BKE_reports_last_displayable(reports)) == NULL) /* may have been deleted */
)
{
return OPERATOR_PASS_THROUGH;
}
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
timeout = (report->type & RPT_ERROR_ALL)?ERROR_TIMEOUT:INFO_TIMEOUT;
color_timeout = (report->type & RPT_ERROR_ALL)?ERROR_COLOR_TIMEOUT:INFO_COLOR_TIMEOUT;
timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
color_timeout = (report->type & RPT_ERROR_ALL) ? ERROR_COLOR_TIMEOUT : INFO_COLOR_TIMEOUT;
/* clear the report display after timeout */
if ((float)reports->reporttimer->duration > timeout) {
WM_event_remove_timer(wm, NULL, reports->reporttimer);
reports->reporttimer = NULL;
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
return (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH);
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
}
if (rti->widthfac == 0.0f) {
@@ -379,7 +380,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm
rti->col[2] = 0.7;
}
rti->greyscale = 0.75;
rti->widthfac=1.0;
rti->widthfac = 1.0;
}
progress = (float)reports->reporttimer->duration / timeout;
@@ -387,7 +388,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm
/* save us from too many draws */
if (color_progress <= 1.0f) {
send_note= 1;
send_note = 1;
/* fade colors out sharply according to progress through fade-out duration */
interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress);
@@ -395,17 +396,17 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm
}
/* collapse report at end of timeout */
if (progress*timeout > timeout - COLLAPSE_TIMEOUT) {
rti->widthfac = (progress*timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT;
if (progress * timeout > timeout - COLLAPSE_TIMEOUT) {
rti->widthfac = (progress * timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT;
rti->widthfac = 1.0f - rti->widthfac;
send_note= 1;
send_note = 1;
}
if (send_note) {
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
}
return (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH);
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
}
void INFO_OT_reports_display_update(wmOperatorType *ot)

View File

@@ -53,16 +53,16 @@ int info_report_mask(SpaceInfo *UNUSED(sinfo))
#if 0
int report_mask = 0;
if (sinfo->rpt_mask & INFO_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL;
if (sinfo->rpt_mask & INFO_RPT_INFO) report_mask |= RPT_INFO_ALL;
if (sinfo->rpt_mask & INFO_RPT_OP) report_mask |= RPT_OPERATOR_ALL;
if (sinfo->rpt_mask & INFO_RPT_WARN) report_mask |= RPT_WARNING_ALL;
if (sinfo->rpt_mask & INFO_RPT_ERR) report_mask |= RPT_ERROR_ALL;
if (sinfo->rpt_mask & INFO_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL;
if (sinfo->rpt_mask & INFO_RPT_INFO) report_mask |= RPT_INFO_ALL;
if (sinfo->rpt_mask & INFO_RPT_OP) report_mask |= RPT_OPERATOR_ALL;
if (sinfo->rpt_mask & INFO_RPT_WARN) report_mask |= RPT_WARNING_ALL;
if (sinfo->rpt_mask & INFO_RPT_ERR) report_mask |= RPT_ERROR_ALL;
return report_mask;
#endif
return RPT_DEBUG_ALL|RPT_INFO_ALL|RPT_OPERATOR_ALL|RPT_WARNING_ALL|RPT_ERROR_ALL;
return RPT_DEBUG_ALL | RPT_INFO_ALL | RPT_OPERATOR_ALL | RPT_WARNING_ALL | RPT_ERROR_ALL;
}
// TODO, get this working again!
@@ -74,9 +74,9 @@ static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
// Report *report;
#if 0
sc->type= CONSOLE_TYPE_PYTHON;
sc->type = CONSOLE_TYPE_PYTHON;
for (report=reports->list.last; report; report=report->prev) {
for (report = reports->list.last; report; report = report->prev) {
if ((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL) && (report->flag & SELECT)) {
console_history_add_str(sc, report->message, 0);
WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL);
@@ -85,7 +85,7 @@ static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
}
}
sc->type= CONSOLE_TYPE_REPORT;
sc->type = CONSOLE_TYPE_REPORT;
#endif
ED_area_tag_redraw(CTX_wm_area(C));
@@ -111,8 +111,8 @@ void INFO_OT_report_replay(wmOperatorType *ot)
static int select_report_pick_exec(bContext *C, wmOperator *op)
{
int report_index= RNA_int_get(op->ptr, "report_index");
Report *report= BLI_findlink(&CTX_wm_reports(C)->list, report_index);
int report_index = RNA_int_get(op->ptr, "report_index");
Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
if (!report)
return OPERATOR_CANCELLED;
@@ -126,15 +126,15 @@ static int select_report_pick_exec(bContext *C, wmOperator *op)
static int select_report_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
SpaceInfo *sinfo= CTX_wm_space_info(C);
ARegion *ar= CTX_wm_region(C);
ReportList *reports= CTX_wm_reports(C);
SpaceInfo *sinfo = CTX_wm_space_info(C);
ARegion *ar = CTX_wm_region(C);
ReportList *reports = CTX_wm_reports(C);
Report *report;
/* uses opengl */
wmSubWindowSet(CTX_wm_window(C), ar->swinid);
report= info_text_pick(sinfo, ar, reports, event->mval[1]);
report = info_text_pick(sinfo, ar, reports, event->mval[1]);
RNA_int_set(op->ptr, "report_index", BLI_findindex(&reports->list, report));
@@ -165,28 +165,28 @@ void INFO_OT_select_pick(wmOperatorType *ot)
static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceInfo *sinfo= CTX_wm_space_info(C);
ReportList *reports= CTX_wm_reports(C);
int report_mask= info_report_mask(sinfo);
int deselect= 0;
SpaceInfo *sinfo = CTX_wm_space_info(C);
ReportList *reports = CTX_wm_reports(C);
int report_mask = info_report_mask(sinfo);
int deselect = 0;
Report *report;
for (report=reports->list.last; report; report=report->prev) {
for (report = reports->list.last; report; report = report->prev) {
if ((report->type & report_mask) && (report->flag & SELECT)) {
deselect= 1;
deselect = 1;
break;
}
}
if (deselect) {
for (report=reports->list.last; report; report=report->prev)
for (report = reports->list.last; report; report = report->prev)
if (report->type & report_mask)
report->flag &= ~SELECT;
}
else {
for (report=reports->list.last; report; report=report->prev)
for (report = reports->list.last; report; report = report->prev)
if (report->type & report_mask)
report->flag |= SELECT;
}
@@ -216,11 +216,11 @@ void INFO_OT_select_all_toggle(wmOperatorType *ot)
/* borderselect operator */
static int borderselect_exec(bContext *C, wmOperator *op)
{
SpaceInfo *sinfo= CTX_wm_space_info(C);
ARegion *ar= CTX_wm_region(C);
ReportList *reports= CTX_wm_reports(C);
int report_mask= info_report_mask(sinfo);
int extend= RNA_boolean_get(op->ptr, "extend");
SpaceInfo *sinfo = CTX_wm_space_info(C);
ARegion *ar = CTX_wm_region(C);
ReportList *reports = CTX_wm_reports(C);
int report_mask = info_report_mask(sinfo);
int extend = RNA_boolean_get(op->ptr, "extend");
Report *report_min, *report_max, *report;
//View2D *v2d= UI_view2d_fromcontext(C);
@@ -228,7 +228,7 @@ static int borderselect_exec(bContext *C, wmOperator *op)
rcti rect;
//rctf rectf, rq;
short selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT);
short selecting = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
//int mval[2];
rect.xmin = RNA_int_get(op->ptr, "xmin");
@@ -237,54 +237,54 @@ static int borderselect_exec(bContext *C, wmOperator *op)
rect.ymax = RNA_int_get(op->ptr, "ymax");
#if 0
mval[0]= rect.xmin;
mval[1]= rect.ymin;
mval[0] = rect.xmin;
mval[1] = rect.ymin;
UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin);
mval[0]= rect.xmax;
mval[1]= rect.ymax;
mval[0] = rect.xmax;
mval[1] = rect.ymax;
UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax);
#endif
if (!extend) {
for (report= reports->list.first; report; report= report->next) {
for (report = reports->list.first; report; report = report->next) {
if ((report->type & report_mask)==0)
if ((report->type & report_mask) == 0)
continue;
report->flag &= ~SELECT;
}
}
report_min= info_text_pick(sinfo, ar, reports, rect.ymax);
report_max= info_text_pick(sinfo, ar, reports, rect.ymin);
report_min = info_text_pick(sinfo, ar, reports, rect.ymax);
report_max = info_text_pick(sinfo, ar, reports, rect.ymin);
/* get the first report if none found */
if (report_min==NULL) {
if (report_min == NULL) {
// printf("find_min\n");
for (report=reports->list.first; report; report=report->next) {
for (report = reports->list.first; report; report = report->next) {
if (report->type & report_mask) {
report_min= report;
report_min = report;
break;
}
}
}
if (report_max==NULL) {
if (report_max == NULL) {
// printf("find_max\n");
for (report=reports->list.last; report; report=report->prev) {
for (report = reports->list.last; report; report = report->prev) {
if (report->type & report_mask) {
report_max= report;
report_max = report;
break;
}
}
}
if (report_min==NULL || report_max==NULL)
if (report_min == NULL || report_max == NULL)
return OPERATOR_CANCELLED;
for (report= report_min; (report != report_max->next); report= report->next) {
for (report = report_min; (report != report_max->next); report = report->next) {
if ((report->type & report_mask)==0)
if ((report->type & report_mask) == 0)
continue;
if (selecting)
@@ -326,16 +326,16 @@ void INFO_OT_select_border(wmOperatorType *ot)
static int report_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceInfo *sinfo= CTX_wm_space_info(C);
ReportList *reports= CTX_wm_reports(C);
int report_mask= info_report_mask(sinfo);
SpaceInfo *sinfo = CTX_wm_space_info(C);
ReportList *reports = CTX_wm_reports(C);
int report_mask = info_report_mask(sinfo);
Report *report, *report_next;
for (report=reports->list.first; report; ) {
for (report = reports->list.first; report; ) {
report_next=report->next;
report_next = report->next;
if ((report->type & report_mask) && (report->flag & SELECT)) {
BLI_remlink(&reports->list, report);
@@ -343,7 +343,7 @@ static int report_delete_exec(bContext *C, wmOperator *UNUSED(op))
MEM_freeN(report);
}
report= report_next;
report = report_next;
}
ED_area_tag_redraw(CTX_wm_area(C));
@@ -371,23 +371,23 @@ void INFO_OT_report_delete(wmOperatorType *ot)
static int report_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceInfo *sinfo= CTX_wm_space_info(C);
ReportList *reports= CTX_wm_reports(C);
int report_mask= info_report_mask(sinfo);
SpaceInfo *sinfo = CTX_wm_space_info(C);
ReportList *reports = CTX_wm_reports(C);
int report_mask = info_report_mask(sinfo);
Report *report;
DynStr *buf_dyn= BLI_dynstr_new();
DynStr *buf_dyn = BLI_dynstr_new();
char *buf_str;
for (report=reports->list.first; report; report= report->next) {
for (report = reports->list.first; report; report = report->next) {
if ((report->type & report_mask) && (report->flag & SELECT)) {
BLI_dynstr_append(buf_dyn, report->message);
BLI_dynstr_append(buf_dyn, "\n");
}
}
buf_str= BLI_dynstr_get_cstring(buf_dyn);
buf_str = BLI_dynstr_get_cstring(buf_dyn);
BLI_dynstr_free(buf_dyn);
WM_clipboard_text_set(buf_str, 0);

View File

@@ -68,78 +68,78 @@ typedef struct SceneStats {
static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
{
switch(ob->type) {
case OB_MESH: {
/* we assume derivedmesh is already built, this strictly does stats now. */
DerivedMesh *dm= ob->derivedFinal;
int totvert, totedge, totface;
switch (ob->type) {
case OB_MESH: {
/* we assume derivedmesh is already built, this strictly does stats now. */
DerivedMesh *dm = ob->derivedFinal;
int totvert, totedge, totface;
stats->totmesh +=totob;
stats->totmesh += totob;
if (dm) {
totvert = dm->getNumVerts(dm);
totedge = dm->getNumEdges(dm);
totface = dm->getNumPolys(dm);
if (dm) {
totvert = dm->getNumVerts(dm);
totedge = dm->getNumEdges(dm);
totface = dm->getNumPolys(dm);
stats->totvert += totvert*totob;
stats->totedge += totedge*totob;
stats->totface += totface*totob;
stats->totvert += totvert * totob;
stats->totedge += totedge * totob;
stats->totface += totface * totob;
if (sel) {
stats->totvertsel += totvert;
stats->totfacesel += totface;
}
}
break;
}
case OB_LAMP:
stats->totlamp += totob;
break;
case OB_SURF:
case OB_CURVE:
case OB_FONT: {
int tot = 0, totf = 0;
stats->totcurve += totob;
if (ob->disp.first)
count_displist(&ob->disp, &tot, &totf);
tot *= totob;
totf *= totob;
stats->totvert += tot;
stats->totface += totf;
if (sel) {
stats->totvertsel += totvert;
stats->totfacesel += totface;
stats->totvertsel += tot;
stats->totfacesel += totf;
}
break;
}
break;
}
case OB_LAMP:
stats->totlamp += totob;
break;
case OB_SURF:
case OB_CURVE:
case OB_FONT: {
int tot= 0, totf= 0;
case OB_MBALL: {
int tot = 0, totf = 0;
stats->totcurve += totob;
if (ob->disp.first)
count_displist(&ob->disp, &tot, &totf);
tot *= totob;
totf *= totob;
tot *= totob;
totf *= totob;
stats->totvert+= tot;
stats->totface+= totf;
stats->totvert += tot;
stats->totface += totf;
if (sel) {
stats->totvertsel += tot;
stats->totfacesel += totf;
if (sel) {
stats->totvertsel += tot;
stats->totfacesel += totf;
}
break;
}
break;
}
case OB_MBALL: {
int tot= 0, totf= 0;
count_displist(&ob->disp, &tot, &totf);
tot *= totob;
totf *= totob;
stats->totvert += tot;
stats->totface += totf;
if (sel) {
stats->totvertsel += tot;
stats->totfacesel += totf;
}
break;
}
}
}
static void stats_object_edit(Object *obedit, SceneStats *stats)
{
if (obedit->type==OB_MESH) {
if (obedit->type == OB_MESH) {
BMEditMesh *em = BMEdit_FromObject(obedit);
stats->totvert = em->bm->totvert;
@@ -151,12 +151,12 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
stats->totface = em->bm->totface;
stats->totfacesel = em->bm->totfacesel;
}
else if (obedit->type==OB_ARMATURE) {
else if (obedit->type == OB_ARMATURE) {
/* Armature Edit */
bArmature *arm= obedit->data;
bArmature *arm = obedit->data;
EditBone *ebo;
for (ebo=arm->edbo->first; ebo; ebo=ebo->next) {
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
stats->totbone++;
if ((ebo->flag & BONE_CONNECTED) && ebo->parent)
@@ -170,27 +170,27 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
if (ebo->flag & BONE_SELECTED) stats->totbonesel++;
/* if this is a connected child and it's parent is being moved, remove our root */
if ((ebo->flag & BONE_CONNECTED)&& (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL))
if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL))
stats->totvertsel--;
stats->totvert+=2;
stats->totvert += 2;
}
}
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { /* OB_FONT has no cu->editnurb */
/* Curve Edit */
Curve *cu= obedit->data;
Curve *cu = obedit->data;
Nurb *nu;
BezTriple *bezt;
BPoint *bp;
int a;
ListBase *nurbs= curve_editnurbs(cu);
ListBase *nurbs = curve_editnurbs(cu);
for (nu=nurbs->first; nu; nu=nu->next) {
for (nu = nurbs->first; nu; nu = nu->next) {
if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
stats->totvert+=3;
stats->totvert += 3;
if (bezt->f1) stats->totvertsel++;
if (bezt->f2) stats->totvertsel++;
if (bezt->f3) stats->totvertsel++;
@@ -198,8 +198,8 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
}
}
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
while (a--) {
stats->totvert++;
if (bp->f1 & SELECT) stats->totvertsel++;
@@ -208,26 +208,26 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
}
}
}
else if (obedit->type==OB_MBALL) {
else if (obedit->type == OB_MBALL) {
/* MetaBall Edit */
MetaBall *mball= obedit->data;
MetaBall *mball = obedit->data;
MetaElem *ml;
for (ml= mball->editelems->first; ml; ml=ml->next) {
for (ml = mball->editelems->first; ml; ml = ml->next) {
stats->totvert++;
if (ml->flag & SELECT) stats->totvertsel++;
}
}
else if (obedit->type==OB_LATTICE) {
else if (obedit->type == OB_LATTICE) {
/* Lattice Edit */
Lattice *lt= obedit->data;
Lattice *editlatt= lt->editlatt->latt;
Lattice *lt = obedit->data;
Lattice *editlatt = lt->editlatt->latt;
BPoint *bp;
int a;
bp= editlatt->def;
bp = editlatt->def;
a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw;
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
while (a--) {
stats->totvert++;
if (bp->f1 & SELECT) stats->totvertsel++;
@@ -239,10 +239,10 @@ static void stats_object_edit(Object *obedit, SceneStats *stats)
static void stats_object_pose(Object *ob, SceneStats *stats)
{
if (ob->pose) {
bArmature *arm= ob->data;
bArmature *arm = ob->data;
bPoseChannel *pchan;
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
stats->totbone++;
if (pchan->bone && (pchan->bone->flag & BONE_SELECTED))
if (pchan->bone->layer & arm->layer)
@@ -260,22 +260,22 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats)
ParticleSystem *psys;
ParticleSettings *part;
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
part=psys->part;
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
part = psys->part;
if (part->draw_as==PART_DRAW_OB && part->dup_ob) {
int tot=count_particles(psys);
if (part->draw_as == PART_DRAW_OB && part->dup_ob) {
int tot = count_particles(psys);
stats_object(part->dup_ob, 0, tot, stats);
}
else if (part->draw_as==PART_DRAW_GR && part->dup_group) {
else if (part->draw_as == PART_DRAW_GR && part->dup_group) {
GroupObject *go;
int tot, totgroup=0, cur=0;
int tot, totgroup = 0, cur = 0;
for (go= part->dup_group->gobject.first; go; go=go->next)
for (go = part->dup_group->gobject.first; go; go = go->next)
totgroup++;
for (go= part->dup_group->gobject.first; go; go=go->next) {
tot=count_particles_mod(psys,totgroup,cur);
for (go = part->dup_group->gobject.first; go; go = go->next) {
tot = count_particles_mod(psys, totgroup, cur);
stats_object(go->ob, 0, tot, stats);
cur++;
}
@@ -285,22 +285,22 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats)
stats_object(ob, base->flag & SELECT, 1, stats);
stats->totobj++;
}
else if (ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS|OB_DUPLIFACES))) {
else if (ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS | OB_DUPLIFACES))) {
/* Dupli Verts/Faces */
int tot= count_duplilist(ob->parent);
stats->totobj+=tot;
int tot = count_duplilist(ob->parent);
stats->totobj += tot;
stats_object(ob, base->flag & SELECT, tot, stats);
}
else if (ob->transflag & OB_DUPLIFRAMES) {
/* Dupli Frames */
int tot= count_duplilist(ob);
stats->totobj+=tot;
int tot = count_duplilist(ob);
stats->totobj += tot;
stats_object(ob, base->flag & SELECT, tot, stats);
}
else if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
/* Dupli Group */
int tot= count_duplilist(ob);
stats->totobj+=tot;
int tot = count_duplilist(ob);
stats->totobj += tot;
stats_object(ob, base->flag & SELECT, tot, stats);
}
else {
@@ -313,8 +313,8 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats)
/* Statistics displayed in info header. Called regularly on scene changes. */
static void stats_update(Scene *scene)
{
SceneStats stats= {0};
Object *ob= (scene->basact)? scene->basact->object: NULL;
SceneStats stats = {0};
Object *ob = (scene->basact) ? scene->basact->object : NULL;
Base *base;
if (scene->obedit) {
@@ -327,78 +327,78 @@ static void stats_update(Scene *scene)
}
else {
/* Objects */
for (base= scene->base.first; base; base=base->next)
for (base = scene->base.first; base; base = base->next)
if (scene->lay & base->lay)
stats_dupli_object(base, base->object, &stats);
}
if (!scene->stats)
scene->stats= MEM_callocN(sizeof(SceneStats), "SceneStats");
scene->stats = MEM_callocN(sizeof(SceneStats), "SceneStats");
*(scene->stats)= stats;
*(scene->stats) = stats;
}
static void stats_string(Scene *scene)
{
SceneStats *stats= scene->stats;
Object *ob= (scene->basact)? scene->basact->object: NULL;
SceneStats *stats = scene->stats;
Object *ob = (scene->basact) ? scene->basact->object : NULL;
uintptr_t mem_in_use, mmap_in_use;
char memstr[64];
char *s;
mem_in_use= MEM_get_memory_in_use();
mmap_in_use= MEM_get_mapped_memory_in_use();
mem_in_use = MEM_get_memory_in_use();
mmap_in_use = MEM_get_mapped_memory_in_use();
/* get memory statistics */
s= memstr + sprintf(memstr, " | Mem:%.2fM", (double)((mem_in_use-mmap_in_use)>>10)/1024.0);
s = memstr + sprintf(memstr, " | Mem:%.2fM", (double)((mem_in_use - mmap_in_use) >> 10) / 1024.0);
if (mmap_in_use)
sprintf(s, " (%.2fM)", (double)((mmap_in_use)>>10)/1024.0);
sprintf(s, " (%.2fM)", (double)((mmap_in_use) >> 10) / 1024.0);
s= stats->infostr;
s = stats->infostr;
s+= sprintf(s, "%s | ", versionstr);
s += sprintf(s, "%s | ", versionstr);
if (scene->obedit) {
if (ob_get_keyblock(scene->obedit))
s+= sprintf(s, "(Key) ");
s += sprintf(s, "(Key) ");
if (scene->obedit->type==OB_MESH) {
if (scene->obedit->type == OB_MESH) {
if (scene->toolsettings->selectmode & SCE_SELECT_VERTEX)
s+= sprintf(s, "Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
s += sprintf(s, "Ve:%d-%d | Ed:%d-%d | Fa:%d-%d",
stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
else if (scene->toolsettings->selectmode & SCE_SELECT_EDGE)
s+= sprintf(s, "Ed:%d-%d | Fa:%d-%d",
stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
s += sprintf(s, "Ed:%d-%d | Fa:%d-%d",
stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface);
else
s+= sprintf(s, "Fa:%d-%d", stats->totfacesel, stats->totface);
s += sprintf(s, "Fa:%d-%d", stats->totfacesel, stats->totface);
}
else if (scene->obedit->type==OB_ARMATURE) {
s+= sprintf(s, "Ve:%d-%d | Bo:%d-%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone);
else if (scene->obedit->type == OB_ARMATURE) {
s += sprintf(s, "Ve:%d-%d | Bo:%d-%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone);
}
else {
s+= sprintf(s, "Ve:%d-%d", stats->totvertsel, stats->totvert);
s += sprintf(s, "Ve:%d-%d", stats->totvertsel, stats->totvert);
}
strcat(s, memstr);
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
s += sprintf(s, "Bo:%d-%d %s",
stats->totbonesel, stats->totbone, memstr);
stats->totbonesel, stats->totbone, memstr);
}
else {
s += sprintf(s, "Ve:%d | Fa:%d | Ob:%d-%d | La:%d%s",
stats->totvert, stats->totface, stats->totobjsel, stats->totobj, stats->totlamp, memstr);
stats->totvert, stats->totface, stats->totobjsel, stats->totobj, stats->totlamp, memstr);
}
if (ob)
sprintf(s, " | %s", ob->id.name+2);
sprintf(s, " | %s", ob->id.name + 2);
}
void ED_info_stats_clear(Scene *scene)
{
if (scene->stats) {
MEM_freeN(scene->stats);
scene->stats= NULL;
scene->stats = NULL;
}
}

View File

@@ -57,7 +57,7 @@
#include "UI_interface.h"
#include "UI_view2d.h"
#include "info_intern.h" // own include
#include "info_intern.h" /* own include */
/* ******************** default callbacks for info space ***************** */
@@ -66,31 +66,31 @@ static SpaceLink *info_new(const bContext *UNUSED(C))
ARegion *ar;
SpaceInfo *sinfo;
sinfo= MEM_callocN(sizeof(SpaceInfo), "initinfo");
sinfo->spacetype= SPACE_INFO;
sinfo = MEM_callocN(sizeof(SpaceInfo), "initinfo");
sinfo->spacetype = SPACE_INFO;
sinfo->rpt_mask= INFO_RPT_OP;
sinfo->rpt_mask = INFO_RPT_OP;
/* header */
ar= MEM_callocN(sizeof(ARegion), "header for info");
ar = MEM_callocN(sizeof(ARegion), "header for info");
BLI_addtail(&sinfo->regionbase, ar);
ar->regiontype= RGN_TYPE_HEADER;
ar->alignment= RGN_ALIGN_BOTTOM;
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_BOTTOM;
/* main area */
ar= MEM_callocN(sizeof(ARegion), "main area for info");
ar = MEM_callocN(sizeof(ARegion), "main area for info");
BLI_addtail(&sinfo->regionbase, ar);
ar->regiontype= RGN_TYPE_WINDOW;
ar->regiontype = RGN_TYPE_WINDOW;
/* keep in sync with console */
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
ar->v2d.align |= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */
ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
ar->v2d.keepofs |= V2D_LOCKOFS_X;
ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS;
ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
//ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
@@ -114,7 +114,7 @@ static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
static SpaceLink *info_duplicate(SpaceLink *sl)
{
SpaceInfo *sinfon= MEM_dupallocN(sl);
SpaceInfo *sinfon = MEM_dupallocN(sl);
/* clear or remove stuff from old */
@@ -137,17 +137,17 @@ static void info_main_area_init(wmWindowManager *wm, ARegion *ar)
static void info_textview_update_rect(const bContext *C, ARegion *ar)
{
SpaceInfo *sinfo= CTX_wm_space_info(C);
View2D *v2d= &ar->v2d;
SpaceInfo *sinfo = CTX_wm_space_info(C);
View2D *v2d = &ar->v2d;
UI_view2d_totRect_set(v2d, ar->winx-1, info_textview_height(sinfo, ar, CTX_wm_reports(C)));
UI_view2d_totRect_set(v2d, ar->winx - 1, info_textview_height(sinfo, ar, CTX_wm_reports(C)));
}
static void info_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceInfo *sinfo= CTX_wm_space_info(C);
View2D *v2d= &ar->v2d;
SpaceInfo *sinfo = CTX_wm_space_info(C);
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
/* clear and setup matrix */
@@ -169,7 +169,7 @@ static void info_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
@@ -231,7 +231,7 @@ static void info_main_area_listener(ARegion *ar, wmNotifier *wmn)
// SpaceInfo *sinfo= sa->spacedata.first;
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SPACE:
if (wmn->data == ND_SPACE_INFO_REPORT) {
/* redraw also but only for report view, could do less redraws by checking the type */
@@ -244,7 +244,7 @@ static void info_main_area_listener(ARegion *ar, wmNotifier *wmn)
static void info_header_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch(wmn->category) {
switch (wmn->category) {
case NC_SCREEN:
if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY))
ED_region_tag_redraw(ar);
@@ -254,7 +254,7 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
if (wmn->data==ND_RENDER_RESULT)
if (wmn->data == ND_RENDER_RESULT)
ED_region_tag_redraw(ar);
break;
case NC_SPACE:
@@ -271,7 +271,7 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
{
struct RecentFile *recent;
uiLayout *layout= menu->layout;
uiLayout *layout = menu->layout;
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
if (G.recent_files.first) {
for (recent = G.recent_files.first; (recent); recent = recent->next) {
@@ -287,49 +287,49 @@ static void recent_files_menu_register(void)
{
MenuType *mt;
mt= MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
mt = MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
strcpy(mt->idname, "INFO_MT_file_open_recent");
strcpy(mt->label, N_("Open Recent..."));
mt->draw= recent_files_menu_draw;
mt->draw = recent_files_menu_draw;
WM_menutype_add(mt);
}
/* only called once, from space/spacetypes.c */
void ED_spacetype_info(void)
{
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype info");
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype info");
ARegionType *art;
st->spaceid= SPACE_INFO;
st->spaceid = SPACE_INFO;
strncpy(st->name, "Info", BKE_ST_MAXNAME);
st->new= info_new;
st->free= info_free;
st->init= info_init;
st->duplicate= info_duplicate;
st->operatortypes= info_operatortypes;
st->keymap= info_keymap;
st->new = info_new;
st->free = info_free;
st->init = info_init;
st->duplicate = info_duplicate;
st->operatortypes = info_operatortypes;
st->keymap = info_keymap;
/* regions: main window */
art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
art->regionid = RGN_TYPE_WINDOW;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
art->init= info_main_area_init;
art->draw= info_main_area_draw;
art->listener= info_main_area_listener;
art->init = info_main_area_init;
art->draw = info_main_area_draw;
art->listener = info_main_area_listener;
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey= HEADERY;
art->prefsizey = HEADERY;
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
art->listener= info_header_listener;
art->init= info_header_area_init;
art->draw= info_header_area_draw;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->listener = info_header_listener;
art->init = info_header_area_init;
art->draw = info_header_area_draw;
BLI_addhead(&st->regiontypes, art);

View File

@@ -47,7 +47,7 @@
static void console_font_begin(TextViewContext *sc)
{
BLF_size(blf_mono_font, sc->lheight-2, 72);
BLF_size(blf_mono_font, sc->lheight - 2, 72);
}
typedef struct ConsoleDrawContext {
@@ -71,14 +71,14 @@ static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth
glEnable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipple_halftone);
glEnable( GL_BLEND );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub(255, 255, 255, 96);
glRecti(xy[0]+(cwidth*sta), xy[1]-2 + lheight, xy[0]+(cwidth*end), xy[1]-2);
glRecti(xy[0] + (cwidth * sta), xy[1] - 2 + lheight, xy[0] + (cwidth * end), xy[1] - 2);
glDisable(GL_POLYGON_STIPPLE);
glDisable( GL_BLEND );
glDisable(GL_BLEND);
}
}
@@ -89,13 +89,13 @@ static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth
static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str_len, unsigned char *fg, unsigned char *bg)
{
#define STEP_SEL(value) cdc->sel[0] += (value); cdc->sel[1] += (value)
int rct_ofs= cdc->lheight/4;
int tot_lines = (str_len/cdc->console_width)+1; /* total number of lines for wrapping */
int y_next = (str_len > cdc->console_width) ? cdc->xy[1]+cdc->lheight*tot_lines : cdc->xy[1]+cdc->lheight;
const int mono= blf_mono_font;
int rct_ofs = cdc->lheight / 4;
int tot_lines = (str_len / cdc->console_width) + 1; /* total number of lines for wrapping */
int y_next = (str_len > cdc->console_width) ? cdc->xy[1] + cdc->lheight * tot_lines : cdc->xy[1] + cdc->lheight;
const int mono = blf_mono_font;
/* just advance the height */
if (cdc->draw==0) {
if (cdc->draw == 0) {
if (cdc->pos_pick && (cdc->mval[1] != INT_MAX)) {
if (cdc->xy[1] <= cdc->mval[1]) {
if ((y_next >= cdc->mval[1])) {
@@ -103,7 +103,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
/* wrap */
if (str_len > cdc->console_width)
ofs += (cdc->console_width * ((int)((((float)(y_next - cdc->mval[1]) / (float)(y_next-cdc->xy[1])) * tot_lines))));
ofs += (cdc->console_width * ((int)((((float)(y_next - cdc->mval[1]) / (float)(y_next - cdc->xy[1])) * tot_lines))));
CLAMP(ofs, 0, str_len);
*cdc->pos_pick += str_len - ofs;
@@ -113,12 +113,12 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
}
}
cdc->xy[1]= y_next;
cdc->xy[1] = y_next;
return 1;
}
else if (y_next-cdc->lheight < cdc->ymin) {
else if (y_next - cdc->lheight < cdc->ymin) {
/* have not reached the drawable area so don't break */
cdc->xy[1]= y_next;
cdc->xy[1] = y_next;
/* adjust selection even if not drawing */
if (cdc->sel[0] != cdc->sel[1]) {
@@ -129,8 +129,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
}
if (str_len > cdc->console_width) { /* wrap? */
const int initial_offset= ((tot_lines-1) * cdc->console_width);
const char *line_stride= str + initial_offset; /* advance to the last line and draw it first */
const int initial_offset = ((tot_lines - 1) * cdc->console_width);
const char *line_stride = str + initial_offset; /* advance to the last line and draw it first */
int sel_orig[2];
copy_v2_v2_int(sel_orig, cdc->sel);
@@ -141,7 +141,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
if (bg) {
glColor3ubv(bg);
glRecti(0, cdc->xy[1]-rct_ofs, cdc->winx, (cdc->xy[1]+(cdc->lheight*tot_lines))+rct_ofs);
glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, (cdc->xy[1] + (cdc->lheight * tot_lines)) + rct_ofs);
}
glColor3ubv(fg);
@@ -187,7 +187,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
if (bg) {
glColor3ubv(bg);
glRecti(0, cdc->xy[1]-rct_ofs, cdc->winx, cdc->xy[1]+cdc->lheight-rct_ofs);
glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, cdc->xy[1] + cdc->lheight - rct_ofs);
}
glColor3ubv(fg);
@@ -198,8 +198,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
if (cdc->sel[0] != cdc->sel[1]) {
int isel[2];
isel[0]= str_len - cdc->sel[1];
isel[1]= str_len - cdc->sel[0];
isel[0] = str_len - cdc->sel[1];
isel[1] = str_len - cdc->sel[0];
// glColor4ub(255, 255, 0, 96); // debug
console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight);
@@ -221,17 +221,17 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick, int *pos_pick)
{
ConsoleDrawContext cdc= {0};
ConsoleDrawContext cdc = {0};
int x_orig=CONSOLE_DRAW_MARGIN, y_orig=CONSOLE_DRAW_MARGIN + tvc->lheight/6;
int x_orig = CONSOLE_DRAW_MARGIN, y_orig = CONSOLE_DRAW_MARGIN + tvc->lheight / 6;
int xy[2], y_prev;
int sel[2]= {-1, -1}; /* defaults disabled */
int sel[2] = {-1, -1}; /* defaults disabled */
unsigned char fg[3], bg[3];
const int mono= blf_mono_font;
const int mono = blf_mono_font;
console_font_begin(tvc);
xy[0]= x_orig; xy[1]= y_orig;
xy[0] = x_orig; xy[1] = y_orig;
if (mval[1] != INT_MAX)
mval[1] += (tvc->ymin + CONSOLE_DRAW_MARGIN);
@@ -240,28 +240,28 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick
*pos_pick = 0;
/* constants for the sequencer context */
cdc.cwidth= (int)BLF_fixed_width(mono);
cdc.cwidth = (int)BLF_fixed_width(mono);
assert(cdc.cwidth > 0);
cdc.lheight= tvc->lheight;
cdc.console_width= (tvc->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN*2) ) / cdc.cwidth;
cdc.lheight = tvc->lheight;
cdc.console_width = (tvc->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN * 2) ) / cdc.cwidth;
CLAMP(cdc.console_width, 1, INT_MAX); /* avoid divide by zero on small windows */
cdc.winx= tvc->winx-(CONSOLE_DRAW_MARGIN+CONSOLE_DRAW_SCROLL);
cdc.winx = tvc->winx - (CONSOLE_DRAW_MARGIN + CONSOLE_DRAW_SCROLL);
cdc.ymin = tvc->ymin;
cdc.ymax = tvc->ymax;
cdc.xy= xy;
cdc.sel= sel;
cdc.pos_pick= pos_pick;
cdc.mval= mval;
cdc.draw= draw;
cdc.xy = xy;
cdc.sel = sel;
cdc.pos_pick = pos_pick;
cdc.mval = mval;
cdc.draw = draw;
/* shouldnt be needed */
tvc->cwidth= cdc.cwidth;
tvc->console_width= cdc.console_width;
tvc->iter_index= 0;
tvc->cwidth = cdc.cwidth;
tvc->console_width = cdc.console_width;
tvc->iter_index = 0;
if (tvc->sel_start != tvc->sel_end) {
sel[0]= tvc->sel_start;
sel[1]= tvc->sel_end;
sel[0] = tvc->sel_start;
sel[1] = tvc->sel_end;
}
if (tvc->begin(tvc)) {
@@ -269,12 +269,12 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick
do {
const char *ext_line;
int ext_len;
int color_flag= 0;
int color_flag = 0;
y_prev= xy[1];
y_prev = xy[1];
if (draw)
color_flag= tvc->line_color(tvc, fg, bg);
color_flag = tvc->line_color(tvc, fg, bg);
tvc->line_get(tvc, &ext_line, &ext_len);
@@ -286,7 +286,7 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick
}
if ((mval[1] != INT_MAX) && (mval[1] >= y_prev && mval[1] <= xy[1])) {
*mouse_pick= (void *)tvc->iter;
*mouse_pick = (void *)tvc->iter;
break;
}