2
$\begingroup$

Hi I am trying to create a tool that has a gizmo in the 2d/Image-editor view. When adding a gizmo I use the self.gizmos.new("GIZMO_GT_dial_3d") to display a radial gizmo. However I saw in the release notes for 2.82 there is a 2d gizmo that you now can display in UV view. I would like to know what its name is so I can use it for my tool, self.gizmos.new("UV_WIDGET_NAME?")

If you know anything about this or somewhere I can see all listed types of gizmos that would be great.

$\endgroup$

1 Answer 1

1
$\begingroup$

TL;DR The UV translate tool uses GIZMO_GT_arrow_3d.


The gizmo groups that are used for the tools in the UV editor can be seen in _defs_image_uv_transform (space_toolsystem_toolbar.py).

The ID name of the gizmo group is IMAGE_GGT_gizmo2d_translate which is implemented in space_image.c. It uses ED_widgetgroup_gizmo2d_xform_no_cage_callbacks_set, which in turn calls ED_widgetgroup_gizmo2d_xform_callbacks_set that stores gizmo2d_xform_setup as function for the setup. Should the setup function be called this also results in gizmogroup2d_init being executed. Its return value is a GizmoGroup2D that is used to set gizmos for the operators through WM_gizmo_operator_set. The gizmo types that are returned by gizmogroup2d_init in a GizmoGroup2D are GIZMO_GT_arrow_3d, GIZMO_GT_cage_2d and GIZMO_GT_button_2d.

These functions are implemented in transform_gizmo_2d.c.

$\endgroup$
3
  • $\begingroup$ Thanks man this info is pure gold! :) $\endgroup$
    – legendari
    Jun 11, 2020 at 19:25
  • $\begingroup$ A follow up question, is it possible to use IMAGE_GGT_gizmo2d_translate for a operator of my own, or is the best way to just try to recreate something similar in a GizmoGroup by myself? I have tried to use GIZMO_GT_arrow_3d in IMAGE_EDITOR context but I instantly get a crash when I try to drag it. I also have the problem with the coordinate system for the gizmo being in region space, since I want to align it to stuff like verts or 2D cursor in UV/View space. $\endgroup$
    – legendari
    Jun 12, 2020 at 9:16
  • $\begingroup$ @legendari I haven't tried to do that. It should be possible to recreate the settings from gizmogroup2d_init in your own gizmo group. It could be that you can just reuse IMAGE_GGT_gizmo2d_translate, but I haven't tested it and there may be issues that I haven't seen. Unfortunately I'm a bit busy at the moment, which is why I likely won't be able to investigate this further. Perhaps someone else will post an example or I will revisit this in the future. $\endgroup$
    – Robert Gützkow
    Jun 12, 2020 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.