Maybe slightly controversial pie commit:
authorAntony Riakiotakis <kalast@gmail.com>
Wed, 13 Aug 2014 13:11:19 +0000 (15:11 +0200)
committerAntony Riakiotakis <kalast@gmail.com>
Wed, 13 Aug 2014 13:11:19 +0000 (15:11 +0200)
Make pie menu item placement touch the radius from the internal side of
the buttons rather than placing on the center on the cirtcle. This
allows us to get rid of the separate visual angle property, also allows
for tighter placement of pies with a smaller radius without easily
overlapping.

Also pie menu title now always appears above the threshold indicator.

source/blender/blenkernel/BKE_blender.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/resources.c

index ea904983eca8fbcde6825fd4200c93eb95ecc794..e2d4f7c5a22300b92d60899cd4ccea9acf0bd1b3 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         271
-#define BLENDER_SUBVERSION      4
+#define BLENDER_SUBVERSION      5
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
index 73eb5f63aeaf0c6d56c3fec9010c9dafe6b3c65d..155b059afe2fc9a142dd8937d6c0098de07601e8 100644 (file)
@@ -1103,8 +1103,7 @@ const char ui_radial_dir_order[8] = {
     UI_RADIAL_NW, UI_RADIAL_NE, UI_RADIAL_SW, UI_RADIAL_SE};
 
 const char  ui_radial_dir_to_numpad[8] = {8, 9, 6, 3, 2, 1, 4, 7};
-const short ui_radial_dir_to_angle_visual[8] = {90, 40, 0, 320, 270, 220, 180, 140};
-const short ui_radial_dir_to_angle[8] =        {90, 45, 0, 315, 270, 225, 180, 135};
+const short ui_radial_dir_to_angle[8] =  {90, 45, 0, 315, 270, 225, 180, 135};
 
 static void ui_but_pie_direction_string(uiBut *but, char *buf, int size)
 {
index 30ce7c6b1ec17bbac4b8caf95a55ee7aef943874..102d7b6feef16b8aa37192b52bf5586fb024c6f3 100644 (file)
@@ -6378,27 +6378,17 @@ static bool ui_but_contains_pt(uiBut *but, float mx, float my)
        return BLI_rctf_isect_pt(&but->rect, mx, my);
 }
 
-static void ui_but_pie_dir__internal(RadialDirection dir, float vec[2], const short angles[8])
+void ui_but_pie_dir(RadialDirection dir, float vec[2])
 {
        float angle;
 
        BLI_assert(dir != UI_RADIAL_NONE);
 
-       angle = DEG2RADF((float)angles[dir]);
+       angle = DEG2RADF((float)ui_radial_dir_to_angle[dir]);
        vec[0] = cosf(angle);
        vec[1] = sinf(angle);
 }
 
-void ui_but_pie_dir_visual(RadialDirection dir, float vec[2])
-{
-       ui_but_pie_dir__internal(dir, vec, ui_radial_dir_to_angle_visual);
-}
-
-void ui_but_pie_dir(RadialDirection dir, float vec[2])
-{
-       ui_but_pie_dir__internal(dir, vec, ui_radial_dir_to_angle);
-}
-
 static bool ui_but_isect_pie_seg(uiBlock *block, uiBut *but)
 {
        const float angle_range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_4 : M_PI_4 / 2.0;
@@ -8650,17 +8640,25 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
                                        block->pie_data.flags |= UI_PIE_ANIMATION_FINISHED;
                                }
 
-                               pie_radius *= fac;
-
                                for (but = block->buttons.first; but; but = but->next) {
                                        if (but->pie_dir != UI_RADIAL_NONE) {
-                                               float dir[2];
+                                               float vec[2];
+                                               float center[2];
+                       
+                                               ui_but_pie_dir(but->pie_dir, vec);
 
-                                               ui_but_pie_dir_visual(but->pie_dir, dir);
+                                               center[0] = (vec[0] > 0.01f) ? 0.5f : ((vec[0] < -0.01f) ? -0.5f : 0.0f);
+                                               center[1] = (vec[1] > 0.99f) ? 0.5f : ((vec[1] < -0.99f) ? -0.5f : 0.0f);
 
-                                               mul_v2_fl(dir, pie_radius );
-                                               add_v2_v2(dir, block->pie_data.pie_center_spawned);
-                                               BLI_rctf_recenter(&but->rect, dir[0], dir[1]);
+                                               center[0] *= BLI_rctf_size_x(&but->rect);
+                                               center[1] *= BLI_rctf_size_y(&but->rect);
+                                               
+                                               mul_v2_fl(vec, pie_radius);
+                                               add_v2_v2(vec, center);
+                                               mul_v2_fl(vec, fac);                                            
+                                               add_v2_v2(vec, block->pie_data.pie_center_spawned);
+                                                           
+                                               BLI_rctf_recenter(&but->rect, vec[0], vec[1]);
                                        }
                                }
                                block->pie_data.alphafac = fac;
