svn merge ^/trunk/blender -r41602:41638 .

This commit is contained in:
2011-11-08 02:57:28 +00:00
367 changed files with 76309 additions and 7120 deletions

View File

@@ -34,6 +34,7 @@
#include "DNA_color_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_movieclip_types.h"
#include "BLI_math.h"
#include "BLI_rect.h"
@@ -1501,6 +1502,114 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float zoomx, float zoomy)
{
ImBuf *scaleibuf;
int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy;
scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect);
for(y= 0; y<scaleibuf->y; y++) {
for (x= 0; x<scaleibuf->x; x++) {
int pixel= scaleibuf->x*y + x;
int orig_pixel= ibuf->x*(int)(((float)y)/zoomy) + (int)(((float)x)/zoomx);
char *rrgb= (char*)scaleibuf->rect + pixel*4;
char *orig_rrgb= (char*)ibuf->rect + orig_pixel*4;
rrgb[0]= orig_rrgb[0];
rrgb[1]= orig_rrgb[1];
rrgb[2]= orig_rrgb[2];
rrgb[3]= orig_rrgb[3];
}
}
return scaleibuf;
}
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
{
rctf rect;
int ok= 0;
GLint scissor[4];
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
rect.xmin = (float)recti->xmin+1;
rect.xmax = (float)recti->xmax-1;
rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2;
rect.ymax = (float)recti->ymax-1;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
/* need scissor test, preview image can draw outside of boundary */
glGetIntegerv(GL_VIEWPORT, scissor);
glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1));
if(scopes->track_disabled) {
glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
uiSetRoundBox(15);
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
ok= 1;
}
else if(scopes->track_preview) {
int a, off_x, off_y;
float zoomx, zoomy;
ImBuf *drawibuf;
glPushMatrix();
/* draw content of pattern area */
glScissor(ar->winrct.xmin+rect.xmin, ar->winrct.ymin+rect.ymin, scissor[2], scissor[3]);
zoomx= (rect.xmax-rect.xmin) / (scopes->track_preview->x-2.f);
zoomy= (rect.ymax-rect.ymin) / (scopes->track_preview->y-2.f);
off_x= ((int)scopes->track_pos[0]-scopes->track_pos[0]-0.5)*zoomx;
off_y= ((int)scopes->track_pos[1]-scopes->track_pos[1]-0.5)*zoomy;
drawibuf= scale_trackpreview_ibuf(scopes->track_preview, zoomx, zoomy);
glaDrawPixelsSafe(off_x+rect.xmin, off_y+rect.ymin, rect.xmax-rect.xmin+1.f-off_x, rect.ymax-rect.ymin+1.f-off_y, drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
IMB_freeImBuf(drawibuf);
/* draw cross for pizel position */
glTranslatef(off_x+rect.xmin+scopes->track_pos[0]*zoomx, off_y+rect.ymin+scopes->track_pos[1]*zoomy, 0.f);
glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin+rect.ymin, rect.xmax-rect.xmin, rect.ymax-rect.ymin);
for(a= 0; a< 2; a++) {
if(a==1) {
glLineStipple(3, 0xaaaa);
glEnable(GL_LINE_STIPPLE);
UI_ThemeColor(TH_SEL_MARKER);
}
else {
UI_ThemeColor(TH_MARKER_OUTLINE);
}
glBegin(GL_LINES);
glVertex2f(-10.0f, 0.0f);
glVertex2f(10.0f, 0.0f);
glVertex2f(0.0f, -10.0f);
glVertex2f(0.0f, 10.0f);
glEnd();
}
glDisable(GL_LINE_STIPPLE);
glPopMatrix();
ok= 1;
}
if(!ok) {
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(15);
uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
}
/* outline, scale gripper */
draw_scope_end(&rect, scissor);
glDisable(GL_BLEND);
}
/* ****************************************************** */

View File

