merge from trunk r37405

This commit is contained in:
Xiao Xiangquan
2011-06-15 08:28:56 +00:00
369 changed files with 7447 additions and 2867 deletions

View File

@@ -30,6 +30,9 @@ set(INC
../../makesrna
../../windowmanager
../../../../intern/guardedalloc
)
set(INC_SYS
${GLEW_INCLUDE_PATH}
)
@@ -44,4 +47,4 @@ set(SRC
screen_intern.h
)
blender_add_lib(bf_editor_screen "${SRC}" "${INC}")
blender_add_lib(bf_editor_screen "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -43,6 +43,8 @@
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BLF_api.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_screen.h"
@@ -650,8 +652,12 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
if(ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT)
alignment= RGN_ALIGN_NONE;
/* prefsize, for header we stick to exception */
prefsizex= ar->sizex?ar->sizex:ar->type->prefsizex;
prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey;
if(ar->regiontype==RGN_TYPE_HEADER)
prefsizey= ar->type->prefsizey;
else
prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey;
/* hidden is user flag */
if(ar->flag & RGN_FLAG_HIDDEN);
@@ -811,8 +817,18 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
ar->winrct.xmax= ar->winrct.xmin;
}
/* in end, add azones, where appropriate */
region_azone_add(sa, ar, alignment);
if(ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) {
/* The logic for this is: when the header takes up the full area,
* disallow hiding it to view the main window.
*
* Without this, uou can drag down the file selectors header and hide it
* by accident very easily (highly annoying!), the value 6 is arbitrary
* but accounts for small common rounding problems when scaling the UI,
* must be minimum '4' */
}
else {
region_azone_add(sa, ar, alignment);
}
region_rect_recursive(sa, ar->next, remainder, quad);
}
@@ -953,6 +969,9 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
uiFreeBlocks(NULL, &ar->uiblocks);
}
/* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */
if(ar->regiontype==RGN_TYPE_HEADER)
ar->v2d.flag &= ~V2D_IS_INITIALISED;
}
}
@@ -1121,7 +1140,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
/* tell WM to refresh, cursor types etc */
WM_event_add_mousemove(C);
/*send space change notifyer*/
/*send space change notifier*/
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa);
ED_area_tag_refresh(sa);
@@ -1148,7 +1167,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
}
ED_area_tag_redraw(sa);
/*send space change notifyer*/
/*send space change notifier*/
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa);
}
@@ -1196,7 +1215,7 @@ static void spacefunc(struct bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)
ED_area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype);
ED_area_tag_redraw(CTX_wm_area(C));
/*send space change notifyer*/
/*send space change notifier*/
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, CTX_wm_area(C));
}
@@ -1208,13 +1227,12 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
int xco= 8;
but= uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D,
editortype_pup(), xco, yco, XIC+10, YIC,
editortype_pup(), xco, yco, UI_UNIT_X+10, UI_UNIT_Y,
&(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0,
"Displays current editor type. "
"Click for menu of available types");
_("Displays current editor type. Click for menu of available types"));
uiButSetFunc(but, spacefunc, NULL, NULL);
return xco + XIC + 14;
return xco + UI_UNIT_X + 14;
}
int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
@@ -1230,21 +1248,21 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
if (sa->flag & HEADER_NO_PULLDOWN) {
uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
ICON_DISCLOSURE_TRI_RIGHT,
xco,yco,XIC,YIC-2,
xco,yco,UI_UNIT_X,UI_UNIT_Y-2,
&(sa->flag), 0, 0, 0, 0,
"Show pulldown menus");
}
else {
uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
ICON_DISCLOSURE_TRI_DOWN,
xco,yco,XIC,YIC-2,
xco,yco,UI_UNIT_X,UI_UNIT_Y-2,
&(sa->flag), 0, 0, 0, 0,
"Hide pulldown menus");
}
uiBlockSetEmboss(block, UI_EMBOSS);
return xco + XIC;
return xco + UI_UNIT_X;
}
/************************ standard UI regions ************************/
@@ -1265,11 +1283,11 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
if(vertical) {
w= v2d->cur.xmax - v2d->cur.xmin;
em= (ar->type->prefsizex)? 10: 20;
em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y;
}
else {
w= UI_PANEL_WIDTH;
em= (ar->type->prefsizex)? 10: 20;
em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y;
}
x= 0;
@@ -1293,8 +1311,8 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
panel= uiBeginPanel(sa, ar, block, pt, &open);
/* bad fixed values */
header= (pt->flag & PNL_NO_HEADER)? 0: 20;
triangle= 22;
header= (pt->flag & PNL_NO_HEADER)? 0: UI_UNIT_Y;
triangle= (int)(UI_UNIT_Y * 1.1f);
if(vertical)
y -= header;
@@ -1446,6 +1464,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
HeaderType *ht;
Header header = {NULL};
int maxco, xco, yco;
int headery= ED_area_headersize();
/* clear */
UI_ThemeClearColor((ED_screen_area_active(C))?TH_HEADER:TH_HEADERDESEL);
@@ -1455,12 +1474,12 @@ void ED_region_header(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(&ar->v2d);
xco= maxco= 8;
yco= HEADERY-4;
yco= headery-4;
/* draw all headers types */
for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
block= uiBeginBlock(C, ar, ht->idname, UI_EMBOSS);
layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, HEADERY-6, 1, style);
layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style);
if(ht->draw) {
header.type= ht;
@@ -1484,7 +1503,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
}
/* always as last */
UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
UI_view2d_totRect_set(&ar->v2d, maxco+UI_UNIT_X+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
/* restore view matrix? */
UI_view2d_view_restore(C);
@@ -1495,3 +1514,8 @@ void ED_region_header_init(ARegion *ar)
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
}
/* UI_UNIT_Y is defined as U variable now, depending dpi */
int ED_area_headersize(void)
{
return UI_UNIT_Y+6;
}

