Nice goodie: Preview renders!

- Added new preview.blend, allowing super wide cinemascope previews
- Draws nicely blended inside widget type, rounded corners
- Preview now renders using all available cpus/cores.
- Uses - hopefully rock stable - method, which doesn't copy or 
  allocate anything for previews, but just uses render API calls.
- Multiple previews are possible! But, added provision in Jobs
  manager to only render one preview job at a time. If you start
  more preview jobs, they're suspended until it's their turn.

Bugfix: new buttons context code crashed when going full-window.

Tweaks are still needed for notifiers. I have to figure out still
how to retrieve SpaceButs button view types...
This commit is contained in:
2009-06-07 11:12:35 +00:00
parent 1bb8d745b9
commit a2f9ca3b3f
20 changed files with 15772 additions and 11899 deletions

View File

@@ -662,12 +662,16 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
else if(block->panel)
ui_draw_aligned_panel(ar, &style, block, &rect);
if(block->drawextra) block->drawextra(C, block);
/* widgets */
for(but= block->buttons.first; but; but= but->next) {
ui_but_to_pixelrect(&rect, ar, block, but);
ui_draw_but(ar, &style, but, &rect);
/* temp? roundbox defines size/location of preview, and ID type */
if(but->type==ROUNDBOX)
if(block->drawextra)
block->drawextra(C, but->poin, &rect);
}
/* restore matrix */
@@ -2968,7 +2972,7 @@ void uiBlockSetRenameFunc(uiBlock *block, uiButHandleRenameFunc func, void *arg1
}
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)())
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, rcti *rect))
{
block->drawextra= func;
}

View File

@@ -255,7 +255,7 @@ struct uiBlock {
void *handle_func_arg;
/* extra draw function for custom blocks */
void (*drawextra)();
void (*drawextra)(const struct bContext *C, void *idv, rcti *rect);
int afterval, flag;

View File

@@ -33,6 +33,7 @@
#include "BKE_utildefines.h"
#include "ED_screen.h"
#include "ED_previewrender.h"
#include "RNA_access.h"
@@ -1277,6 +1278,16 @@ uiLayout *uiTemplateGroup(uiLayout *layout, Object *ob, Group *group)
#define B_MATPRV 1
static void do_preview_buttons(bContext *C, void *arg, int event)
{
switch(event) {
case B_MATPRV:
WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, arg);
break;
}
}
void uiTemplatePreview(uiLayout *layout, ID *id)
{
uiLayout *row, *col;
@@ -1294,8 +1305,12 @@ void uiTemplatePreview(uiLayout *layout, ID *id)
col= uiLayoutColumn(row, 0);
uiLayoutSetKeepAspect(col, 1);
uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, id, 0.0, 0.0, 0, 0, "");
/* extra draw is tied to roundbox for now */
uiBlockSetDrawExtraFunc(block, ED_preview_draw);
uiBlockSetHandleFunc(block, do_preview_buttons, NULL);
if(GS(id->name) == ID_MA) {
ma= (Material*)id;