2.5 3D_View:

Patch [#19031] (2.5) python menus for the view3d header
by Lorenzo Pierfederici (lento). Thanks!

* Added CTX_data_mode_string() to find out in which mode we're in.
* Added some "select" menus as a test.

This patch makes it basically possible to wrap the 3D View menus to python.
This commit is contained in:
2009-08-15 19:40:09 +00:00
parent ca906df5cc
commit 0ce5163cc0
11 changed files with 400 additions and 302 deletions

View File

@@ -95,6 +95,256 @@ class VIEW3D_MT_view(bpy.types.Menu):
layout.itemO("screen.region_foursplit", text="Toggle Quad View")
layout.itemO("screen.screen_full_area", text="Toggle Full Screen")
# ********** Select menus ****************
class VIEW3D_MT_select_objectmode(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemS()
layout.itemO("object.select_all_toggle", text="Select/Deselect All")
layout.itemO("object.select_inverse", text="Inverse")
layout.itemO("object.select_random", text="Random")
layout.itemO("object.select_by_layer", text="Select All by Layer")
layout.item_enumO("object.select_by_type", "type", "", text="Select All by Type")
layout.item_enumO("object.select_grouped", "type", "", text="Select Grouped")
class VIEW3D_MT_select_posemode(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemS()
layout.itemO("pose.select_all_toggle", text="Select/Deselect All")
layout.itemO("pose.select_inverse", text="Inverse")
layout.itemO("pose.select_constraint_target", text="Constraint Target")
layout.itemS()
layout.item_enumO("pose.select_hierarchy", "direction", "PARENT")
layout.item_enumO("pose.select_hierarchy", "direction", "CHILD")
layout.itemS()
layout.view3d_select_posemenu()
class VIEW3D_MT_select_particlemode(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemS()
layout.itemO("particle.select_all_toggle", text="Select/Deselect All")
layout.itemO("particle.select_linked")
layout.itemS()
#layout.itemO("particle.select_last")
#layout.itemO("particle.select_first")
layout.itemO("particle.select_more")
layout.itemO("particle.select_less")
class VIEW3D_MT_select_meshedit(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemS()
layout.itemO("mesh.select_all_toggle", text="Select/Deselect All")
layout.itemO("mesh.select_inverse", text="Inverse")
layout.itemS()
layout.itemO("mesh.select_random", text="Random...")
layout.itemO("mesh.edges_select_sharp", text="Sharp Edges")
layout.itemO("mesh.faces_select_linked_flat", text="Linked Flat Faces")
layout.itemS()
layout.item_enumO("mesh.select_by_number_vertices", "type", "TRIANGLES", text="Triangles")
layout.item_enumO("mesh.select_by_number_vertices", "type", "QUADS", text="Quads")
layout.item_enumO("mesh.select_by_number_vertices", "type", "OTHER", text="Loose Verts/Edges")
layout.itemO("mesh.select_similar", text="Similar...")
layout.itemS()
layout.itemO("mesh.select_less", text="Less")
layout.itemO("mesh.select_more", text="More")
layout.itemS()
layout.itemO("mesh.select_linked", text="Linked")
layout.itemO("mesh.select_vertex_path", text="Vertex Path")
layout.itemO("mesh.loop_multi_select", text="Edge Loop")
layout.item_booleanO("mesh.loop_multi_select", "ring", True, text="Edge Ring")
layout.itemS()
layout.itemO("mesh.loop_to_region")
layout.itemO("mesh.region_to_loop")
class VIEW3D_MT_select_curveedit(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemO("view3d.select_circle")
layout.itemS()
layout.itemO("curve.select_all_toggle", text="Select/Deselect All")
layout.itemO("curve.select_inverse")
layout.itemO("curve.select_random")
layout.itemO("curve.select_every_nth")
layout.itemS()
layout.itemO("curve.de_select_first")
layout.itemO("curve.de_select_last")
layout.itemO("curve.select_next")
layout.itemO("curve.select_previous")
layout.itemS()
layout.itemO("curve.select_more")
layout.itemO("curve.select_less")
class VIEW3D_MT_select_surfaceedit(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemO("view3d.select_circle")
layout.itemS()
layout.itemO("curve.select_all_toggle", text="Select/Deselect All")
layout.itemO("curve.select_inverse")
layout.itemO("curve.select_random")
layout.itemO("curve.select_every_nth")
layout.itemS()
layout.itemO("curve.select_row")
layout.itemS()
layout.itemO("curve.select_more")
layout.itemO("curve.select_less")
class VIEW3D_MT_select_mballedit(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemS()
layout.itemL(text="Select/Deselect All")
layout.itemL(text="Inverse")
layout.itemS()
layout.itemL(text="Random")
class VIEW3D_MT_select_latticeedit(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemS()
layout.itemO("lattice.select_all_toggle", text="Select/Deselect All")
class VIEW3D_MT_select_armatureedit(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.itemO("view3d.select_border")
layout.itemS()
layout.itemO("armature.select_all_toggle", text="Select/Deselect All")
layout.itemO("armature.select_inverse", text="Inverse")
layout.itemS()
layout.item_enumO("armature.select_hierarchy", "direction", "PARENT")
layout.item_enumO("armature.select_hierarchy", "direction", "CHILD")
layout.itemS()
layout.view3d_select_armaturemenu()
class VIEW3D_MT_select_facesel(bpy.types.Menu):
__space_type__ = "VIEW_3D"
__label__ = "Select"
def draw(self, context):
layout = self.layout
layout.view3d_select_faceselmenu()
class VIEW3D_HT_header(bpy.types.Header):
__space_type__ = "VIEW_3D"
def draw(self, context):
view = context.space_data
mode_string = context.mode_string
layout = self.layout
layout.template_header()
# menus
if context.area.show_menus:
row = layout.row()
row.itemM("VIEW3D_MT_view")
selectmenu = "VIEW3D_MT_select_%s" % mode_string
if selectmenu in dir(bpy.types):
layout.itemM(selectmenu)
layout.template_header_3D()
# ********** Panel ****************
class VIEW3D_PT_3dview_properties(bpy.types.Panel):
@@ -200,6 +450,16 @@ class VIEW3D_PT_background_image(bpy.types.Panel):
bpy.types.register(VIEW3D_MT_view_navigation)
bpy.types.register(VIEW3D_MT_view)
bpy.types.register(VIEW3D_MT_select_objectmode)
bpy.types.register(VIEW3D_MT_select_posemode)
bpy.types.register(VIEW3D_MT_select_particlemode)
bpy.types.register(VIEW3D_MT_select_meshedit)
bpy.types.register(VIEW3D_MT_select_curveedit)
bpy.types.register(VIEW3D_MT_select_surfaceedit)
bpy.types.register(VIEW3D_MT_select_mballedit)
bpy.types.register(VIEW3D_MT_select_latticeedit)
bpy.types.register(VIEW3D_MT_select_armatureedit)
bpy.types.register(VIEW3D_MT_select_facesel)
bpy.types.register(VIEW3D_HT_header)
bpy.types.register(VIEW3D_PT_3dview_properties)
bpy.types.register(VIEW3D_PT_3dview_display)

View File

@@ -1,14 +1,15 @@
import bpy
# ********** default tools for objectmode ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "objectmode"
# ********** default tools for objectmode ****************
class VIEW3D_PT_tools_objectmode(View3DPanel):
__context__ = "objectmode"
__label__ = "Object Tools"
def draw(self, context):
@@ -43,12 +44,8 @@ class VIEW3D_PT_tools_objectmode(View3DPanel):
# ********** default tools for editmode_mesh ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "editmode_mesh"
class VIEW3D_PT_tools_editmode_mesh(View3DPanel):
class VIEW3D_PT_tools_meshedit(View3DPanel):
__context__ = "meshedit"
__label__ = "Mesh Tools"
def draw(self, context):
@@ -90,12 +87,8 @@ class VIEW3D_PT_tools_editmode_mesh(View3DPanel):
# ********** default tools for editmode_curve ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "editmode_curve"
class VIEW3D_PT_tools_editmode_curve(View3DPanel):
class VIEW3D_PT_tools_curveedit(View3DPanel):
__context__ = "curveedit"
__label__ = "Curve Tools"
def draw(self, context):
@@ -124,12 +117,8 @@ class VIEW3D_PT_tools_editmode_curve(View3DPanel):
# ********** default tools for editmode_surface ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "editmode_surface"
class VIEW3D_PT_tools_editmode_surface(View3DPanel):
class VIEW3D_PT_tools_surfaceedit(View3DPanel):
__context__ = "surfaceedit"
__label__ = "Surface Tools"
def draw(self, context):
@@ -158,12 +147,8 @@ class VIEW3D_PT_tools_editmode_surface(View3DPanel):
# ********** default tools for editmode_text ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "editmode_text"
class VIEW3D_PT_tools_editmode_text(View3DPanel):
class VIEW3D_PT_tools_textedit(View3DPanel):
__context__ = "textedit"
__label__ = "Text Tools"
def draw(self, context):
@@ -179,12 +164,8 @@ class VIEW3D_PT_tools_editmode_text(View3DPanel):
# ********** default tools for editmode_armature ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "editmode_armature"
class VIEW3D_PT_tools_editmode_armature(View3DPanel):
class VIEW3D_PT_tools_armatureedit(View3DPanel):
__context__ = "armatureedit"
__label__ = "Armature Tools"
def draw(self, context):
@@ -209,12 +190,8 @@ class VIEW3D_PT_tools_editmode_armature(View3DPanel):
# ********** default tools for editmode_mball ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "editmode_mball"
class VIEW3D_PT_tools_editmode_mball(View3DPanel):
class VIEW3D_PT_tools_mballedit(View3DPanel):
__context__ = "mballedit"
__label__ = "Meta Tools"
def draw(self, context):
@@ -229,12 +206,8 @@ class VIEW3D_PT_tools_editmode_mball(View3DPanel):
# ********** default tools for editmode_lattice ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "editmode_lattice"
class VIEW3D_PT_tools_editmode_lattice(View3DPanel):
class VIEW3D_PT_tools_latticeedit(View3DPanel):
__context__ = "latticeedit"
__label__ = "Lattice Tools"
def draw(self, context):
@@ -249,12 +222,8 @@ class VIEW3D_PT_tools_editmode_lattice(View3DPanel):
# ********** default tools for posemode ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "pose_mode"
class VIEW3D_PT_tools_posemode(View3DPanel):
__context__ = "posemode"
__label__ = "Pose Tools"
def draw(self, context):
@@ -492,12 +461,8 @@ class VIEW3D_PT_sculpt_options(PaintPanel):
# ********** default tools for weightpaint ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "weight_paint"
class VIEW3D_PT_weight_paint_options(View3DPanel):
class VIEW3D_PT_tools_weightpaint(View3DPanel):
__context__ = "weightpaint"
__label__ = "Options"
def draw(self, context):
@@ -523,12 +488,8 @@ class VIEW3D_PT_weight_paint_options(View3DPanel):
# ********** default tools for vertexpaint ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
class VIEW3D_PT_vertex_paint_options(View3DPanel):
__context__ = "vertex_paint"
class VIEW3D_PT_tools_vertexpaint(View3DPanel):
__context__ = "vertexpaint"
__label__ = "Options"
def draw(self, context):
@@ -551,12 +512,8 @@ class VIEW3D_PT_vertex_paint_options(View3DPanel):
# ********** default tools for texturepaint ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "texture_paint"
class VIEW3D_PT_tools_texture_paint(View3DPanel):
class VIEW3D_PT_tools_texturepaint(View3DPanel):
__context__ = "texturepaint"
__label__ = "Options"
def draw(self, context):
@@ -584,12 +541,8 @@ class VIEW3D_PT_tools_texture_paint(View3DPanel):
# ********** default tools for particle mode ****************
class View3DPanel(bpy.types.Panel):
__space_type__ = "VIEW_3D"
__region_type__ = "TOOLS"
__context__ = "particle_mode"
class VIEW3D_PT_tools_particle_edit(View3DPanel):
class VIEW3D_PT_tools_particlemode(View3DPanel):
__context__ = "particlemode"
__label__ = "Options"
def draw(self, context):
@@ -613,18 +566,18 @@ class VIEW3D_PT_tools_particle_edit(View3DPanel):
col.itemR(pe, "show_children", text="Children")
bpy.types.register(VIEW3D_PT_tools_objectmode)
bpy.types.register(VIEW3D_PT_tools_editmode_mesh)
bpy.types.register(VIEW3D_PT_tools_editmode_curve)
bpy.types.register(VIEW3D_PT_tools_editmode_surface)
bpy.types.register(VIEW3D_PT_tools_editmode_text)
bpy.types.register(VIEW3D_PT_tools_editmode_armature)
bpy.types.register(VIEW3D_PT_tools_editmode_mball)
bpy.types.register(VIEW3D_PT_tools_editmode_lattice)
bpy.types.register(VIEW3D_PT_tools_meshedit)
bpy.types.register(VIEW3D_PT_tools_curveedit)
bpy.types.register(VIEW3D_PT_tools_surfaceedit)
bpy.types.register(VIEW3D_PT_tools_textedit)
bpy.types.register(VIEW3D_PT_tools_armatureedit)
bpy.types.register(VIEW3D_PT_tools_mballedit)
bpy.types.register(VIEW3D_PT_tools_latticeedit)
bpy.types.register(VIEW3D_PT_tools_posemode)
bpy.types.register(VIEW3D_PT_tools_brush)
bpy.types.register(VIEW3D_PT_tools_brush_curve)
bpy.types.register(VIEW3D_PT_sculpt_options)
bpy.types.register(VIEW3D_PT_vertex_paint_options)
bpy.types.register(VIEW3D_PT_weight_paint_options)
bpy.types.register(VIEW3D_PT_tools_texture_paint)
bpy.types.register(VIEW3D_PT_tools_particle_edit)
bpy.types.register(VIEW3D_PT_tools_vertexpaint)
bpy.types.register(VIEW3D_PT_tools_weightpaint)
bpy.types.register(VIEW3D_PT_tools_texturepaint)
bpy.types.register(VIEW3D_PT_tools_particlemode)

View File

@@ -191,6 +191,8 @@ struct Main *CTX_data_main(const bContext *C);
struct Scene *CTX_data_scene(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
char *CTX_data_mode_string(const bContext *C);
void CTX_data_main_set(bContext *C, struct Main *bmain);
void CTX_data_scene_set(bContext *C, struct Scene *bmain);

View File

@@ -34,6 +34,7 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_object_types.h"
#include "RNA_access.h"
@@ -43,6 +44,7 @@
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_global.h"
#include <string.h>
@@ -659,6 +661,42 @@ Scene *CTX_data_scene(const bContext *C)
return C->data.scene;
}
char *CTX_data_mode_string(const bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
if(obedit) {
switch(obedit->type) {
case OB_MESH:
return "meshedit";
case OB_CURVE:
return "curveedit";
case OB_SURF:
return "surfaceedit";
case OB_FONT:
return "textedit";
case OB_ARMATURE:
return "armatureedit";
case OB_MBALL:
return "mballedit";
case OB_LATTICE:
return "latticeedit";
}
}
else {
Object *ob = CTX_data_active_object(C);
if(ob && (ob->flag & OB_POSEMODE)) return "posemode";
else if (ob && ob->mode & OB_MODE_SCULPT) return "sculpt_mode";
else if (G.f & G_WEIGHTPAINT) return "weightpaint";
else if (G.f & G_VERTEXPAINT) return "vertexpaint";
else if (G.f & G_TEXTUREPAINT) return "texturepaint";
else if(G.f & G_PARTICLEEDIT) return "particlemode";
}
return "objectmode";
}
void CTX_data_scene_set(bContext *C, Scene *scene)
{
C->data.scene= scene;

View File

@@ -638,6 +638,10 @@ 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 uiTemplate_view3d_select_metaballmenu(uiLayout *layout, struct bContext *C);
void uiTemplate_view3d_select_armaturemenu(uiLayout *layout, struct bContext *C);
void uiTemplate_view3d_select_posemenu(uiLayout *layout, struct bContext *C);
void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, struct bContext *C);
void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
typedef struct uiListItem {

View File

@@ -595,7 +595,7 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar)
static void view3d_tools_area_draw(const bContext *C, ARegion *ar)
{
ED_region_panels(C, ar, 1, view3d_context_string(C), -1);
ED_region_panels(C, ar, 1, CTX_data_mode_string(C), -1);
}
static int view3d_context(const bContext *C, const char *member, bContextDataResult *result)

View File

@@ -970,112 +970,6 @@ static uiBlock *view3d_select_object_groupedmenu(bContext *C, ARegion *ar, void
#endif
static void view3d_select_objectmenu(bContext *C, uiLayout *layout, void *arg_unused)
{
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
uiItemS(layout);
uiItemO(layout, "Select/Deselect All", 0, "OBJECT_OT_select_all_toggle");
uiItemO(layout, "Inverse", 0, "OBJECT_OT_select_inverse");
uiItemO(layout, "Random", 0, "OBJECT_OT_select_random");
uiItemO(layout, "Select All by Layer", 0, "OBJECT_OT_select_by_layer");
uiItemMenuEnumO(layout, "Select All by Type", 0, "OBJECT_OT_select_by_type", "type");
uiItemMenuEnumO(layout, "Select Grouped", 0, "OBJECT_OT_select_grouped", "type");
#if 0
uiDefIconTextBlockBut(block, view3d_select_object_layermenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Layer", 0, yco-=20, 120, 19, "");
uiDefIconTextBlockBut(block, view3d_select_object_typemenu, NULL, ICON_RIGHTARROW_THIN, "Select All by Type", 0, yco-=20, 120, 19, "");
uiItemS(layout);
uiDefIconTextBlockBut(block, view3d_select_object_linkedmenu, NULL, ICON_RIGHTARROW_THIN, "Linked", 0, yco-=20, 120, 19, "");
uiDefIconTextBlockBut(block, view3d_select_object_groupedmenu, NULL, ICON_RIGHTARROW_THIN, "Grouped", 0, yco-=20, 120, 19, "");
#endif
}
static void view3d_select_meshmenu(bContext *C, uiLayout *layout, void *arg_unused)
{
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
uiItemS(layout);
uiItemO(layout, "Select/Deselect All", 0, "MESH_OT_select_all_toggle");
uiItemO(layout, "Inverse", 0, "MESH_OT_select_inverse");
uiItemS(layout);
uiItemO(layout, "Random...", 0, "MESH_OT_select_random"); // Random...
uiItemO(layout, "Sharp Edges", 0, "MESH_OT_edges_select_sharp");
uiItemO(layout, "Linked Flat Faces", 0, "MESH_OT_faces_select_linked_flat");
uiItemS(layout);
uiItemEnumO(layout, "Triangles", 0, "MESH_OT_select_by_number_vertices", "type", 3); // Ctrl Alt Shift 3
uiItemEnumO(layout, "Quads", 0, "MESH_OT_select_by_number_vertices", "type", 4); // Ctrl Alt Shift 4
uiItemEnumO(layout, "Loose Verts/Edges", 0, "MESH_OT_select_by_number_vertices", "type", 5); // Ctrl Alt Shift 5
uiItemO(layout, "Similar...", 0, "MESH_OT_select_similar");
uiItemS(layout);
uiItemO(layout, "Less", 0, "MESH_OT_select_more");
uiItemO(layout, "More", 0, "MESH_OT_select_less");
uiItemS(layout);
uiItemO(layout, "Linked", 0, "MESH_OT_select_linked");
uiItemO(layout, "Vertex Path", 0, "MESH_OT_select_vertex_path"); // W, Alt 7
uiItemO(layout, "Edge Loop", 0, "MESH_OT_loop_multi_select");
uiItemBooleanO(layout, "Edge Ring", 0, "MESH_OT_loop_multi_select", "ring", 1);
uiItemS(layout);
uiItemO(layout, NULL, 0, "MESH_OT_loop_to_region"); // Ctrl E 8
uiItemO(layout, NULL, 0, "MESH_OT_region_to_loop"); // Ctrl E 9
}
static void view3d_select_curvemenu(bContext *C, uiLayout *layout, void *arg_unused)
{
Object *obedit= CTX_data_edit_object(C);
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_circle");
uiItemS(layout);
uiItemO(layout, NULL, 0, "CURVE_OT_select_all_toggle");
uiItemO(layout, NULL, 0, "CURVE_OT_select_inverse");
uiItemO(layout, NULL, 0, "CURVE_OT_select_random"); // Random...
uiItemO(layout, NULL, 0, "CURVE_OT_select_every_nth"); // Every Nth..
uiItemS(layout);
if(obedit->type == OB_SURF) {
uiItemO(layout, NULL, 0, "CURVE_OT_select_row");
}
else {
uiItemO(layout, NULL, 0, "CURVE_OT_de_select_first");
uiItemO(layout, NULL, 0, "CURVE_OT_de_select_last");
uiItemO(layout, NULL, 0, "CURVE_OT_select_next");
uiItemO(layout, NULL, 0, "CURVE_OT_select_previous");
}
uiItemS(layout);
uiItemO(layout, NULL, 0, "CURVE_OT_select_more");
uiItemO(layout, NULL, 0, "CURVE_OT_select_less");
/* commented out because it seems to only like the LKEY method - based on mouse pointer position :( */
/* uiItemO(layout, NULL, 0, "CURVE_OT_select_linked"); */
#if 0
G.qual |= LR_CTRLKEY;
select_connected_nurb();
G.qual &= ~LR_CTRLKEY;
break;*/
#endif
}
static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_unused)
{
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
@@ -1086,18 +980,20 @@ static void view3d_select_metaballmenu(bContext *C, uiLayout *layout, void *arg_
uiItemO(layout, NULL, 0, "MBALL_OT_select_random_metaelems");
}
static void view3d_select_latticemenu(bContext *C, uiLayout *layout, void *arg_unused)
/* wrapper for python layouts */
void uiTemplate_view3d_select_metaballmenu(uiLayout *layout, bContext *C)
{
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
uiItemS(layout);
uiItemO(layout, NULL, 0, "LATTICE_OT_select_all_toggle");
void *arg_unused = NULL;
ARegion *ar= CTX_wm_region(C);
view3d_select_metaballmenu(C, ar, arg_unused);
}
static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_unused)
{
PointerRNA ptr;
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
/* this part of the menu has been moved to python */
/*uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
uiItemS(layout);
@@ -1109,7 +1005,7 @@ static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_
uiItemEnumO(layout, "Parent", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT);
uiItemEnumO(layout, "Child", 0, "ARMATURE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD);
uiItemS(layout);
uiItemS(layout);*/
WM_operator_properties_create(&ptr, "ARMATURE_OT_select_hierarchy");
RNA_boolean_set(&ptr, "extend", 1);
@@ -1122,25 +1018,17 @@ static void view3d_select_armaturemenu(bContext *C, uiLayout *layout, void *arg_
uiItemFullO(layout, "Extend Child", 0, "ARMATURE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN);
}
/* wrapper for python layouts */
void uiTemplate_view3d_select_armaturemenu(uiLayout *layout, bContext *C)
{
void *arg_unused = NULL;
view3d_select_armaturemenu(C, layout, arg_unused);
}
static void view3d_select_posemenu(bContext *C, uiLayout *layout, void *arg_unused)
{
PointerRNA ptr;
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
uiItemS(layout);
uiItemO(layout, "Select/Deselect All", 0, "POSE_OT_select_all_toggle");
uiItemO(layout, "Inverse", 0, "POSE_OT_select_inverse");
uiItemO(layout, "Constraint Target", 0, "POSE_OT_select_constraint_target");
uiItemS(layout);
uiItemEnumO(layout, "Parent", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_PARENT);
uiItemEnumO(layout, "Child", 0, "POSE_OT_select_hierarchy", "direction", BONE_SELECT_CHILD);
uiItemS(layout);
WM_operator_properties_create(&ptr, "POSE_OT_select_hierarchy");
RNA_boolean_set(&ptr, "extend", 1);
RNA_enum_set(&ptr, "direction", BONE_SELECT_PARENT);
@@ -1152,6 +1040,13 @@ static void view3d_select_posemenu(bContext *C, uiLayout *layout, void *arg_unus
uiItemFullO(layout, "Extend Child", 0, "POSE_OT_select_hierarchy", ptr.data, WM_OP_EXEC_REGION_WIN);
}
/* wrapper for python layouts */
void uiTemplate_view3d_select_posemenu(uiLayout *layout, bContext *C)
{
void *arg_unused = NULL;
view3d_select_posemenu(C, layout, arg_unused);
}
void do_view3d_select_faceselmenu(bContext *C, void *arg, int event)
{
#if 0
@@ -1222,6 +1117,14 @@ static uiBlock *view3d_select_faceselmenu(bContext *C, ARegion *ar, void *arg_un
return block;
}
/* wrapper for python layouts */
void uiTemplate_view3d_select_faceselmenu(uiLayout *layout, bContext *C)
{
void *arg_unused = NULL;
ARegion *ar= CTX_wm_region(C);
view3d_select_faceselmenu(C, ar, arg_unused);
}
static void view3d_edit_snapmenu(bContext *C, uiLayout *layout, void *arg_unused)
{
uiItemO(layout, NULL, 0, "VIEW3D_OT_snap_selected_to_grid");
@@ -3333,28 +3236,6 @@ static uiBlock *view3d_faceselmenu(bContext *C, ARegion *ar, void *arg_unused)
return block;
}
static void view3d_select_particlemenu(bContext *C, uiLayout *layout, void *arg_unused)
{
ToolSettings *ts= CTX_data_tool_settings(C);
uiItemO(layout, NULL, 0, "VIEW3D_OT_select_border");
uiItemS(layout);
uiItemO(layout, NULL, 0, "PARTICLE_OT_select_all_toggle");
uiItemO(layout, NULL, 0, "PARTICLE_OT_select_linked");
if(ts->particle.selectmode & SCE_SELECT_POINT) {
uiItemO(layout, NULL, 0, "PARTICLE_OT_select_last"); // |W, 4
uiItemO(layout, NULL, 0, "PARTICLE_OT_select_first"); // |W, 3
}
uiItemS(layout);
uiItemO(layout, NULL, 0, "PARTICLE_OT_select_more");
uiItemO(layout, NULL, 0, "PARTICLE_OT_select_less");
}
static void view3d_particle_showhidemenu(bContext *C, uiLayout *layout, void *arg_unused)
{
uiItemO(layout, NULL, 0, "PARTICLE_OT_reveal");
@@ -3788,35 +3669,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
* height of the header */
xmax= GetButStringLength("Select");
if (obedit) {
if (ob && ob->type == OB_MESH) {
uiDefMenuBut(block, view3d_select_meshmenu, NULL, "Select", xco,yco, xmax-3, 20, "");
} else if (ob && (ob->type == OB_CURVE || ob->type == OB_SURF)) {
uiDefMenuBut(block, view3d_select_curvemenu, NULL, "Select", xco, yco, xmax-3, 20, "");
} else if (ob && ob->type == OB_FONT) {
xmax= 0;
} else if (ob && ob->type == OB_MBALL) {
uiDefMenuBut(block, view3d_select_metaballmenu, NULL, "Select", xco,yco, xmax-3, 20, "");
} else if (ob && ob->type == OB_LATTICE) {
uiDefMenuBut(block, view3d_select_latticemenu, NULL, "Select", xco, yco, xmax-3, 20, "");
} else if (ob && ob->type == OB_ARMATURE) {
uiDefMenuBut(block, view3d_select_armaturemenu, NULL, "Select", xco,yco, xmax-3, 20, "");
}
} else if (FACESEL_PAINT_TEST) {
if (ob && ob->type == OB_MESH) {
uiDefPulldownBut(block, view3d_select_faceselmenu, NULL, "Select", xco,yco, xmax-3, 20, "");
}
} else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) {
uiDefBut(block, LABEL,0,"", xco, 0, xmax, 20, 0, 0, 0, 0, 0, "");
} else if (G.f & G_PARTICLEEDIT) {
uiDefMenuBut(block, view3d_select_particlemenu, NULL, "Select", xco,yco, xmax-3, 20, "");
} else {
if (ob && (ob->flag & OB_POSEMODE))
uiDefMenuBut(block, view3d_select_posemenu, NULL, "Select", xco,yco, xmax-3, 20, "");
else
uiDefMenuBut(block, view3d_select_objectmenu, NULL, "Select", xco,yco, xmax-3, 20, "");
}
xco+= xmax;
if (obedit) {

View File

@@ -140,7 +140,6 @@ void view3d_buttons_register(struct ARegionType *art);
void VIEW3D_OT_toolbar(struct wmOperatorType *ot);
void view3d_toolbar_register(struct ARegionType *art);
void view3d_tool_props_register(struct ARegionType *art);
char *view3d_context_string(const struct bContext *C);
/* view3d_snap.c */
int minmax_verts(Object *obedit, float *min, float *max);

View File

@@ -164,42 +164,6 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
/* ******************* */
char *view3d_context_string(const bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
if(obedit) {
switch(obedit->type) {
case OB_MESH:
return "editmode_mesh";
case OB_CURVE:
return "editmode_curve";
case OB_SURF:
return "editmode_surface";
case OB_FONT:
return "editmode_text";
case OB_ARMATURE:
return "editmode_armature";
case OB_MBALL:
return "editmode_mball";
case OB_LATTICE:
return "editmode_lattice";
}
}
else {
Object *ob = CTX_data_active_object(C);
if(ob && (ob->flag & OB_POSEMODE)) return "pose_mode";
else if (ob && ob->mode & OB_MODE_SCULPT) return "sculpt_mode";
else if (G.f & G_WEIGHTPAINT) return "weight_paint";
else if (G.f & G_VERTEXPAINT) return "vertex_paint";
else if (G.f & G_TEXTUREPAINT) return "texture_paint";
else if(G.f & G_PARTICLEEDIT) return "particle_mode";
}
return "objectmode";
}
typedef struct CustomTool {
struct CustomTool *next, *prev;
char opname[OP_MAX_TYPENAME];
@@ -215,7 +179,7 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2)
BLI_addtail(arg_listbase, ct);
BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME);
BLI_strncpy(ct->context, view3d_context_string(C), OP_MAX_TYPENAME);
BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME);
}
}
@@ -278,7 +242,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa)
SpaceLink *sl= CTX_wm_space_data(C);
SpaceType *st= NULL;
uiLayout *col;
const char *context= view3d_context_string(C);
const char *context= CTX_data_mode_string(C);
if(sl)
st= BKE_spacetype_from_id(sl->spacetype);

View File

@@ -110,6 +110,18 @@ static PointerRNA rna_Context_user_preferences_get(PointerRNA *ptr)
return newptr;
}
static void rna_Context_mode_string_get(PointerRNA *ptr, char *value)
{
bContext *C= (bContext*)ptr->data;
strcpy(value, CTX_data_mode_string(C));
}
static int rna_Context_mode_string_length(PointerRNA *ptr)
{
bContext *C= (bContext*)ptr->data;
return strlen(CTX_data_mode_string(C));
}
#else
void RNA_def_context(BlenderRNA *brna)
@@ -177,6 +189,10 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "UserPreferences");
RNA_def_property_pointer_funcs(prop, "rna_Context_user_preferences_get", NULL, NULL);
prop= RNA_def_property(srna, "mode_string", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Context_mode_string_get", "rna_Context_mode_string_length", NULL);
}
#endif

View File

@@ -288,6 +288,15 @@ 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, "view3d_select_metaballmenu", "uiTemplate_view3d_select_metaballmenu");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func= RNA_def_function(srna, "view3d_select_armaturemenu", "uiTemplate_view3d_select_armaturemenu");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func= RNA_def_function(srna, "view3d_select_posemenu", "uiTemplate_view3d_select_posemenu");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func= RNA_def_function(srna, "view3d_select_faceselmenu", "uiTemplate_view3d_select_faceselmenu");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
func= RNA_def_function(srna, "template_texture_image", "uiTemplateTextureImage");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
parm= RNA_def_pointer(func, "texture", "Texture", "", "");