2025-01-13 18:52:49 +01:00
|
|
|
# blext
|
|
|
|
# Copyright (C) 2025 blext Project Contributors
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2025-01-13 18:30:57 +01:00
|
|
|
"""Explicit type annotations for Blender objects, making it easier to guarantee correctness in communications with Blender."""
|
|
|
|
|
|
|
|
import typing as typ
|
|
|
|
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Strings
|
|
|
|
####################
|
|
|
|
BLEnumID: typ.TypeAlias = str
|
|
|
|
SocketName: typ.TypeAlias = str
|
|
|
|
PropName: typ.TypeAlias = str
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Enums
|
|
|
|
####################
|
|
|
|
BLImportMethod: typ.TypeAlias = typ.Literal['append', 'link']
|
|
|
|
BLModifierType: typ.TypeAlias = typ.Literal['NODES', 'ARRAY']
|
|
|
|
BLNodeTreeInterfaceID: typ.TypeAlias = str
|
|
|
|
|
|
|
|
BLIcon: typ.TypeAlias = str
|
|
|
|
BLIconSet: frozenset[BLIcon] = frozenset(
|
|
|
|
bpy.types.UILayout.bl_rna.functions['prop'].parameters['icon'].enum_items.keys()
|
|
|
|
)
|
|
|
|
|
|
|
|
BLEnumElement = tuple[BLEnumID, str, str, BLIcon, int]
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Structs
|
|
|
|
####################
|
|
|
|
BLClass: typ.TypeAlias = (
|
|
|
|
bpy.types.Panel
|
|
|
|
| bpy.types.UIList
|
|
|
|
| bpy.types.Menu
|
|
|
|
| bpy.types.Header
|
|
|
|
| bpy.types.Operator
|
|
|
|
| bpy.types.KeyingSetInfo
|
|
|
|
| bpy.types.RenderEngine
|
|
|
|
| bpy.types.AssetShelf
|
|
|
|
| bpy.types.FileHandler
|
|
|
|
)
|
|
|
|
BLIDStruct: typ.TypeAlias = (
|
|
|
|
bpy.types.Action
|
|
|
|
| bpy.types.Armature
|
|
|
|
| bpy.types.Brush
|
|
|
|
| bpy.types.CacheFile
|
|
|
|
| bpy.types.Camera
|
|
|
|
| bpy.types.Collection
|
|
|
|
| bpy.types.Curve
|
|
|
|
| bpy.types.Curves
|
|
|
|
| bpy.types.FreestyleLineStyle
|
|
|
|
| bpy.types.GreasePencil
|
|
|
|
| bpy.types.Image
|
|
|
|
| bpy.types.Key
|
|
|
|
| bpy.types.Lattice
|
|
|
|
| bpy.types.Library
|
|
|
|
| bpy.types.Light
|
|
|
|
| bpy.types.LightProbe
|
|
|
|
| bpy.types.Mask
|
|
|
|
| bpy.types.Material
|
|
|
|
| bpy.types.Mesh
|
|
|
|
| bpy.types.MetaBall
|
|
|
|
| bpy.types.MovieClip
|
|
|
|
| bpy.types.NodeTree
|
|
|
|
| bpy.types.Object
|
|
|
|
| bpy.types.PaintCurve
|
|
|
|
| bpy.types.Palette
|
|
|
|
| bpy.types.ParticleSettings
|
|
|
|
| bpy.types.PointCloud
|
|
|
|
| bpy.types.Scene
|
|
|
|
| bpy.types.Screen
|
|
|
|
| bpy.types.Sound
|
|
|
|
| bpy.types.Speaker
|
|
|
|
| bpy.types.Text
|
|
|
|
| bpy.types.Texture
|
|
|
|
| bpy.types.VectorFont
|
|
|
|
| bpy.types.Volume
|
|
|
|
| bpy.types.WindowManager
|
|
|
|
| bpy.types.WorkSpace
|
|
|
|
| bpy.types.World
|
|
|
|
)
|
|
|
|
BLPropFlag: typ.TypeAlias = typ.Literal[
|
|
|
|
'HIDDEN',
|
|
|
|
'SKIP_SAVE',
|
|
|
|
'SKIP_PRESET',
|
|
|
|
'ANIMATABLE',
|
|
|
|
'LIBRARY_EDITABLE',
|
|
|
|
'PROPORTIONAL',
|
|
|
|
'TEXTEDIT_UPDATE',
|
|
|
|
'OUTPUT_PATH',
|
|
|
|
]
|
|
|
|
BLColorRGBA = tuple[float, float, float, float]
|
|
|
|
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Operators
|
|
|
|
####################
|
|
|
|
BLRegionType: typ.TypeAlias = typ.Literal[
|
|
|
|
'WINDOW',
|
|
|
|
'HEADER',
|
|
|
|
'CHANNELS',
|
|
|
|
'TEMPORARY',
|
|
|
|
'UI',
|
|
|
|
'TOOLS',
|
|
|
|
'TOOL_PROPS',
|
|
|
|
'ASSET_SHELF',
|
|
|
|
'ASSET_SHELF_HEADER',
|
|
|
|
'PREVIEW',
|
|
|
|
'HUD',
|
|
|
|
'NAVIGATION_BAR',
|
|
|
|
'EXECUTE',
|
|
|
|
'FOOTER',
|
|
|
|
'TOOL_HEADER',
|
|
|
|
'XR',
|
|
|
|
]
|
|
|
|
BLSpaceType: typ.TypeAlias = typ.Literal[
|
|
|
|
'EMPTY',
|
|
|
|
'VIEW_3D',
|
|
|
|
'IMAGE_EDITOR',
|
|
|
|
'NODE_EDITOR',
|
|
|
|
'SEQUENCE_EDITOR',
|
|
|
|
'CLIP_EDITOR',
|
|
|
|
'DOPESHEET_EDITOR',
|
|
|
|
'GRAPH_EDITOR',
|
|
|
|
'NLA_EDITOR',
|
|
|
|
'TEXT_EDITOR',
|
|
|
|
'CONSOLE',
|
|
|
|
'INFO',
|
|
|
|
'TOPBAR',
|
|
|
|
'STATUSBAR',
|
|
|
|
'OUTLINER',
|
|
|
|
'PROPERTIES',
|
|
|
|
'FILE_BROWSER',
|
|
|
|
'SPREADSHEET',
|
|
|
|
'PREFERENCES',
|
|
|
|
]
|
|
|
|
BLOperatorStatus: typ.TypeAlias = set[
|
|
|
|
typ.Literal['RUNNING_MODAL', 'CANCELLED', 'FINISHED', 'PASS_THROUGH', 'INTERFACE']
|
|
|
|
]
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Operators
|
|
|
|
####################
|
|
|
|
## TODO: Write the rest in.
|
|
|
|
BLEventType: typ.TypeAlias = typ.Literal[
|
|
|
|
'NONE',
|
|
|
|
'LEFTMOUSE',
|
|
|
|
'MIDDLEMOUSE',
|
|
|
|
'RIGHTMOUSE',
|
|
|
|
'BUTTON4MOUSE',
|
|
|
|
'BUTTON5MOUSE',
|
|
|
|
'BUTTON6MOUSE',
|
|
|
|
'BUTTON7MOUSE',
|
|
|
|
'PEN',
|
|
|
|
'ERASOR',
|
|
|
|
'MOUSEMOVE',
|
|
|
|
'INBETWEEN_MOUSEMOVE',
|
|
|
|
'TRACKPADPAN',
|
|
|
|
'TRACKPADZOOM',
|
|
|
|
'MOUSEROTATE',
|
|
|
|
'MOUSESMARTZOOM',
|
|
|
|
'WHEELUPMOUSE',
|
|
|
|
'WHEELDOWNMOUSE',
|
|
|
|
'WHEELINMOUSE',
|
|
|
|
'WHEELOUTMOUSE',
|
|
|
|
'A',
|
|
|
|
'B',
|
|
|
|
'C',
|
|
|
|
'D',
|
|
|
|
'E',
|
|
|
|
'F',
|
|
|
|
'G',
|
|
|
|
'H',
|
|
|
|
'I',
|
|
|
|
'J',
|
|
|
|
'K',
|
|
|
|
'L',
|
|
|
|
'M',
|
|
|
|
'N',
|
|
|
|
'O',
|
|
|
|
'P',
|
|
|
|
'Q',
|
|
|
|
'R',
|
|
|
|
'S',
|
|
|
|
'T',
|
|
|
|
'U',
|
|
|
|
'V',
|
|
|
|
'W',
|
|
|
|
'X',
|
|
|
|
'Y',
|
|
|
|
'Z',
|
|
|
|
'ZERO',
|
|
|
|
'ONE',
|
|
|
|
'TWO',
|
|
|
|
'THREE',
|
|
|
|
'FOUR',
|
|
|
|
'FIVE',
|
|
|
|
'SIX',
|
|
|
|
'S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'F11',
|
|
|
|
'F12',
|
|
|
|
'PAUSE',
|
|
|
|
'INSERT',
|
|
|
|
'HOME',
|
|
|
|
'PAGE_UP',
|
|
|
|
'PAGE_DOWN',
|
|
|
|
'END',
|
|
|
|
'MEDIA_PLAY',
|
|
|
|
'MEDIA_STOP',
|
|
|
|
'MEDIA_FIRST',
|
|
|
|
'MEDIA_LAST',
|
|
|
|
]
|
|
|
|
BLEventValue: typ.TypeAlias = typ.Literal[
|
|
|
|
'ANY',
|
|
|
|
'PRESS',
|
|
|
|
'RELEASE',
|
|
|
|
'CLICK',
|
|
|
|
'DOUBLE_CLICK',
|
|
|
|
'CLICK_DRAG',
|
|
|
|
'NOTHING',
|
|
|
|
]
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Strings
|
|
|
|
####################
|
|
|
|
PresetName = str
|