Commit: 3926d10f0f52b9a2f486d509624db50614398f51
Author: Joshua Leung
Date:   Fri Nov 7 16:32:11 2014 +1300
Branches: GPencil_EditStrokes
https://developer.blender.org/rB3926d10f0f52b9a2f486d509624db50614398f51

Select More/Less for Grease Pencil points

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

M       release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M       source/blender/editors/gpencil/gpencil_intern.h
M       source/blender/editors/gpencil/gpencil_ops.c
M       source/blender/editors/gpencil/gpencil_select.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index a913a19..a3fc290 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -110,12 +110,19 @@ class GreasePencilStrokeEditPanel():
         subcol = col.column(align=True)
         subcol.active = edit_ok
         subcol.operator("gpencil.select_all", text="Select All")
-        subcol.operator("gpencil.select_linked")
         subcol.operator("gpencil.select_border")
         subcol.operator("gpencil.select_circle")
 
         col.separator()
 
+        subcol = col.column(align=True)
+        subcol.active = edit_ok
+        subcol.operator("gpencil.select_linked")
+        subcol.operator("gpencil.select_more")
+        subcol.operator("gpencil.select_less")
+
+        col.separator()
+
         col.label(text="Edit:")
         subcol = col.column(align=True)
         subcol.active = edit_ok
diff --git a/source/blender/editors/gpencil/gpencil_intern.h 
b/source/blender/editors/gpencil/gpencil_intern.h
index 8c3cb1a..b6b07c6 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -117,7 +117,10 @@ void GPENCIL_OT_select(struct wmOperatorType *ot);
 void GPENCIL_OT_select_all(struct wmOperatorType *ot);
 void GPENCIL_OT_select_circle(struct wmOperatorType *ot);
 void GPENCIL_OT_select_border(struct wmOperatorType *ot);
+
 void GPENCIL_OT_select_linked(struct wmOperatorType *ot);
+void GPENCIL_OT_select_more(struct wmOperatorType *ot);
+void GPENCIL_OT_select_less(struct wmOperatorType *ot);
 
 void GPENCIL_OT_duplicate(struct wmOperatorType *ot);
 void GPENCIL_OT_delete(struct wmOperatorType *ot);
diff --git a/source/blender/editors/gpencil/gpencil_ops.c 
b/source/blender/editors/gpencil/gpencil_ops.c
index f6df618..9460668 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -136,6 +136,10 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf)
        /* select linked */
        WM_keymap_add_item(keymap, "GPENCIL_OT_select_linked", LKEY, KM_PRESS, 
KM_CTRL, 0);
        
+       /* select more/less */
+       WM_keymap_add_item(keymap, "GPENCIL_OT_select_more", PADPLUSKEY, 
KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "GPENCIL_OT_select_less", PADMINUS, 
KM_PRESS, KM_CTRL, 0);
+       
        
        /* Editing ----------------------------------------- */
        
@@ -191,7 +195,10 @@ void ED_operatortypes_gpencil(void)
        WM_operatortype_append(GPENCIL_OT_select_all);
        WM_operatortype_append(GPENCIL_OT_select_circle);
        WM_operatortype_append(GPENCIL_OT_select_border);
+       
        WM_operatortype_append(GPENCIL_OT_select_linked);
+       WM_operatortype_append(GPENCIL_OT_select_more);
+       WM_operatortype_append(GPENCIL_OT_select_less);
        
        WM_operatortype_append(GPENCIL_OT_duplicate);
        WM_operatortype_append(GPENCIL_OT_delete);
diff --git a/source/blender/editors/gpencil/gpencil_select.c 
b/source/blender/editors/gpencil/gpencil_select.c
index 106e91e..2be5b8d 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -249,6 +249,147 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot)
 }
 
 /* ********************************************** */