index d3ff1c7063f1f16b6863f50c492518703226e11f..f5a965e9701969b448ddf6e36a082c75bc7db1e7 100644 (file)
@@ -137,7 +137,6 @@ typedef enum RadialDirection {
 
 extern const char  ui_radial_dir_order[8];
 extern const char  ui_radial_dir_to_numpad[8];
-extern const short ui_radial_dir_to_angle_visual[8];
 extern const short ui_radial_dir_to_angle[8];
 
 /* internal panel drawing defines */
index a2d8ce06e5f66d0714cab2e05c76a13d78eb0ab1..ac9110873fffe56e2321dc2934e6c4ead04f64c5 100644 (file)
@@ -2121,7 +2121,7 @@ static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum)
        BLI_assert(itemnum < 8);
 
        dir = ui_radial_dir_order[itemnum];
-       ui_but_pie_dir_visual(dir, vec);
+       ui_but_pie_dir(dir, vec);
 
        return dir;
 }
@@ -2179,8 +2179,11 @@ static void ui_litem_layout_radial(uiLayout *litem)
                if (ui_item_is_radial_displayable(item)) {
                        RadialDirection dir;
                        float vec[2];
+                       float factor[2];
 
                        dir = ui_get_radialbut_vec(vec, itemnum);
+                       factor[0] = (vec[0] > 0.01f) ? 0.0f : ((vec[0] < -0.01f) ? -1.0f : -0.5f);
+                       factor[1] = (vec[1] > 0.99f) ? 0.0f : ((vec[1] < -0.99f) ? -1.0f : -0.5f);
 
                        itemnum++;
 
@@ -2199,7 +2202,7 @@ static void ui_litem_layout_radial(uiLayout *litem)
 
                        ui_item_size(item, &itemw, &itemh);
 
-                       ui_item_position(item, x + vec[0] * pie_radius - itemw / 2, y + vec[1] * pie_radius - itemh / 2, itemw, itemh);
+                       ui_item_position(item, x + vec[0] * pie_radius + factor[0] * itemw, y + vec[1] * pie_radius + factor[1] * itemh, itemw, itemh);
 
                        minx = min_ii(minx, x + vec[0] * pie_radius - itemw / 2);
                        maxx = max_ii(maxx, x + vec[0] * pie_radius + itemw / 2);
@@ -2232,7 +2235,7 @@ static void ui_litem_layout_root_radial(uiLayout *litem)
 
                ui_item_size(item, &itemw, &itemh);
 
-               ui_item_position(item, x - itemw / 2, y + 2 * UI_UNIT_Y, itemw, itemh);
+               ui_item_position(item, x - itemw / 2, y + U.pixelsize * (U.pie_menu_threshold + 9.0f), itemw, itemh);
        }
 }
 
index 8eadff137d6f7579e6e4c146aec345b755857e08..8ad30d05197881f492bcf84ec95e1728e7b6f0e6 100644 (file)
@@ -113,7 +113,7 @@ int ui_step_name_menu(uiBut *but, int direction)
 {
        /* currenly only RNA buttons */
        if ((but->rnaprop == NULL) || (RNA_property_type(but->rnaprop) != PROP_ENUM)) {
-               printf("%s: cannot cycle button '%s'\n", __func__, but->str);
+               printf("%s: cannot cycle button '%s'", __func__, but->str);
                return 0;
        }
 
index 92277cc63eac33a189d21f47e8b8f74a0df273ab..822fa41e69d2ef4c63ba7f7576011e0f4f7f03ec 100644 (file)
@@ -2454,7 +2454,7 @@ void init_userdef_do_versions(void)
                }
        }
 
-       if (U.versionfile < 271 || (U.versionfile == 271 && U.subversionfile < 4)) {
+       if (U.versionfile < 271 || (U.versionfile == 271 && U.subversionfile < 5)) {
                bTheme *btheme;
 
                struct uiWidgetColors wcol_pie_menu = {
@@ -2470,7 +2470,7 @@ void init_userdef_do_versions(void)
                        10, -10
                };
 
-               U.pie_menu_radius = 150;
+               U.pie_menu_radius = 100;
                U.pie_menu_threshold = 12;
                U.pie_animation_timeout = 6;