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:
authorDiego Borghetti <bdiego@gmail.com>2010-05-13 02:29:32 +0400
committerDiego Borghetti <bdiego@gmail.com>2010-05-13 02:29:32 +0400
commitd0802b4db29a888515b20b7b1976be67f1537f90 (patch)
treeba8c499bdce891c294d08fa8065654eae59ee5a3 /source/blender/editors/object/object_select.c
parent98e0b07b51d8f6a4e04eae78ae311b67d82ceadf (diff)
Bring back the pupmenu for "select object in the same group"
when the object have more that one group. I put a XXX because the selection function use G.main to get the group, probably we need a CTX_DATA_BEGIN for groups ? Brecht ? Campbell ? I make a new operator for the pupmenu, it's only for the selection menu, so don't have any key binding. Matt, can you check ?
Diffstat (limited to 'source/blender/editors/object/object_select.c')
-rw-r--r--source/blender/editors/object/object_select.c90
1 files changed, 65 insertions, 25 deletions
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 01821612e9e..47168d2b9c0 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -60,6 +60,8 @@
#include "ED_screen.h"
+#include "UI_interface.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -403,14 +405,12 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in
{
short changed = 0;
Group *group, *ob_groups[GROUP_MENU_MAX];
- //char str[10 + (24*GROUP_MENU_MAX)];
- //char *p = str;
- int group_count=0; //, menu, i;
-
- for ( group=G.main->group.first;
- group && group_count < GROUP_MENU_MAX;
- group=group->id.next
- ) {
+ int group_count=0, i;
+ uiPopupMenu *pup;
+ uiLayout *layout;
+
+ // XXX G.main ?
+ for (group=G.main->group.first; group && group_count < GROUP_MENU_MAX; group=group->id.next) {
if (object_in_group (ob, group)) {
ob_groups[group_count] = group;
group_count++;
@@ -419,7 +419,6 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in
if (!group_count)
return 0;
-
else if (group_count == 1) {
group = ob_groups[0];
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
@@ -431,27 +430,18 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in
CTX_DATA_END;
return changed;
}
-#if 0 // XXX hows this work in 2.5?
+
/* build the menu. */
- p += sprintf(str, "Groups%%t");
+ pup= uiPupMenuBegin(C, "Select Group", 0);
+ layout= uiPupMenuLayout(pup);
+
for (i=0; i<group_count; i++) {
group = ob_groups[i];
- p += sprintf (p, "|%s%%x%i", group->id.name+2, i);
+ uiItemStringO(layout, group->id.name+2, 0, "OBJECT_OT_select_same_group", "group", group->id.name);
}
- menu = pupmenu (str);
- if (menu == -1)
- return 0;
-
- group = ob_groups[menu];
- for (base= FIRSTBASE; base; base= base->next) {
- if (!(base->flag & SELECT) && object_in_group(base->object, group)) {
- ED_base_object_select(base, BA_SELECT);
- changed = 1;
- }
- }
-#endif
- return changed;
+ uiPupMenuEnd(C, pup);
+ return changed; // The operator already handle this!
}
static short select_grouped_object_hooks(bContext *C, Object *ob)
@@ -786,6 +776,56 @@ void OBJECT_OT_select_all(wmOperatorType *ot)
WM_operator_properties_select_all(ot);
}
+/**************************** Select In The Same Group ****************************/
+
+static int object_select_same_group_exec(bContext *C, wmOperator *op)
+{
+ Group *group;
+ char group_name[32];
+
+ /* passthrough if no objects are visible */
+ if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH;
+
+ RNA_string_get(op->ptr, "group", group_name);
+
+ // XXX G.main ?
+ for (group=G.main->group.first; group; group=group->id.next) {
+ if (!strcmp(group->id.name, group_name))
+ break;
+ }
+
+ if (!group)
+ return OPERATOR_PASS_THROUGH;
+
+ CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
+ if (!(base->flag & SELECT) && object_in_group(base->object, group))
+ ED_base_object_select(base, BA_SELECT);
+ }
+ CTX_DATA_END;
+
+ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_select_same_group(wmOperatorType *ot)
+{
+
+ /* identifiers */
+ ot->name= "select same group";
+ ot->description = "Select object in the same group";
+ ot->idname= "OBJECT_OT_select_same_group";
+
+ /* api callbacks */
+ ot->exec= object_select_same_group_exec;
+ ot->poll= ED_operator_scene_editable;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_string(ot->srna, "group", "", 32, "Group", "Name of the group to select.");
+}
+
/**************************** Select Mirror ****************************/
/* finds the best possible flipped name. For renaming; check for unique names afterwards */