+/* Select More */
+
+static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
+       {
+               if (gps->flag & GP_STROKE_SELECT) {
+                       bGPDspoint *pt;
+                       int i;
+                       bool prev_sel;
+                       
+                       /* First Pass: Go in forward order, expanding selection 
if previous was selected (pre changes)... 
+                        * - This pass covers the "after" edges of selection 
islands
+                        */
+                       prev_sel = false;
+                       for (i = 0, pt = gps->points; i < gps->totpoints; i++, 
pt++) {
+                               if (pt->flag & GP_SPOINT_SELECT) {
+                                       /* selected point - just set flag for 
next point */
+                                       prev_sel = true;
+                               }
+                               else {
+                                       /* unselected point - expand selection 
if previous was selected... */
+                                       if (prev_sel) {
+                                               pt->flag |= GP_SPOINT_SELECT;
+                                       }
+                                       prev_sel = false;
+                               }
+                       }
+                       
+                       /* Second Pass: Go in reverse order, doing the same as 
before (except in opposite order) 
+                        * - This pass covers the "before" edges of selection 
islands
+                        */
+                       prev_sel = false;
+                       for (pt -= 1; i > 0; i--, pt--) {
+                               if (pt->flag & GP_SPOINT_SELECT) {
+                                       prev_sel = true;
+                               }
+                               else {
+                                       /* unselected point - expand selection 
if previous was selected... */
+                                       if (prev_sel) {
+                                               pt->flag |= GP_SPOINT_SELECT;
+                                       }
+                                       prev_sel = false;
+                               }
+                       }
+               }
+       }
+       CTX_DATA_END;
+       
+       /* updates */
+       WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+       return OPERATOR_FINISHED;
+}
+
+void GPENCIL_OT_select_more(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Select More";
+       ot->idname = "GPENCIL_OT_select_more";
+       ot->description = "Grow sets of selected Grease Pencil points";
+       
+       /* callbacks */
+       ot->exec = gpencil_select_more_exec;
+       ot->poll = gpencil_select_poll;
+       
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* ********************************************** */
+/* Select Less */
+
+static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes)
+       {
+               if (gps->flag & GP_STROKE_SELECT) {
+                       bGPDspoint *pt;
+                       int i;
+                       bool prev_sel;
+                       
+                       /* First Pass: Go in forward order, shrinking selection 
if previous was not selected (pre changes)... 
+                        * - This pass covers the "after" edges of selection 
islands
+                        */
+                       prev_sel = false;
+                       for (i = 0, pt = gps->points; i < gps->totpoints; i++, 
pt++) {
+                               if (pt->flag & GP_SPOINT_SELECT) {
+                                       /* shrink if previous wasn't selected */
+                                       if (prev_sel == false) {
+                                               pt->flag &= ~GP_SPOINT_SELECT;
+                                       }
+                                       prev_sel = true;
+                               }
+                               else {
+                                       /* mark previous as being unselected - 
and hence, is trigger for shrinking */
+                                       prev_sel = false;
+                               }
+                       }
+                       
+                       /* Second Pass: Go in reverse order, doing the same as 
before (except in opposite order) 
+                        * - This pass covers the "before" edges of selection 
islands
+                        */
+                       prev_sel = false;
+                       for (pt -= 1; i > 0; i--, pt--) {
+                               if (pt->flag & GP_SPOINT_SELECT) {
+                                       /* shrink if previous wasn't selected */
+                                       if (prev_sel == false) {
+                                               pt->flag &= ~GP_SPOINT_SELECT;
+                                       }
+                                       prev_sel = true;
+                               }
+                               else {
+                                       /* mark previous as being unselected - 
and hence, is trigger for shrinking */
+                                       prev_sel = false;
+                               }
+                       }
+               }
+       }
+       CTX_DATA_END;
+       
+       /* updates */
+       WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+       return OPERATOR_FINISHED;
+}
+
+void GPENCIL_OT_select_less(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Select Less";
+       ot->idname = "GPENCIL_OT_select_less";
+       ot->description = "Shrink sets of selected Grease Pencil points";
+       
+       /* callbacks */
+       ot->exec = gpencil_select_less_exec;
+       ot->poll = gpencil_select_poll;
+       
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* ********************************************** */
 /* Circle Select Operator */
 
 /* Helper to check if a given stroke is within the area */

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

Reply via email to