[Bf-blender-cvs] [cb5aecd] master: Code cleanup: Use enums for redraw timer operator, makes things more readable

Antony Riakiotakis noreply at git.blender.org
Tue Jun 23 12:53:41 CEST 2015


Commit: cb5aecdae92b805ddc6d8b208449ffd3e058ad9a
Author: Antony Riakiotakis
Date:   Tue Jun 23 12:53:33 2015 +0200
Branches: master
https://developer.blender.org/rBcb5aecdae92b805ddc6d8b208449ffd3e058ad9a

Code cleanup: Use enums for redraw timer operator, makes things more
readable

===================================================================

M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index b958592..bcc49af 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -4621,15 +4621,25 @@ static void redraw_timer_window_swap(bContext *C)
 	CTX_wm_window_set(C, win);  /* XXX context manipulation warning! */
 }
 
+enum eRedrawTimerItems {
+	eRTDrawRegion = 0,
+	eRTDrawRegionSwap = 1,
+	eRTDrawWindow = 2,
+	eRTDrawWindowSwap = 3,
+	eRTAnimationStep = 4,
+	eRTAnimationPlay = 5,
+	eRTUndo = 6,
+};
+
 static EnumPropertyItem redraw_timer_type_items[] = {
-	{0, "DRAW", 0, "Draw Region", "Draw Region"},
-	{1, "DRAW_SWAP", 0, "Draw Region + Swap", "Draw Region and Swap"},
-	{2, "DRAW_WIN", 0, "Draw Window", "Draw Window"},
-	{3, "DRAW_WIN_SWAP", 0, "Draw Window + Swap", "Draw Window and Swap"},
-	{4, "ANIM_STEP", 0, "Anim Step", "Animation Steps"},
-	{5, "ANIM_PLAY", 0, "Anim Play", "Animation Playback"},
+	{eRTDrawRegion, "DRAW", 0, "Draw Region", "Draw Region"},
+	{eRTDrawRegionSwap, "DRAW_SWAP", 0, "Draw Region + Swap", "Draw Region and Swap"},
+	{eRTDrawWindow, "DRAW_WIN", 0, "Draw Window", "Draw Window"},
+	{eRTDrawWindowSwap, "DRAW_WIN_SWAP", 0, "Draw Window + Swap", "Draw Window and Swap"},
+	{eRTAnimationStep, "ANIM_STEP", 0, "Anim Step", "Animation Steps"},
+	{eRTAnimationPlay, "ANIM_PLAY", 0, "Anim Play", "Animation Playback"},
 	{6, "UNDO", 0, "Undo/Redo", "Undo/Redo"},
-	{0, NULL, 0, NULL, NULL}
+	{eRTUndo, NULL, 0, NULL, NULL}
 };
 
 static int redraw_timer_exec(bContext *C, wmOperator *op)
@@ -4645,13 +4655,13 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
 	WM_cursor_wait(1);
 
 	for (a = 0; a < iter; a++) {
-		if (type == 0) {
+		if (type == eRTDrawRegion) {
 			if (ar) {
 				ED_region_do_draw(C, ar);
 				ar->do_draw = false;
 			}
 		}
-		else if (type == 1) {
+		else if (type == eRTDrawRegionSwap) {
 			wmWindow *win = CTX_wm_window(C);
 			CTX_wm_menu_set(C, NULL);
 		
@@ -4660,7 +4670,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
 			
 			CTX_wm_window_set(C, win);  /* XXX context manipulation warning! */
 		}
-		else if (type == 2) {
+		else if (type == eRTDrawWindow) {
 			wmWindow *win = CTX_wm_window(C);
 			ScrArea *sa;
 			
@@ -4687,10 +4697,10 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
 			CTX_wm_area_set(C, sa_back);
 			CTX_wm_region_set(C, ar_back);
 		}
-		else if (type == 3) {
+		else if (type == eRTDrawWindowSwap) {
 			redraw_timer_window_swap(C);
 		}
-		else if (type == 4) {
+		else if (type == eRTAnimationStep) {
 			Main *bmain = CTX_data_main(C);
 			Scene *scene = CTX_data_scene(C);
 			
@@ -4698,7 +4708,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
 			else scene->r.cfra++;
 			BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay);
 		}
-		else if (type == 5) {
+		else if (type == eRTAnimationPlay) {
 
 			/* play anim, return on same frame as started with */
 			Main *bmain = CTX_data_main(C);
@@ -4715,7 +4725,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
 				redraw_timer_window_swap(C);
 			}
 		}
-		else { /* 6 */
+		else { /* eRTUndo */
 			ED_undo_pop(C);
 			ED_undo_redo(C);
 		}
@@ -4742,7 +4752,7 @@ static void WM_OT_redraw_timer(wmOperatorType *ot)
 	ot->exec = redraw_timer_exec;
 	ot->poll = WM_operator_winactive;
 
-	ot->prop = RNA_def_enum(ot->srna, "type", redraw_timer_type_items, 0, "Type", "");
+	ot->prop = RNA_def_enum(ot->srna, "type", redraw_timer_type_items, eRTDrawRegion, "Type", "");
 	RNA_def_int(ot->srna, "iterations", 10, 1, INT_MAX, "Iterations", "Number of times to redraw", 1, 1000);
 
 }




More information about the Bf-blender-cvs mailing list