Blender V4.3
wm_gizmo_map.cc File Reference
#include <cstring>
#include "BLI_buffer.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math_bits.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector_types.hh"
#include "BLI_rect.h"
#include "BKE_context.hh"
#include "BKE_global.hh"
#include "BKE_main.hh"
#include "ED_screen.hh"
#include "ED_select_utils.hh"
#include "ED_view3d.hh"
#include "GPU_framebuffer.hh"
#include "GPU_matrix.hh"
#include "GPU_platform.hh"
#include "GPU_select.hh"
#include "GPU_state.hh"
#include "GPU_viewport.hh"
#include "MEM_guardedalloc.h"
#include "WM_api.hh"
#include "WM_types.hh"
#include "wm_event_system.hh"
#include "UI_interface.hh"
#include "DEG_depsgraph.hh"
#include "wm_gizmo_intern.hh"
#include "wm_gizmo_wmapi.hh"

Go to the source code of this file.

Enumerations

enum  eWM_GizmoFlagGroupTypeGlobalFlag { WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0) , WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE = (1 << 1) , WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE = (1 << 2) , WM_GIZMOTYPE_GLOBAL_REINIT_ALL = (1 << 3) }
 
enum  { GIZMOMAP_IS_PREPARE_DRAW = (1 << 0) , GIZMOMAP_IS_REFRESH_CALLBACK = (1 << 1) }
 

Functions

wmGizmoMap Selection Array API

Just handle wm_gizmomap_select_array_*, not flags or callbacks.

static void wm_gizmomap_select_array_ensure_len_alloc (wmGizmoMap *gzmap, int len)
 
void wm_gizmomap_select_array_clear (wmGizmoMap *gzmap)
 
void wm_gizmomap_select_array_shrink (wmGizmoMap *gzmap, int len_subtract)
 
void wm_gizmomap_select_array_push_back (wmGizmoMap *gzmap, wmGizmo *gz)
 
void wm_gizmomap_select_array_remove (wmGizmoMap *gzmap, wmGizmo *gz)
 
wmGizmoMap
static wmGizmoMapwm_gizmomap_new_from_type_ex (wmGizmoMapType *gzmap_type, wmGizmoMap *gzmap)
 
wmGizmoMapWM_gizmomap_new_from_type (const wmGizmoMapType_Params *gzmap_params)
 
static void wm_gizmomap_free_data (wmGizmoMap *gzmap)
 
void wm_gizmomap_remove (wmGizmoMap *gzmap)
 
void WM_gizmomap_reinit (wmGizmoMap *gzmap)
 
wmGizmoGroupWM_gizmomap_group_find (wmGizmoMap *gzmap, const char *idname)
 
wmGizmoGroupWM_gizmomap_group_find_ptr (wmGizmoMap *gzmap, const wmGizmoGroupType *gzgt)
 
const ListBaseWM_gizmomap_group_list (wmGizmoMap *gzmap)
 
bool WM_gizmomap_is_any_selected (const wmGizmoMap *gzmap)
 
wmGizmoWM_gizmomap_get_modal (const wmGizmoMap *gzmap)
 
bool WM_gizmomap_minmax (const wmGizmoMap *gzmap, bool, bool use_select, float r_min[3], float r_max[3])
 
static GHashWM_gizmomap_gizmo_hash_new (const bContext *C, wmGizmoMap *gzmap, bool(*poll)(const wmGizmo *, void *), void *data, const eWM_GizmoFlag flag_exclude)
 
eWM_GizmoFlagMapDrawStep WM_gizmomap_drawstep_from_gizmo_group (const wmGizmoGroup *gzgroup)
 
void WM_gizmomap_tag_refresh_drawstep (wmGizmoMap *gzmap, const eWM_GizmoFlagMapDrawStep drawstep)
 
void WM_gizmomap_tag_refresh (wmGizmoMap *gzmap)
 
bool WM_gizmomap_tag_delay_refresh_for_tweak_check (wmGizmoMap *gzmap)
 
