Blender  V3.3
Typedefs | Enumerations | Variables
wm_gizmo_map.c File Reference
#include <string.h>
#include "BLI_buffer.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_math_bits.h"
#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
#include "GPU_framebuffer.h"
#include "GPU_matrix.h"
#include "GPU_platform.h"
#include "GPU_select.h"
#include "GPU_state.h"
#include "GPU_viewport.h"
#include "MEM_guardedalloc.h"
#include "WM_api.h"
#include "WM_types.h"
#include "wm_event_system.h"
#include "UI_interface.h"
#include "DEG_depsgraph.h"
#include "wm_gizmo_intern.h"
#include "wm_gizmo_wmapi.h"

Go to the source code of this file.

Typedefs

typedef enum eWM_GizmoFlagGroupTypeGlobalFlag eWM_GizmoFlagGroupTypeGlobalFlag
 

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) }
 
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 (struct wmGizmoMapType *gzmap_type, wmGizmoMap *gzmap)
 
wmGizmoMapWM_gizmomap_new_from_type (const struct 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 (struct wmGizmoMap *gzmap, const char *idname)
 
wmGizmoGroupWM_gizmomap_group_find_ptr (struct wmGizmoMap *gzmap, const struct 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 UNUSED(use_hidden), 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)
 
BLI_INLINE bool gizmo_selectable_poll (const wmGizmo *gz, void *UNUSED(data))
 
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 *UNUSED(C), wmEventHandler_Gizmo *UNUSED(handler))
 
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, struct wmMsgBus *mbus)
 
Tooltip Handling
struct ARegionWM_gizmomap_tooltip_init (struct bContext *C, struct ARegion *region, int *UNUSED(r_pass), double *UNUSED(pass_delay), bool *r_exit_on_event)
 
wmGizmoMapType
wmGizmoMapTypeWM_gizmomaptype_find (const struct wmGizmoMapType_Params *gzmap_params)
 
wmGizmoMapTypeWM_gizmomaptype_ensure (const struct wmGizmoMapType_Params *gzmap_params)
 
void wm_gizmomaptypes_free (void)
 
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 (struct Main *bmain)
 
Recreate All Gizmos

Use when adjusting themes.

void WM_reinit_gizmomap_all (Main *bmain)
 

Variables

static ListBase gizmomaptypes = {NULL, NULL}
 
static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag = 0
 

Typedef Documentation

◆ eWM_GizmoFlagGroupTypeGlobalFlag

Update when gizmo-map types change.

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 72 of file wm_gizmo_map.c.

◆ 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.

Definition at line 57 of file wm_gizmo_map.c.

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()

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

◆ 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()

BLI_INLINE bool gizmo_selectable_poll ( const wmGizmo gz,
void UNUSEDdata 
)

◆ gizmomap_prepare_drawing()

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

◆ gizmos_draw_list()

static void gizmos_draw_list ( const wmGizmoMap gzmap,
const bContext C,
ListBase draw_gizmos 
)
static

◆ WM_gizmoconfig_update()

void WM_gizmoconfig_update ( struct Main bmain)

◆ WM_gizmoconfig_update_tag_group_remove()

void WM_gizmoconfig_update_tag_group_remove ( wmGizmoMap gzmap)

◆ WM_gizmoconfig_update_tag_group_type_init()

void WM_gizmoconfig_update_tag_group_type_init ( wmGizmoMapType gzmap_type,
wmGizmoGroupType gzgt 
)

◆ WM_gizmoconfig_update_tag_group_type_remove()

void WM_gizmoconfig_update_tag_group_type_remove ( wmGizmoMapType gzmap_type,
wmGizmoGroupType gzgt 
)

◆ WM_gizmomap_add_handlers()

void WM_gizmomap_add_handlers ( ARegion region,
wmGizmoMap gzmap 
)

◆ WM_gizmomap_cursor_set()

bool WM_gizmomap_cursor_set ( const wmGizmoMap gzmap,
wmWindow win 
)

◆ wm_gizmomap_deselect_all()

bool wm_gizmomap_deselect_all ( struct wmGizmoMap gzmap)

Deselect all selected gizmos in gzmap.

Returns
if selection has changed.

Definition at line 855 of file wm_gizmo_map.c.

References wmGizmoMap::gzmap_context, wmGizmoMapSelectState::items, wmGizmoMapSelectState::len, NULL, 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()

void WM_gizmomap_draw ( wmGizmoMap gzmap,
const bContext C,
const eWM_GizmoFlagMapDrawStep  drawstep 
)

◆ WM_gizmomap_drawstep_from_gizmo_group()

eWM_GizmoFlagMapDrawStep WM_gizmomap_drawstep_from_gizmo_group ( const wmGizmoGroup gzgroup)

◆ wm_gizmomap_free_data()

static void wm_gizmomap_free_data ( wmGizmoMap gzmap)
static

◆ WM_gizmomap_get_modal()

wmGizmo* WM_gizmomap_get_modal ( const wmGizmoMap gzmap)

◆ WM_gizmomap_gizmo_hash_new()