@@ -56,6 +56,7 @@
#include "BKE_idprop.h"
#include "BKE_report.h"
#include "BKE_texture.h"
#include "BKE_tracking.h"
#include "BKE_unit.h"
#include "ED_screen.h"
@@ -259,7 +260,7 @@ static uiBut *ui_but_last(uiBlock *block)
static int ui_is_a_warp_but(uiBut *but)
{
if(U.uiflag & USER_CONTINUOUS_MOUSE)
if(ELEM3(but->type, NUM, NUMABS, HSVCIRCLE))
if(ELEM4(but->type, NUM, NUMABS, HSVCIRCLE, TRACKPREVIEW))
return TRUE;
return FALSE;
@@ -922,6 +923,13 @@ static void ui_apply_but_WAVEFORM(bContext *C, uiBut *but, uiHandleButtonData *d
data->applied= 1;
}
static void ui_apply_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
data->retval= but->retval;
data->applied= 1;
}
static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, int interactive)
{
@@ -1051,6 +1059,9 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
case WAVEFORM:
ui_apply_but_WAVEFORM(C, but, data);
break;
case TRACKPREVIEW:
ui_apply_but_TRACKPREVIEW(C, but, data);
break;
default:
break;
}
@@ -4254,6 +4265,88 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
return WM_UI_HANDLER_CONTINUE;
}
static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data, int mx, int my, int shift)
{
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
int changed= 1;
float dx, dy;
dx = mx - data->draglastx;
dy = my - data->draglasty;
if(shift) {
dx /= 5.0f;
dy /= 5.0f;
}
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize preview widget itself */
scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my);
} else {
if(scopes->marker) {
if(scopes->marker->framenr!=scopes->framenr)
scopes->marker= BKE_tracking_ensure_marker(scopes->track, scopes->framenr);
scopes->marker->flag&= ~(MARKER_DISABLED|MARKER_TRACKED);
scopes->marker->pos[0]+= -dx*scopes->slide_scale[0] / (but->block->maxx-but->block->minx);
scopes->marker->pos[1]+= -dy*scopes->slide_scale[1] / (but->block->maxy-but->block->miny);
WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL);
}
scopes->ok= 0;
}
data->draglastx= mx;
data->draglasty= my;
return changed;
}
static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
int mx, my;
mx= event->x;
my= event->y;
ui_window_to_block(data->region, block, &mx, &my);
if(data->state == BUTTON_STATE_HIGHLIGHT) {
if(event->type==LEFTMOUSE && event->val==KM_PRESS) {
data->dragstartx= mx;
data->dragstarty= my;
data->draglastx= mx;
data->draglasty= my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
if(ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
}
}
else if(data->state == BUTTON_STATE_NUM_EDITING) {
if(event->type == ESCKEY) {
data->cancel= 1;
data->escapecancel= 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if(event->type == MOUSEMOVE) {
if(mx!=data->draglastx || my!=data->draglasty) {
if(ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
}
}
else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
}
return WM_UI_HANDLER_CONTINUE;
}
static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
{
uiBut *but = (uiBut *)arg1;
@@ -4791,6 +4884,9 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
case INLINK:
retval= ui_do_but_LINK(C, but, data, event);
break;
case TRACKPREVIEW:
retval= ui_do_but_TRACKPREVIEW(C, block, but, data, event);
break;
}
return retval;

View File

@@ -79,6 +79,7 @@ typedef enum {
UI_WTYPE_MENU_RADIO,
UI_WTYPE_MENU_ICON_RADIO,
UI_WTYPE_MENU_POINTER_LINK,
UI_WTYPE_MENU_NODE_LINK,
UI_WTYPE_PULLDOWN,
UI_WTYPE_MENU_ITEM,
@@ -96,11 +97,6 @@ typedef enum {
} uiWidgetTypeEnum;
#define UI_MAX_DRAW_STR 400
#define UI_MAX_NAME_STR 128
/* panel limits */
#define UI_PANEL_MINX 100
#define UI_PANEL_MINY 70
@@ -454,6 +450,7 @@ void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect);
/* interface_handlers.c */
extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);

View File

@@ -1533,15 +1533,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
if(ELEM(but->type, BLOCK, PULLDOWN))
block->xofs = -2; /* for proper alignment */
/* only used for automatic toolbox, so can set the shift flag */
if(but->flag & UI_MAKE_TOP) {
block->direction= UI_TOP|UI_SHIFT_FLIPPED;
uiBlockFlipOrder(block);
}
if(but->flag & UI_MAKE_DOWN) block->direction= UI_DOWN|UI_SHIFT_FLIPPED;
if(but->flag & UI_MAKE_LEFT) block->direction |= UI_LEFT;
if(but->flag & UI_MAKE_RIGHT) block->direction |= UI_RIGHT;
ui_block_position(window, butregion, but, block);
}
else {

View File

@@ -2455,6 +2455,7 @@ void uiTemplateOperatorSearch(uiLayout *layout)
#define B_STOPANIM 3
#define B_STOPCOMPO 4
#define B_STOPSEQ 5
#define B_STOPCLIP 6
static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
{
@@ -2474,6 +2475,9 @@ static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
case B_STOPSEQ:
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
break;
case B_STOPCLIP:
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
break;
}
}
@@ -2499,6 +2503,10 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
if(WM_jobs_test(wm, sa))
owner = sa;
handle_event = B_STOPSEQ;
} else if(sa->spacetype==SPACE_CLIP) {
if(WM_jobs_test(wm, sa))
owner = sa;
handle_event= B_STOPCLIP;
} else {
Scene *scene;
/* another scene can be rendering too, for example via compositor */

View File

@@ -1181,6 +1181,12 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
widget_draw_icon(but, ICON_DOT, dualset?1.0f:0.25f, rect);
}
else if(but->type==MENU && (but->flag & UI_BUT_NODE_LINK)) {
int tmp = rect->xmin;
rect->xmin = rect->xmax - (rect->ymax - rect->ymin) - 1;
widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect);
rect->xmin = tmp;
}
/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
and offset the text label to accommodate it */
@@ -1543,6 +1549,10 @@ static void widget_state(uiWidgetType *wt, int state)
char red[4]= {255, 0, 0};
widget_state_blend(wt->wcol.inner, red, 0.4f);
}
if(state & UI_BUT_NODE_ACTIVE) {
char blue[4]= {86, 128, 194};
widget_state_blend(wt->wcol.inner, blue, 0.3f);
}
}
/* sliders use special hack which sets 'item' as inner when drawing filling */
@@ -2530,6 +2540,29 @@ static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
widgetbase_draw(&wtb, wcol);
}
static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
/* silly node link button hacks */
uiWidgetBase wtb;
uiWidgetColors wcol_backup= *wcol;
widget_init(&wtb);
/* half rounded */
round_box_edges(&wtb, roundboxalign, rect, 4.0f);
wcol->inner[0] += 15;
wcol->inner[1] += 15;
wcol->inner[2] += 15;
wcol->outline[0] += 15;
wcol->outline[1] += 15;
wcol->outline[2] += 15;
/* decoration */
widgetbase_draw(&wtb, wcol);
*wcol= wcol_backup;
}
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
{
if(state & UI_ACTIVE) {
@@ -2804,6 +2837,11 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_theme= &btheme->tui.wcol_menu;
wt.draw= widget_menubut;
break;
case UI_WTYPE_MENU_NODE_LINK:
wt.wcol_theme= &btheme->tui.wcol_menu;
wt.draw= widget_menunodebut;
break;
case UI_WTYPE_PULLDOWN:
wt.wcol_theme= &btheme->tui.wcol_pulldown;
@@ -2996,7 +3034,9 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case MENU:
case BLOCK:
case ICONTEXTROW:
if(!but->str[0] && but->icon)
if(but->flag & UI_BUT_NODE_LINK)
wt= widget_type(UI_WTYPE_MENU_NODE_LINK);
else if(!but->str[0] && but->icon)
wt= widget_type(UI_WTYPE_MENU_ICON_RADIO);
else
wt= widget_type(UI_WTYPE_MENU_RADIO);
@@ -3078,6 +3118,10 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
wt= widget_type(UI_WTYPE_SCROLL);
break;
case TRACKPREVIEW:
ui_draw_but_TRACKPREVIEW(ar, but, &tui->wcol_regular, rect);
break;
default:
wt= widget_type(UI_WTYPE_REGULAR);
}

View File

@@ -153,6 +153,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case SPACE_LOGIC:
ts= &btheme->tlogic;
break;
case SPACE_CLIP:
ts= &btheme->tclip;
break;
default:
ts= &btheme->tv3d;
break;
@@ -409,6 +412,27 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case TH_PREVIEW_BACK:
cp= ts->preview_back;
break;
case TH_MARKER_OUTLINE:
cp= ts->marker_outline; break;
case TH_MARKER:
cp= ts->marker; break;
case TH_ACT_MARKER:
cp= ts->act_marker; break;
case TH_SEL_MARKER:
cp= ts->sel_marker; break;
case TH_BUNDLE_SOLID:
cp= ts->bundle_solid; break;
case TH_DIS_MARKER:
cp= ts->dis_marker; break;
case TH_PATH_BEFORE:
cp= ts->path_before; break;
case TH_PATH_AFTER:
cp= ts->path_after; break;
case TH_CAMERA_PATH:
cp= ts->camera_path; break;
case TH_LOCK_MARKER:
cp= ts->lock_marker; break;
}
}
}
@@ -533,6 +557,7 @@ static void ui_theme_init_new(bTheme *btheme)
ui_theme_init_new_do(&btheme->tlogic);
ui_theme_init_new_do(&btheme->tuserpref);
ui_theme_init_new_do(&btheme->tconsole);
ui_theme_init_new_do(&btheme->tclip);
}
@@ -639,7 +664,9 @@ void ui_theme_init_default(void)
SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw
SETCOL(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
SETCOL(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
/* space buttons */
/* to have something initialized */
@@ -777,6 +804,23 @@ void ui_theme_init_default(void)
/* space logic */
btheme->tlogic= btheme->tv3d;
SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
/* space clip */
btheme->tclip= btheme->tv3d;
SETCOL(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
SETCOL(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
SETCOL(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
SETCOL(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
SETCOL(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
SETCOL(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
SETCOL(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
btheme->tclip.handle_vertex_size= 4;
}
@@ -1590,6 +1634,35 @@ void init_userdef_do_versions(void)
}
}
{
bTheme *btheme;
for(btheme= U.themes.first; btheme; btheme= btheme->next) {
if(btheme->tv3d.bundle_solid[3] == 0)
SETCOL(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
if(btheme->tv3d.camera_path[3] == 0)
SETCOL(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
if((btheme->tclip.back[3]) == 0) {
btheme->tclip= btheme->tv3d;
SETCOL(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
SETCOL(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
SETCOL(btheme->tclip.act_marker, 0xff, 0xff, 0xff, 255);
SETCOL(btheme->tclip.sel_marker, 0xff, 0xff, 0x00, 255);
SETCOL(btheme->tclip.dis_marker, 0x7f, 0x00, 0x00, 255);
SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255);
SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255);
SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255);
SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255);
SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
SETCOL(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
SETCOL(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
btheme->tclip.handle_vertex_size= 4;
}
}
}
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
U.texcollectrate = 60;