[Bf-extensions-cvs] [9007bcd] master: brush menus alt/v: T42564
meta-androcto
noreply at git.blender.org
Sun Mar 19 23:51:04 CET 2017
Commit: 9007bcd10713e55168235e9e8420b17172674638
Author: meta-androcto
Date: Mon Mar 20 09:50:42 2017 +1100
Branches: master
https://developer.blender.org/rBA9007bcd10713e55168235e9e8420b17172674638
brush menus alt/v: T42564
===================================================================
A space_view3d_brush_menus/Utils/__init__.py
A space_view3d_brush_menus/Utils/core.py
A space_view3d_brush_menus/__init__.py
A space_view3d_brush_menus/brush_menu.py
A space_view3d_brush_menus/brushes.py
A space_view3d_brush_menus/curve_menu.py
A space_view3d_brush_menus/dyntopo_menu.py
A space_view3d_brush_menus/stroke_menu.py
A space_view3d_brush_menus/symmetry_menu.py
A space_view3d_brush_menus/texture_menu.py
===================================================================
diff --git a/space_view3d_brush_menus/Utils/__init__.py b/space_view3d_brush_menus/Utils/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/space_view3d_brush_menus/Utils/core.py b/space_view3d_brush_menus/Utils/core.py
new file mode 100644
index 0000000..ea73a87
--- /dev/null
+++ b/space_view3d_brush_menus/Utils/core.py
@@ -0,0 +1,204 @@
+import bpy
+import time
+import sys
+import os
+import re
+
+object_mode = 'OBJECT'
+edit = 'EDIT'
+sculpt = 'SCULPT'
+vertex_paint = 'VERTEX_PAINT'
+weight_paint = 'WEIGHT_PAINT'
+texture_paint = 'TEXTURE_PAINT'
+particle_edit = 'PARTICLE_EDIT'
+pose = 'POSE'
+gpencil_edit = 'GPENCIL_EDIT'
+
+PIW = ' '
+
+a_props = []
+
+class Menu():
+ def __init__(self, menu):
+ self.layout = menu.layout
+ self.items = {}
+ self.current_item = None
+
+ def add_item(self, ui_type="row", parent=None, name=None, **kwargs):
+ # set the parent layout
+ if parent:
+ layout = parent
+ else:
+ layout = self.layout
+
+ # set unique identifier for new items
+ if not name:
+ name = len(self.items) + 1
+
+ # create and return a ui layout
+ if ui_type == "row":
+ self.current_item = self.items[name] = layout.row(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "column":
+ self.current_item = self.items[name] = layout.column(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "column_flow":
+ self.current_item = self.items[name] = layout.column_flow(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "box":
+ self.current_item = self.items[name] = layout.box(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "split":
+ self.current_item = self.items[name] = layout.split(**kwargs)
+
+ return self.current_item
+
+ else:
+ print("Unknown Type")
+
+
+def get_selected():
+ # get the number of verts from the information string on the info header
+ sel_verts_num = (e for e in bpy.context.scene.statistics().split(" | ")
+ if e.startswith("Verts:")).__next__()[6:].split("/")
+
+ # turn the number of verts from a string to an int
+ sel_verts_num = int(sel_verts_num[0].replace("," ,""))
+
+ # get the number of edges from the information string on the info header
+ sel_edges_num = (e for e in bpy.context.scene.statistics().split(" | ")
+ if e.startswith("Edges:")).__next__()[6:].split("/")
+
+ # turn the number of edges from a string to an int
+ sel_edges_num = int(sel_edges_num[0].replace(",", ""))
+
+ # get the number of faces from the information string on the info header
+ sel_faces_num = (e for e in bpy.context.scene.statistics().split(" | ")
+ if e.startswith("Faces:")).__next__()[6:].split("/")
+
+ # turn the number of faces from a string to an int
+ sel_faces_num = int(sel_faces_num[0].replace(",", ""))
+
+ return sel_verts_num, sel_edges_num, sel_faces_num
+
+
+def get_mode():
+ if bpy.context.gpencil_data and \
+ bpy.context.object.mode == object_mode and \
+ bpy.context.scene.grease_pencil.use_stroke_edit_mode:
+ return gpencil_edit
+ else:
+ return bpy.context.object.mode
+
+def menuprop(item, name, value, data_path,
+ icon='NONE', disable=False, disable_icon=None,
+ custom_disable_exp=None, method=None, path=False):
+
+ # disable the ui
+ if disable:
+ disabled = False
+
+ # used if you need a custom expression to disable the ui
+ if custom_disable_exp:
+ if custom_disable_exp[0] == custom_disable_exp[1]:
+ item.enabled = False
+ disabled = True
+
+ # check if the ui should be disabled for numbers
+ elif isinstance(eval("bpy.context.{}".format(data_path)), float):
+ if round(eval("bpy.context.{}".format(data_path)), 2) == value:
+ item.enabled = False
+ disabled = True
+
+ # check if the ui should be disabled for anything else
+ else:
+ if eval("bpy.context.{}".format(data_path)) == value:
+ item.enabled = False
+ disabled = True
+
+ # change the icon to the disable_icon if the ui has been disabled
+ if disable_icon and disabled:
+ icon = disable_icon
+
+ # creates the menu item
+ prop = item.operator("wm.context_set_value", text=name, icon=icon)
+
+ # sets what the menu item changes
+ if path:
+ prop.value = value
+ value = eval(value)
+
+ elif type(value) == str:
+ prop.value = "'{}'".format(value)
+
+ else:
+ prop.value = '{}'.format(value)
+
+ # sets the path to what is changed
+ prop.data_path = data_path
+
+# used for global blender properties
+def set_prop(prop_type, path, **kwargs):
+ kwstring = ""
+
+ # turn **kwargs into a string that can be used with exec
+ for k, v in kwargs.items():
+ if type(v) is str:
+ v = '"{}"'.format(v)
+
+ if callable(v):
+ exec("from {0} import {1}".format(v.__module__, v.__name__))
+ v = v.__name__
+
+ kwstring += "{0}={1}, ".format(k, v)
+
+ kwstring = kwstring[:-2]
+
+ # create the property
+ exec("{0} = bpy.props.{1}({2})".format(path, prop_type, kwstring))
+
+ # add the path to a list of property paths
+ a_props.append(path)
+
+ return eval(path)
+
+# used for removing properties created with set_prop
+def del_props():
+ for prop in a_props:
+ exec("del {}".format(prop))
+
+ a_props.clear()
+
+class SendReport(bpy.types.Operator):
+ bl_label = "Send Report"
+ bl_idname = "view3d.send_report"
+
+ message = bpy.props.StringProperty()
+
+ def draw(self, context):
+ self.layout.label("Error", icon='ERROR')
+ self.layout.label(self.message)
+
+ def invoke(self, context, event):
+ wm = context.window_manager
+ return wm.invoke_popup(self, width=400, height=200)
+
+ def execute(self, context):
+ self.report({'INFO'}, self.message)
+ print(self.message)
+ return {'FINISHED'}
+
+def send_report(message):
+ def report(scene):
+ bpy.ops.view3d.send_report('INVOKE_DEFAULT', message=message)
+ bpy.app.handlers.scene_update_pre.remove(report)
+
+ bpy.app.handlers.scene_update_pre.append(report)
diff --git a/space_view3d_brush_menus/__init__.py b/space_view3d_brush_menus/__init__.py
new file mode 100644
index 0000000..6613b82
--- /dev/null
+++ b/space_view3d_brush_menus/__init__.py
@@ -0,0 +1,138 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+# Modified by Meta-Androcto
+
+
+""" Copyright 2011 GPL licence applies"""
+
+bl_info = {
+ "name": "Sculpt/Paint Brush Menus",
+ "description": "Fast access to brushes & tools in Sculpt and Paint Modes",
+ "author": "Ryan Inch (Imaginer)",
+ "version": (1, 1, 3),
+ "blender": (2, 7, 8),
+ "location": "Alt V in Sculpt/Paint Modes",
+ "warning": '', # used for warning icon and text in addons panel
+ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Advanced_UI_Menus",
+ "category": "3D View"}
+
+import sys
+import os
+from bl_ui.properties_paint_common import (
+ UnifiedPaintPanel,
+ brush_texture_settings,
+ brush_texpaint_common,
+ brush_mask_texture_settings,
+ )
+from .Utils.core import *
+
+from . import brush_menu
+from . import brushes
+from . import curve_menu
+from . import dyntopo_menu
+from . import stroke_menu
+from . import symmetry_menu
+from . import texture_menu
+
+# Use compact brushes menus #
+def UseBrushesLists():
+ # separate function just for more convience
+ useLists = bpy.context.user_preferences.addons[__name__].preferences.use_brushes_lists
+
+ return bool(useLists)
+
+class VIEW3D_MT_Brush_Selection1(bpy.types.Menu):
+ bl_label = "Brush Tool"
+
+ def draw(self, context):
+ layout = self.layout
+ settings = UnifiedPaintPanel.paint_settings(context)
+
+ # check if brush exists (for instance, in paint mode before adding a slot)
+ if hasattr(settings, 'brush'):
+ brush = settings.brush
+ else:
+ brush = None
+
+ if not brush:
+ return
+
+ if not context.particle_edit_object:
+ if UseBrushesLists():
+ flow = layout.column_flow(columns=3)
+
+ for brsh in bpy.data.brushes:
+ if (context.sculpt_object and brsh.use_paint_sculpt):
+ props = flow.operator("wm.context_set_id", text=brsh.name,
+ icon_value=layout.icon(brsh))
+ props.data_path = "tool_settings.sculpt.brush"
+ props.value = brsh.name
+ elif (context.image_paint_object and brsh.use_paint_image):
+ props = flow.operator("wm.context_set_id", text=brsh.name,
+ icon_value=layout.icon(brsh))
+ props.data_path = "tool_settings.image_paint.brush"
+ props.value = brsh.name
+ elif (context.ve
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list