Commit: 8e12efb43100552f6cdd108591bf3696ac55f55a
Author: Campbell Barton
Date:   Sun Aug 3 02:28:31 2014 +1000
Branches: pie-menus
https://developer.blender.org/rB8e12efb43100552f6cdd108591bf3696ac55f55a

set UI_RADIAL_NONE to -1 so we can use the enum to undex arrays

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

M       source/blender/editors/interface/interface.c
M       source/blender/editors/interface/interface_handlers.c
M       source/blender/editors/interface/interface_intern.h
M       source/blender/editors/interface/interface_regions.c

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

diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 524cafb..be15203 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1108,8 +1108,8 @@ const short ui_radial_dir_to_angle[8] =        {90, 45, 
0, 315, 270, 225, 180, 1
 
 static void ui_pie_direction_string(uiBut *but, char *buf, int size)
 {
-       BLI_assert((unsigned int)(but->pie_dir - 1) < 
ARRAY_SIZE(ui_radial_dir_to_numpad));
-       BLI_snprintf(buf, size, "%d", ui_radial_dir_to_numpad[but->pie_dir - 
1]);
+       BLI_assert(but->pie_dir < ARRAY_SIZE(ui_radial_dir_to_numpad));
+       BLI_snprintf(buf, size, "%d", ui_radial_dir_to_numpad[but->pie_dir]);
 }
 
 static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
@@ -3071,6 +3071,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int 
retval, const char *str,
        but->lock = block->lock;
        but->lockstr = block->lockstr;
        but->dt = block->dt;
+       but->pie_dir = UI_RADIAL_NONE;
 
        but->block = block;  /* pointer back, used for frontbuffer status, and 
picker */
 
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 1b004ea..b9eb566 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -8603,7 +8603,7 @@ static int ui_handler_pie(bContext *C, const wmEvent 
*event, uiPopupBlockHandle
                                pie_radius *= fac;
 
                                for (but = block->buttons.first; but; but = 
but->next) {
-                                       if (but->pie_dir) {
+                                       if (but->pie_dir != UI_RADIAL_NONE) {
                                                float dir[2];
 
                                                
ui_but_pie_dir_visual(but->pie_dir, dir);
diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index e81d427..21fbf05 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -124,15 +124,15 @@ enum {
 
 /* but->pie_dir */
 typedef enum RadialDirection {
-       UI_RADIAL_NONE = 0,
-       UI_RADIAL_N  = 1,
-       UI_RADIAL_NE = 2,
-       UI_RADIAL_E  = 3,
-       UI_RADIAL_SE = 4,
-       UI_RADIAL_S  = 5,
-       UI_RADIAL_SW = 6,
-       UI_RADIAL_W  = 7,
-       UI_RADIAL_NW = 8,
+       UI_RADIAL_NONE  = -1,
+       UI_RADIAL_N     =  0,
+       UI_RADIAL_NE    =  1,
+       UI_RADIAL_E     =  2,
+       UI_RADIAL_SE    =  3,
+       UI_RADIAL_S     =  4,
+       UI_RADIAL_SW    =  5,
+       UI_RADIAL_W     =  6,
+       UI_RADIAL_NW    =  7,
 } RadialDirection;
 
 extern const char  ui_radial_dir_order[8];
@@ -259,7 +259,7 @@ struct uiBut {
        BIFIconID icon;
        bool lock;
        char dt; /* drawtype: UI_EMBOSS, UI_EMBOSSN ... etc, copied from the 
block */
-       char pie_dir; /* direction in a pie menu, used for collision detection 
*/
+       signed char pie_dir; /* direction in a pie menu, used for collision 
detection (RadialDirection) */
        char changed; /* could be made into a single flag */
        unsigned char unit_type; /* so buttons can support unit systems which 
are not RNA */
        short modifier_key;
diff --git a/source/blender/editors/interface/interface_regions.c 
b/source/blender/editors/interface/interface_regions.c
index 956cc9e..0da16dc 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1750,7 +1750,7 @@ uiBlock *ui_popup_block_refresh(
                /* lastly set the buttons at the center of the pie menu, ready 
for animation */
                if (U.pie_animation_timeout > 0) {
                        for (but = block->buttons.first; but; but = but->next) {
-                               if (but->pie_dir) {
+                               if (but->pie_dir != UI_RADIAL_NONE) {
                                        BLI_rctf_recenter(&but->rect, 
UNPACK2(block->pie_data.pie_center_spawned));
                                }
                        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to