I’m working on addon which uses Gizmo API and have found a bug. I don’t know how these are related but…
Here is sample code (complete sample, can be added to the Blender as an addon and tested):
# Licensing information
bl_info = {
"name": "Gizmo button 2d test",
"version": (0, 1),
"blender": (2, 80, 0),
"description": "test gizmo button 2d functionality, report problem...",
"location": "View3D",
"warning": "",
"category": "3D View"
}
import bpy
from bpy.props import (IntProperty, EnumProperty, BoolProperty)
from bpy.types import (AddonPreferences, GizmoGroup, Operator)
class GizmoButton2D(GizmoGroup):
""" test gizmo button 2d """
bl_idname = "view3d.gizmo_button_2d"
bl_label = "Test button 2d"
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
bl_options = {'PERSISTENT', 'SCALE'}
@classmethod
def poll(cls, context):
if context.object != None:
return True
return False
def draw_prepare(self, context):
self.foo_gizmo.matrix_basis[0][3] = 100
self.foo_gizmo.matrix_basis[1][3] = 100
def setup(self, context):
mpr = self.gizmos.new("GIZMO_GT_button_2d")
mpr.target_set_operator("transform.rotate")
mpr.icon = 'OUTLINER_OB_CAMERA'
mpr.draw_options = {'BACKDROP', 'OUTLINE'}
mpr.alpha = 0.0
mpr.color_highlight = 0.8, 0.8, 0.8
mpr.alpha_highlight = 0.2
mpr.scale_basis = (80 * 0.35) / 2 # same as buttons defined in C
self.foo_gizmo = mpr
def register():
bpy.utils.register_class(GizmoButton2D)
def unregister():
bpy.utils.unregister_class(GizmoButton2D)
When this addon is activated in preferences in the Operator properties window (as an example used Move op - I’ve moved islands in the UV editor) content is downscaled as in this screenshot:
When the addon is deactivated everything is OK:
As far as I’ve found in my experiments, any operation with Gizmo (even seemingly completely innocent self.foo_gizmo.hide = True in the GizmoGroup.draw_prepare() function will give this effect!)