|
from bpy.types import ( |
|
GizmoGroup |
|
) |
|
import bpy |
|
bl_info = { |
|
"name": "POC buttons", |
|
"description": "POC 2D BUTTON script refactored from GP Animator Desk addon", |
|
"author": "Anthony Aragues, P.Świda", |
|
"version": (0, 0, 1), |
|
"blender": (3, 4, 0), |
|
"location": "3d window", |
|
"wiki_url": "", |
|
"tracker_url": "", |
|
"category": "UI" |
|
} |
|
|
|
|
|
class AD_3DVIEW_UI_Buttons(GizmoGroup): |
|
bl_idname = "GP Animator Desk UI Buttons" |
|
bl_label = "GP Animator Desk UI Buttons" |
|
bl_space_type = 'VIEW_3D' |
|
bl_region_type = 'WINDOW' |
|
bl_options = {'PERSISTENT', 'SCALE'} |
|
|
|
@classmethod |
|
def poll(cls, context): |
|
# modify this to whatever conditions you need for showing this gizmo group |
|
return True |
|
|
|
def draw_prepare(self, context): |
|
# set the x and y for the gizmo, by default starting from bottom left == the center of the gizmo |
|
self.button_gizmo.matrix_basis[0][3] = context.region.width/2 |
|
self.button_gizmo.matrix_basis[1][3] = 40 |
|
self.button_gizmo.color = (1, 0, 0) |
|
self.button_gizmo.color_highlight = self.button_gizmo.color |
|
self.button_gizmo.alpha = 1 |
|
return |
|
|
|
def setup(self, context): |
|
# array not necessary, but might be useful if setting up several |
|
# a collection might be better where each gizmo props are read and set. But his is fine for POC to understand |
|
gizmos = [] |
|
|
|
gizmos.append(self.gizmos.new("GIZMO_GT_button_2d")) |
|
gizmos[0].icon = 'BLENDER' |
|
gizmos[0].draw_options = {'BACKDROP', 'OUTLINE'} |
|
gizmos[0].alpha = 0.8 |
|
gizmos[0].color = 0, 0, 0 |
|
gizmos[0].color_highlight = 0.0, 0.0, 0.0 |
|
gizmos[0].alpha_highlight = 0.3 |
|
gizmos[0].scale_basis = (80 * 0.35) / 1.8 |
|
gizmos[0].show_drag = False |
|
|
|
self.button_gizmo = gizmos[0] |
|
|
|
|
|
def register(): |
|
bpy.utils.register_class(AD_3DVIEW_UI_Buttons) |
|
|
|
|
|
def unregister(): |
|
bpy.utils.unregister_class(AD_3DVIEW_UI_Buttons) |