[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25275] trunk/blender/source/blender/ editors/screen/screen_ops.c: Fix for [#19776] Header bar problem in 2.5
Matt Ebb
matt at mke3.net
Thu Dec 10 10:25:30 CET 2009
Revision: 25275
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25275
Author: broken
Date: 2009-12-10 10:25:30 +0100 (Thu, 10 Dec 2009)
Log Message:
-----------
Fix for [#19776] Header bar problem in 2.5
Prevents dragging region edges outside area boundaries or into other regions.
Modified Paths:
--------------
trunk/blender/source/blender/editors/screen/screen_ops.c
Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c 2009-12-10 08:54:16 UTC (rev 25274)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c 2009-12-10 09:25:30 UTC (rev 25275)
@@ -180,10 +180,10 @@
int ED_operator_node_active(bContext *C)
{
SpaceNode *snode= CTX_wm_space_node(C);
-
+
if(snode && snode->edittree)
return 1;
-
+
return 0;
}
@@ -252,7 +252,7 @@
if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE))
return (obact->mode & OB_MODE_POSE)!=0;
-
+
return 0;
}
@@ -261,15 +261,15 @@
{
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= NULL;
-
+
if(obedit && obedit->type==OB_MESH)
em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
if(em && (em->faces.first) && (CustomData_has_layer(&em->fdata, CD_MTFACE))) {
BKE_mesh_end_editmesh(obedit->data, em);
return 1;
}
-
+
if(obedit)
BKE_mesh_end_editmesh(obedit->data, em);
return 0;
@@ -279,15 +279,15 @@
{
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= NULL;
-
+
if(obedit && obedit->type==OB_MESH)
em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
if(em && (em->faces.first)) {
BKE_mesh_end_editmesh(obedit->data, em);
return 1;
}
-
+
if(obedit)
BKE_mesh_end_editmesh(obedit->data, em);
return 0;
@@ -345,28 +345,28 @@
/* *************************** action zone operator ************************** */
/* operator state vars used:
- none
+ none
+
+ functions:
+
+ apply() set actionzone event
+
+ exit() free customdata
+
+ callbacks:
+
+ exec() never used
+
+ invoke() check if in zone
+ add customdata, put mouseco and area in it
+ add modal handler
+
+ modal() accept modal events while doing it
+ call apply() with gesture info, active window, nonactive window
+ call exit() and remove handler when LMB confirm
+
+ */
-functions:
-
- apply() set actionzone event
-
- exit() free customdata
-
-callbacks:
-
- exec() never used
-
- invoke() check if in zone
- add customdata, put mouseco and area in it
- add modal handler
-
- modal() accept modal events while doing it
- call apply() with gesture info, active window, nonactive window
- call exit() and remove handler when LMB confirm
-
-*/
-
typedef struct sActionzoneData {
ScrArea *sa1, *sa2;
AZone *az;
@@ -399,7 +399,7 @@
for(az= sa->actionzones.first; az; az= az->next)
if(BLI_in_rcti(&az->rect, x, y))
- return 1;
+ return 1;
}
return 0;
}
@@ -514,14 +514,14 @@
return OPERATOR_FINISHED;
}
- break;
+ break;
case ESCKEY:
actionzone_exit(C, op);
return OPERATOR_CANCELLED;
case LEFTMOUSE:
actionzone_exit(C, op);
return OPERATOR_CANCELLED;
-
+
}
return OPERATOR_RUNNING_MODAL;
@@ -537,7 +537,7 @@
ot->invoke= actionzone_invoke;
ot->modal= actionzone_modal;
ot->poll= actionzone_area_poll;
-
+
ot->flag= OPTYPE_BLOCKING;
RNA_def_int(ot->srna, "modifier", 0, 0, 2, "modifier", "modifier state", 0, 2);
@@ -546,26 +546,26 @@
/* ************** swap area operator *********************************** */
/* operator state vars used:
- sa1 start area
- sa2 area to swap with
+ sa1 start area
+ sa2 area to swap with
+
+ functions:
+
+ init() set custom data for operator, based on actionzone event custom data
+
+ cancel() cancel the operator
+
+ exit() cleanup, send notifier
+
+ callbacks:
+
+ invoke() gets called on shift+lmb drag in actionzone
+ call init(), add handler
+
+ modal() accept modal events while doing it
+
+ */
- functions:
-
- init() set custom data for operator, based on actionzone event custom data
-
- cancel() cancel the operator
-
- exit() cleanup, send notifier
-
- callbacks:
-
- invoke() gets called on shift+lmb drag in actionzone
- call init(), add handler
-
- modal() accept modal events while doing it
-
-*/
-
typedef struct sAreaSwapData {
ScrArea *sa1, *sa2;
} sAreaSwapData;
@@ -574,15 +574,15 @@
{
sAreaSwapData *sd= NULL;
sActionzoneData *sad= event->customdata;
-
+
if(sad==NULL || sad->sa1==NULL)
- return 0;
+ return 0;
sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
sd->sa1= sad->sa1;
sd->sa2= sad->sa2;
op->customdata= sd;
-
+
return 1;
}
@@ -602,22 +602,22 @@
static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
-
+
if(!area_swap_init(C, op, event))
return OPERATOR_PASS_THROUGH;
-
+
/* add modal handler */
WM_cursor_modal(CTX_wm_window(C), BC_SWAPAREA_CURSOR);
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
-
+
}
static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event)
{
sActionzoneData *sad= op->customdata;
-
+
switch(event->type) {
case MOUSEMOVE:
/* second area, for join */
@@ -626,19 +626,19 @@
case LEFTMOUSE: /* release LMB */
if(event->val==KM_RELEASE) {
if(!sad->sa2 || sad->sa1 == sad->sa2) {
-
+
return area_swap_cancel(C, op);
}
ED_area_swapspace(C, sad->sa1, sad->sa2);
-
+
area_swap_exit(C, op);
-
+
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
break;
-
+
case ESCKEY:
return area_swap_cancel(C, op);
}
@@ -650,11 +650,11 @@
ot->name= "Swap areas";
ot->description= "Swap selected areas screen positions.";
ot->idname= "SCREEN_OT_area_swap";
-
+
ot->invoke= area_swap_invoke;
ot->modal= area_swap_modal;
ot->poll= ED_operator_areaactive;
-
+
ot->flag= OPTYPE_BLOCKING;
}
@@ -675,10 +675,10 @@
/* XXX hrmf! */
if(event->type==EVT_ACTIONZONE_AREA) {
sActionzoneData *sad= event->customdata;
-
+
if(sad==NULL)
return OPERATOR_PASS_THROUGH;
-
+
sa= sad->sa1;
}
@@ -703,7 +703,7 @@
/* screen, areas init */
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
-
+
if(event->type==EVT_ACTIONZONE_AREA)
actionzone_exit(C, op);
@@ -724,34 +724,34 @@
/* ************** move area edge operator *********************************** */
/* operator state vars used:
- x, y mouse coord near edge
- delta movement of edge
+ x, y mouse coord near edge
+ delta movement of edge
+
+ functions:
+
+ init() set default property values, find edge based on mouse coords, test
+ if the edge can be moved, select edges, calculate min and max movement
+
+ apply() apply delta on selection
+
+ exit() cleanup, send notifier
+
+ cancel() cancel moving
+
+ callbacks:
+
+ exec() execute without any user interaction, based on properties
+ call init(), apply(), exit()
+
+ invoke() gets called on mouse click near edge
+ call init(), add handler
+
+ modal() accept modal events while doing it
+ call apply() with delta motion
+ call exit() and remove handler
+
+ */
- functions:
-
- init() set default property values, find edge based on mouse coords, test
- if the edge can be moved, select edges, calculate min and max movement
-
- apply() apply delta on selection
-
- exit() cleanup, send notifier
-
- cancel() cancel moving
-
- callbacks:
-
- exec() execute without any user interaction, based on properties
- call init(), apply(), exit()
-
- invoke() gets called on mouse click near edge
- call init(), add handler
-
- modal() accept modal events while doing it
- call apply() with delta motion
- call exit() and remove handler
-
-*/
-
typedef struct sAreaMoveData {
int bigger, smaller, origval, step;
char dir;
@@ -795,25 +795,25 @@
ScrEdge *actedge;
sAreaMoveData *md;
int x, y;
-
+
/* required properties */
x= RNA_int_get(op->ptr, "x");
y= RNA_int_get(op->ptr, "y");
-
+
/* setup */
actedge= screen_find_active_scredge(sc, x, y);
if(actedge==NULL) return 0;
-
+
md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
op->customdata= md;
-
+
md->dir= scredge_is_horizontal(actedge)?'h':'v';
if(md->dir=='h') md->origval= actedge->v1->vec.y;
else md->origval= actedge->v1->vec.x;
select_connected_scredge(sc, actedge);
/* now all vertices with 'flag==1' are the ones that can be moved. */
-
+
area_move_set_limits(sc, md->dir, &md->bigger, &md->smaller);
return 1;
@@ -837,7 +837,7 @@
}
if((dir=='h') && v1->vec.y>0 && v1->vec.y<win->sizey-1) {
v1->vec.y= origval + delta;
-
+
v1->vec.y+= AREAGRID-1;
v1->vec.y-= (v1->vec.y % AREAGRID);
@@ -847,7 +847,7 @@
}
}
}
-
+
WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
}
@@ -887,7 +887,7 @@
{
RNA_int_set(op->ptr, "x", event->x);
RNA_int_set(op->ptr, "y", event->y);
-
+
if(!area_move_init(C, op))
return OPERATOR_PASS_THROUGH;
@@ -899,11 +899,11 @@
static int area_move_cancel(bContext *C, wmOperator *op)
{
-
+
RNA_int_set(op->ptr, "delta", 0);
area_move_apply(C, op);
area_move_exit(C, op);
-
+
return OPERATOR_CANCELLED;
}
@@ -912,7 +912,7 @@
{
sAreaMoveData *md= op->customdata;
int delta, x, y;
-
+
/* execute the events */
switch(event->type) {
case MOUSEMOVE:
@@ -923,7 +923,7 @@
delta= (md->dir == 'v')? event->x - x: event->y - y;
if(md->step) delta= delta - (delta % md->step);
RNA_int_set(op->ptr, "delta", delta);
-
+
area_move_apply(C, op);
break;
@@ -933,7 +933,7 @@
case KM_MODAL_APPLY:
area_move_exit(C, op);
return OPERATOR_FINISHED;
-
+
case KM_MODAL_CANCEL:
return area_move_cancel(C, op);
@@ -955,15 +955,15 @@
ot->name= "Move area edges";
ot->description= "Move selected area edges.";
ot->idname= "SCREEN_OT_area_move";
-
+
ot->exec= area_move_exec;
ot->invoke= area_move_invoke;
ot->cancel= area_move_cancel;
ot->modal= area_move_modal;
ot->poll= ED_operator_screen_mainwinactive; /* when mouse is over area-edge */
-
+
ot->flag= OPTYPE_BLOCKING;
-
+
/* rna */
RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
@@ -973,57 +973,57 @@
/* ************** split area operator *********************************** */
/*
-operator state vars:
- fac spit point
- dir direction 'v' or 'h'
+ operator state vars:
+ fac spit point
+ dir direction 'v' or 'h'
+
+ operator customdata:
+ area pointer to (active) area
+ x, y last used mouse pos
+ (more, see below)
+
+ functions:
+
+ init() set default property values, find area based on context
+
+ apply() split area based on state vars
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list