"""Panel definitions for AMZN Character Tools.""" import bpy from bpy.types import Panel from .operators import OP_SPECS PANEL_KEYS = ("scene", "general", "core", "devices", "geo", "helmet", "vest") PANEL_BUTTONS = {key: [spec for spec in OP_SPECS if spec["panel"] == key] for key in PANEL_KEYS} class _AMZN_BasePanel(Panel): """Base panel class for AMZN Character Tools.""" bl_space_type = "VIEW_3D" bl_region_type = "UI" bl_category = "Rigging" panel_key = "" @classmethod def poll(cls, context): return True def draw(self, context): layout = self.layout for spec in PANEL_BUTTONS.get(self.panel_key, ()): # Make buttons marked as "large" bigger if spec.get("large", False): row = layout.row() row.scale_y = 2.0 row.operator( spec["full_idname"], text=spec["button"], icon=spec["icon"], ) else: layout.operator( spec["full_idname"], text=spec["button"], icon=spec["icon"], ) class AMZN_PT_Main(_AMZN_BasePanel): """Main panel for AMZN Character Tools.""" bl_idname = "AMZN_PT_MAIN" bl_label = "AMZN Character Tools" panel_key = "core" class AMZN_PT_Scene(_AMZN_BasePanel): """Scene panel.""" bl_idname = "AMZN_PT_SCENE" bl_label = "Scene" bl_parent_id = "AMZN_PT_MAIN" panel_key = "scene" class AMZN_PT_General(_AMZN_BasePanel): """General panel.""" bl_idname = "AMZN_PT_GENERAL" bl_label = "General" bl_parent_id = "AMZN_PT_MAIN" panel_key = "general" class AMZN_PT_Devices(_AMZN_BasePanel): """Devices panel.""" bl_idname = "AMZN_PT_DEVICES" bl_label = "Devices" bl_parent_id = "AMZN_PT_MAIN" panel_key = "devices" class AMZN_PT_Geo(_AMZN_BasePanel): """GEO panel.""" bl_idname = "AMZN_PT_GEO" bl_label = "GEO" bl_parent_id = "AMZN_PT_MAIN" panel_key = "geo" class AMZN_PT_Helmet(_AMZN_BasePanel): """Helmet panel.""" bl_idname = "AMZN_PT_HELMET" bl_label = "Helmet" bl_parent_id = "AMZN_PT_MAIN" panel_key = "helmet" class AMZN_PT_Vest(_AMZN_BasePanel): """Vest panel.""" bl_idname = "AMZN_PT_VEST" bl_label = "Vest" bl_parent_id = "AMZN_PT_MAIN" panel_key = "vest" PANEL_CLASSES = (AMZN_PT_Main, AMZN_PT_Scene, AMZN_PT_General, AMZN_PT_Devices, AMZN_PT_Geo, AMZN_PT_Helmet, AMZN_PT_Vest)