Skip to content

Commit

Permalink
Support for Blender 4.3 (with Brush Asset Shelf)
Browse files Browse the repository at this point in the history
  • Loading branch information
SietseB committed Nov 1, 2024
1 parent 02cdb0e commit 12b0919
Show file tree
Hide file tree
Showing 11 changed files with 746 additions and 114 deletions.
20 changes: 8 additions & 12 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
bl_info = {
"name": "GP Tool Wheel",
"author": "Sietse Brouwer",
"version": (1, 0, 5),
"blender": (3, 0, 0),
"description": "Extended pie menu for selecting Grease Pencil tools quickly.",
"doc_url": "https://github.com/SietseB/GP-Tool-Wheel",
"tracker_url": "https://github.com/SietseB/GP-Tool-Wheel/issues",
"category": "3D View"
}


if 'bpy' in locals():
import importlib
importlib.reload(preferences)
Expand All @@ -36,6 +24,9 @@ def addon_init():
# Assign hotkey to tool wheel operator
preferences.assign_hotkey_to_tool_wheel()

# Add brush asset context menu item
preferences.add_brush_asset_context_menu_item()

# Load tool icons
tool_data.tool_data.get_tool_icon_textures()

Expand All @@ -50,6 +41,7 @@ def register():
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_AssignHotkey)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_SavePrefDefinition)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_LoadPrefDefinition)
bpy.utils.register_class(preferences.GPENCIL_OT_link_brush_to_gp_tool_wheel)
bpy.utils.register_class(tool_wheel_operator.GPENCIL_OT_tool_wheel)

# Delayed inits
Expand All @@ -65,11 +57,15 @@ def unregister():
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_AssignHotkey)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_SavePrefDefinition)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_LoadPrefDefinition)
bpy.utils.unregister_class(preferences.GPENCIL_OT_link_brush_to_gp_tool_wheel)
bpy.utils.unregister_class(tool_wheel_operator.GPENCIL_OT_tool_wheel)

# Remove hotkey
preferences.remove_hotkey_of_tool_wheel()

# Remove brush asset context menu item
preferences.remove_brush_asset_context_menu_item()


if __name__ == "__main__":
register()
71 changes: 71 additions & 0 deletions __init__extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
if 'bpy' in locals():
import importlib
importlib.reload(preferences)
importlib.reload(tool_wheel_operator)
importlib.reload(tool_data)
else:
from . import preferences
from . import tool_wheel_operator
from . import tool_data

import bpy


# Inits
def addon_init():
# Blender ready to assign hotkey?
if bpy.context.window_manager.keyconfigs.active is None:
# Keep interval timer alive
return 0.2

# Set default preferences (when needed)
preferences.set_default_preferences()

# Assign hotkey to tool wheel operator
preferences.assign_hotkey_to_tool_wheel()

# Add brush asset context menu item
preferences.add_brush_asset_context_menu_item()

# Load tool icons
tool_data.tool_data.get_tool_icon_textures()


# Addon registration
def register():
bpy.utils.register_class(preferences.GPToolWheel_PG_tool)
bpy.utils.register_class(preferences.GPToolWheel_PG_mode_order)
bpy.utils.register_class(preferences.GPToolWheelPreferences)
bpy.utils.register_class(preferences.GPTOOLWHEEL_UL_ModeList)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_MoveItem)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_AssignHotkey)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_SavePrefDefinition)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_LoadPrefDefinition)
bpy.utils.register_class(preferences.GPENCIL_OT_link_brush_to_gp_tool_wheel)
bpy.utils.register_class(tool_wheel_operator.GPENCIL_OT_tool_wheel)

# Delayed inits
bpy.app.timers.register(addon_init, first_interval=0.2)


def unregister():
bpy.utils.unregister_class(preferences.GPToolWheel_PG_tool)
bpy.utils.unregister_class(preferences.GPToolWheel_PG_mode_order)
bpy.utils.unregister_class(preferences.GPToolWheelPreferences)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_UL_ModeList)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_MoveItem)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_AssignHotkey)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_SavePrefDefinition)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_LoadPrefDefinition)
bpy.utils.unregister_class(preferences.GPENCIL_OT_link_brush_to_gp_tool_wheel)
bpy.utils.unregister_class(tool_wheel_operator.GPENCIL_OT_tool_wheel)

