Skip to content

Commit

Permalink
Commotion object menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mrachinskiy committed Oct 11, 2020
1 parent a16f5aa commit 3785902
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 25 deletions.
18 changes: 18 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def reload_recursive(path, mods):
preferences.CommotionPreferences,
preferences.SceneProperties,
preferences.WmProperties,
ui.VIEW3D_MT_commotion,
ui.VIEW3D_PT_commotion_update,
ui.VIEW3D_PT_commotion_animation_offset,
ui.VIEW3D_PT_commotion_animation_utils,
Expand Down Expand Up @@ -122,6 +123,14 @@ def register():
bpy.types.Scene.commotion = PointerProperty(type=preferences.SceneProperties)
bpy.types.WindowManager.commotion = PointerProperty(type=preferences.WmProperties)

# Menu
# ---------------------------

bpy.types.VIEW3D_MT_object.append(ui.draw_commotion_menu)

# mod_update
# ---------------------------

mod_update.init(
addon_version=bl_info["version"],
releases_url="https://api.github.com/repos/mrachinskiy/commotion/releases",
Expand All @@ -136,6 +145,15 @@ def unregister():

del bpy.types.Scene.commotion
del bpy.types.WindowManager.commotion

# Menu
# ---------------------------

bpy.types.VIEW3D_MT_object.remove(ui.draw_commotion_menu)

# Handlers
# ---------------------------

proxy_effector.handler_del()


Expand Down
91 changes: 66 additions & 25 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,49 @@
# ##### END GPL LICENSE BLOCK #####


from bpy.types import Panel
from bpy.types import Panel, Menu

from . import mod_update


# Utils
# Menus
# ---------------------------


class Setup:
bl_category = "Commotion"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_context = "objectmode"
def draw_commotion_menu(self, context):
layout = self.layout
layout.separator()
layout.menu("VIEW3D_MT_commotion")


class VIEW3D_MT_commotion(Menu):
bl_label = "Commotion"

def draw(self, context):
layout = self.layout
layout.operator("wm.call_panel", text="Animation Offset", icon="WINDOW").name = "VIEW3D_PT_commotion_animation_offset"
layout.separator()
layout.operator("anim.commotion_animation_copy", text="Copy", icon="COPYDOWN")
layout.operator("anim.commotion_animation_link", text="Link", icon="LINKED")
layout.operator_menu_enum("anim.commotion_animation_convert", "ad_type")
layout.separator()
layout.operator("wm.call_panel", text="Shape Keys", icon="WINDOW").name = "VIEW3D_PT_commotion_shape_keys"
layout.separator()
layout.operator("wm.call_panel", text="Proximity Effector", icon="WINDOW").name = "VIEW3D_PT_commotion_proxy_effector"


# Panels
# ---------------------------


class VIEW3D_PT_commotion_update(Setup, Panel):
class SidebarSetup:
bl_category = "Commotion"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_context = "objectmode"


class VIEW3D_PT_commotion_update(SidebarSetup, Panel):
bl_label = "Update"

@classmethod
Expand All @@ -50,12 +72,17 @@ def draw(self, context):
mod_update.sidebar_ui(self, context)


class VIEW3D_PT_commotion_shape_keys(Setup, Panel):
class VIEW3D_PT_commotion_shape_keys(SidebarSetup, Panel):
bl_label = "Shape Keys"
bl_options = {"DEFAULT_CLOSED"}

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

if self.is_popover:
layout.label(text="Shape Keys")
layout.separator()

layout.use_property_split = True
layout.use_property_decorate = False

Expand Down Expand Up @@ -91,11 +118,15 @@ def draw(self, context):
layout.operator("anim.commotion_sk_generate_keyframes", text="Generate Keyframes", icon="IPO_BEZIER")


class VIEW3D_PT_commotion_animation_offset(Setup, Panel):
class VIEW3D_PT_commotion_animation_offset(SidebarSetup, Panel):
bl_label = "Animation Offset"

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

if self.is_popover:
layout.label(text="Animation Offset")

layout.use_property_split = True
layout.use_property_decorate = False
props = context.scene.commotion
Expand Down Expand Up @@ -128,7 +159,7 @@ def draw(self, context):
row.operator("anim.commotion_animation_offset_eyedropper", text="", icon="EYEDROPPER")


class VIEW3D_PT_commotion_animation_utils(Setup, Panel):
class VIEW3D_PT_commotion_animation_utils(SidebarSetup, Panel):
bl_label = "Animation Utils"
bl_options = {"DEFAULT_CLOSED"}

Expand All @@ -141,7 +172,7 @@ def draw(self, context):
col.operator_menu_enum("anim.commotion_animation_convert", "ad_type")


class VIEW3D_PT_commotion_proxy_effector(Setup, Panel):
class VIEW3D_PT_commotion_proxy_effector(SidebarSetup, Panel):
bl_label = "Proximity Effector"
bl_options = {"DEFAULT_CLOSED"}

Expand All @@ -151,6 +182,13 @@ def draw_header(self, context):

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

if self.is_popover:
row = layout.row(align=True)
row.prop(context.window_manager.commotion, "use_proxy", text="")
row.label(text="Proximity Effector")
layout.separator()

layout.use_property_split = True
layout.use_property_decorate = False
layout.active = context.window_manager.commotion.use_proxy
Expand All @@ -170,8 +208,11 @@ def draw(self, context):
subrow.active = props.proxy_use_trail
subrow.prop(props, "proxy_trail_fade", text="")

# Popover subpanels
layout.use_property_split = False


class VIEW3D_PT_commotion_proxy_effector_loc(Setup, Panel):
class VIEW3D_PT_commotion_proxy_effector_loc(SidebarSetup, Panel):
bl_label = "Location"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
Expand All @@ -181,17 +222,17 @@ def draw_header(self, context):
layout.prop(context.scene.commotion, "proxy_use_loc", text="")

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

props = context.scene.commotion

layout = self.layout
layout.active = props.proxy_use_loc

row = layout.row()
row.column().prop(props, "proxy_start_loc", text="")
row.column().prop(props, "proxy_final_loc", text="")


class VIEW3D_PT_commotion_proxy_effector_rot(Setup, Panel):
class VIEW3D_PT_commotion_proxy_effector_rot(SidebarSetup, Panel):
bl_label = "Rotation"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
Expand All @@ -201,17 +242,17 @@ def draw_header(self, context):
layout.prop(context.scene.commotion, "proxy_use_rot", text="")

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

props = context.scene.commotion

layout = self.layout
layout.active = props.proxy_use_rot

row = layout.row()
row.column().prop(props, "proxy_start_rot", text="")
row.column().prop(props, "proxy_final_rot", text="")


class VIEW3D_PT_commotion_proxy_effector_sca(Setup, Panel):
class VIEW3D_PT_commotion_proxy_effector_sca(SidebarSetup, Panel):
bl_label = "Scale"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
Expand All @@ -221,17 +262,17 @@ def draw_header(self, context):
layout.prop(context.scene.commotion, "proxy_use_sca", text="")

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

props = context.scene.commotion

layout = self.layout
layout.active = props.proxy_use_sca

row = layout.row()
row.column().prop(props, "proxy_start_sca", text="")
row.column().prop(props, "proxy_final_sca", text="")


class VIEW3D_PT_commotion_proxy_effector_sk(Setup, Panel):
class VIEW3D_PT_commotion_proxy_effector_sk(SidebarSetup, Panel):
bl_label = "Shape Keys"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
Expand All @@ -241,17 +282,17 @@ def draw_header(self, context):
layout.prop(context.scene.commotion, "proxy_use_sk", text="")

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

props = context.scene.commotion

layout = self.layout
layout.active = props.proxy_use_sk

row = layout.row()
row.column().prop(props, "proxy_start_sk", text="")
row.column().prop(props, "proxy_final_sk", text="")


class VIEW3D_PT_commotion_proxy_effector_bake(Setup, Panel):
class VIEW3D_PT_commotion_proxy_effector_bake(SidebarSetup, Panel):
bl_label = "Bake"
bl_options = {"DEFAULT_CLOSED"}
bl_parent_id = "VIEW3D_PT_commotion_proxy_effector"
Expand Down

0 comments on commit 3785902

Please sign in to comment.