static bool gizmo_prepare_drawing (wmGizmoMap *gzmap, wmGizmo *gz, const bContext *C, ListBase *draw_gizmos, const eWM_GizmoFlagMapDrawStep drawstep)
 
static void gizmomap_prepare_drawing (wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos, const eWM_GizmoFlagMapDrawStep drawstep)
 
static void gizmos_draw_list (const wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos)
 
void WM_gizmomap_draw (wmGizmoMap *gzmap, const bContext *C, const eWM_GizmoFlagMapDrawStep drawstep)
 
static void gizmo_draw_select_3d_loop (const bContext *C, wmGizmo **visible_gizmos, const int visible_gizmos_len, bool *r_use_select_bias)
 
static int gizmo_find_intersected_3d_intern (wmGizmo **visible_gizmos, const int visible_gizmos_len, const bContext *C, const int co[2], const int hotspot)
 
static wmGizmogizmo_find_intersected_3d (bContext *C, const int co[2], wmGizmo **visible_gizmos, const int visible_gizmos_len, int *r_part)
 
wmGizmowm_gizmomap_highlight_find (wmGizmoMap *gzmap, bContext *C, const wmEvent *event, int *r_part)
 
void WM_gizmomap_add_handlers (ARegion *region, wmGizmoMap *gzmap)
 
void wm_gizmomaps_handled_modal_update (bContext *C, wmEvent *event, wmEventHandler_Op *handler)
 
bool wm_gizmomap_deselect_all (wmGizmoMap *gzmap)
 
static bool gizmo_selectable_poll (const wmGizmo *gz, void *)
 
static bool wm_gizmomap_select_all_intern (bContext *C, wmGizmoMap *gzmap)
 
bool WM_gizmomap_select_all (bContext *C, wmGizmoMap *gzmap, const int action)
 
void wm_gizmomap_handler_context_op (bContext *C, wmEventHandler_Op *handler)
 
void wm_gizmomap_handler_context_gizmo (bContext *, wmEventHandler_Gizmo *)
 
bool WM_gizmomap_cursor_set (const wmGizmoMap *gzmap, wmWindow *win)
 
bool wm_gizmomap_highlight_set (wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part)
 
wmGizmowm_gizmomap_highlight_get (wmGizmoMap *gzmap)
 
void wm_gizmomap_modal_set (wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, const wmEvent *event, bool enable)
 
wmGizmowm_gizmomap_modal_get (wmGizmoMap *gzmap)
 
wmGizmo ** wm_gizmomap_selected_get (wmGizmoMap *gzmap, int *r_selected_len)
 
ListBasewm_gizmomap_groups_get (wmGizmoMap *gzmap)
 
void WM_gizmomap_message_subscribe (const bContext *C, wmGizmoMap *gzmap, ARegion *region, wmMsgBus *mbus)
 
Tooltip Handling
ARegionWM_gizmomap_tooltip_init (bContext *C, ARegion *region, int *, double *, bool *r_exit_on_event)
 
wmGizmoMapType
wmGizmoMapTypeWM_gizmomaptype_find (const wmGizmoMapType_Params *gzmap_params)
 
wmGizmoMapTypeWM_gizmomaptype_ensure (const wmGizmoMapType_Params *gzmap_params)
 
void wm_gizmomaptypes_free ()
 
void wm_gizmos_keymap (wmKeyConfig *keyconf)
 
