[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32027] trunk/blender/source/blender/ editors: Partly apply patch [#23746] Clarify azone->edge values.
Nathan Letwory
nathan at letworyinteractive.com
Mon Sep 20 15:13:40 CEST 2010
Revision: 32027
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32027
Author: jesterking
Date: 2010-09-20 15:13:40 +0200 (Mon, 20 Sep 2010)
Log Message:
-----------
Partly apply patch [#23746] Clarify azone->edge values.
Submitted by Shane Ambler.
The original patches made an enum for action zone edges, changed positioning for minimised icons and repositioned minimised icon for operator properties panel.
I kept the enum idea, but further improved on the naming. Some switches used in place of if/else blocks and added some comments. See patch tracker for more comments.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/ED_screen_types.h
trunk/blender/source/blender/editors/screen/area.c
trunk/blender/source/blender/editors/screen/screen_edit.c
trunk/blender/source/blender/editors/screen/screen_ops.c
Modified: trunk/blender/source/blender/editors/include/ED_screen_types.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_screen_types.h 2010-09-20 13:10:53 UTC (rev 32026)
+++ trunk/blender/source/blender/editors/include/ED_screen_types.h 2010-09-20 13:13:40 UTC (rev 32027)
@@ -68,13 +68,21 @@
/* ----------------------------------------------------- */
+/* Enum for Action Zone Edges. Which edge of area is action zone. */
+typedef enum {
+ AE_RIGHT_TO_TOPLEFT, /* Region located on the left, _right_ edge is action zone. Region minimised to the top left */
+ AE_LEFT_TO_TOPRIGHT, /* Region located on the right, _left_ edge is action zone. Region minimised to the top right */
+ AE_TOP_TO_BOTTOMRIGHT, /* Region located at the bottom, _top_ edge is action zone. Region minimised to the bottom right */
+ AE_BOTTOM_TO_TOPLEFT /* Region located at the top, _bottom_edge is action zone. Region minimised to the top left */
+} AZEdge;
+
/* for editing areas/regions */
typedef struct AZone {
struct AZone *next, *prev;
ARegion *ar;
int type;
/* region-azone, which of the edges */
- short edge;
+ AZEdge edge;
/* internal */
short do_draw;
/* for draw */
Modified: trunk/blender/source/blender/editors/screen/area.c
===================================================================
--- trunk/blender/source/blender/editors/screen/area.c 2010-09-20 13:10:53 UTC (rev 32026)
+++ trunk/blender/source/blender/editors/screen/area.c 2010-09-20 13:13:40 UTC (rev 32027)
@@ -469,30 +469,32 @@
#define AZONEPAD_ICON 8
static void region_azone_edge(AZone *az, ARegion *ar)
{
- if(az->edge=='t') {
- az->x1= ar->winrct.xmin;
- az->y1= ar->winrct.ymax - AZONEPAD_EDGE;
- az->x2= ar->winrct.xmax;
- az->y2= ar->winrct.ymax;
+ switch(az->edge) {
+ case AE_TOP_TO_BOTTOMRIGHT:
+ az->x1= ar->winrct.xmin;
+ az->y1= ar->winrct.ymax - AZONEPAD_EDGE;
+ az->x2= ar->winrct.xmax;
+ az->y2= ar->winrct.ymax;
+ break;
+ case AE_BOTTOM_TO_TOPLEFT:
+ az->x1= ar->winrct.xmin;
+ az->y1= ar->winrct.ymin + AZONEPAD_EDGE;
+ az->x2= ar->winrct.xmax;
+ az->y2= ar->winrct.ymin;
+ break;
+ case AE_LEFT_TO_TOPRIGHT:
+ az->x1= ar->winrct.xmin;
+ az->y1= ar->winrct.ymin;
+ az->x2= ar->winrct.xmin + AZONEPAD_EDGE;
+ az->y2= ar->winrct.ymax;
+ break;
+ case AE_RIGHT_TO_TOPLEFT:
+ az->x1= ar->winrct.xmax;
+ az->y1= ar->winrct.ymin;
+ az->x2= ar->winrct.xmax - AZONEPAD_EDGE;
+ az->y2= ar->winrct.ymax;
+ break;
}
- else if(az->edge=='b') {
- az->x1= ar->winrct.xmin;
- az->y1= ar->winrct.ymin + AZONEPAD_EDGE;
- az->x2= ar->winrct.xmax;
- az->y2= ar->winrct.ymin;
- }
- else if(az->edge=='l') {
- az->x1= ar->winrct.xmin;
- az->y1= ar->winrct.ymin;
- az->x2= ar->winrct.xmin + AZONEPAD_EDGE;
- az->y2= ar->winrct.ymax;
- }
- else { // if(az->edge=='r') {
- az->x1= ar->winrct.xmax;
- az->y1= ar->winrct.ymin;
- az->x2= ar->winrct.xmax - AZONEPAD_EDGE;
- az->y2= ar->winrct.ymax;
- }
BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
@@ -502,34 +504,39 @@
AZone *azt;
int tot=0;
+ /* count how many actionzones with along same edge are available.
+ This allows for adding more action zones in the future without
+ having to worry about correct offset */
for(azt= sa->actionzones.first; azt; azt= azt->next) {
if(azt->edge == az->edge) tot++;
}
- if(az->edge=='t') {
- az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON;
- az->y1= ar->winrct.ymax + AZONEPAD_ICON;
- az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON;
- az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON;
+ switch(az->edge) {
+ case AE_TOP_TO_BOTTOMRIGHT:
+ az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON;
+ az->y1= ar->winrct.ymax + AZONEPAD_ICON;
+ az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON;
+ az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON;
+ break;
+ case AE_BOTTOM_TO_TOPLEFT:
+ az->x1= ar->winrct.xmin + AZONEPAD_ICON;
+ az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON;
+ az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON;
+ az->y2= ar->winrct.ymin - AZONEPAD_ICON;
+ break;
+ case AE_LEFT_TO_TOPRIGHT:
+ az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON;
+ az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
+ az->x2= ar->winrct.xmin - AZONEPAD_ICON;
+ az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
+ break;
+ case AE_RIGHT_TO_TOPLEFT:
+ az->x1= ar->winrct.xmax + AZONEPAD_ICON;
+ az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
+ az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON;
+ az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
+ break;
}
- else if(az->edge=='b') {
- az->x1= ar->winrct.xmin + AZONEPAD_ICON;
- az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON;
- az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON;
- az->y2= ar->winrct.ymin - AZONEPAD_ICON;
- }
- else if(az->edge=='l') {
- az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON;
- az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
- az->x2= ar->winrct.xmin - AZONEPAD_ICON;
- az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
- }
- else { // if(az->edge=='r') {
- az->x1= ar->winrct.xmax + AZONEPAD_ICON;
- az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
- az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON;
- az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
- }
BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
@@ -537,22 +544,21 @@
for(azt= sa->actionzones.first; azt; azt= azt->next) {
if(az!=azt) {
if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) {
- if(az->edge=='t' || az->edge=='b') {
+ if(az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) {
az->x1+= AZONESPOT;
az->x2+= AZONESPOT;
- BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
- else {
+ else{
az->y1-= AZONESPOT;
az->y2-= AZONESPOT;
- BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
+ BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
}
}
}
-static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge)
+static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge)
{
AZone *az;
@@ -575,17 +581,16 @@
static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
{
- /* edge code (t b l r) is where azone will be drawn */
+ /* edge code (t b l r) is along which area edge azone will be drawn */
if(alignment==RGN_ALIGN_TOP)
- region_azone_initialize(sa, ar, 'b');
+ region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT);
else if(alignment==RGN_ALIGN_BOTTOM)
- region_azone_initialize(sa, ar, 't');
+ region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT);
else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
- region_azone_initialize(sa, ar, 'l');
+ region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT);
else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
- region_azone_initialize(sa, ar, 'r');
-
+ region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT);
}
/* dir is direction to check, not the splitting edge direction! */
Modified: trunk/blender/source/blender/editors/screen/screen_edit.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_edit.c 2010-09-20 13:10:53 UTC (rev 32026)
+++ trunk/blender/source/blender/editors/screen/screen_edit.c 2010-09-20 13:13:40 UTC (rev 32027)
@@ -1162,7 +1162,7 @@
if(az->type==AZONE_AREA)
WM_cursor_set(win, CURSOR_EDIT);
else if(az->type==AZONE_REGION) {
- if(az->edge == 'l' || az->edge == 'r')
+ if(az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT)
WM_cursor_set(win, CURSOR_X_MOVE);
else
WM_cursor_set(win, CURSOR_Y_MOVE);
Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c 2010-09-20 13:10:53 UTC (rev 32026)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c 2010-09-20 13:13:40 UTC (rev 32027)
@@ -1291,19 +1291,19 @@
int bigger, smaller, origval;
int origx, origy;
int maxsize;
- char edge;
+ AZEdge edge;
} RegionMoveData;
-static int area_max_regionsize(ScrArea *sa, ARegion *scalear, char edge)
+static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
{
ARegion *ar;
int dist;
- if(edge=='l' || edge=='r') {
+ if(edge==AE_RIGHT_TO_TOPLEFT || edge==AE_LEFT_TO_TOPRIGHT) {
dist = sa->totrct.xmax - sa->totrct.xmin;
- } else { /* t, b */
+ } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
dist = sa->totrct.ymax - sa->totrct.ymin;
}
@@ -1325,9 +1325,9 @@
/* case of regions in regions, like operator properties panel */
/* these can sit on top of other regions such as headers, so account for this */
- else if (edge == 'b' && scalear->alignment & RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER)
+ else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER)
dist -= ar->winy;
- else if (edge == 't' && scalear->alignment & RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER)
+ else if (edge == AE_TOP_TO_BOTTOMRIGHT && scalear->alignment & RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER)
dist -= ar->winy;
}
@@ -1367,7 +1367,7 @@
rmd->ar->sizey= rmd->ar->type->prefsizey;
/* now copy to regionmovedata */
- if(rmd->edge=='l' || rmd->edge=='r') {
+ if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) {
rmd->origval= rmd->ar->sizex;
} else {
rmd->origval= rmd->ar->sizey;
@@ -1399,9 +1399,9 @@
switch(event->type) {
case MOUSEMOVE:
- if(rmd->edge=='l' || rmd->edge=='r') {
+ if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) {
delta= event->x - rmd->origx;
- if(rmd->edge=='l') delta= -delta;
+ if(rmd->edge==AE_LEFT_TO_TOPRIGHT) delta= -delta;
rmd->ar->sizex= rmd->origval + delta;
CLAMP(rmd->ar->sizex, 0, rmd->maxsize);
@@ -1417,7 +1417,7 @@
else {
int maxsize=0;
delta= event->y - rmd->origy;
- if(rmd->edge=='b') delta= -delta;
+ if(rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta;
rmd->ar->sizey= rmd->origval + delta;
CLAMP(rmd->ar->sizey, 0, rmd->maxsize);
More information about the Bf-blender-cvs
mailing list