2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback design, which should make a design based on user-less exec() first, then wrap invoke() and modal() around it. The exec() should be callable with only Context and properties. - split now works again; and inversed as previously, if you drag from a triangle (action zone) inside area it subdivides area as expected. - dragging from triangle outside area, over an edge, joins areas - split has been simplified, it had too many options... it could just work simpler (now) - 'action zone' now is an operator itself, a widget sending an ACTIONZONE event, which can be handled by others (so other gestures can be added in action zone too) Still evaluating: - context gets set where? - code structure confuses... what are proper functions for operators? - what is WM... should low level screen stuff more there? - when do you send event, notifier? - files grow to large, will clean Oh yeah and docs, docs, docs. Coming! :)
This commit is contained in:
@@ -69,6 +69,7 @@ void ED_keymap_screen(struct wmWindowManager *wm);
|
||||
/* operators; context poll callbacks */
|
||||
int ED_operator_screenactive(struct bContext *C);
|
||||
int ED_operator_screen_mainwinactive(struct bContext *C);
|
||||
int ED_operator_areaactive(struct bContext *C);
|
||||
|
||||
|
||||
#endif /* ED_SCREEN_H */
|
||||
|
||||
@@ -33,23 +33,14 @@ typedef struct AZone {
|
||||
struct AZone *next, *prev;
|
||||
int type;
|
||||
int flag;
|
||||
int action;
|
||||
int pos;
|
||||
short x1, y1, x2, y2;
|
||||
} AZone;
|
||||
|
||||
#define MAX_AZONES 8
|
||||
|
||||
|
||||
/* actionzone type */
|
||||
#define AZONE_TRI 1
|
||||
#define AZONE_QUAD 2
|
||||
|
||||
/* actionzone action */
|
||||
#define AZONE_SPLIT 1
|
||||
#define AZONE_JOIN 2
|
||||
#define AZONE_DRAG 3
|
||||
|
||||
/* actionzone pos */
|
||||
#define AZONE_S 1
|
||||
#define AZONE_SW 2
|
||||
|
||||
@@ -267,77 +267,21 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
|
||||
}
|
||||
|
||||
#define AZONESPOT 12
|
||||
void area_azone_initialize(ScrArea *sa) {
|
||||
void area_azone_initialize(ScrArea *sa)
|
||||
{
|
||||
AZone *az;
|
||||
if(sa->actionzones.first==NULL) {
|
||||
/* set action zones - should these actually be ARegions? With these we can easier check area hotzones */
|
||||
/* (ton) for time being just area, ARegion split is not foreseen on user level */
|
||||
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&(sa->actionzones), az);
|
||||
az->type= AZONE_TRI;
|
||||
az->x1= sa->v1->vec.x+1;
|
||||
az->y1= sa->v1->vec.y+1;
|
||||
az->x2= sa->v1->vec.x+AZONESPOT;
|
||||
az->y2= sa->v1->vec.y+AZONESPOT;
|
||||
az->pos= AZONE_SW;
|
||||
az->action= AZONE_SPLIT;
|
||||
|
||||
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&(sa->actionzones), az);
|
||||
az->type= AZONE_TRI;
|
||||
az->x1= sa->v3->vec.x-1;
|
||||
az->y1= sa->v3->vec.y-1;
|
||||
az->x2= sa->v3->vec.x-AZONESPOT;
|
||||
az->y2= sa->v3->vec.y-AZONESPOT;
|
||||
az->pos= AZONE_NE;
|
||||
az->action= AZONE_DRAG;
|
||||
|
||||
/*az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&sa->azones, az);
|
||||
az->type= AZONE_TRI;
|
||||
az->x1= as->v1->vec.x;
|
||||
az->y1= as->v1->vec.y;
|
||||
az->x2= as->v1->vec.x+AZONESPOT;
|
||||
az->y2= as->v1->vec.y+AZONESPOT;
|
||||
|
||||
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&sa->azones, az);
|
||||
az->type= AZONE_TRI;
|
||||
az->x1= as->v1->vec.x;
|
||||
az->y1= as->v1->vec.y;
|
||||
az->x2= as->v1->vec.x+AZONESPOT;
|
||||
az->y2= as->v1->vec.y+AZONESPOT;
|
||||
|
||||
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&sa->azones, az);
|
||||
az->type= AZONE_QUAD;
|
||||
az->x1= as->v1->vec.x;
|
||||
az->y1= as->v1->vec.y;
|
||||
az->x2= as->v1->vec.x+AZONESPOT;
|
||||
az->y2= as->v1->vec.y+AZONESPOT;
|
||||
|
||||
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&sa->azones, az);
|
||||
az->type= AZONE_QUAD;
|
||||
az->x1= as->v1->vec.x;
|
||||
az->y1= as->v1->vec.y;
|
||||
az->x2= as->v1->vec.x+AZONESPOT;
|
||||
az->y2= as->v1->vec.y+AZONESPOT;
|
||||
|
||||
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&sa->azones, az);
|
||||
az->type= AZONE_QUAD;
|
||||
az->x1= as->v1->vec.x;
|
||||
az->y1= as->v1->vec.y;
|
||||
az->x2= as->v1->vec.x+AZONESPOT;
|
||||
az->y2= as->v1->vec.y+AZONESPOT;
|
||||
|
||||
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
||||
BLI_addtail(&sa->azones, az);
|
||||
az->type= AZONE_QUAD;
|
||||
az->x1= as->v1->vec.x;
|
||||
az->y1= as->v1->vec.y;
|
||||
az->x2= as->v1->vec.x+AZONESPOT;
|
||||
az->y2= as->v1->vec.y+AZONESPOT;*/
|
||||
}
|
||||
|
||||
for(az= sa->actionzones.first; az; az= az->next) {
|
||||
@@ -406,7 +350,6 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
|
||||
{
|
||||
Panel *pa1, *pa2, *patab;
|
||||
ARegion *ar;
|
||||
AZone *az;
|
||||
|
||||
sa1->headertype= sa2->headertype;
|
||||
sa1->spacetype= sa2->spacetype;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,6 +42,7 @@ int area_cursor_test(bContext *C, wmOperator *op, wmEvent *event);
|
||||
void ED_SCR_OT_move_areas(wmOperatorType *ot);
|
||||
void ED_SCR_OT_split_area(wmOperatorType *ot);
|
||||
void ED_SCR_OT_join_areas(wmOperatorType *ot);
|
||||
void ED_SCR_OT_actionzone(wmOperatorType *ot);
|
||||
|
||||
#endif /* ED_SCREEN_INTERN_H */
|
||||
|
||||
|
||||
@@ -44,6 +44,14 @@
|
||||
|
||||
/* ************** Poll tests ********************** */
|
||||
|
||||
int ED_operator_areaactive(bContext *C)
|
||||
{
|
||||
if(C->window==NULL) return 0;
|
||||
if(C->screen==NULL) return 0;
|
||||
if(C->area==NULL) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ED_operator_screenactive(bContext *C)
|
||||
{
|
||||
if(C->window==NULL) return 0;
|
||||
@@ -51,6 +59,7 @@ int ED_operator_screenactive(bContext *C)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* when mouse is over area-edge */
|
||||
int ED_operator_screen_mainwinactive(bContext *C)
|
||||
{
|
||||
if(C->window==NULL) return 0;
|
||||
@@ -73,8 +82,12 @@ static void ED_SCR_OT_cursor_type(wmOperatorType *ot)
|
||||
/* called in spacetypes.c */
|
||||
void ED_operatortypes_screen(void)
|
||||
{
|
||||
WM_operatortype_append(ED_SCR_OT_move_areas);
|
||||
/* generic UI stuff */
|
||||
WM_operatortype_append(ED_SCR_OT_cursor_type);
|
||||
WM_operatortype_append(ED_SCR_OT_actionzone);
|
||||
|
||||
/* tools */
|
||||
WM_operatortype_append(ED_SCR_OT_move_areas);
|
||||
WM_operatortype_append(ED_SCR_OT_split_area);
|
||||
WM_operatortype_append(ED_SCR_OT_join_areas);
|
||||
}
|
||||
@@ -83,8 +96,10 @@ void ED_operatortypes_screen(void)
|
||||
void ED_keymap_screen(wmWindowManager *wm)
|
||||
{
|
||||
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_cursor_type", MOUSEMOVE, 0, 0, 0);
|
||||
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_move_areas", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_split_area", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_join_areas", RIGHTMOUSE, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_split_area", EVT_ACTIONZONE, 0, 0, 0); /* action tria */
|
||||
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_join_areas", EVT_ACTIONZONE, 0, 0, 0); /* action tria */
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ void WM_event_add_notifier(wmWindowManager *wm, wmWindow *window,
|
||||
int swinid, int type,
|
||||
int value, void *data);
|
||||
|
||||
void wm_event_add(wmWindow *win, struct wmEvent *event_to_add); /* XXX only for warning */
|
||||
|
||||
/* one-shot timer, returns wmTimerData.handle */
|
||||
struct wmTimerHandle *WM_event_add_window_timer(wmWindow *win, int delay_ms, int interval_ms);
|
||||
void WM_event_remove_window_timer(wmWindow *wm, struct wmTimerHandle *handle);
|
||||
|
||||
@@ -442,8 +442,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
|
||||
for(km= handler->keymap->first; km; km= km->next) {
|
||||
if(wm_eventmatch(event, km)) {
|
||||
/*if(event->type!=MOUSEMOVE)
|
||||
printf("handle evt %d win %d op %s\n", event->type, C->window->winid, km->idname);*/
|
||||
/* if(event->type!=MOUSEMOVE)
|
||||
printf("handle evt %d win %d op %s\n", event->type, C->window->winid, km->idname); */
|
||||
|
||||
event->keymap_idname= km->idname; /* weak, but allows interactive callback to not use rawkey */
|
||||
|
||||
@@ -470,6 +470,17 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect)
|
||||
return BLI_in_rcti(rect, event->x, event->y);
|
||||
}
|
||||
|
||||
static ScrArea *area_event_inside(bContext *C, wmEvent *event)
|
||||
{
|
||||
ScrArea *sa;
|
||||
|
||||
if(C->screen)
|
||||
for(sa= C->screen->areabase.first; sa; sa= sa->next)
|
||||
if(wm_event_inside_i(event, &sa->totrct))
|
||||
return sa;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* called in main loop */
|
||||
/* goes over entire hierarchy: events -> window -> screen -> area -> region */
|
||||
@@ -488,7 +499,8 @@ void wm_event_do_handlers(bContext *C)
|
||||
|
||||
C->window= win;
|
||||
C->screen= win->screen;
|
||||
|
||||
C->area= area_event_inside(C, event);
|
||||
|
||||
/* MVC demands to not draw in event handlers... for now we leave it */
|
||||
wm_window_make_drawable(C, win);
|
||||
|
||||
|
||||
@@ -258,7 +258,9 @@
|
||||
#define REDRAWVIEW3D_IMAGE 0x4041
|
||||
|
||||
/* **************** BLENDER GESTURE EVENTS ********************* */
|
||||
|
||||
#define BORDERSELECT 0x5000
|
||||
#define EVT_ACTIONZONE 0x5001
|
||||
|
||||
#endif /* WM_EVENT_TYPES_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user