Updates for Dynamic Type Registration
void WM_gizmoconfig_update_tag_group_type_init (wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
 
void WM_gizmoconfig_update_tag_group_type_remove (wmGizmoMapType *gzmap_type, wmGizmoGroupType *gzgt)
 
void WM_gizmoconfig_update_tag_group_remove (wmGizmoMap *gzmap)
 
void WM_gizmoconfig_update_tag_reinit_all ()
 
void WM_gizmoconfig_update (Main *bmain)
 
Recreate All Gizmos

Use when adjusting themes.

void WM_reinit_gizmomap_all (Main *bmain)
 

Variables

static ListBase gizmomaptypes = {nullptr, nullptr}
 
static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Gizmo-map update tagging.

Enumerator
GIZMOMAP_IS_PREPARE_DRAW 

gizmomap_prepare_drawing has run.

GIZMOMAP_IS_REFRESH_CALLBACK 

Definition at line 86 of file wm_gizmo_map.cc.

◆ eWM_GizmoFlagGroupTypeGlobalFlag

Update when gizmo-map types change.

Enumerator
WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT 

Initialize by #wmGroupType.type_update_flag.

WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE 

Remove by #wmGroupType.type_update_flag.

WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE 

Remove by #wmGroup.tag_remove.

WM_GIZMOTYPE_GLOBAL_REINIT_ALL 

Re-create all gizmos.

This is a heavy operation as it clears and re-initializes all gizmos. It should only be performed when internals have been manipulated (such as reloading Python scripts).

Definition at line 59 of file wm_gizmo_map.cc.

Function Documentation

◆ gizmo_draw_select_3d_loop()

static void gizmo_draw_select_3d_loop ( const bContext * C,
wmGizmo ** visible_gizmos,
const int visible_gizmos_len,
bool * r_use_select_bias )
static

◆ gizmo_find_intersected_3d()

static wmGizmo * gizmo_find_intersected_3d ( bContext * C,
const int co[2],
wmGizmo ** visible_gizmos,
const int visible_gizmos_len,
int * r_part )
static

◆ gizmo_find_intersected_3d_intern()

◆ gizmo_prepare_drawing()

static bool gizmo_prepare_drawing ( wmGizmoMap * gzmap,
wmGizmo * gz,
const bContext * C,
ListBase * draw_gizmos,
const eWM_GizmoFlagMapDrawStep drawstep )
static

◆ gizmo_selectable_poll()

static bool gizmo_selectable_poll ( const wmGizmo * gz,
void *  )
static

◆ gizmomap_prepare_drawing()

static void gizmomap_prepare_drawing ( wmGizmoMap * gzmap,
const bContext * C,
ListBase * draw_gizmos,
const eWM_GizmoFlagMapDrawStep drawstep )
static

◆ gizmos_draw_list()

◆ WM_gizmoconfig_update()

◆ WM_gizmoconfig_update_tag_group_remove()

void WM_gizmoconfig_update_tag_group_remove ( wmGizmoMap * gzmap)

◆ WM_gizmoconfig_update_tag_group_type_init()

◆ WM_gizmoconfig_update_tag_group_type_remove()

◆ WM_gizmoconfig_update_tag_reinit_all()

void WM_gizmoconfig_update_tag_reinit_all ( )

Definition at line 1333 of file wm_gizmo_map.cc.

References WM_GIZMOTYPE_GLOBAL_REINIT_ALL, and wm_gzmap_type_update_flag.

Referenced by WM_script_tag_reload().

◆ WM_gizmomap_add_handlers()

◆ WM_gizmomap_cursor_set()

bool WM_gizmomap_cursor_set ( const wmGizmoMap * gzmap,
wmWindow * win )

◆ wm_gizmomap_deselect_all()

bool wm_gizmomap_deselect_all ( wmGizmoMap * gzmap)

Deselect all selected gizmos in gzmap.

Returns
if selection has changed.

Definition at line 875 of file wm_gizmo_map.cc.

References wmGizmoMap::gzmap_context, wmGizmoMapSelectState::items, wmGizmoMapSelectState::len, wmGizmoMap::select, wm_gizmo_select_set_ex(), and wm_gizmomap_select_array_clear().

Referenced by gizmo_select_invoke(), and WM_gizmomap_select_all().

◆ WM_gizmomap_draw()

◆ WM_gizmomap_drawstep_from_gizmo_group()

◆ wm_gizmomap_free_data()

static void wm_gizmomap_free_data ( wmGizmoMap * gzmap)
static

◆ WM_gizmomap_get_modal()

◆ WM_gizmomap_gizmo_hash_new()

static GHash * WM_gizmomap_gizmo_hash_new ( const bContext * C,
wmGizmoMap * gzmap,
bool(* poll )(const wmGizmo *, void *),
void * data,
const eWM_GizmoFlag flag_exclude )
static

Creates and returns idname hash table for (visible) gizmos in gzmap

Parameters
pollPolling function for excluding gizmos.
dataCustom data passed to poll

TODO(@ideasman42): this uses unreliable order, best we use an iterator function instead of a hash.

Definition at line 278 of file wm_gizmo_map.cc.

References BLI_ghash_insert(), BLI_ghash_ptr_new(), wmGizmoMap::groups, hash, LISTBASE_FOREACH, and WM_gizmo_group_type_poll().

Referenced by wm_gizmomap_select_all_intern().

◆ WM_gizmomap_group_find()

◆ WM_gizmomap_group_find_ptr()

wmGizmoGroup * WM_gizmomap_group_find_ptr ( wmGizmoMap * gzmap,
const wmGizmoGroupType * gzgt )

◆ WM_gizmomap_group_list()

const ListBase * WM_gizmomap_group_list ( wmGizmoMap * gzmap)

◆ wm_gizmomap_groups_get()

ListBase * wm_gizmomap_groups_get ( wmGizmoMap * gzmap)

Definition at line 1180 of file wm_gizmo_map.cc.

References wmGizmoMap::groups.

◆ wm_gizmomap_handler_context_gizmo()

void wm_gizmomap_handler_context_gizmo ( bContext * C,
wmEventHandler_Gizmo * handler )

Definition at line 988 of file wm_gizmo_map.cc.

Referenced by wm_handlers_do_gizmo_handler().

◆ wm_gizmomap_handler_context_op()

void wm_gizmomap_handler_context_op ( bContext * C,
wmEventHandler_Op * handler )

Prepare context for gizmo handling (but only if area/region is part of screen). Version of wm_handler_op_context for gizmos.

Definition at line 954 of file wm_gizmo_map.cc.

References wmEventHandler_Op::area, wmEventHandler_Op::context, CTX_wm_area_set(), CTX_wm_region_set(), CTX_wm_screen(), printf, and wmEventHandler_Op::region.

Referenced by wm_gizmomaps_handled_modal_update().

◆ wm_gizmomap_highlight_find()

◆ wm_gizmomap_highlight_get()

◆ wm_gizmomap_highlight_set()

◆ WM_gizmomap_is_any_selected()

bool WM_gizmomap_is_any_selected ( const wmGizmoMap * gzmap)

◆ WM_gizmomap_message_subscribe()

void WM_gizmomap_message_subscribe ( const bContext * C,
wmGizmoMap * gzmap,
ARegion * region,
wmMsgBus * mbus )

◆ WM_gizmomap_minmax()

bool WM_gizmomap_minmax ( const wmGizmoMap * gzmap,
bool use_hidden,
bool use_select,
float r_min[3],
float r_max[3] )
Note
We could use a callback to define bounds, for now just use matrix location.

Definition at line 253 of file wm_gizmo_map.cc.

References BLI_assert_msg, wmGizmoMap::gzmap_context, wmGizmoMapSelectState::items, wmGizmoMapSelectState::len, wmGizmo::matrix_basis, minmax_v3v3_v3(), and wmGizmoMap::select.

Referenced by viewselected_exec().

◆ wm_gizmomap_modal_get()

wmGizmo * wm_gizmomap_modal_get ( wmGizmoMap * gzmap)

◆ wm_gizmomap_modal_set()

void wm_gizmomap_modal_set ( wmGizmoMap * gzmap,
bContext * C,
wmGizmo * gz,
const wmEvent * event,
bool enable )

◆ WM_gizmomap_new_from_type()

wmGizmoMap * WM_gizmomap_new_from_type ( const wmGizmoMapType_Params * gzmap_params)

Creates a gizmo-map with all registered gizmos for that type

Definition at line 181 of file wm_gizmo_map.cc.

References MEM_callocN, wm_gizmomap_new_from_type_ex(), and WM_gizmomaptype_ensure().

Referenced by ed_default_handlers().

◆ wm_gizmomap_new_from_type_ex()

◆ WM_gizmomap_reinit()

void WM_gizmomap_reinit ( wmGizmoMap * gzmap)

Re-create the gizmos (use when changing theme settings).

Definition at line 211 of file wm_gizmo_map.cc.

References wmGizmoMap::type, wm_gizmomap_free_data(), and wm_gizmomap_new_from_type_ex().

Referenced by WM_reinit_gizmomap_all().

◆ wm_gizmomap_remove()

void wm_gizmomap_remove ( wmGizmoMap * gzmap)

Definition at line 205 of file wm_gizmo_map.cc.

References MEM_freeN(), and wm_gizmomap_free_data().

Referenced by WM_init().

◆ WM_gizmomap_select_all()

bool WM_gizmomap_select_all ( bContext * C,
wmGizmoMap * gzmap,
int action )

Select/Deselect all selectable gizmos in gzmap.

Returns
if selection has changed.

TODO: select all by type.

Definition at line 931 of file wm_gizmo_map.cc.

References BLI_assert_unreachable, CTX_wm_window(), SEL_DESELECT, SEL_SELECT, WM_event_add_mousemove(), wm_gizmomap_deselect_all(), and wm_gizmomap_select_all_intern().

◆ wm_gizmomap_select_all_intern()

◆ wm_gizmomap_select_array_clear()

◆ wm_gizmomap_select_array_ensure_len_alloc()

static void wm_gizmomap_select_array_ensure_len_alloc ( wmGizmoMap * gzmap,
int len )
static

◆ wm_gizmomap_select_array_push_back()

◆ wm_gizmomap_select_array_remove()

void wm_gizmomap_select_array_remove ( wmGizmoMap * gzmap,
wmGizmo * gz )

◆ wm_gizmomap_select_array_shrink()

◆ wm_gizmomap_selected_get()

wmGizmo ** wm_gizmomap_selected_get ( wmGizmoMap * gzmap,
int * r_selected_len )

◆ WM_gizmomap_tag_delay_refresh_for_tweak_check()

bool WM_gizmomap_tag_delay_refresh_for_tweak_check ( wmGizmoMap * gzmap)

◆ WM_gizmomap_tag_refresh()

◆ WM_gizmomap_tag_refresh_drawstep()

void WM_gizmomap_tag_refresh_drawstep ( wmGizmoMap * gzmap,
const eWM_GizmoFlagMapDrawStep drawstep )

◆ WM_gizmomap_tooltip_init()

ARegion * WM_gizmomap_tooltip_init ( bContext * C,
ARegion * region,
int * pass,
double * pass_delay,
bool * r_exit_on_event )

◆ wm_gizmomaps_handled_modal_update()

◆ WM_gizmomaptype_ensure()

◆ WM_gizmomaptype_find()

◆ wm_gizmomaptypes_free()

void wm_gizmomaptypes_free ( )

◆ wm_gizmos_keymap()

void wm_gizmos_keymap ( wmKeyConfig * keyconf)

Initialize key-maps for all existing gizmo-groups

Definition at line 1290 of file wm_gizmo_map.cc.

References gizmomaptypes, LISTBASE_FOREACH, wm_gizmogroup_tweak_modal_keymap(), and wm_gizmogrouptype_setup_keymap().

Referenced by wm_window_keymap().

◆ WM_reinit_gizmomap_all()

Variable Documentation

◆ gizmomaptypes

ListBase gizmomaptypes = {nullptr, nullptr}
static

Store all gizmo-maps here. Anyone who wants to register a gizmo for a certain area type can query the gizmo-map to do so.

Definition at line 53 of file wm_gizmo_map.cc.

Referenced by WM_gizmoconfig_update(), WM_gizmomaptype_ensure(), WM_gizmomaptype_find(), wm_gizmomaptypes_free(), and wm_gizmos_keymap().

◆ wm_gzmap_type_update_flag