forked from bartvdbraak/blender
2.5
- Added new popup menu type, which can be used to pass on a running operator too. Needed it for debug menu, allowing to set variables outside of operator "first do then tweak" system. :) void uiPupBlockOperator() Don't forget to tell invoke() return that operator now runs modal! - Test menu: alt+ctrl+d gives the G.rt debug value. Values of 0-16 now can be used to shrink areas, stuff like this then happens (rt==4): http://download.blender.org/institute/rt5.jpg Was looking at ways to visually distinguish areas and regions better. Yes I know, cute rounded corners, etc. Just testing!
This commit is contained in:
parent
5bc3bd7b06
commit
1a69eab4a0
@ -238,6 +238,7 @@ typedef uiBlock* (*uiBlockCreateFunc)(struct bContext *C, struct ARegion *ar, vo
|
|||||||
|
|
||||||
void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
|
void uiPupBlock(struct bContext *C, uiBlockCreateFunc func, void *arg);
|
||||||
void uiPupBlockO(struct bContext *C, uiBlockCreateFunc func, void *arg, char *opname, int opcontext);
|
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);
|
||||||
|
|
||||||
/* Blocks
|
/* Blocks
|
||||||
*
|
*
|
||||||
|
@ -2080,3 +2080,20 @@ void uiPupBlock(bContext *C, uiBlockCreateFunc func, void *arg)
|
|||||||
uiPupBlockO(C, func, arg, NULL, 0);
|
uiPupBlockO(C, func, arg, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int opcontext)
|
||||||
|
{
|
||||||
|
wmWindow *window= CTX_wm_window(C);
|
||||||
|
uiPopupBlockHandle *handle;
|
||||||
|
|
||||||
|
handle= ui_popup_block_create(C, NULL, NULL, func, NULL, op);
|
||||||
|
handle->popup= 1;
|
||||||
|
handle->retvalue= 1;
|
||||||
|
|
||||||
|
handle->popup_arg= op;
|
||||||
|
handle->popup_func= operator_cb;
|
||||||
|
handle->cancel_func= confirm_cancel_operator;
|
||||||
|
handle->opcontext= opcontext;
|
||||||
|
|
||||||
|
UI_add_popup_handlers(C, &window->handlers, handle);
|
||||||
|
WM_event_add_mousemove(C);
|
||||||
|
}
|
||||||
|
@ -545,15 +545,16 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder, int quad)
|
|||||||
|
|
||||||
static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
|
static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
|
||||||
{
|
{
|
||||||
|
short rt= CLAMPIS(G.rt, 0, 16);
|
||||||
|
|
||||||
if(sa->v1->vec.x>0) sa->totrct.xmin= sa->v1->vec.x+1;
|
if(sa->v1->vec.x>0) sa->totrct.xmin= sa->v1->vec.x+1+rt;
|
||||||
else sa->totrct.xmin= sa->v1->vec.x;
|
else sa->totrct.xmin= sa->v1->vec.x;
|
||||||
if(sa->v4->vec.x<sizex-1) sa->totrct.xmax= sa->v4->vec.x-1;
|
if(sa->v4->vec.x<sizex-1) sa->totrct.xmax= sa->v4->vec.x-1-rt;
|
||||||
else sa->totrct.xmax= sa->v4->vec.x;
|
else sa->totrct.xmax= sa->v4->vec.x;
|
||||||
|
|
||||||
if(sa->v1->vec.y>0) sa->totrct.ymin= sa->v1->vec.y+1;
|
if(sa->v1->vec.y>0) sa->totrct.ymin= sa->v1->vec.y+1+rt;
|
||||||
else sa->totrct.ymin= sa->v1->vec.y;
|
else sa->totrct.ymin= sa->v1->vec.y;
|
||||||
if(sa->v2->vec.y<sizey-1) sa->totrct.ymax= sa->v2->vec.y-1;
|
if(sa->v2->vec.y<sizey-1) sa->totrct.ymax= sa->v2->vec.y-1-rt;
|
||||||
else sa->totrct.ymax= sa->v2->vec.y;
|
else sa->totrct.ymax= sa->v2->vec.y;
|
||||||
|
|
||||||
/* for speedup */
|
/* for speedup */
|
||||||
@ -582,16 +583,16 @@ void area_azone_initialize(ScrArea *sa)
|
|||||||
|
|
||||||
for(az= sa->actionzones.first; az; az= az->next) {
|
for(az= sa->actionzones.first; az; az= az->next) {
|
||||||
if(az->pos==AZONE_SW) {
|
if(az->pos==AZONE_SW) {
|
||||||
az->x1= sa->v1->vec.x+1;
|
az->x1= sa->totrct.xmin;
|
||||||
az->y1= sa->v1->vec.y+1;
|
az->y1= sa->totrct.ymin;
|
||||||
az->x2= sa->v1->vec.x+AZONESPOT;
|
az->x2= sa->totrct.xmin + AZONESPOT-1;
|
||||||
az->y2= sa->v1->vec.y+AZONESPOT;
|
az->y2= sa->totrct.ymin + AZONESPOT-1;
|
||||||
}
|
}
|
||||||
else if (az->pos==AZONE_NE) {
|
else if (az->pos==AZONE_NE) {
|
||||||
az->x1= sa->v3->vec.x;
|
az->x1= sa->totrct.xmax+1;
|
||||||
az->y1= sa->v3->vec.y;
|
az->y1= sa->totrct.ymax+1;
|
||||||
az->x2= sa->v3->vec.x-AZONESPOT;
|
az->x2= sa->totrct.xmax-AZONESPOT+1;
|
||||||
az->y2= sa->v3->vec.y-AZONESPOT;
|
az->y2= sa->totrct.ymax-AZONESPOT+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -868,30 +868,47 @@ static void scrarea_draw_shape_light(ScrArea *sa, char dir)
|
|||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, short x2, short y2, short a)
|
||||||
|
{
|
||||||
|
/* right border area */
|
||||||
|
if(x2<sizex-1)
|
||||||
|
sdrawline(x2+a, y1, x2+a, y2);
|
||||||
|
|
||||||
|
/* left border area */
|
||||||
|
if(x1>0) /* otherwise it draws the emboss of window over */
|
||||||
|
sdrawline(x1+a, y1, x1+a, y2);
|
||||||
|
|
||||||
|
/* top border area */
|
||||||
|
if(y2<sizey-1)
|
||||||
|
sdrawline(x1, y2+a, x2, y2+a);
|
||||||
|
|
||||||
|
/* bottom border area */
|
||||||
|
if(y1>0)
|
||||||
|
sdrawline(x1, y1+a, x2, y1+a);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/** screen edges drawing **/
|
/** screen edges drawing **/
|
||||||
static void drawscredge_area(ScrArea *sa)
|
static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center)
|
||||||
{
|
{
|
||||||
short x1= sa->v1->vec.x;
|
short x1= sa->v1->vec.x;
|
||||||
short y1= sa->v1->vec.y;
|
short y1= sa->v1->vec.y;
|
||||||
short x2= sa->v3->vec.x;
|
short x2= sa->v3->vec.x;
|
||||||
short y2= sa->v3->vec.y;
|
short y2= sa->v3->vec.y;
|
||||||
|
short a, rt;
|
||||||
|
|
||||||
cpack(0x0);
|
rt= CLAMPIS(G.rt, 0, 16);
|
||||||
|
|
||||||
/* right border area */
|
if(center==0) {
|
||||||
sdrawline(x2, y1, x2, y2);
|
cpack(0x505050);
|
||||||
|
for(a=-rt; a<=rt; a++)
|
||||||
/* left border area */
|
if(a!=0)
|
||||||
if(x1>0) { /* otherwise it draws the emboss of window over */
|
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, a);
|
||||||
sdrawline(x1, y1, x1, y2);
|
}
|
||||||
|
else {
|
||||||
|
cpack(0x0);
|
||||||
|
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* top border area */
|
|
||||||
sdrawline(x1, y2, x2, y2);
|
|
||||||
|
|
||||||
/* bottom border area */
|
|
||||||
sdrawline(x1, y1, x2, y1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************** EXPORTED API TO OTHER MODULES *************************** */
|
/* ****************** EXPORTED API TO OTHER MODULES *************************** */
|
||||||
@ -971,8 +988,10 @@ void ED_screen_draw(wmWindow *win)
|
|||||||
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
||||||
if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa;
|
if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa;
|
||||||
if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa;
|
if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa;
|
||||||
drawscredge_area(sa);
|
drawscredge_area(sa, win->sizex, win->sizey, 0);
|
||||||
}
|
}
|
||||||
|
for(sa= win->screen->areabase.first; sa; sa= sa->next)
|
||||||
|
drawscredge_area(sa, win->sizex, win->sizey, 1);
|
||||||
|
|
||||||
/* blended join arrow */
|
/* blended join arrow */
|
||||||
if (sa1 && sa2) {
|
if (sa1 && sa2) {
|
||||||
|
@ -319,6 +319,61 @@ int WM_operator_redo_popup(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ***************** Debug menu ************************* */
|
||||||
|
|
||||||
|
static uiBlock *wm_block_create_menu(bContext *C, ARegion *ar, void *arg_op)
|
||||||
|
{
|
||||||
|
wmOperator *op= arg_op;
|
||||||
|
uiBlock *block;
|
||||||
|
uiLayout *layout;
|
||||||
|
uiStyle *style= U.uistyles.first;
|
||||||
|
|
||||||
|
block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
|
||||||
|
uiBlockClearFlag(block, UI_BLOCK_LOOP);
|
||||||
|
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
|
||||||
|
|
||||||
|
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 300, 20, style);
|
||||||
|
uiDefAutoButsRNA(C, layout, op->ptr);
|
||||||
|
|
||||||
|
uiPopupBoundsBlock(block, 4.0f, 0, 0);
|
||||||
|
uiEndBlock(C, block);
|
||||||
|
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int wm_debug_menu_exec(bContext *C, wmOperator *op)
|
||||||
|
{
|
||||||
|
G.rt= RNA_int_get(op->ptr, "debugval");
|
||||||
|
ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
|
||||||
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||||
|
|
||||||
|
return OPERATOR_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int wm_debug_menu_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
RNA_int_set(op->ptr, "debugval", G.rt);
|
||||||
|
|
||||||
|
/* pass on operator, so return modal */
|
||||||
|
uiPupBlockOperator(C, wm_block_create_menu, op, WM_OP_EXEC_DEFAULT);
|
||||||
|
|
||||||
|
return OPERATOR_RUNNING_MODAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WM_OT_debug_menu(wmOperatorType *ot)
|
||||||
|
{
|
||||||
|
ot->name= "Debug Menu";
|
||||||
|
ot->idname= "WM_OT_debug_menu";
|
||||||
|
|
||||||
|
ot->invoke= wm_debug_menu_invoke;
|
||||||
|
ot->exec= wm_debug_menu_exec;
|
||||||
|
ot->poll= WM_operator_winactive;
|
||||||
|
|
||||||
|
RNA_def_int(ot->srna, "debugval", 0, -10000, 10000, "Debug Value", "", INT_MIN, INT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ************ window / screen operator definitions ************** */
|
/* ************ window / screen operator definitions ************** */
|
||||||
|
|
||||||
static void WM_OT_window_duplicate(wmOperatorType *ot)
|
static void WM_OT_window_duplicate(wmOperatorType *ot)
|
||||||
@ -1381,6 +1436,7 @@ void wm_operatortype_init(void)
|
|||||||
WM_operatortype_append(WM_OT_save_as_mainfile);
|
WM_operatortype_append(WM_OT_save_as_mainfile);
|
||||||
WM_operatortype_append(WM_OT_save_mainfile);
|
WM_operatortype_append(WM_OT_save_mainfile);
|
||||||
WM_operatortype_append(WM_OT_ten_timer);
|
WM_operatortype_append(WM_OT_ten_timer);
|
||||||
|
WM_operatortype_append(WM_OT_debug_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default keymap for windows and screens, only call once per WM */
|
/* default keymap for windows and screens, only call once per WM */
|
||||||
@ -1402,6 +1458,9 @@ void wm_window_keymap(wmWindowManager *wm)
|
|||||||
WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, 0, 0);
|
WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, 0, 0);
|
||||||
WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
|
WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
|
||||||
|
|
||||||
|
/* debug/testing */
|
||||||
WM_keymap_verify_item(keymap, "WM_OT_ten_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
|
WM_keymap_verify_item(keymap, "WM_OT_ten_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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user