[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50499] trunk/blender/source/blender/ editors: code cleanup: use typedef'd enum for block bounds types.

Campbell Barton ideasman42 at gmail.com
Mon Sep 10 09:03:31 CEST 2012


Revision: 50499
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50499
Author:   campbellbarton
Date:     2012-09-10 07:03:30 +0000 (Mon, 10 Sep 2012)
Log Message:
-----------
code cleanup: use typedef'd enum for block bounds types.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_intern.h

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2012-09-10 06:44:25 UTC (rev 50498)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2012-09-10 07:03:30 UTC (rev 50499)
@@ -397,7 +397,8 @@
 void uiBlockEndAlign(uiBlock *block);
 
 /* block bounds/position calculation */
-enum {
+typedef enum {
+	UI_BLOCK_BOUNDS_NONE = 0,
 	UI_BLOCK_BOUNDS = 1,
 	UI_BLOCK_BOUNDS_TEXT,
 	UI_BLOCK_BOUNDS_POPUP_MOUSE,

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2012-09-10 06:44:25 UTC (rev 50498)
+++ trunk/blender/source/blender/editors/interface/interface.c	2012-09-10 07:03:30 UTC (rev 50499)
@@ -317,7 +317,7 @@
 	ui_bounds_block(block);
 	
 }
-static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_calc)
+static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBoundsCalc bounds_calc)
 {
 	wmWindow *window = CTX_wm_window(C);
 	int startx, starty, endx, endy, width, height, oldwidth, oldheight;
@@ -388,21 +388,21 @@
 		return;
 	
 	block->bounds = addval;
-	block->dobounds = UI_BLOCK_BOUNDS;
+	block->bounds_type = UI_BLOCK_BOUNDS;
 }
 
 /* used for pulldowns */
 void uiTextBoundsBlock(uiBlock *block, int addval)
 {
 	block->bounds = addval;
-	block->dobounds = UI_BLOCK_BOUNDS_TEXT;
+	block->bounds_type = UI_BLOCK_BOUNDS_TEXT;
 }
 
 /* used for block popups */
 void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
 {
 	block->bounds = addval;
-	block->dobounds = UI_BLOCK_BOUNDS_POPUP_MOUSE;
+	block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MOUSE;
 	block->mx = mx;
 	block->my = my;
 }
@@ -411,7 +411,7 @@
 void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
 {
 	block->bounds = addval;
-	block->dobounds = UI_BLOCK_BOUNDS_POPUP_MENU;
+	block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MENU;
 	block->mx = mx;
 	block->my = my;
 }
@@ -420,7 +420,7 @@
 void uiCenteredBoundsBlock(uiBlock *block, int addval)
 {
 	block->bounds = addval;
-	block->dobounds = UI_BLOCK_BOUNDS_POPUP_CENTER;
+	block->bounds_type = UI_BLOCK_BOUNDS_POPUP_CENTER;
 }
 
 void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy)
@@ -429,7 +429,7 @@
 	block->rect.ymin = miny;
 	block->rect.xmax = maxx;
 	block->rect.ymax = maxy;
-	block->dobounds = 0;
+	block->bounds_type = UI_BLOCK_BOUNDS_NONE;
 }
 
 /* ************** LINK LINE DRAWING  ************* */
@@ -934,22 +934,46 @@
 	}
 
 	/* handle pending stuff */
-	if (block->layouts.first) uiBlockLayoutResolve(block, NULL, NULL);
+	if (block->layouts.first) {
+		uiBlockLayoutResolve(block, NULL, NULL);
+	}
 	ui_block_do_align(block);
 	if ((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) {
 		ui_menu_block_set_keyaccels(block); /* could use a different flag to check */
 	}
-	if (block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block);
+
+	if (block->flag & UI_BLOCK_LOOP) {
+		ui_menu_block_set_keymaps(C, block);
+	}
 	
 	/* after keymaps! */
-	if (block->dobounds == UI_BLOCK_BOUNDS) ui_bounds_block(block);
-	else if (block->dobounds == UI_BLOCK_BOUNDS_TEXT) ui_text_bounds_block(block, 0.0f);
-	else if (block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block);
-	else if (block->dobounds) ui_popup_bounds_block(C, block, block->dobounds);
+	switch (block->bounds_type) {
+		case UI_BLOCK_BOUNDS_NONE:
+			break;
+		case UI_BLOCK_BOUNDS:
+			ui_bounds_block(block);
+			break;
+		case UI_BLOCK_BOUNDS_TEXT:
+			ui_text_bounds_block(block, 0.0f);
+			break;
+		case UI_BLOCK_BOUNDS_POPUP_CENTER:
+			ui_centered_bounds_block(C, block);
+			break;
 
-	if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) uiBoundsBlock(block, 0);
-	if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
+			/* fallback */
+		case UI_BLOCK_BOUNDS_POPUP_MOUSE:
+		case UI_BLOCK_BOUNDS_POPUP_MENU:
+			ui_popup_bounds_block(C, block, block->bounds_type);
+			break;
+	}
 
+	if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
+		uiBoundsBlock(block, 0);
+	}
+	if (block->flag & UI_BUT_ALIGN) {
+		uiBlockEndAlign(block);
+	}
+
 	block->endblock = 1;
 }
 
@@ -2540,11 +2564,13 @@
 			/* skip with same number */
 			for (; but && but->alignnr == nr; but = but->next) ;
 
-			if (!but)
+			if (!but) {
 				break;
+			}
 		}
-		else
+		else {
 			but = but->next;
+		}
 	}
 }
 

Modified: trunk/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_intern.h	2012-09-10 06:44:25 UTC (rev 50498)
+++ trunk/blender/source/blender/editors/interface/interface_intern.h	2012-09-10 07:03:30 UTC (rev 50499)
@@ -316,7 +316,8 @@
 	char endblock;              /* uiEndBlock done? */
 
 	float xofs, yofs;           /* offset to parent button */
-	int dobounds, mx, my;       /* for doing delayed */
+	eBlockBoundsCalc bounds_type;  /* for doing delayed */
+	int mx, my;
 	int bounds, minbounds;      /* for doing delayed */
 
 	rctf safety;                /* pulldowns, to detect outside, can differ per case how it is created */




More information about the Bf-blender-cvs mailing list