Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2016-01-22 05:31:20 +0300
committerJoshua Leung <aligorith@gmail.com>2016-01-22 05:31:42 +0300
commit017c45b966eccef9902154362d1c2aef661d0622 (patch)
treef76eb5ee5c6f764d692f8072848e89b57bd1dae6 /source/blender/editors/gpencil/gpencil_select.c
parent8e35657beb595e0b5f1ac2a594ab36bb306cbf6e (diff)
GPencil: Select Grouped (Shift G)
This commit adds a "Select Grouped" operator. Although it is set up to allow more types of "grouping" in future, it current only supports a single mode (i.e. "Same Layer"). As a result, it does not pop up any menus/submenus in all the usual places.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_select.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 83a1f2458eb..0a36df471f1 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -41,6 +41,7 @@
#include "BLI_math_vector.h"
#include "DNA_gpencil_types.h"
+#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_context.h"
@@ -245,6 +246,109 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot)
}
/* ********************************************** */
+/* Select Grouped */
+
+typedef enum eGP_SelectGrouped {
+ /* Select strokes in the same layer */
+ GP_SEL_SAME_LAYER = 0,
+
+ /* TODO: All with same prefix - Useful for isolating all layers for a particular character for instance */
+ /* TODO: All with same appearance - colour/opacity/volumetric/fills ? */
+} eGP_SelectGrouped;
+
+/* ----------------------------------- */
+
+/* On each visible layer, check for selected strokes - if found, select all others */
+static void gp_select_same_layer(bContext *C)
+{
+ Scene *scene = CTX_data_scene(C);
+
+ CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
+ {
+ bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0);
+ bGPDstroke *gps;
+ bool found = false;
+
+ if (gpf == NULL)
+ continue;
+
+ /* Search for a selected stroke */
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ if (ED_gpencil_stroke_can_use(C, gps)) {
+ if (gps->flag & GP_STROKE_SELECT) {
+ found = true;
+ break;
+ }
+ }
+ }
+
+ /* Select all if found */
+ if (found) {
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ if (ED_gpencil_stroke_can_use(C, gps)) {
+ bGPDspoint *pt;
+ int i;
+
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ pt->flag |= GP_SPOINT_SELECT;
+ }
+
+ gps->flag |= GP_STROKE_SELECT;
+ }
+ }
+ }
+ }
+ CTX_DATA_END;
+}
+
+
+
+/* ----------------------------------- */
+
+static int gpencil_select_grouped_exec(bContext *C, wmOperator *op)
+{
+ eGP_SelectGrouped mode = RNA_enum_get(op->ptr, "type");
+
+ switch (mode) {
+ case GP_SEL_SAME_LAYER:
+ gp_select_same_layer(C);
+ break;
+
+ default:
+ BLI_assert(!"unhandled select grouped gpencil mode");
+ break;
+ }
+
+ /* updates */
+ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+ return OPERATOR_FINISHED;
+}
+
+void GPENCIL_OT_select_grouped(wmOperatorType *ot)
+{
+ static EnumPropertyItem prop_select_grouped_types[] = {
+ {GP_SEL_SAME_LAYER, "LAYER", 0, "Layer", "Shared layers"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Select Grouped";
+ ot->idname = "GPENCIL_OT_select_grouped";
+ ot->description = "Select all strokes with similar characteristics";
+
+ /* callbacks */
+ //ot->invoke = WM_menu_invoke;
+ ot->exec = gpencil_select_grouped_exec;
+ ot->poll = gpencil_select_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, GP_SEL_SAME_LAYER, "Type", "");
+}
+
+/* ********************************************** */
/* Select More */
static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op))