[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24809] trunk/blender/source: Splash screen, implemented by Matt.
Brecht Van Lommel
brecht at blender.org
Mon Nov 23 14:58:58 CET 2009
Revision: 24809
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24809
Author: blendix
Date: 2009-11-23 14:58:55 +0100 (Mon, 23 Nov 2009)
Log Message:
-----------
Splash screen, implemented by Matt.
* Now has documentation links and recent files.
* Click on image or outside splash to make it go away.
* Still has old image, new one will be committed later.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/UI_interface.h
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_draw.c
trunk/blender/source/blender/editors/interface/interface_handlers.c
trunk/blender/source/blender/editors/interface/interface_intern.h
trunk/blender/source/blender/editors/interface/interface_regions.c
trunk/blender/source/blender/editors/interface/interface_widgets.c
trunk/blender/source/blender/windowmanager/WM_api.h
trunk/blender/source/blender/windowmanager/intern/wm_init_exit.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
trunk/blender/source/creator/creator.c
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2009-11-23 13:52:08 UTC (rev 24808)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2009-11-23 13:58:55 UTC (rev 24809)
@@ -214,6 +214,7 @@
#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 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 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 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
*
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2009-11-23 13:52:08 UTC (rev 24808)
+++ trunk/blender/source/blender/editors/interface/interface.c 2009-11-23 13:58:55 UTC (rev 24809)
@@ -313,9 +313,32 @@
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;
int oldbounds, mx, my, xmax, ymax;
@@ -323,13 +346,14 @@
/* compute mouse position with user defined offset */
ui_bounds_block(block);
+
+ wm_window_get_size(window, &xmax, &ymax);
+
mx= window->eventstate->x + block->minx + block->mx;
my= window->eventstate->y + block->miny + block->my;
-
- wm_window_get_size(window, &xmax, &ymax);
-
+
/* 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 @@
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 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 @@
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);
Modified: trunk/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_draw.c 2009-11-23 13:52:08 UTC (rev 24808)
+++ trunk/blender/source/blender/editors/interface/interface_draw.c 2009-11-23 13:58:55 UTC (rev 24809)
@@ -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,9 +461,48 @@
}
-/* ************** 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
static void ui_draw_but_CHARTAB(uiBut *but)
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c 2009-11-23 13:52:08 UTC (rev 24808)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c 2009-11-23 13:58:55 UTC (rev 24809)
@@ -183,8 +183,6 @@
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,7 +752,14 @@
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)
{
char *editstr;
@@ -874,6 +879,9 @@
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 @@
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 @@
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 @@
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 @@
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)
+{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list