static GHash* WM_gizmomap_gizmo_hash_new ( const bContext C,
wmGizmoMap gzmap,
bool(*)(const wmGizmo *, void *)  poll,
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(campbell): this uses unreliable order, best we use an iterator function instead of a hash.

Definition at line 265 of file wm_gizmo_map.c.

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

Referenced by wm_gizmomap_select_all_intern().

◆ WM_gizmomap_group_find()

wmGizmoGroup* WM_gizmomap_group_find ( struct wmGizmoMap gzmap,
const char *  idname 
)

◆ WM_gizmomap_group_find_ptr()

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

Definition at line 211 of file wm_gizmo_map.c.

References wmGizmoMap::groups, LISTBASE_FOREACH, and NULL.

Referenced by v3d_cursor_snap_poll_fn(), and WM_gizmomap_group_find().

◆ 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 1139 of file wm_gizmo_map.c.

References wmGizmoMap::groups.

◆ wm_gizmomap_handler_context_gizmo()

void wm_gizmomap_handler_context_gizmo ( bContext UNUSEDC,
wmEventHandler_Gizmo UNUSEDhandler 
)

Definition at line 967 of file wm_gizmo_map.c.

Referenced by wm_handlers_do_gizmo_handler().

◆ wm_gizmomap_handler_context_op()

void wm_gizmomap_handler_context_op ( bContext C,
struct 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 934 of file wm_gizmo_map.c.

References blender::compositor::area(), wmEventHandler_Op::area, bScreen::areabase, C, wmEventHandler_Op::context, CTX_wm_area_set(), CTX_wm_region_set(), CTX_wm_screen(), ListBase::first, ARegion::next, NULL, and wmEventHandler_Op::region.

Referenced by wm_gizmomaps_handled_modal_update().

◆ wm_gizmomap_highlight_find()

wmGizmo* wm_gizmomap_highlight_find ( wmGizmoMap gzmap,
bContext C,
const wmEvent event,
int *  r_part 
)

◆ wm_gizmomap_highlight_get()

wmGizmo* wm_gizmomap_highlight_get ( wmGizmoMap gzmap)

◆ wm_gizmomap_highlight_set()

bool wm_gizmomap_highlight_set ( wmGizmoMap gzmap,
const bContext C,
wmGizmo gz,
int  part 
)

◆ 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,
struct wmMsgBus mbus 
)

◆ WM_gizmomap_minmax()

bool WM_gizmomap_minmax ( const wmGizmoMap gzmap,
bool   UNUSEDuse_hidden,
bool  use_select,
float  r_min[3],
float  r_max[3] 
)

◆ 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 struct wmGizmoMapType_Params gzmap_params)

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

Definition at line 166 of file wm_gizmo_map.c.

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

Referenced by ed_default_handlers().

◆ wm_gizmomap_new_from_type_ex()

static wmGizmoMap* wm_gizmomap_new_from_type_ex ( struct wmGizmoMapType gzmap_type,
wmGizmoMap gzmap 
)
static

◆ WM_gizmomap_reinit()

void WM_gizmomap_reinit ( struct wmGizmoMap gzmap)

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

Definition at line 194 of file wm_gizmo_map.c.

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 188 of file wm_gizmo_map.c.

References MEM_freeN, and wm_gizmomap_free_data().

Referenced by WM_init().

◆ WM_gizmomap_select_all()

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

Select/Deselect all selectable gizmos in gzmap.

Returns
if selection has changed.

TODO: select all by type.

Definition at line 911 of file wm_gizmo_map.c.

References BLI_assert_unreachable, C, 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()

static bool wm_gizmomap_select_all_intern ( bContext C,
wmGizmoMap gzmap 
)
static

◆ wm_gizmomap_select_array_clear()

void wm_gizmomap_select_array_clear ( wmGizmoMap gzmap)

◆ 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()

void wm_gizmomap_select_array_push_back ( wmGizmoMap gzmap,
wmGizmo gz 
)

◆ wm_gizmomap_select_array_remove()

void wm_gizmomap_select_array_remove ( wmGizmoMap gzmap,
wmGizmo gz 
)

◆ wm_gizmomap_select_array_shrink()

void wm_gizmomap_select_array_shrink ( wmGizmoMap gzmap,
int  len_subtract 
)

◆ 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()

void WM_gizmomap_tag_refresh ( wmGizmoMap gzmap)

◆ WM_gizmomap_tag_refresh_drawstep()

void WM_gizmomap_tag_refresh_drawstep ( wmGizmoMap gzmap,
const eWM_GizmoFlagMapDrawStep  drawstep 
)

◆ WM_gizmomap_tooltip_init()

struct ARegion* WM_gizmomap_tooltip_init ( struct bContext C,
struct ARegion region,
int *  UNUSEDr_pass,
double UNUSEDpass_delay,
bool r_exit_on_event 
)

◆ wm_gizmomaps_handled_modal_update()

void wm_gizmomaps_handled_modal_update ( bContext C,
wmEvent event,
wmEventHandler_Op handler 
)

◆ WM_gizmomaptype_ensure()

wmGizmoMapType* WM_gizmomaptype_ensure ( const struct wmGizmoMapType_Params gzmap_params)

◆ WM_gizmomaptype_find()

wmGizmoMapType* WM_gizmomaptype_find ( const struct wmGizmoMapType_Params gzmap_params)

◆ wm_gizmomaptypes_free()

void wm_gizmomaptypes_free ( void  )

Definition at line 1228 of file wm_gizmo_map.c.

References ListBase::first, gizmomaptypes, MEM_freeN, and WM_gizmomaptype_group_free().

Referenced by WM_exit_ex().

◆ wm_gizmos_keymap()

void wm_gizmos_keymap ( struct wmKeyConfig keyconf)

Initialize key-maps for all existing gizmo-groups

Definition at line 1242 of file wm_gizmo_map.c.

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

Referenced by wm_window_keymap().

◆ WM_reinit_gizmomap_all()

void WM_reinit_gizmomap_all ( Main bmain)

Variable Documentation

◆ gizmomaptypes

ListBase gizmomaptypes = {NULL, NULL}
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 51 of file wm_gizmo_map.c.

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

◆ wm_gzmap_type_update_flag

eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag = 0
static