[Bf-extensions-cvs] [2ff215a1] master: Brush Tools: Initial Commit: T42564
meta-androcto
noreply at git.blender.org
Sun Feb 26 22:01:21 CET 2017
Commit: 2ff215a194267434043433d83e4cf48eff58250c
Author: meta-androcto
Date: Mon Feb 27 08:00:58 2017 +1100
Branches: master
https://developer.blender.org/rBAC2ff215a194267434043433d83e4cf48eff58250c
Brush Tools: Initial Commit: T42564
===================================================================
A space_view3d_brush_menus/Utils/__init__.py
A space_view3d_brush_menus/Utils/core.py
A space_view3d_brush_menus/Utils/keymodes.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 00000000..e69de29b
diff --git a/space_view3d_brush_menus/Utils/core.py b/space_view3d_brush_menus/Utils/core.py
new file mode 100644
index 00000000..4c7afadf
--- /dev/null
+++ b/space_view3d_brush_menus/Utils/core.py
@@ -0,0 +1,142 @@
+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'
+
+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, **kwargs):
+ # set the parent layout
+ if parent:
+ layout = parent
+ else:
+ layout = self.layout
+
+ # create and return a ui layout
+ if ui_type == "row":
+ self.current_item = self.items[len(self.items) + 1] = layout.row(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "column":
+ self.current_item = self.items[len(self.items) + 1] = layout.column(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "column_flow":
+ self.current_item = self.items[len(self.items) + 1] = layout.column_flow(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "box":
+ self.current_item = self.items[len(self.items) + 1] = layout.box(**kwargs)
+
+ return self.current_item
+
+ elif ui_type == "split":
+ self.current_item = self.items[len(self.items) + 1] = layout.split(**kwargs)
+
+ return self.current_item
+
+ else:
+ print("Unknown Type")
+
+
+def get_mode():
+ 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
+
+
+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)
+
+ 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)
+
+
+def del_props():
+ for prop in a_props:
+ exec("del {}".format(prop))
+
+ a_props.clear()
+
diff --git a/space_view3d_brush_menus/Utils/keymodes.py b/space_view3d_brush_menus/Utils/keymodes.py
new file mode 100644
index 00000000..6efc460c
--- /dev/null
+++ b/space_view3d_brush_menus/Utils/keymodes.py
@@ -0,0 +1,31 @@
+from .core import *
+
+# this is a list of keys to deactivate with a list of modes to deactivate them in
+keymodes = [ # key any shift ctrl alt oskey modes
+
+ ['V', False, False, False, True, False, ['Object Non-modal', 'Sculpt', 'Vertex Paint', 'Weight Paint', 'Image Paint']],
+
+]
+
+
+def opposingkeys(activation):
+ wm = bpy.context.window_manager
+
+ # deactivate the opposing keys to prevent clashing and reactivate them on unregister
+ # keymode is a list containing the mode and key you want changed
+ for key in keymodes:
+ # mode is the mode you want the key to be (de)activated for.
+ for mode in key[6]:
+ km = wm.keyconfigs.active.keymaps[mode]
+
+ # this iterates through all the keys in the current
+ # hotkey layout and (de)activates the ones that
+ # match the key we want to (de)activate
+ for kmi in km.keymap_items:
+ #print(kmi.type, "shift={0}".format(kmi.shift), "ctrl={0}".format(kmi.ctrl), "alt={0}".format(kmi.alt))
+ if kmi.type == key[0] and kmi.any == key[1] \
+ and kmi.shift == key[2] and kmi.ctrl == key[3] \
+ and kmi.alt == key[4] and kmi.oskey == key[5]:
+
+ # (de)activate the current key
+ kmi.active = activation
diff --git a/space_view3d_brush_menus/__init__.py b/space_view3d_brush_menus/__init__.py
new file mode 100644
index 00000000..5f1d5246
--- /dev/null
+++ b/space_view3d_brush_menus/__init__.py
@@ -0,0 +1,165 @@
+# ##### 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 Menus",
+ "description": "",
+ "author": "Ryan Inch",
+ "version": (1, 1, 2),
+ "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 .Utils import keymodes
+
+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
+
+addon_files = [
+ brush_menu,
+ curve_menu,
+ dyntopo_menu,
+ stroke_menu,
+ symmetry_menu,
+ 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.vertex_paint_object and brsh.use_paint_vertex):
+ props = flow.operator("wm.context_set_id", text=brsh.name,
+ icon_value=layout.icon(brsh))
+ props.data_path = "tool_settings.vertex_paint.brush"
+ props.value = brsh.name
+ elif (context.weight_paint_object and brsh.use_paint_weight):
+ props = flow.operator("wm.context_set_id", text=brsh.name,
+ icon_value=layout.icon(brsh))
+ props.data_path = "tool_settings.weight_paint.brush"
+ props.value = brsh.name
+ else:
+ layout.template_ID_prev
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list