I want to be able to detect when the mouse is over any of these icons and the navigation widgets so I can pass through events through my modal operator. I know how to get mouse position, detect if it's in a particular area/region etc.
I don't know all the preferences and settings that can allow me to calculate their width, height and locations.
Here is all the digging I have done.
I can detect if the navigation gizmo is there or not
/* Offset from screen edge. */
#define GIZMO_OFFSET_FAC 1.2f
/* Size of main icon. */
#define GIZMO_SIZE 80
/* Factor for size of smaller button. */
#define GIZMO_MINI_FAC 0.35f
/* How much mini buttons offset from the primary. */
#define GIZMO_MINI_OFFSET_FAC 0.38f
enum {
GZ_INDEX_MOVE = 0,
GZ_INDEX_ROTATE = 1,
GZ_INDEX_ZOOM = 2,
/* just buttons */
/* overlaps GZ_INDEX_ORTHO (switch between) */
GZ_INDEX_PERSP = 3,
GZ_INDEX_ORTHO = 4,
GZ_INDEX_CAMERA = 5,
GZ_INDEX_TOTAL = 6,
};
To me this says there is a 1.2 pixel offset from the screen edge the rotation gizmo is 80 pixels the smaller gizmos are .35 the size of the rotation gizmo (28 pixels I don't know what the .38f offset is, perhaps a vertical offset?
There are some clues in the drawing https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/space_view3d/view3d_draw.c$1469
#Sample with code
def should_pass_through(self, context, event):
if context.area.type != "VIEW_3D":
return False
#first, check outside of area
if event.mouse_x < context.area.x: return False
if event.mouse_y < context.area.y: return False
if event.mouse_x > context.area.x + context.area.width: return False
if event.mouse_y > context.area.y + context.area.height: return False
#make sure we are in the window region, not the header, tools or UI
for reg in context.area.regions:
if in_region(reg, event.mouse_x, event.mouse_y) and reg.type != "WINDOW":
return False
#check panel open
#check visibility preferences for gizmos
#get icon and button width and height
#do math to figure out if we are over them
#if so allow pass through and flag