[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47102] branches/soc-2011-tomato/source/ blender: make selection operator follow mesh selection options from trunk.
Campbell Barton
ideasman42 at gmail.com
Mon May 28 07:37:16 CEST 2012
Revision: 47102
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47102
Author: campbellbarton
Date: 2012-05-28 05:37:16 +0000 (Mon, 28 May 2012)
Log Message:
-----------
make selection operator follow mesh selection options from trunk.
Modified Paths:
--------------
branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
branches/soc-2011-tomato/source/blender/editors/mask/mask_select.c
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-28 05:25:29 UTC (rev 47101)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_mask.h 2012-05-28 05:37:16 UTC (rev 47102)
@@ -73,6 +73,9 @@
struct MaskSplinePointUW *BKE_mask_point_sort_uw(struct MaskSplinePoint *point, struct MaskSplinePointUW *uw);
void BKE_mask_point_add_uw(struct MaskSplinePoint *point, float u, float w);
+void BKE_mask_point_select_set(struct MaskSplinePoint *point, int select);
+void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point, int select);
+
/* general */
struct Mask *BKE_mask_new(const char *name);
@@ -134,5 +137,6 @@
#define MASKPOINT_HANDLE_ONLY_ISSEL(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) && (((p)->bezt.f2 & SELECT) == 0) )
#define MASKPOINT_HANDLE_ISSEL(p) ( (((p)->bezt.f1 | (p)->bezt.f2) & SELECT) )
#define MASKPOINT_HANDLE_SEL(p) { (p)->bezt.f1 |= SELECT; (p)->bezt.f3 |= SELECT; } (void)0
+#define MASKPOINT_HANDLE_DESEL(p) { (p)->bezt.f1 &= ~SELECT; (p)->bezt.f3 &= ~SELECT; } (void)0
#endif
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-28 05:25:29 UTC (rev 47101)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/mask.c 2012-05-28 05:37:16 UTC (rev 47102)
@@ -41,6 +41,7 @@
#include "DNA_mask_types.h"
#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_movieclip_types.h"
@@ -618,6 +619,37 @@
BKE_mask_point_sort_uw(point, &point->uw[point->tot_uw - 1]);
}
+void BKE_mask_point_select_set(MaskSplinePoint *point, int select)
+{
+ int i;
+
+ if (select) {
+ MASKPOINT_SEL(point);
+ }
+ else {
+ MASKPOINT_DESEL(point);
+ }
+
+ for (i = 0; i < point->tot_uw; i++) {
+ if (select) {
+ point->uw[i].flag |= SELECT;
+ }
+ else {
+ point->uw[i].flag &= ~SELECT;
+ }
+ }
+}
+
+void BKE_mask_point_select_set_handle(MaskSplinePoint *point, int select)
+{
+ if (select) {
+ MASKPOINT_HANDLE_SEL(point);
+ }
+ else {
+ MASKPOINT_HANDLE_DESEL(point);
+ }
+}
+
/* only mask block itself */
static Mask *mask_alloc(const char *name)
{
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c 2012-05-28 05:25:29 UTC (rev 47101)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_editor.c 2012-05-28 05:37:16 UTC (rev 47102)
@@ -189,10 +189,15 @@
WM_keymap_add_item(keymap, "MASK_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MASK_OT_delete", DELKEY, KM_PRESS, 0, 0);
- /* select */
- WM_keymap_add_item(keymap, "MASK_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+ /* selection */
+ kmi = WM_keymap_add_item(keymap, "MASK_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+ RNA_boolean_set(kmi->ptr, "extend", FALSE);
+ RNA_boolean_set(kmi->ptr, "deselect", FALSE);
+ RNA_boolean_set(kmi->ptr, "toggle", FALSE);
kmi = WM_keymap_add_item(keymap, "MASK_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
- RNA_boolean_set(kmi->ptr, "extend", TRUE);
+ RNA_boolean_set(kmi->ptr, "extend", FALSE);
+ RNA_boolean_set(kmi->ptr, "deselect", FALSE);
+ RNA_boolean_set(kmi->ptr, "toggle", TRUE);
kmi = WM_keymap_add_item(keymap, "MASK_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h 2012-05-28 05:25:29 UTC (rev 47101)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_intern.h 2012-05-28 05:37:16 UTC (rev 47102)
@@ -73,7 +73,8 @@
int ED_mask_spline_select_check(struct MaskSplinePoint *points, int tot_point);
int ED_mask_select_check(struct Mask *mask);
-void ED_mask_point_select(struct MaskSplinePoint *point, int action);
+void ED_mask_point_select_set(struct MaskSplinePoint *point, int action);
+void ED_mask_point_select_set_handle(struct MaskSplinePoint *point, int select);
void ED_mask_select_toggle_all(struct Mask *mask, int action);
void ED_mask_select_flush_all(struct Mask *mask);
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-28 05:25:29 UTC (rev 47101)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_ops.c 2012-05-28 05:37:16 UTC (rev 47102)
@@ -646,7 +646,7 @@
else if (!MASKPOINT_ISSEL(slidedata->point)) {
ED_mask_select_toggle_all(mask, SEL_DESELECT);
- ED_mask_point_select(slidedata->point, SEL_SELECT);
+ BKE_mask_point_select_set(slidedata->point, TRUE);
ED_mask_select_flush_all(mask);
}
Modified: branches/soc-2011-tomato/source/blender/editors/mask/mask_select.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/mask/mask_select.c 2012-05-28 05:25:29 UTC (rev 47101)
+++ branches/soc-2011-tomato/source/blender/editors/mask/mask_select.c 2012-05-28 05:37:16 UTC (rev 47102)
@@ -86,38 +86,6 @@
return FALSE;
}
-void ED_mask_point_select(MaskSplinePoint *point, int action)
-{
- int i;
-
- switch (action) {
- case SEL_SELECT:
- MASKPOINT_SEL(point);
- break;
- case SEL_DESELECT:
- MASKPOINT_DESEL(point);
- break;
- case SEL_INVERT:
- MASKPOINT_INVSEL(point);
- break;
- }
-
- for (i = 0; i < point->tot_uw; i++) {
- switch (action) {
- case SEL_SELECT:
- point->uw[i].flag |= SELECT;
- break;
- case SEL_DESELECT:
- point->uw[i].flag &= ~SELECT;
- break;
- case SEL_INVERT:
- point->uw[i].flag ^= SELECT;
- break;
- }
- }
-}
-
-
void ED_mask_select_toggle_all(Mask *mask, int action)
{
MaskObject *maskobj;
@@ -138,7 +106,7 @@
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- ED_mask_point_select(point, action);
+ BKE_mask_point_select_set(point, (action == SEL_SELECT) ? TRUE : FALSE);
}
}
}
@@ -219,7 +187,10 @@
MaskSpline *spline;
MaskSplinePoint *point = NULL;
float co[2];
- int extend = RNA_boolean_get(op->ptr, "extend");
+ short extend = RNA_boolean_get(op->ptr, "extend");
+ short deselect = RNA_boolean_get(op->ptr, "deselect");
+ short toggle = RNA_boolean_get(op->ptr, "toggle");
+
int is_handle = 0;
const float threshold = 19;
@@ -228,14 +199,52 @@
point = ED_mask_point_find_nearest(C, mask, co, threshold, &maskobj, &spline, &is_handle, NULL);
if (point) {
- if (!extend)
+ if (extend == 0 && deselect == 0 && toggle == 0)
ED_mask_select_toggle_all(mask, SEL_DESELECT);
if (is_handle) {
- MASKPOINT_HANDLE_SEL(point);
+ if (extend) {
+ maskobj->act_spline = spline;
+ maskobj->act_point = point;
+
+ BKE_mask_point_select_set_handle(point, TRUE);
+ }
+ else if (deselect) {
+ BKE_mask_point_select_set_handle(point, FALSE);
+ }
+ else {
+ maskobj->act_spline = spline;
+ maskobj->act_point = point;
+
+ if (!MASKPOINT_HANDLE_ISSEL(point)) {
+ BKE_mask_point_select_set_handle(point, TRUE);
+ }
+ else if (toggle) {
+ BKE_mask_point_select_set_handle(point, FALSE);
+ }
+ }
}
else {
- ED_mask_point_select(point, SEL_SELECT);
+ if (extend) {
+ maskobj->act_spline = spline;
+ maskobj->act_point = point;
+
+ BKE_mask_point_select_set(point, TRUE);
+ }
+ else if (deselect) {
+ BKE_mask_point_select_set(point, FALSE);
+ }
+ else {
+ maskobj->act_spline = spline;
+ maskobj->act_point = point;
+
+ if (!MASKPOINT_ISSEL(point)) {
+ BKE_mask_point_select_set(point, TRUE);
+ }
+ else if (toggle) {
+ BKE_mask_point_select_set(point, FALSE);
+ }
+ }
}
maskobj->act_spline = spline;
@@ -298,8 +307,10 @@
ot->flag = OPTYPE_UNDO;
/* properties */
- RNA_def_boolean(ot->srna, "extend", 0,
- "Extend", "Extend selection rather than clearing the existing selection");
+ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first");
+ RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from selection");
+ RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Selection", "Toggles selection");
+
RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
"Location", "Location of vertex in normalized space", -1.0f, 1.0f);
}
More information about the Bf-blender-cvs
mailing list