Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-02 17:22:52 +0300
committerTon Roosendaal <ton@blender.org>2008-12-02 17:22:52 +0300
commit54908979c54ab332156f438e995d5dce8ee8420c (patch)
tree94558d3acad12b5c0f08e902d967ce3d6d0f0723 /source/blender/editors/screen
parentc4fe6d0f00aa2a9656445ebb53161768e0c51342 (diff)
Lots of stuff; couldn't commit in parts because of refactor work.
* Changes in interface/ module This commit brings back the way how buttons/menus work under control of WM event system. The previous implementation extended usage of handlers and operators in an interesting but confusing way. Better to try it first according the design specs. :) Most obviously: - modal-handler operators are not stored anymore in regions/areas/windows. such modal handlers own their operator, and should remove it themselves. - removed code to move handlers from one queue to another. (needs review with brecht!) - WM fix: the API call to remove a modal handler got removed. This was a dangerous thing anyway, and you should leave that to the event system. Now, if a handler modal() call gets a cancel/finish return, it frees itself in event system. WM_event_remove_modal_handler was a confusing call anyway! Todo: - allow button-activate to refresh after using button - re-enable arrow keys for menus (do both after commit) - review return values of operator callbacks in interface_ops.c * Fixes in WM system - Freeing areas/regions/windows, also on quit, now correctly closes running modal handlers - On starting a modal handler, the handler now stores previous area and region context, so they send proper notifiers etc. * Other fixes - Area-split operator had bug, wrong minimal size checking. This solves error when trying to split a very narrow area. - removed DNA_USHORT_FIX from screen_types.h, gave warning - operators didn't get ID name copied when activated, needed for later re-use or saving.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/screen_edit.c15
-rw-r--r--source/blender/editors/screen/screen_ops.c43
2 files changed, 24 insertions, 34 deletions
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 742022ea370..31ac5d63835 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -268,8 +268,8 @@ static short testsplitpoint(wmWindow *win, ScrArea *sa, char dir, float fac)
short x, y;
// area big enough?
- if(sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX) return 0;
- if(sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY) return 0;
+ if(dir=='v' && (sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX)) return 0;
+ if(dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0;
// to be sure
if(fac<0.0) fac= 0.0;
@@ -305,7 +305,7 @@ ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac
ScrVert *sv1, *sv2;
short split;
- if(sa==0) return NULL;
+ if(sa==NULL) return NULL;
split= testsplitpoint(win, sa, dir, fac);
if(split==0) return NULL;
@@ -920,8 +920,7 @@ void ED_screens_initialize(wmWindowManager *wm)
void ED_region_exit(bContext *C, ARegion *ar)
{
- WM_operator_cancel(C, &ar->modalops, NULL);
- WM_event_remove_handlers(&ar->handlers);
+ WM_event_remove_handlers(C, &ar->handlers);
}
void ED_area_exit(bContext *C, ScrArea *sa)
@@ -931,8 +930,7 @@ void ED_area_exit(bContext *C, ScrArea *sa)
for(ar= sa->regionbase.first; ar; ar= ar->next)
ED_region_exit(C, ar);
- WM_operator_cancel(C, &sa->modalops, NULL);
- WM_event_remove_handlers(&sa->handlers);
+ WM_event_remove_handlers(C, &sa->handlers);
}
void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
@@ -946,8 +944,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
for(sa= screen->areabase.first; sa; sa= sa->next)
ED_area_exit(C, sa);
- WM_operator_cancel(C, &window->modalops, NULL);
- WM_event_remove_handlers(&window->handlers);
+ WM_event_remove_handlers(C, &window->handlers);
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 4c7a98e97c3..095f6e1a74b 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -125,7 +125,7 @@ static AZone *is_in_area_actionzone(ScrArea *sa, int x, int y)
int i= 0;
for(az= sa->actionzones.first, i= 0; az; az= az->next, i++) {
- if(az && az->type == AZONE_TRI) {
+ if(az->type == AZONE_TRI) {
if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y))
break;
}
@@ -154,7 +154,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
sad->x= event->x; sad->y= event->y;
/* add modal handler */
- WM_event_add_modal_handler(&C->window->handlers, op);
+ WM_event_add_modal_handler(C, &C->window->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -209,15 +209,12 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
actionzone_apply(C, op);
actionzone_exit(C, op);
- WM_event_remove_modal_handler(&C->window->handlers, op);
-
return OPERATOR_FINISHED;
}
break;
case ESCKEY:
case LEFTMOUSE:
actionzone_exit(C, op);
- WM_event_remove_modal_handler(&C->window->handlers, op);
return OPERATOR_CANCELLED;
}
@@ -560,14 +557,13 @@ static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_PASS_THROUGH;
/* add temp handler */
- WM_event_add_modal_handler(&C->window->handlers, op);
+ WM_event_add_modal_handler(C, &C->window->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
static int area_move_cancel(bContext *C, wmOperator *op)
{
- WM_event_remove_modal_handler(&C->window->handlers, op);
RNA_int_set(op->ptr, "delta", 0);
area_move_apply(C, op);
@@ -599,7 +595,6 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event)
case LEFTMOUSE:
if(event->val==0) {
area_move_exit(C, op);
- WM_event_remove_modal_handler(&C->window->handlers, op);
return OPERATOR_FINISHED;
}
break;
@@ -740,8 +735,8 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
}
-/* do the split */
-static void area_split_apply(bContext *C, wmOperator *op)
+/* do the split, return success */
+static int area_split_apply(bContext *C, wmOperator *op)
{
sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
float fac;
@@ -767,10 +762,12 @@ static void area_split_apply(bContext *C, wmOperator *op)
if(dir=='h') sd->origval= sd->nedge->v1->vec.y;
else sd->origval= sd->nedge->v1->vec.x;
+ WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+
+ return 1;
}
- WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
-
+ return 0;
}
static void area_split_exit(bContext *C, wmOperator *op)
@@ -826,13 +823,14 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
sd->y= event->y;
/* do the split */
- area_split_apply(C, op);
- area_move_set_limits(C->screen, dir, &sd->bigger, &sd->smaller);
-
- /* add temp handler for edge move or cancel */
- WM_event_add_modal_handler(&C->window->handlers, op);
-
- return OPERATOR_RUNNING_MODAL;
+ if(area_split_apply(C, op)) {
+ area_move_set_limits(C->screen, dir, &sd->bigger, &sd->smaller);
+
+ /* add temp handler for edge move or cancel */
+ WM_event_add_modal_handler(C, &C->window->handlers, op);
+
+ return OPERATOR_RUNNING_MODAL;
+ }
}
else {
@@ -861,8 +859,6 @@ static int area_split_cancel(bContext *C, wmOperator *op)
{
sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
- WM_event_remove_modal_handler(&C->window->handlers, op);
-
if (screen_area_join(C->screen,sd->sarea, sd->narea)) {
if (C->area == sd->narea) {
C->area = NULL;
@@ -893,7 +889,6 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
case LEFTMOUSE:
if(event->val==0) { /* mouse up */
area_split_exit(C, op);
- WM_event_remove_modal_handler(&C->window->handlers, op);
return OPERATOR_FINISHED;
}
break;
@@ -1070,7 +1065,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_PASS_THROUGH;
/* add temp handler */
- WM_event_add_modal_handler(&C->window->handlers, op);
+ WM_event_add_modal_handler(C, &C->window->handlers, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -1092,7 +1087,6 @@ static int area_join_cancel(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL);
- WM_event_remove_modal_handler(&C->window->handlers, op);
area_join_exit(C, op);
@@ -1174,7 +1168,6 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
area_join_apply(C, op);
WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL);
area_join_exit(C, op);
- WM_event_remove_modal_handler(&C->window->handlers, op);
return OPERATOR_FINISHED;
}
break;