Skip to content

Commit

Permalink
Fixed FRACTION in Vec Math (Sub search). Added keymap functionality i…
Browse files Browse the repository at this point in the history
…nto addon preferences.
  • Loading branch information
jiggymoon69 committed Oct 14, 2020
1 parent b293bba commit 26e8035
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 27 deletions.
71 changes: 62 additions & 9 deletions node_tabber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
bl_info = {
"name": "Node Tabber",
"author": "Richard Lyons <[email protected]>",
"version": (0, 1, 3),
"blender": (2, 83, 0),
"version": (0, 1, 4),
"blender": (2, 83, 7),
"description": "Allows quick smart searching of node types.",
"category": "Node",
}
Expand All @@ -35,8 +35,10 @@
IntProperty,
)
from . import operators
import rna_keymap_ui


addon_keymaps = []


class node_tabberPreferences(AddonPreferences):
Expand Down Expand Up @@ -72,30 +74,81 @@ class node_tabberPreferences(AddonPreferences):
)



def draw(self, context):
layout = self.layout

# Prefs

box = layout.box()
row1 = box.row()
row2 = box.row()
row3 = box.row()
row4 = box.row()
row1.prop(self, "tally")
row1.operator('node.reset_tally',
row1.prop(self, "sub_search")
row1.prop(self, "quick_place")
row2.prop(self, "tally")
row2.operator('node.reset_tally',
text = 'Reset Tally')
row1.prop(self, "tally_weight")
row2.prop(self, "quick_place")
row2.prop(self, "nt_debug")
row3.prop(self, "sub_search")
row4.label(text="NOTE: CTRL + TAB : Performs \"Edit Group\" functionality.")
row2.prop(self, "tally_weight")
#row2.prop(self, "nt_debug")
#row4.label(text="NOTE: CTRL + TAB : Performs \"Edit Group\" functionality.")


# Keymaps

#box = layout.box()
col = box.column()
col.label(text="Keymap List:",icon="KEYINGSET")

wm = bpy.context.window_manager
kc = wm.keyconfigs.user
old_km_name = ""
get_kmi_l = []
for km_add, kmi_add in addon_keymaps:
for km_con in kc.keymaps:
if km_add.name == km_con.name:
km = km_con
break

for kmi_con in km.keymap_items:
if kmi_add.idname == kmi_con.idname:
if kmi_add.name == kmi_con.name:
get_kmi_l.append((km,kmi_con))

get_kmi_l = sorted(set(get_kmi_l), key=get_kmi_l.index)

for km, kmi in get_kmi_l:
if not km.name == old_km_name:
col.label(text=str(km.name),icon="DOT")
col.context_pointer_set("keymap", km)
rna_keymap_ui.draw_kmi([], kc, km, kmi, col, 0)
col.separator()
old_km_name = km.name





def register():
operators.register()
bpy.utils.register_class(node_tabberPreferences)

wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
km = wm.keyconfigs.addon.keymaps.new(name='Node Editor', space_type='NODE_EDITOR')
kmi = km.keymap_items.new("node.add_tabber_search", type = 'TAB', value= 'PRESS')
addon_keymaps.append((km, kmi))
kmi = km.keymap_items.new("node.group_edit", type = 'TAB', value= 'PRESS', ctrl= True)
addon_keymaps.append((km, kmi))

def unregister():
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()

operators.unregister()
bpy.utils.unregister_class(node_tabberPreferences)


2 changes: 1 addition & 1 deletion node_tabber/nt_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[" VM DISTANCE", "Distance (D) VEC MATH"], [" VM LENGTH", "Length (L) VEC MATH"], [" VM SCALE", "Scale (S) VEC MATH"], [" VM NORMALIZE", "Normalize (N) VEC MATH"],
[" VM ABSOLUTE", "Absolute (A) VEC MATH"], [" VM MINIMUM", "Minimum (M) VEC MATH"],
[" VM MAXIMUM", "Maximum (M) VEC MATH"],
[" VM FLOOR", "Floor (F) VEC MATH"], [" VM CEIL", "Ceiling (C) VEC MATH"], [" VM FRACT", "Fraction (F) VEC MATH"],
[" VM FLOOR", "Floor (F) VEC MATH"], [" VM CEIL", "Ceiling (C) VEC MATH"], [" VM FRACTION", "Fraction (F) VEC MATH"],
[" VM MODULO", "Modulo (M) VEC MATH"], [" VM WRAP", "Wrap (W) VEC MATH"], [" VM SNAP", "Snap (S) VEC MATH"],
[" VM SINE", "Sine (S) VEC MATH"], [" VM COSINE", "Cosine (C) VEC MATH"], [" VM TANGENT", "Tangent (T) VEC MATH"],
]
Expand Down
18 changes: 1 addition & 17 deletions node_tabber/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,30 +369,14 @@ def execute(self, context):
return {'FINISHED'}


addon_keymaps = []
#addon_keymaps = []

def register():

bpy.utils.register_class(NodeTabSetting)
bpy.utils.register_class(NODE_OT_add_tabber_search)
bpy.utils.register_class(NODE_OT_reset_tally)

#print("Registered Node Tabber")
# handle the keymap
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
km = wm.keyconfigs.addon.keymaps.new(name='Node Editor', space_type='NODE_EDITOR')
kmi = km.keymap_items.new("node.add_tabber_search", type = 'TAB', value= 'PRESS')
kmj = km.keymap_items.new("node.group_edit", type = 'TAB', value= 'PRESS', ctrl= True)
addon_keymaps.append((km, kmi, kmj))

def unregister():
for km, kmi, kmj in addon_keymaps:
km.keymap_items.remove(kmi)
km.keymap_items.remove(kmj)
addon_keymaps.clear()

bpy.utils.unregister_class(NodeTabSetting)
bpy.utils.unregister_class(NODE_OT_add_tabber_search)
bpy.utils.unregister_class(NODE_OT_reset_tally)
Expand Down

0 comments on commit 26e8035

Please sign in to comment.