View File

@@ -671,9 +671,9 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
/* test for collapsed areas. This could happen in some blender version... */
/* ton: removed option now, it needs Context... */
/* make each window at least HEADERY high */
/* make each window at least ED_area_headersize() high */
for(sa= sc->areabase.first; sa; sa= sa->next) {
int headery= HEADERY+1;
int headery= ED_area_headersize()+1;
if(sa->v1->vec.y+headery > sa->v2->vec.y) {
/* lower edge */
@@ -1055,6 +1055,18 @@ void ED_screen_draw(wmWindow *win)
win->screen->do_draw= 0;
}
/* helper call for below, dpi changes headers */
static void screen_refresh_headersizes(void)
{
const ListBase *lb= BKE_spacetypes_list();
SpaceType *st;
for(st= lb->first; st; st= st->next) {
ARegionType *art= BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
if(art) art->prefsizey= ED_area_headersize();
}
}
/* make this screen usable */
/* for file read and first use, for scaling window, area moves */
void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
@@ -1076,6 +1088,9 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
else
wm_subwindow_position(win, win->screen->mainwin, &winrct);
/* header size depends on DPI, let's verify */
screen_refresh_headersizes();
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
/* set spacetype and region callbacks, calls init() */
/* sets subwindows for regions, adds handlers */
@@ -1498,7 +1513,7 @@ void ED_screen_delete_scene(bContext *C, Scene *scene)
unlink_scene(bmain, scene, newscene);
}
int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
{
wmWindow *win= CTX_wm_window(C);
bScreen *screen= CTX_wm_screen(C);
@@ -1523,7 +1538,7 @@ int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
ED_area_newspace(C, newsa, type);
return 1;
return newsa;
}
void ED_screen_full_prevspace(bContext *C, ScrArea *sa)

View File

