diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-04 16:18:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-04 16:18:07 +0400 |
commit | 1f77f7b05af24d3117d76d8c2ec43dbee031ab6a (patch) | |
tree | c3262b326313bb4c1cdf0dc6894204e4eaf3bdd9 /release | |
parent | 2f8f86e4f6afe8ecdff5c57bdbcc1c0d9b18301e (diff) |
Brush/Paint internal changes
- remove brush array for each Paint struct, just use a single brush pointer.
- removed rna function based template filtering.
- filter brushes using a flag on the brush and the pointer poll function.
- set the brushes using a new operator WM_OT_context_set_id().
TODO
- remake startup.blend, currently brush groupings are lost.
- rewrite WM_OT_context_set_id() to use rna introspection.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/op/wm.py | 33 | ||||
-rw-r--r-- | release/scripts/ui/space_view3d_toolbar.py | 30 |
2 files changed, 42 insertions, 21 deletions
diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index 3b34225b7da..4f2ec5056ab 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -325,6 +325,39 @@ class WM_OT_context_cycle_enum(bpy.types.Operator): exec("context.%s=advance_enum" % self.properties.data_path) return {'FINISHED'} + +class WM_OT_context_set_id(bpy.types.Operator): + '''Toggle a context value.''' + bl_idname = "wm.context_set_id" + bl_label = "Set Library ID" + bl_options = {'UNDO'} + + data_path = rna_path_prop + value = StringProperty(name="Value", + description="Assign value", maxlen=1024, default="") + + def execute(self, context): + value = self.properties.value + print(value) + + # TODO! highly lazy, must rewrite + for lib in dir(bpy.data): + try: + id_value = getattr(bpy.data, lib)[value] # bpy.data.brushes["Smooth"] + except: + id_value = None + + if id_value: + try: + print("attempts", id_value) + exec("context.%s=id_value" % self.properties.data_path) + break # success + except: + pass + + return {'FINISHED'} + + doc_id = StringProperty(name="Doc ID", description="", maxlen=1024, default="", options={'HIDDEN'}) diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index 34132069017..625eae89dbe 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -504,26 +504,7 @@ class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): if not context.particle_edit_object: col = layout.split().column() - - if context.sculpt_object and context.tool_settings.sculpt: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_sculpt_brush", rows=3, cols=8) - elif context.texture_paint_object and context.tool_settings.image_paint: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_imapaint_brush", rows=3, cols=8) - elif context.vertex_paint_object and context.tool_settings.vertex_paint: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_vpaint_brush", rows=3, cols=8) - elif context.weight_paint_object and context.tool_settings.weight_paint: - col.template_ID_preview(settings, "brush", new="brush.add", filter="is_wpaint_brush", rows=3, cols=8) - else: - row = col.row() - - if context.sculpt_object and brush: - defaultbrushes = 8 - elif context.texture_paint_object and brush: - defaultbrushes = 4 - else: - defaultbrushes = 7 - - row.template_list(settings, "brushes", settings, "active_brush_index", rows=2, maxrows=defaultbrushes) + col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8) # Particle Mode # @@ -865,6 +846,12 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): elif context.vertex_paint_object or context.weight_paint_object: col.prop(brush, "vertexpaint_tool", expand=False, text="") + row = layout.row(align=True) + row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT') + row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT') + row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT') + row.prop(brush, "use_paint_texture", text="", icon='TPAINT_HLT') + class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): bl_label = "Stroke" @@ -1191,7 +1178,8 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel): bl_label = "Project Paint" def poll(self, context): - return context.tool_settings.image_paint.brush.imagepaint_tool != 'SMEAR' + brush = context.tool_settings.image_paint.brush + return (brush and brush.imagepaint_tool != 'SMEAR') def draw_header(self, context): ipaint = context.tool_settings.image_paint |