Fix #27165: uvedit mesh selection sync did not handle click / shift+click
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 2 May 2011 11:34:57 +0000 (11:34 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 2 May 2011 11:34:57 +0000 (11:34 +0000)
for switching selection modes in the header.

release/scripts/startup/bl_ui/space_image.py
source/blender/editors/include/UI_interface.h
source/blender/editors/space_view3d/view3d_header.c
source/blender/makesrna/intern/rna_ui_api.c

index da6318ed39e6339c3d4a35d7503813a78e3c95a8..0bdc239c408703dcfecfbde50265babd5ad456b5 100644 (file)
@@ -370,10 +370,7 @@ class IMAGE_HT_header(bpy.types.Header):
             layout.prop(toolsettings, "use_uv_select_sync", text="")
 
             if toolsettings.use_uv_select_sync:
-                row = layout.row(align=True)
-                row.prop(toolsettings, "mesh_select_mode", text="", index=0, icon='VERTEXSEL')
-                row.prop(toolsettings, "mesh_select_mode", text="", index=1, icon='EDGESEL')
-                row.prop(toolsettings, "mesh_select_mode", text="", index=2, icon='FACESEL')
+               layout.template_edit_mode_selection()
             else:
                 layout.prop(toolsettings, "uv_select_mode", text="", expand=True)
                 layout.prop(uvedit, "sticky_select_mode", text="", icon_only=True)
index e0f344106738a6843428934ba99c682210a824c3..821f0e05a369df2e1dbd5124a93f1961fb8d1f9a 100644 (file)
@@ -712,6 +712,7 @@ void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *i
 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
 void uiTemplateOperatorSearch(uiLayout *layout);
 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
+void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
 void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
 void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
 
index 939c44a0514d0a598a043ea4ef3fb8509387695b..63c3c6901c38a559557346837608703b8152a32f 100644 (file)
@@ -432,6 +432,27 @@ static int object_mode_icon(int mode)
        return ICON_OBJECT_DATAMODE;
 }
 
+void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
+{
+       Object *obedit = CTX_data_edit_object(C);
+       uiBlock *block= uiLayoutGetBlock(layout);
+
+       uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
+
+       if(obedit && (obedit->type == OB_MESH)) {
+               EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+               uiLayout *row;
+
+               row= uiLayoutRow(layout, 1);
+               block= uiLayoutGetBlock(row);
+               uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
+               uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
+               uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
+
+               BKE_mesh_end_editmesh(obedit->data, em);
+       }
+}
+
 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 {
        bScreen *screen= CTX_wm_screen(C);
@@ -527,16 +548,6 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
                uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
        }
        
-       /* selection modus, dont use python for this since it cant do the toggle buttons with shift+click as well as clicking to set one. */
-       if(obedit && (obedit->type == OB_MESH)) {
-               EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
-               row= uiLayoutRow(layout, 1);
-               block= uiLayoutGetBlock(row);
-               uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
-               uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
-               uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
-
-               BKE_mesh_end_editmesh(obedit->data, em);
-       }
+       uiTemplateEditModeSelection(layout, C);
 }
+
index 2ee19b07d8631091eaf15c3a6327e58fff6ab252..ae308b9423f4ac253bd1f9bbd6bc352017dbbdbb 100644 (file)
@@ -414,6 +414,9 @@ void RNA_api_ui_layout(StructRNA *srna)
 
        func= RNA_def_function(srna, "template_header_3D", "uiTemplateHeader3D");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+
+       func= RNA_def_function(srna, "template_edit_mode_selection", "uiTemplateEditModeSelection");
+       RNA_def_function_flag(func, FUNC_USE_CONTEXT);
        
        func= RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);