From b931e7ab4fa8b876cd8f96219c5abd872a8fe3b1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 24 Sep 2018 16:40:21 +1000 Subject: Gizmo: option to hide from selection Allows some gizmo to be used as guides. --- source/blender/makesrna/intern/rna_wm_gizmo.c | 7 +++++++ source/blender/windowmanager/gizmo/WM_gizmo_types.h | 17 +++++++++-------- .../blender/windowmanager/gizmo/intern/wm_gizmo_group.c | 4 ++-- .../blender/windowmanager/gizmo/intern/wm_gizmo_map.c | 7 ++++--- 4 files changed, 22 insertions(+), 13 deletions(-) (limited to 'source/blender') diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 6a1d00b13ae..358549fecd2 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -404,6 +404,7 @@ RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_GIZMO_DRAW_VALUE); RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_draw_offset_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE); RNA_GIZMO_GENERIC_FLAG_NEG_RW_DEF(flag_use_draw_scale, flag, WM_GIZMO_DRAW_OFFSET_SCALE); RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_GIZMO_HIDDEN); +RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_hide_select, flag, WM_GIZMO_HIDDEN_SELECT); RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_grab_cursor, flag, WM_GIZMO_MOVE_CURSOR); RNA_GIZMO_GENERIC_FLAG_RW_DEF(flag_use_select_background, flag, WM_GIZMO_SELECT_BACKGROUND); @@ -1101,6 +1102,12 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop) prop, "rna_Gizmo_flag_hide_get", "rna_Gizmo_flag_hide_set"); RNA_def_property_ui_text(prop, "Hide", ""); RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); + /* WM_GIZMO_HIDDEN_SELECT */ + prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs( + prop, "rna_Gizmo_flag_hide_select_get", "rna_Gizmo_flag_hide_select_set"); + RNA_def_property_ui_text(prop, "Hide Select", ""); + RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL); /* WM_GIZMO_MOVE_CURSOR */ prop = RNA_def_property(srna, "use_grab_cursor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs( diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index bb86217d132..f67a0d05bee 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -67,25 +67,26 @@ typedef enum eWM_GizmoFlagState { * Flags for individual gizmos. */ typedef enum eWM_GizmoFlag { - WM_GIZMO_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ - WM_GIZMO_DRAW_MODAL = (1 << 1), /* draw while dragging */ - WM_GIZMO_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ - WM_GIZMO_HIDDEN = (1 << 3), + WM_GIZMO_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */ + WM_GIZMO_DRAW_MODAL = (1 << 1), /* draw while dragging */ + WM_GIZMO_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */ + WM_GIZMO_HIDDEN = (1 << 3), + WM_GIZMO_HIDDEN_SELECT = (1 << 4), /** * When set 'scale_final' value also scales the offset. * Use when offset is to avoid screen-space overlap instead of absolute positioning. */ - WM_GIZMO_DRAW_OFFSET_SCALE = (1 << 4), + WM_GIZMO_DRAW_OFFSET_SCALE = (1 << 5), /** * User should still use 'scale_final' for any handles and UI elements. * This simply skips scale when calculating the final matrix. * Needed when the gizmo needs to align with the interface underneath it. */ - WM_GIZMO_DRAW_NO_SCALE = (1 << 5), + WM_GIZMO_DRAW_NO_SCALE = (1 << 6), /** * Hide the cursor and lock it's position while interacting with this gizmo. */ - WM_GIZMO_MOVE_CURSOR = (1 << 6), + WM_GIZMO_MOVE_CURSOR = (1 << 7), /** Don't write into the depth buffer when selecting. */ - WM_GIZMO_SELECT_BACKGROUND = (1 << 7), + WM_GIZMO_SELECT_BACKGROUND = (1 << 8), } eWM_GizmoFlag; /** diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 070d0ba76b0..221d8df6c2b 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -152,7 +152,7 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo( int *r_part) { for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { - if (gz->type->test_select && (gz->flag & WM_GIZMO_HIDDEN) == 0) { + if (gz->type->test_select && (gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) { if ((*r_part = gz->type->test_select(C, gz, event->mval)) != -1) { return gz; } @@ -168,7 +168,7 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo( void wm_gizmogroup_intersectable_gizmos_to_list(const wmGizmoGroup *gzgroup, ListBase *listbase) { for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { - if ((gz->flag & WM_GIZMO_HIDDEN) == 0) { + if ((gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) { if (((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) && (gz->type->draw_select || gz->type->test_select)) || ((gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0 && gz->type->test_select)) { diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index 0883a1726bd..c6d6a5cd48c 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -267,7 +267,7 @@ bool WM_gizmomap_minmax( static GHash *WM_gizmomap_gizmo_hash_new( const bContext *C, wmGizmoMap *gzmap, bool (*poll)(const wmGizmo *, void *), - void *data, const bool include_hidden) + void *data, const eWM_GizmoFlag flag_exclude) { GHash *hash = BLI_ghash_ptr_new(__func__); @@ -275,7 +275,7 @@ static GHash *WM_gizmomap_gizmo_hash_new( for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { if (WM_gizmo_group_type_poll(C, gzgroup->type)) { for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { - if ((include_hidden || (gz->flag & WM_GIZMO_HIDDEN) == 0) && + if (((flag_exclude == 0) || ((gz->flag & flag_exclude) == 0)) && (!poll || poll(gz, data))) { BLI_ghash_insert(hash, gz, gz); @@ -787,7 +787,8 @@ static bool wm_gizmomap_select_all_intern( * get tot_sel for allocating, once for actually selecting). Instead we collect * selectable gizmos in hash table and use this to get tot_sel and do selection */ - GHash *hash = WM_gizmomap_gizmo_hash_new(C, gzmap, gizmo_selectable_poll, NULL, true); + GHash *hash = WM_gizmomap_gizmo_hash_new( + C, gzmap, gizmo_selectable_poll, NULL, WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT); GHashIterator gh_iter; int i; bool changed = false; -- cgit v1.2.3