add delete key for removing active ruler.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 8 Mar 2013 16:53:00 +0000 (16:53 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 8 Mar 2013 16:53:00 +0000 (16:53 +0000)
source/blender/editors/space_view3d/view3d_ruler.c

index 75cf27a..45e4a4e 100644 (file)
@@ -158,13 +158,11 @@ static RulerItem *ruler_item_add(RulerInfo *ruler_info)
        return ruler_item;
 }
 
-#if 0
 static void ruler_item_remove(RulerInfo *ruler_info, RulerItem *ruler_item)
 {
        BLI_remlink(&ruler_info->items, ruler_item);
        MEM_freeN(ruler_item);
 }
-#endif
 
 static RulerItem *ruler_item_active_get(RulerInfo *ruler_info)
 {
@@ -726,13 +724,26 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, wmEvent *event)
                        }
                        break;
                }
-
                case ESCKEY:
                {
                        do_draw = true;
                        exit_code = OPERATOR_CANCELLED;
                        break;
                }
+               case DELKEY:
+               {
+                       if (event->val == KM_PRESS) {
+                               if (ruler_info->state == RULER_STATE_NORMAL) {
+                                       RulerItem *ruler_item = ruler_item_active_get(ruler_info);
+                                       if (ruler_item) {
+                                               ruler_item_remove(ruler_info, ruler_item);
+                                               ruler_info->item_active = -1;
+                                               do_draw = true;
+                                       }
+                               }
+                       }
+                       break;
+               }
                default:
                        exit_code = OPERATOR_PASS_THROUGH;
                        break;