diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 00b060b836b..7fa601c749d 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -214,6 +214,7 @@ typedef struct uiLayout uiLayout; #define LISTBOX (43<<9) #define LISTROW (44<<9) #define HOTKEYEVT (45<<9) +#define BUT_IMAGE (46<<9) #define BUTTYPE (63<<9) @@ -271,6 +272,8 @@ void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg); void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext); void uiPupBlockOperator(struct bContext *C, uiBlockCreateFunc func, struct wmOperator *op, int opcontext); +void uiPupBlockClose(struct bContext *C, uiBlock *block); + /* Blocks * * Functions for creating, drawing and freeing blocks. A Block is a @@ -303,10 +306,20 @@ void uiBlockClearButLock(uiBlock *block); void uiBlockBeginAlign(uiBlock *block); void uiBlockEndAlign(uiBlock *block); +/* block bounds/position calculation */ +enum { + UI_BLOCK_BOUNDS=1, + UI_BLOCK_BOUNDS_TEXT, + UI_BLOCK_BOUNDS_POPUP_MOUSE, + UI_BLOCK_BOUNDS_POPUP_MENU, + UI_BLOCK_BOUNDS_POPUP_CENTER, +} eBlockBoundsCalc; + void uiBoundsBlock(struct uiBlock *block, int addval); void uiTextBoundsBlock(uiBlock *block, int addval); void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my); void uiMenuPopupBoundsBlock(uiBlock *block, int addvall, int mx, int my); +void uiCenteredBoundsBlock(uiBlock *block, int addval); int uiBlocksGetYMin (struct ListBase *lb); @@ -532,7 +545,8 @@ void uiEndPanel(uiBlock *block, int width, int height); void UI_add_region_handlers(struct ListBase *handlers); void UI_add_area_handlers(struct ListBase *handlers); -void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *menu); +void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *popup); +void UI_remove_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *popup); /* Module * diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b9f80946345..f8490204968 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -313,7 +313,30 @@ void ui_bounds_block(uiBlock *block) block->safety.ymax= block->maxy+xof; } -static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int menu) +static void ui_centered_bounds_block(const bContext *C, uiBlock *block) +{ + wmWindow *window= CTX_wm_window(C); + int xmax, ymax; + int startx, starty; + int width, height; + + wm_window_get_size(window, &xmax, &ymax); + + ui_bounds_block(block); + + width= block->maxx - block->minx; + height= block->maxy - block->miny; + + startx = (xmax * 0.5f) - (width * 0.5f); + starty = (ymax * 0.5f) - (height * 0.5f); + + ui_block_translate(block, startx - block->minx, starty - block->miny); + + /* now recompute bounds and safety */ + ui_bounds_block(block); + +} +static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_calc) { wmWindow *window= CTX_wm_window(C); int startx, starty, endx, endy, width, height; @@ -323,13 +346,14 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int menu) /* compute mouse position with user defined offset */ ui_bounds_block(block); - mx= window->eventstate->x + block->minx + block->mx; - my= window->eventstate->y + block->miny + block->my; - + wm_window_get_size(window, &xmax, &ymax); + mx= window->eventstate->x + block->minx + block->mx; + my= window->eventstate->y + block->miny + block->my; + /* first we ensure wide enough text bounds */ - if(menu) { + if(bounds_calc==UI_BLOCK_BOUNDS_POPUP_MENU) { if(block->flag & UI_BLOCK_LOOP) { block->bounds= 50; ui_text_bounds_block(block, block->minx); @@ -377,21 +401,21 @@ void uiBoundsBlock(uiBlock *block, int addval) return; block->bounds= addval; - block->dobounds= 1; + block->dobounds= UI_BLOCK_BOUNDS; } /* used for pulldowns */ void uiTextBoundsBlock(uiBlock *block, int addval) { block->bounds= addval; - block->dobounds= 2; + block->dobounds= UI_BLOCK_BOUNDS_TEXT; } /* used for block popups */ void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my) { block->bounds= addval; - block->dobounds= 3; + block->dobounds= UI_BLOCK_BOUNDS_POPUP_MOUSE; block->mx= mx; block->my= my; } @@ -400,11 +424,18 @@ void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my) void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my) { block->bounds= addval; - block->dobounds= 4; + block->dobounds= UI_BLOCK_BOUNDS_POPUP_MENU; block->mx= mx; block->my= my; } +/* used for centered popups, i.e. splash */ +void uiCenteredBoundsBlock(uiBlock *block, int addval) +{ + block->bounds= addval; + block->dobounds= UI_BLOCK_BOUNDS_POPUP_CENTER; +} + /* ************** LINK LINE DRAWING ************* */ /* link line drawing is not part of buttons or theme.. so we stick with it here */ @@ -627,9 +658,10 @@ void uiEndBlock(const bContext *C, uiBlock *block) if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block); /* after keymaps! */ - if(block->dobounds == 1) ui_bounds_block(block); - else if(block->dobounds == 2) ui_text_bounds_block(block, 0.0f); - else if(block->dobounds) ui_popup_bounds_block(C, block, (block->dobounds == 4)); + if(block->dobounds == UI_BLOCK_BOUNDS) ui_bounds_block(block); + else if(block->dobounds == UI_BLOCK_BOUNDS_TEXT) ui_text_bounds_block(block, 0.0f); + else if(block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); + else if(block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0); if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index a233a84e6c8..92bbd1c6573 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -43,6 +43,9 @@ #include "BKE_texture.h" #include "BKE_utildefines.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + #include "BIF_gl.h" #include "BIF_glutil.h" @@ -458,8 +461,47 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel) } -/* ************** TEXT AND ICON DRAWING FUNCTIONS ************* */ +/* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */ +void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect) +{ + extern char datatoc_splash_png[]; + extern int datatoc_splash_png_size; + ImBuf *ibuf; + GLint scissor[4]; + int w, h; + + /* hardcoded to splash, loading and freeing every draw, eek! */ + ibuf= IMB_ibImageFromMemory((int *)datatoc_splash_png, datatoc_splash_png_size, IB_rect); + + if (!ibuf) return; + + /* scissor doesn't seem to be doing the right thing...? + //glColor4f(1.0, 0.f, 0.f, 1.f); + //fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax) + + w = (rect->xmax - rect->xmin); + h = (rect->ymax - rect->ymin); + // prevent drawing outside widget area + glGetIntegerv(GL_SCISSOR_BOX, scissor); + glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h); + */ + + glEnable(GL_BLEND); + glColor4f(0.0, 0.0, 0.0, 0.0); + + glaDrawPixelsSafe((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + //glaDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); + + glDisable(GL_BLEND); + + /* + // restore scissortest + glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + */ + + IMB_freeImBuf(ibuf); +} #if 0 #ifdef INTERNATIONAL diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6ae5cab1a18..fafa8047a00 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -183,8 +183,6 @@ typedef struct uiAfterFunc { static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y); static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state); static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata); -static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata); -static void ui_handler_remove_popup(bContext *C, void *userdata); static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type); static void button_timers_tooltip_remove(bContext *C, uiBut *but); @@ -754,6 +752,13 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data) data->applied= 1; } +static void ui_apply_but_IMAGE(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) { @@ -874,6 +879,9 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut case INLINK: ui_apply_but_LINK(C, but, data); break; + case BUT_IMAGE: + ui_apply_but_IMAGE(C, but, data); + break; default: break; } @@ -3356,7 +3364,7 @@ static uiBlock *menu_change_hotkey(bContext *C, ARegion *ar, void *arg_but) dummy[1]= 0; block= uiBeginBlock(C, ar, "_popup", UI_EMBOSSP); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_MOVEMOUSE_QUIT|UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_MOVEMOUSE_QUIT|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); BLI_strncpy(buf, ot->name, OP_MAX_TYPENAME); strcat(buf, " |"); @@ -3647,6 +3655,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) case TOG3: case ROW: case LISTROW: + case BUT_IMAGE: retval= ui_do_but_EXIT(C, but, data, event); break; case TEX: @@ -4982,7 +4991,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata) uiPopupBlockHandle temp= *menu; ui_popup_block_free(C, menu); - WM_event_remove_ui_handler(&CTX_wm_window(C)->modalhandlers, ui_handler_popup, ui_handler_remove_popup, menu); + UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu); if(temp.menuretval == UI_RETURN_OK) { if(temp.popup_func) @@ -5023,8 +5032,14 @@ void UI_add_region_handlers(ListBase *handlers) WM_event_add_ui_handler(NULL, handlers, ui_handler_region, ui_handler_remove_region, NULL); } -void UI_add_popup_handlers(bContext *C, ListBase *handlers, uiPopupBlockHandle *menu) +void UI_add_popup_handlers(bContext *C, ListBase *handlers, uiPopupBlockHandle *popup) { - WM_event_add_ui_handler(C, handlers, ui_handler_popup, ui_handler_remove_popup, menu); + WM_event_add_ui_handler(C, handlers, ui_handler_popup, ui_handler_remove_popup, popup); } +void UI_remove_popup_handlers(ListBase *handlers, uiPopupBlockHandle *popup) +{ + WM_event_remove_ui_handler(handlers, ui_handler_popup, ui_handler_remove_popup, popup); +} + + diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 3c3b289a945..21425bbb261 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -427,6 +427,7 @@ extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float 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); /* interface_handlers.c */ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 2c4fb71af75..c3eac3f3893 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1303,7 +1303,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut bt->y2 -= ar->winrct.ymin; } - block->flag |= UI_BLOCK_LOOP|UI_BLOCK_MOVEMOUSE_QUIT; + block->flag |= UI_BLOCK_LOOP; /* adds subwindow */ ED_region_init(C, ar); @@ -1338,6 +1338,8 @@ static void ui_block_func_MENUSTR(bContext *C, uiLayout *layout, void *arg_str) char *instr= arg_str; int columns, rows, a, b; + uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); + /* compute menu data */ md= decompose_menu_string(instr); @@ -1414,6 +1416,8 @@ void ui_block_func_ICONROW(bContext *C, uiLayout *layout, void *arg_but) uiBut *but= arg_but; int a; + uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); + for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, 0, UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float)a, 0.0, 0, 0, ""); @@ -1427,6 +1431,8 @@ void ui_block_func_ICONTEXTROW(bContext *C, uiLayout *layout, void *arg_but) MenuData *md; MenuEntry *entry; int a; + + uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); md= decompose_menu_string(but->str); @@ -1994,6 +2000,8 @@ uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_bu block= uiBeginBlock(C, handle->region, "colorpicker", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); + VECCOPY(handle->retvec, but->editvec); if(win->eventstate->shift) { uiBlockPickerButtons(block, handle->retvec, hsvcol, oldcol, hexcol, 'p', 0); @@ -2195,6 +2203,8 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi uiBlockLayoutResolve(block, NULL, NULL); + uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); + if(pup->popup) { uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1); uiBlockSetDirection(block, direction); @@ -2548,3 +2558,11 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int WM_event_add_mousemove(C); } +void uiPupBlockClose(bContext *C, uiBlock *block) +{ + if(block->handle) { + UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, block->handle); + ui_popup_block_free(C, block->handle); + } +} + diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index fa577f6be66..e148fd9217f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2553,6 +2553,10 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct ui_draw_but_NORMAL(but, &tui->wcol_regular, rect); break; + case BUT_IMAGE: + ui_draw_but_IMAGE(ar, but, &tui->wcol_regular, rect); + break; + case BUT_CURVE: ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect); break; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index d4ba83b2886..a99c90e01a1 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -52,6 +52,8 @@ void WM_init (struct bContext *C); void WM_exit (struct bContext *C); void WM_main (struct bContext *C); +void WM_init_splash (struct bContext *C); + void WM_check (struct bContext *C); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 06227086006..d5fe9d324c4 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -151,6 +151,19 @@ void WM_init(bContext *C) read_Blog(); BLI_strncpy(G.lib, G.sce, FILE_MAX); + +} + +void WM_init_splash(bContext *C) +{ + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *prevwin= CTX_wm_window(C); + + if(wm->windows.first) { + CTX_wm_window_set(C, wm->windows.first); + WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL); + CTX_wm_window_set(C, prevwin); + } } /* free strings of open recent files */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1b334bc778f..8eb980d0112 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -704,7 +704,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) block= uiBeginBlock(C, ar, "redo_popup", UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); uiBlockSetHandleFunc(block, redo_cb, arg_op); if(!op->properties) { @@ -764,7 +764,7 @@ static uiBlock *wm_block_create_menu(bContext *C, ARegion *ar, void *arg_op) block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style); uiItemL(layout, op->type->name, 0); @@ -813,6 +813,71 @@ static void WM_OT_debug_menu(wmOperatorType *ot) RNA_def_int(ot->srna, "debugval", 0, -10000, 10000, "Debug Value", "", INT_MIN, INT_MAX); } + +/* ***************** Splash Screen ************************* */ + +static void wm_block_splash_close(bContext *C, void *arg_block, void *arg_unused) +{ + uiPupBlockClose(C, arg_block); +} + +static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unused) +{ + uiBlock *block; + uiBut *but; + uiLayout *layout, *split, *col; + uiStyle *style= U.uistyles.first; + + block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1); + + but= uiDefBut(block, BUT_IMAGE, 0, "", 0, 10, 501, 282, NULL, 0.0, 0.0, 0, 0, ""); + uiButSetFunc(but, wm_block_splash_close, block, NULL); + + uiBlockSetEmboss(block, UI_EMBOSSP); + + layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 10, 10, 480, 110, style); + + uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); + + split = uiLayoutSplit(layout, 0); + col = uiLayoutColumn(split, 0); + uiItemL(col, "Links", 0); + uiItemO(col, NULL, ICON_URL, "HELP_OT_release_logs"); + uiItemO(col, NULL, ICON_URL, "HELP_OT_manual"); + uiItemO(col, NULL, ICON_URL, "HELP_OT_blender_website"); + uiItemO(col, NULL, ICON_URL, "HELP_OT_user_community"); + uiItemS(col); + + col = uiLayoutColumn(split, 0); + uiItemL(col, "Recent", 0); + uiItemsEnumO(col, "WM_OT_open_recentfile_splash", "file"); + uiItemS(col); + + uiCenteredBoundsBlock(block, 0.0f); + uiEndBlock(C, block); + + return block; +} + +static int wm_splash_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + uiPupBlock(C, wm_block_create_splash, NULL); + + return OPERATOR_FINISHED; +} + +static void WM_OT_splash(wmOperatorType *ot) +{ + ot->name= "Splash Screen"; + ot->idname= "WM_OT_splash"; + ot->description= "Opens a blocking popup region with release info"; + + ot->invoke= wm_splash_invoke; + ot->poll= WM_operator_winactive; +} + + /* ***************** Search menu ************************* */ static void operator_call_cb(struct bContext *C, void *arg1, void *arg2) { @@ -858,7 +923,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *arg_op) uiBut *but; block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT); but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 10, 180, 19, ""); uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL); @@ -1018,6 +1083,7 @@ static EnumPropertyItem *open_recentfile_itemf(bContext *C, PointerRNA *ptr, int /* dynamically construct enum */ for(recent = G.recent_files.first, i=0; (inext, i++) { tmp.value= i+1; + tmp.icon= ICON_FILE_BLEND; tmp.identifier= recent->filename; tmp.name= BLI_short_filename(recent->filename); RNA_enum_item_add(&item, &totitem, &tmp); @@ -1047,6 +1113,45 @@ static void WM_OT_open_recentfile(wmOperatorType *ot) RNA_def_enum_funcs(prop, open_recentfile_itemf); } +static EnumPropertyItem *open_recentfile_splash_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + EnumPropertyItem tmp = {0, "", 0, "", ""}; + EnumPropertyItem *item= NULL; + struct RecentFile *recent; + int totitem= 0, i; + + /* dynamically construct enum */ + for(recent = G.recent_files.first, i=0; (i<6) && (recent); recent = recent->next, i++) { + tmp.value= i+1; + tmp.icon= ICON_FILE_BLEND; + tmp.identifier= recent->filename; + tmp.name= BLI_last_slash(recent->filename)+1; + RNA_enum_item_add(&item, &totitem, &tmp); + } + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; +} + +static void WM_OT_open_recentfile_splash(wmOperatorType *ot) +{ + PropertyRNA *prop; + static EnumPropertyItem file_items[]= { + {0, NULL, 0, NULL, NULL}}; + + ot->name= "Open Recent File"; + ot->idname= "WM_OT_open_recentfile_splash"; + ot->description="Open recent files list."; + + ot->exec= recentfile_exec; + ot->poll= WM_operator_winactive; + + prop= RNA_def_enum(ot->srna, "file", file_items, 1, "File", ""); + RNA_def_enum_funcs(prop, open_recentfile_splash_itemf); +} + /* *************** open file **************** */ static void open_set_load_ui(wmOperator *op) @@ -2464,6 +2569,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_window_fullscreen_toggle); WM_operatortype_append(WM_OT_exit_blender); WM_operatortype_append(WM_OT_open_recentfile); + WM_operatortype_append(WM_OT_open_recentfile_splash); WM_operatortype_append(WM_OT_open_mainfile); WM_operatortype_append(WM_OT_link_append); WM_operatortype_append(WM_OT_recover_last_session); @@ -2473,6 +2579,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_redraw_timer); WM_operatortype_append(WM_OT_memory_statistics); WM_operatortype_append(WM_OT_debug_menu); + WM_operatortype_append(WM_OT_splash); WM_operatortype_append(WM_OT_search_menu); WM_operatortype_append(WM_OT_call_menu); @@ -2624,6 +2731,7 @@ void wm_window_keymap(wmKeyConfig *keyconf) /* debug/testing */ WM_keymap_verify_item(keymap, "WM_OT_redraw_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_verify_item(keymap, "WM_OT_splash", F1KEY, KM_PRESS, KM_ALT|KM_CTRL, 0); WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0); /* Space switching */ diff --git a/source/creator/creator.c b/source/creator/creator.c index 10674d830ba..3a9ee9859e8 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -278,7 +278,7 @@ int main(int argc, char **argv) { SYS_SystemHandle syshandle; bContext *C= CTX_create(); - int a, i, stax, stay, sizx, sizy /*XXX, scr_init = 0*/; + int a, i, stax, stay, sizx, sizy /*XXX, scr_init = 0*/, file_loaded= 0; #ifdef WITH_BINRELOC br_init( NULL ); @@ -880,6 +880,8 @@ int main(int argc, char **argv) a file - this should do everything a 'load file' does */ WM_read_file(C, filename, NULL); } + + file_loaded = 1; } } @@ -888,9 +890,12 @@ int main(int argc, char **argv) WM_exit(C); } + if(!G.background && !file_loaded) + WM_init_splash(C); WM_main(C); - + + /*XXX if (scr_init==0) { main_init_screen(); }