@@ -40,6 +40,8 @@
#include "BLI_dlrbTree.h"
#include "BLI_utildefines.h"
#include "BLF_api.h"
#include "DNA_armature_types.h"
#include "DNA_lattice_types.h"
#include "DNA_object_types.h"
@@ -627,6 +629,13 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static int actionzone_cancel(bContext *UNUSED(C), wmOperator *op)
{
actionzone_exit(op);
return OPERATOR_CANCELLED;
}
static void SCREEN_OT_actionzone(wmOperatorType *ot)
{
/* identifiers */
@@ -637,6 +646,7 @@ static void SCREEN_OT_actionzone(wmOperatorType *ot)
ot->invoke= actionzone_invoke;
ot->modal= actionzone_modal;
ot->poll= actionzone_area_poll;
ot->cancel= actionzone_cancel;
ot->flag= OPTYPE_BLOCKING;
@@ -759,6 +769,7 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
ot->invoke= area_swap_invoke;
ot->modal= area_swap_modal;
ot->poll= ED_operator_areaactive;
ot->cancel= area_swap_cancel;
ot->flag= OPTYPE_BLOCKING;
}
@@ -868,13 +879,14 @@ typedef struct sAreaMoveData {
static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller)
{
ScrArea *sa;
int areaminy= ED_area_headersize()+1;
/* we check all areas and test for free space with MINSIZE */
*bigger= *smaller= 100000;
for(sa= sc->areabase.first; sa; sa= sa->next) {
if(dir=='h') {
int y1= sa->v2->vec.y - sa->v1->vec.y-AREAMINY;
int y1= sa->v2->vec.y - sa->v1->vec.y-areaminy;
/* if top or down edge selected, test height */
if(sa->v1->flag && sa->v4->flag)
@@ -933,6 +945,7 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int
bScreen *sc= CTX_wm_screen(C);
ScrVert *v1;
ScrArea *sa;
int areaminy= ED_area_headersize()+1;
delta= CLAMPIS(delta, -smaller, bigger);
@@ -950,8 +963,8 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int
v1->vec.y-= (v1->vec.y % AREAGRID);
/* prevent too small top header */
if(v1->vec.y > win->sizey-AREAMINY)
v1->vec.y= win->sizey-AREAMINY;
if(v1->vec.y > win->sizey-areaminy)
v1->vec.y= win->sizey-areaminy;
}
}
}
@@ -1165,6 +1178,7 @@ static int area_split_init(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);
sAreaSplitData *sd;
int areaminy= ED_area_headersize()+1;
int dir;
/* required context */
@@ -1175,7 +1189,7 @@ static int area_split_init(bContext *C, wmOperator *op)
/* minimal size */
if(dir=='v' && sa->winx < 2*AREAMINX) return 0;
if(dir=='h' && sa->winy < 2*AREAMINY) return 0;
if(dir=='h' && sa->winy < 2*areaminy) return 0;
/* custom data */
sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split");
@@ -1491,6 +1505,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
ot->exec= area_split_exec;
ot->invoke= area_split_invoke;
ot->modal= area_split_modal;
ot->cancel= area_split_cancel;
ot->poll= screen_active_editable;
ot->flag= OPTYPE_BLOCKING;
@@ -1628,7 +1643,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
rmd->ar->sizex= rmd->origval + delta;
CLAMP(rmd->ar->sizex, 0, rmd->maxsize);
if(rmd->ar->sizex < 24) {
if(rmd->ar->sizex < UI_UNIT_X) {
rmd->ar->sizex= rmd->origval;
if(!(rmd->ar->flag & RGN_FLAG_HIDDEN))
ED_region_toggle_hidden(C, rmd->ar);
@@ -1643,11 +1658,17 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
rmd->ar->sizey= rmd->origval + delta;
CLAMP(rmd->ar->sizey, 0, rmd->maxsize);
if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS)
maxsize = rmd->maxsize - ((rmd->sa->headertype==2)?48:24) - 10;
if(rmd->ar->sizey < 24 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) {
if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) {
/* this calculation seems overly verbose
* can someone explain why this method is necessary? - campbell */
maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4);
}
/* note, 'UI_UNIT_Y/4' means you need to drag the header almost
* all the way down for it to become hidden, this is done
* otherwise its too easy to do this by accident */
if(rmd->ar->sizey < UI_UNIT_Y/4 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) {
rmd->ar->sizey= rmd->origval;
if(!(rmd->ar->flag & RGN_FLAG_HIDDEN))
ED_region_toggle_hidden(C, rmd->ar);
@@ -1684,6 +1705,13 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
return OPERATOR_CANCELLED;
}
static void SCREEN_OT_region_scale(wmOperatorType *ot)
{
@@ -1694,6 +1722,7 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot)
ot->invoke= region_scale_invoke;
ot->modal= region_scale_modal;
ot->cancel= region_scale_cancel;
ot->poll= ED_operator_areaactive;
@@ -2248,8 +2277,9 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
ot->invoke= area_join_invoke;
ot->modal= area_join_modal;
ot->poll= screen_active_editable;
ot->cancel= area_join_cancel;
ot->flag= OPTYPE_BLOCKING;
ot->flag= OPTYPE_BLOCKING|OPTYPE_INTERNAL;
/* rna */
RNA_def_int(ot->srna, "min_x", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX);
@@ -2433,13 +2463,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot)
static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
wmWindowManager *wm= CTX_wm_manager(C);
wmOperator *lastop;
/* only for operators that are registered and did an undo push */
for(lastop= wm->operators.last; lastop; lastop= lastop->prev)
if((lastop->type->flag & OPTYPE_REGISTER) && (lastop->type->flag & OPTYPE_UNDO))
break;
wmOperator *lastop= WM_operator_last_redo(C);
if(lastop)
WM_operator_redo_popup(C, lastop);
@@ -3044,6 +3068,7 @@ static void SCREEN_OT_border_select(wmOperatorType *ot)
ot->exec= border_select_do;
ot->invoke= WM_border_select_invoke;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_areaactive;
@@ -3118,7 +3143,7 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot)
{
/* identifiers */
ot->name= "Show/Hide User Preferences";
ot->description= "Show/hide user preferences";
ot->description= _("Show/hide user preferences");
ot->idname= "SCREEN_OT_userpref_show";
/* api callbacks */
@@ -3314,6 +3339,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(ED_OT_undo);
WM_operatortype_append(ED_OT_undo_push);
WM_operatortype_append(ED_OT_redo);
WM_operatortype_append(ED_OT_undo_history);
}
@@ -3422,9 +3448,11 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
#ifdef __APPLE__
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0);
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_OSKEY, 0);
#endif
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
/* render */