# Remove hotkey
preferences.remove_hotkey_of_tool_wheel()

# Remove brush asset context menu item
preferences.remove_brush_asset_context_menu_item()


if __name__ == "__main__":
register()
83 changes: 83 additions & 0 deletions __init__legacy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
bl_info = {
"name": "GP Tool Wheel",
"author": "Sietse Brouwer",
"version": (1, 0, 6),
"blender": (3, 0, 0),
"description": "Extended pie menu for selecting Grease Pencil tools quickly.",
"doc_url": "https://github.com/SietseB/GP-Tool-Wheel",
"tracker_url": "https://github.com/SietseB/GP-Tool-Wheel/issues",
"category": "3D View"
}


if 'bpy' in locals():
import importlib
importlib.reload(preferences)
importlib.reload(tool_wheel_operator)
importlib.reload(tool_data)
else:
from . import preferences
from . import tool_wheel_operator
from . import tool_data

import bpy


# Inits
def addon_init():
# Blender ready to assign hotkey?
if bpy.context.window_manager.keyconfigs.active is None:
# Keep interval timer alive
return 0.2

# Set default preferences (when needed)
preferences.set_default_preferences()

# Assign hotkey to tool wheel operator
preferences.assign_hotkey_to_tool_wheel()

# Add brush asset context menu item
preferences.add_brush_asset_context_menu_item()

# Load tool icons
tool_data.tool_data.get_tool_icon_textures()


# Addon registration
def register():
bpy.utils.register_class(preferences.GPToolWheel_PG_tool)
bpy.utils.register_class(preferences.GPToolWheel_PG_mode_order)
bpy.utils.register_class(preferences.GPToolWheelPreferences)
bpy.utils.register_class(preferences.GPTOOLWHEEL_UL_ModeList)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_MoveItem)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_AssignHotkey)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_SavePrefDefinition)
bpy.utils.register_class(preferences.GPTOOLWHEEL_OT_LoadPrefDefinition)
bpy.utils.register_class(preferences.GPENCIL_OT_link_brush_to_gp_tool_wheel)
bpy.utils.register_class(tool_wheel_operator.GPENCIL_OT_tool_wheel)

# Delayed inits
bpy.app.timers.register(addon_init, first_interval=0.2)


def unregister():
bpy.utils.unregister_class(preferences.GPToolWheel_PG_tool)
bpy.utils.unregister_class(preferences.GPToolWheel_PG_mode_order)
bpy.utils.unregister_class(preferences.GPToolWheelPreferences)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_UL_ModeList)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_MoveItem)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_AssignHotkey)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_SavePrefDefinition)
bpy.utils.unregister_class(preferences.GPTOOLWHEEL_OT_LoadPrefDefinition)
bpy.utils.unregister_class(preferences.GPENCIL_OT_link_brush_to_gp_tool_wheel)
bpy.utils.unregister_class(tool_wheel_operator.GPENCIL_OT_tool_wheel)

# Remove hotkey
preferences.remove_hotkey_of_tool_wheel()

# Remove brush asset context menu item
preferences.remove_brush_asset_context_menu_item()


if __name__ == "__main__":
register()
2 changes: 1 addition & 1 deletion blender_manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ schema_version = "1.0.0"
# Example of manifest file for a Blender extension
# Change the values according to your extension
id = "grease_pencil_tool_wheel"
version = "1.0.5"
version = "1.0.6"
name = "GP Tool Wheel"
tagline = "Extended pie menu for selecting Grease Pencil tools quickly"
maintainer = "Sietse Brouwer <sietse@hetvrijeoog.nl>"
Expand Down
Binary file added docs/images/link_brush_to_tool_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/link_brush_to_tool_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 12b0919

Please sign in to comment.