WM: move to C++
Also see #103343. Pull Request: https://projects.blender.org/blender/blender/pulls/110292
This commit is contained in:
@@ -30,46 +30,46 @@ set(INC
|
||||
)
|
||||
|
||||
set(SRC
|
||||
intern/wm.c
|
||||
intern/wm_cursors.c
|
||||
intern/wm.cc
|
||||
intern/wm_cursors.cc
|
||||
intern/wm_dragdrop.cc
|
||||
intern/wm_draw.c
|
||||
intern/wm_event_query.c
|
||||
intern/wm_draw.cc
|
||||
intern/wm_event_query.cc
|
||||
intern/wm_event_system.cc
|
||||
intern/wm_files.cc
|
||||
intern/wm_files_link.c
|
||||
intern/wm_gesture.c
|
||||
intern/wm_gesture_ops.c
|
||||
intern/wm_files_link.cc
|
||||
intern/wm_gesture.cc
|
||||
intern/wm_gesture_ops.cc
|
||||
intern/wm_init_exit.cc
|
||||
intern/wm_jobs.c
|
||||
intern/wm_keymap.c
|
||||
intern/wm_keymap_utils.c
|
||||
intern/wm_menu_type.c
|
||||
intern/wm_operator_props.c
|
||||
intern/wm_operator_type.c
|
||||
intern/wm_operator_utils.c
|
||||
intern/wm_operators.c
|
||||
intern/wm_panel_type.c
|
||||
intern/wm_platform_support.c
|
||||
intern/wm_playanim.c
|
||||
intern/wm_splash_screen.c
|
||||
intern/wm_stereo.c
|
||||
intern/wm_subwindow.c
|
||||
intern/wm_surface.c
|
||||
intern/wm_toolsystem.c
|
||||
intern/wm_tooltip.c
|
||||
intern/wm_uilist_type.c
|
||||
intern/wm_utils.c
|
||||
intern/wm_window.c
|
||||
gizmo/intern/wm_gizmo.c
|
||||
gizmo/intern/wm_gizmo_group.c
|
||||
gizmo/intern/wm_gizmo_group_type.c
|
||||
gizmo/intern/wm_gizmo_map.c
|
||||
gizmo/intern/wm_gizmo_target_props.c
|
||||
gizmo/intern/wm_gizmo_type.c
|
||||
message_bus/intern/wm_message_bus.c
|
||||
message_bus/intern/wm_message_bus_rna.c
|
||||
message_bus/intern/wm_message_bus_static.c
|
||||
intern/wm_jobs.cc
|
||||
intern/wm_keymap.cc
|
||||
intern/wm_keymap_utils.cc
|
||||
intern/wm_menu_type.cc
|
||||
intern/wm_operator_props.cc
|
||||
intern/wm_operator_type.cc
|
||||
intern/wm_operator_utils.cc
|
||||
intern/wm_operators.cc
|
||||
intern/wm_panel_type.cc
|
||||
intern/wm_platform_support.cc
|
||||
intern/wm_playanim.cc
|
||||
intern/wm_splash_screen.cc
|
||||
intern/wm_stereo.cc
|
||||
intern/wm_subwindow.cc
|
||||
intern/wm_surface.cc
|
||||
intern/wm_toolsystem.cc
|
||||
intern/wm_tooltip.cc
|
||||
intern/wm_uilist_type.cc
|
||||
intern/wm_utils.cc
|
||||
intern/wm_window.cc
|
||||
gizmo/intern/wm_gizmo.cc
|
||||
gizmo/intern/wm_gizmo_group.cc
|
||||
gizmo/intern/wm_gizmo_group_type.cc
|
||||
gizmo/intern/wm_gizmo_map.cc
|
||||
gizmo/intern/wm_gizmo_target_props.cc
|
||||
gizmo/intern/wm_gizmo_type.cc
|
||||
message_bus/intern/wm_message_bus.cc
|
||||
message_bus/intern/wm_message_bus_rna.cc
|
||||
message_bus/intern/wm_message_bus_static.cc
|
||||
|
||||
WM_api.h
|
||||
WM_keymap.h
|
||||
@@ -192,12 +192,12 @@ if(WITH_XR_OPENXR)
|
||||
)
|
||||
|
||||
list(APPEND SRC
|
||||
xr/intern/wm_xr.c
|
||||
xr/intern/wm_xr_action.c
|
||||
xr/intern/wm_xr_actionmap.c
|
||||
xr/intern/wm_xr_draw.c
|
||||
xr/intern/wm_xr_operators.c
|
||||
xr/intern/wm_xr_session.c
|
||||
xr/intern/wm_xr.cc
|
||||
xr/intern/wm_xr_action.cc
|
||||
xr/intern/wm_xr_actionmap.cc
|
||||
xr/intern/wm_xr_draw.cc
|
||||
xr/intern/wm_xr_operators.cc
|
||||
xr/intern/wm_xr_session.cc
|
||||
|
||||
xr/wm_xr.h
|
||||
xr/intern/wm_xr_intern.h
|
||||
|
||||
@@ -174,6 +174,7 @@ typedef enum eWM_CapabilitiesFlag {
|
||||
/** Ability to copy/paste system clipboard images. */
|
||||
WM_CAPABILITY_CLIPBOARD_IMAGES = (1 << 4),
|
||||
} eWM_CapabilitiesFlag;
|
||||
ENUM_OPERATORS(eWM_CapabilitiesFlag, WM_CAPABILITY_CLIPBOARD_IMAGES)
|
||||
|
||||
eWM_CapabilitiesFlag WM_capabilities_flag(void);
|
||||
|
||||
|
||||
@@ -885,6 +885,7 @@ typedef enum {
|
||||
* deleted in a safe context. */
|
||||
WM_TIMER_TAGGED_FOR_REMOVAL = 1 << 16,
|
||||
} wmTimerFlags;
|
||||
ENUM_OPERATORS(wmTimerFlags, WM_TIMER_TAGGED_FOR_REMOVAL)
|
||||
|
||||
typedef struct wmTimer {
|
||||
struct wmTimer *next, *prev;
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef enum eWM_GizmoFlagState {
|
||||
WM_GIZMO_STATE_MODAL = (1 << 1),
|
||||
WM_GIZMO_STATE_SELECT = (1 << 2),
|
||||
} eWM_GizmoFlagState;
|
||||
ENUM_OPERATORS(eWM_GizmoFlagState, WM_GIZMO_STATE_SELECT)
|
||||
|
||||
/**
|
||||
* #wmGizmo.flag
|
||||
@@ -161,6 +162,7 @@ typedef enum eWM_GizmoFlagGroupInitFlag {
|
||||
WM_GIZMOGROUP_INIT_SETUP = (1 << 0),
|
||||
WM_GIZMOGROUP_INIT_REFRESH = (1 << 1),
|
||||
} eWM_GizmoFlagGroupInitFlag;
|
||||
ENUM_OPERATORS(eWM_GizmoFlagGroupInitFlag, WM_GIZMOGROUP_INIT_REFRESH)
|
||||
|
||||
/**
|
||||
* #wmGizmoMapType.type_update_flag
|
||||
@@ -175,6 +177,7 @@ typedef enum eWM_GizmoFlagMapTypeUpdateFlag {
|
||||
* So we need to keep track of keymap initialization separately. */
|
||||
WM_GIZMOMAPTYPE_KEYMAP_INIT = (1 << 2),
|
||||
} eWM_GizmoFlagMapTypeUpdateFlag;
|
||||
ENUM_OPERATORS(eWM_GizmoFlagMapTypeUpdateFlag, WM_GIZMOMAPTYPE_KEYMAP_INIT)
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* wmGizmo */
|
||||
|
||||
@@ -50,23 +50,23 @@ static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz);
|
||||
*/
|
||||
static wmGizmo *wm_gizmo_create(const wmGizmoType *gzt, PointerRNA *properties)
|
||||
{
|
||||
BLI_assert(gzt != NULL);
|
||||
BLI_assert(gzt != nullptr);
|
||||
BLI_assert(gzt->struct_size >= sizeof(wmGizmo));
|
||||
|
||||
wmGizmo *gz = MEM_callocN(
|
||||
gzt->struct_size + (sizeof(wmGizmoProperty) * gzt->target_property_defs_len), __func__);
|
||||
wmGizmo *gz = static_cast<wmGizmo *>(MEM_callocN(
|
||||
gzt->struct_size + (sizeof(wmGizmoProperty) * gzt->target_property_defs_len), __func__));
|
||||
gz->type = gzt;
|
||||
|
||||
/* initialize properties, either copy or create */
|
||||
gz->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA");
|
||||
gz->ptr = static_cast<PointerRNA *>(MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA"));
|
||||
if (properties && properties->data) {
|
||||
gz->properties = IDP_CopyProperty(properties->data);
|
||||
gz->properties = IDP_CopyProperty(static_cast<const IDProperty *>(properties->data));
|
||||
}
|
||||
else {
|
||||
IDPropertyTemplate val = {0};
|
||||
gz->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties");
|
||||
}
|
||||
RNA_pointer_create(G_MAIN->wm.first, gzt->srna, gz->properties, gz->ptr);
|
||||
RNA_pointer_create(static_cast<ID *>(G_MAIN->wm.first), gzt->srna, gz->properties, gz->ptr);
|
||||
|
||||
WM_gizmo_properties_sanitize(gz->ptr, 0);
|
||||
|
||||
@@ -85,7 +85,7 @@ wmGizmo *WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, Pointer
|
||||
|
||||
wm_gizmo_register(gzgroup, gz);
|
||||
|
||||
if (gz->type->setup != NULL) {
|
||||
if (gz->type->setup != nullptr) {
|
||||
gz->type->setup(gz);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
|
||||
|
||||
void WM_gizmo_free(wmGizmo *gz)
|
||||
{
|
||||
if (gz->type->free != NULL) {
|
||||
if (gz->type->free != nullptr) {
|
||||
gz->type->free(gz);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void WM_gizmo_free(wmGizmo *gz)
|
||||
MEM_freeN(gz->op_data);
|
||||
}
|
||||
|
||||
if (gz->ptr != NULL) {
|
||||
if (gz->ptr != nullptr) {
|
||||
WM_gizmo_properties_free(gz->ptr);
|
||||
MEM_freeN(gz->ptr);
|
||||
}
|
||||
@@ -166,10 +166,10 @@ void WM_gizmo_free(wmGizmo *gz)
|
||||
void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
|
||||
{
|
||||
if (gz->state & WM_GIZMO_STATE_HIGHLIGHT) {
|
||||
wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
|
||||
wm_gizmomap_highlight_set(gzmap, C, nullptr, 0);
|
||||
}
|
||||
if (gz->state & WM_GIZMO_STATE_MODAL) {
|
||||
wm_gizmomap_modal_set(gzmap, C, gz, NULL, false);
|
||||
wm_gizmomap_modal_set(gzmap, C, gz, nullptr, false);
|
||||
}
|
||||
/* Unlink instead of setting so we don't run callbacks. */
|
||||
if (gz->state & WM_GIZMO_STATE_SELECT) {
|
||||
@@ -198,7 +198,7 @@ wmGizmoOpElem *WM_gizmo_operator_get(wmGizmo *gz, int part_index)
|
||||
if (gz->op_data && ((part_index >= 0) && (part_index < gz->op_data_len))) {
|
||||
return &gz->op_data[part_index];
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PointerRNA *WM_gizmo_operator_set(wmGizmo *gz,
|
||||
@@ -210,7 +210,8 @@ PointerRNA *WM_gizmo_operator_set(wmGizmo *gz,
|
||||
/* We could pre-allocate these but using multiple is such a rare thing. */
|
||||
if (part_index >= gz->op_data_len) {
|
||||
gz->op_data_len = part_index + 1;
|
||||
gz->op_data = MEM_recallocN(gz->op_data, sizeof(*gz->op_data) * gz->op_data_len);
|
||||
gz->op_data = static_cast<wmGizmoOpElem *>(
|
||||
MEM_recallocN(gz->op_data, sizeof(*gz->op_data) * gz->op_data_len));
|
||||
}
|
||||
wmGizmoOpElem *gzop = &gz->op_data[part_index];
|
||||
gzop->type = ot;
|
||||
@@ -234,11 +235,13 @@ int WM_gizmo_operator_invoke(bContext *C, wmGizmo *gz, wmGizmoOpElem *gzop, cons
|
||||
PointerRNA tref_ptr;
|
||||
bToolRef *tref = WM_toolsystem_ref_from_context(C);
|
||||
if (tref && WM_toolsystem_ref_properties_get_from_operator(tref, gzop->type, &tref_ptr)) {
|
||||
if (gzop->ptr.data == NULL) {
|
||||
if (gzop->ptr.data == nullptr) {
|
||||
IDPropertyTemplate val = {0};
|
||||
gzop->ptr.data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
|
||||
}
|
||||
IDP_MergeGroup(gzop->ptr.data, tref_ptr.data, false);
|
||||
IDP_MergeGroup(static_cast<IDProperty *>(gzop->ptr.data),
|
||||
static_cast<const IDProperty *>(tref_ptr.data),
|
||||
false);
|
||||
}
|
||||
}
|
||||
return WM_operator_name_call_ptr(C, gzop->type, WM_OP_INVOKE_DEFAULT, &gzop->ptr, event);
|
||||
@@ -247,7 +250,7 @@ int WM_gizmo_operator_invoke(bContext *C, wmGizmo *gz, wmGizmoOpElem *gzop, cons
|
||||
static void wm_gizmo_set_matrix_rotation_from_z_axis__internal(float matrix[4][4],
|
||||
const float z_axis[3])
|
||||
{
|
||||
/* old code, seems we can use simpler method */
|
||||
/* old code, seems we can use simpler method */
|
||||
#if 0
|
||||
const float z_global[3] = {0.0f, 0.0f, 1.0f};
|
||||
float rot[3][3];
|
||||
@@ -305,10 +308,10 @@ void WM_gizmo_set_matrix_offset_location(wmGizmo *gz, const float offset[3])
|
||||
void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
gz->flag |= flag;
|
||||
gz->flag |= eWM_GizmoFlag(flag);
|
||||
}
|
||||
else {
|
||||
gz->flag &= ~flag;
|
||||
gz->flag &= eWM_GizmoFlag(~flag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +405,7 @@ bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
|
||||
|
||||
bool WM_gizmo_highlight_set(wmGizmoMap *gzmap, wmGizmo *gz)
|
||||
{
|
||||
return wm_gizmomap_highlight_set(gzmap, NULL, gz, gz ? gz->highlight_part : 0);
|
||||
return wm_gizmomap_highlight_set(gzmap, nullptr, gz, gz ? gz->highlight_part : 0);
|
||||
}
|
||||
|
||||
bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
|
||||
@@ -424,7 +427,7 @@ void WM_gizmo_modal_set_from_setup(
|
||||
}
|
||||
else {
|
||||
/* WEAK: but it works. */
|
||||
WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_DEFAULT, NULL, event);
|
||||
WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_DEFAULT, nullptr, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,7 +534,7 @@ void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz,
|
||||
const float *scale_final = params->scale_final ? params->scale_final : &gz->scale_final;
|
||||
|
||||
float final_matrix[4][4];
|
||||
if (params->matrix_basis == NULL && gz->type->matrix_basis_get) {
|
||||
if (params->matrix_basis == nullptr && gz->type->matrix_basis_get) {
|
||||
gz->type->matrix_basis_get(gz, final_matrix);
|
||||
}
|
||||
else {
|
||||
@@ -560,26 +563,22 @@ void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
|
||||
float mat_identity[4][4];
|
||||
unit_m4(mat_identity);
|
||||
|
||||
WM_gizmo_calc_matrix_final_params(gz,
|
||||
&((struct WM_GizmoMatrixParams){
|
||||
.matrix_space = NULL,
|
||||
.matrix_basis = NULL,
|
||||
.matrix_offset = mat_identity,
|
||||
.scale_final = NULL,
|
||||
}),
|
||||
r_mat);
|
||||
WM_GizmoMatrixParams params{};
|
||||
params.matrix_space = nullptr;
|
||||
params.matrix_basis = nullptr;
|
||||
params.matrix_offset = mat_identity;
|
||||
params.scale_final = nullptr;
|
||||
WM_gizmo_calc_matrix_final_params(gz, ¶ms, r_mat);
|
||||
}
|
||||
|
||||
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
|
||||
{
|
||||
WM_gizmo_calc_matrix_final_params(gz,
|
||||
&((struct WM_GizmoMatrixParams){
|
||||
.matrix_space = NULL,
|
||||
.matrix_basis = NULL,
|
||||
.matrix_offset = NULL,
|
||||
.scale_final = NULL,
|
||||
}),
|
||||
r_mat);
|
||||
WM_GizmoMatrixParams params{};
|
||||
params.matrix_space = nullptr;
|
||||
params.matrix_basis = nullptr;
|
||||
params.matrix_offset = nullptr;
|
||||
params.scale_final = nullptr;
|
||||
WM_gizmo_calc_matrix_final_params(gz, ¶ms, r_mat);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -591,7 +590,7 @@ void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
|
||||
|
||||
void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *gzt)
|
||||
{
|
||||
RNA_pointer_create(NULL, gzt->srna, NULL, ptr);
|
||||
RNA_pointer_create(nullptr, gzt->srna, nullptr, ptr);
|
||||
}
|
||||
|
||||
void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
|
||||
@@ -602,19 +601,19 @@ void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
|
||||
WM_gizmo_properties_create_ptr(ptr, (wmGizmoType *)gzt);
|
||||
}
|
||||
else {
|
||||
RNA_pointer_create(NULL, &RNA_GizmoProperties, NULL, ptr);
|
||||
RNA_pointer_create(nullptr, &RNA_GizmoProperties, nullptr, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring)
|
||||
{
|
||||
if (*properties == NULL) {
|
||||
if (*properties == nullptr) {
|
||||
IDPropertyTemplate val = {0};
|
||||
*properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
|
||||
}
|
||||
|
||||
if (*ptr == NULL) {
|
||||
*ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
|
||||
if (*ptr == nullptr) {
|
||||
*ptr = static_cast<PointerRNA *>(MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"));
|
||||
WM_gizmo_properties_create(*ptr, gtstring);
|
||||
}
|
||||
|
||||
@@ -684,7 +683,7 @@ void WM_gizmo_properties_reset(wmGizmo *gz)
|
||||
iterprop = RNA_struct_iterator_property(gz->type->srna);
|
||||
|
||||
RNA_PROP_BEGIN (gz->ptr, itemptr, iterprop) {
|
||||
PropertyRNA *prop = itemptr.data;
|
||||
PropertyRNA *prop = static_cast<PropertyRNA *>(itemptr.data);
|
||||
|
||||
if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
|
||||
const char *identifier = RNA_property_identifier(prop);
|
||||
@@ -697,7 +696,7 @@ void WM_gizmo_properties_reset(wmGizmo *gz)
|
||||
|
||||
void WM_gizmo_properties_clear(PointerRNA *ptr)
|
||||
{
|
||||
IDProperty *properties = ptr->data;
|
||||
IDProperty *properties = static_cast<IDProperty *>(ptr->data);
|
||||
|
||||
if (properties) {
|
||||
IDP_ClearProperty(properties);
|
||||
@@ -706,11 +705,11 @@ void WM_gizmo_properties_clear(PointerRNA *ptr)
|
||||
|
||||
void WM_gizmo_properties_free(PointerRNA *ptr)
|
||||
{
|
||||
IDProperty *properties = ptr->data;
|
||||
IDProperty *properties = static_cast<IDProperty *>(ptr->data);
|
||||
|
||||
if (properties) {
|
||||
IDP_FreeProperty(properties);
|
||||
ptr->data = NULL; /* just in case */
|
||||
ptr->data = nullptr; /* just in case */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@
|
||||
|
||||
wmGizmoGroup *wm_gizmogroup_new_from_type(wmGizmoMap *gzmap, wmGizmoGroupType *gzgt)
|
||||
{
|
||||
wmGizmoGroup *gzgroup = MEM_callocN(sizeof(*gzgroup), "gizmo-group");
|
||||
wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(
|
||||
MEM_callocN(sizeof(*gzgroup), "gizmo-group"));
|
||||
|
||||
gzgroup->type = gzgt;
|
||||
gzgroup->type->users += 1;
|
||||
@@ -65,7 +66,8 @@ wmGizmoGroup *wm_gizmogroup_new_from_type(wmGizmoMap *gzmap, wmGizmoGroupType *g
|
||||
|
||||
wmGizmoGroup *wm_gizmogroup_find_by_type(const wmGizmoMap *gzmap, const wmGizmoGroupType *gzgt)
|
||||
{
|
||||
return BLI_findptr(&gzmap->groups, gzgt, offsetof(wmGizmoGroup, type));
|
||||
return static_cast<wmGizmoGroup *>(
|
||||
BLI_findptr(&gzmap->groups, gzgt, offsetof(wmGizmoGroup, type)));
|
||||
}
|
||||
|
||||
void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup)
|
||||
@@ -76,13 +78,13 @@ void wm_gizmogroup_free(bContext *C, wmGizmoGroup *gzgroup)
|
||||
* we don't want to run callbacks. */
|
||||
if (gzmap->gzmap_context.highlight && gzmap->gzmap_context.highlight->parent_gzgroup == gzgroup)
|
||||
{
|
||||
wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
|
||||
wm_gizmomap_highlight_set(gzmap, C, nullptr, 0);
|
||||
}
|
||||
if (gzmap->gzmap_context.modal && gzmap->gzmap_context.modal->parent_gzgroup == gzgroup) {
|
||||
wm_gizmomap_modal_set(gzmap, C, gzmap->gzmap_context.modal, NULL, false);
|
||||
wm_gizmomap_modal_set(gzmap, C, gzmap->gzmap_context.modal, nullptr, false);
|
||||
}
|
||||
|
||||
for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) {
|
||||
for (wmGizmo *gz = static_cast<wmGizmo *>(gzgroup->gizmos.first), *gz_next; gz; gz = gz_next) {
|
||||
gz_next = gz->next;
|
||||
if (gzmap->gzmap_context.select.len) {
|
||||
WM_gizmo_select_unlink(gzmap, gz);
|
||||
@@ -139,8 +141,8 @@ void wm_gizmogroup_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
|
||||
|
||||
int WM_gizmo_cmp_temp_fl(const void *gz_a_ptr, const void *gz_b_ptr)
|
||||
{
|
||||
const wmGizmo *gz_a = gz_a_ptr;
|
||||
const wmGizmo *gz_b = gz_b_ptr;
|
||||
const wmGizmo *gz_a = static_cast<const wmGizmo *>(gz_a_ptr);
|
||||
const wmGizmo *gz_b = static_cast<const wmGizmo *>(gz_b_ptr);
|
||||
if (gz_a->temp.f < gz_b->temp.f) {
|
||||
return -1;
|
||||
}
|
||||
@@ -152,8 +154,8 @@ int WM_gizmo_cmp_temp_fl(const void *gz_a_ptr, const void *gz_b_ptr)
|
||||
|
||||
int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr)
|
||||
{
|
||||
const wmGizmo *gz_a = gz_a_ptr;
|
||||
const wmGizmo *gz_b = gz_b_ptr;
|
||||
const wmGizmo *gz_a = static_cast<const wmGizmo *>(gz_a_ptr);
|
||||
const wmGizmo *gz_b = static_cast<const wmGizmo *>(gz_b_ptr);
|
||||
if (gz_a->temp.f < gz_b->temp.f) {
|
||||
return 1;
|
||||
}
|
||||
@@ -211,7 +213,7 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm,
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void wm_gizmogroup_intersectable_gizmos_to_list(wmWindowManager *wm,
|
||||
@@ -220,7 +222,7 @@ void wm_gizmogroup_intersectable_gizmos_to_list(wmWindowManager *wm,
|
||||
BLI_Buffer *visible_gizmos)
|
||||
{
|
||||
int gzgroup_keymap_uses_modifier = -1;
|
||||
for (wmGizmo *gz = gzgroup->gizmos.last; gz; gz = gz->prev) {
|
||||
for (wmGizmo *gz = static_cast<wmGizmo *>(gzgroup->gizmos.last); gz; gz = gz->prev) {
|
||||
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)) ||
|
||||
@@ -248,10 +250,10 @@ void WM_gizmogroup_ensure_init(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
|
||||
/* Not ideal, initialize keymap here, needed for RNA runtime generated gizmos. */
|
||||
wmGizmoGroupType *gzgt = gzgroup->type;
|
||||
if (gzgt->keymap == NULL) {
|
||||
if (gzgt->keymap == nullptr) {
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wm_gizmogrouptype_setup_keymap(gzgt, wm->defaultconf);
|
||||
BLI_assert(gzgt->keymap != NULL);
|
||||
BLI_assert(gzgt->keymap != nullptr);
|
||||
}
|
||||
gzgroup->init_flag |= WM_GIZMOGROUP_INIT_SETUP;
|
||||
}
|
||||
@@ -272,14 +274,17 @@ void WM_gizmo_group_remove_by_tool(bContext *C,
|
||||
const bToolRef *tref)
|
||||
{
|
||||
wmGizmoMapType *gzmap_type = WM_gizmomaptype_find(&gzgt->gzmap_params);
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
if (area->runtime.tool == tref) {
|
||||
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||
wmGizmoMap *gzmap = region->gizmo_map;
|
||||
if (gzmap && gzmap->type == gzmap_type) {
|
||||
wmGizmoGroup *gzgroup, *gzgroup_next;
|
||||
for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup_next) {
|
||||
for (gzgroup = static_cast<wmGizmoGroup *>(gzmap->groups.first); gzgroup;
|
||||
gzgroup = gzgroup_next) {
|
||||
gzgroup_next = gzgroup->next;
|
||||
if (gzgroup->type == gzgt) {
|
||||
BLI_assert(gzgroup->parent_gzmap == gzmap);
|
||||
@@ -328,7 +333,7 @@ bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *gzgroup)
|
||||
* Basic operators for gizmo interaction with user configurable keymaps.
|
||||
* \{ */
|
||||
|
||||
static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
wmGizmoMap *gzmap = region->gizmo_map;
|
||||
@@ -342,7 +347,7 @@ static int gizmo_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
|
||||
/* deselect all first */
|
||||
if (extend == false && deselect == false && toggle == false) {
|
||||
wm_gizmomap_deselect_all(gzmap);
|
||||
BLI_assert(msel->items == NULL && msel->len == 0);
|
||||
BLI_assert(msel->items == nullptr && msel->len == 0);
|
||||
UNUSED_VARS_NDEBUG(msel);
|
||||
}
|
||||
|
||||
@@ -391,15 +396,14 @@ void GIZMOGROUP_OT_gizmo_select(wmOperatorType *ot)
|
||||
WM_operator_properties_mouse_select(ot);
|
||||
}
|
||||
|
||||
typedef struct GizmoTweakData {
|
||||
struct GizmoTweakData {
|
||||
wmGizmoMap *gzmap;
|
||||
wmGizmoGroup *gzgroup;
|
||||
wmGizmo *gz_modal;
|
||||
|
||||
int init_event; /* initial event type */
|
||||
int flag; /* tweak flags */
|
||||
|
||||
} GizmoTweakData;
|
||||
};
|
||||
|
||||
static bool gizmo_tweak_start(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz, const wmEvent *event)
|
||||
{
|
||||
@@ -423,7 +427,7 @@ static bool gizmo_tweak_start_and_finish(
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmOperator *op = WM_operator_last_redo(C);
|
||||
|
||||
/* We may want to enable this, for now the gizmo can manage its own properties. */
|
||||
/* We may want to enable this, for now the gizmo can manage its own properties. */
|
||||
#if 0
|
||||
IDP_MergeGroup(gzop->ptr.data, op->properties, false);
|
||||
#endif
|
||||
@@ -455,7 +459,7 @@ static bool gizmo_tweak_start_and_finish(
|
||||
|
||||
static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, bool clear_modal)
|
||||
{
|
||||
GizmoTweakData *mtweak = op->customdata;
|
||||
GizmoTweakData *mtweak = static_cast<GizmoTweakData *>(op->customdata);
|
||||
if (mtweak->gz_modal->type->exit) {
|
||||
mtweak->gz_modal->type->exit(C, mtweak->gz_modal, cancel);
|
||||
}
|
||||
@@ -464,7 +468,7 @@ static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, b
|
||||
if ((BLI_findindex(&mtweak->gzmap->groups, mtweak->gzgroup) != -1) &&
|
||||
(BLI_findindex(&mtweak->gzgroup->gizmos, mtweak->gz_modal) != -1))
|
||||
{
|
||||
wm_gizmomap_modal_set(mtweak->gzmap, C, mtweak->gz_modal, NULL, false);
|
||||
wm_gizmomap_modal_set(mtweak->gzmap, C, mtweak->gz_modal, nullptr, false);
|
||||
}
|
||||
}
|
||||
MEM_freeN(mtweak);
|
||||
@@ -472,12 +476,12 @@ static void gizmo_tweak_finish(bContext *C, wmOperator *op, const bool cancel, b
|
||||
|
||||
static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
GizmoTweakData *mtweak = op->customdata;
|
||||
GizmoTweakData *mtweak = static_cast<GizmoTweakData *>(op->customdata);
|
||||
wmGizmo *gz = mtweak->gz_modal;
|
||||
int retval = OPERATOR_PASS_THROUGH;
|
||||
bool clear_modal = true;
|
||||
|
||||
if (gz == NULL) {
|
||||
if (gz == nullptr) {
|
||||
BLI_assert_unreachable();
|
||||
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
|
||||
}
|
||||
@@ -532,7 +536,7 @@ static int gizmo_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
evil_event->val = evil_event->prev_val;
|
||||
}
|
||||
|
||||
int modal_retval = modal_fn(C, gz, event, mtweak->flag);
|
||||
int modal_retval = modal_fn(C, gz, event, eWM_GizmoFlagTweak(mtweak->flag));
|
||||
|
||||
if (event_modal_val != 0) {
|
||||
evil_event->type = EVT_MODAL_MAP;
|
||||
@@ -577,7 +581,7 @@ static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
if (gizmo_tweak_start_and_finish(C, gzmap, gz, event, NULL)) {
|
||||
if (gizmo_tweak_start_and_finish(C, gzmap, gz, event, nullptr)) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -587,7 +591,8 @@ static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
GizmoTweakData *mtweak = MEM_mallocN(sizeof(GizmoTweakData), __func__);
|
||||
GizmoTweakData *mtweak = static_cast<GizmoTweakData *>(
|
||||
MEM_mallocN(sizeof(GizmoTweakData), __func__));
|
||||
|
||||
mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
mtweak->gz_modal = gzmap->gzmap_context.highlight;
|
||||
@@ -614,8 +619,8 @@ void GIZMOGROUP_OT_gizmo_tweak(wmOperatorType *ot)
|
||||
ot->modal = gizmo_tweak_modal;
|
||||
ot->poll = ED_operator_region_gizmo_active;
|
||||
|
||||
/* TODO(@ideasman42): This causes problems tweaking settings for operators,
|
||||
* need to find a way to support this. */
|
||||
/* TODO(@ideasman42): This causes problems tweaking settings for operators,
|
||||
* need to find a way to support this. */
|
||||
#if 0
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
#endif
|
||||
@@ -633,7 +638,7 @@ wmKeyMap *wm_gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf)
|
||||
{TWEAK_MODAL_PRECISION_OFF, "PRECISION_OFF", 0, "Disable Precision", ""},
|
||||
{TWEAK_MODAL_SNAP_ON, "SNAP_ON", 0, "Enable Snap", ""},
|
||||
{TWEAK_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Disable Snap", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
STRNCPY(name, "Generic Gizmo Tweak Modal Map");
|
||||
@@ -641,111 +646,108 @@ wmKeyMap *wm_gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf)
|
||||
|
||||
/* This function is called for each space-type, only needs to add map once. */
|
||||
if (keymap && keymap->modal_items) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
keymap = WM_modalkeymap_ensure(keyconf, name, modal_items);
|
||||
|
||||
/* items for modal map */
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_ESCKEY,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_CANCEL);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = RIGHTMOUSE,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_CANCEL);
|
||||
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_RETKEY,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_CONFIRM);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_PADENTER,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_CONFIRM);
|
||||
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_RIGHTSHIFTKEY,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_PRECISION_ON);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_RIGHTSHIFTKEY,
|
||||
.value = KM_RELEASE,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_PRECISION_OFF);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_LEFTSHIFTKEY,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_PRECISION_ON);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_LEFTSHIFTKEY,
|
||||
.value = KM_RELEASE,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_PRECISION_OFF);
|
||||
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_RIGHTCTRLKEY,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_SNAP_ON);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_RIGHTCTRLKEY,
|
||||
.value = KM_RELEASE,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_SNAP_OFF);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_LEFTCTRLKEY,
|
||||
.value = KM_PRESS,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_SNAP_ON);
|
||||
WM_modalkeymap_add_item(keymap,
|
||||
&(const KeyMapItem_Params){
|
||||
.type = EVT_LEFTCTRLKEY,
|
||||
.value = KM_RELEASE,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
},
|
||||
TWEAK_MODAL_SNAP_OFF);
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_ESCKEY;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_CANCEL);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = RIGHTMOUSE;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_CANCEL);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_RETKEY;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_CONFIRM);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_PADENTER;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_CONFIRM);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_RIGHTSHIFTKEY;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_PRECISION_ON);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_RIGHTSHIFTKEY;
|
||||
params.value = KM_RELEASE;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_PRECISION_OFF);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_LEFTSHIFTKEY;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_PRECISION_ON);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_LEFTSHIFTKEY;
|
||||
params.value = KM_RELEASE;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_PRECISION_OFF);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_RIGHTCTRLKEY;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_SNAP_ON);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_RIGHTCTRLKEY;
|
||||
params.value = KM_RELEASE;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_SNAP_OFF);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_LEFTCTRLKEY;
|
||||
params.value = KM_PRESS;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_SNAP_ON);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = EVT_LEFTCTRLKEY;
|
||||
params.value = KM_RELEASE;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_modalkeymap_add_item(keymap, ¶ms, TWEAK_MODAL_SNAP_OFF);
|
||||
}
|
||||
|
||||
WM_modalkeymap_assign(keymap, "GIZMOGROUP_OT_gizmo_tweak");
|
||||
|
||||
@@ -758,18 +760,18 @@ wmKeyMap *wm_gizmogroup_tweak_modal_keymap(wmKeyConfig *keyconf)
|
||||
/** \name wmGizmoGroup (Key-map callbacks)
|
||||
* \{ */
|
||||
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic(const wmGizmoGroupType *UNUSED(gzgt), wmKeyConfig *kc)
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic(const wmGizmoGroupType * /*gzgt*/, wmKeyConfig *kc)
|
||||
{
|
||||
return WM_gizmo_keymap_generic_with_keyconfig(kc);
|
||||
}
|
||||
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic_drag(const wmGizmoGroupType *UNUSED(gzgt),
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic_drag(const wmGizmoGroupType * /*gzgt*/,
|
||||
wmKeyConfig *kc)
|
||||
{
|
||||
return WM_gizmo_keymap_generic_drag_with_keyconfig(kc);
|
||||
}
|
||||
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic_maybe_drag(const wmGizmoGroupType *UNUSED(gzgt),
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic_maybe_drag(const wmGizmoGroupType * /*gzgt*/,
|
||||
wmKeyConfig *kc)
|
||||
{
|
||||
return WM_gizmo_keymap_generic_maybe_drag_with_keyconfig(kc);
|
||||
@@ -791,7 +793,7 @@ static wmKeyMap *WM_gizmogroup_keymap_template_select_ex(
|
||||
wmKeyMap *km = WM_keymap_ensure(kc, name, params->spaceid, params->regionid);
|
||||
const bool do_init = BLI_listbase_is_empty(&km->items);
|
||||
|
||||
/* FIXME(@ideasman42): Currently hard coded. */
|
||||
/* FIXME(@ideasman42): Currently hard coded. */
|
||||
#if 0
|
||||
const int select_mouse = (U.flag & USER_LMOUSESELECT) ? LEFTMOUSE : RIGHTMOUSE;
|
||||
const int select_tweak = (U.flag & USER_LMOUSESELECT) ? EVT_TWEAK_L : EVT_TWEAK_R;
|
||||
@@ -803,59 +805,58 @@ static wmKeyMap *WM_gizmogroup_keymap_template_select_ex(
|
||||
#endif
|
||||
|
||||
if (do_init) {
|
||||
WM_keymap_add_item(km,
|
||||
"GIZMOGROUP_OT_gizmo_tweak",
|
||||
&(const KeyMapItem_Params){
|
||||
.type = action_mouse,
|
||||
.value = action_mouse_val,
|
||||
.modifier = KM_ANY,
|
||||
.direction = KM_ANY,
|
||||
});
|
||||
WM_keymap_add_item(km,
|
||||
"GIZMOGROUP_OT_gizmo_tweak",
|
||||
&(const KeyMapItem_Params){
|
||||
.type = select_tweak,
|
||||
.value = select_tweak_val,
|
||||
.modifier = 0,
|
||||
.direction = KM_ANY,
|
||||
});
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = action_mouse;
|
||||
params.value = action_mouse_val;
|
||||
params.modifier = KM_ANY;
|
||||
params.direction = KM_ANY;
|
||||
WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", ¶ms);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = select_tweak;
|
||||
params.value = select_tweak_val;
|
||||
params.modifier = 0;
|
||||
params.direction = KM_ANY;
|
||||
WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_tweak", ¶ms);
|
||||
}
|
||||
}
|
||||
|
||||
if (do_init) {
|
||||
wmKeyMapItem *kmi = WM_keymap_add_item(km,
|
||||
"GIZMOGROUP_OT_gizmo_select",
|
||||
&(const KeyMapItem_Params){
|
||||
.type = select_mouse,
|
||||
.value = select_mouse_val,
|
||||
.modifier = 0,
|
||||
.direction = KM_ANY,
|
||||
});
|
||||
RNA_boolean_set(kmi->ptr, "extend", false);
|
||||
RNA_boolean_set(kmi->ptr, "deselect", false);
|
||||
RNA_boolean_set(kmi->ptr, "toggle", false);
|
||||
kmi = WM_keymap_add_item(km,
|
||||
"GIZMOGROUP_OT_gizmo_select",
|
||||
&(const KeyMapItem_Params){
|
||||
.type = select_mouse,
|
||||
.value = select_mouse_val,
|
||||
.modifier = KM_SHIFT,
|
||||
.direction = KM_ANY,
|
||||
});
|
||||
RNA_boolean_set(kmi->ptr, "extend", false);
|
||||
RNA_boolean_set(kmi->ptr, "deselect", false);
|
||||
RNA_boolean_set(kmi->ptr, "toggle", true);
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = select_mouse;
|
||||
params.value = select_mouse_val;
|
||||
params.modifier = 0;
|
||||
params.direction = KM_ANY;
|
||||
wmKeyMapItem *kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", ¶ms);
|
||||
RNA_boolean_set(kmi->ptr, "extend", false);
|
||||
RNA_boolean_set(kmi->ptr, "deselect", false);
|
||||
RNA_boolean_set(kmi->ptr, "toggle", false);
|
||||
}
|
||||
{
|
||||
KeyMapItem_Params params{};
|
||||
params.type = select_mouse;
|
||||
params.value = select_mouse_val;
|
||||
params.modifier = KM_SHIFT;
|
||||
params.direction = KM_ANY;
|
||||
wmKeyMapItem *kmi = WM_keymap_add_item(km, "GIZMOGROUP_OT_gizmo_select", ¶ms);
|
||||
RNA_boolean_set(kmi->ptr, "extend", false);
|
||||
RNA_boolean_set(kmi->ptr, "deselect", false);
|
||||
RNA_boolean_set(kmi->ptr, "toggle", true);
|
||||
}
|
||||
}
|
||||
|
||||
return km;
|
||||
}
|
||||
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic_select(const wmGizmoGroupType *UNUSED(gzgt),
|
||||
wmKeyMap *WM_gizmogroup_setup_keymap_generic_select(const wmGizmoGroupType * /*gzgt*/,
|
||||
wmKeyConfig *kc)
|
||||
{
|
||||
struct wmGizmoMapType_Params params = {
|
||||
.spaceid = SPACE_EMPTY,
|
||||
.regionid = RGN_TYPE_WINDOW,
|
||||
};
|
||||
wmGizmoMapType_Params params{};
|
||||
params.spaceid = SPACE_EMPTY;
|
||||
params.regionid = RGN_TYPE_WINDOW;
|
||||
return WM_gizmogroup_keymap_template_select_ex(kc, "Generic Gizmo Select", ¶ms);
|
||||
}
|
||||
|
||||
@@ -932,7 +933,7 @@ wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr(wmGizmoMapType *gzmap_type,
|
||||
return gzgt_ref;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(wmGizmoMapType *gzmap_type, const char *idname)
|
||||
@@ -943,20 +944,21 @@ wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(wmGizmoMapType *gzmap_type, cons
|
||||
return gzgt_ref;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link(wmGizmoMapType *gzmap_type, const char *idname)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
|
||||
BLI_assert(gzgt != NULL);
|
||||
BLI_assert(gzgt != nullptr);
|
||||
return WM_gizmomaptype_group_link_ptr(gzmap_type, gzgt);
|
||||
}
|
||||
|
||||
wmGizmoGroupTypeRef *WM_gizmomaptype_group_link_ptr(wmGizmoMapType *gzmap_type,
|
||||
wmGizmoGroupType *gzgt)
|
||||
{
|
||||
wmGizmoGroupTypeRef *gzgt_ref = MEM_callocN(sizeof(wmGizmoGroupTypeRef), "gizmo-group-ref");
|
||||
wmGizmoGroupTypeRef *gzgt_ref = static_cast<wmGizmoGroupTypeRef *>(
|
||||
MEM_callocN(sizeof(wmGizmoGroupTypeRef), "gizmo-group-ref"));
|
||||
gzgt_ref->type = gzgt;
|
||||
BLI_addtail(&gzmap_type->grouptype_refs, gzgt_ref);
|
||||
return gzgt_ref;
|
||||
@@ -978,7 +980,9 @@ void WM_gizmomaptype_group_init_runtime(const Main *bmain,
|
||||
}
|
||||
|
||||
/* now create a gizmo for all existing areas */
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
|
||||
@@ -1012,7 +1016,7 @@ wmGizmoGroup *WM_gizmomaptype_group_init_runtime_with_region(wmGizmoMapType *gzm
|
||||
}
|
||||
}
|
||||
|
||||
wm_gizmomap_highlight_set(gzmap, NULL, NULL, 0);
|
||||
wm_gizmomap_highlight_set(gzmap, nullptr, nullptr, 0);
|
||||
|
||||
ED_region_tag_redraw_editor_overlays(region);
|
||||
|
||||
@@ -1030,7 +1034,9 @@ void WM_gizmomaptype_group_unlink(bContext *C,
|
||||
const wmGizmoGroupType *gzgt)
|
||||
{
|
||||
/* Free instances. */
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
|
||||
@@ -1038,7 +1044,8 @@ void WM_gizmomaptype_group_unlink(bContext *C,
|
||||
wmGizmoMap *gzmap = region->gizmo_map;
|
||||
if (gzmap && gzmap->type == gzmap_type) {
|
||||
wmGizmoGroup *gzgroup, *gzgroup_next;
|
||||
for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup_next) {
|
||||
for (gzgroup = static_cast<wmGizmoGroup *>(gzmap->groups.first); gzgroup;
|
||||
gzgroup = gzgroup_next) {
|
||||
gzgroup_next = gzgroup->next;
|
||||
if (gzgroup->type == gzgt) {
|
||||
BLI_assert(gzgroup->parent_gzmap == gzmap);
|
||||
@@ -1059,19 +1066,19 @@ void WM_gizmomaptype_group_unlink(bContext *C,
|
||||
WM_gizmomaptype_group_free(gzgt_ref);
|
||||
}
|
||||
|
||||
/* TODO(@ideasman42): Gizmos may share key-maps, for now don't
|
||||
* remove however we could flag them as temporary/owned by the gizmo. */
|
||||
/* TODO(@ideasman42): Gizmos may share key-maps, for now don't
|
||||
* remove however we could flag them as temporary/owned by the gizmo. */
|
||||
#if 0
|
||||
/* NOTE: we may want to keep this key-map for editing. */
|
||||
WM_keymap_remove(gzgt->keyconf, gzgt->keymap);
|
||||
#endif
|
||||
|
||||
BLI_assert(WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt) == NULL);
|
||||
BLI_assert(WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt) == nullptr);
|
||||
}
|
||||
|
||||
void wm_gizmogrouptype_setup_keymap(wmGizmoGroupType *gzgt, wmKeyConfig *keyconf)
|
||||
{
|
||||
/* Use flag since setup_keymap may return NULL,
|
||||
/* Use flag since setup_keymap may return nullptr,
|
||||
* in that case we better not keep calling it. */
|
||||
if (gzgt->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) {
|
||||
gzgt->keymap = gzgt->setup_keymap(gzgt, keyconf);
|
||||
@@ -1110,14 +1117,14 @@ void WM_gizmo_group_type_add_ptr(wmGizmoGroupType *gzgt)
|
||||
void WM_gizmo_group_type_add(const char *idname)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
|
||||
BLI_assert(gzgt != NULL);
|
||||
BLI_assert(gzgt != nullptr);
|
||||
WM_gizmo_group_type_add_ptr(gzgt);
|
||||
}
|
||||
|
||||
bool WM_gizmo_group_type_ensure_ptr_ex(wmGizmoGroupType *gzgt, wmGizmoMapType *gzmap_type)
|
||||
{
|
||||
wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt);
|
||||
if (gzgt_ref == NULL) {
|
||||
if (gzgt_ref == nullptr) {
|
||||
WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
|
||||
return true;
|
||||
}
|
||||
@@ -1131,7 +1138,7 @@ bool WM_gizmo_group_type_ensure_ptr(wmGizmoGroupType *gzgt)
|
||||
bool WM_gizmo_group_type_ensure(const char *idname)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
|
||||
BLI_assert(gzgt != NULL);
|
||||
BLI_assert(gzgt != nullptr);
|
||||
return WM_gizmo_group_type_ensure_ptr(gzgt);
|
||||
}
|
||||
|
||||
@@ -1139,7 +1146,7 @@ void WM_gizmo_group_type_remove_ptr_ex(Main *bmain,
|
||||
wmGizmoGroupType *gzgt,
|
||||
wmGizmoMapType *gzmap_type)
|
||||
{
|
||||
WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt);
|
||||
WM_gizmomaptype_group_unlink(nullptr, bmain, gzmap_type, gzgt);
|
||||
}
|
||||
void WM_gizmo_group_type_remove_ptr(Main *bmain, wmGizmoGroupType *gzgt)
|
||||
{
|
||||
@@ -1149,7 +1156,7 @@ void WM_gizmo_group_type_remove_ptr(Main *bmain, wmGizmoGroupType *gzgt)
|
||||
void WM_gizmo_group_type_remove(Main *bmain, const char *idname)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
|
||||
BLI_assert(gzgt != NULL);
|
||||
BLI_assert(gzgt != nullptr);
|
||||
WM_gizmo_group_type_remove_ptr(bmain, gzgt);
|
||||
}
|
||||
|
||||
@@ -1158,9 +1165,9 @@ void WM_gizmo_group_type_reinit_ptr_ex(Main *bmain,
|
||||
wmGizmoMapType *gzmap_type)
|
||||
{
|
||||
wmGizmoGroupTypeRef *gzgt_ref = WM_gizmomaptype_group_find_ptr(gzmap_type, gzgt);
|
||||
BLI_assert(gzgt_ref != NULL);
|
||||
BLI_assert(gzgt_ref != nullptr);
|
||||
UNUSED_VARS_NDEBUG(gzgt_ref);
|
||||
WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt);
|
||||
WM_gizmomaptype_group_unlink(nullptr, bmain, gzmap_type, gzgt);
|
||||
WM_gizmo_group_type_add_ptr_ex(gzgt, gzmap_type);
|
||||
}
|
||||
void WM_gizmo_group_type_reinit_ptr(Main *bmain, wmGizmoGroupType *gzgt)
|
||||
@@ -1171,7 +1178,7 @@ void WM_gizmo_group_type_reinit_ptr(Main *bmain, wmGizmoGroupType *gzgt)
|
||||
void WM_gizmo_group_type_reinit(Main *bmain, const char *idname)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
|
||||
BLI_assert(gzgt != NULL);
|
||||
BLI_assert(gzgt != nullptr);
|
||||
WM_gizmo_group_type_reinit_ptr(bmain, gzgt);
|
||||
}
|
||||
|
||||
@@ -1191,7 +1198,7 @@ void WM_gizmo_group_type_unlink_delayed_ptr(wmGizmoGroupType *gzgt)
|
||||
void WM_gizmo_group_type_unlink_delayed(const char *idname)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
|
||||
BLI_assert(gzgt != NULL);
|
||||
BLI_assert(gzgt != nullptr);
|
||||
WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
|
||||
}
|
||||
|
||||
@@ -1236,7 +1243,7 @@ void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
const wmGizmoGroupType *gzgt = gzgroup->type;
|
||||
if (gzgt->flag & WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK) {
|
||||
wmGizmoMap *gzmap = gzgroup->parent_gzmap;
|
||||
wmGizmo *gz = NULL;
|
||||
wmGizmo *gz = nullptr;
|
||||
/* Without the check for refresh, any highlighted gizmo will prevent hiding
|
||||
* when selecting with RMB when the cursor happens to be over a gizmo. */
|
||||
if ((gzgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0) {
|
||||
@@ -1247,7 +1254,7 @@ void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
BLI_assert(region->gizmo_map == gzmap);
|
||||
/* Check if the tweak event originated from this region. */
|
||||
if ((win->eventstate != NULL) && (win->event_queue_check_drag) &&
|
||||
if ((win->eventstate != nullptr) && (win->event_queue_check_drag) &&
|
||||
BLI_rcti_isect_pt_v(®ion->winrct, win->eventstate->prev_press_xy))
|
||||
{
|
||||
/* We need to run refresh again. */
|
||||
@@ -35,14 +35,14 @@
|
||||
* \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
|
||||
* \{ */
|
||||
|
||||
static GHash *global_gizmogrouptype_hash = NULL;
|
||||
static GHash *global_gizmogrouptype_hash = nullptr;
|
||||
|
||||
wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet)
|
||||
{
|
||||
if (idname[0]) {
|
||||
wmGizmoGroupType *gzgt;
|
||||
|
||||
gzgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname);
|
||||
gzgt = static_cast<wmGizmoGroupType *>(BLI_ghash_lookup(global_gizmogrouptype_hash, idname));
|
||||
if (gzgt) {
|
||||
return gzgt;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ wmGizmoGroupType *WM_gizmogrouptype_find(const char *idname, bool quiet)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_gizmogrouptype_iter(GHashIterator *ghi)
|
||||
@@ -67,7 +67,8 @@ void WM_gizmogrouptype_iter(GHashIterator *ghi)
|
||||
|
||||
static wmGizmoGroupType *wm_gizmogrouptype_append__begin(void)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype");
|
||||
wmGizmoGroupType *gzgt = static_cast<wmGizmoGroupType *>(
|
||||
MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype"));
|
||||
gzgt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoGroupProperties);
|
||||
#if 0
|
||||
/* Set the default i18n context now, so that opfunc can redefine it if needed! */
|
||||
@@ -78,15 +79,15 @@ static wmGizmoGroupType *wm_gizmogrouptype_append__begin(void)
|
||||
}
|
||||
static void wm_gizmogrouptype_append__end(wmGizmoGroupType *gzgt)
|
||||
{
|
||||
BLI_assert(gzgt->name != NULL);
|
||||
BLI_assert(gzgt->idname != NULL);
|
||||
BLI_assert(gzgt->name != nullptr);
|
||||
BLI_assert(gzgt->idname != nullptr);
|
||||
|
||||
RNA_def_struct_identifier(&BLENDER_RNA, gzgt->srna, gzgt->idname);
|
||||
|
||||
gzgt->type_update_flag |= WM_GIZMOMAPTYPE_KEYMAP_INIT;
|
||||
|
||||
/* if not set, use default */
|
||||
if (gzgt->setup_keymap == NULL) {
|
||||
if (gzgt->setup_keymap == nullptr) {
|
||||
if (gzgt->flag & WM_GIZMOGROUPTYPE_SELECT) {
|
||||
gzgt->setup_keymap = WM_gizmogroup_setup_keymap_generic_select;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt)
|
||||
{
|
||||
BLI_assert(gzgt == WM_gizmogrouptype_find(gzgt->idname, false));
|
||||
|
||||
BLI_ghash_remove(global_gizmogrouptype_hash, gzgt->idname, NULL, NULL);
|
||||
BLI_ghash_remove(global_gizmogrouptype_hash, gzgt->idname, nullptr, nullptr);
|
||||
|
||||
gizmogrouptype_free(gzgt);
|
||||
|
||||
@@ -152,9 +153,10 @@ void WM_gizmo_group_type_free_ptr(wmGizmoGroupType *gzgt)
|
||||
|
||||
bool WM_gizmo_group_type_free(const char *idname)
|
||||
{
|
||||
wmGizmoGroupType *gzgt = BLI_ghash_lookup(global_gizmogrouptype_hash, idname);
|
||||
wmGizmoGroupType *gzgt = static_cast<wmGizmoGroupType *>(
|
||||
BLI_ghash_lookup(global_gizmogrouptype_hash, idname));
|
||||
|
||||
if (gzgt == NULL) {
|
||||
if (gzgt == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -171,8 +173,8 @@ static void wm_gizmogrouptype_ghash_free_cb(wmGizmoGroupType *gzgt)
|
||||
void wm_gizmogrouptype_free(void)
|
||||
{
|
||||
BLI_ghash_free(
|
||||
global_gizmogrouptype_hash, NULL, (GHashValFreeFP)wm_gizmogrouptype_ghash_free_cb);
|
||||
global_gizmogrouptype_hash = NULL;
|
||||
global_gizmogrouptype_hash, nullptr, (GHashValFreeFP)wm_gizmogrouptype_ghash_free_cb);
|
||||
global_gizmogrouptype_hash = nullptr;
|
||||
}
|
||||
|
||||
void wm_gizmogrouptype_init(void)
|
||||
@@ -14,6 +14,10 @@ struct wmKeyConfig;
|
||||
|
||||
#include "wm_gizmo_fn.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* wmGizmo */
|
||||
|
||||
@@ -149,3 +153,7 @@ bool wm_gizmomap_deselect_all(struct wmGizmoMap *gzmap);
|
||||
void wm_gizmomap_select_array_shrink(struct wmGizmoMap *gzmap, int len_subtract);
|
||||
void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz);
|
||||
void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_bits.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
@@ -49,13 +50,13 @@
|
||||
* 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.
|
||||
*/
|
||||
static ListBase gizmomaptypes = {NULL, NULL};
|
||||
static ListBase gizmomaptypes = {nullptr, nullptr};
|
||||
|
||||
/**
|
||||
* Update when gizmo-map types change.
|
||||
*/
|
||||
/* so operator removal can trigger update */
|
||||
typedef enum eWM_GizmoFlagGroupTypeGlobalFlag {
|
||||
enum eWM_GizmoFlagGroupTypeGlobalFlag {
|
||||
/** Initialize by #wmGroupType.type_update_flag. */
|
||||
WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT = (1 << 0),
|
||||
/** Remove by #wmGroupType.type_update_flag. */
|
||||
@@ -63,9 +64,11 @@ typedef enum eWM_GizmoFlagGroupTypeGlobalFlag {
|
||||
|
||||
/** Remove by #wmGroup.tag_remove. */
|
||||
WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE = (1 << 2),
|
||||
} eWM_GizmoFlagGroupTypeGlobalFlag;
|
||||
};
|
||||
ENUM_OPERATORS(eWM_GizmoFlagGroupTypeGlobalFlag, WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE)
|
||||
|
||||
static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag = 0;
|
||||
static eWM_GizmoFlagGroupTypeGlobalFlag wm_gzmap_type_update_flag =
|
||||
eWM_GizmoFlagGroupTypeGlobalFlag(0);
|
||||
|
||||
/**
|
||||
* Gizmo-map update tagging.
|
||||
@@ -89,7 +92,7 @@ static void wm_gizmomap_select_array_ensure_len_alloc(wmGizmoMap *gzmap, int len
|
||||
if (len <= msel->len_alloc) {
|
||||
return;
|
||||
}
|
||||
msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * len);
|
||||
msel->items = static_cast<wmGizmo **>(MEM_reallocN(msel->items, sizeof(*msel->items) * len));
|
||||
msel->len_alloc = len;
|
||||
}
|
||||
|
||||
@@ -110,7 +113,8 @@ void wm_gizmomap_select_array_shrink(wmGizmoMap *gzmap, int len_subtract)
|
||||
}
|
||||
else {
|
||||
if (msel->len < msel->len_alloc / 2) {
|
||||
msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len);
|
||||
msel->items = static_cast<wmGizmo **>(
|
||||
MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len));
|
||||
msel->len_alloc = msel->len;
|
||||
}
|
||||
}
|
||||
@@ -122,7 +126,8 @@ void wm_gizmomap_select_array_push_back(wmGizmoMap *gzmap, wmGizmo *gz)
|
||||
BLI_assert(msel->len <= msel->len_alloc);
|
||||
if (msel->len == msel->len_alloc) {
|
||||
msel->len_alloc = (msel->len + 1) * 2;
|
||||
msel->items = MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc);
|
||||
msel->items = static_cast<wmGizmo **>(
|
||||
MEM_reallocN(msel->items, sizeof(*msel->items) * msel->len_alloc));
|
||||
}
|
||||
msel->items[msel->len++] = gz;
|
||||
}
|
||||
@@ -166,7 +171,7 @@ static wmGizmoMap *wm_gizmomap_new_from_type_ex(wmGizmoMapType *gzmap_type, wmGi
|
||||
wmGizmoMap *WM_gizmomap_new_from_type(const struct wmGizmoMapType_Params *gzmap_params)
|
||||
{
|
||||
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(gzmap_params);
|
||||
wmGizmoMap *gzmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap");
|
||||
wmGizmoMap *gzmap = static_cast<wmGizmoMap *>(MEM_callocN(sizeof(wmGizmoMap), "GizmoMap"));
|
||||
wm_gizmomap_new_from_type_ex(gzmap_type, gzmap);
|
||||
return gzmap;
|
||||
}
|
||||
@@ -176,11 +181,13 @@ static void wm_gizmomap_free_data(wmGizmoMap *gzmap)
|
||||
/* Clear first so further calls don't waste time trying to maintain correct array state. */
|
||||
wm_gizmomap_select_array_clear(gzmap);
|
||||
|
||||
for (wmGizmoGroup *gzgroup = gzmap->groups.first, *gzgroup_next; gzgroup; gzgroup = gzgroup_next)
|
||||
for (wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(gzmap->groups.first), *gzgroup_next;
|
||||
gzgroup;
|
||||
gzgroup = gzgroup_next)
|
||||
{
|
||||
gzgroup_next = gzgroup->next;
|
||||
BLI_assert(gzgroup->parent_gzmap == gzmap);
|
||||
wm_gizmogroup_free(NULL, gzgroup);
|
||||
wm_gizmogroup_free(nullptr, gzgroup);
|
||||
}
|
||||
BLI_assert(BLI_listbase_is_empty(&gzmap->groups));
|
||||
}
|
||||
@@ -205,7 +212,7 @@ wmGizmoGroup *WM_gizmomap_group_find(wmGizmoMap *gzmap, const char *idname)
|
||||
if (gzgt) {
|
||||
return WM_gizmomap_group_find_ptr(gzmap, gzgt);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmGizmoGroup *WM_gizmomap_group_find_ptr(wmGizmoMap *gzmap, const wmGizmoGroupType *gzgt)
|
||||
@@ -215,7 +222,7 @@ wmGizmoGroup *WM_gizmomap_group_find_ptr(wmGizmoMap *gzmap, const wmGizmoGroupTy
|
||||
return gzgroup;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ListBase *WM_gizmomap_group_list(wmGizmoMap *gzmap)
|
||||
@@ -233,11 +240,8 @@ wmGizmo *WM_gizmomap_get_modal(const wmGizmoMap *gzmap)
|
||||
return gzmap->gzmap_context.modal;
|
||||
}
|
||||
|
||||
bool WM_gizmomap_minmax(const wmGizmoMap *gzmap,
|
||||
bool UNUSED(use_hidden),
|
||||
bool use_select,
|
||||
float r_min[3],
|
||||
float r_max[3])
|
||||
bool WM_gizmomap_minmax(
|
||||
const wmGizmoMap *gzmap, bool /*use_hidden*/, bool use_select, float r_min[3], float r_max[3])
|
||||
{
|
||||
if (use_select) {
|
||||
int i;
|
||||
@@ -425,7 +429,7 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap,
|
||||
static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBase *draw_gizmos)
|
||||
{
|
||||
/* Can be empty if we're dynamically added and removed. */
|
||||
if ((gzmap == NULL) || BLI_listbase_is_empty(&gzmap->groups)) {
|
||||
if ((gzmap == nullptr) || BLI_listbase_is_empty(&gzmap->groups)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -436,8 +440,10 @@ static void gizmos_draw_list(const wmGizmoMap *gzmap, const bContext *C, ListBas
|
||||
bool is_depth_prev = false;
|
||||
|
||||
/* draw_gizmos contains all visible gizmos - draw them */
|
||||
for (LinkData *link = draw_gizmos->first, *link_next; link; link = link_next) {
|
||||
wmGizmo *gz = link->data;
|
||||
for (LinkData *link = static_cast<LinkData *>(draw_gizmos->first), *link_next; link;
|
||||
link = link_next)
|
||||
{
|
||||
wmGizmo *gz = static_cast<wmGizmo *>(link->data);
|
||||
link_next = link->next;
|
||||
|
||||
bool is_depth = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_DEPTH_3D) != 0;
|
||||
@@ -487,7 +493,7 @@ void WM_gizmomap_draw(wmGizmoMap *gzmap,
|
||||
return;
|
||||
}
|
||||
|
||||
ListBase draw_gizmos = {NULL};
|
||||
ListBase draw_gizmos = {nullptr};
|
||||
|
||||
gizmomap_prepare_drawing(gzmap, C, &draw_gizmos, drawstep);
|
||||
gizmos_draw_list(gzmap, C, &draw_gizmos);
|
||||
@@ -507,7 +513,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C,
|
||||
|
||||
for (int select_id = 0; select_id < visible_gizmos_len; select_id++) {
|
||||
wmGizmo *gz = visible_gizmos[select_id];
|
||||
if (gz->type->draw_select == NULL) {
|
||||
if (gz->type->draw_select == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -559,7 +565,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
|
||||
const wmWindowManager *wm = CTX_wm_manager(C);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
View3D *v3d = area->spacedata.first;
|
||||
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
rcti rect;
|
||||
/* Almost certainly overkill, but allow for many custom gizmos. */
|
||||
@@ -569,7 +575,7 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
|
||||
BLI_rcti_init_pt_radius(&rect, co, hotspot);
|
||||
|
||||
ED_view3d_draw_setup_view(
|
||||
wm, CTX_wm_window(C), depsgraph, CTX_data_scene(C), region, v3d, NULL, NULL, &rect);
|
||||
wm, CTX_wm_window(C), depsgraph, CTX_data_scene(C), region, v3d, nullptr, nullptr, &rect);
|
||||
|
||||
bool use_select_bias = false;
|
||||
|
||||
@@ -589,14 +595,14 @@ static int gizmo_find_intersected_3d_intern(wmGizmo **visible_gizmos,
|
||||
}
|
||||
|
||||
ED_view3d_draw_setup_view(
|
||||
wm, CTX_wm_window(C), depsgraph, CTX_data_scene(C), region, v3d, NULL, NULL, NULL);
|
||||
wm, CTX_wm_window(C), depsgraph, CTX_data_scene(C), region, v3d, nullptr, nullptr, nullptr);
|
||||
|
||||
if (use_select_bias && (hits > 1)) {
|
||||
float co_direction[3];
|
||||
float co_screen[3] = {co[0], co[1], 0.0f};
|
||||
ED_view3d_win_to_vector(region, (float[2]){UNPACK2(co)}, co_direction);
|
||||
float co_screen[3] = {float(co[0]), float(co[1]), 0.0f};
|
||||
ED_view3d_win_to_vector(region, blender::float2{float(co[0]), float(co[1])}, co_direction);
|
||||
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||
const int viewport[4] = {0, 0, region->winx, region->winy};
|
||||
float co_3d_origin[3];
|
||||
|
||||
@@ -639,7 +645,7 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C,
|
||||
const int visible_gizmos_len,
|
||||
int *r_part)
|
||||
{
|
||||
wmGizmo *result = NULL;
|
||||
wmGizmo *result = nullptr;
|
||||
int visible_gizmos_len_trim = visible_gizmos_len;
|
||||
int hit = -1;
|
||||
|
||||
@@ -654,7 +660,7 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C,
|
||||
for (int select_id = 0; select_id < visible_gizmos_len; select_id++) {
|
||||
wmGizmo *gz = visible_gizmos[select_id];
|
||||
/* With both defined, favor the 3D, in case the gizmo can be used in 2D or 3D views. */
|
||||
if (gz->type->test_select && (gz->type->draw_select == NULL)) {
|
||||
if (gz->type->test_select && (gz->type->draw_select == nullptr)) {
|
||||
if ((*r_part = gz->type->test_select(C, gz, co)) != -1) {
|
||||
hit = select_id;
|
||||
result = gz;
|
||||
@@ -663,7 +669,7 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C,
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (gz->type->draw_select != NULL) {
|
||||
else if (gz->type->draw_select != nullptr) {
|
||||
has_3d = true;
|
||||
}
|
||||
}
|
||||
@@ -677,13 +683,13 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C,
|
||||
GPUViewport *viewport = WM_draw_region_get_viewport(CTX_wm_region(C));
|
||||
|
||||
/* When switching between modes and the mouse pointer is over a gizmo, the highlight test is
|
||||
* performed before the viewport is fully initialized (region->draw_buffer = NULL).
|
||||
* performed before the viewport is fully initialized (region->draw_buffer = nullptr).
|
||||
* When this is the case we should not use depth testing. */
|
||||
if (viewport == NULL) {
|
||||
return NULL;
|
||||
if (viewport == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport);
|
||||
GPUFrameBuffer *depth_read_fb = NULL;
|
||||
GPUFrameBuffer *depth_read_fb = nullptr;
|
||||
GPU_framebuffer_ensure_config(&depth_read_fb,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(depth_tx),
|
||||
@@ -692,9 +698,9 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C,
|
||||
GPU_framebuffer_bind(depth_read_fb);
|
||||
|
||||
const int hotspot_radii[] = {
|
||||
3 * U.pixelsize,
|
||||
int(3 * U.pixelsize),
|
||||
/* This runs on mouse move, careful doing too many tests! */
|
||||
10 * U.pixelsize,
|
||||
int(10 * U.pixelsize),
|
||||
};
|
||||
for (int i = 0; i < ARRAY_SIZE(hotspot_radii); i++) {
|
||||
hit = gizmo_find_intersected_3d_intern(
|
||||
@@ -725,7 +731,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
|
||||
int *r_part)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmGizmo *gz = NULL;
|
||||
wmGizmo *gz = nullptr;
|
||||
BLI_buffer_declare_static(wmGizmo *, visible_3d_gizmos, BLI_BUFFER_NOP, 128);
|
||||
bool do_step[WM_GIZMOMAP_DRAWSTEP_MAX];
|
||||
|
||||
@@ -738,7 +744,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
|
||||
}
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(do_step); i++) {
|
||||
do_step[i] = WM_gizmo_context_check_drawstep(C, i);
|
||||
do_step[i] = WM_gizmo_context_check_drawstep(C, eWM_GizmoFlagMapDrawStep(i));
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
|
||||
@@ -773,9 +779,12 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
|
||||
|
||||
if (visible_3d_gizmos.count) {
|
||||
/* 2D gizmos get priority. */
|
||||
if (gz == NULL) {
|
||||
gz = gizmo_find_intersected_3d(
|
||||
C, mval, visible_3d_gizmos.data, visible_3d_gizmos.count, r_part);
|
||||
if (gz == nullptr) {
|
||||
gz = gizmo_find_intersected_3d(C,
|
||||
mval,
|
||||
static_cast<wmGizmo **>(visible_3d_gizmos.data),
|
||||
visible_3d_gizmos.count,
|
||||
r_part);
|
||||
}
|
||||
}
|
||||
BLI_buffer_free(&visible_3d_gizmos);
|
||||
@@ -797,7 +806,8 @@ void WM_gizmomap_add_handlers(ARegion *region, wmGizmoMap *gzmap)
|
||||
}
|
||||
}
|
||||
|
||||
wmEventHandler_Gizmo *handler = MEM_callocN(sizeof(*handler), __func__);
|
||||
wmEventHandler_Gizmo *handler = static_cast<wmEventHandler_Gizmo *>(
|
||||
MEM_callocN(sizeof(*handler), __func__));
|
||||
handler->head.type = WM_HANDLER_TYPE_GIZMO;
|
||||
BLI_assert(gzmap == region->gizmo_map);
|
||||
handler->gizmo_map = gzmap;
|
||||
@@ -806,7 +816,7 @@ void WM_gizmomap_add_handlers(ARegion *region, wmGizmoMap *gzmap)
|
||||
|
||||
void wm_gizmomaps_handled_modal_update(bContext *C, wmEvent *event, wmEventHandler_Op *handler)
|
||||
{
|
||||
const bool modal_running = (handler->op != NULL);
|
||||
const bool modal_running = (handler->op != nullptr);
|
||||
|
||||
/* happens on render or when joining areas */
|
||||
if (!handler->context.region || !handler->context.region->gizmo_map) {
|
||||
@@ -822,11 +832,11 @@ void wm_gizmomaps_handled_modal_update(bContext *C, wmEvent *event, wmEventHandl
|
||||
|
||||
/* regular update for running operator */
|
||||
if (modal_running) {
|
||||
wmGizmoOpElem *gzop = gz ? WM_gizmo_operator_get(gz, gz->highlight_part) : NULL;
|
||||
if (gz && gzop && (gzop->type != NULL) && (gzop->type == handler->op->type)) {
|
||||
wmGizmoOpElem *gzop = gz ? WM_gizmo_operator_get(gz, gz->highlight_part) : nullptr;
|
||||
if (gz && gzop && (gzop->type != nullptr) && (gzop->type == handler->op->type)) {
|
||||
wmGizmoFnModal modal_fn = gz->custom_modal ? gz->custom_modal : gz->type->modal;
|
||||
if (modal_fn != NULL) {
|
||||
int retval = modal_fn(C, gz, event, 0);
|
||||
if (modal_fn != nullptr) {
|
||||
int retval = modal_fn(C, gz, event, eWM_GizmoFlagTweak(0));
|
||||
/* The gizmo is tried to the operator, we can't choose when to exit. */
|
||||
BLI_assert(retval & OPERATOR_RUNNING_MODAL);
|
||||
UNUSED_VARS_NDEBUG(retval);
|
||||
@@ -835,14 +845,14 @@ void wm_gizmomaps_handled_modal_update(bContext *C, wmEvent *event, wmEventHandl
|
||||
}
|
||||
/* operator not running anymore */
|
||||
else {
|
||||
wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
|
||||
wm_gizmomap_highlight_set(gzmap, C, nullptr, 0);
|
||||
if (gz) {
|
||||
/* This isn't defined if it ends because of success of cancel, we may want to change. */
|
||||
bool cancel = true;
|
||||
if (gz->type->exit) {
|
||||
gz->type->exit(C, gz, cancel);
|
||||
}
|
||||
wm_gizmomap_modal_set(gzmap, C, gz, NULL, false);
|
||||
wm_gizmomap_modal_set(gzmap, C, gz, nullptr, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -855,7 +865,7 @@ bool wm_gizmomap_deselect_all(wmGizmoMap *gzmap)
|
||||
{
|
||||
wmGizmoMapSelectState *msel = &gzmap->gzmap_context.select;
|
||||
|
||||
if (msel->items == NULL || msel->len == 0) {
|
||||
if (msel->items == nullptr || msel->len == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -870,7 +880,7 @@ bool wm_gizmomap_deselect_all(wmGizmoMap *gzmap)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gizmo_selectable_poll(const wmGizmo *gz, void *UNUSED(data))
|
||||
static bool gizmo_selectable_poll(const wmGizmo *gz, void * /*data*/)
|
||||
{
|
||||
return (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT);
|
||||
}
|
||||
@@ -887,7 +897,7 @@ static bool wm_gizmomap_select_all_intern(bContext *C, wmGizmoMap *gzmap)
|
||||
* 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, WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT);
|
||||
C, gzmap, gizmo_selectable_poll, nullptr, WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT);
|
||||
GHashIterator gh_iter;
|
||||
int i;
|
||||
bool changed = false;
|
||||
@@ -895,7 +905,7 @@ static bool wm_gizmomap_select_all_intern(bContext *C, wmGizmoMap *gzmap)
|
||||
wm_gizmomap_select_array_ensure_len_alloc(gzmap, BLI_ghash_len(hash));
|
||||
|
||||
GHASH_ITER_INDEX (gh_iter, hash, i) {
|
||||
wmGizmo *gz_iter = BLI_ghashIterator_getValue(&gh_iter);
|
||||
wmGizmo *gz_iter = static_cast<wmGizmo *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||
WM_gizmo_select_set(gzmap, gz_iter, true);
|
||||
}
|
||||
/* highlight first gizmo */
|
||||
@@ -903,7 +913,7 @@ static bool wm_gizmomap_select_all_intern(bContext *C, wmGizmoMap *gzmap)
|
||||
|
||||
BLI_assert(BLI_ghash_len(hash) == msel->len);
|
||||
|
||||
BLI_ghash_free(hash, NULL, NULL);
|
||||
BLI_ghash_free(hash, nullptr, nullptr);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -937,12 +947,12 @@ void wm_gizmomap_handler_context_op(bContext *C, wmEventHandler_Op *handler)
|
||||
if (screen) {
|
||||
ScrArea *area;
|
||||
|
||||
for (area = screen->areabase.first; area; area = area->next) {
|
||||
for (area = static_cast<ScrArea *>(screen->areabase.first); area; area = area->next) {
|
||||
if (area == handler->context.area) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (area == NULL) {
|
||||
if (area == nullptr) {
|
||||
/* when changing screen layouts with running modal handlers (like render display), this
|
||||
* is not an error to print */
|
||||
printf("internal error: modal gizmo-map handler has invalid area\n");
|
||||
@@ -950,7 +960,8 @@ void wm_gizmomap_handler_context_op(bContext *C, wmEventHandler_Op *handler)
|
||||
else {
|
||||
ARegion *region;
|
||||
CTX_wm_area_set(C, area);
|
||||
for (region = area->regionbase.first; region; region = region->next) {
|
||||
for (region = static_cast<ARegion *>(area->regionbase.first); region; region = region->next)
|
||||
{
|
||||
if (region == handler->context.region) {
|
||||
break;
|
||||
}
|
||||
@@ -963,7 +974,7 @@ void wm_gizmomap_handler_context_op(bContext *C, wmEventHandler_Op *handler)
|
||||
}
|
||||
}
|
||||
|
||||
void wm_gizmomap_handler_context_gizmo(bContext *UNUSED(C), wmEventHandler_Gizmo *UNUSED(handler))
|
||||
void wm_gizmomap_handler_context_gizmo(bContext * /*C*/, wmEventHandler_Gizmo * /*handler*/)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
@@ -1037,7 +1048,7 @@ void wm_gizmomap_modal_set(
|
||||
bool do_refresh = false;
|
||||
|
||||
if (enable) {
|
||||
BLI_assert(gzmap->gzmap_context.modal == NULL);
|
||||
BLI_assert(gzmap->gzmap_context.modal == nullptr);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
WM_tooltip_clear(C, win);
|
||||
@@ -1061,7 +1072,7 @@ void wm_gizmomap_modal_set(
|
||||
gzmap->gzmap_context.modal = gz;
|
||||
|
||||
if ((gz->flag & WM_GIZMO_MOVE_CURSOR) && (event->tablet.is_motion_absolute == false)) {
|
||||
WM_cursor_grab_enable(win, WM_CURSOR_WRAP_XY, NULL, true);
|
||||
WM_cursor_grab_enable(win, WM_CURSOR_WRAP_XY, nullptr, true);
|
||||
copy_v2_v2_int(gzmap->gzmap_context.event_xy, event->xy);
|
||||
gzmap->gzmap_context.event_grabcursor = win->grabcursor;
|
||||
}
|
||||
@@ -1084,7 +1095,7 @@ void wm_gizmomap_modal_set(
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLI_assert(ELEM(gzmap->gzmap_context.modal, NULL, gz));
|
||||
BLI_assert(ELEM(gzmap->gzmap_context.modal, nullptr, gz));
|
||||
|
||||
/* deactivate, gizmo but first take care of some stuff */
|
||||
if (gz) {
|
||||
@@ -1092,10 +1103,10 @@ void wm_gizmomap_modal_set(
|
||||
MEM_SAFE_FREE(gz->interaction_data);
|
||||
}
|
||||
|
||||
if (gzmap->gzmap_context.modal != NULL) {
|
||||
if (gzmap->gzmap_context.modal != nullptr) {
|
||||
do_refresh = true;
|
||||
}
|
||||
gzmap->gzmap_context.modal = NULL;
|
||||
gzmap->gzmap_context.modal = nullptr;
|
||||
|
||||
if (C) {
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
@@ -1177,7 +1188,7 @@ void WM_gizmomap_message_subscribe(const bContext *C,
|
||||
}
|
||||
WM_gizmo_target_property_subscribe_all(gz, mbus, region);
|
||||
}
|
||||
if (gzgroup->type->message_subscribe != NULL) {
|
||||
if (gzgroup->type->message_subscribe != nullptr) {
|
||||
gzgroup->type->message_subscribe(C, gzgroup, mbus);
|
||||
}
|
||||
}
|
||||
@@ -1189,11 +1200,8 @@ void WM_gizmomap_message_subscribe(const bContext *C,
|
||||
/** \name Tooltip Handling
|
||||
* \{ */
|
||||
|
||||
ARegion *WM_gizmomap_tooltip_init(bContext *C,
|
||||
ARegion *region,
|
||||
int *UNUSED(r_pass),
|
||||
double *UNUSED(pass_delay),
|
||||
bool *r_exit_on_event)
|
||||
ARegion *WM_gizmomap_tooltip_init(
|
||||
bContext *C, ARegion *region, int * /*r_pass*/, double * /*pass_delay*/, bool *r_exit_on_event)
|
||||
{
|
||||
wmGizmoMap *gzmap = region->gizmo_map;
|
||||
*r_exit_on_event = false;
|
||||
@@ -1208,7 +1216,7 @@ ARegion *WM_gizmomap_tooltip_init(bContext *C,
|
||||
return UI_tooltip_create_from_gizmo(C, gz);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */ /* wmGizmoMapType */
|
||||
@@ -1226,7 +1234,7 @@ wmGizmoMapType *WM_gizmomaptype_find(const struct wmGizmoMapType_Params *gzmap_p
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmGizmoMapType *WM_gizmomaptype_ensure(const struct wmGizmoMapType_Params *gzmap_params)
|
||||
@@ -1237,7 +1245,8 @@ wmGizmoMapType *WM_gizmomaptype_ensure(const struct wmGizmoMapType_Params *gzmap
|
||||
return gzmap_type;
|
||||
}
|
||||
|
||||
gzmap_type = MEM_callocN(sizeof(wmGizmoMapType), "gizmotype list");
|
||||
gzmap_type = static_cast<wmGizmoMapType *>(
|
||||
MEM_callocN(sizeof(wmGizmoMapType), "gizmotype list"));
|
||||
gzmap_type->spaceid = gzmap_params->spaceid;
|
||||
gzmap_type->regionid = gzmap_params->regionid;
|
||||
BLI_addhead(&gizmomaptypes, gzmap_type);
|
||||
@@ -1247,11 +1256,16 @@ wmGizmoMapType *WM_gizmomaptype_ensure(const struct wmGizmoMapType_Params *gzmap
|
||||
|
||||
void wm_gizmomaptypes_free(void)
|
||||
{
|
||||
for (wmGizmoMapType *gzmap_type = gizmomaptypes.first, *gzmap_type_next; gzmap_type;
|
||||
for (wmGizmoMapType *gzmap_type = static_cast<wmGizmoMapType *>(gizmomaptypes.first),
|
||||
*gzmap_type_next;
|
||||
gzmap_type;
|
||||
gzmap_type = gzmap_type_next)
|
||||
{
|
||||
gzmap_type_next = gzmap_type->next;
|
||||
for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_next; gzgt_ref;
|
||||
for (wmGizmoGroupTypeRef *
|
||||
gzgt_ref = static_cast<wmGizmoGroupTypeRef *>(gzmap_type->grouptype_refs.first),
|
||||
*gzgt_next;
|
||||
gzgt_ref;
|
||||
gzgt_ref = gzgt_next)
|
||||
{
|
||||
gzgt_next = gzgt_ref->next;
|
||||
@@ -1318,14 +1332,16 @@ void WM_gizmoconfig_update(Main *bmain)
|
||||
LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) {
|
||||
if (gzmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) {
|
||||
gzmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE;
|
||||
for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_ref_next;
|
||||
for (wmGizmoGroupTypeRef *
|
||||
gzgt_ref = static_cast<wmGizmoGroupTypeRef *>(gzmap_type->grouptype_refs.first),
|
||||
*gzgt_ref_next;
|
||||
gzgt_ref;
|
||||
gzgt_ref = gzgt_ref_next)
|
||||
{
|
||||
gzgt_ref_next = gzgt_ref->next;
|
||||
if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_UPDATE_REMOVE) {
|
||||
gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE;
|
||||
WM_gizmomaptype_group_unlink(NULL, bmain, gzmap_type, gzgt_ref->type);
|
||||
WM_gizmomaptype_group_unlink(nullptr, bmain, gzmap_type, gzgt_ref->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1338,7 +1354,7 @@ void WM_gizmoconfig_update(Main *bmain)
|
||||
LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) {
|
||||
const uchar type_update_all = WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT;
|
||||
if (gzmap_type->type_update_flag & type_update_all) {
|
||||
gzmap_type->type_update_flag &= ~type_update_all;
|
||||
gzmap_type->type_update_flag &= eWM_GizmoFlagMapTypeUpdateFlag(~type_update_all);
|
||||
LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) {
|
||||
if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) {
|
||||
WM_gizmomaptype_group_init_runtime_keymap(bmain, gzgt_ref->type);
|
||||
@@ -1357,21 +1373,26 @@ void WM_gizmoconfig_update(Main *bmain)
|
||||
}
|
||||
|
||||
if (wm_gzmap_type_update_flag & WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE) {
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
|
||||
&sl->regionbase;
|
||||
LISTBASE_FOREACH (ARegion *, region, regionbase) {
|
||||
wmGizmoMap *gzmap = region->gizmo_map;
|
||||
if (gzmap != NULL && gzmap->tag_remove_group) {
|
||||
if (gzmap != nullptr && gzmap->tag_remove_group) {
|
||||
gzmap->tag_remove_group = false;
|
||||
|
||||
for (wmGizmoGroup *gzgroup = gzmap->groups.first, *gzgroup_next; gzgroup;
|
||||
gzgroup = gzgroup_next) {
|
||||
for (wmGizmoGroup *gzgroup = static_cast<wmGizmoGroup *>(gzmap->groups.first),
|
||||
*gzgroup_next;
|
||||
gzgroup;
|
||||
gzgroup = gzgroup_next)
|
||||
{
|
||||
gzgroup_next = gzgroup->next;
|
||||
if (gzgroup->tag_remove) {
|
||||
wm_gizmogroup_free(NULL, gzgroup);
|
||||
wm_gizmogroup_free(nullptr, gzgroup);
|
||||
ED_region_tag_redraw_editor_overlays(region);
|
||||
}
|
||||
}
|
||||
@@ -1395,13 +1416,15 @@ void WM_gizmoconfig_update(Main *bmain)
|
||||
|
||||
void WM_reinit_gizmomap_all(Main *bmain)
|
||||
{
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
|
||||
LISTBASE_FOREACH (ARegion *, region, regionbase) {
|
||||
wmGizmoMap *gzmap = region->gizmo_map;
|
||||
if ((gzmap != NULL) && (gzmap->is_init == false)) {
|
||||
if ((gzmap != nullptr) && (gzmap->is_init == false)) {
|
||||
WM_gizmomap_reinit(gzmap);
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ wmGizmoProperty *WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
|
||||
if (index != -1) {
|
||||
return WM_gizmo_target_property_at_index(gz, index);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_gizmo_target_property_def_rna_ptr(wmGizmo *gz,
|
||||
@@ -70,8 +70,8 @@ void WM_gizmo_target_property_def_rna_ptr(wmGizmo *gz,
|
||||
wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type);
|
||||
|
||||
/* if gizmo evokes an operator we cannot use it for property manipulation */
|
||||
BLI_assert(gz->op_data == NULL);
|
||||
BLI_assert(prop != NULL);
|
||||
BLI_assert(gz->op_data == nullptr);
|
||||
BLI_assert(prop != nullptr);
|
||||
|
||||
gz_prop->type = gz_prop_type;
|
||||
|
||||
@@ -89,7 +89,7 @@ void WM_gizmo_target_property_def_rna(
|
||||
{
|
||||
const wmGizmoPropertyType *gz_prop_type = WM_gizmotype_target_property_find(gz->type, idname);
|
||||
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||
if (prop == NULL) {
|
||||
if (prop == nullptr) {
|
||||
RNA_warning("%s: %s.%s not found", __func__, RNA_struct_identifier(ptr->type), propname);
|
||||
}
|
||||
WM_gizmo_target_property_def_rna_ptr(gz, gz_prop_type, ptr, prop, index);
|
||||
@@ -102,7 +102,7 @@ void WM_gizmo_target_property_def_func_ptr(wmGizmo *gz,
|
||||
wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type);
|
||||
|
||||
/* if gizmo evokes an operator we cannot use it for property manipulation */
|
||||
BLI_assert(gz->op_data == NULL);
|
||||
BLI_assert(gz->op_data == nullptr);
|
||||
|
||||
gz_prop->type = gz_prop_type;
|
||||
|
||||
@@ -130,12 +130,12 @@ void WM_gizmo_target_property_clear_rna_ptr(wmGizmo *gz, const wmGizmoPropertyTy
|
||||
wmGizmoProperty *gz_prop = WM_gizmo_target_property_at_index(gz, gz_prop_type->index_in_type);
|
||||
|
||||
/* if gizmo evokes an operator we cannot use it for property manipulation */
|
||||
BLI_assert(gz->op_data == NULL);
|
||||
BLI_assert(gz->op_data == nullptr);
|
||||
|
||||
gz_prop->type = NULL;
|
||||
gz_prop->type = nullptr;
|
||||
|
||||
gz_prop->ptr = PointerRNA_NULL;
|
||||
gz_prop->prop = NULL;
|
||||
gz_prop->prop = nullptr;
|
||||
gz_prop->index = -1;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ bool WM_gizmo_target_property_is_valid_any(wmGizmo *gz)
|
||||
|
||||
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
|
||||
{
|
||||
return ((gz_prop->prop != NULL) ||
|
||||
return ((gz_prop->prop != nullptr) ||
|
||||
(gz_prop->custom_func.value_get_fn && gz_prop->custom_func.value_set_fn));
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ bool WM_gizmo_target_property_float_range_get(const wmGizmo *gz,
|
||||
return true;
|
||||
}
|
||||
|
||||
int WM_gizmo_target_property_array_length(const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
|
||||
int WM_gizmo_target_property_array_length(const wmGizmo * /*gz*/, wmGizmoProperty *gz_prop)
|
||||
{
|
||||
if (gz_prop->custom_func.value_get_fn) {
|
||||
return gz_prop->type->array_length;
|
||||
@@ -265,7 +265,8 @@ int WM_gizmo_target_property_array_length(const wmGizmo *UNUSED(gz), wmGizmoProp
|
||||
const wmGizmoPropertyType *WM_gizmotype_target_property_find(const wmGizmoType *gzt,
|
||||
const char *idname)
|
||||
{
|
||||
return BLI_findstring(&gzt->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname));
|
||||
return static_cast<const wmGizmoPropertyType *>(
|
||||
BLI_findstring(&gzt->target_property_defs, idname, offsetof(wmGizmoPropertyType, idname)));
|
||||
}
|
||||
|
||||
void WM_gizmotype_target_property_def(wmGizmoType *gzt,
|
||||
@@ -274,11 +275,11 @@ void WM_gizmotype_target_property_def(wmGizmoType *gzt,
|
||||
int array_length)
|
||||
{
|
||||
|
||||
BLI_assert(WM_gizmotype_target_property_find(gzt, idname) == NULL);
|
||||
BLI_assert(WM_gizmotype_target_property_find(gzt, idname) == nullptr);
|
||||
|
||||
const uint idname_size = strlen(idname) + 1;
|
||||
wmGizmoPropertyType *gz_prop_type = MEM_callocN(sizeof(wmGizmoPropertyType) + idname_size,
|
||||
__func__);
|
||||
wmGizmoPropertyType *gz_prop_type = static_cast<wmGizmoPropertyType *>(
|
||||
MEM_callocN(sizeof(wmGizmoPropertyType) + idname_size, __func__));
|
||||
memcpy(gz_prop_type->idname, idname, idname_size);
|
||||
gz_prop_type->data_type = data_type;
|
||||
gz_prop_type->array_length = array_length;
|
||||
@@ -293,12 +294,12 @@ void WM_gizmotype_target_property_def(wmGizmoType *gzt,
|
||||
/** \name Property Utilities
|
||||
* \{ */
|
||||
|
||||
void WM_gizmo_do_msg_notify_tag_refresh(bContext *UNUSED(C),
|
||||
wmMsgSubscribeKey *UNUSED(msg_key),
|
||||
void WM_gizmo_do_msg_notify_tag_refresh(bContext * /*C*/,
|
||||
wmMsgSubscribeKey * /*msg_key*/,
|
||||
wmMsgSubscribeValue *msg_val)
|
||||
{
|
||||
ARegion *region = msg_val->owner;
|
||||
wmGizmoMap *gzmap = msg_val->user_data;
|
||||
ARegion *region = static_cast<ARegion *>(msg_val->owner);
|
||||
wmGizmoMap *gzmap = static_cast<wmGizmoMap *>(msg_val->user_data);
|
||||
|
||||
/* Could possibly avoid a full redraw and only tag for editor overlays
|
||||
* redraw in some cases, see #ED_region_tag_redraw_editor_overlays(). */
|
||||
@@ -315,24 +316,20 @@ void WM_gizmo_target_property_subscribe_all(wmGizmo *gz, struct wmMsgBus *mbus,
|
||||
wmGizmoProperty *gz_prop = &gz_prop_array[i];
|
||||
if (WM_gizmo_target_property_is_valid(gz_prop)) {
|
||||
if (gz_prop->prop) {
|
||||
WM_msg_subscribe_rna(mbus,
|
||||
&gz_prop->ptr,
|
||||
gz_prop->prop,
|
||||
&(const wmMsgSubscribeValue){
|
||||
.owner = region,
|
||||
.user_data = region,
|
||||
.notify = ED_region_do_msg_notify_tag_redraw,
|
||||
},
|
||||
__func__);
|
||||
WM_msg_subscribe_rna(mbus,
|
||||
&gz_prop->ptr,
|
||||
gz_prop->prop,
|
||||
&(const wmMsgSubscribeValue){
|
||||
.owner = region,
|
||||
.user_data = gz->parent_gzgroup->parent_gzmap,
|
||||
.notify = WM_gizmo_do_msg_notify_tag_refresh,
|
||||
},
|
||||
__func__);
|
||||
{
|
||||
wmMsgSubscribeValue value{};
|
||||
value.owner = region;
|
||||
value.user_data = region;
|
||||
value.notify = ED_region_do_msg_notify_tag_redraw;
|
||||
WM_msg_subscribe_rna(mbus, &gz_prop->ptr, gz_prop->prop, &value, __func__);
|
||||
}
|
||||
{
|
||||
wmMsgSubscribeValue value{};
|
||||
value.owner = region;
|
||||
value.user_data = gz->parent_gzgroup->parent_gzmap;
|
||||
value.notify = WM_gizmo_do_msg_notify_tag_refresh;
|
||||
WM_msg_subscribe_rna(mbus, &gz_prop->ptr, gz_prop->prop, &value, __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,10 +337,10 @@ void WM_gizmo_target_property_subscribe_all(wmGizmo *gz, struct wmMsgBus *mbus,
|
||||
}
|
||||
|
||||
void WM_gizmo_target_property_anim_autokey(bContext *C,
|
||||
const wmGizmo *UNUSED(gz),
|
||||
const wmGizmo * /*gz*/,
|
||||
wmGizmoProperty *gz_prop)
|
||||
{
|
||||
if (gz_prop->prop != NULL) {
|
||||
if (gz_prop->prop != nullptr) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
const float cfra = (float)scene->r.cfra;
|
||||
const int index = gz_prop->index == -1 ? 0 : gz_prop->index;
|
||||
@@ -42,14 +42,14 @@
|
||||
* \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends.
|
||||
* \{ */
|
||||
|
||||
static GHash *global_gizmotype_hash = NULL;
|
||||
static GHash *global_gizmotype_hash = nullptr;
|
||||
|
||||
const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet)
|
||||
{
|
||||
if (idname[0]) {
|
||||
wmGizmoType *gzt;
|
||||
|
||||
gzt = BLI_ghash_lookup(global_gizmotype_hash, idname);
|
||||
gzt = static_cast<wmGizmoType *>(BLI_ghash_lookup(global_gizmotype_hash, idname));
|
||||
if (gzt) {
|
||||
return gzt;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_gizmotype_iter(GHashIterator *ghi)
|
||||
@@ -74,7 +74,7 @@ void WM_gizmotype_iter(GHashIterator *ghi)
|
||||
|
||||
static wmGizmoType *wm_gizmotype_append__begin(void)
|
||||
{
|
||||
wmGizmoType *gzt = MEM_callocN(sizeof(wmGizmoType), "gizmotype");
|
||||
wmGizmoType *gzt = static_cast<wmGizmoType *>(MEM_callocN(sizeof(wmGizmoType), "gizmotype"));
|
||||
gzt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties);
|
||||
#if 0
|
||||
/* Set the default i18n context now, so that opfunc can redefine it if needed! */
|
||||
@@ -118,12 +118,14 @@ void WM_gizmotype_free_ptr(wmGizmoType *gzt)
|
||||
}
|
||||
|
||||
/**
|
||||
* \param C: May be NULL.
|
||||
* \param C: May be nullptr.
|
||||
*/
|
||||
static void gizmotype_unlink(bContext *C, Main *bmain, wmGizmoType *gzt)
|
||||
{
|
||||
/* Free instances. */
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
|
||||
@@ -131,8 +133,10 @@ static void gizmotype_unlink(bContext *C, Main *bmain, wmGizmoType *gzt)
|
||||
wmGizmoMap *gzmap = region->gizmo_map;
|
||||
if (gzmap) {
|
||||
wmGizmoGroup *gzgroup;
|
||||
for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
|
||||
for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) {
|
||||
for (gzgroup = static_cast<wmGizmoGroup *>(gzmap->groups.first); gzgroup;
|
||||
gzgroup = gzgroup->next) {
|
||||
for (wmGizmo *gz = static_cast<wmGizmo *>(gzgroup->gizmos.first), *gz_next; gz;
|
||||
gz = gz_next) {
|
||||
gz_next = gz->next;
|
||||
BLI_assert(gzgroup->parent_gzmap == gzmap);
|
||||
if (gz->type == gzt) {
|
||||
@@ -152,16 +156,16 @@ void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt)
|
||||
{
|
||||
BLI_assert(gzt == WM_gizmotype_find(gzt->idname, false));
|
||||
|
||||
BLI_ghash_remove(global_gizmotype_hash, gzt->idname, NULL, NULL);
|
||||
BLI_ghash_remove(global_gizmotype_hash, gzt->idname, nullptr, nullptr);
|
||||
|
||||
gizmotype_unlink(C, bmain, gzt);
|
||||
}
|
||||
|
||||
bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname)
|
||||
{
|
||||
wmGizmoType *gzt = BLI_ghash_lookup(global_gizmotype_hash, idname);
|
||||
wmGizmoType *gzt = static_cast<wmGizmoType *>(BLI_ghash_lookup(global_gizmotype_hash, idname));
|
||||
|
||||
if (gzt == NULL) {
|
||||
if (gzt == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -177,8 +181,8 @@ static void wm_gizmotype_ghash_free_cb(wmGizmoType *gzt)
|
||||
|
||||
void wm_gizmotype_free(void)
|
||||
{
|
||||
BLI_ghash_free(global_gizmotype_hash, NULL, (GHashValFreeFP)wm_gizmotype_ghash_free_cb);
|
||||
global_gizmotype_hash = NULL;
|
||||
BLI_ghash_free(global_gizmotype_hash, nullptr, (GHashValFreeFP)wm_gizmotype_ghash_free_cb);
|
||||
global_gizmotype_hash = nullptr;
|
||||
}
|
||||
|
||||
void wm_gizmotype_init(void)
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
static void window_manager_free_data(ID *id)
|
||||
{
|
||||
wm_close_and_free(NULL, (wmWindowManager *)id);
|
||||
wm_close_and_free(nullptr, (wmWindowManager *)id);
|
||||
}
|
||||
|
||||
static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
@@ -74,8 +74,8 @@ static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, win->scene, IDWALK_CB_USER_ONE);
|
||||
|
||||
/* This pointer can be NULL during old files reading, better be safe than sorry. */
|
||||
if (win->workspace_hook != NULL) {
|
||||
/* This pointer can be nullptr during old files reading, better be safe than sorry. */
|
||||
if (win->workspace_hook != nullptr) {
|
||||
ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook);
|
||||
BKE_lib_query_foreachid_process(data, &workspace, IDWALK_CB_USER);
|
||||
/* Allow callback to set a different workspace. */
|
||||
@@ -123,7 +123,7 @@ static void window_manager_blend_write(BlendWriter *writer, ID *id, const void *
|
||||
BKE_screen_area_map_blend_write(writer, &win->global_areas);
|
||||
|
||||
/* data is written, clear deprecated data again */
|
||||
win->screen = NULL;
|
||||
win->screen = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,27 +145,27 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
WorkSpaceInstanceHook *hook = win->workspace_hook;
|
||||
BLO_read_data_address(reader, &win->workspace_hook);
|
||||
|
||||
/* This will be NULL for any pre-2.80 blend file. */
|
||||
if (win->workspace_hook != NULL) {
|
||||
/* This will be nullptr for any pre-2.80 blend file. */
|
||||
if (win->workspace_hook != nullptr) {
|
||||
/* We need to restore a pointer to this later when reading workspaces,
|
||||
* so store in global oldnew-map.
|
||||
* Note that this is only needed for versioning of older .blend files now. */
|
||||
BLO_read_data_globmap_add(reader, hook, win->workspace_hook);
|
||||
/* Cleanup pointers to data outside of this data-block scope. */
|
||||
win->workspace_hook->act_layout = NULL;
|
||||
win->workspace_hook->temp_workspace_store = NULL;
|
||||
win->workspace_hook->temp_layout_store = NULL;
|
||||
win->workspace_hook->act_layout = nullptr;
|
||||
win->workspace_hook->temp_workspace_store = nullptr;
|
||||
win->workspace_hook->temp_layout_store = nullptr;
|
||||
}
|
||||
|
||||
BKE_screen_area_map_blend_read_data(reader, &win->global_areas);
|
||||
|
||||
win->ghostwin = NULL;
|
||||
win->gpuctx = NULL;
|
||||
win->eventstate = NULL;
|
||||
win->event_last_handled = NULL;
|
||||
win->cursor_keymap_status = NULL;
|
||||
win->ghostwin = nullptr;
|
||||
win->gpuctx = nullptr;
|
||||
win->eventstate = nullptr;
|
||||
win->event_last_handled = nullptr;
|
||||
win->cursor_keymap_status = nullptr;
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
win->ime_data = NULL;
|
||||
win->ime_data = nullptr;
|
||||
#endif
|
||||
|
||||
BLI_listbase_clear(&win->event_queue);
|
||||
@@ -184,7 +184,7 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
win->event_queue_check_drag = 0;
|
||||
win->event_queue_check_drag_handled = 0;
|
||||
win->event_queue_consecutive_gesture_type = 0;
|
||||
win->event_queue_consecutive_gesture_data = NULL;
|
||||
win->event_queue_consecutive_gesture_data = nullptr;
|
||||
BLO_read_data_address(reader, &win->stereo3d_format);
|
||||
|
||||
/* Multi-view always fallback to anaglyph at file opening
|
||||
@@ -200,24 +200,24 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
BLI_listbase_clear(&wm->operators);
|
||||
BLI_listbase_clear(&wm->paintcursors);
|
||||
BLI_listbase_clear(&wm->notifier_queue);
|
||||
wm->notifier_queue_set = NULL;
|
||||
wm->notifier_queue_set = nullptr;
|
||||
BKE_reports_init(&wm->reports, RPT_STORE);
|
||||
|
||||
BLI_listbase_clear(&wm->keyconfigs);
|
||||
wm->defaultconf = NULL;
|
||||
wm->addonconf = NULL;
|
||||
wm->userconf = NULL;
|
||||
wm->undo_stack = NULL;
|
||||
wm->defaultconf = nullptr;
|
||||
wm->addonconf = nullptr;
|
||||
wm->userconf = nullptr;
|
||||
wm->undo_stack = nullptr;
|
||||
|
||||
wm->message_bus = NULL;
|
||||
wm->message_bus = nullptr;
|
||||
|
||||
wm->xr.runtime = NULL;
|
||||
wm->xr.runtime = nullptr;
|
||||
|
||||
BLI_listbase_clear(&wm->jobs);
|
||||
BLI_listbase_clear(&wm->drags);
|
||||
|
||||
wm->windrawable = NULL;
|
||||
wm->winactive = NULL;
|
||||
wm->windrawable = nullptr;
|
||||
wm->winactive = nullptr;
|
||||
wm->init_flag = 0;
|
||||
wm->op_undo_depth = 0;
|
||||
wm->is_interface_locked = 0;
|
||||
@@ -243,14 +243,14 @@ static void window_manager_blend_read_lib(BlendLibReader *reader, ID *id)
|
||||
wmWindowManager *wm = (wmWindowManager *)id;
|
||||
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
if (win->workspace_hook) { /* NULL for old files */
|
||||
if (win->workspace_hook) { /* nullptr for old files */
|
||||
lib_link_workspace_instance_hook(reader, win->workspace_hook, id);
|
||||
}
|
||||
BLO_read_id_address(reader, id, &win->scene);
|
||||
/* deprecated, but needed for versioning (will be NULL'ed then) */
|
||||
/* deprecated, but needed for versioning (will be nullptr'ed then) */
|
||||
BLO_read_id_address(reader, id, &win->screen);
|
||||
|
||||
/* The unpinned scene is a UI->Scene-data pointer, and should be NULL'ed on linking (like
|
||||
/* The unpinned scene is a UI->Scene-data pointer, and should be nullptr'ed on linking (like
|
||||
* WorkSpace.pin_scene). But the WindowManager ID (owning the window) is never linked. */
|
||||
BLI_assert(!ID_IS_LINKED(id));
|
||||
BLO_read_id_address(reader, id, &win->unpinned_scene);
|
||||
@@ -264,34 +264,34 @@ static void window_manager_blend_read_lib(BlendLibReader *reader, ID *id)
|
||||
}
|
||||
|
||||
IDTypeInfo IDType_ID_WM = {
|
||||
.id_code = ID_WM,
|
||||
.id_filter = FILTER_ID_WM,
|
||||
.main_listbase_index = INDEX_ID_WM,
|
||||
.struct_size = sizeof(wmWindowManager),
|
||||
.name = "WindowManager",
|
||||
.name_plural = "window_managers",
|
||||
.translation_context = BLT_I18NCONTEXT_ID_WINDOWMANAGER,
|
||||
.flags = IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_LIBLINKING | IDTYPE_FLAGS_NO_ANIMDATA |
|
||||
IDTYPE_FLAGS_NO_MEMFILE_UNDO,
|
||||
.asset_type_info = NULL,
|
||||
/*id_code*/ ID_WM,
|
||||
/*id_filter*/ FILTER_ID_WM,
|
||||
/*main_listbase_index*/ INDEX_ID_WM,
|
||||
/*struct_size*/ sizeof(wmWindowManager),
|
||||
/*name*/ "WindowManager",
|
||||
/*name_plural*/ "window_managers",
|
||||
/*translation_context*/ BLT_I18NCONTEXT_ID_WINDOWMANAGER,
|
||||
/*flags*/ IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_LIBLINKING | IDTYPE_FLAGS_NO_ANIMDATA |
|
||||
IDTYPE_FLAGS_NO_MEMFILE_UNDO,
|
||||
/*asset_type_info*/ nullptr,
|
||||
|
||||
.init_data = NULL,
|
||||
.copy_data = NULL,
|
||||
.free_data = window_manager_free_data,
|
||||
.make_local = NULL,
|
||||
.foreach_id = window_manager_foreach_id,
|
||||
.foreach_cache = NULL,
|
||||
.foreach_path = NULL,
|
||||
.owner_pointer_get = NULL,
|
||||
/*init_data*/ nullptr,
|
||||
/*copy_data*/ nullptr,
|
||||
/*free_data*/ window_manager_free_data,
|
||||
/*make_local*/ nullptr,
|
||||
/*foreach_id*/ window_manager_foreach_id,
|
||||
/*foreach_cache*/ nullptr,
|
||||
/*foreach_path*/ nullptr,
|
||||
/*owner_pointer_get*/ nullptr,
|
||||
|
||||
.blend_write = window_manager_blend_write,
|
||||
.blend_read_data = window_manager_blend_read_data,
|
||||
.blend_read_lib = window_manager_blend_read_lib,
|
||||
.blend_read_expand = NULL,
|
||||
/*blend_write*/ window_manager_blend_write,
|
||||
/*blend_read_data*/ window_manager_blend_read_data,
|
||||
/*blend_read_lib*/ window_manager_blend_read_lib,
|
||||
/*blend_read_expand*/ nullptr,
|
||||
|
||||
.blend_read_undo_preserve = NULL,
|
||||
/*blend_read_undo_preserve*/ nullptr,
|
||||
|
||||
.lib_override_apply_post = NULL,
|
||||
/*lib_override_apply_post*/ nullptr,
|
||||
};
|
||||
|
||||
#define MAX_OP_REGISTERED 32
|
||||
@@ -307,7 +307,7 @@ void WM_operator_free(wmOperator *op)
|
||||
#endif
|
||||
|
||||
if (op->ptr) {
|
||||
op->properties = op->ptr->data;
|
||||
op->properties = static_cast<IDProperty *>(op->ptr->data);
|
||||
MEM_freeN(op->ptr);
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ void WM_operator_free(wmOperator *op)
|
||||
|
||||
if (op->macro.first) {
|
||||
wmOperator *opm, *opmnext;
|
||||
for (opm = op->macro.first; opm; opm = opmnext) {
|
||||
for (opm = static_cast<wmOperator *>(op->macro.first); opm; opm = opmnext) {
|
||||
opmnext = opm->next;
|
||||
WM_operator_free(opm);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ void WM_operator_free(wmOperator *op)
|
||||
void WM_operator_free_all_after(wmWindowManager *wm, wmOperator *op)
|
||||
{
|
||||
op = op->next;
|
||||
while (op != NULL) {
|
||||
while (op != nullptr) {
|
||||
wmOperator *op_next = op->next;
|
||||
BLI_remlink(&wm->operators, op);
|
||||
WM_operator_free(op);
|
||||
@@ -345,7 +345,7 @@ void WM_operator_free_all_after(wmWindowManager *wm, wmOperator *op)
|
||||
void WM_operator_type_set(wmOperator *op, wmOperatorType *ot)
|
||||
{
|
||||
/* Not supported for Python. */
|
||||
BLI_assert(op->py_instance == NULL);
|
||||
BLI_assert(op->py_instance == nullptr);
|
||||
|
||||
op->type = ot;
|
||||
op->ptr->type = ot->srna;
|
||||
@@ -358,7 +358,7 @@ void WM_operator_type_set(wmOperator *op, wmOperatorType *ot)
|
||||
WM_operator_properties_default(&ptr, false);
|
||||
|
||||
if (ptr.data) {
|
||||
IDP_SyncGroupTypes(op->properties, ptr.data, true);
|
||||
IDP_SyncGroupTypes(op->properties, static_cast<const IDProperty *>(ptr.data), true);
|
||||
}
|
||||
|
||||
WM_operator_properties_free(&ptr);
|
||||
@@ -368,7 +368,7 @@ void WM_operator_type_set(wmOperator *op, wmOperatorType *ot)
|
||||
static void wm_reports_free(wmWindowManager *wm)
|
||||
{
|
||||
BKE_reports_clear(&wm->reports);
|
||||
WM_event_timer_remove(wm, NULL, wm->reports.reporttimer);
|
||||
WM_event_timer_remove(wm, nullptr, wm->reports.reporttimer);
|
||||
}
|
||||
|
||||
void wm_operator_register(bContext *C, wmOperator *op)
|
||||
@@ -392,19 +392,19 @@ void wm_operator_register(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* So the console is redrawn. */
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
|
||||
WM_event_add_notifier(C, NC_WM | ND_HISTORY, NULL);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO_REPORT, nullptr);
|
||||
WM_event_add_notifier(C, NC_WM | ND_HISTORY, nullptr);
|
||||
}
|
||||
|
||||
void WM_operator_stack_clear(wmWindowManager *wm)
|
||||
{
|
||||
wmOperator *op;
|
||||
|
||||
while ((op = BLI_pophead(&wm->operators))) {
|
||||
while ((op = static_cast<wmOperator *>(BLI_pophead(&wm->operators)))) {
|
||||
WM_operator_free(op);
|
||||
}
|
||||
|
||||
WM_main_add_notifier(NC_WM | ND_HISTORY, NULL);
|
||||
WM_main_add_notifier(NC_WM | ND_HISTORY, nullptr);
|
||||
}
|
||||
|
||||
void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
|
||||
@@ -420,7 +420,7 @@ void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
|
||||
* assume whoever unregisters the operator will cleanup */
|
||||
handler->head.flag |= WM_HANDLER_DO_FREE;
|
||||
WM_operator_free(handler->op);
|
||||
handler->op = NULL;
|
||||
handler->op = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -434,7 +434,8 @@ void WM_keyconfig_reload(bContext *C)
|
||||
{
|
||||
if (CTX_py_init_get(C) && !G.background) {
|
||||
#ifdef WITH_PYTHON
|
||||
BPY_run_string_eval(C, (const char *[]){"bpy", NULL}, "bpy.utils.keyconfig_init()");
|
||||
const char *imports[] = {"bpy", nullptr};
|
||||
BPY_run_string_eval(C, imports, "bpy.utils.keyconfig_init()");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -444,14 +445,14 @@ void WM_keyconfig_init(bContext *C)
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
|
||||
/* Create standard key configs. */
|
||||
if (wm->defaultconf == NULL) {
|
||||
if (wm->defaultconf == nullptr) {
|
||||
/* Keep lowercase to match the preset filename. */
|
||||
wm->defaultconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT, false);
|
||||
}
|
||||
if (wm->addonconf == NULL) {
|
||||
if (wm->addonconf == nullptr) {
|
||||
wm->addonconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT " addon", false);
|
||||
}
|
||||
if (wm->userconf == NULL) {
|
||||
if (wm->userconf == nullptr) {
|
||||
wm->userconf = WM_keyconfig_new(wm, WM_KEYCONFIG_STR_DEFAULT " user", false);
|
||||
}
|
||||
|
||||
@@ -470,7 +471,7 @@ void WM_keyconfig_init(bContext *C)
|
||||
|
||||
/* Harmless, but no need to update in background mode. */
|
||||
if (!G.background) {
|
||||
WM_keyconfig_update_tag(NULL, NULL);
|
||||
WM_keyconfig_update_tag(nullptr, nullptr);
|
||||
}
|
||||
WM_keyconfig_update(wm);
|
||||
|
||||
@@ -484,17 +485,17 @@ void WM_check(bContext *C)
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
|
||||
/* WM context. */
|
||||
if (wm == NULL) {
|
||||
wm = bmain->wm.first;
|
||||
if (wm == nullptr) {
|
||||
wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
CTX_wm_manager_set(C, wm);
|
||||
}
|
||||
|
||||
if (wm == NULL || BLI_listbase_is_empty(&wm->windows)) {
|
||||
if (wm == nullptr || BLI_listbase_is_empty(&wm->windows)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Run before loading the keyconfig. */
|
||||
if (wm->message_bus == NULL) {
|
||||
if (wm->message_bus == nullptr) {
|
||||
wm->message_bus = WM_msgbus_create();
|
||||
}
|
||||
|
||||
@@ -522,12 +523,12 @@ void wm_clear_default_size(bContext *C)
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
|
||||
/* WM context. */
|
||||
if (wm == NULL) {
|
||||
wm = CTX_data_main(C)->wm.first;
|
||||
if (wm == nullptr) {
|
||||
wm = static_cast<wmWindowManager *>(CTX_data_main(C)->wm.first);
|
||||
CTX_wm_manager_set(C, wm);
|
||||
}
|
||||
|
||||
if (wm == NULL || BLI_listbase_is_empty(&wm->windows)) {
|
||||
if (wm == nullptr || BLI_listbase_is_empty(&wm->windows)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -541,14 +542,15 @@ void wm_clear_default_size(bContext *C)
|
||||
|
||||
void wm_add_default(Main *bmain, bContext *C)
|
||||
{
|
||||
wmWindowManager *wm = BKE_libblock_alloc(bmain, ID_WM, "WinMan", 0);
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(
|
||||
BKE_libblock_alloc(bmain, ID_WM, "WinMan", 0));
|
||||
wmWindow *win;
|
||||
bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */
|
||||
WorkSpace *workspace;
|
||||
WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace);
|
||||
|
||||
CTX_wm_manager_set(C, wm);
|
||||
win = wm_window_new(bmain, wm, NULL, false);
|
||||
win = wm_window_new(bmain, wm, nullptr, false);
|
||||
win->scene = CTX_data_scene(C);
|
||||
STRNCPY(win->view_layer_name, CTX_data_view_layer(C)->name);
|
||||
BKE_workspace_active_set(win->workspace_hook, workspace);
|
||||
@@ -572,29 +574,29 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
|
||||
#endif
|
||||
|
||||
wmWindow *win;
|
||||
while ((win = BLI_pophead(&wm->windows))) {
|
||||
while ((win = static_cast<wmWindow *>(BLI_pophead(&wm->windows)))) {
|
||||
/* Prevent draw clear to use screen. */
|
||||
BKE_workspace_active_set(win->workspace_hook, NULL);
|
||||
BKE_workspace_active_set(win->workspace_hook, nullptr);
|
||||
wm_window_free(C, wm, win);
|
||||
}
|
||||
|
||||
wmOperator *op;
|
||||
while ((op = BLI_pophead(&wm->operators))) {
|
||||
while ((op = static_cast<wmOperator *>(BLI_pophead(&wm->operators)))) {
|
||||
WM_operator_free(op);
|
||||
}
|
||||
|
||||
wmKeyConfig *keyconf;
|
||||
while ((keyconf = BLI_pophead(&wm->keyconfigs))) {
|
||||
while ((keyconf = static_cast<wmKeyConfig *>(BLI_pophead(&wm->keyconfigs)))) {
|
||||
WM_keyconfig_free(keyconf);
|
||||
}
|
||||
|
||||
BLI_freelistN(&wm->notifier_queue);
|
||||
if (wm->notifier_queue_set) {
|
||||
BLI_gset_free(wm->notifier_queue_set, NULL);
|
||||
wm->notifier_queue_set = NULL;
|
||||
BLI_gset_free(wm->notifier_queue_set, nullptr);
|
||||
wm->notifier_queue_set = nullptr;
|
||||
}
|
||||
|
||||
if (wm->message_bus != NULL) {
|
||||
if (wm->message_bus != nullptr) {
|
||||
WM_msgbus_destroy(wm->message_bus);
|
||||
}
|
||||
|
||||
@@ -614,11 +616,11 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
|
||||
|
||||
if (wm->undo_stack) {
|
||||
BKE_undosys_stack_destroy(wm->undo_stack);
|
||||
wm->undo_stack = NULL;
|
||||
wm->undo_stack = nullptr;
|
||||
}
|
||||
|
||||
if (C && CTX_wm_manager(C) == wm) {
|
||||
CTX_wm_manager_set(C, NULL);
|
||||
CTX_wm_manager_set(C, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,13 +108,19 @@ static GHOST_TStandardCursor convert_to_ghost_standard_cursor(WMCursorType curs)
|
||||
static void window_set_custom_cursor(
|
||||
wmWindow *win, const uchar mask[16][2], const uchar bitmap[16][2], int hotx, int hoty)
|
||||
{
|
||||
GHOST_SetCustomCursorShape(
|
||||
win->ghostwin, (uint8_t *)bitmap, (uint8_t *)mask, 16, 16, hotx, hoty, true);
|
||||
GHOST_SetCustomCursorShape(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
(uint8_t *)bitmap,
|
||||
(uint8_t *)mask,
|
||||
16,
|
||||
16,
|
||||
hotx,
|
||||
hoty,
|
||||
true);
|
||||
}
|
||||
|
||||
static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor)
|
||||
{
|
||||
GHOST_SetCustomCursorShape(win->ghostwin,
|
||||
GHOST_SetCustomCursorShape(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
(uint8_t *)cursor->bitmap,
|
||||
(uint8_t *)cursor->mask,
|
||||
16,
|
||||
@@ -126,7 +132,7 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor)
|
||||
|
||||
void WM_cursor_set(wmWindow *win, int curs)
|
||||
{
|
||||
if (win == NULL || G.background) {
|
||||
if (win == nullptr || G.background) {
|
||||
return; /* Can't set custom cursor before Window init */
|
||||
}
|
||||
|
||||
@@ -135,11 +141,11 @@ void WM_cursor_set(wmWindow *win, int curs)
|
||||
}
|
||||
|
||||
if (curs == WM_CURSOR_NONE) {
|
||||
GHOST_SetCursorVisibility(win->ghostwin, 0);
|
||||
GHOST_SetCursorVisibility(static_cast<GHOST_WindowHandle>(win->ghostwin), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
GHOST_SetCursorVisibility(win->ghostwin, 1);
|
||||
GHOST_SetCursorVisibility(static_cast<GHOST_WindowHandle>(win->ghostwin), 1);
|
||||
|
||||
if (win->cursor == curs) {
|
||||
return; /* Cursor is already set */
|
||||
@@ -152,13 +158,13 @@ void WM_cursor_set(wmWindow *win, int curs)
|
||||
return;
|
||||
}
|
||||
|
||||
GHOST_TStandardCursor ghost_cursor = convert_to_ghost_standard_cursor(curs);
|
||||
GHOST_TStandardCursor ghost_cursor = convert_to_ghost_standard_cursor(WMCursorType(curs));
|
||||
|
||||
if (ghost_cursor != GHOST_kStandardCursorCustom &&
|
||||
GHOST_HasCursorShape(win->ghostwin, ghost_cursor))
|
||||
GHOST_HasCursorShape(static_cast<GHOST_WindowHandle>(win->ghostwin), ghost_cursor))
|
||||
{
|
||||
/* Use native GHOST cursor when available. */
|
||||
GHOST_SetCursorShape(win->ghostwin, ghost_cursor);
|
||||
GHOST_SetCursorShape(static_cast<GHOST_WindowHandle>(win->ghostwin), ghost_cursor);
|
||||
}
|
||||
else {
|
||||
BCursor *bcursor = BlenderCursor[curs];
|
||||
@@ -168,7 +174,8 @@ void WM_cursor_set(wmWindow *win, int curs)
|
||||
}
|
||||
else {
|
||||
/* Fallback to default cursor if no bitmap found. */
|
||||
GHOST_SetCursorShape(win->ghostwin, GHOST_kStandardCursorDefault);
|
||||
GHOST_SetCursorShape(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
GHOST_kStandardCursorDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +186,7 @@ bool WM_cursor_set_from_tool(wmWindow *win, const ScrArea *area, const ARegion *
|
||||
return false;
|
||||
}
|
||||
|
||||
bToolRef_Runtime *tref_rt = (area && area->runtime.tool) ? area->runtime.tool->runtime : NULL;
|
||||
bToolRef_Runtime *tref_rt = (area && area->runtime.tool) ? area->runtime.tool->runtime : nullptr;
|
||||
if (tref_rt && tref_rt->cursor != WM_CURSOR_DEFAULT) {
|
||||
if (win->modalcursor == 0) {
|
||||
WM_cursor_set(win, tref_rt->cursor);
|
||||
@@ -211,8 +218,8 @@ void WM_cursor_modal_restore(wmWindow *win)
|
||||
void WM_cursor_wait(bool val)
|
||||
{
|
||||
if (!G.background) {
|
||||
wmWindowManager *wm = G_MAIN->wm.first;
|
||||
wmWindow *win = wm ? wm->windows.first : NULL;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
|
||||
wmWindow *win = static_cast<wmWindow *>(wm ? wm->windows.first : nullptr);
|
||||
|
||||
for (; win; win = win->next) {
|
||||
if (val) {
|
||||
@@ -231,12 +238,12 @@ void WM_cursor_grab_enable(wmWindow *win,
|
||||
const bool hide)
|
||||
{
|
||||
int _wrap_region_buf[4];
|
||||
int *wrap_region_screen = NULL;
|
||||
int *wrap_region_screen = nullptr;
|
||||
|
||||
/* Only grab cursor when not running debug.
|
||||
* It helps not to get a stuck WM when hitting a break-point. */
|
||||
GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
|
||||
GHOST_TAxisFlag mode_axis = GHOST_kAxisX | GHOST_kAxisY;
|
||||
GHOST_TAxisFlag mode_axis = GHOST_TAxisFlag(GHOST_kAxisX | GHOST_kAxisY);
|
||||
|
||||
if (wrap_region) {
|
||||
wrap_region_screen = _wrap_region_buf;
|
||||
@@ -265,7 +272,11 @@ void WM_cursor_grab_enable(wmWindow *win,
|
||||
if ((G.debug & G_DEBUG) == 0) {
|
||||
if (win->ghostwin) {
|
||||
if (win->eventstate->tablet.is_motion_absolute == false) {
|
||||
GHOST_SetCursorGrab(win->ghostwin, mode, mode_axis, wrap_region_screen, NULL);
|
||||
GHOST_SetCursorGrab(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
mode,
|
||||
mode_axis,
|
||||
wrap_region_screen,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
win->grabcursor = mode;
|
||||
@@ -280,10 +291,18 @@ void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
|
||||
if (mouse_ungrab_xy) {
|
||||
int mouse_xy[2] = {mouse_ungrab_xy[0], mouse_ungrab_xy[1]};
|
||||
wm_cursor_position_to_ghost_screen_coords(win, &mouse_xy[0], &mouse_xy[1]);
|
||||
GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, GHOST_kAxisNone, NULL, mouse_xy);
|
||||
GHOST_SetCursorGrab(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
GHOST_kGrabDisable,
|
||||
GHOST_kAxisNone,
|
||||
nullptr,
|
||||
mouse_xy);
|
||||
}
|
||||
else {
|
||||
GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, GHOST_kAxisNone, NULL, NULL);
|
||||
GHOST_SetCursorGrab(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
GHOST_kGrabDisable,
|
||||
GHOST_kAxisNone,
|
||||
nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
win->grabcursor = GHOST_kGrabDisable;
|
||||
@@ -305,7 +324,7 @@ bool wm_cursor_arrow_move(wmWindow *win, const wmEvent *event)
|
||||
|
||||
if (win && event->val == KM_PRESS) {
|
||||
/* Must move at least this much to avoid rounding in WM_cursor_warp. */
|
||||
float fac = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
float fac = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
if (event->type == EVT_UPARROWKEY) {
|
||||
wm_cursor_warp_relative(win, 0, fac);
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
@@ -78,8 +79,11 @@ static bool wm_window_grab_warp_region_is_set(const wmWindow *win)
|
||||
GHOST_TAxisFlag wrap_axis_dummy;
|
||||
int bounds[4] = {0};
|
||||
bool use_software_cursor_dummy = false;
|
||||
GHOST_GetCursorGrabState(
|
||||
win->ghostwin, &mode_dummy, &wrap_axis_dummy, bounds, &use_software_cursor_dummy);
|
||||
GHOST_GetCursorGrabState(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
&mode_dummy,
|
||||
&wrap_axis_dummy,
|
||||
bounds,
|
||||
&use_software_cursor_dummy);
|
||||
if ((bounds[0] != bounds[2]) || (bounds[1] != bounds[3])) {
|
||||
return true;
|
||||
}
|
||||
@@ -119,7 +123,7 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pc->poll == NULL || pc->poll(C)) {
|
||||
if (pc->poll == nullptr || pc->poll(C)) {
|
||||
UI_SetTheme(area->spacetype, region->regiontype);
|
||||
|
||||
/* Prevent drawing outside region. */
|
||||
@@ -166,8 +170,8 @@ static struct {
|
||||
int winid;
|
||||
int xy[2];
|
||||
} g_software_cursor = {
|
||||
.enabled = -1,
|
||||
.winid = -1,
|
||||
/*enabled*/ -1,
|
||||
/*winid*/ -1,
|
||||
};
|
||||
|
||||
/** Reuse the result from #GHOST_GetCursorGrabState. */
|
||||
@@ -188,11 +192,11 @@ static bool wm_software_cursor_needed(void)
|
||||
static bool wm_software_cursor_needed_for_window(const wmWindow *win, struct GrabState *grab_state)
|
||||
{
|
||||
BLI_assert(wm_software_cursor_needed());
|
||||
if (GHOST_GetCursorVisibility(win->ghostwin)) {
|
||||
if (GHOST_GetCursorVisibility(static_cast<GHOST_WindowHandle>(win->ghostwin))) {
|
||||
/* NOTE: The value in `win->grabcursor` can't be used as it
|
||||
* doesn't always match GHOST's value in the case of tablet events. */
|
||||
bool use_software_cursor;
|
||||
GHOST_GetCursorGrabState(win->ghostwin,
|
||||
GHOST_GetCursorGrabState(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
&grab_state->mode,
|
||||
&grab_state->wrap_axis,
|
||||
grab_state->bounds,
|
||||
@@ -234,7 +238,7 @@ static void wm_software_cursor_draw_bitmap(const int event_xy[2],
|
||||
float gl_matrix[4][4];
|
||||
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_GENERAL;
|
||||
GPUTexture *texture = GPU_texture_create_2d(
|
||||
"softeare_cursor", bitmap->data_size[0], bitmap->data_size[1], 1, GPU_RGBA8, usage, NULL);
|
||||
"softeare_cursor", bitmap->data_size[0], bitmap->data_size[1], 1, GPU_RGBA8, usage, nullptr);
|
||||
GPU_texture_update(texture, GPU_DATA_UBYTE, bitmap->data);
|
||||
GPU_texture_filter_mode(texture, false);
|
||||
|
||||
@@ -351,7 +355,9 @@ static void wm_software_cursor_draw(wmWindow *win, const struct GrabState *grab_
|
||||
}
|
||||
|
||||
GHOST_CursorBitmapRef bitmap = {0};
|
||||
if (GHOST_GetCursorBitmap(win->ghostwin, &bitmap) == GHOST_kSuccess) {
|
||||
if (GHOST_GetCursorBitmap(static_cast<GHOST_WindowHandle>(win->ghostwin), &bitmap) ==
|
||||
GHOST_kSuccess)
|
||||
{
|
||||
wm_software_cursor_draw_bitmap(event_xy, &bitmap);
|
||||
}
|
||||
else {
|
||||
@@ -395,7 +401,7 @@ static bool wm_draw_region_stereo_set(Main *bmain,
|
||||
switch (area->spacetype) {
|
||||
case SPACE_IMAGE: {
|
||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||
SpaceImage *sima = area->spacedata.first;
|
||||
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
||||
sima->iuser.multiview_eye = sview;
|
||||
return true;
|
||||
}
|
||||
@@ -403,16 +409,17 @@ static bool wm_draw_region_stereo_set(Main *bmain,
|
||||
}
|
||||
case SPACE_VIEW3D: {
|
||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||
View3D *v3d = area->spacedata.first;
|
||||
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||
if (v3d->camera && v3d->camera->type == OB_CAMERA) {
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
RenderEngine *engine = rv3d->view_render ? RE_view_engine_get(rv3d->view_render) : NULL;
|
||||
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||
RenderEngine *engine = rv3d->view_render ? RE_view_engine_get(rv3d->view_render) :
|
||||
nullptr;
|
||||
if (engine && !(engine->type->flag & RE_USE_STEREO_VIEWPORT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Camera *cam = v3d->camera->data;
|
||||
CameraBGImage *bgpic = cam->bg_images.first;
|
||||
Camera *cam = static_cast<Camera *>(v3d->camera->data);
|
||||
CameraBGImage *bgpic = static_cast<CameraBGImage *>(cam->bg_images.first);
|
||||
v3d->multiview_eye = sview;
|
||||
if (bgpic) {
|
||||
bgpic->iuser.multiview_eye = sview;
|
||||
@@ -424,7 +431,7 @@ static bool wm_draw_region_stereo_set(Main *bmain,
|
||||
}
|
||||
case SPACE_NODE: {
|
||||
if (region->regiontype == RGN_TYPE_WINDOW) {
|
||||
SpaceNode *snode = area->spacedata.first;
|
||||
SpaceNode *snode = static_cast<SpaceNode *>(area->spacedata.first);
|
||||
if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
|
||||
Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
ima->eye = sview;
|
||||
@@ -434,7 +441,7 @@ static bool wm_draw_region_stereo_set(Main *bmain,
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ: {
|
||||
SpaceSeq *sseq = area->spacedata.first;
|
||||
SpaceSeq *sseq = static_cast<SpaceSeq *>(area->spacedata.first);
|
||||
sseq->multiview_eye = sview;
|
||||
|
||||
if (region->regiontype == RGN_TYPE_PREVIEW) {
|
||||
@@ -454,7 +461,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C,
|
||||
ARegion *region,
|
||||
bool tag_redraw)
|
||||
{
|
||||
if (region->gizmo_map == NULL) {
|
||||
if (region->gizmo_map == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -494,12 +501,12 @@ static void wm_region_test_render_do_draw(const Scene *scene,
|
||||
{
|
||||
/* tag region for redraw from render engine preview running inside of it */
|
||||
if (area->spacetype == SPACE_VIEW3D && region->regiontype == RGN_TYPE_WINDOW) {
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
RenderEngine *engine = rv3d->view_render ? RE_view_engine_get(rv3d->view_render) : NULL;
|
||||
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||
RenderEngine *engine = rv3d->view_render ? RE_view_engine_get(rv3d->view_render) : nullptr;
|
||||
GPUViewport *viewport = WM_draw_region_get_viewport(region);
|
||||
|
||||
if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) {
|
||||
View3D *v3d = area->spacedata.first;
|
||||
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
|
||||
rcti border_rect;
|
||||
|
||||
/* do partial redraw when possible */
|
||||
@@ -524,7 +531,9 @@ static void wm_region_test_xr_do_draw(const wmWindowManager *wm,
|
||||
ARegion *region)
|
||||
{
|
||||
if ((area->spacetype == SPACE_VIEW3D) && (region->regiontype == RGN_TYPE_WINDOW)) {
|
||||
if (ED_view3d_is_region_xr_mirror_active(wm, area->spacedata.first, region)) {
|
||||
if (ED_view3d_is_region_xr_mirror_active(
|
||||
wm, static_cast<const View3D *>(area->spacedata.first), region))
|
||||
{
|
||||
ED_region_tag_redraw_no_rebuild(region);
|
||||
}
|
||||
}
|
||||
@@ -582,17 +591,16 @@ static const char *wm_area_name(ScrArea *area)
|
||||
* Reference method, draw all each time.
|
||||
* \{ */
|
||||
|
||||
typedef struct WindowDrawCB {
|
||||
struct WindowDrawCB {
|
||||
struct WindowDrawCB *next, *prev;
|
||||
|
||||
void (*draw)(const wmWindow *, void *);
|
||||
void *customdata;
|
||||
|
||||
} WindowDrawCB;
|
||||
};
|
||||
|
||||
void *WM_draw_cb_activate(wmWindow *win, void (*draw)(const wmWindow *, void *), void *customdata)
|
||||
{
|
||||
WindowDrawCB *wdc = MEM_callocN(sizeof(*wdc), "WindowDrawCB");
|
||||
WindowDrawCB *wdc = static_cast<WindowDrawCB *>(MEM_callocN(sizeof(*wdc), "WindowDrawCB"));
|
||||
|
||||
BLI_addtail(&win->drawcalls, wdc);
|
||||
wdc->draw = draw;
|
||||
@@ -641,7 +649,7 @@ static void wm_draw_region_buffer_free(ARegion *region)
|
||||
}
|
||||
|
||||
MEM_freeN(region->draw_buffer);
|
||||
region->draw_buffer = NULL;
|
||||
region->draw_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,7 +683,8 @@ static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_
|
||||
if (!region->draw_buffer) {
|
||||
if (use_viewport) {
|
||||
/* Allocate viewport which includes an off-screen buffer with depth multi-sample, etc. */
|
||||
region->draw_buffer = MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer");
|
||||
region->draw_buffer = static_cast<wmDrawBuffer *>(
|
||||
MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer"));
|
||||
region->draw_buffer->viewport = stereo ? GPU_viewport_stereo_create() :
|
||||
GPU_viewport_create();
|
||||
}
|
||||
@@ -684,7 +693,7 @@ static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_
|
||||
* depth or multi-sample buffers. 3D view creates own buffers with
|
||||
* the data it needs. */
|
||||
GPUOffScreen *offscreen = GPU_offscreen_create(
|
||||
region->winx, region->winy, false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
|
||||
region->winx, region->winy, false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
|
||||
if (!offscreen) {
|
||||
WM_report(RPT_ERROR, "Region could not be drawn!");
|
||||
return;
|
||||
@@ -692,7 +701,8 @@ static void wm_draw_region_buffer_create(ARegion *region, bool stereo, bool use_
|
||||
|
||||
wm_draw_offscreen_texture_parameters(offscreen);
|
||||
|
||||
region->draw_buffer = MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer");
|
||||
region->draw_buffer = static_cast<wmDrawBuffer *>(
|
||||
MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer"));
|
||||
region->draw_buffer->offscreen = offscreen;
|
||||
}
|
||||
|
||||
@@ -750,7 +760,7 @@ static void wm_draw_region_blit(ARegion *region, int view)
|
||||
view = 0;
|
||||
}
|
||||
else if (view > 0) {
|
||||
if (region->draw_buffer->viewport == NULL) {
|
||||
if (region->draw_buffer->viewport == nullptr) {
|
||||
/* Region does not need stereo or failed to allocate stereo buffers. */
|
||||
view = 0;
|
||||
}
|
||||
@@ -768,7 +778,7 @@ static void wm_draw_region_blit(ARegion *region, int view)
|
||||
GPUTexture *wm_draw_region_texture(ARegion *region, int view)
|
||||
{
|
||||
if (!region->draw_buffer) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUViewport *viewport = region->draw_buffer->viewport;
|
||||
@@ -826,7 +836,8 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
|
||||
|
||||
/* Not the same layout as #rctf/#rcti. */
|
||||
const float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax};
|
||||
const float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax};
|
||||
const float rectg[4] = {
|
||||
float(rect_geo.xmin), float(rect_geo.ymin), float(rect_geo.xmax), float(rect_geo.ymax)};
|
||||
|
||||
if (blend) {
|
||||
/* Regions drawn off-screen have pre-multiplied alpha. */
|
||||
@@ -848,7 +859,7 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
|
||||
|
||||
GPU_shader_uniform_float_ex(shader, rect_tex_loc, 4, 1, rectt);
|
||||
GPU_shader_uniform_float_ex(shader, rect_geo_loc, 4, 1, rectg);
|
||||
GPU_shader_uniform_float_ex(shader, color_loc, 4, 1, (const float[4]){1, 1, 1, 1});
|
||||
GPU_shader_uniform_float_ex(shader, color_loc, 4, 1, blender::float4{1, 1, 1, 1});
|
||||
|
||||
GPUBatch *quad = GPU_batch_preset_quad();
|
||||
GPU_batch_set_shader(quad, shader);
|
||||
@@ -864,7 +875,7 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
|
||||
GPUViewport *WM_draw_region_get_viewport(ARegion *region)
|
||||
{
|
||||
if (!region->draw_buffer) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUViewport *viewport = region->draw_buffer->viewport;
|
||||
@@ -874,7 +885,7 @@ GPUViewport *WM_draw_region_get_viewport(ARegion *region)
|
||||
GPUViewport *WM_draw_region_get_bound_viewport(ARegion *region)
|
||||
{
|
||||
if (!region->draw_buffer || region->draw_buffer->bound_view == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUViewport *viewport = region->draw_buffer->viewport;
|
||||
@@ -909,7 +920,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
|
||||
{
|
||||
CTX_wm_region_set(C, region);
|
||||
ED_region_do_layout(C, region);
|
||||
CTX_wm_region_set(C, NULL);
|
||||
CTX_wm_region_set(C, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,10 +978,10 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
|
||||
GPU_debug_group_end();
|
||||
|
||||
region->do_draw = false;
|
||||
CTX_wm_region_set(C, NULL);
|
||||
CTX_wm_region_set(C, nullptr);
|
||||
}
|
||||
|
||||
CTX_wm_area_set(C, NULL);
|
||||
CTX_wm_area_set(C, nullptr);
|
||||
|
||||
GPU_debug_group_end();
|
||||
}
|
||||
@@ -1000,7 +1011,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
|
||||
GPU_debug_group_end();
|
||||
|
||||
region->do_draw = false;
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
CTX_wm_menu_set(C, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,11 +1025,11 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
|
||||
/* Draw into the window frame-buffer, in full window coordinates. */
|
||||
wmWindowViewport(win);
|
||||
|
||||
/* We draw on all pixels of the windows so we don't need to clear them before.
|
||||
* Actually this is only a problem when resizing the window.
|
||||
* If it becomes a problem we should clear only when window size changes. */
|
||||
/* We draw on all pixels of the windows so we don't need to clear them before.
|
||||
* Actually this is only a problem when resizing the window.
|
||||
* If it becomes a problem we should clear only when window size changes. */
|
||||
#if 0
|
||||
GPU_clear_color(0, 0, 0, 0);
|
||||
GPU_clear_color(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
/* Blit non-overlapping area regions. */
|
||||
@@ -1055,8 +1066,8 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
|
||||
if (do_paint_cursor) {
|
||||
wm_paintcursor_draw(C, area, region);
|
||||
}
|
||||
CTX_wm_region_set(C, NULL);
|
||||
CTX_wm_area_set(C, NULL);
|
||||
CTX_wm_region_set(C, nullptr);
|
||||
CTX_wm_area_set(C, nullptr);
|
||||
}
|
||||
}
|
||||
wmWindowViewport(win);
|
||||
@@ -1115,7 +1126,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
|
||||
|
||||
static void wm_draw_window(bContext *C, wmWindow *win)
|
||||
{
|
||||
GPU_context_begin_frame(win->gpuctx);
|
||||
GPU_context_begin_frame(static_cast<GPUContext *>(win->gpuctx));
|
||||
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
bool stereo = WM_stereo3d_enabled(win, false);
|
||||
@@ -1152,7 +1163,7 @@ static void wm_draw_window(bContext *C, wmWindow *win)
|
||||
const int width = WM_window_pixels_x(win);
|
||||
const int height = WM_window_pixels_y(win);
|
||||
GPUOffScreen *offscreen = GPU_offscreen_create(
|
||||
width, height, false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
|
||||
width, height, false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
|
||||
|
||||
if (offscreen) {
|
||||
GPUTexture *texture = GPU_offscreen_color_texture(offscreen);
|
||||
@@ -1188,7 +1199,7 @@ static void wm_draw_window(bContext *C, wmWindow *win)
|
||||
|
||||
screen->do_draw = false;
|
||||
|
||||
GPU_context_end_frame(win->gpuctx);
|
||||
GPU_context_end_frame(static_cast<GPUContext *>(win->gpuctx));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1233,21 +1244,22 @@ uint8_t *WM_window_pixels_read_from_frontbuffer(const wmWindowManager *wm,
|
||||
bool setup_context = wm->windrawable != win;
|
||||
|
||||
if (setup_context) {
|
||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||
GPU_context_active_set(win->gpuctx);
|
||||
GHOST_ActivateWindowDrawingContext(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
GPU_context_active_set(static_cast<GPUContext *>(win->gpuctx));
|
||||
}
|
||||
|
||||
r_size[0] = WM_window_pixels_x(win);
|
||||
r_size[1] = WM_window_pixels_y(win);
|
||||
const uint rect_len = r_size[0] * r_size[1];
|
||||
uint8_t *rect = MEM_mallocN(4 * sizeof(uint8_t) * rect_len, __func__);
|
||||
uint8_t *rect = static_cast<uint8_t *>(MEM_mallocN(4 * sizeof(uint8_t) * rect_len, __func__));
|
||||
|
||||
GPU_frontbuffer_read_color(0, 0, r_size[0], r_size[1], 4, GPU_DATA_UBYTE, rect);
|
||||
|
||||
if (setup_context) {
|
||||
if (wm->windrawable) {
|
||||
GHOST_ActivateWindowDrawingContext(wm->windrawable->ghostwin);
|
||||
GPU_context_active_set(wm->windrawable->gpuctx);
|
||||
GHOST_ActivateWindowDrawingContext(
|
||||
static_cast<GHOST_WindowHandle>(wm->windrawable->ghostwin));
|
||||
GPU_context_active_set(static_cast<GPUContext *>(wm->windrawable->gpuctx));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1269,16 +1281,17 @@ void WM_window_pixels_read_sample_from_frontbuffer(const wmWindowManager *wm,
|
||||
bool setup_context = wm->windrawable != win;
|
||||
|
||||
if (setup_context) {
|
||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||
GPU_context_active_set(win->gpuctx);
|
||||
GHOST_ActivateWindowDrawingContext(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
GPU_context_active_set(static_cast<GPUContext *>(win->gpuctx));
|
||||
}
|
||||
|
||||
GPU_frontbuffer_read_color(pos[0], pos[1], 1, 1, 3, GPU_DATA_FLOAT, r_col);
|
||||
|
||||
if (setup_context) {
|
||||
if (wm->windrawable) {
|
||||
GHOST_ActivateWindowDrawingContext(wm->windrawable->ghostwin);
|
||||
GPU_context_active_set(wm->windrawable->gpuctx);
|
||||
GHOST_ActivateWindowDrawingContext(
|
||||
static_cast<GHOST_WindowHandle>(wm->windrawable->ghostwin));
|
||||
GPU_context_active_set(static_cast<GPUContext *>(wm->windrawable->gpuctx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1302,13 +1315,13 @@ uint8_t *WM_window_pixels_read_from_offscreen(bContext *C, wmWindow *win, int r_
|
||||
r_size[1] = WM_window_pixels_y(win);
|
||||
|
||||
GPUOffScreen *offscreen = GPU_offscreen_create(
|
||||
r_size[0], r_size[1], false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
|
||||
r_size[0], r_size[1], false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
|
||||
if (UNLIKELY(!offscreen)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const uint rect_len = r_size[0] * r_size[1];
|
||||
uint8_t *rect = MEM_mallocN(4 * sizeof(uint8_t) * rect_len, __func__);
|
||||
uint8_t *rect = static_cast<uint8_t *>(MEM_mallocN(4 * sizeof(uint8_t) * rect_len, __func__));
|
||||
GPU_offscreen_bind(offscreen, false);
|
||||
wm_draw_window_onscreen(C, win, -1);
|
||||
GPU_offscreen_unbind(offscreen, false);
|
||||
@@ -1333,7 +1346,7 @@ bool WM_window_pixels_read_sample_from_offscreen(bContext *C,
|
||||
}
|
||||
|
||||
GPUOffScreen *offscreen = GPU_offscreen_create(
|
||||
size[0], size[1], false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
|
||||
size[0], size[1], false, GPU_RGBA8, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
|
||||
if (UNLIKELY(!offscreen)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1465,7 +1478,7 @@ static void wm_draw_update_clear_window(bContext *C, wmWindow *win)
|
||||
screen->do_draw_drag = false;
|
||||
}
|
||||
|
||||
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(region))
|
||||
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion * /*region*/)
|
||||
{
|
||||
if (win) {
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
@@ -1487,7 +1500,8 @@ void wm_draw_update(bContext *C)
|
||||
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
#ifdef WIN32
|
||||
GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin);
|
||||
GHOST_TWindowState state = GHOST_GetWindowState(
|
||||
static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
if (state == GHOST_kWindowStateMinimized) {
|
||||
/* do not update minimized windows, gives issues on Intel (see #33223)
|
||||
@@ -1516,7 +1530,7 @@ void wm_draw_update(bContext *C)
|
||||
}
|
||||
}
|
||||
|
||||
CTX_wm_window_set(C, NULL);
|
||||
CTX_wm_window_set(C, nullptr);
|
||||
|
||||
/* Draw non-windows (surfaces) */
|
||||
wm_surfaces_iter(C, wm_draw_surface);
|
||||
@@ -1525,7 +1539,7 @@ void wm_draw_update(bContext *C)
|
||||
GPU_context_main_unlock();
|
||||
}
|
||||
|
||||
void wm_draw_region_clear(wmWindow *win, ARegion *UNUSED(region))
|
||||
void wm_draw_region_clear(wmWindow *win, ARegion * /*region*/)
|
||||
{
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
screen->do_draw = true;
|
||||
@@ -134,9 +134,9 @@ void WM_event_print(const wmEvent *event)
|
||||
|
||||
#ifdef WITH_INPUT_NDOF
|
||||
if (ISNDOF(event->type)) {
|
||||
const wmNDOFMotionData *ndof = event->customdata;
|
||||
const wmNDOFMotionData *ndof = static_cast<const wmNDOFMotionData *>(event->customdata);
|
||||
if (event->type == NDOF_MOTION) {
|
||||
printf(", ndof: rot: (%.4f %.4f %.4f), tx: (%.4f %.4f %.4f), dt: %.4f, progress: %u",
|
||||
printf(", ndof: rot: (%.4f %.4f %.4f), tx: (%.4f %.4f %.4f), dt: %.4f, progress: %d",
|
||||
UNPACK3(ndof->rvec),
|
||||
UNPACK3(ndof->tvec),
|
||||
ndof->dt,
|
||||
@@ -159,7 +159,7 @@ void WM_event_print(const wmEvent *event)
|
||||
printf("\n");
|
||||
}
|
||||
else {
|
||||
printf("wmEvent - NULL\n");
|
||||
printf("wmEvent - nullptr\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ static bool wm_link_append_poll(bContext *C)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int wm_link_append_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
const char *blendfile_path = BKE_main_blendfile_path_from_global();
|
||||
@@ -266,7 +266,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
"Scene '%s' is linked, instantiation of objects is disabled",
|
||||
scene->id.name + 2);
|
||||
flag &= ~(BLO_LIBLINK_COLLECTION_INSTANCE | BLO_LIBLINK_OBDATA_INSTANCE);
|
||||
scene = NULL;
|
||||
scene = nullptr;
|
||||
}
|
||||
|
||||
/* from here down, no error returns */
|
||||
@@ -301,14 +301,14 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
BLI_path_join(filepath, sizeof(filepath), root, relname);
|
||||
|
||||
if (BKE_blendfile_library_path_explode(filepath, libname, &group, &name)) {
|
||||
if (!wm_link_append_item_poll(NULL, filepath, group, name, do_append)) {
|
||||
if (!wm_link_append_item_poll(nullptr, filepath, group, name, do_append)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!BLI_ghash_haskey(libraries, libname)) {
|
||||
BLI_ghash_insert(libraries, BLI_strdup(libname), POINTER_FROM_INT(lib_idx));
|
||||
lib_idx++;
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, libname, NULL);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, libname, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,20 +329,20 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
lib_idx = POINTER_AS_INT(BLI_ghash_lookup(libraries, libname));
|
||||
|
||||
item = BKE_blendfile_link_append_context_item_add(
|
||||
lapp_context, name, BKE_idtype_idcode_from_name(group), NULL);
|
||||
lapp_context, name, BKE_idtype_idcode_from_name(group), nullptr);
|
||||
BKE_blendfile_link_append_context_item_library_index_enable(lapp_context, item, lib_idx);
|
||||
}
|
||||
}
|
||||
RNA_END;
|
||||
|
||||
BLI_ghash_free(libraries, MEM_freeN, NULL);
|
||||
BLI_ghash_free(libraries, MEM_freeN, nullptr);
|
||||
}
|
||||
else {
|
||||
BlendfileLinkAppendContextItem *item;
|
||||
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, libname, NULL);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, libname, nullptr);
|
||||
item = BKE_blendfile_link_append_context_item_add(
|
||||
lapp_context, name, BKE_idtype_idcode_from_name(group), NULL);
|
||||
lapp_context, name, BKE_idtype_idcode_from_name(group), nullptr);
|
||||
BKE_blendfile_link_append_context_item_library_index_enable(lapp_context, item, 0);
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
|
||||
/* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */
|
||||
STRNCPY(G.lib, root);
|
||||
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -535,16 +535,16 @@ static ID *wm_file_link_append_datablock_ex(Main *bmain,
|
||||
BKE_blendfile_link_append_context_embedded_blendfile_set(
|
||||
lapp_context, datatoc_startup_blend, datatoc_startup_blend_size);
|
||||
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, nullptr);
|
||||
BlendfileLinkAppendContextItem *item = BKE_blendfile_link_append_context_item_add(
|
||||
lapp_context, id_name, id_code, NULL);
|
||||
lapp_context, id_name, id_code, nullptr);
|
||||
BKE_blendfile_link_append_context_item_library_index_enable(lapp_context, item, 0);
|
||||
|
||||
/* Link datablock. */
|
||||
BKE_blendfile_link(lapp_context, NULL);
|
||||
BKE_blendfile_link(lapp_context, nullptr);
|
||||
|
||||
if (do_append) {
|
||||
BKE_blendfile_append(lapp_context, NULL);
|
||||
BKE_blendfile_append(lapp_context, nullptr);
|
||||
}
|
||||
|
||||
/* Get linked datablock and free working data. */
|
||||
@@ -593,7 +593,7 @@ ID *WM_file_append_datablock(Main *bmain,
|
||||
/** \name Library Relocate Operator & Library Reload API
|
||||
* \{ */
|
||||
|
||||
static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Library *lib;
|
||||
char lib_name[MAX_NAME];
|
||||
@@ -644,11 +644,11 @@ void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
|
||||
0,
|
||||
CTX_data_scene(C),
|
||||
CTX_data_view_layer(C),
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
BlendfileLinkAppendContext *lapp_context = BKE_blendfile_link_append_context_new(&lapp_params);
|
||||
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, lib->filepath_abs, NULL);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, lib->filepath_abs, nullptr);
|
||||
|
||||
BKE_blendfile_library_relocate(lapp_context, reports, lib, true);
|
||||
|
||||
@@ -664,7 +664,7 @@ void WM_lib_reload(Library *lib, bContext *C, ReportList *reports)
|
||||
/* Recreate dependency graph to include new IDs. */
|
||||
DEG_relations_tag_update(bmain);
|
||||
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
}
|
||||
|
||||
static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
||||
@@ -674,7 +674,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
||||
|
||||
RNA_string_get(op->ptr, "library", lib_name);
|
||||
Library *lib = (Library *)BKE_libblock_find_name(bmain, ID_LI, lib_name);
|
||||
if (lib == NULL) {
|
||||
if (lib == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
||||
|
||||
LibraryLink_Params lapp_params;
|
||||
BLO_library_link_params_init_with_context(
|
||||
&lapp_params, bmain, flag, 0, CTX_data_scene(C), CTX_data_view_layer(C), NULL);
|
||||
&lapp_params, bmain, flag, 0, CTX_data_scene(C), CTX_data_view_layer(C), nullptr);
|
||||
|
||||
if (BLI_path_cmp(lib->filepath_abs, filepath) == 0) {
|
||||
CLOG_INFO(&LOG, 4, "We are supposed to reload '%s' lib (%d)", lib->filepath, lib->id.us);
|
||||
@@ -734,7 +734,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
||||
do_reload = true;
|
||||
|
||||
lapp_context = BKE_blendfile_link_append_context_new(&lapp_params);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, nullptr);
|
||||
}
|
||||
else {
|
||||
int totfiles = 0;
|
||||
@@ -768,13 +768,13 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
||||
}
|
||||
|
||||
CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", filepath);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, nullptr);
|
||||
}
|
||||
RNA_END;
|
||||
}
|
||||
else {
|
||||
CLOG_INFO(&LOG, 4, "\tCandidate new lib to reload datablocks from: %s", filepath);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, NULL);
|
||||
BKE_blendfile_link_append_context_library_add(lapp_context, filepath, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
||||
/* Recreate dependency graph to include new IDs. */
|
||||
DEG_relations_tag_update(bmain);
|
||||
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -824,7 +824,7 @@ void WM_OT_lib_relocate(wmOperatorType *ot)
|
||||
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
||||
prop = RNA_def_string(ot->srna, "library", NULL, MAX_NAME, "Library", "Library to relocate");
|
||||
prop = RNA_def_string(ot->srna, "library", nullptr, MAX_NAME, "Library", "Library to relocate");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
|
||||
WM_operator_properties_filesel(ot,
|
||||
@@ -854,7 +854,7 @@ void WM_OT_lib_reload(wmOperatorType *ot)
|
||||
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
||||
prop = RNA_def_string(ot->srna, "library", NULL, MAX_NAME, "Library", "Library to reload");
|
||||
prop = RNA_def_string(ot->srna, "library", nullptr, MAX_NAME, "Library", "Library to reload");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
|
||||
WM_operator_properties_filesel(ot,
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent *event, int type)
|
||||
{
|
||||
wmGesture *gesture = MEM_callocN(sizeof(wmGesture), "new gesture");
|
||||
wmGesture *gesture = static_cast<wmGesture *>(MEM_callocN(sizeof(wmGesture), "new gesture"));
|
||||
|
||||
BLI_addtail(&window->gesture, gesture);
|
||||
|
||||
@@ -58,7 +58,7 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent
|
||||
WM_GESTURE_CROSS_RECT,
|
||||
WM_GESTURE_CIRCLE,
|
||||
WM_GESTURE_STRAIGHTLINE)) {
|
||||
rcti *rect = MEM_callocN(sizeof(rcti), "gesture rect new");
|
||||
rcti *rect = static_cast<rcti *>(MEM_callocN(sizeof(rcti), "gesture rect new"));
|
||||
|
||||
gesture->customdata = rect;
|
||||
rect->xmin = xy[0] - gesture->winrct.xmin;
|
||||
@@ -74,8 +74,8 @@ wmGesture *WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent
|
||||
else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) {
|
||||
short *lasso;
|
||||
gesture->points_alloc = 1024;
|
||||
gesture->customdata = lasso = MEM_mallocN(sizeof(short[2]) * gesture->points_alloc,
|
||||
"lasso points");
|
||||
gesture->customdata = lasso = static_cast<short int *>(
|
||||
MEM_mallocN(sizeof(short[2]) * gesture->points_alloc, "lasso points"));
|
||||
lasso[0] = xy[0] - gesture->winrct.xmin;
|
||||
lasso[1] = xy[1] - gesture->winrct.ymin;
|
||||
gesture->points = 1;
|
||||
@@ -95,20 +95,20 @@ void WM_gesture_end(wmWindow *win, wmGesture *gesture)
|
||||
void WM_gestures_free_all(wmWindow *win)
|
||||
{
|
||||
while (win->gesture.first) {
|
||||
WM_gesture_end(win, win->gesture.first);
|
||||
WM_gesture_end(win, static_cast<wmGesture *>(win->gesture.first));
|
||||
}
|
||||
}
|
||||
|
||||
void WM_gestures_remove(wmWindow *win)
|
||||
{
|
||||
while (win->gesture.first) {
|
||||
WM_gesture_end(win, win->gesture.first);
|
||||
WM_gesture_end(win, static_cast<wmGesture *>(win->gesture.first));
|
||||
}
|
||||
}
|
||||
|
||||
bool WM_gesture_is_modal_first(const wmGesture *gesture)
|
||||
{
|
||||
if (gesture == NULL) {
|
||||
if (gesture == nullptr) {
|
||||
return true;
|
||||
}
|
||||
return (gesture->is_active_prev == false);
|
||||
@@ -130,8 +130,8 @@ static void wm_gesture_draw_line_active_side(rcti *rect, const bool flip)
|
||||
float gradient_dir[2];
|
||||
float gradient_point[2][2];
|
||||
|
||||
const float line_start[2] = {rect->xmin, rect->ymin};
|
||||
const float line_end[2] = {rect->xmax, rect->ymax};
|
||||
const float line_start[2] = {float(rect->xmin), float(rect->ymin)};
|
||||
const float line_end[2] = {float(rect->xmax), float(rect->ymax)};
|
||||
const float color_line_gradient_start[4] = {0.2f, 0.2f, 0.2f, 0.4f};
|
||||
const float color_line_gradient_end[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
@@ -282,7 +282,7 @@ struct LassoFillData {
|
||||
|
||||
static void draw_filled_lasso_px_cb(int x, int x_end, int y, void *user_data)
|
||||
{
|
||||
struct LassoFillData *data = user_data;
|
||||
struct LassoFillData *data = static_cast<LassoFillData *>(user_data);
|
||||
uchar *col = &(data->px[(y * data->width) + x]);
|
||||
memset(col, 0x10, x_end - x);
|
||||
}
|
||||
@@ -291,7 +291,8 @@ static void draw_filled_lasso(wmGesture *gt)
|
||||
{
|
||||
const short *lasso = (short *)gt->customdata;
|
||||
const int mcoords_len = gt->points;
|
||||
int(*mcoords)[2] = MEM_mallocN(sizeof(*mcoords) * (mcoords_len + 1), __func__);
|
||||
int(*mcoords)[2] = static_cast<int(*)[2]>(
|
||||
MEM_mallocN(sizeof(*mcoords) * (mcoords_len + 1), __func__));
|
||||
int i;
|
||||
rcti rect;
|
||||
const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
|
||||
@@ -311,7 +312,7 @@ static void draw_filled_lasso(wmGesture *gt)
|
||||
if (BLI_rcti_is_empty(&rect) == false) {
|
||||
const int w = BLI_rcti_size_x(&rect);
|
||||
const int h = BLI_rcti_size_y(&rect);
|
||||
uchar *pixel_buf = MEM_callocN(sizeof(*pixel_buf) * w * h, __func__);
|
||||
uchar *pixel_buf = static_cast<uchar *>(MEM_callocN(sizeof(*pixel_buf) * w * h, __func__));
|
||||
struct LassoFillData lasso_fill_data = {pixel_buf, w};
|
||||
|
||||
BLI_bitmap_draw_2d_poly_v2i_n(rect.xmin,
|
||||
@@ -331,7 +332,7 @@ static void draw_filled_lasso(wmGesture *gt)
|
||||
state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red);
|
||||
|
||||
immDrawPixelsTexTiled(
|
||||
&state, rect.xmin, rect.ymin, w, h, GPU_R8, false, pixel_buf, 1.0f, 1.0f, NULL);
|
||||
&state, rect.xmin, rect.ymin, w, h, GPU_R8, false, pixel_buf, 1.0f, 1.0f, nullptr);
|
||||
|
||||
GPU_shader_unbind();
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
static void gesture_modal_end(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
|
||||
WM_gesture_end(win, gesture); /* frees gesture itself, and unregisters from window */
|
||||
op->customdata = NULL;
|
||||
op->customdata = nullptr;
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
@@ -125,8 +125,8 @@ static int UNUSED_FUNCTION(gesture_modal_state_from_operator)(wmOperator *op)
|
||||
|
||||
static bool gesture_box_apply_rect(wmOperator *op)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
rcti *rect = gesture->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
if (rect->xmin == rect->xmax || rect->ymin == rect->ymax) {
|
||||
return 0;
|
||||
@@ -143,7 +143,7 @@ static bool gesture_box_apply_rect(wmOperator *op)
|
||||
|
||||
static bool gesture_box_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
|
||||
int retval;
|
||||
|
||||
@@ -176,7 +176,7 @@ int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
}
|
||||
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
gesture->wait_for_input = wait_for_input;
|
||||
}
|
||||
|
||||
@@ -191,8 +191,8 @@ int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wmGesture *gesture = op->customdata;
|
||||
rcti *rect = gesture->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
if (event->type == EVT_MODAL_MAP) {
|
||||
switch (event->val) {
|
||||
@@ -291,8 +291,8 @@ int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
RNA_boolean_get(op->ptr, "wait_for_input");
|
||||
|
||||
op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_CIRCLE);
|
||||
wmGesture *gesture = op->customdata;
|
||||
rcti *rect = gesture->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
/* Default or previously stored value. */
|
||||
rect->xmax = RNA_int_get(op->ptr, "radius");
|
||||
@@ -317,8 +317,8 @@ int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
static void gesture_circle_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
rcti *rect = gesture->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
if (gesture->wait_for_input && (gesture->modal_state == GESTURE_MODAL_NOP)) {
|
||||
return;
|
||||
@@ -346,8 +346,8 @@ static void gesture_circle_apply(bContext *C, wmOperator *op)
|
||||
int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wmGesture *gesture = op->customdata;
|
||||
rcti *rect = gesture->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
if (event->type == MOUSEMOVE) {
|
||||
|
||||
@@ -516,11 +516,11 @@ int WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int gesture_lasso_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
int retval = OPERATOR_FINISHED;
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
PointerRNA itemptr;
|
||||
float loc[2];
|
||||
int i;
|
||||
const short *lasso = gesture->customdata;
|
||||
const short *lasso = static_cast<const short int *>(gesture->customdata);
|
||||
|
||||
/* operator storage as path. */
|
||||
|
||||
@@ -544,7 +544,7 @@ static int gesture_lasso_apply(bContext *C, wmOperator *op)
|
||||
|
||||
int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
|
||||
if (event->type == EVT_MODAL_MAP) {
|
||||
switch (event->val) {
|
||||
@@ -567,7 +567,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
}
|
||||
|
||||
{
|
||||
short(*lasso)[2] = gesture->customdata;
|
||||
short(*lasso)[2] = static_cast<short int(*)[2]>(gesture->customdata);
|
||||
|
||||
const int x = ((event->xy[0] - gesture->winrct.xmin) - lasso[gesture->points - 1][0]);
|
||||
const int y = ((event->xy[1] - gesture->winrct.ymin) - lasso[gesture->points - 1][1]);
|
||||
@@ -623,20 +623,20 @@ void WM_gesture_lines_cancel(bContext *C, wmOperator *op)
|
||||
gesture_modal_end(C, op);
|
||||
}
|
||||
|
||||
const int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C),
|
||||
const int (*WM_gesture_lasso_path_to_array(bContext * /*C*/,
|
||||
wmOperator *op,
|
||||
int *r_mcoords_len))[2]
|
||||
{
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "path");
|
||||
int(*mcoords)[2] = NULL;
|
||||
BLI_assert(prop != NULL);
|
||||
int(*mcoords)[2] = nullptr;
|
||||
BLI_assert(prop != nullptr);
|
||||
|
||||
if (prop) {
|
||||
const int len = RNA_property_collection_length(op->ptr, prop);
|
||||
|
||||
if (len) {
|
||||
int i = 0;
|
||||
mcoords = MEM_mallocN(sizeof(int[2]) * len, __func__);
|
||||
mcoords = static_cast<int(*)[2]>(MEM_mallocN(sizeof(int[2]) * len, __func__));
|
||||
|
||||
RNA_PROP_BEGIN (op->ptr, itemptr, prop) {
|
||||
float loc[2];
|
||||
@@ -712,8 +712,8 @@ void WM_OT_lasso_gesture(wmOperatorType *ot)
|
||||
|
||||
static bool gesture_straightline_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
rcti *rect = gesture->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
if (rect->xmin == rect->xmax && rect->ymin == rect->ymax) {
|
||||
return 0;
|
||||
@@ -742,7 +742,7 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_STRAIGHTLINE);
|
||||
|
||||
if (WM_event_is_mouse_drag_or_press(event)) {
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
gesture->is_active = true;
|
||||
}
|
||||
|
||||
@@ -760,7 +760,7 @@ int WM_gesture_straightline_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
int WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
WM_gesture_straightline_invoke(C, op, event);
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
gesture->draw_active_side = true;
|
||||
gesture->use_flip = false;
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@@ -769,8 +769,8 @@ int WM_gesture_straightline_active_side_invoke(bContext *C, wmOperator *op, cons
|
||||
#define STRAIGHTLINE_SNAP_DEG 15.0f
|
||||
static void wm_gesture_straightline_do_angle_snap(rcti *rect)
|
||||
{
|
||||
const float line_start[2] = {rect->xmin, rect->ymin};
|
||||
const float line_end[2] = {rect->xmax, rect->ymax};
|
||||
const float line_start[2] = {float(rect->xmin), float(rect->ymin)};
|
||||
const float line_end[2] = {float(rect->xmax), float(rect->ymax)};
|
||||
const float x_axis[2] = {1.0f, 0.0f};
|
||||
|
||||
float line_direction[2];
|
||||
@@ -794,9 +794,9 @@ static void wm_gesture_straightline_do_angle_snap(rcti *rect)
|
||||
|
||||
int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
rcti *rect = gesture->customdata;
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
if (event->type == EVT_MODAL_MAP) {
|
||||
switch (event->val) {
|
||||
@@ -874,9 +874,9 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
|
||||
|
||||
int WM_gesture_straightline_oneshot_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmGesture *gesture = op->customdata;
|
||||
wmGesture *gesture = static_cast<wmGesture *>(op->customdata);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
rcti *rect = gesture->customdata;
|
||||
rcti *rect = static_cast<rcti *>(gesture->customdata);
|
||||
|
||||
if (event->type == EVT_MODAL_MAP) {
|
||||
switch (event->val) {
|
||||
@@ -179,7 +179,7 @@ static wmJob *wm_job_find(const wmWindowManager *wm, const void *owner, const eW
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* ******************* public API ***************** */
|
||||
@@ -193,8 +193,8 @@ wmJob *WM_jobs_get(wmWindowManager *wm,
|
||||
{
|
||||
wmJob *wm_job = wm_job_find(wm, owner, job_type);
|
||||
|
||||
if (wm_job == NULL) {
|
||||
wm_job = MEM_callocN(sizeof(wmJob), "new job");
|
||||
if (wm_job == nullptr) {
|
||||
wm_job = static_cast<wmJob *>(MEM_callocN(sizeof(wmJob), "new job"));
|
||||
|
||||
BLI_addtail(&wm->jobs, wm_job);
|
||||
wm_job->win = win;
|
||||
@@ -294,18 +294,18 @@ const char *WM_jobs_name(const wmWindowManager *wm, const void *owner)
|
||||
return wm_job->name;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *WM_jobs_customdata_from_type(wmWindowManager *wm, const void *owner, int job_type)
|
||||
{
|
||||
wmJob *wm_job = wm_job_find(wm, owner, job_type);
|
||||
wmJob *wm_job = wm_job_find(wm, owner, eWM_JobType(job_type));
|
||||
|
||||
if (wm_job) {
|
||||
return WM_jobs_customdata_get(wm_job);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool WM_jobs_is_running(const wmJob *wm_job)
|
||||
@@ -361,7 +361,7 @@ void WM_jobs_callbacks(wmJob *wm_job,
|
||||
void (*update)(void *),
|
||||
void (*endjob)(void *))
|
||||
{
|
||||
WM_jobs_callbacks_ex(wm_job, startjob, initjob, update, endjob, NULL, NULL);
|
||||
WM_jobs_callbacks_ex(wm_job, startjob, initjob, update, endjob, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void WM_jobs_callbacks_ex(wmJob *wm_job,
|
||||
@@ -382,12 +382,12 @@ void WM_jobs_callbacks_ex(wmJob *wm_job,
|
||||
|
||||
static void *do_job_thread(void *job_v)
|
||||
{
|
||||
wmJob *wm_job = job_v;
|
||||
wmJob *wm_job = static_cast<wmJob *>(job_v);
|
||||
|
||||
wm_job->startjob(wm_job->run_customdata, &wm_job->stop, &wm_job->do_update, &wm_job->progress);
|
||||
wm_job->ready = true;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* don't allow same startjob to be executed twice */
|
||||
@@ -460,8 +460,8 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
|
||||
/* copy to ensure proper free in end */
|
||||
wm_job->run_customdata = wm_job->customdata;
|
||||
wm_job->run_free = wm_job->free;
|
||||
wm_job->free = NULL;
|
||||
wm_job->customdata = NULL;
|
||||
wm_job->free = nullptr;
|
||||
wm_job->customdata = nullptr;
|
||||
wm_job->running = true;
|
||||
|
||||
if (wm_job->initjob) {
|
||||
@@ -483,7 +483,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
|
||||
WM_event_timer_remove(wm, wm_job->win, wm_job->wt);
|
||||
wm_job->wt = WM_event_timer_add(wm, wm_job->win, TIMERJOBS, timestep);
|
||||
}
|
||||
if (wm_job->wt == NULL) {
|
||||
if (wm_job->wt == nullptr) {
|
||||
wm_job->wt = WM_event_timer_add(wm, wm_job->win, TIMERJOBS, timestep);
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ void WM_jobs_kill_all(wmWindowManager *wm)
|
||||
{
|
||||
wmJob *wm_job;
|
||||
|
||||
while ((wm_job = wm->jobs.first)) {
|
||||
while ((wm_job = static_cast<wmJob *>(wm->jobs.first))) {
|
||||
wm_jobs_kill_job(wm, wm_job);
|
||||
}
|
||||
|
||||
@@ -639,11 +639,11 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt)
|
||||
wm_job->update(wm_job->run_customdata);
|
||||
}
|
||||
if (wm_job->note) {
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, wm_job->note, NULL);
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, wm_job->note, nullptr);
|
||||
}
|
||||
|
||||
if (wm_job->flag & WM_JOB_PROGRESS) {
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, NC_WM | ND_JOB, NULL);
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, NC_WM | ND_JOB, nullptr);
|
||||
}
|
||||
wm_job->do_update = false;
|
||||
}
|
||||
@@ -653,16 +653,16 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt)
|
||||
|
||||
/* free own data */
|
||||
wm_job->run_free(wm_job->run_customdata);
|
||||
wm_job->run_customdata = NULL;
|
||||
wm_job->run_free = NULL;
|
||||
wm_job->run_customdata = nullptr;
|
||||
wm_job->run_free = nullptr;
|
||||
|
||||
#if 0
|
||||
if (wm_job->stop) {
|
||||
printf("job ready but stopped %s\n", wm_job->name);
|
||||
}
|
||||
else {
|
||||
printf("job finished %s\n", wm_job->name);
|
||||
}
|
||||
if (wm_job->stop) {
|
||||
printf("job ready but stopped %s\n", wm_job->name);
|
||||
}
|
||||
else {
|
||||
printf("job finished %s\n", wm_job->name);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (G.debug & G_DEBUG_JOBS) {
|
||||
@@ -678,10 +678,10 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt)
|
||||
WM_job_main_thread_lock_acquire(wm_job);
|
||||
|
||||
if (wm_job->endnote) {
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, wm_job->endnote, NULL);
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, wm_job->endnote, nullptr);
|
||||
}
|
||||
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, NC_WM | ND_JOB, NULL);
|
||||
WM_event_add_notifier_ex(wm, wm_job->win, NC_WM | ND_JOB, nullptr);
|
||||
|
||||
/* new job added for wm_job? */
|
||||
if (wm_job->customdata) {
|
||||
@@ -690,7 +690,7 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt)
|
||||
}
|
||||
else {
|
||||
WM_event_timer_remove(wm, wm_job->win, wm_job->wt);
|
||||
wm_job->wt = NULL;
|
||||
wm_job->wt = nullptr;
|
||||
|
||||
/* remove wm_job */
|
||||
wm_job_free(wm, wm_job);
|
||||
@@ -59,24 +59,24 @@ struct wmKeyMapItemFind_Params {
|
||||
|
||||
static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
|
||||
{
|
||||
wmKeyMapItem *kmin = MEM_dupallocN(kmi);
|
||||
wmKeyMapItem *kmin = static_cast<wmKeyMapItem *>(MEM_dupallocN(kmi));
|
||||
|
||||
kmin->prev = kmin->next = NULL;
|
||||
kmin->prev = kmin->next = nullptr;
|
||||
kmin->flag &= ~KMI_UPDATE;
|
||||
|
||||
if (kmin->properties) {
|
||||
kmin->ptr = MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr");
|
||||
kmin->ptr = static_cast<PointerRNA *>(MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr"));
|
||||
WM_operator_properties_create(kmin->ptr, kmin->idname);
|
||||
|
||||
/* Signal for no context, see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */
|
||||
kmin->ptr->owner_id = NULL;
|
||||
kmin->ptr->owner_id = nullptr;
|
||||
|
||||
kmin->properties = IDP_CopyProperty(kmin->properties);
|
||||
kmin->ptr->data = kmin->properties;
|
||||
}
|
||||
else {
|
||||
kmin->properties = NULL;
|
||||
kmin->ptr = NULL;
|
||||
kmin->properties = nullptr;
|
||||
kmin->ptr = nullptr;
|
||||
}
|
||||
|
||||
return kmin;
|
||||
@@ -88,8 +88,8 @@ static void wm_keymap_item_free(wmKeyMapItem *kmi)
|
||||
if (kmi->ptr) {
|
||||
WM_operator_properties_free(kmi->ptr);
|
||||
MEM_freeN(kmi->ptr);
|
||||
kmi->ptr = NULL;
|
||||
kmi->properties = NULL;
|
||||
kmi->ptr = nullptr;
|
||||
kmi->properties = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ static void wm_keymap_item_properties_set(wmKeyMapItem *kmi)
|
||||
WM_operator_properties_sanitize(kmi->ptr, 1);
|
||||
|
||||
/* Signal for no context, see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */
|
||||
kmi->ptr->owner_id = NULL;
|
||||
kmi->ptr->owner_id = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,11 +109,11 @@ static void wm_keymap_item_properties_set(wmKeyMapItem *kmi)
|
||||
static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
|
||||
{
|
||||
if (kmi->idname[0] == 0) {
|
||||
BLI_assert(kmi->ptr == NULL);
|
||||
BLI_assert(kmi->ptr == nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (kmi->ptr == NULL) {
|
||||
if (kmi->ptr == nullptr) {
|
||||
wm_keymap_item_properties_set(kmi);
|
||||
}
|
||||
else {
|
||||
@@ -122,7 +122,7 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
|
||||
if (ot->srna != kmi->ptr->type) {
|
||||
/* matches wm_keymap_item_properties_set but doesn't alloc new ptr */
|
||||
WM_operator_properties_create_ptr(kmi->ptr, ot);
|
||||
/* 'kmi->ptr->data' NULL'd above, keep using existing properties.
|
||||
/* 'kmi->ptr->data' nullptr'd above, keep using existing properties.
|
||||
* NOTE: the operators property types may have changed,
|
||||
* we will need a more comprehensive sanitize function to support this properly.
|
||||
*/
|
||||
@@ -132,7 +132,7 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
|
||||
WM_operator_properties_sanitize(kmi->ptr, 1);
|
||||
|
||||
/* Signal for no context, see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */
|
||||
kmi->ptr->owner_id = NULL;
|
||||
kmi->ptr->owner_id = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -184,7 +184,7 @@ void WM_keymap_item_properties_reset(wmKeyMapItem *kmi, IDProperty *properties)
|
||||
WM_operator_properties_free(kmi->ptr);
|
||||
MEM_freeN(kmi->ptr);
|
||||
|
||||
kmi->ptr = NULL;
|
||||
kmi->ptr = nullptr;
|
||||
}
|
||||
|
||||
kmi->properties = properties;
|
||||
@@ -225,9 +225,9 @@ int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi)
|
||||
|
||||
static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
|
||||
{
|
||||
wmKeyMapDiffItem *kmdin = MEM_dupallocN(kmdi);
|
||||
wmKeyMapDiffItem *kmdin = static_cast<wmKeyMapDiffItem *>(MEM_dupallocN(kmdi));
|
||||
|
||||
kmdin->next = kmdin->prev = NULL;
|
||||
kmdin->next = kmdin->prev = nullptr;
|
||||
if (kmdi->add_item) {
|
||||
kmdin->add_item = wm_keymap_item_copy(kmdi->add_item);
|
||||
}
|
||||
@@ -262,7 +262,8 @@ static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi)
|
||||
|
||||
wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user_defined)
|
||||
{
|
||||
wmKeyConfig *keyconf = BLI_findstring(&wm->keyconfigs, idname, offsetof(wmKeyConfig, idname));
|
||||
wmKeyConfig *keyconf = static_cast<wmKeyConfig *>(
|
||||
BLI_findstring(&wm->keyconfigs, idname, offsetof(wmKeyConfig, idname)));
|
||||
if (keyconf) {
|
||||
if (keyconf == wm->defaultconf) {
|
||||
/* For default configuration, we need to keep keymap
|
||||
@@ -280,7 +281,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user
|
||||
}
|
||||
|
||||
/* Create new configuration. */
|
||||
keyconf = MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig");
|
||||
keyconf = static_cast<wmKeyConfig *>(MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig"));
|
||||
STRNCPY(keyconf->idname, idname);
|
||||
BLI_addtail(&wm->keyconfigs, keyconf);
|
||||
|
||||
@@ -302,7 +303,7 @@ bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
|
||||
if (STREQLEN(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr))) {
|
||||
STRNCPY(U.keyconfigstr, wm->defaultconf->idname);
|
||||
U.runtime.is_dirty = true;
|
||||
WM_keyconfig_update_tag(NULL, NULL);
|
||||
WM_keyconfig_update_tag(nullptr, nullptr);
|
||||
}
|
||||
|
||||
BLI_remlink(&wm->keyconfigs, keyconf);
|
||||
@@ -333,7 +334,8 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
|
||||
wmKeyConfig *keyconf;
|
||||
|
||||
/* first try from preset */
|
||||
keyconf = BLI_findstring(&wm->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname));
|
||||
keyconf = static_cast<wmKeyConfig *>(
|
||||
BLI_findstring(&wm->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname)));
|
||||
if (keyconf) {
|
||||
return keyconf;
|
||||
}
|
||||
@@ -354,7 +356,7 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
|
||||
U.runtime.is_dirty = true;
|
||||
}
|
||||
|
||||
WM_keyconfig_update_tag(NULL, NULL);
|
||||
WM_keyconfig_update_tag(nullptr, nullptr);
|
||||
WM_keyconfig_update(wm);
|
||||
}
|
||||
|
||||
@@ -368,7 +370,7 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
|
||||
|
||||
static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid)
|
||||
{
|
||||
wmKeyMap *km = MEM_callocN(sizeof(wmKeyMap), "keymap list");
|
||||
wmKeyMap *km = static_cast<wmKeyMap *>(MEM_callocN(sizeof(wmKeyMap), "keymap list"));
|
||||
|
||||
STRNCPY(km->idname, idname);
|
||||
km->spaceid = spaceid;
|
||||
@@ -385,7 +387,7 @@ static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid)
|
||||
|
||||
static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap)
|
||||
{
|
||||
wmKeyMap *keymapn = MEM_dupallocN(keymap);
|
||||
wmKeyMap *keymapn = static_cast<wmKeyMap *>(MEM_dupallocN(keymap));
|
||||
|
||||
keymapn->modal_items = keymap->modal_items;
|
||||
keymapn->poll = keymap->poll;
|
||||
@@ -458,7 +460,7 @@ bool WM_keymap_poll(bContext *C, wmKeyMap *keymap)
|
||||
}
|
||||
}
|
||||
|
||||
if (keymap->poll != NULL) {
|
||||
if (keymap->poll != nullptr) {
|
||||
return keymap->poll(C);
|
||||
}
|
||||
return true;
|
||||
@@ -511,7 +513,8 @@ wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap,
|
||||
const char *idname,
|
||||
const KeyMapItem_Params *params)
|
||||
{
|
||||
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
|
||||
wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(
|
||||
MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"));
|
||||
|
||||
BLI_addtail(&keymap->items, kmi);
|
||||
STRNCPY(kmi->idname, idname);
|
||||
@@ -548,7 +551,7 @@ bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
|
||||
}
|
||||
BLI_freelinkN(&keymap->items, kmi);
|
||||
|
||||
WM_keyconfig_update_tag(keymap, NULL);
|
||||
WM_keyconfig_update_tag(keymap, nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -582,7 +585,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapItem *needle)
|
||||
@@ -593,7 +596,7 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void wm_keymap_diff(
|
||||
@@ -604,13 +607,15 @@ static void wm_keymap_diff(
|
||||
|
||||
if (!to_kmi) {
|
||||
/* remove item */
|
||||
wmKeyMapDiffItem *kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
|
||||
wmKeyMapDiffItem *kmdi = static_cast<wmKeyMapDiffItem *>(
|
||||
MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"));
|
||||
kmdi->remove_item = wm_keymap_item_copy(kmi);
|
||||
BLI_addtail(&diff_km->diff_items, kmdi);
|
||||
}
|
||||
else if (to_kmi && !wm_keymap_item_equals(kmi, to_kmi)) {
|
||||
/* replace item */
|
||||
wmKeyMapDiffItem *kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
|
||||
wmKeyMapDiffItem *kmdi = static_cast<wmKeyMapDiffItem *>(
|
||||
MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"));
|
||||
kmdi->remove_item = wm_keymap_item_copy(kmi);
|
||||
kmdi->add_item = wm_keymap_item_copy(to_kmi);
|
||||
BLI_addtail(&diff_km->diff_items, kmdi);
|
||||
@@ -634,7 +639,8 @@ static void wm_keymap_diff(
|
||||
LISTBASE_FOREACH (wmKeyMapItem *, kmi, &to_km->items) {
|
||||
if (kmi->id < 0) {
|
||||
/* add item */
|
||||
wmKeyMapDiffItem *kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
|
||||
wmKeyMapDiffItem *kmdi = static_cast<wmKeyMapDiffItem *>(
|
||||
MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem"));
|
||||
kmdi->add_item = wm_keymap_item_copy(kmi);
|
||||
BLI_addtail(&diff_km->diff_items, kmdi);
|
||||
}
|
||||
@@ -645,7 +651,7 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
|
||||
{
|
||||
LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &diff_km->diff_items) {
|
||||
/* find item to remove */
|
||||
wmKeyMapItem *kmi_remove = NULL;
|
||||
wmKeyMapItem *kmi_remove = nullptr;
|
||||
if (kmdi->remove_item) {
|
||||
kmi_remove = wm_keymap_find_item_equals(km, kmdi->remove_item);
|
||||
if (!kmi_remove) {
|
||||
@@ -675,8 +681,8 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
|
||||
* since base keymap was exported with that user-defined shortcut already!
|
||||
*
|
||||
* Maybe we should rather keep user-defined keymaps specific to a given base one? */
|
||||
if (kmi_add != NULL && kmi_add == kmi_remove) {
|
||||
kmi_remove = NULL;
|
||||
if (kmi_add != nullptr && kmi_add == kmi_remove) {
|
||||
kmi_remove = nullptr;
|
||||
}
|
||||
/* only if nothing to remove or item to remove found */
|
||||
else if (!kmi_add && (!kmdi->remove_item || kmi_remove)) {
|
||||
@@ -835,7 +841,7 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb,
|
||||
@@ -851,18 +857,18 @@ wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb,
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmKeyMap *WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
|
||||
{
|
||||
wmKeyMap *km = WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
|
||||
|
||||
if (km == NULL) {
|
||||
if (km == nullptr) {
|
||||
km = wm_keymap_new(idname, spaceid, regionid);
|
||||
BLI_addtail(&keyconf->keymaps, km);
|
||||
|
||||
WM_keyconfig_update_tag(km, NULL);
|
||||
WM_keyconfig_update_tag(km, nullptr);
|
||||
}
|
||||
|
||||
return km;
|
||||
@@ -898,7 +904,7 @@ wmKeyMap *WM_modalkeymap_ensure(wmKeyConfig *keyconf,
|
||||
km->flag |= KEYMAP_MODAL;
|
||||
|
||||
/* init modal items from default config */
|
||||
wmWindowManager *wm = G_MAIN->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
|
||||
if (wm->defaultconf && wm->defaultconf != keyconf) {
|
||||
wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
|
||||
|
||||
@@ -926,12 +932,13 @@ wmKeyMap *WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmKeyMapItem *WM_modalkeymap_add_item(wmKeyMap *km, const KeyMapItem_Params *params, int value)
|
||||
{
|
||||
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
|
||||
wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(
|
||||
MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"));
|
||||
|
||||
BLI_addtail(&km->items, kmi);
|
||||
kmi->propvalue = value;
|
||||
@@ -949,7 +956,8 @@ wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km,
|
||||
const KeyMapItem_Params *params,
|
||||
const char *value)
|
||||
{
|
||||
wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
|
||||
wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(
|
||||
MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"));
|
||||
|
||||
BLI_addtail(&km->items, kmi);
|
||||
STRNCPY(kmi->propvalue_str, value);
|
||||
@@ -968,7 +976,7 @@ static const wmKeyMapItem *wm_modalkeymap_find_propvalue_iter(const wmKeyMap *km
|
||||
const int propvalue)
|
||||
{
|
||||
if (km->flag & KEYMAP_MODAL) {
|
||||
kmi = kmi ? kmi->next : km->items.first;
|
||||
kmi = static_cast<const wmKeyMapItem *>(kmi ? kmi->next : km->items.first);
|
||||
for (; kmi; kmi = kmi->next) {
|
||||
if (kmi->propvalue == propvalue) {
|
||||
return kmi;
|
||||
@@ -979,12 +987,12 @@ static const wmKeyMapItem *wm_modalkeymap_find_propvalue_iter(const wmKeyMap *km
|
||||
BLI_assert_msg(0, "called with non modal keymap");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const wmKeyMapItem *WM_modalkeymap_find_propvalue(const wmKeyMap *km, const int propvalue)
|
||||
{
|
||||
return wm_modalkeymap_find_propvalue_iter(km, NULL, propvalue);
|
||||
return wm_modalkeymap_find_propvalue_iter(km, nullptr, propvalue);
|
||||
}
|
||||
|
||||
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
|
||||
@@ -1005,7 +1013,7 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
|
||||
* being created before the actual modal keymaps, so no modal_items */
|
||||
|
||||
if (km && (km->flag & KEYMAP_MODAL) && !km->modal_items) {
|
||||
if (wm->defaultconf == NULL) {
|
||||
if (wm->defaultconf == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1022,7 +1030,10 @@ static void wm_user_modal_keymap_set_items(wmWindowManager *wm, wmKeyMap *km)
|
||||
LISTBASE_FOREACH (wmKeyMapItem *, kmi, &km->items) {
|
||||
if (kmi->propvalue_str[0]) {
|
||||
int propvalue;
|
||||
if (RNA_enum_value_from_id(km->modal_items, kmi->propvalue_str, &propvalue)) {
|
||||
if (RNA_enum_value_from_id(static_cast<const EnumPropertyItem *>(km->modal_items),
|
||||
kmi->propvalue_str,
|
||||
&propvalue))
|
||||
{
|
||||
kmi->propvalue = propvalue;
|
||||
}
|
||||
kmi->propvalue_str[0] = '\0';
|
||||
@@ -1042,7 +1053,7 @@ static const char *key_event_glyph_or_text(const int font_id,
|
||||
const char *text,
|
||||
const char *single_glyph)
|
||||
{
|
||||
BLI_assert(single_glyph == NULL || (BLI_strlen_utf8(single_glyph) == 1));
|
||||
BLI_assert(single_glyph == nullptr || (BLI_strlen_utf8(single_glyph) == 1));
|
||||
return (single_glyph && BLF_has_glyph(font_id, BLI_str_utf8_as_unicode(single_glyph))) ?
|
||||
single_glyph :
|
||||
text;
|
||||
@@ -1051,8 +1062,8 @@ static const char *key_event_glyph_or_text(const int font_id,
|
||||
const char *WM_key_event_string(const short type, const bool compact)
|
||||
{
|
||||
if (compact) {
|
||||
/* String storing a single unicode character or NULL. */
|
||||
const char *single_glyph = NULL;
|
||||
/* String storing a single unicode character or nullptr. */
|
||||
const char *single_glyph = nullptr;
|
||||
int font_id = BLF_default();
|
||||
const enum {
|
||||
UNIX,
|
||||
@@ -1238,7 +1249,7 @@ int WM_modalkeymap_items_to_string(const wmKeyMap *km,
|
||||
BLI_assert(result_maxncpy > 0);
|
||||
|
||||
const wmKeyMapItem *kmi;
|
||||
if (km == NULL || (kmi = WM_modalkeymap_find_propvalue(km, propvalue)) == NULL) {
|
||||
if (km == nullptr || (kmi = WM_modalkeymap_find_propvalue(km, propvalue)) == nullptr) {
|
||||
*result = '\0';
|
||||
return 0;
|
||||
}
|
||||
@@ -1247,7 +1258,7 @@ int WM_modalkeymap_items_to_string(const wmKeyMap *km,
|
||||
do {
|
||||
totlen += WM_keymap_item_to_string(kmi, compact, &result[totlen], result_maxncpy - totlen);
|
||||
|
||||
if ((kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue)) == NULL ||
|
||||
if ((kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue)) == nullptr ||
|
||||
totlen >= (result_maxncpy - 2))
|
||||
{
|
||||
break;
|
||||
@@ -1267,7 +1278,7 @@ int WM_modalkeymap_operator_items_to_string(wmOperatorType *ot,
|
||||
const int result_maxncpy)
|
||||
{
|
||||
BLI_string_debug_size_after_nil(result, result_maxncpy);
|
||||
wmWindowManager *wm = G_MAIN->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
|
||||
wmKeyMap *keymap = WM_keymap_active(wm, ot->modalkeymap);
|
||||
return WM_modalkeymap_items_to_string(keymap, propvalue, compact, result, result_maxncpy);
|
||||
}
|
||||
@@ -1323,19 +1334,21 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
|
||||
|
||||
bool kmi_match = false;
|
||||
if (properties) {
|
||||
/* example of debugging keymaps */
|
||||
/* example of debugging keymaps */
|
||||
#if 0
|
||||
if (kmi->ptr) {
|
||||
if (STREQ("MESH_OT_rip_move", opname)) {
|
||||
printf("OPERATOR\n");
|
||||
IDP_print(properties);
|
||||
printf("KEYMAP\n");
|
||||
IDP_print(kmi->ptr->data);
|
||||
}
|
||||
if (kmi->ptr) {
|
||||
if (STREQ("MESH_OT_rip_move", opname)) {
|
||||
printf("OPERATOR\n");
|
||||
IDP_print(properties);
|
||||
printf("KEYMAP\n");
|
||||
IDP_print(kmi->ptr->data);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) {
|
||||
if (kmi->ptr && IDP_EqualsProperties_ex(
|
||||
properties, static_cast<const IDProperty *>(kmi->ptr->data), is_strict))
|
||||
{
|
||||
kmi_match = true;
|
||||
}
|
||||
/* Debug only, helps spotting mismatches between menu entries and shortcuts! */
|
||||
@@ -1345,9 +1358,10 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
|
||||
if (ot) {
|
||||
/* make a copy of the properties and set unset ones to their default values. */
|
||||
PointerRNA opptr;
|
||||
IDProperty *properties_default = IDP_CopyProperty(kmi->ptr->data);
|
||||
IDProperty *properties_default = IDP_CopyProperty(
|
||||
static_cast<const IDProperty *>(kmi->ptr->data));
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);
|
||||
RNA_pointer_create(nullptr, ot->srna, properties_default, &opptr);
|
||||
WM_operator_properties_default(&opptr, true);
|
||||
|
||||
if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) {
|
||||
@@ -1364,7 +1378,7 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
|
||||
printf("OPERATOR\n");
|
||||
IDP_print(properties);
|
||||
printf("KEYMAP\n");
|
||||
IDP_print(kmi->ptr->data);
|
||||
IDP_print(static_cast<IDProperty *>(kmi->ptr->data));
|
||||
# endif
|
||||
#endif
|
||||
printf("\n");
|
||||
@@ -1380,12 +1394,12 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
|
||||
}
|
||||
|
||||
if (kmi_match) {
|
||||
if ((params == NULL) || params->filter_fn(keymap, kmi, params->user_data)) {
|
||||
if ((params == nullptr) || params->filter_fn(keymap, kmi, params->user_data)) {
|
||||
return kmi;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C,
|
||||
@@ -1393,7 +1407,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C,
|
||||
wmWindow *win,
|
||||
ListBase *handlers,
|
||||
const char *opname,
|
||||
wmOperatorCallContext UNUSED(opcontext),
|
||||
wmOperatorCallContext /*opcontext*/,
|
||||
IDProperty *properties,
|
||||
const bool is_strict,
|
||||
const struct wmKeyMapItemFind_Params *params,
|
||||
@@ -1410,7 +1424,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C,
|
||||
if (WM_keymap_poll((bContext *)C, keymap)) {
|
||||
wmKeyMapItem *kmi = wm_keymap_item_find_in_keymap(
|
||||
keymap, opname, properties, is_strict, params);
|
||||
if (kmi != NULL) {
|
||||
if (kmi != nullptr) {
|
||||
if (r_keymap) {
|
||||
*r_keymap = keymap;
|
||||
}
|
||||
@@ -1422,9 +1436,9 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(const bContext *C,
|
||||
}
|
||||
/* ensure un-initialized keymap is never used */
|
||||
if (r_keymap) {
|
||||
*r_keymap = NULL;
|
||||
*r_keymap = nullptr;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C,
|
||||
@@ -1439,7 +1453,7 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C,
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
wmKeyMapItem *found = NULL;
|
||||
wmKeyMapItem *found = nullptr;
|
||||
|
||||
/* look into multiple handler lists to find the item */
|
||||
if (win) {
|
||||
@@ -1453,18 +1467,18 @@ static wmKeyMapItem *wm_keymap_item_find_props(const bContext *C,
|
||||
is_strict,
|
||||
params,
|
||||
r_keymap);
|
||||
if (found == NULL) {
|
||||
if (found == nullptr) {
|
||||
found = wm_keymap_item_find_handlers(
|
||||
C, wm, win, &win->handlers, opname, opcontext, properties, is_strict, params, r_keymap);
|
||||
}
|
||||
}
|
||||
|
||||
if (area && found == NULL) {
|
||||
if (area && found == nullptr) {
|
||||
found = wm_keymap_item_find_handlers(
|
||||
C, wm, win, &area->handlers, opname, opcontext, properties, is_strict, params, r_keymap);
|
||||
}
|
||||
|
||||
if (found == NULL) {
|
||||
if (found == nullptr) {
|
||||
if (ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
|
||||
if (area) {
|
||||
if (!(region && region->regiontype == RGN_TYPE_WINDOW)) {
|
||||
@@ -1575,7 +1589,7 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C,
|
||||
PointerRNA opptr;
|
||||
IDProperty *properties_temp = IDP_CopyProperty(properties);
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, properties_temp, &opptr);
|
||||
RNA_pointer_create(nullptr, ot->srna, properties_temp, &opptr);
|
||||
|
||||
if (RNA_property_is_set(&opptr, ot->prop)) {
|
||||
/* For operator that has enum menu,
|
||||
@@ -1598,7 +1612,7 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C,
|
||||
PointerRNA opptr;
|
||||
IDProperty *properties_default = IDP_CopyProperty(properties);
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);
|
||||
RNA_pointer_create(nullptr, ot->srna, properties_default, &opptr);
|
||||
WM_operator_properties_default(&opptr, true);
|
||||
|
||||
wmKeyMap *km;
|
||||
@@ -1617,7 +1631,7 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C,
|
||||
printf("OPERATOR\n");
|
||||
IDP_print(properties);
|
||||
printf("KEYMAP\n");
|
||||
IDP_print(kmi->ptr->data);
|
||||
IDP_print(static_cast<IDProperty *>(kmi->ptr->data));
|
||||
# endif
|
||||
#endif
|
||||
printf("\n");
|
||||
@@ -1631,9 +1645,9 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C,
|
||||
return found;
|
||||
}
|
||||
|
||||
static bool kmi_filter_is_visible(const wmKeyMap *UNUSED(km),
|
||||
static bool kmi_filter_is_visible(const wmKeyMap * /*km*/,
|
||||
const wmKeyMapItem *kmi,
|
||||
void *UNUSED(user_data))
|
||||
void * /*user_data*/)
|
||||
{
|
||||
return ((WM_key_event_string(kmi->type, false)[0] != '\0') &&
|
||||
(IS_EVENT_ACTIONZONE(kmi->type) == false));
|
||||
@@ -1647,16 +1661,11 @@ char *WM_key_event_operator_string(const bContext *C,
|
||||
char *result,
|
||||
const int result_maxncpy)
|
||||
{
|
||||
wmKeyMapItem *kmi = wm_keymap_item_find(C,
|
||||
opname,
|
||||
opcontext,
|
||||
properties,
|
||||
is_strict,
|
||||
&(struct wmKeyMapItemFind_Params){
|
||||
.filter_fn = kmi_filter_is_visible,
|
||||
.user_data = NULL,
|
||||
},
|
||||
NULL);
|
||||
wmKeyMapItemFind_Params params{};
|
||||
params.filter_fn = kmi_filter_is_visible;
|
||||
params.user_data = nullptr;
|
||||
wmKeyMapItem *kmi = wm_keymap_item_find(
|
||||
C, opname, opcontext, properties, is_strict, ¶ms, nullptr);
|
||||
if (kmi) {
|
||||
WM_keymap_item_to_string(kmi, false, result, result_maxncpy);
|
||||
return result;
|
||||
@@ -1667,16 +1676,16 @@ char *WM_key_event_operator_string(const bContext *C,
|
||||
return result;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool kmi_filter_is_visible_type_mask(const wmKeyMap *km,
|
||||
const wmKeyMapItem *kmi,
|
||||
void *user_data)
|
||||
{
|
||||
short *mask_pair = user_data;
|
||||
return ((WM_event_type_mask_test(kmi->type, mask_pair[0]) == true) &&
|
||||
(WM_event_type_mask_test(kmi->type, mask_pair[1]) == false) &&
|
||||
short *mask_pair = static_cast<short int *>(user_data);
|
||||
return ((WM_event_type_mask_test(kmi->type, eEventType_Mask(mask_pair[0])) == true) &&
|
||||
(WM_event_type_mask_test(kmi->type, eEventType_Mask(mask_pair[1])) == false) &&
|
||||
kmi_filter_is_visible(km, kmi, user_data));
|
||||
}
|
||||
|
||||
@@ -1690,17 +1699,10 @@ wmKeyMapItem *WM_key_event_operator(const bContext *C,
|
||||
{
|
||||
short user_data_mask[2] = {include_mask, exclude_mask};
|
||||
bool use_mask = (include_mask != EVT_TYPE_MASK_ALL) || (exclude_mask != 0);
|
||||
return wm_keymap_item_find(
|
||||
C,
|
||||
opname,
|
||||
opcontext,
|
||||
properties,
|
||||
true,
|
||||
&(struct wmKeyMapItemFind_Params){
|
||||
.filter_fn = use_mask ? kmi_filter_is_visible_type_mask : kmi_filter_is_visible,
|
||||
.user_data = use_mask ? user_data_mask : NULL,
|
||||
},
|
||||
r_keymap);
|
||||
wmKeyMapItemFind_Params params{};
|
||||
params.filter_fn = use_mask ? kmi_filter_is_visible_type_mask : kmi_filter_is_visible;
|
||||
params.user_data = use_mask ? user_data_mask : nullptr;
|
||||
return wm_keymap_item_find(C, opname, opcontext, properties, true, ¶ms, r_keymap);
|
||||
}
|
||||
|
||||
wmKeyMapItem *WM_key_event_operator_from_keymap(wmKeyMap *keymap,
|
||||
@@ -1711,15 +1713,11 @@ wmKeyMapItem *WM_key_event_operator_from_keymap(wmKeyMap *keymap,
|
||||
{
|
||||
short user_data_mask[2] = {include_mask, exclude_mask};
|
||||
bool use_mask = (include_mask != EVT_TYPE_MASK_ALL) || (exclude_mask != 0);
|
||||
return wm_keymap_item_find_in_keymap(
|
||||
keymap,
|
||||
opname,
|
||||
properties,
|
||||
true,
|
||||
&(struct wmKeyMapItemFind_Params){
|
||||
.filter_fn = use_mask ? kmi_filter_is_visible_type_mask : kmi_filter_is_visible,
|
||||
.user_data = use_mask ? user_data_mask : NULL,
|
||||
});
|
||||
wmKeyMapItemFind_Params params{};
|
||||
params.filter_fn = use_mask ? kmi_filter_is_visible_type_mask : kmi_filter_is_visible;
|
||||
params.user_data = use_mask ? user_data_mask : nullptr;
|
||||
|
||||
return wm_keymap_item_find_in_keymap(keymap, opname, properties, true, ¶ms);
|
||||
}
|
||||
|
||||
bool WM_keymap_item_compare(const wmKeyMapItem *k1, const wmKeyMapItem *k2)
|
||||
@@ -1853,7 +1851,7 @@ void WM_keyconfig_update(wmWindowManager *wm)
|
||||
&wm->userconf->keymaps,
|
||||
&wm->defaultconf->keymaps,
|
||||
&wm->addonconf->keymaps,
|
||||
NULL,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
int i;
|
||||
@@ -1937,7 +1935,7 @@ void WM_keyconfig_update(wmWindowManager *wm)
|
||||
BLI_assert(wm_keymap_update_flag == 0);
|
||||
|
||||
if (compat_update) {
|
||||
WM_keyconfig_update_tag(NULL, NULL);
|
||||
WM_keyconfig_update_tag(nullptr, nullptr);
|
||||
WM_keyconfig_update(wm);
|
||||
}
|
||||
}
|
||||
@@ -1954,7 +1952,7 @@ void WM_keyconfig_update(wmWindowManager *wm)
|
||||
wmKeyMap *WM_keymap_active(const wmWindowManager *wm, wmKeyMap *keymap)
|
||||
{
|
||||
if (!keymap) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* first user defined keymaps */
|
||||
@@ -1999,13 +1997,13 @@ void WM_keymap_item_restore_to_default(wmWindowManager *wm, wmKeyMap *keymap, wm
|
||||
/* restore to original */
|
||||
if (!STREQ(orig->idname, kmi->idname)) {
|
||||
STRNCPY(kmi->idname, orig->idname);
|
||||
WM_keymap_item_properties_reset(kmi, NULL);
|
||||
WM_keymap_item_properties_reset(kmi, nullptr);
|
||||
}
|
||||
|
||||
if (orig->properties) {
|
||||
if (kmi->properties) {
|
||||
IDP_FreeProperty(kmi->properties);
|
||||
kmi->properties = NULL;
|
||||
kmi->properties = nullptr;
|
||||
}
|
||||
|
||||
kmi->properties = IDP_CopyProperty(orig->properties);
|
||||
@@ -2044,7 +2042,7 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, wmWindowManager *wm)
|
||||
WM_keymap_clear(usermap);
|
||||
BLI_freelinkN(&U.user_keymaps, usermap);
|
||||
|
||||
WM_keyconfig_update_tag(NULL, NULL);
|
||||
WM_keyconfig_update_tag(nullptr, nullptr);
|
||||
WM_keyconfig_update(wm);
|
||||
}
|
||||
}
|
||||
@@ -2057,7 +2055,7 @@ wmKeyMapItem *WM_keymap_item_find_id(wmKeyMap *keymap, int id)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *WM_bool_as_string(bool test)
|
||||
@@ -78,7 +78,7 @@ wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap,
|
||||
wmKeyMap *WM_keymap_guess_from_context(const bContext *C)
|
||||
{
|
||||
SpaceLink *sl = CTX_wm_space_data(C);
|
||||
const char *km_id = NULL;
|
||||
const char *km_id = nullptr;
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
|
||||
switch (mode) {
|
||||
@@ -158,7 +158,7 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C)
|
||||
}
|
||||
else if (sl->spacetype == SPACE_IMAGE) {
|
||||
const SpaceImage *sima = (SpaceImage *)sl;
|
||||
const eSpaceImage_Mode mode = sima->mode;
|
||||
const eSpaceImage_Mode mode = eSpaceImage_Mode(sima->mode);
|
||||
switch (mode) {
|
||||
case SI_MODE_VIEW:
|
||||
km_id = "Image";
|
||||
@@ -175,7 +175,7 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C)
|
||||
}
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmKeyMap *km = WM_keymap_find_all(CTX_wm_manager(C), km_id, 0, 0);
|
||||
@@ -197,7 +197,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
* WORLD_OT
|
||||
*/
|
||||
|
||||
wmKeyMap *km = NULL;
|
||||
wmKeyMap *km = nullptr;
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
SpaceLink *sl = CTX_wm_space_data(C);
|
||||
|
||||
@@ -207,7 +207,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
km = WM_keymap_guess_from_context(C);
|
||||
}
|
||||
|
||||
if (km == NULL) {
|
||||
if (km == nullptr) {
|
||||
km = WM_keymap_find_all(wm, "Window", 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
km = WM_keymap_find_all(wm, "Mesh", 0, 0);
|
||||
if (km && !WM_keymap_poll((bContext *)C, km)) {
|
||||
km = NULL;
|
||||
km = nullptr;
|
||||
}
|
||||
}
|
||||
if (!km) {
|
||||
@@ -382,7 +382,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
break;
|
||||
}
|
||||
if (km && !WM_keymap_poll((bContext *)C, km)) {
|
||||
km = NULL;
|
||||
km = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
static GHash *menutypes_hash = NULL;
|
||||
static GHash *menutypes_hash = nullptr;
|
||||
|
||||
MenuType *WM_menutype_find(const char *idname, bool quiet)
|
||||
{
|
||||
if (idname[0]) {
|
||||
MenuType *mt = BLI_ghash_lookup(menutypes_hash, idname);
|
||||
MenuType *mt = static_cast<MenuType *>(BLI_ghash_lookup(menutypes_hash, idname));
|
||||
if (mt) {
|
||||
return mt;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ MenuType *WM_menutype_find(const char *idname, bool quiet)
|
||||
printf("search for unknown menutype %s\n", idname);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_menutype_iter(GHashIterator *ghi)
|
||||
@@ -52,14 +52,14 @@ void WM_menutype_iter(GHashIterator *ghi)
|
||||
|
||||
bool WM_menutype_add(MenuType *mt)
|
||||
{
|
||||
BLI_assert((mt->description == NULL) || (mt->description[0]));
|
||||
BLI_assert((mt->description == nullptr) || (mt->description[0]));
|
||||
BLI_ghash_insert(menutypes_hash, mt->idname, mt);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WM_menutype_freelink(MenuType *mt)
|
||||
{
|
||||
bool ok = BLI_ghash_remove(menutypes_hash, mt->idname, NULL, MEM_freeN);
|
||||
bool ok = BLI_ghash_remove(menutypes_hash, mt->idname, nullptr, MEM_freeN);
|
||||
|
||||
BLI_assert(ok);
|
||||
UNUSED_VARS_NDEBUG(ok);
|
||||
@@ -76,14 +76,14 @@ void WM_menutype_free(void)
|
||||
GHashIterator gh_iter;
|
||||
|
||||
GHASH_ITER (gh_iter, menutypes_hash) {
|
||||
MenuType *mt = BLI_ghashIterator_getValue(&gh_iter);
|
||||
MenuType *mt = static_cast<MenuType *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||
if (mt->rna_ext.free) {
|
||||
mt->rna_ext.free(mt->rna_ext.data);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_ghash_free(menutypes_hash, NULL, MEM_freeN);
|
||||
menutypes_hash = NULL;
|
||||
BLI_ghash_free(menutypes_hash, nullptr, MEM_freeN);
|
||||
menutypes_hash = nullptr;
|
||||
}
|
||||
|
||||
bool WM_menutype_poll(bContext *C, MenuType *mt)
|
||||
@@ -96,24 +96,24 @@ bool WM_menutype_poll(bContext *C, MenuType *mt)
|
||||
}
|
||||
}
|
||||
|
||||
if (mt->poll != NULL) {
|
||||
if (mt->poll != nullptr) {
|
||||
return mt->poll(C, mt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void WM_menutype_idname_visit_for_search(const bContext *UNUSED(C),
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
const char *UNUSED(edit_text),
|
||||
void WM_menutype_idname_visit_for_search(const bContext * /*C*/,
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
const char * /*edit_text*/,
|
||||
StringPropertySearchVisitFunc visit_fn,
|
||||
void *visit_user_data)
|
||||
{
|
||||
GHashIterator gh_iter;
|
||||
GHASH_ITER (gh_iter, menutypes_hash) {
|
||||
MenuType *mt = BLI_ghashIterator_getValue(&gh_iter);
|
||||
MenuType *mt = static_cast<MenuType *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||
|
||||
StringPropertySearchVisitParams visit_params = {NULL};
|
||||
StringPropertySearchVisitParams visit_params = {nullptr};
|
||||
visit_params.text = mt->idname;
|
||||
visit_params.info = mt->label;
|
||||
visit_fn(visit_user_data, &visit_params);
|
||||
@@ -42,7 +42,7 @@ void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
|
||||
* Extends rna_enum_fileselect_params_sort_items with a default item for operators to use.
|
||||
*/
|
||||
static const EnumPropertyItem *wm_operator_properties_filesel_sort_items_itemf(
|
||||
struct bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
|
||||
struct bContext * /*C*/, PointerRNA * /*ptr*/, PropertyRNA * /*prop*/, bool *r_free)
|
||||
{
|
||||
EnumPropertyItem *items;
|
||||
const EnumPropertyItem default_item = {
|
||||
@@ -89,21 +89,21 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
|
||||
"Long List",
|
||||
"Display files as a detailed list"},
|
||||
{FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
if (flag & WM_FILESEL_FILEPATH) {
|
||||
RNA_def_string_file_path(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path to file");
|
||||
RNA_def_string_file_path(ot->srna, "filepath", nullptr, FILE_MAX, "File Path", "Path to file");
|
||||
}
|
||||
|
||||
if (flag & WM_FILESEL_DIRECTORY) {
|
||||
RNA_def_string_dir_path(
|
||||
ot->srna, "directory", NULL, FILE_MAX, "Directory", "Directory of the file");
|
||||
ot->srna, "directory", nullptr, FILE_MAX, "Directory", "Directory of the file");
|
||||
}
|
||||
|
||||
if (flag & WM_FILESEL_FILENAME) {
|
||||
RNA_def_string_file_name(
|
||||
ot->srna, "filename", NULL, FILE_MAX, "File Name", "Name of the file");
|
||||
ot->srna, "filename", nullptr, FILE_MAX, "File Name", "Name of the file");
|
||||
}
|
||||
|
||||
if (flag & WM_FILESEL_FILES) {
|
||||
@@ -258,7 +258,7 @@ ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain,
|
||||
return BKE_libblock_find_name(bmain, type, name);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr)
|
||||
@@ -274,7 +274,7 @@ void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_pr
|
||||
if (add_name_prop) {
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"name",
|
||||
NULL,
|
||||
nullptr,
|
||||
MAX_ID_NAME - 2,
|
||||
"Name",
|
||||
"Name of the data-block to use by the operator");
|
||||
@@ -314,7 +314,7 @@ void WM_operator_properties_select_action(wmOperatorType *ot, int default_action
|
||||
{SEL_SELECT, "SELECT", 0, "Select", "Select all elements"},
|
||||
{SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"},
|
||||
{SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
wm_operator_properties_select_action_ex(ot, default_action, select_actions, hide_gui);
|
||||
@@ -327,7 +327,7 @@ void WM_operator_properties_select_action_simple(wmOperatorType *ot,
|
||||
static const EnumPropertyItem select_actions[] = {
|
||||
{SEL_SELECT, "SELECT", 0, "Select", "Select all elements"},
|
||||
{SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
wm_operator_properties_select_action_ex(ot, default_action, select_actions, hide_gui);
|
||||
@@ -456,7 +456,7 @@ void WM_operator_properties_select_operation(wmOperatorType *ot)
|
||||
{SEL_OP_SUB, "SUB", ICON_SELECT_SUBTRACT, "Subtract", "Subtract existing selection"},
|
||||
{SEL_OP_XOR, "XOR", ICON_SELECT_DIFFERENCE, "Difference", "Invert existing selection"},
|
||||
{SEL_OP_AND, "AND", ICON_SELECT_INTERSECT, "Intersect", "Intersect existing selection"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
PropertyRNA *prop = RNA_def_enum(ot->srna, "mode", select_mode_items, SEL_OP_SET, "Mode", "");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
@@ -468,7 +468,7 @@ void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
|
||||
{SEL_OP_SET, "SET", ICON_SELECT_SET, "Set", "Set a new selection"},
|
||||
{SEL_OP_ADD, "ADD", ICON_SELECT_EXTEND, "Extend", "Extend existing selection"},
|
||||
{SEL_OP_SUB, "SUB", ICON_SELECT_SUBTRACT, "Subtract", "Subtract existing selection"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
PropertyRNA *prop = RNA_def_enum(ot->srna, "mode", select_mode_items, SEL_OP_SET, "Mode", "");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
@@ -481,7 +481,7 @@ void WM_operator_properties_select_walk_direction(wmOperatorType *ot)
|
||||
{UI_SELECT_WALK_DOWN, "DOWN", 0, "Next", ""},
|
||||
{UI_SELECT_WALK_LEFT, "LEFT", 0, "Left", ""},
|
||||
{UI_SELECT_WALK_RIGHT, "RIGHT", 0, "Right", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_enum(ot->srna,
|
||||
@@ -46,7 +46,7 @@ static void wm_operatortype_free_macro(wmOperatorType *ot);
|
||||
/** \name Operator Type Registry
|
||||
* \{ */
|
||||
|
||||
static GHash *global_ops_hash = NULL;
|
||||
static GHash *global_ops_hash = nullptr;
|
||||
/** Counter for operator-properties that should not be tagged with #OP_PROP_TAG_ADVANCED. */
|
||||
static int ot_prop_basic_count = -1;
|
||||
|
||||
@@ -59,7 +59,7 @@ wmOperatorType *WM_operatortype_find(const char *idname, bool quiet)
|
||||
char idname_bl[OP_MAX_TYPENAME];
|
||||
WM_operator_bl_idname(idname_bl, idname);
|
||||
|
||||
ot = BLI_ghash_lookup(global_ops_hash, idname_bl);
|
||||
ot = static_cast<wmOperatorType *>(BLI_ghash_lookup(global_ops_hash, idname_bl));
|
||||
if (ot) {
|
||||
return ot;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ wmOperatorType *WM_operatortype_find(const char *idname, bool quiet)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_operatortype_iter(GHashIterator *ghi)
|
||||
@@ -89,7 +89,8 @@ void WM_operatortype_iter(GHashIterator *ghi)
|
||||
|
||||
static wmOperatorType *wm_operatortype_append__begin(void)
|
||||
{
|
||||
wmOperatorType *ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
|
||||
wmOperatorType *ot = static_cast<wmOperatorType *>(
|
||||
MEM_callocN(sizeof(wmOperatorType), "operatortype"));
|
||||
|
||||
BLI_assert(ot_prop_basic_count == -1);
|
||||
|
||||
@@ -104,10 +105,10 @@ static wmOperatorType *wm_operatortype_append__begin(void)
|
||||
}
|
||||
static void wm_operatortype_append__end(wmOperatorType *ot)
|
||||
{
|
||||
if (ot->name == NULL) {
|
||||
if (ot->name == nullptr) {
|
||||
CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname);
|
||||
}
|
||||
BLI_assert((ot->description == NULL) || (ot->description[0]));
|
||||
BLI_assert((ot->description == nullptr) || (ot->description[0]));
|
||||
|
||||
/* Allow calling _begin without _end in operatortype creation. */
|
||||
WM_operatortype_props_advanced_end(ot);
|
||||
@@ -152,7 +153,7 @@ void WM_operatortype_remove_ptr(wmOperatorType *ot)
|
||||
wm_operatortype_free_macro(ot);
|
||||
}
|
||||
|
||||
BLI_ghash_remove(global_ops_hash, ot->idname, NULL, NULL);
|
||||
BLI_ghash_remove(global_ops_hash, ot->idname, nullptr, nullptr);
|
||||
|
||||
WM_keyconfig_update_operatortype();
|
||||
|
||||
@@ -163,7 +164,7 @@ bool WM_operatortype_remove(const char *idname)
|
||||
{
|
||||
wmOperatorType *ot = WM_operatortype_find(idname, 0);
|
||||
|
||||
if (ot == NULL) {
|
||||
if (ot == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,8 +199,8 @@ static void operatortype_ghash_free_cb(wmOperatorType *ot)
|
||||
|
||||
void wm_operatortype_free(void)
|
||||
{
|
||||
BLI_ghash_free(global_ops_hash, NULL, (GHashValFreeFP)operatortype_ghash_free_cb);
|
||||
global_ops_hash = NULL;
|
||||
BLI_ghash_free(global_ops_hash, nullptr, (GHashValFreeFP)operatortype_ghash_free_cb);
|
||||
global_ops_hash = nullptr;
|
||||
}
|
||||
|
||||
void WM_operatortype_props_advanced_begin(wmOperatorType *ot)
|
||||
@@ -239,30 +240,30 @@ void WM_operatortype_last_properties_clear_all(void)
|
||||
|
||||
for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter))
|
||||
{
|
||||
wmOperatorType *ot = BLI_ghashIterator_getValue(&iter);
|
||||
wmOperatorType *ot = static_cast<wmOperatorType *>(BLI_ghashIterator_getValue(&iter));
|
||||
|
||||
if (ot->last_properties) {
|
||||
IDP_FreeProperty(ot->last_properties);
|
||||
ot->last_properties = NULL;
|
||||
ot->last_properties = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WM_operatortype_idname_visit_for_search(const bContext *UNUSED(C),
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
const char *UNUSED(edit_text),
|
||||
void WM_operatortype_idname_visit_for_search(const bContext * /*C*/,
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
const char * /*edit_text*/,
|
||||
StringPropertySearchVisitFunc visit_fn,
|
||||
void *visit_user_data)
|
||||
{
|
||||
GHashIterator gh_iter;
|
||||
GHASH_ITER (gh_iter, global_ops_hash) {
|
||||
wmOperatorType *ot = BLI_ghashIterator_getValue(&gh_iter);
|
||||
wmOperatorType *ot = static_cast<wmOperatorType *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||
|
||||
char idname_py[OP_MAX_TYPENAME];
|
||||
WM_operator_py_idname(idname_py, ot->idname);
|
||||
|
||||
StringPropertySearchVisitParams visit_params = {NULL};
|
||||
StringPropertySearchVisitParams visit_params = {nullptr};
|
||||
visit_params.text = idname_py;
|
||||
visit_params.info = ot->name;
|
||||
visit_fn(visit_user_data, &visit_params);
|
||||
@@ -275,13 +276,13 @@ void WM_operatortype_idname_visit_for_search(const bContext *UNUSED(C),
|
||||
/** \name Operator Macro Type
|
||||
* \{ */
|
||||
|
||||
typedef struct {
|
||||
struct MacroData {
|
||||
int retval;
|
||||
} MacroData;
|
||||
};
|
||||
|
||||
static void wm_macro_start(wmOperator *op)
|
||||
{
|
||||
if (op->customdata == NULL) {
|
||||
if (op->customdata == nullptr) {
|
||||
op->customdata = MEM_callocN(sizeof(MacroData), "MacroData");
|
||||
}
|
||||
}
|
||||
@@ -289,7 +290,7 @@ static void wm_macro_start(wmOperator *op)
|
||||
static int wm_macro_end(wmOperator *op, int retval)
|
||||
{
|
||||
if (retval & OPERATOR_CANCELLED) {
|
||||
MacroData *md = op->customdata;
|
||||
MacroData *md = static_cast<MacroData *>(op->customdata);
|
||||
|
||||
if (md->retval & OPERATOR_FINISHED) {
|
||||
retval |= OPERATOR_FINISHED;
|
||||
@@ -301,7 +302,7 @@ static int wm_macro_end(wmOperator *op, int retval)
|
||||
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) {
|
||||
if (op->customdata) {
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
op->customdata = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +327,7 @@ static int wm_macro_exec(bContext *C, wmOperator *op)
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
if (retval & OPERATOR_FINISHED) {
|
||||
MacroData *md = op->customdata;
|
||||
MacroData *md = static_cast<MacroData *>(op->customdata);
|
||||
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
|
||||
}
|
||||
else {
|
||||
@@ -366,7 +367,7 @@ static int wm_macro_invoke_internal(bContext *C,
|
||||
BLI_movelisttolist(&op->reports->list, &opm->reports->list);
|
||||
|
||||
if (retval & OPERATOR_FINISHED) {
|
||||
MacroData *md = op->customdata;
|
||||
MacroData *md = static_cast<MacroData *>(op->customdata);
|
||||
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
|
||||
}
|
||||
else {
|
||||
@@ -380,7 +381,7 @@ static int wm_macro_invoke_internal(bContext *C,
|
||||
static int wm_macro_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wm_macro_start(op);
|
||||
return wm_macro_invoke_internal(C, op, event, op->macro.first);
|
||||
return wm_macro_invoke_internal(C, op, event, static_cast<wmOperator *>(op->macro.first));
|
||||
}
|
||||
|
||||
static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
@@ -388,8 +389,8 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
wmOperator *opm = op->opm;
|
||||
int retval = OPERATOR_FINISHED;
|
||||
|
||||
if (opm == NULL) {
|
||||
CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling NULL modal()");
|
||||
if (opm == nullptr) {
|
||||
CLOG_ERROR(WM_LOG_OPERATORS, "macro error, calling nullptr modal()");
|
||||
}
|
||||
else {
|
||||
retval = opm->type->modal(C, opm, event);
|
||||
@@ -402,7 +403,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
/* if this one is done but it's not the last operator in the macro */
|
||||
if ((retval & OPERATOR_FINISHED) && opm->next) {
|
||||
MacroData *md = op->customdata;
|
||||
MacroData *md = static_cast<MacroData *>(op->customdata);
|
||||
|
||||
md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
|
||||
|
||||
@@ -413,7 +414,8 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wmEventHandler_Op *handler;
|
||||
|
||||
handler = BLI_findptr(&win->modalhandlers, op, offsetof(wmEventHandler_Op, op));
|
||||
handler = static_cast<wmEventHandler_Op *>(
|
||||
BLI_findptr(&win->modalhandlers, op, offsetof(wmEventHandler_Op, op)));
|
||||
if (handler) {
|
||||
BLI_remlink(&win->modalhandlers, handler);
|
||||
wm_event_free_handler(&handler->head);
|
||||
@@ -423,7 +425,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
* This may end up grabbing twice, but we don't care. */
|
||||
if (op->opm->type->flag & OPTYPE_BLOCKING) {
|
||||
int wrap = WM_CURSOR_WRAP_NONE;
|
||||
const rcti *wrap_region = NULL;
|
||||
const rcti *wrap_region = nullptr;
|
||||
|
||||
if ((op->opm->flag & OP_IS_MODAL_GRAB_CURSOR) ||
|
||||
(op->opm->type->flag & OPTYPE_GRAB_CURSOR_XY)) {
|
||||
@@ -443,7 +445,7 @@ static int wm_macro_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
WM_cursor_grab_enable(win, wrap, wrap_region, false);
|
||||
WM_cursor_grab_enable(win, eWM_CursorWrapAxis(wrap), wrap_region, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -472,10 +474,10 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname,
|
||||
|
||||
if (WM_operatortype_find(idname, true)) {
|
||||
CLOG_ERROR(WM_LOG_OPERATORS, "operator %s exists, cannot create macro", idname);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
|
||||
ot = static_cast<wmOperatorType *>(MEM_callocN(sizeof(wmOperatorType), "operatortype"));
|
||||
ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
|
||||
|
||||
ot->idname = idname;
|
||||
@@ -487,10 +489,10 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname,
|
||||
ot->invoke = wm_macro_invoke;
|
||||
ot->modal = wm_macro_modal;
|
||||
ot->cancel = wm_macro_cancel;
|
||||
ot->poll = NULL;
|
||||
ot->poll = nullptr;
|
||||
|
||||
/* XXX All ops should have a description but for now allow them not to. */
|
||||
BLI_assert((ot->description == NULL) || (ot->description[0]));
|
||||
BLI_assert((ot->description == nullptr) || (ot->description[0]));
|
||||
|
||||
RNA_def_struct_ui_text(
|
||||
ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
|
||||
@@ -510,7 +512,7 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *),
|
||||
{
|
||||
wmOperatorType *ot;
|
||||
|
||||
ot = MEM_callocN(sizeof(wmOperatorType), "operatortype");
|
||||
ot = static_cast<wmOperatorType *>(MEM_callocN(sizeof(wmOperatorType), "operatortype"));
|
||||
ot->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_OperatorProperties);
|
||||
|
||||
ot->flag = OPTYPE_MACRO;
|
||||
@@ -518,10 +520,10 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *),
|
||||
ot->invoke = wm_macro_invoke;
|
||||
ot->modal = wm_macro_modal;
|
||||
ot->cancel = wm_macro_cancel;
|
||||
ot->poll = NULL;
|
||||
ot->poll = nullptr;
|
||||
|
||||
/* XXX All ops should have a description but for now allow them not to. */
|
||||
BLI_assert((ot->description == NULL) || (ot->description[0]));
|
||||
BLI_assert((ot->description == nullptr) || (ot->description[0]));
|
||||
|
||||
/* Set the default i18n context now, so that opfunc can redefine it if needed! */
|
||||
RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
|
||||
@@ -537,7 +539,8 @@ void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *),
|
||||
|
||||
wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
|
||||
{
|
||||
wmOperatorTypeMacro *otmacro = MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro");
|
||||
wmOperatorTypeMacro *otmacro = static_cast<wmOperatorTypeMacro *>(
|
||||
MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro"));
|
||||
|
||||
STRNCPY(otmacro->idname, idname);
|
||||
|
||||
@@ -572,7 +575,7 @@ static void wm_operatortype_free_macro(wmOperatorType *ot)
|
||||
|
||||
const char *WM_operatortype_name(wmOperatorType *ot, PointerRNA *properties)
|
||||
{
|
||||
const char *name = NULL;
|
||||
const char *name = nullptr;
|
||||
|
||||
if (ot->get_name && properties) {
|
||||
name = ot->get_name(ot, properties);
|
||||
@@ -598,15 +601,15 @@ char *WM_operatortype_description(bContext *C, wmOperatorType *ot, PointerRNA *p
|
||||
if (info && info[0]) {
|
||||
return BLI_strdup(info);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char *WM_operatortype_description_or_name(bContext *C, wmOperatorType *ot, PointerRNA *properties)
|
||||
{
|
||||
char *text = WM_operatortype_description(C, ot, properties);
|
||||
if (text == NULL) {
|
||||
if (text == nullptr) {
|
||||
const char *text_orig = WM_operatortype_name(ot, properties);
|
||||
if (text_orig != NULL) {
|
||||
if (text_orig != nullptr) {
|
||||
text = BLI_strdup(text_orig);
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ int WM_operator_flag_only_pass_through_on_press(int retval, const wmEvent *event
|
||||
*
|
||||
* \{ */
|
||||
|
||||
typedef struct ValueInteraction {
|
||||
struct ValueInteraction {
|
||||
struct {
|
||||
float mval[2];
|
||||
float prop_value;
|
||||
@@ -74,7 +74,7 @@ typedef struct ValueInteraction {
|
||||
ScrArea *area;
|
||||
ARegion *region;
|
||||
} context_vars;
|
||||
} ValueInteraction;
|
||||
};
|
||||
|
||||
static void interactive_value_init(bContext *C,
|
||||
ValueInteraction *inter,
|
||||
@@ -106,7 +106,7 @@ static void interactive_value_init_from_property(
|
||||
|
||||
static void interactive_value_exit(ValueInteraction *inter)
|
||||
{
|
||||
ED_area_status_text(inter->context_vars.area, NULL);
|
||||
ED_area_status_text(inter->context_vars.area, nullptr);
|
||||
}
|
||||
|
||||
static bool interactive_value_update(ValueInteraction *inter,
|
||||
@@ -173,13 +173,13 @@ struct ObCustomData_ForEditMode {
|
||||
/* Internal callback to free. */
|
||||
static void op_generic_value_exit(wmOperator *op)
|
||||
{
|
||||
struct ObCustomData_ForEditMode *cd = op->customdata;
|
||||
struct ObCustomData_ForEditMode *cd = static_cast<ObCustomData_ForEditMode *>(op->customdata);
|
||||
if (cd) {
|
||||
interactive_value_exit(&cd->inter);
|
||||
|
||||
for (uint ob_index = 0; ob_index < cd->objects_len; ob_index++) {
|
||||
struct XFormObjectData *xod = cd->objects_xform[ob_index];
|
||||
if (xod != NULL) {
|
||||
if (xod != nullptr) {
|
||||
ED_object_data_xform_destroy(xod);
|
||||
}
|
||||
}
|
||||
@@ -193,14 +193,14 @@ static void op_generic_value_exit(wmOperator *op)
|
||||
|
||||
static void op_generic_value_restore(wmOperator *op)
|
||||
{
|
||||
struct ObCustomData_ForEditMode *cd = op->customdata;
|
||||
struct ObCustomData_ForEditMode *cd = static_cast<ObCustomData_ForEditMode *>(op->customdata);
|
||||
for (uint ob_index = 0; ob_index < cd->objects_len; ob_index++) {
|
||||
ED_object_data_xform_restore(cd->objects_xform[ob_index]);
|
||||
ED_object_data_xform_tag_update(cd->objects_xform[ob_index]);
|
||||
}
|
||||
}
|
||||
|
||||
static void op_generic_value_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
static void op_generic_value_cancel(bContext * /*C*/, wmOperator *op)
|
||||
{
|
||||
op_generic_value_exit(op);
|
||||
}
|
||||
@@ -221,7 +221,8 @@ static int op_generic_value_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
struct ObCustomData_ForEditMode *cd = MEM_callocN(sizeof(*cd), __func__);
|
||||
struct ObCustomData_ForEditMode *cd = static_cast<ObCustomData_ForEditMode *>(
|
||||
MEM_callocN(sizeof(*cd), __func__));
|
||||
cd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
cd->wait_for_input = RNA_boolean_get(op->ptr, "wait_for_input");
|
||||
cd->is_active = !cd->wait_for_input;
|
||||
@@ -233,11 +234,13 @@ static int op_generic_value_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
interactive_value_init_from_property(C, &cd->inter, event, op->ptr, op->type->prop);
|
||||
}
|
||||
|
||||
cd->objects_xform = MEM_callocN(sizeof(*cd->objects_xform) * objects_len, __func__);
|
||||
cd->objects_xform = static_cast<XFormObjectData **>(
|
||||
MEM_callocN(sizeof(*cd->objects_xform) * objects_len, __func__));
|
||||
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *obedit = objects[ob_index];
|
||||
cd->objects_xform[ob_index] = ED_object_data_xform_create_from_edit_mode(obedit->data);
|
||||
cd->objects_xform[ob_index] = ED_object_data_xform_create_from_edit_mode(
|
||||
static_cast<ID *>(obedit->data));
|
||||
}
|
||||
|
||||
op->customdata = cd;
|
||||
@@ -250,7 +253,7 @@ static int op_generic_value_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
|
||||
static int op_generic_value_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
struct ObCustomData_ForEditMode *cd = op->customdata;
|
||||
struct ObCustomData_ForEditMode *cd = static_cast<ObCustomData_ForEditMode *>(op->customdata);
|
||||
|
||||
/* Special case, check if we release the event that activated this operator. */
|
||||
if ((event->type == cd->launch_event) && (event->val == KM_RELEASE)) {
|
||||
@@ -333,10 +336,10 @@ void WM_operator_type_modal_from_exec_for_object_edit_coords(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
BLI_assert(ot->modal == NULL);
|
||||
BLI_assert(ot->invoke == NULL);
|
||||
BLI_assert(ot->cancel == NULL);
|
||||
BLI_assert(ot->prop != NULL);
|
||||
BLI_assert(ot->modal == nullptr);
|
||||
BLI_assert(ot->invoke == nullptr);
|
||||
BLI_assert(ot->cancel == nullptr);
|
||||
BLI_assert(ot->prop != nullptr);
|
||||
|
||||
ot->invoke = op_generic_value_invoke;
|
||||
ot->modal = op_generic_value_modal;
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "BLI_dial_2d.h"
|
||||
#include "BLI_dynstr.h" /* For #WM_operator_pystring. */
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_string_utils.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
@@ -231,12 +232,12 @@ char *WM_operator_pystring_ex(bContext *C,
|
||||
wmOperator *opm;
|
||||
bool first_op = true;
|
||||
|
||||
opm = macro_args ? op->macro.first : NULL;
|
||||
opm = static_cast<wmOperator *>(macro_args ? op->macro.first : nullptr);
|
||||
|
||||
for (; opm; opm = opm->next) {
|
||||
PointerRNA *opmptr = opm->ptr;
|
||||
PointerRNA opmptr_default;
|
||||
if (opmptr == NULL) {
|
||||
if (opmptr == nullptr) {
|
||||
WM_operator_properties_create_ptr(&opmptr_default, opm->type);
|
||||
opmptr = &opmptr_default;
|
||||
}
|
||||
@@ -261,7 +262,7 @@ char *WM_operator_pystring_ex(bContext *C,
|
||||
PointerRNA opptr_default;
|
||||
const bool macro_args_test = ot->macro.first ? macro_args : true;
|
||||
|
||||
if (opptr == NULL) {
|
||||
if (opptr == nullptr) {
|
||||
WM_operator_properties_create_ptr(&opptr_default, ot);
|
||||
opptr = &opptr_default;
|
||||
}
|
||||
@@ -325,7 +326,7 @@ bool WM_operator_pystring_abbreviate(char *str, int str_len_max)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* return NULL if no match is found */
|
||||
/* return nullptr if no match is found */
|
||||
#if 0
|
||||
static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr, bool *r_is_id)
|
||||
{
|
||||
@@ -340,16 +341,16 @@ static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr
|
||||
ListBase lb = CTX_data_dir_get_ex(C, false, true, true);
|
||||
LinkData *link;
|
||||
|
||||
const char *member_found = NULL;
|
||||
const char *member_id = NULL;
|
||||
const char *member_found = nullptr;
|
||||
const char *member_id = nullptr;
|
||||
bool member_found_is_id = false;
|
||||
|
||||
for (link = lb.first; link; link = link->next) {
|
||||
const char *identifier = link->data;
|
||||
PointerRNA ctx_item_ptr = {
|
||||
{0}}; /* CTX_data_pointer_get(C, identifier); */ /* XXX, this isn't working. */
|
||||
PointerRNA ctx_item_ptr = {{0}};
|
||||
/* CTX_data_pointer_get(C, identifier); */ /* XXX, this isn't working. */
|
||||
|
||||
if (ctx_item_ptr.type == NULL) {
|
||||
if (ctx_item_ptr.type == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -378,7 +379,7 @@ static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr
|
||||
return member_id;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +405,7 @@ static const char *wm_context_member_from_ptr(const bContext *C,
|
||||
const PointerRNA *ptr,
|
||||
bool *r_is_id)
|
||||
{
|
||||
const char *member_id = NULL;
|
||||
const char *member_id = nullptr;
|
||||
bool is_id = false;
|
||||
|
||||
# define CTX_TEST_PTR_ID(C, member, idptr) \
|
||||
@@ -442,7 +443,7 @@ static const char *wm_context_member_from_ptr(const bContext *C,
|
||||
} \
|
||||
(void)0
|
||||
|
||||
/* A version of #TEST_PTR_DATA_TYPE that calls `CTX_data_pointer_get_type(C, member)`. */
|
||||
/* A version of #TEST_PTR_DATA_TYPE that calls `CTX_data_pointer_get_type(C, member)`. */
|
||||
# define TEST_PTR_DATA_TYPE_FROM_CONTEXT(member, rna_type, rna_ptr) \
|
||||
{ \
|
||||
const char *ctx_member = member; \
|
||||
@@ -470,7 +471,7 @@ static const char *wm_context_member_from_ptr(const bContext *C,
|
||||
}
|
||||
|
||||
/* Specific ID type checks. */
|
||||
if (ptr->owner_id && (member_id == NULL)) {
|
||||
if (ptr->owner_id && (member_id == nullptr)) {
|
||||
|
||||
const ID_Type ptr_id_type = GS(ptr->owner_id->name);
|
||||
switch (ptr_id_type) {
|
||||
@@ -491,7 +492,7 @@ static const char *wm_context_member_from_ptr(const bContext *C,
|
||||
|
||||
if (ptr_id_type == ID_AR) {
|
||||
const bArmature *arm = (bArmature *)ptr->owner_id;
|
||||
if (arm->edbo != NULL) {
|
||||
if (arm->edbo != nullptr) {
|
||||
TEST_PTR_DATA_TYPE("active_bone", RNA_EditBone, ptr, arm->act_edbone);
|
||||
}
|
||||
else {
|
||||
@@ -525,7 +526,7 @@ static const char *wm_context_member_from_ptr(const bContext *C,
|
||||
TEST_PTR_DATA_TYPE("region", RNA_Region, ptr, CTX_wm_region(C));
|
||||
|
||||
SpaceLink *space_data = CTX_wm_space_data(C);
|
||||
if (space_data != NULL) {
|
||||
if (space_data != nullptr) {
|
||||
TEST_PTR_DATA_TYPE("space_data", RNA_Space, ptr, space_data);
|
||||
|
||||
switch (space_data->spacetype) {
|
||||
@@ -593,12 +594,12 @@ char *WM_context_path_resolve_property_full(const bContext *C,
|
||||
{
|
||||
bool is_id;
|
||||
const char *member_id = wm_context_member_from_ptr(C, ptr, &is_id);
|
||||
char *member_id_data_path = NULL;
|
||||
if (member_id != NULL) {
|
||||
char *member_id_data_path = nullptr;
|
||||
if (member_id != nullptr) {
|
||||
if (is_id && !RNA_struct_is_ID(ptr->type)) {
|
||||
char *data_path = RNA_path_from_ID_to_struct(ptr);
|
||||
if (data_path != NULL) {
|
||||
if (prop != NULL) {
|
||||
if (data_path != nullptr) {
|
||||
if (prop != nullptr) {
|
||||
char *prop_str = RNA_path_property_py(ptr, prop, index);
|
||||
if (prop_str[0] == '[') {
|
||||
member_id_data_path = BLI_string_joinN(member_id, ".", data_path, prop_str);
|
||||
@@ -616,7 +617,7 @@ char *WM_context_path_resolve_property_full(const bContext *C,
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (prop != NULL) {
|
||||
if (prop != nullptr) {
|
||||
char *prop_str = RNA_path_property_py(ptr, prop, index);
|
||||
if (prop_str[0] == '[') {
|
||||
member_id_data_path = BLI_string_joinN(member_id, prop_str);
|
||||
@@ -636,7 +637,7 @@ char *WM_context_path_resolve_property_full(const bContext *C,
|
||||
|
||||
char *WM_context_path_resolve_full(bContext *C, const PointerRNA *ptr)
|
||||
{
|
||||
return WM_context_path_resolve_property_full(C, ptr, NULL, -1);
|
||||
return WM_context_path_resolve_property_full(C, ptr, nullptr, -1);
|
||||
}
|
||||
|
||||
static char *wm_prop_pystring_from_context(bContext *C,
|
||||
@@ -645,8 +646,8 @@ static char *wm_prop_pystring_from_context(bContext *C,
|
||||
int index)
|
||||
{
|
||||
char *member_id_data_path = WM_context_path_resolve_property_full(C, ptr, prop, index);
|
||||
char *ret = NULL;
|
||||
if (member_id_data_path != NULL) {
|
||||
char *ret = nullptr;
|
||||
if (member_id_data_path != nullptr) {
|
||||
ret = BLI_sprintfN("bpy.context.%s", member_id_data_path);
|
||||
MEM_freeN(member_id_data_path);
|
||||
}
|
||||
@@ -655,21 +656,21 @@ static char *wm_prop_pystring_from_context(bContext *C,
|
||||
|
||||
char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
|
||||
{
|
||||
char *lhs = C ? wm_prop_pystring_from_context(C, ptr, prop, index) : NULL;
|
||||
char *lhs = C ? wm_prop_pystring_from_context(C, ptr, prop, index) : nullptr;
|
||||
|
||||
if (lhs == NULL) {
|
||||
if (lhs == nullptr) {
|
||||
/* Fallback to `bpy.data.foo[id]` if we don't find in the context. */
|
||||
lhs = RNA_path_full_property_py(ptr, prop, index);
|
||||
}
|
||||
|
||||
if (!lhs) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char *rhs = RNA_property_as_string(C, ptr, prop, index, INT_MAX);
|
||||
if (!rhs) {
|
||||
MEM_freeN(lhs);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char *ret = BLI_sprintfN("%s = %s", lhs, rhs);
|
||||
@@ -681,7 +682,7 @@ char *WM_prop_pystring_assign(bContext *C, PointerRNA *ptr, PropertyRNA *prop, i
|
||||
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
|
||||
{
|
||||
/* Set the ID so the context can be accessed: see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */
|
||||
RNA_pointer_create(G_MAIN->wm.first, ot->srna, NULL, ptr);
|
||||
RNA_pointer_create(static_cast<ID *>(G_MAIN->wm.first), ot->srna, nullptr, ptr);
|
||||
}
|
||||
|
||||
void WM_operator_properties_create(PointerRNA *ptr, const char *opstring)
|
||||
@@ -693,25 +694,25 @@ void WM_operator_properties_create(PointerRNA *ptr, const char *opstring)
|
||||
}
|
||||
else {
|
||||
/* Set the ID so the context can be accessed: see #STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID. */
|
||||
RNA_pointer_create(G_MAIN->wm.first, &RNA_OperatorProperties, NULL, ptr);
|
||||
RNA_pointer_create(static_cast<ID *>(G_MAIN->wm.first), &RNA_OperatorProperties, nullptr, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *opstring)
|
||||
{
|
||||
IDProperty *tmp_properties = NULL;
|
||||
/* Allow passing NULL for properties, just create the properties here then. */
|
||||
if (properties == NULL) {
|
||||
IDProperty *tmp_properties = nullptr;
|
||||
/* Allow passing nullptr for properties, just create the properties here then. */
|
||||
if (properties == nullptr) {
|
||||
properties = &tmp_properties;
|
||||
}
|
||||
|
||||
if (*properties == NULL) {
|
||||
if (*properties == nullptr) {
|
||||
IDPropertyTemplate val = {0};
|
||||
*properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
|
||||
}
|
||||
|
||||
if (*ptr == NULL) {
|
||||
*ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
|
||||
if (*ptr == nullptr) {
|
||||
*ptr = static_cast<PointerRNA *>(MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"));
|
||||
WM_operator_properties_create(*ptr, opstring);
|
||||
}
|
||||
|
||||
@@ -780,7 +781,7 @@ void WM_operator_properties_reset(wmOperator *op)
|
||||
PropertyRNA *iterprop = RNA_struct_iterator_property(op->type->srna);
|
||||
|
||||
RNA_PROP_BEGIN (op->ptr, itemptr, iterprop) {
|
||||
PropertyRNA *prop = itemptr.data;
|
||||
PropertyRNA *prop = static_cast<PropertyRNA *>(itemptr.data);
|
||||
|
||||
if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
|
||||
const char *identifier = RNA_property_identifier(prop);
|
||||
@@ -793,7 +794,7 @@ void WM_operator_properties_reset(wmOperator *op)
|
||||
|
||||
void WM_operator_properties_clear(PointerRNA *ptr)
|
||||
{
|
||||
IDProperty *properties = ptr->data;
|
||||
IDProperty *properties = static_cast<IDProperty *>(ptr->data);
|
||||
|
||||
if (properties) {
|
||||
IDP_ClearProperty(properties);
|
||||
@@ -802,11 +803,11 @@ void WM_operator_properties_clear(PointerRNA *ptr)
|
||||
|
||||
void WM_operator_properties_free(PointerRNA *ptr)
|
||||
{
|
||||
IDProperty *properties = ptr->data;
|
||||
IDProperty *properties = static_cast<IDProperty *>(ptr->data);
|
||||
|
||||
if (properties) {
|
||||
IDP_FreeProperty(properties);
|
||||
ptr->data = NULL; /* just in case */
|
||||
ptr->data = nullptr; /* just in case */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,7 +830,7 @@ static bool operator_last_properties_init_impl(wmOperator *op, IDProperty *last_
|
||||
PropertyRNA *iterprop = RNA_struct_iterator_property(op->type->srna);
|
||||
|
||||
RNA_PROP_BEGIN (op->ptr, itemptr, iterprop) {
|
||||
PropertyRNA *prop = itemptr.data;
|
||||
PropertyRNA *prop = static_cast<PropertyRNA *>(itemptr.data);
|
||||
if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
|
||||
if (!RNA_property_is_set(op->ptr, prop)) { /* don't override a setting already set */
|
||||
const char *identifier = RNA_property_identifier(prop);
|
||||
@@ -875,7 +876,7 @@ bool WM_operator_last_properties_store(wmOperator *op)
|
||||
{
|
||||
if (op->type->last_properties) {
|
||||
IDP_FreeProperty(op->type->last_properties);
|
||||
op->type->last_properties = NULL;
|
||||
op->type->last_properties = nullptr;
|
||||
}
|
||||
|
||||
if (op->properties) {
|
||||
@@ -883,12 +884,12 @@ bool WM_operator_last_properties_store(wmOperator *op)
|
||||
op->type->last_properties = IDP_CopyProperty(op->properties);
|
||||
}
|
||||
|
||||
if (op->macro.first != NULL) {
|
||||
if (op->macro.first != nullptr) {
|
||||
LISTBASE_FOREACH (wmOperator *, opm, &op->macro) {
|
||||
if (opm->properties) {
|
||||
if (op->type->last_properties == NULL) {
|
||||
op->type->last_properties = IDP_New(
|
||||
IDP_GROUP, &(IDPropertyTemplate){0}, "wmOperatorProperties");
|
||||
if (op->type->last_properties == nullptr) {
|
||||
IDPropertyTemplate temp{};
|
||||
op->type->last_properties = IDP_New(IDP_GROUP, &temp, "wmOperatorProperties");
|
||||
}
|
||||
IDProperty *idp_macro = IDP_CopyProperty(opm->properties);
|
||||
STRNCPY(idp_macro->name, opm->type->idname);
|
||||
@@ -897,17 +898,17 @@ bool WM_operator_last_properties_store(wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
return (op->type->last_properties != NULL);
|
||||
return (op->type->last_properties != nullptr);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool WM_operator_last_properties_init(wmOperator *UNUSED(op))
|
||||
bool WM_operator_last_properties_init(wmOperator * /*op*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WM_operator_last_properties_store(wmOperator *UNUSED(op))
|
||||
bool WM_operator_last_properties_store(wmOperator * /*op*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1000,8 +1001,8 @@ void WM_operator_view3d_unit_defaults(bContext *C, wmOperator *op)
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) :
|
||||
ED_scene_grid_scale(scene, NULL);
|
||||
const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, nullptr) :
|
||||
ED_scene_grid_scale(scene, nullptr);
|
||||
|
||||
/* always run, so the values are initialized,
|
||||
* otherwise we may get differ behavior when (dia != 1.0) */
|
||||
@@ -1032,7 +1033,7 @@ int WM_menu_invoke_ex(bContext *C, wmOperator *op, wmOperatorCallContext opconte
|
||||
{
|
||||
PropertyRNA *prop = op->type->prop;
|
||||
|
||||
if (prop == NULL) {
|
||||
if (prop == nullptr) {
|
||||
CLOG_ERROR(WM_LOG_OPERATORS, "'%s' has no enum property set", op->type->idname);
|
||||
}
|
||||
else if (RNA_property_type(prop) != PROP_ENUM) {
|
||||
@@ -1051,8 +1052,12 @@ int WM_menu_invoke_ex(bContext *C, wmOperator *op, wmOperatorCallContext opconte
|
||||
uiLayout *layout = UI_popup_menu_layout(pup);
|
||||
/* set this so the default execution context is the same as submenus */
|
||||
uiLayoutSetOperatorContext(layout, opcontext);
|
||||
uiItemsFullEnumO(
|
||||
layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, opcontext, 0);
|
||||
uiItemsFullEnumO(layout,
|
||||
op->type->idname,
|
||||
RNA_property_identifier(prop),
|
||||
static_cast<IDProperty *>(op->ptr->data),
|
||||
opcontext,
|
||||
0);
|
||||
UI_popup_menu_end(C, pup);
|
||||
return OPERATOR_INTERFACE;
|
||||
}
|
||||
@@ -1060,7 +1065,7 @@ int WM_menu_invoke_ex(bContext *C, wmOperator *op, wmOperatorCallContext opconte
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
return WM_menu_invoke_ex(C, op, WM_OP_INVOKE_REGION_WIN);
|
||||
}
|
||||
@@ -1075,7 +1080,7 @@ struct EnumSearchMenu {
|
||||
/** Generic enum search invoke popup. */
|
||||
static uiBlock *wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
|
||||
{
|
||||
struct EnumSearchMenu *search_menu = arg;
|
||||
struct EnumSearchMenu *search_menu = static_cast<EnumSearchMenu *>(arg);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
wmOperator *op = search_menu->op;
|
||||
/* template_ID uses 4 * widget_unit for width,
|
||||
@@ -1102,7 +1107,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
|
||||
10,
|
||||
UI_searchbox_size_x(),
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
0,
|
||||
@@ -1111,7 +1116,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
|
||||
#endif
|
||||
uiBut *but = uiDefSearchButO_ptr(block,
|
||||
op->type,
|
||||
op->ptr->data,
|
||||
static_cast<IDProperty *>(op->ptr->data),
|
||||
search,
|
||||
0,
|
||||
ICON_VIEWZOOM,
|
||||
@@ -1133,15 +1138,15 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *region, void *arg)
|
||||
10 - UI_searchbox_size_y(),
|
||||
width,
|
||||
height,
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
/* Move it downwards, mouse over button. */
|
||||
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, (const int[2]){0, -UI_UNIT_Y});
|
||||
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, blender::int2{0, -UI_UNIT_Y});
|
||||
|
||||
UI_but_focus_on_enter_event(win, but);
|
||||
|
||||
@@ -1157,16 +1162,16 @@ int WM_enum_search_invoke_previews(bContext *C, wmOperator *op, short prv_cols,
|
||||
search_menu.prv_cols = prv_cols;
|
||||
search_menu.prv_rows = prv_rows;
|
||||
|
||||
UI_popup_block_invoke(C, wm_enum_search_menu, &search_menu, NULL);
|
||||
UI_popup_block_invoke(C, wm_enum_search_menu, &search_menu, nullptr);
|
||||
|
||||
return OPERATOR_INTERFACE;
|
||||
}
|
||||
|
||||
int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
static struct EnumSearchMenu search_menu;
|
||||
search_menu.op = op;
|
||||
UI_popup_block_invoke(C, wm_enum_search_menu, &search_menu, NULL);
|
||||
UI_popup_block_invoke(C, wm_enum_search_menu, &search_menu, nullptr);
|
||||
return OPERATOR_INTERFACE;
|
||||
}
|
||||
|
||||
@@ -1177,18 +1182,18 @@ int WM_operator_confirm_message_ex(bContext *C,
|
||||
const char *message,
|
||||
const wmOperatorCallContext opcontext)
|
||||
{
|
||||
IDProperty *properties = op->ptr->data;
|
||||
IDProperty *properties = static_cast<IDProperty *>(op->ptr->data);
|
||||
|
||||
if (properties && properties->len) {
|
||||
properties = IDP_CopyProperty(op->ptr->data);
|
||||
properties = IDP_CopyProperty(static_cast<const IDProperty *>(op->ptr->data));
|
||||
}
|
||||
else {
|
||||
properties = NULL;
|
||||
properties = nullptr;
|
||||
}
|
||||
|
||||
uiPopupMenu *pup = UI_popup_menu_begin(C, title, icon);
|
||||
uiLayout *layout = UI_popup_menu_layout(pup);
|
||||
uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, opcontext, 0, NULL);
|
||||
uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, opcontext, 0, nullptr);
|
||||
UI_popup_menu_end(C, pup);
|
||||
|
||||
return OPERATOR_INTERFACE;
|
||||
@@ -1200,21 +1205,21 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message
|
||||
C, op, IFACE_("OK?"), ICON_QUESTION, message, WM_OP_EXEC_REGION_WIN);
|
||||
}
|
||||
|
||||
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
return WM_operator_confirm_message(C, op, NULL);
|
||||
return WM_operator_confirm_message(C, op, nullptr);
|
||||
}
|
||||
|
||||
int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
const bool confirm = RNA_boolean_get(op->ptr, "confirm");
|
||||
if (confirm) {
|
||||
return WM_operator_confirm_message(C, op, NULL);
|
||||
return WM_operator_confirm_message(C, op, nullptr);
|
||||
}
|
||||
return op->type->exec(C, op);
|
||||
}
|
||||
|
||||
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
return WM_operator_call_notest(C, op); /* call exec direct */
|
||||
@@ -1226,7 +1231,7 @@ int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event
|
||||
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const ImageFormatData *im_format)
|
||||
{
|
||||
char filepath[FILE_MAX];
|
||||
/* Don't NULL check prop, this can only run on ops with a 'filepath'. */
|
||||
/* Don't nullptr check prop, this can only run on ops with a 'filepath'. */
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath");
|
||||
RNA_property_string_get(op->ptr, prop, filepath);
|
||||
if (BKE_image_path_ext_from_imformat_ensure(filepath, sizeof(filepath), im_format)) {
|
||||
@@ -1240,7 +1245,7 @@ bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const ImageFormatData
|
||||
|
||||
bool WM_operator_winactive(bContext *C)
|
||||
{
|
||||
if (CTX_wm_window(C) == NULL) {
|
||||
if (CTX_wm_window(C) == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -1265,12 +1270,12 @@ wmOperator *WM_operator_last_redo(const bContext *C)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IDProperty *WM_operator_last_properties_ensure_idprops(wmOperatorType *ot)
|
||||
{
|
||||
if (ot->last_properties == NULL) {
|
||||
if (ot->last_properties == nullptr) {
|
||||
IDPropertyTemplate val = {0};
|
||||
ot->last_properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
|
||||
}
|
||||
@@ -1280,13 +1285,13 @@ IDProperty *WM_operator_last_properties_ensure_idprops(wmOperatorType *ot)
|
||||
void WM_operator_last_properties_ensure(wmOperatorType *ot, PointerRNA *ptr)
|
||||
{
|
||||
IDProperty *props = WM_operator_last_properties_ensure_idprops(ot);
|
||||
RNA_pointer_create(G_MAIN->wm.first, ot->srna, props, ptr);
|
||||
RNA_pointer_create(static_cast<ID *>(G_MAIN->wm.first), ot->srna, props, ptr);
|
||||
}
|
||||
|
||||
ID *WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
ID *id = NULL;
|
||||
ID *id = nullptr;
|
||||
|
||||
/* check input variables */
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
@@ -1312,7 +1317,7 @@ ID *WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
|
||||
BKE_idtype_idcode_to_name(idcode),
|
||||
filepath,
|
||||
errno ? strerror(errno) : TIP_("unsupported format"));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (is_relative_path) {
|
||||
@@ -1330,11 +1335,11 @@ ID *WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
|
||||
}
|
||||
|
||||
if (!WM_operator_properties_id_lookup_is_set(op->ptr)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Lookup an already existing ID. */
|
||||
id = WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, idcode);
|
||||
id = WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_Type(idcode));
|
||||
|
||||
if (!id) {
|
||||
/* Print error with the name if the name is available. */
|
||||
@@ -1344,20 +1349,20 @@ ID *WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
BKE_reportf(
|
||||
op->reports, RPT_ERROR, "%s '%s' not found", BKE_idtype_idcode_to_name(idcode), name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BKE_reportf(op->reports, RPT_ERROR, "%s not found", BKE_idtype_idcode_to_name(idcode));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
id_us_plus(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
static void wm_block_redo_cb(bContext *C, void *arg_op, int UNUSED(arg_event))
|
||||
static void wm_block_redo_cb(bContext *C, void *arg_op, int /*arg_event*/)
|
||||
{
|
||||
wmOperator *op = arg_op;
|
||||
wmOperator *op = static_cast<wmOperator *>(arg_op);
|
||||
|
||||
if (op == WM_operator_last_redo(C)) {
|
||||
/* operator was already executed once? undo & repeat */
|
||||
@@ -1374,7 +1379,7 @@ static void wm_block_redo_cb(bContext *C, void *arg_op, int UNUSED(arg_event))
|
||||
|
||||
static void wm_block_redo_cancel_cb(bContext *C, void *arg_op)
|
||||
{
|
||||
wmOperator *op = arg_op;
|
||||
wmOperator *op = static_cast<wmOperator *>(arg_op);
|
||||
|
||||
/* if operator never got executed, free it */
|
||||
if (op != WM_operator_last_redo(C)) {
|
||||
@@ -1384,7 +1389,7 @@ static void wm_block_redo_cancel_cb(bContext *C, void *arg_op)
|
||||
|
||||
static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
|
||||
{
|
||||
wmOperator *op = arg_op;
|
||||
wmOperator *op = static_cast<wmOperator *>(arg_op);
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
int width = 15 * UI_UNIT_X;
|
||||
|
||||
@@ -1413,17 +1418,17 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
|
||||
uiTemplateOperatorPropertyButs(
|
||||
C, col, op, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
|
||||
UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, NULL);
|
||||
UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, nullptr);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
typedef struct wmOpPopUp {
|
||||
struct wmOpPopUp {
|
||||
wmOperator *op;
|
||||
int width;
|
||||
int height;
|
||||
int free_op;
|
||||
} wmOpPopUp;
|
||||
};
|
||||
|
||||
/* Only invoked by OK button in popups created with wm_block_dialog_create() */
|
||||
static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
|
||||
@@ -1432,12 +1437,12 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
|
||||
{
|
||||
/* Execute will free the operator.
|
||||
* In this case, wm_operator_ui_popup_cancel won't run. */
|
||||
wmOpPopUp *data = arg1;
|
||||
wmOpPopUp *data = static_cast<wmOpPopUp *>(arg1);
|
||||
op = data->op;
|
||||
MEM_freeN(data);
|
||||
}
|
||||
|
||||
uiBlock *block = arg2;
|
||||
uiBlock *block = static_cast<uiBlock *>(arg2);
|
||||
/* Explicitly set UI_RETURN_OK flag, otherwise the menu might be canceled
|
||||
* in case WM_operator_call_ex exits/reloads the current file (#49199). */
|
||||
|
||||
@@ -1454,7 +1459,7 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
|
||||
/* Dialogs are popups that require user verification (click OK) before exec */
|
||||
static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userData)
|
||||
{
|
||||
wmOpPopUp *data = userData;
|
||||
wmOpPopUp *data = static_cast<wmOpPopUp *>(userData);
|
||||
wmOperator *op = data->op;
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
|
||||
@@ -1473,7 +1478,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userD
|
||||
C, layout, op, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
|
||||
/* clear so the OK button is left alone */
|
||||
UI_block_func_set(block, NULL, NULL, NULL);
|
||||
UI_block_func_set(block, nullptr, nullptr, nullptr);
|
||||
|
||||
/* new column so as not to interfere with custom layouts #26436. */
|
||||
{
|
||||
@@ -1481,21 +1486,21 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userD
|
||||
uiBlock *col_block = uiLayoutGetBlock(col);
|
||||
/* Create OK button, the callback of which will execute op */
|
||||
uiBut *but = uiDefBut(
|
||||
col_block, UI_BTYPE_BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
|
||||
col_block, UI_BTYPE_BUT, 0, IFACE_("OK"), 0, -30, 0, UI_UNIT_Y, nullptr, 0, 0, 0, 0, "");
|
||||
UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT);
|
||||
UI_but_func_set(but, dialog_exec_cb, data, col_block);
|
||||
}
|
||||
|
||||
/* center around the mouse */
|
||||
UI_block_bounds_set_popup(
|
||||
block, 6 * UI_SCALE_FAC, (const int[2]){data->width / -2, data->height / 2});
|
||||
block, 6 * UI_SCALE_FAC, blender::int2{data->width / -2, data->height / 2});
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static uiBlock *wm_operator_ui_create(bContext *C, ARegion *region, void *userData)
|
||||
{
|
||||
wmOpPopUp *data = userData;
|
||||
wmOpPopUp *data = static_cast<wmOpPopUp *>(userData);
|
||||
wmOperator *op = data->op;
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
|
||||
@@ -1510,16 +1515,16 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *region, void *userDa
|
||||
/* since ui is defined the auto-layout args are not used */
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, UI_BUT_LABEL_ALIGN_COLUMN, 0);
|
||||
|
||||
UI_block_func_set(block, NULL, NULL, NULL);
|
||||
UI_block_func_set(block, nullptr, nullptr, nullptr);
|
||||
|
||||
UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, NULL);
|
||||
UI_block_bounds_set_popup(block, 6 * UI_SCALE_FAC, nullptr);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static void wm_operator_ui_popup_cancel(bContext *C, void *userData)
|
||||
{
|
||||
wmOpPopUp *data = userData;
|
||||
wmOpPopUp *data = static_cast<wmOpPopUp *>(userData);
|
||||
wmOperator *op = data->op;
|
||||
|
||||
if (op) {
|
||||
@@ -1537,7 +1542,7 @@ static void wm_operator_ui_popup_cancel(bContext *C, void *userData)
|
||||
|
||||
static void wm_operator_ui_popup_ok(bContext *C, void *arg, int retval)
|
||||
{
|
||||
wmOpPopUp *data = arg;
|
||||
wmOpPopUp *data = static_cast<wmOpPopUp *>(arg);
|
||||
wmOperator *op = data->op;
|
||||
|
||||
if (op && retval > 0) {
|
||||
@@ -1549,13 +1554,14 @@ static void wm_operator_ui_popup_ok(bContext *C, void *arg, int retval)
|
||||
|
||||
int WM_operator_ui_popup(bContext *C, wmOperator *op, int width)
|
||||
{
|
||||
wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup");
|
||||
wmOpPopUp *data = static_cast<wmOpPopUp *>(
|
||||
MEM_callocN(sizeof(wmOpPopUp), "WM_operator_ui_popup"));
|
||||
data->op = op;
|
||||
data->width = width * UI_SCALE_FAC;
|
||||
/* Actual used height depends on the content. */
|
||||
data->height = 0;
|
||||
data->free_op = true; /* if this runs and gets registered we may want not to free it */
|
||||
UI_popup_block_ex(C, wm_operator_ui_create, NULL, wm_operator_ui_popup_cancel, data, op);
|
||||
UI_popup_block_ex(C, wm_operator_ui_create, nullptr, wm_operator_ui_popup_cancel, data, op);
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
@@ -1593,7 +1599,7 @@ static int wm_operator_props_popup_ex(bContext *C,
|
||||
return WM_operator_props_dialog_popup(C, op, 300);
|
||||
}
|
||||
|
||||
UI_popup_block_ex(C, wm_block_create_redo, NULL, wm_block_redo_cancel_cb, op, op);
|
||||
UI_popup_block_ex(C, wm_block_create_redo, nullptr, wm_block_redo_cancel_cb, op, op);
|
||||
|
||||
if (do_call) {
|
||||
wm_block_redo_cb(C, op, 0);
|
||||
@@ -1602,24 +1608,25 @@ static int wm_operator_props_popup_ex(bContext *C,
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
int WM_operator_props_popup_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_operator_props_popup_confirm(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
return wm_operator_props_popup_ex(C, op, false, false);
|
||||
}
|
||||
|
||||
int WM_operator_props_popup_call(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_operator_props_popup_call(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
return wm_operator_props_popup_ex(C, op, true, true);
|
||||
}
|
||||
|
||||
int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
return wm_operator_props_popup_ex(C, op, false, true);
|
||||
}
|
||||
|
||||
int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width)
|
||||
{
|
||||
wmOpPopUp *data = MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup");
|
||||
wmOpPopUp *data = static_cast<wmOpPopUp *>(
|
||||
MEM_callocN(sizeof(wmOpPopUp), "WM_operator_props_dialog_popup"));
|
||||
|
||||
data->op = op;
|
||||
data->width = width * UI_SCALE_FAC;
|
||||
@@ -1650,7 +1657,7 @@ int WM_operator_redo_popup(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
UI_popup_block_invoke(C, wm_block_create_redo, op, NULL);
|
||||
UI_popup_block_invoke(C, wm_block_create_redo, op, nullptr);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -1667,12 +1674,12 @@ static int wm_debug_menu_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
G.debug_value = RNA_int_get(op->ptr, "debug_value");
|
||||
ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C));
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int wm_debug_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int wm_debug_menu_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
RNA_int_set(op->ptr, "debug_value", G.debug_value);
|
||||
return WM_operator_props_dialog_popup(C, op, 250);
|
||||
@@ -1728,18 +1735,20 @@ static void WM_OT_operator_defaults(wmOperatorType *ot)
|
||||
/** \name Operator/Menu Search Operator
|
||||
* \{ */
|
||||
|
||||
struct SearchPopupInit_Data {
|
||||
enum {
|
||||
SEARCH_TYPE_OPERATOR = 0,
|
||||
SEARCH_TYPE_MENU = 1,
|
||||
} search_type;
|
||||
enum SearchType {
|
||||
SEARCH_TYPE_OPERATOR = 0,
|
||||
SEARCH_TYPE_MENU = 1,
|
||||
};
|
||||
|
||||
struct SearchPopupInit_Data {
|
||||
SearchType search_type;
|
||||
int size[2];
|
||||
};
|
||||
|
||||
static uiBlock *wm_block_search_menu(bContext *C, ARegion *region, void *userdata)
|
||||
{
|
||||
const struct SearchPopupInit_Data *init_data = userdata;
|
||||
const struct SearchPopupInit_Data *init_data = static_cast<const SearchPopupInit_Data *>(
|
||||
userdata);
|
||||
static char search[256] = "";
|
||||
|
||||
uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
|
||||
@@ -1780,20 +1789,20 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *region, void *userdat
|
||||
10 - init_data->size[1],
|
||||
init_data->size[0],
|
||||
init_data->size[1],
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
/* Move it downwards, mouse over button. */
|
||||
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, (const int[2]){0, -UI_UNIT_Y});
|
||||
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, blender::int2{0, -UI_UNIT_Y});
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int wm_search_menu_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1834,13 +1843,12 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *eve
|
||||
search_type = SEARCH_TYPE_OPERATOR;
|
||||
}
|
||||
|
||||
static struct SearchPopupInit_Data data;
|
||||
data = (struct SearchPopupInit_Data){
|
||||
.search_type = search_type,
|
||||
.size = {UI_searchbox_size_x() * 2, UI_searchbox_size_y()},
|
||||
};
|
||||
static SearchPopupInit_Data data{};
|
||||
data.search_type = SearchType(search_type);
|
||||
data.size[0] = UI_searchbox_size_x() * 2;
|
||||
data.size[1] = UI_searchbox_size_y();
|
||||
|
||||
UI_popup_block_invoke_ex(C, wm_block_search_menu, &data, NULL, false);
|
||||
UI_popup_block_invoke_ex(C, wm_block_search_menu, &data, nullptr, false);
|
||||
|
||||
return OPERATOR_INTERFACE;
|
||||
}
|
||||
@@ -1898,7 +1906,7 @@ static void WM_OT_call_menu(wmOperatorType *ot)
|
||||
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu");
|
||||
prop = RNA_def_string(ot->srna, "name", nullptr, BKE_ST_MAXNAME, "Name", "Name of the menu");
|
||||
RNA_def_property_string_search_func_runtime(
|
||||
prop,
|
||||
WM_menutype_idname_visit_for_search,
|
||||
@@ -1937,7 +1945,7 @@ static void WM_OT_call_menu_pie(wmOperatorType *ot)
|
||||
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the pie menu");
|
||||
prop = RNA_def_string(ot->srna, "name", nullptr, BKE_ST_MAXNAME, "Name", "Name of the pie menu");
|
||||
RNA_def_property_string_search_func_runtime(
|
||||
prop,
|
||||
WM_menutype_idname_visit_for_search,
|
||||
@@ -1977,7 +1985,7 @@ static void WM_OT_call_panel(wmOperatorType *ot)
|
||||
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_string(ot->srna, "name", NULL, BKE_ST_MAXNAME, "Name", "Name of the menu");
|
||||
prop = RNA_def_string(ot->srna, "name", nullptr, BKE_ST_MAXNAME, "Name", "Name of the menu");
|
||||
RNA_def_property_string_search_func_runtime(
|
||||
prop,
|
||||
WM_paneltype_idname_visit_for_search,
|
||||
@@ -2001,7 +2009,7 @@ static bool wm_operator_winactive_normal(bContext *C)
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *screen;
|
||||
|
||||
if (win == NULL) {
|
||||
if (win == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (!((screen = WM_window_get_active_screen(win)) && (screen->state == SCREENNORMAL))) {
|
||||
@@ -2055,15 +2063,13 @@ static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
|
||||
ot->poll = WM_operator_winactive;
|
||||
}
|
||||
|
||||
static int wm_exit_blender_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int wm_exit_blender_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
wm_exit_schedule_delayed(C);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int wm_exit_blender_invoke(bContext *C,
|
||||
wmOperator *UNUSED(op),
|
||||
const wmEvent *UNUSED(event))
|
||||
static int wm_exit_blender_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/)
|
||||
{
|
||||
if (U.uiflag & USER_SAVE_PROMPT) {
|
||||
wm_quit_with_optional_confirmation_prompt(C, CTX_wm_window(C));
|
||||
@@ -2092,7 +2098,7 @@ static void WM_OT_quit_blender(wmOperatorType *ot)
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
static int wm_console_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int wm_console_toggle_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
GHOST_setConsoleWindowState(GHOST_kConsoleWindowStateToggle);
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -2128,9 +2134,10 @@ wmPaintCursor *WM_paint_cursor_activate(short space_type,
|
||||
wmPaintCursorDraw draw,
|
||||
void *customdata)
|
||||
{
|
||||
wmWindowManager *wm = G_MAIN->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
|
||||
|
||||
wmPaintCursor *pc = MEM_callocN(sizeof(wmPaintCursor), "paint cursor");
|
||||
wmPaintCursor *pc = static_cast<wmPaintCursor *>(
|
||||
MEM_callocN(sizeof(wmPaintCursor), "paint cursor"));
|
||||
|
||||
BLI_addtail(&wm->paintcursors, pc);
|
||||
|
||||
@@ -2146,7 +2153,7 @@ wmPaintCursor *WM_paint_cursor_activate(short space_type,
|
||||
|
||||
bool WM_paint_cursor_end(wmPaintCursor *handle)
|
||||
{
|
||||
wmWindowManager *wm = G_MAIN->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
|
||||
LISTBASE_FOREACH (wmPaintCursor *, pc, &wm->paintcursors) {
|
||||
if (pc == (wmPaintCursor *)handle) {
|
||||
BLI_remlink(&wm->paintcursors, pc);
|
||||
@@ -2182,7 +2189,7 @@ void WM_paint_cursor_remove_by_type(wmWindowManager *wm, void *draw_fn, void (*f
|
||||
(WM_RADIAL_CONTROL_DISPLAY_SIZE - WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE)
|
||||
#define WM_RADIAL_MAX_STR 10
|
||||
|
||||
typedef struct {
|
||||
struct RadialControl {
|
||||
PropertyType type;
|
||||
PropertySubType subtype;
|
||||
PointerRNA ptr, col_ptr, fill_col_ptr, rot_ptr, zoom_ptr, image_id_ptr;
|
||||
@@ -2203,11 +2210,11 @@ typedef struct {
|
||||
void *cursor;
|
||||
NumInput num_input;
|
||||
int init_event;
|
||||
} RadialControl;
|
||||
};
|
||||
|
||||
static void radial_control_update_header(wmOperator *op, bContext *C)
|
||||
{
|
||||
RadialControl *rc = op->customdata;
|
||||
RadialControl *rc = static_cast<RadialControl *>(op->customdata);
|
||||
char msg[UI_MAX_DRAW_STR];
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -2301,7 +2308,7 @@ static void radial_control_set_tex(RadialControl *rc)
|
||||
switch (RNA_type_to_ID_code(rc->image_id_ptr.type)) {
|
||||
case ID_BR:
|
||||
if ((ibuf = BKE_brush_gen_radial_control_imbuf(
|
||||
rc->image_id_ptr.data,
|
||||
static_cast<Brush *>(rc->image_id_ptr.data),
|
||||
rc->use_secondary_tex,
|
||||
!ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE))))
|
||||
{
|
||||
@@ -2418,9 +2425,9 @@ static void radial_control_paint_curve(uint pos, Brush *br, float radius, int li
|
||||
immEnd();
|
||||
}
|
||||
|
||||
static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void *customdata)
|
||||
static void radial_control_paint_cursor(bContext * /*C*/, int x, int y, void *customdata)
|
||||
{
|
||||
RadialControl *rc = customdata;
|
||||
RadialControl *rc = static_cast<RadialControl *>(customdata);
|
||||
const uiStyle *style = UI_style_get();
|
||||
const uiFontStyle *fstyle = &style->widget;
|
||||
const int fontid = fstyle->uifont_id;
|
||||
@@ -2551,7 +2558,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
|
||||
|
||||
/* draw curve falloff preview */
|
||||
if (RNA_type_to_ID_code(rc->image_id_ptr.type) == ID_BR && rc->subtype == PROP_FACTOR) {
|
||||
Brush *br = rc->image_id_ptr.data;
|
||||
Brush *br = static_cast<Brush *>(rc->image_id_ptr.data);
|
||||
if (br) {
|
||||
radial_control_paint_curve(pos, br, r2, 120);
|
||||
}
|
||||
@@ -2572,11 +2579,11 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void
|
||||
GPU_line_smooth(false);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
enum RCPropFlags {
|
||||
RC_PROP_ALLOW_MISSING = 1,
|
||||
RC_PROP_REQUIRE_FLOAT = 2,
|
||||
RC_PROP_REQUIRE_BOOL = 4,
|
||||
} RCPropFlags;
|
||||
};
|
||||
|
||||
/**
|
||||
* Attempt to retrieve the rna pointer/property from an rna path.
|
||||
@@ -2601,13 +2608,13 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
|
||||
|
||||
/* get an rna string path from the operator's properties */
|
||||
char *str;
|
||||
if (!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0, NULL))) {
|
||||
if (!(str = RNA_string_get_alloc(op->ptr, name, nullptr, 0, nullptr))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (str[0] == '\0') {
|
||||
if (r_prop) {
|
||||
*r_prop = NULL;
|
||||
*r_prop = nullptr;
|
||||
}
|
||||
MEM_freeN(str);
|
||||
return 1;
|
||||
@@ -2661,21 +2668,21 @@ static int radial_control_get_path(PointerRNA *ctx_ptr,
|
||||
/* initialize the rna pointers and properties using rna paths */
|
||||
static int radial_control_get_properties(bContext *C, wmOperator *op)
|
||||
{
|
||||
RadialControl *rc = op->customdata;
|
||||
RadialControl *rc = static_cast<RadialControl *>(op->customdata);
|
||||
|
||||
PointerRNA ctx_ptr;
|
||||
RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
|
||||
RNA_pointer_create(nullptr, &RNA_Context, C, &ctx_ptr);
|
||||
|
||||
/* check if we use primary or secondary path */
|
||||
PointerRNA use_secondary_ptr;
|
||||
PropertyRNA *use_secondary_prop = NULL;
|
||||
PropertyRNA *use_secondary_prop = nullptr;
|
||||
if (!radial_control_get_path(&ctx_ptr,
|
||||
op,
|
||||
"use_secondary",
|
||||
&use_secondary_ptr,
|
||||
&use_secondary_prop,
|
||||
0,
|
||||
(RC_PROP_ALLOW_MISSING | RC_PROP_REQUIRE_BOOL)))
|
||||
RCPropFlags((RC_PROP_ALLOW_MISSING | RC_PROP_REQUIRE_BOOL))))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -2688,7 +2695,7 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
|
||||
data_path = "data_path_primary";
|
||||
}
|
||||
|
||||
if (!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, 0)) {
|
||||
if (!radial_control_get_path(&ctx_ptr, op, data_path, &rc->ptr, &rc->prop, 0, RCPropFlags(0))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2750,12 +2757,14 @@ static int radial_control_get_properties(bContext *C, wmOperator *op)
|
||||
&rc->zoom_ptr,
|
||||
&rc->zoom_prop,
|
||||
2,
|
||||
RC_PROP_REQUIRE_FLOAT | RC_PROP_ALLOW_MISSING))
|
||||
RCPropFlags(RC_PROP_REQUIRE_FLOAT | RC_PROP_ALLOW_MISSING)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0)) {
|
||||
if (!radial_control_get_path(
|
||||
&ctx_ptr, op, "image_id", &rc->image_id_ptr, nullptr, 0, RCPropFlags(0)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (rc->image_id_ptr.data) {
|
||||
@@ -2776,7 +2785,9 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve
|
||||
wmWindowManager *wm;
|
||||
RadialControl *rc;
|
||||
|
||||
if (!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl"))) {
|
||||
if (!(op->customdata = rc = static_cast<RadialControl *>(
|
||||
MEM_callocN(sizeof(RadialControl), "RadialControl"))))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -2875,15 +2886,15 @@ static void radial_control_set_value(RadialControl *rc, float val)
|
||||
|
||||
static void radial_control_cancel(bContext *C, wmOperator *op)
|
||||
{
|
||||
RadialControl *rc = op->customdata;
|
||||
RadialControl *rc = static_cast<RadialControl *>(op->customdata);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
|
||||
MEM_SAFE_FREE(rc->dial);
|
||||
|
||||
ED_area_status_text(area, NULL);
|
||||
ED_area_status_text(area, nullptr);
|
||||
|
||||
WM_paint_cursor_end(rc->cursor);
|
||||
WM_paint_cursor_end(static_cast<wmPaintCursor *>(rc->cursor));
|
||||
|
||||
/* restore original paint cursors */
|
||||
wm->paintcursors = rc->orig_paintcursors;
|
||||
@@ -2891,9 +2902,9 @@ static void radial_control_cancel(bContext *C, wmOperator *op)
|
||||
/* not sure if this is a good notifier to use;
|
||||
* intended purpose is to update the UI so that the
|
||||
* new value is displayed in sliders/numfields */
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
|
||||
if (rc->texture != NULL) {
|
||||
if (rc->texture != nullptr) {
|
||||
GPU_texture_free(rc->texture);
|
||||
}
|
||||
|
||||
@@ -2902,7 +2913,7 @@ static void radial_control_cancel(bContext *C, wmOperator *op)
|
||||
|
||||
static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
RadialControl *rc = op->customdata;
|
||||
RadialControl *rc = static_cast<RadialControl *>(op->customdata);
|
||||
float new_value, dist = 0.0f, zoom[2];
|
||||
float delta[2];
|
||||
int ret = OPERATOR_RUNNING_MODAL;
|
||||
@@ -2961,7 +2972,9 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
|
||||
delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1];
|
||||
|
||||
/* precision angle gets calculated from dial and gets added later */
|
||||
angle_precision = -0.1f * BLI_dial_angle(rc->dial, (float[2]){UNPACK2(event->xy)});
|
||||
angle_precision = -0.1f * BLI_dial_angle(rc->dial,
|
||||
blender::float2{float(event->xy[0]),
|
||||
float(event->xy[1])});
|
||||
}
|
||||
else {
|
||||
delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
|
||||
@@ -3056,8 +3069,9 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
|
||||
rc->slow_mouse[1] = event->xy[1];
|
||||
rc->slow_mode = true;
|
||||
if (rc->subtype == PROP_ANGLE) {
|
||||
const float initial_position[2] = {UNPACK2(rc->initial_mouse)};
|
||||
const float current_position[2] = {UNPACK2(rc->slow_mouse)};
|
||||
const float initial_position[2] = {float(rc->initial_mouse[0]),
|
||||
float(rc->initial_mouse[1])};
|
||||
const float current_position[2] = {float(rc->slow_mouse[0]), float(rc->slow_mouse[1])};
|
||||
rc->dial = BLI_dial_init(initial_position, 0.0f);
|
||||
/* immediately set the position to get a an initial direction */
|
||||
BLI_dial_angle(rc->dial, current_position);
|
||||
@@ -3136,7 +3150,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"data_path_primary",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Primary Data Path",
|
||||
"Primary path of property to be set by the radial control");
|
||||
@@ -3144,7 +3158,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
|
||||
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"data_path_secondary",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Secondary Data Path",
|
||||
"Secondary path of property to be set by the radial control");
|
||||
@@ -3152,7 +3166,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
|
||||
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"use_secondary",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Use Secondary",
|
||||
"Path of property to select between the primary and secondary data paths");
|
||||
@@ -3160,7 +3174,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
|
||||
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"rotation_path",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Rotation Path",
|
||||
"Path of property used to rotate the texture display");
|
||||
@@ -3168,7 +3182,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
|
||||
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"color_path",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Color Path",
|
||||
"Path of property used to set the color of the control");
|
||||
@@ -3176,22 +3190,22 @@ static void WM_OT_radial_control(wmOperatorType *ot)
|
||||
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"fill_color_path",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Fill Color Path",
|
||||
"Path of property used to set the fill color of the control");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_string(
|
||||
ot->srna, "fill_color_override_path", NULL, 0, "Fill Color Override Path", "");
|
||||
ot->srna, "fill_color_override_path", nullptr, 0, "Fill Color Override Path", "");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
prop = RNA_def_string(
|
||||
ot->srna, "fill_color_override_test_path", NULL, 0, "Fill Color Override Test", "");
|
||||
ot->srna, "fill_color_override_test_path", nullptr, 0, "Fill Color Override Test", "");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"zoom_path",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Zoom Path",
|
||||
"Path of property used to set the zoom level for the control");
|
||||
@@ -3199,7 +3213,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
|
||||
|
||||
prop = RNA_def_string(ot->srna,
|
||||
"image_id",
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
"Image ID",
|
||||
"Path of ID that is used to generate an image for the control");
|
||||
@@ -3229,7 +3243,7 @@ static void redraw_timer_window_swap(bContext *C)
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
CTX_wm_menu_set(C, nullptr);
|
||||
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
ED_area_tag_redraw(area);
|
||||
@@ -3257,7 +3271,7 @@ static const EnumPropertyItem redraw_timer_type_items[] = {
|
||||
{eRTAnimationStep, "ANIM_STEP", 0, "Animation Step", "Animation steps"},
|
||||
{eRTAnimationPlay, "ANIM_PLAY", 0, "Animation Play", "Animation playback"},
|
||||
{eRTUndo, "UNDO", 0, "Undo/Redo", "Undo and redo"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static void redraw_timer_step(bContext *C,
|
||||
@@ -3275,7 +3289,7 @@ static void redraw_timer_step(bContext *C,
|
||||
}
|
||||
}
|
||||
else if (type == eRTDrawRegionSwap) {
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
CTX_wm_menu_set(C, nullptr);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
wm_draw_update(C);
|
||||
@@ -3285,7 +3299,7 @@ static void redraw_timer_step(bContext *C,
|
||||
else if (type == eRTDrawWindow) {
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
CTX_wm_menu_set(C, nullptr);
|
||||
|
||||
LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
|
||||
CTX_wm_area_set(C, area_iter);
|
||||
@@ -3429,7 +3443,7 @@ static void WM_OT_redraw_timer(wmOperatorType *ot)
|
||||
* Use for testing/debugging.
|
||||
* \{ */
|
||||
|
||||
static int memory_statistics_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int memory_statistics_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
MEM_printmemlist_stats();
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -3452,10 +3466,10 @@ static void WM_OT_memory_statistics(wmOperatorType *ot)
|
||||
* Use for material/texture/light ... etc.
|
||||
* \{ */
|
||||
|
||||
typedef struct PreviewsIDEnsureData {
|
||||
struct PreviewsIDEnsureData {
|
||||
bContext *C;
|
||||
Scene *scene;
|
||||
} PreviewsIDEnsureData;
|
||||
};
|
||||
|
||||
static void previews_id_ensure(bContext *C, Scene *scene, ID *id)
|
||||
{
|
||||
@@ -3477,7 +3491,7 @@ static int previews_id_ensure_callback(LibraryIDLinkCallbackData *cb_data)
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
PreviewsIDEnsureData *data = cb_data->user_data;
|
||||
PreviewsIDEnsureData *data = static_cast<PreviewsIDEnsureData *>(cb_data->user_data);
|
||||
ID *id = *cb_data->id_pointer;
|
||||
|
||||
if (id && (id->tag & LIB_TAG_DOIT)) {
|
||||
@@ -3489,11 +3503,15 @@ static int previews_id_ensure_callback(LibraryIDLinkCallbackData *cb_data)
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int previews_ensure_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
ListBase *lb[] = {
|
||||
&bmain->materials, &bmain->textures, &bmain->images, &bmain->worlds, &bmain->lights, NULL};
|
||||
ListBase *lb[] = {&bmain->materials,
|
||||
&bmain->textures,
|
||||
&bmain->images,
|
||||
&bmain->worlds,
|
||||
&bmain->lights,
|
||||
nullptr};
|
||||
PreviewsIDEnsureData preview_id_data;
|
||||
|
||||
/* We use LIB_TAG_DOIT to check whether we have already handled a given ID or not. */
|
||||
@@ -3508,7 +3526,7 @@ static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ID *id = (ID *)scene;
|
||||
|
||||
BKE_library_foreach_ID_link(
|
||||
NULL, id, previews_id_ensure_callback, &preview_id_data, IDWALK_RECURSE);
|
||||
nullptr, id, previews_id_ensure_callback, &preview_id_data, IDWALK_RECURSE);
|
||||
}
|
||||
|
||||
/* Check a last time for ID not used (fake users only, in theory), and
|
||||
@@ -3516,7 +3534,7 @@ static int previews_ensure_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
for (int i = 0; lb[i]; i++) {
|
||||
LISTBASE_FOREACH (ID *, id, lb[i]) {
|
||||
if (id->tag & LIB_TAG_DOIT) {
|
||||
previews_id_ensure(C, NULL, id);
|
||||
previews_id_ensure(C, nullptr, id);
|
||||
id->tag &= ~LIB_TAG_DOIT;
|
||||
}
|
||||
}
|
||||
@@ -3542,7 +3560,7 @@ static void WM_OT_previews_ensure(wmOperatorType *ot)
|
||||
/** \name Data-Block Preview Clear Operator
|
||||
* \{ */
|
||||
|
||||
typedef enum PreviewFilterID {
|
||||
enum PreviewFilterID {
|
||||
PREVIEW_FILTER_ALL,
|
||||
PREVIEW_FILTER_GEOMETRY,
|
||||
PREVIEW_FILTER_SHADING,
|
||||
@@ -3554,7 +3572,7 @@ typedef enum PreviewFilterID {
|
||||
PREVIEW_FILTER_WORLD,
|
||||
PREVIEW_FILTER_TEXTURE,
|
||||
PREVIEW_FILTER_IMAGE,
|
||||
} PreviewFilterID;
|
||||
};
|
||||
|
||||
/* Only types supporting previews currently. */
|
||||
static const EnumPropertyItem preview_id_type_items[] = {
|
||||
@@ -3580,7 +3598,7 @@ static const EnumPropertyItem preview_id_type_items[] = {
|
||||
#if 0 /* XXX TODO */
|
||||
{PREVIEW_FILTER_BRUSH, "BRUSH", 0, "Brushes", ""},
|
||||
#endif
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static uint preview_filter_to_idfilter(enum PreviewFilterID filter)
|
||||
@@ -3625,13 +3643,14 @@ static int previews_clear_exec(bContext *C, wmOperator *op)
|
||||
&bmain->lights,
|
||||
&bmain->textures,
|
||||
&bmain->images,
|
||||
NULL,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
const int id_filters = preview_filter_to_idfilter(RNA_enum_get(op->ptr, "id_type"));
|
||||
const int id_filters = preview_filter_to_idfilter(
|
||||
PreviewFilterID(RNA_enum_get(op->ptr, "id_type")));
|
||||
|
||||
for (int i = 0; lb[i]; i++) {
|
||||
ID *id = lb[i]->first;
|
||||
ID *id = static_cast<ID *>(lb[i]->first);
|
||||
if (!id) {
|
||||
continue;
|
||||
}
|
||||
@@ -3649,7 +3668,7 @@ static int previews_clear_exec(bContext *C, wmOperator *op)
|
||||
continue;
|
||||
}
|
||||
|
||||
for (; id; id = id->next) {
|
||||
for (; id; id = static_cast<ID *>(id->next)) {
|
||||
PreviewImage *prv_img = BKE_previewimg_id_ensure(id);
|
||||
|
||||
BKE_previewimg_clear(prv_img);
|
||||
@@ -3683,7 +3702,7 @@ static void WM_OT_previews_clear(wmOperatorType *ot)
|
||||
/** \name Doc from UI Operator
|
||||
* \{ */
|
||||
|
||||
static int doc_view_manual_ui_context_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int doc_view_manual_ui_context_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
PointerRNA ptr_props;
|
||||
char buf[512];
|
||||
@@ -3697,7 +3716,7 @@ static int doc_view_manual_ui_context_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
WM_operatortype_find("WM_OT_doc_view_manual", false),
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
&ptr_props,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
WM_operator_properties_free(&ptr_props);
|
||||
}
|
||||
@@ -3848,7 +3867,7 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
|
||||
{GESTURE_MODAL_DESELECT, "DESELECT", 0, "Deselect", ""},
|
||||
{GESTURE_MODAL_NOP, "NOP", 0, "No Operation", ""},
|
||||
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/* WARNING: Name is incorrect, use for non-3d views. */
|
||||
@@ -3882,7 +3901,7 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
|
||||
{GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
|
||||
{GESTURE_MODAL_SNAP, "SNAP", 0, "Snap", ""},
|
||||
{GESTURE_MODAL_FLIP, "FLIP", 0, "Flip", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Straight Line");
|
||||
@@ -3911,7 +3930,7 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
|
||||
{GESTURE_MODAL_DESELECT, "DESELECT", 0, "Deselect", ""},
|
||||
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
|
||||
{GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Box");
|
||||
@@ -3964,7 +3983,7 @@ static void gesture_lasso_modal_keymap(wmKeyConfig *keyconf)
|
||||
{
|
||||
static const EnumPropertyItem modal_items[] = {
|
||||
{GESTURE_MODAL_MOVE, "MOVE", 0, "Move", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Lasso");
|
||||
@@ -3999,7 +4018,7 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf)
|
||||
{GESTURE_MODAL_IN, "IN", 0, "In", ""},
|
||||
{GESTURE_MODAL_OUT, "OUT", 0, "Out", ""},
|
||||
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Gesture Zoom Border");
|
||||
@@ -4053,14 +4072,14 @@ static const EnumPropertyItem *rna_id_itemf(bool *r_free,
|
||||
bool (*filter_ids)(const ID *id, void *user_data),
|
||||
void *user_data)
|
||||
{
|
||||
EnumPropertyItem item_tmp = {0}, *item = NULL;
|
||||
EnumPropertyItem item_tmp = {0}, *item = nullptr;
|
||||
int totitem = 0;
|
||||
int i = 0;
|
||||
|
||||
if (id != NULL) {
|
||||
if (id != nullptr) {
|
||||
const short id_type = GS(id->name);
|
||||
for (; id; id = id->next) {
|
||||
if ((filter_ids != NULL) && filter_ids(id, user_data) == false) {
|
||||
for (; id; id = static_cast<ID *>(id->next)) {
|
||||
if ((filter_ids != nullptr) && filter_ids(id, user_data) == false) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
@@ -4087,111 +4106,118 @@ static const EnumPropertyItem *rna_id_itemf(bool *r_free,
|
||||
/* Can add more ID types as needed. */
|
||||
|
||||
const EnumPropertyItem *RNA_action_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->actions.first : NULL, false, NULL, NULL);
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->actions.first : nullptr, false, nullptr, nullptr);
|
||||
}
|
||||
#if 0 /* UNUSED */
|
||||
const EnumPropertyItem *RNA_action_local_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, true);
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->action.first : nullptr, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
const EnumPropertyItem *RNA_collection_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, false, NULL, NULL);
|
||||
r_free, C ? (ID *)CTX_data_main(C)->collections.first : nullptr, false, nullptr, nullptr);
|
||||
}
|
||||
const EnumPropertyItem *RNA_collection_local_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->collections.first : NULL, true, NULL, NULL);
|
||||
r_free, C ? (ID *)CTX_data_main(C)->collections.first : nullptr, true, nullptr, nullptr);
|
||||
}
|
||||
|
||||
const EnumPropertyItem *RNA_image_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, false, NULL, NULL);
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->images.first : nullptr, false, nullptr, nullptr);
|
||||
}
|
||||
const EnumPropertyItem *RNA_image_local_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->images.first : NULL, true, NULL, NULL);
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->images.first : nullptr, true, nullptr, nullptr);
|
||||
}
|
||||
|
||||
const EnumPropertyItem *RNA_scene_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, false, NULL, NULL);
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->scenes.first : nullptr, false, nullptr, nullptr);
|
||||
}
|
||||
const EnumPropertyItem *RNA_scene_local_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->scenes.first : NULL, true, NULL, NULL);
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->scenes.first : nullptr, true, nullptr, nullptr);
|
||||
}
|
||||
const EnumPropertyItem *RNA_scene_without_active_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
Scene *scene_active = C ? CTX_data_scene(C) : NULL;
|
||||
Scene *scene_active = C ? CTX_data_scene(C) : nullptr;
|
||||
return rna_id_itemf(r_free,
|
||||
C ? (ID *)CTX_data_main(C)->scenes.first : NULL,
|
||||
C ? (ID *)CTX_data_main(C)->scenes.first : nullptr,
|
||||
false,
|
||||
rna_id_enum_filter_single,
|
||||
scene_active);
|
||||
}
|
||||
const EnumPropertyItem *RNA_movieclip_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, false, NULL, NULL);
|
||||
r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : nullptr, false, nullptr, nullptr);
|
||||
}
|
||||
const EnumPropertyItem *RNA_movieclip_local_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : NULL, true, NULL, NULL);
|
||||
r_free, C ? (ID *)CTX_data_main(C)->movieclips.first : nullptr, true, nullptr, nullptr);
|
||||
}
|
||||
|
||||
const EnumPropertyItem *RNA_mask_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, false, NULL, NULL);
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->masks.first : nullptr, false, nullptr, nullptr);
|
||||
}
|
||||
const EnumPropertyItem *RNA_mask_local_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_id_itemf(r_free, C ? (ID *)CTX_data_main(C)->masks.first : NULL, true, NULL, NULL);
|
||||
return rna_id_itemf(
|
||||
r_free, C ? (ID *)CTX_data_main(C)->masks.first : nullptr, true, nullptr, nullptr);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -25,12 +25,12 @@
|
||||
|
||||
#include "WM_api.h"
|
||||
|
||||
static GHash *g_paneltypes_hash = NULL;
|
||||
static GHash *g_paneltypes_hash = nullptr;
|
||||
|
||||
PanelType *WM_paneltype_find(const char *idname, bool quiet)
|
||||
{
|
||||
if (idname[0]) {
|
||||
PanelType *pt = BLI_ghash_lookup(g_paneltypes_hash, idname);
|
||||
PanelType *pt = static_cast<PanelType *>(BLI_ghash_lookup(g_paneltypes_hash, idname));
|
||||
if (pt) {
|
||||
return pt;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ PanelType *WM_paneltype_find(const char *idname, bool quiet)
|
||||
printf("search for unknown paneltype %s\n", idname);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool WM_paneltype_add(PanelType *pt)
|
||||
@@ -51,7 +51,7 @@ bool WM_paneltype_add(PanelType *pt)
|
||||
|
||||
void WM_paneltype_remove(PanelType *pt)
|
||||
{
|
||||
const bool ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
|
||||
const bool ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, nullptr, nullptr);
|
||||
|
||||
BLI_assert(ok);
|
||||
UNUSED_VARS_NDEBUG(ok);
|
||||
@@ -65,21 +65,21 @@ void WM_paneltype_init(void)
|
||||
|
||||
void WM_paneltype_clear(void)
|
||||
{
|
||||
BLI_ghash_free(g_paneltypes_hash, NULL, NULL);
|
||||
BLI_ghash_free(g_paneltypes_hash, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void WM_paneltype_idname_visit_for_search(const bContext *UNUSED(C),
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
const char *UNUSED(edit_text),
|
||||
void WM_paneltype_idname_visit_for_search(const bContext * /*C*/,
|
||||
PointerRNA * /*ptr*/,
|
||||
PropertyRNA * /*prop*/,
|
||||
const char * /*edit_text*/,
|
||||
StringPropertySearchVisitFunc visit_fn,
|
||||
void *visit_user_data)
|
||||
{
|
||||
GHashIterator gh_iter;
|
||||
GHASH_ITER (gh_iter, g_paneltypes_hash) {
|
||||
PanelType *pt = BLI_ghashIterator_getValue(&gh_iter);
|
||||
PanelType *pt = static_cast<PanelType *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||
|
||||
StringPropertySearchVisitParams visit_params = {NULL};
|
||||
StringPropertySearchVisitParams visit_params = {nullptr};
|
||||
visit_params.text = pt->idname;
|
||||
visit_params.info = pt->label;
|
||||
visit_fn(visit_user_data, &visit_params);
|
||||
@@ -36,7 +36,7 @@ static bool wm_platform_support_check_approval(const char *platform_support_key,
|
||||
if (G.factory_startup) {
|
||||
return false;
|
||||
}
|
||||
const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
|
||||
const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, nullptr);
|
||||
if (!cfgdir) {
|
||||
return false;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ static bool wm_platform_support_check_approval(const char *platform_support_key,
|
||||
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_PLATFORM_SUPPORT_FILE);
|
||||
LinkNode *lines = BLI_file_read_as_lines(filepath);
|
||||
for (LinkNode *line_node = lines; line_node; line_node = line_node->next) {
|
||||
char *line = line_node->link;
|
||||
char *line = static_cast<char *>(line_node->link);
|
||||
if (STREQ(line, platform_support_key)) {
|
||||
result = true;
|
||||
break;
|
||||
@@ -117,7 +117,7 @@ bool WM_platform_support_perform_checks(void)
|
||||
}
|
||||
|
||||
/* update the message and link based on the found support level */
|
||||
GHOST_DialogOptions dialog_options = 0;
|
||||
GHOST_DialogOptions dialog_options = GHOST_DialogOptions(0);
|
||||
|
||||
switch (support_level) {
|
||||
default:
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_string.h"
|
||||
@@ -73,10 +74,10 @@
|
||||
# include <AUD_Sound.h>
|
||||
# include <AUD_Special.h>
|
||||
|
||||
static AUD_Sound *source = NULL;
|
||||
static AUD_Handle *playback_handle = NULL;
|
||||
static AUD_Handle *scrub_handle = NULL;
|
||||
static AUD_Device *audio_device = NULL;
|
||||
static AUD_Sound *source = nullptr;
|
||||
static AUD_Handle *playback_handle = nullptr;
|
||||
static AUD_Handle *scrub_handle = nullptr;
|
||||
static AUD_Device *audio_device = nullptr;
|
||||
#endif
|
||||
|
||||
/* simple limiter to avoid flooding memory */
|
||||
@@ -97,7 +98,7 @@ static bool playanim_window_font_scale_from_dpi(struct PlayState *ps);
|
||||
|
||||
/**
|
||||
* \param filepath: The file path to read into memory.
|
||||
* \param r_mem: Optional, when NULL, don't allocate memory (just set the size).
|
||||
* \param r_mem: Optional, when nullptr, don't allocate memory (just set the size).
|
||||
* \param r_size: The file-size of `filepath`.
|
||||
*/
|
||||
static bool buffer_from_filepath(const char *filepath, void **r_mem, size_t *r_size)
|
||||
@@ -110,12 +111,12 @@ static bool buffer_from_filepath(const char *filepath, void **r_mem, size_t *r_s
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
uchar *mem = NULL;
|
||||
uchar *mem = nullptr;
|
||||
const size_t size = BLI_file_descriptor_size(file);
|
||||
if (UNLIKELY(size == (size_t)-1)) {
|
||||
CLOG_WARN(&LOG, "failure '%s' to access size '%s'", strerror(errno), filepath);
|
||||
}
|
||||
else if (r_mem && UNLIKELY(!(mem = MEM_mallocN(size, __func__)))) {
|
||||
else if (r_mem && UNLIKELY(!(mem = static_cast<uchar *>(MEM_mallocN(size, __func__))))) {
|
||||
CLOG_WARN(&LOG, "error allocating buffer for '%s'", filepath);
|
||||
}
|
||||
else if (r_mem && UNLIKELY(read(file, mem, size) != size)) {
|
||||
@@ -126,7 +127,7 @@ static bool buffer_from_filepath(const char *filepath, void **r_mem, size_t *r_s
|
||||
*r_size = size;
|
||||
if (r_mem) {
|
||||
*r_mem = mem;
|
||||
mem = NULL; /* `r_mem` owns, don't free on exit. */
|
||||
mem = nullptr; /* `r_mem` owns, don't free on exit. */
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
@@ -139,7 +140,7 @@ static bool buffer_from_filepath(const char *filepath, void **r_mem, size_t *r_s
|
||||
/** \} */
|
||||
|
||||
/** Use a flag to store held modifiers & mouse buttons. */
|
||||
typedef enum eWS_Qual {
|
||||
enum eWS_Qual {
|
||||
WS_QUAL_LSHIFT = (1 << 0),
|
||||
WS_QUAL_RSHIFT = (1 << 1),
|
||||
WS_QUAL_SHIFT = (WS_QUAL_LSHIFT | WS_QUAL_RSHIFT),
|
||||
@@ -153,9 +154,10 @@ typedef enum eWS_Qual {
|
||||
WS_QUAL_MMOUSE = (1 << 17),
|
||||
WS_QUAL_RMOUSE = (1 << 18),
|
||||
WS_QUAL_MOUSE = (WS_QUAL_LMOUSE | WS_QUAL_MMOUSE | WS_QUAL_RMOUSE),
|
||||
} eWS_Qual;
|
||||
};
|
||||
ENUM_OPERATORS(eWS_Qual, WS_QUAL_MOUSE)
|
||||
|
||||
typedef struct GhostData {
|
||||
struct GhostData {
|
||||
GHOST_SystemHandle system;
|
||||
GHOST_WindowHandle window;
|
||||
|
||||
@@ -164,18 +166,18 @@ typedef struct GhostData {
|
||||
|
||||
/** Held keys. */
|
||||
eWS_Qual qual;
|
||||
} GhostData;
|
||||
};
|
||||
|
||||
/**
|
||||
* The minimal context necessary for displaying an image.
|
||||
* Used while displaying images both on load and while playing.
|
||||
*/
|
||||
typedef struct PlayDisplayContext {
|
||||
struct PlayDisplayContext {
|
||||
ColorManagedViewSettings view_settings;
|
||||
ColorManagedDisplaySettings display_settings;
|
||||
/** Window & viewport size in pixels. */
|
||||
int size[2];
|
||||
} PlayDisplayContext;
|
||||
};
|
||||
|
||||
/**
|
||||
* The current state of the player.
|
||||
@@ -184,7 +186,7 @@ typedef struct PlayDisplayContext {
|
||||
* in this struct if they need to persist across playing back different
|
||||
* files as these will be cleared when playing other files (drag & drop).
|
||||
*/
|
||||
typedef struct PlayState {
|
||||
struct PlayState {
|
||||
/** Context for displaying images (color spaces & display-size). */
|
||||
PlayDisplayContext display_ctx;
|
||||
|
||||
@@ -243,7 +245,7 @@ typedef struct PlayState {
|
||||
int frame_cursor_x;
|
||||
|
||||
GhostData ghost_data;
|
||||
} PlayState;
|
||||
};
|
||||
|
||||
/* for debugging */
|
||||
#if 0
|
||||
@@ -304,7 +306,7 @@ static void playanim_event_qual_update(GhostData *ghost_data)
|
||||
SET_FLAG_FROM_TEST(ghost_data->qual, val, WS_QUAL_RALT);
|
||||
}
|
||||
|
||||
typedef struct PlayAnimPict {
|
||||
struct PlayAnimPict {
|
||||
struct PlayAnimPict *next, *prev;
|
||||
uchar *mem;
|
||||
int size;
|
||||
@@ -320,9 +322,9 @@ typedef struct PlayAnimPict {
|
||||
LinkData *frame_cache_node;
|
||||
size_t size_in_memory;
|
||||
#endif
|
||||
} PlayAnimPict;
|
||||
};
|
||||
|
||||
static ListBase picsbase = {NULL, NULL};
|
||||
static ListBase picsbase = {nullptr, nullptr};
|
||||
/* frames in memory - store them here to for easy deallocation later */
|
||||
static bool fromdisk = false;
|
||||
static double ptottime = 0.0, swaptime = 0.04;
|
||||
@@ -341,10 +343,10 @@ static struct {
|
||||
/** Optionally limit the amount of memory used for cache (in bytes), ignored when zero. */
|
||||
size_t memory_limit;
|
||||
} g_frame_cache = {
|
||||
.pics = {NULL, NULL},
|
||||
.pics_len = 0,
|
||||
.pics_size_in_memory = 0,
|
||||
.memory_limit = 0,
|
||||
/*pics*/ {nullptr, nullptr},
|
||||
/*pics_len*/ 0,
|
||||
/*pics_size_in_memory*/ 0,
|
||||
/*memory_limit*/ 0,
|
||||
};
|
||||
|
||||
static void frame_cache_add(PlayAnimPict *pic)
|
||||
@@ -369,8 +371,8 @@ static void frame_cache_remove(PlayAnimPict *pic)
|
||||
g_frame_cache.pics_size_in_memory -= pic->size_in_memory;
|
||||
pic->size_in_memory = 0;
|
||||
}
|
||||
pic->ibuf = NULL;
|
||||
pic->frame_cache_node = NULL;
|
||||
pic->ibuf = nullptr;
|
||||
pic->frame_cache_node = nullptr;
|
||||
BLI_freelinkN(&g_frame_cache.pics, node);
|
||||
g_frame_cache.pics_len--;
|
||||
}
|
||||
@@ -393,9 +395,9 @@ static bool frame_cache_limit_exceeded(void)
|
||||
static void frame_cache_limit_apply(ImBuf *ibuf_keep)
|
||||
{
|
||||
/* Really basic memory conservation scheme. Keep frames in a FIFO queue. */
|
||||
LinkData *node = g_frame_cache.pics.last;
|
||||
LinkData *node = static_cast<LinkData *>(g_frame_cache.pics.last);
|
||||
while (node && frame_cache_limit_exceeded()) {
|
||||
PlayAnimPict *pic = node->data;
|
||||
PlayAnimPict *pic = static_cast<PlayAnimPict *>(node->data);
|
||||
BLI_assert(pic->frame_cache_node == node);
|
||||
|
||||
node = node->prev;
|
||||
@@ -409,7 +411,7 @@ static void frame_cache_limit_apply(ImBuf *ibuf_keep)
|
||||
|
||||
static ImBuf *ibuf_from_picture(PlayAnimPict *pic)
|
||||
{
|
||||
ImBuf *ibuf = NULL;
|
||||
ImBuf *ibuf = nullptr;
|
||||
|
||||
if (pic->ibuf) {
|
||||
ibuf = pic->ibuf;
|
||||
@@ -419,11 +421,11 @@ static ImBuf *ibuf_from_picture(PlayAnimPict *pic)
|
||||
}
|
||||
else if (pic->mem) {
|
||||
/* use correct colorspace here */
|
||||
ibuf = IMB_ibImageFromMemory(pic->mem, pic->size, pic->IB_flags, NULL, pic->filepath);
|
||||
ibuf = IMB_ibImageFromMemory(pic->mem, pic->size, pic->IB_flags, nullptr, pic->filepath);
|
||||
}
|
||||
else {
|
||||
/* use correct colorspace here */
|
||||
ibuf = IMB_loadiffname(pic->filepath, pic->IB_flags, NULL);
|
||||
ibuf = IMB_loadiffname(pic->filepath, pic->IB_flags, nullptr);
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
@@ -475,7 +477,7 @@ static void *ocio_transform_ibuf(const PlayDisplayContext *display_ctx,
|
||||
/* Fallback to CPU based color space conversion. */
|
||||
if (force_fallback) {
|
||||
*r_glsl_used = false;
|
||||
display_buffer = NULL;
|
||||
display_buffer = nullptr;
|
||||
}
|
||||
else if (ibuf->float_buffer.data) {
|
||||
display_buffer = ibuf->float_buffer.data;
|
||||
@@ -512,7 +514,7 @@ static void *ocio_transform_ibuf(const PlayDisplayContext *display_ctx,
|
||||
false);
|
||||
}
|
||||
else {
|
||||
display_buffer = NULL;
|
||||
display_buffer = nullptr;
|
||||
}
|
||||
|
||||
/* There is data to be displayed, but GLSL is not initialized
|
||||
@@ -544,12 +546,12 @@ static void draw_display_buffer(const PlayDisplayContext *display_ctx,
|
||||
uint texCoord = GPU_vertformat_attr_add(
|
||||
imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
|
||||
void *buffer_cache_handle = NULL;
|
||||
void *buffer_cache_handle = nullptr;
|
||||
display_buffer = ocio_transform_ibuf(
|
||||
display_ctx, ibuf, &glsl_used, &format, &data, &buffer_cache_handle);
|
||||
|
||||
GPUTexture *texture = GPU_texture_create_2d(
|
||||
"display_buf", ibuf->x, ibuf->y, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, NULL);
|
||||
"display_buf", ibuf->x, ibuf->y, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, nullptr);
|
||||
GPU_texture_update(texture, data, display_buffer);
|
||||
GPU_texture_filter_mode(texture, false);
|
||||
|
||||
@@ -646,8 +648,8 @@ static void playanim_toscreen_ex(GHOST_WindowHandle ghost_window,
|
||||
offs_y,
|
||||
offs_x + span_x,
|
||||
offs_y + span_y,
|
||||
(const float[4]){0.15, 0.15, 0.15, 1.0},
|
||||
(const float[4]){0.20, 0.20, 0.20, 1.0},
|
||||
blender::float4{0.15, 0.15, 0.15, 1.0},
|
||||
blender::float4{0.20, 0.20, 0.20, 1.0},
|
||||
8);
|
||||
}
|
||||
rctf canvas;
|
||||
@@ -718,7 +720,7 @@ static void playanim_toscreen_on_load(GHOST_WindowHandle ghost_window,
|
||||
const int fstep = -1;
|
||||
const float zoom = 1.0f;
|
||||
const float indicator_factor = -1.0f;
|
||||
const bool *draw_flip = NULL;
|
||||
const bool *draw_flip = nullptr;
|
||||
|
||||
playanim_toscreen_ex(
|
||||
ghost_window, display_ctx, picture, ibuf, fstep, font_id, zoom, draw_flip, indicator_factor);
|
||||
@@ -735,7 +737,7 @@ static void playanim_toscreen(PlayState *ps, const PlayAnimPict *picture, ImBuf
|
||||
int fontid = -1;
|
||||
if ((ps->ghost_data.qual & (WS_QUAL_SHIFT | WS_QUAL_LMOUSE)) ||
|
||||
/* Always inform the user of an error, this should be an exceptional case. */
|
||||
(ibuf == NULL))
|
||||
(ibuf == nullptr))
|
||||
{
|
||||
fontid = ps->fontid;
|
||||
}
|
||||
@@ -757,15 +759,15 @@ static void build_pict_list_from_anim(GhostData *ghost_data,
|
||||
const char *filepath_first)
|
||||
{
|
||||
/* OCIO_TODO: support different input color space */
|
||||
struct anim *anim = IMB_open_anim(filepath_first, IB_rect, 0, NULL);
|
||||
if (anim == NULL) {
|
||||
struct anim *anim = IMB_open_anim(filepath_first, IB_rect, 0, nullptr);
|
||||
if (anim == nullptr) {
|
||||
CLOG_WARN(&LOG, "couldn't open anim '%s'", filepath_first);
|
||||
return;
|
||||
}
|
||||
|
||||
ImBuf *ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
|
||||
if (ibuf) {
|
||||
playanim_toscreen_on_load(ghost_data->window, display_ctx, NULL, ibuf);
|
||||
playanim_toscreen_on_load(ghost_data->window, display_ctx, nullptr, ibuf);
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
|
||||
@@ -786,8 +788,8 @@ static void build_pict_list_from_image_sequence(GhostData *ghost_data,
|
||||
const int fstep,
|
||||
const bool *loading_p)
|
||||
{
|
||||
/* Load images into cache until the cache is full,
|
||||
* this resolves choppiness for images that are slow to load, see: #81751. */
|
||||
/* Load images into cache until the cache is full,
|
||||
* this resolves choppiness for images that are slow to load, see: #81751. */
|
||||
#ifdef USE_FRAME_CACHE_LIMIT
|
||||
bool fill_cache = true;
|
||||
#else
|
||||
@@ -817,9 +819,9 @@ static void build_pict_list_from_image_sequence(GhostData *ghost_data,
|
||||
break;
|
||||
}
|
||||
|
||||
void *mem = NULL;
|
||||
void *mem = nullptr;
|
||||
size_t size = -1;
|
||||
if (!buffer_from_filepath(filepath, fromdisk ? NULL : &mem, &size)) {
|
||||
if (!buffer_from_filepath(filepath, fromdisk ? nullptr : &mem, &size)) {
|
||||
/* A warning will have been logged. */
|
||||
break;
|
||||
}
|
||||
@@ -827,7 +829,7 @@ static void build_pict_list_from_image_sequence(GhostData *ghost_data,
|
||||
PlayAnimPict *picture = (PlayAnimPict *)MEM_callocN(sizeof(PlayAnimPict), "picture");
|
||||
picture->size = size;
|
||||
picture->IB_flags = IB_rect;
|
||||
picture->mem = mem;
|
||||
picture->mem = static_cast<uchar *>(mem);
|
||||
picture->filepath = BLI_strdup(filepath);
|
||||
picture->frame = pic;
|
||||
BLI_addtail(&picsbase, picture);
|
||||
@@ -938,7 +940,7 @@ static void change_frame(PlayState *ps)
|
||||
#ifdef WITH_AUDASPACE
|
||||
if (scrub_handle) {
|
||||
AUD_Handle_stop(scrub_handle);
|
||||
scrub_handle = NULL;
|
||||
scrub_handle = nullptr;
|
||||
}
|
||||
|
||||
if (playback_handle) {
|
||||
@@ -967,8 +969,8 @@ static void change_frame(PlayState *ps)
|
||||
}
|
||||
#endif
|
||||
|
||||
ps->picture = BLI_findlink(&picsbase, i);
|
||||
BLI_assert(ps->picture != NULL);
|
||||
ps->picture = static_cast<PlayAnimPict *>(BLI_findlink(&picsbase, i));
|
||||
BLI_assert(ps->picture != nullptr);
|
||||
|
||||
ps->sstep = true;
|
||||
ps->wait2 = false;
|
||||
@@ -1123,7 +1125,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
ps->sstep = true;
|
||||
ps->wait2 = false;
|
||||
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
|
||||
ps->picture = picsbase.first;
|
||||
ps->picture = static_cast<PlayAnimPict *>(picsbase.first);
|
||||
ps->next_frame = 0;
|
||||
}
|
||||
else {
|
||||
@@ -1148,7 +1150,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
ps->sstep = true;
|
||||
ps->wait2 = false;
|
||||
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
|
||||
ps->picture = picsbase.last;
|
||||
ps->picture = static_cast<PlayAnimPict *>(picsbase.last);
|
||||
ps->next_frame = 0;
|
||||
}
|
||||
else {
|
||||
@@ -1192,7 +1194,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
ps->once = ps->wait2 = false;
|
||||
}
|
||||
else {
|
||||
ps->picture = NULL;
|
||||
ps->picture = nullptr;
|
||||
ps->once = true;
|
||||
ps->wait2 = false;
|
||||
}
|
||||
@@ -1205,7 +1207,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
ps->wait2 = ps->sstep = false;
|
||||
#ifdef WITH_AUDASPACE
|
||||
{
|
||||
PlayAnimPict *picture = picsbase.first;
|
||||
PlayAnimPict *picture = static_cast<PlayAnimPict *>(picsbase.first);
|
||||
/* TODO: store in ps direct? */
|
||||
int i = 0;
|
||||
|
||||
@@ -1230,7 +1232,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
#ifdef WITH_AUDASPACE
|
||||
if (playback_handle) {
|
||||
AUD_Handle_stop(playback_handle);
|
||||
playback_handle = NULL;
|
||||
playback_handle = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1242,7 +1244,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
ps->wait2 = ps->sstep = false;
|
||||
#ifdef WITH_AUDASPACE
|
||||
{
|
||||
PlayAnimPict *picture = picsbase.first;
|
||||
PlayAnimPict *picture = static_cast<PlayAnimPict *>(picsbase.first);
|
||||
/* TODO: store in ps direct? */
|
||||
int i = 0;
|
||||
while (picture && picture != ps->picture) {
|
||||
@@ -1273,7 +1275,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
#ifdef WITH_AUDASPACE
|
||||
if (playback_handle) {
|
||||
AUD_Handle_stop(playback_handle);
|
||||
playback_handle = NULL;
|
||||
playback_handle = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1322,7 +1324,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
}
|
||||
case GHOST_kEventButtonDown:
|
||||
case GHOST_kEventButtonUp: {
|
||||
GHOST_TEventButtonData *bd = GHOST_GetEventData(evt);
|
||||
GHOST_TEventButtonData *bd = reinterpret_cast<GHOST_TEventButtonData *>(evt);
|
||||
int cx, cy, sizex, sizey, inside_window;
|
||||
|
||||
GHOST_GetCursorPosition(ghost_system, ghost_window, &cx, &cy);
|
||||
@@ -1365,7 +1367,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
}
|
||||
case GHOST_kEventCursorMove: {
|
||||
if (ps->ghost_data.qual & WS_QUAL_LMOUSE) {
|
||||
GHOST_TEventCursorData *cd = GHOST_GetEventData(evt);
|
||||
GHOST_TEventCursorData *cd = reinterpret_cast<GHOST_TEventCursorData *>(evt);
|
||||
int cx, cy;
|
||||
|
||||
/* Ignore 'in-between' events, since they can make scrubbing lag.
|
||||
@@ -1412,7 +1414,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
|
||||
ptottime = 0.0;
|
||||
|
||||
playanim_toscreen(ps, ps->picture, ps->picture ? ps->picture->ibuf : NULL);
|
||||
playanim_toscreen(ps, ps->picture, ps->picture ? ps->picture->ibuf : nullptr);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1427,10 +1429,10 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventDraggingDropDone: {
|
||||
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
|
||||
GHOST_TEventDragnDropData *ddd = reinterpret_cast<GHOST_TEventDragnDropData *>(evt);
|
||||
|
||||
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
|
||||
GHOST_TStringArray *stra = ddd->data;
|
||||
GHOST_TStringArray *stra = reinterpret_cast<GHOST_TStringArray *>(ddd->data);
|
||||
int a;
|
||||
|
||||
for (a = 0; a < stra->count; a++) {
|
||||
@@ -1463,7 +1465,7 @@ static GHOST_WindowHandle playanim_window_open(
|
||||
posy = (scr_h - posy - sizey);
|
||||
|
||||
return GHOST_CreateWindow(ghost_system,
|
||||
NULL,
|
||||
nullptr,
|
||||
title,
|
||||
posx,
|
||||
posy,
|
||||
@@ -1510,11 +1512,11 @@ static bool playanim_window_font_scale_from_dpi(PlayState *ps)
|
||||
}
|
||||
|
||||
/**
|
||||
* \return The a path used to restart the animation player or NULL to exit.
|
||||
* \return The a path used to restart the animation player or nullptr to exit.
|
||||
*/
|
||||
static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
{
|
||||
ImBuf *ibuf = NULL;
|
||||
ImBuf *ibuf = nullptr;
|
||||
static char filepath[FILE_MAX]; /* abused to return dropped file path */
|
||||
uint32_t maxwinx, maxwiny;
|
||||
int i;
|
||||
@@ -1524,7 +1526,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
int efra = -1;
|
||||
int totblock;
|
||||
|
||||
PlayState ps = {0};
|
||||
PlayState ps{};
|
||||
|
||||
ps.go = true;
|
||||
ps.direction = true;
|
||||
@@ -1536,7 +1538,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
ps.wait2 = false;
|
||||
ps.stopped = false;
|
||||
ps.loading = false;
|
||||
ps.picture = NULL;
|
||||
ps.picture = nullptr;
|
||||
ps.indicator = false;
|
||||
ps.dropped_file[0] = 0;
|
||||
ps.zoom = 1.0f;
|
||||
@@ -1639,11 +1641,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
if (IMB_isanim(filepath)) {
|
||||
/* OCIO_TODO: support different input color spaces */
|
||||
struct anim *anim;
|
||||
anim = IMB_open_anim(filepath, IB_rect, 0, NULL);
|
||||
anim = IMB_open_anim(filepath, IB_rect, 0, nullptr);
|
||||
if (anim) {
|
||||
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
|
||||
IMB_close_anim(anim);
|
||||
anim = NULL;
|
||||
anim = nullptr;
|
||||
}
|
||||
}
|
||||
else if (!IMB_ispic(filepath)) {
|
||||
@@ -1651,12 +1653,12 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (ibuf == NULL) {
|
||||
if (ibuf == nullptr) {
|
||||
/* OCIO_TODO: support different input color space */
|
||||
ibuf = IMB_loadiffname(filepath, IB_rect, NULL);
|
||||
ibuf = IMB_loadiffname(filepath, IB_rect, nullptr);
|
||||
}
|
||||
|
||||
if (ibuf == NULL) {
|
||||
if (ibuf == nullptr) {
|
||||
printf("%s: '%s' couldn't open\n", __func__, filepath);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -1668,7 +1670,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
|
||||
ps.ghost_data.system = GHOST_CreateSystem();
|
||||
|
||||
if (UNLIKELY(ps.ghost_data.system == NULL)) {
|
||||
if (UNLIKELY(ps.ghost_data.system == nullptr)) {
|
||||
/* GHOST will have reported the back-ends that failed to load. */
|
||||
CLOG_WARN(&LOG, "GHOST: unable to initialize, exiting!");
|
||||
/* This will leak memory, it's preferable to crashing. */
|
||||
@@ -1686,7 +1688,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
// GHOST_ActivateWindowDrawingContext(ps.ghost_data.window);
|
||||
|
||||
/* Initialize OpenGL immediate mode. */
|
||||
ps.ghost_data.gpu_context = GPU_context_create(ps.ghost_data.window, NULL);
|
||||
ps.ghost_data.gpu_context = GPU_context_create(ps.ghost_data.window, nullptr);
|
||||
GPU_init();
|
||||
|
||||
/* initialize the font */
|
||||
@@ -1754,12 +1756,12 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
}
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
ibuf = NULL;
|
||||
ibuf = nullptr;
|
||||
|
||||
pupdate_time();
|
||||
ptottime = 0;
|
||||
|
||||
/* newly added in 2.6x, without this images never get freed */
|
||||
/* newly added in 2.6x, without this images never get freed */
|
||||
#define USE_IMB_CACHE
|
||||
|
||||
while (ps.go) {
|
||||
@@ -1768,13 +1770,13 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
}
|
||||
|
||||
if (ps.direction == 1) {
|
||||
ps.picture = picsbase.first;
|
||||
ps.picture = static_cast<PlayAnimPict *>(picsbase.first);
|
||||
}
|
||||
else {
|
||||
ps.picture = picsbase.last;
|
||||
ps.picture = static_cast<PlayAnimPict *>(picsbase.last);
|
||||
}
|
||||
|
||||
if (ps.picture == NULL) {
|
||||
if (ps.picture == nullptr) {
|
||||
printf("couldn't find pictures\n");
|
||||
ps.go = false;
|
||||
}
|
||||
@@ -1801,7 +1803,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
while (ps.picture) {
|
||||
bool has_event;
|
||||
#ifndef USE_IMB_CACHE
|
||||
if (ibuf != NULL && ibuf->ftype == IMB_FTYPE_NONE) {
|
||||
if (ibuf != nullptr && ibuf->ftype == IMB_FTYPE_NONE) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
#endif
|
||||
@@ -1814,7 +1816,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
#endif
|
||||
if (ibuf) {
|
||||
#ifdef USE_FRAME_CACHE_LIMIT
|
||||
if (ps.picture->frame_cache_node == NULL) {
|
||||
if (ps.picture->frame_cache_node == nullptr) {
|
||||
frame_cache_add(ps.picture);
|
||||
}
|
||||
else {
|
||||
@@ -1826,7 +1828,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
STRNCPY(ibuf->filepath, ps.picture->filepath);
|
||||
}
|
||||
|
||||
/* why only windows? (from 2.4x) - campbell */
|
||||
/* why only windows? (from 2.4x) - campbell */
|
||||
#ifdef _WIN32
|
||||
GHOST_SetTitle(ps.ghost_data.window, ps.picture->filepath);
|
||||
#endif
|
||||
@@ -1839,10 +1841,10 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
}
|
||||
|
||||
if (ps.once) {
|
||||
if (ps.picture->next == NULL) {
|
||||
if (ps.picture->next == nullptr) {
|
||||
ps.wait2 = true;
|
||||
}
|
||||
else if (ps.picture->prev == NULL) {
|
||||
else if (ps.picture->prev == nullptr) {
|
||||
ps.wait2 = true;
|
||||
}
|
||||
}
|
||||
@@ -1877,11 +1879,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
while (ps.picture) {
|
||||
ps.picture = playanim_step(ps.picture, ps.next_frame);
|
||||
|
||||
if (ps.once && ps.picture != NULL) {
|
||||
if (ps.picture->next == NULL) {
|
||||
if (ps.once && ps.picture != nullptr) {
|
||||
if (ps.picture->next == nullptr) {
|
||||
ps.wait2 = true;
|
||||
}
|
||||
else if (ps.picture->prev == NULL) {
|
||||
else if (ps.picture->prev == nullptr) {
|
||||
ps.wait2 = true;
|
||||
}
|
||||
}
|
||||
@@ -1891,7 +1893,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
}
|
||||
ptottime -= swaptime;
|
||||
}
|
||||
if (ps.picture == NULL && ps.sstep) {
|
||||
if (ps.picture == nullptr && ps.sstep) {
|
||||
ps.picture = playanim_step(ps.picture, ps.next_frame);
|
||||
}
|
||||
}
|
||||
@@ -1900,9 +1902,9 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((ps.picture = BLI_pophead(&picsbase))) {
|
||||
while ((ps.picture = static_cast<PlayAnimPict *>(BLI_pophead(&picsbase)))) {
|
||||
if (ps.picture->anim) {
|
||||
if ((ps.picture->next == NULL) || (ps.picture->next->anim != ps.picture->anim)) {
|
||||
if ((ps.picture->next == nullptr) || (ps.picture->next->anim != ps.picture->anim)) {
|
||||
IMB_close_anim(ps.picture->anim);
|
||||
}
|
||||
}
|
||||
@@ -1918,7 +1920,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
MEM_freeN(ps.picture);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
/* cleanup */
|
||||
#ifndef USE_IMB_CACHE
|
||||
if (ibuf) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
@@ -1936,14 +1938,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
#ifdef WITH_AUDASPACE
|
||||
if (playback_handle) {
|
||||
AUD_Handle_stop(playback_handle);
|
||||
playback_handle = NULL;
|
||||
playback_handle = nullptr;
|
||||
}
|
||||
if (scrub_handle) {
|
||||
AUD_Handle_stop(scrub_handle);
|
||||
scrub_handle = NULL;
|
||||
scrub_handle = nullptr;
|
||||
}
|
||||
AUD_Sound_free(source);
|
||||
source = NULL;
|
||||
source = nullptr;
|
||||
#endif
|
||||
|
||||
/* we still miss freeing a lot!,
|
||||
@@ -1958,7 +1960,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
GPU_context_active_set(ps.ghost_data.gpu_context);
|
||||
GPU_exit();
|
||||
GPU_context_discard(ps.ghost_data.gpu_context);
|
||||
ps.ghost_data.gpu_context = NULL;
|
||||
ps.ghost_data.gpu_context = nullptr;
|
||||
}
|
||||
|
||||
GHOST_DisposeWindow(ps.ghost_data.system, ps.ghost_data.window);
|
||||
@@ -1971,14 +1973,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
|
||||
|
||||
totblock = MEM_get_memory_blocks_in_use();
|
||||
if (totblock != 0) {
|
||||
/* prints many bAKey, bArgument's which are tricky to fix */
|
||||
/* prints many bAKey, bArgument's which are tricky to fix */
|
||||
#if 0
|
||||
printf("Error Totblock: %d\n", totblock);
|
||||
MEM_printmemlist();
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_main_playanim(int argc, const char **argv)
|
||||
@@ -1996,7 +1998,7 @@ void WM_main_playanim(int argc, const char **argv)
|
||||
|
||||
AUD_initOnce();
|
||||
|
||||
if (!(audio_device = AUD_init(NULL, specs, 1024, "Blender"))) {
|
||||
if (!(audio_device = AUD_init(nullptr, specs, 1024, "Blender"))) {
|
||||
audio_device = AUD_init("None", specs, 0, "Blender");
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "ED_datafiles.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
@@ -51,10 +52,10 @@
|
||||
|
||||
#include "wm.h"
|
||||
|
||||
static void wm_block_close(bContext *C, void *arg_block, void *UNUSED(arg))
|
||||
static void wm_block_close(bContext *C, void *arg_block, void * /*arg*/)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
UI_popup_block_close(C, win, arg_block);
|
||||
UI_popup_block_close(C, win, static_cast<uiBlock *>(arg_block));
|
||||
}
|
||||
|
||||
static void wm_block_splash_add_label(uiBlock *block, const char *label, int x, int y)
|
||||
@@ -66,7 +67,7 @@ static void wm_block_splash_add_label(uiBlock *block, const char *label, int x,
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
|
||||
uiBut *but = uiDefBut(
|
||||
block, UI_BTYPE_LABEL, 0, label, 0, y, x, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
||||
block, UI_BTYPE_LABEL, 0, label, 0, y, x, UI_UNIT_Y, nullptr, 0, 0, 0, 0, nullptr);
|
||||
UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
|
||||
UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT);
|
||||
|
||||
@@ -131,12 +132,9 @@ static void wm_block_splash_image_roundcorners_add(ImBuf *ibuf)
|
||||
|
||||
static ImBuf *wm_block_splash_image(int width, int *r_height)
|
||||
{
|
||||
ImBuf *ibuf = NULL;
|
||||
ImBuf *ibuf = nullptr;
|
||||
int height = 0;
|
||||
#ifndef WITH_HEADLESS
|
||||
extern char datatoc_splash_png[];
|
||||
extern int datatoc_splash_png_size;
|
||||
|
||||
if (U.app_template[0] != '\0') {
|
||||
char splash_filepath[FILE_MAX];
|
||||
char template_directory[FILE_MAX];
|
||||
@@ -144,14 +142,15 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
|
||||
U.app_template, template_directory, sizeof(template_directory)))
|
||||
{
|
||||
BLI_path_join(splash_filepath, sizeof(splash_filepath), template_directory, "splash.png");
|
||||
ibuf = IMB_loadiffname(splash_filepath, IB_rect, NULL);
|
||||
ibuf = IMB_loadiffname(splash_filepath, IB_rect, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (ibuf == NULL) {
|
||||
if (ibuf == nullptr) {
|
||||
const uchar *splash_data = (const uchar *)datatoc_splash_png;
|
||||
size_t splash_data_size = datatoc_splash_png_size;
|
||||
ibuf = IMB_ibImageFromMemory(splash_data, splash_data_size, IB_rect, NULL, "<splash screen>");
|
||||
ibuf = IMB_ibImageFromMemory(
|
||||
splash_data, splash_data_size, IB_rect, nullptr, "<splash screen>");
|
||||
}
|
||||
|
||||
if (ibuf) {
|
||||
@@ -171,7 +170,7 @@ static ImBuf *wm_block_splash_image(int width, int *r_height)
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSED(arg))
|
||||
static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void * /*arg*/)
|
||||
{
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
|
||||
@@ -194,9 +193,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
|
||||
/* This should never happen, if it does - don't crash. */
|
||||
if (LIKELY(ibuf)) {
|
||||
uiBut *but = uiDefButImage(
|
||||
block, ibuf, 0, 0.5f * U.widget_unit, splash_width, splash_height, NULL);
|
||||
block, ibuf, 0, 0.5f * U.widget_unit, splash_width, splash_height, nullptr);
|
||||
|
||||
UI_but_func_set(but, wm_block_close, block, NULL);
|
||||
UI_but_func_set(but, wm_block_close, block, nullptr);
|
||||
|
||||
wm_block_splash_add_label(block,
|
||||
BKE_blender_version_string(),
|
||||
@@ -217,7 +216,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
|
||||
|
||||
MenuType *mt;
|
||||
char userpref[FILE_MAX];
|
||||
const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
|
||||
const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, nullptr);
|
||||
|
||||
if (cfgdir) {
|
||||
BLI_path_join(userpref, sizeof(userpref), cfgdir, BLENDER_USERPREF_FILE);
|
||||
@@ -244,9 +243,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
|
||||
return block;
|
||||
}
|
||||
|
||||
static int wm_splash_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
|
||||
static int wm_splash_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/)
|
||||
{
|
||||
UI_popup_block_invoke(C, wm_block_create_splash, NULL, NULL);
|
||||
UI_popup_block_invoke(C, wm_block_create_splash, nullptr, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -261,7 +260,7 @@ void WM_OT_splash(wmOperatorType *ot)
|
||||
ot->poll = WM_operator_winactive;
|
||||
}
|
||||
|
||||
static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED(arg))
|
||||
static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void * /*arg*/)
|
||||
{
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points);
|
||||
@@ -275,15 +274,13 @@ static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED
|
||||
uiLayout *layout = UI_block_layout(
|
||||
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, dialog_width, 0, 0, style);
|
||||
|
||||
/* Blender logo. */
|
||||
/* Blender logo. */
|
||||
#ifndef WITH_HEADLESS
|
||||
extern char datatoc_blender_logo_png[];
|
||||
extern int datatoc_blender_logo_png_size;
|
||||
|
||||
const uchar *blender_logo_data = (const uchar *)datatoc_blender_logo_png;
|
||||
size_t blender_logo_data_size = datatoc_blender_logo_png_size;
|
||||
ImBuf *ibuf = IMB_ibImageFromMemory(
|
||||
blender_logo_data, blender_logo_data_size, IB_rect, NULL, "blender_logo");
|
||||
blender_logo_data, blender_logo_data_size, IB_rect, nullptr, "blender_logo");
|
||||
|
||||
if (ibuf) {
|
||||
int width = 0.5 * dialog_width;
|
||||
@@ -324,9 +321,9 @@ static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED
|
||||
return block;
|
||||
}
|
||||
|
||||
static int wm_about_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
|
||||
static int wm_about_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/)
|
||||
{
|
||||
UI_popup_block_invoke(C, wm_block_create_about, NULL, NULL);
|
||||
UI_popup_block_invoke(C, wm_block_create_about, nullptr, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -146,8 +146,9 @@ bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
|
||||
|
||||
/* some 3d methods change the window arrangement, thus they shouldn't
|
||||
* toggle on/off just because there is no 3d elements being drawn */
|
||||
if (wm_stereo3d_is_fullscreen_required(win->stereo3d_format->display_mode)) {
|
||||
return GHOST_GetWindowState(win->ghostwin) == GHOST_kWindowStateFullScreen;
|
||||
if (wm_stereo3d_is_fullscreen_required(eStereoDisplayMode(win->stereo3d_format->display_mode))) {
|
||||
return GHOST_GetWindowState(static_cast<GHOST_WindowHandle>(win->ghostwin)) ==
|
||||
GHOST_kWindowStateFullScreen;
|
||||
}
|
||||
|
||||
if ((skip_stereo3d_check == false) && (ED_screen_stereo3d_required(screen, scene) == false)) {
|
||||
@@ -156,8 +157,9 @@ bool WM_stereo3d_enabled(wmWindow *win, bool skip_stereo3d_check)
|
||||
|
||||
/* some 3d methods change the window arrangement, thus they shouldn't
|
||||
* toggle on/off just because there is no 3d elements being drawn */
|
||||
if (wm_stereo3d_is_fullscreen_required(win->stereo3d_format->display_mode)) {
|
||||
return GHOST_GetWindowState(win->ghostwin) == GHOST_kWindowStateFullScreen;
|
||||
if (wm_stereo3d_is_fullscreen_required(eStereoDisplayMode(win->stereo3d_format->display_mode))) {
|
||||
return GHOST_GetWindowState(static_cast<GHOST_WindowHandle>(win->ghostwin)) ==
|
||||
GHOST_kWindowStateFullScreen;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -188,13 +190,13 @@ void wm_stereo3d_mouse_offset_apply(wmWindow *win, int r_mouse_xy[2])
|
||||
}
|
||||
|
||||
/************************** Stereo 3D operator **********************************/
|
||||
typedef struct Stereo3dData {
|
||||
struct Stereo3dData {
|
||||
Stereo3dFormat stereo3d_format;
|
||||
} Stereo3dData;
|
||||
};
|
||||
|
||||
static bool wm_stereo3d_set_properties(bContext *UNUSED(C), wmOperator *op)
|
||||
static bool wm_stereo3d_set_properties(bContext * /*C*/, wmOperator *op)
|
||||
{
|
||||
Stereo3dData *s3dd = op->customdata;
|
||||
Stereo3dData *s3dd = static_cast<Stereo3dData *>(op->customdata);
|
||||
Stereo3dFormat *s3d = &s3dd->stereo3d_format;
|
||||
PropertyRNA *prop;
|
||||
bool is_set = false;
|
||||
@@ -246,7 +248,7 @@ static void wm_stereo3d_set_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
Stereo3dData *s3dd = MEM_callocN(sizeof(Stereo3dData), __func__);
|
||||
Stereo3dData *s3dd = static_cast<Stereo3dData *>(MEM_callocN(sizeof(Stereo3dData), __func__));
|
||||
op->customdata = s3dd;
|
||||
|
||||
/* store the original win stereo 3d settings in case of cancel */
|
||||
@@ -257,7 +259,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win_src = CTX_wm_window(C);
|
||||
wmWindow *win_dst = NULL;
|
||||
wmWindow *win_dst = nullptr;
|
||||
const bool is_fullscreen = WM_window_is_fullscreen(win_src);
|
||||
char prev_display_mode = win_src->stereo3d_format->display_mode;
|
||||
bool ok = true;
|
||||
@@ -266,13 +268,13 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (op->customdata == NULL) {
|
||||
if (op->customdata == nullptr) {
|
||||
/* no invoke means we need to set the operator properties here */
|
||||
wm_stereo3d_set_init(C, op);
|
||||
wm_stereo3d_set_properties(C, op);
|
||||
}
|
||||
|
||||
Stereo3dData *s3dd = op->customdata;
|
||||
Stereo3dData *s3dd = static_cast<Stereo3dData *>(op->customdata);
|
||||
*win_src->stereo3d_format = s3dd->stereo3d_format;
|
||||
|
||||
if (prev_display_mode == S3D_DISPLAY_PAGEFLIP &&
|
||||
@@ -306,7 +308,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else {
|
||||
wm_window_close(C, wm, win_dst);
|
||||
win_dst = NULL;
|
||||
win_dst = nullptr;
|
||||
BKE_report(op->reports, RPT_ERROR, "Quad-buffer not supported by the system");
|
||||
ok = false;
|
||||
}
|
||||
@@ -319,7 +321,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
if (wm_stereo3d_is_fullscreen_required(s3dd->stereo3d_format.display_mode)) {
|
||||
if (wm_stereo3d_is_fullscreen_required(eStereoDisplayMode(s3dd->stereo3d_format.display_mode))) {
|
||||
if (!is_fullscreen) {
|
||||
BKE_report(op->reports, RPT_INFO, "Stereo 3D Mode requires the window to be fullscreen");
|
||||
}
|
||||
@@ -332,7 +334,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
|
||||
wm_window_close(C, wm, win_src);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -342,7 +344,7 @@ int wm_stereo3d_set_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
wm_stereo3d_set_init(C, op);
|
||||
|
||||
@@ -352,33 +354,33 @@ int wm_stereo3d_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
|
||||
return WM_operator_props_dialog_popup(C, op, 300);
|
||||
}
|
||||
|
||||
void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op)
|
||||
void wm_stereo3d_set_draw(bContext * /*C*/, wmOperator *op)
|
||||
{
|
||||
Stereo3dData *s3dd = op->customdata;
|
||||
Stereo3dData *s3dd = static_cast<Stereo3dData *>(op->customdata);
|
||||
PointerRNA stereo3d_format_ptr;
|
||||
uiLayout *layout = op->layout;
|
||||
uiLayout *col;
|
||||
|
||||
RNA_pointer_create(NULL, &RNA_Stereo3dDisplay, &s3dd->stereo3d_format, &stereo3d_format_ptr);
|
||||
RNA_pointer_create(nullptr, &RNA_Stereo3dDisplay, &s3dd->stereo3d_format, &stereo3d_format_ptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
uiLayoutSetPropDecorate(layout, false);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &stereo3d_format_ptr, "display_mode", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &stereo3d_format_ptr, "display_mode", 0, nullptr, ICON_NONE);
|
||||
|
||||
switch (s3dd->stereo3d_format.display_mode) {
|
||||
case S3D_DISPLAY_ANAGLYPH: {
|
||||
uiItemR(col, &stereo3d_format_ptr, "anaglyph_type", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &stereo3d_format_ptr, "anaglyph_type", 0, nullptr, ICON_NONE);
|
||||
break;
|
||||
}
|
||||
case S3D_DISPLAY_INTERLACE: {
|
||||
uiItemR(col, &stereo3d_format_ptr, "interlace_type", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &stereo3d_format_ptr, "use_interlace_swap", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &stereo3d_format_ptr, "interlace_type", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, &stereo3d_format_ptr, "use_interlace_swap", 0, nullptr, ICON_NONE);
|
||||
break;
|
||||
}
|
||||
case S3D_DISPLAY_SIDEBYSIDE: {
|
||||
uiItemR(col, &stereo3d_format_ptr, "use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &stereo3d_format_ptr, "use_sidebyside_crosseyed", 0, nullptr, ICON_NONE);
|
||||
/* fall-through */
|
||||
}
|
||||
case S3D_DISPLAY_PAGEFLIP:
|
||||
@@ -389,7 +391,7 @@ void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
bool wm_stereo3d_set_check(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
bool wm_stereo3d_set_check(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
/* the check function guarantees that the menu is updated to show the
|
||||
* sub-options when an enum change (e.g., it shows the anaglyph options
|
||||
@@ -397,8 +399,8 @@ bool wm_stereo3d_set_check(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
return true;
|
||||
}
|
||||
|
||||
void wm_stereo3d_set_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
void wm_stereo3d_set_cancel(bContext * /*C*/, wmOperator *op)
|
||||
{
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
op->customdata = nullptr;
|
||||
}
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
#include "wm_surface.h"
|
||||
|
||||
static ListBase global_surface_list = {NULL, NULL};
|
||||
static wmSurface *g_drawable = NULL;
|
||||
static ListBase global_surface_list = {nullptr, nullptr};
|
||||
static wmSurface *g_drawable = nullptr;
|
||||
|
||||
void wm_surfaces_iter(bContext *C, void (*cb)(bContext *C, wmSurface *))
|
||||
{
|
||||
@@ -55,19 +55,19 @@ void wm_surface_clear_drawable(void)
|
||||
{
|
||||
if (g_drawable) {
|
||||
WM_system_gpu_context_release(g_drawable->system_gpu_context);
|
||||
GPU_context_active_set(NULL);
|
||||
GPU_context_active_set(nullptr);
|
||||
|
||||
if (g_drawable->deactivate) {
|
||||
g_drawable->deactivate();
|
||||
}
|
||||
|
||||
g_drawable = NULL;
|
||||
g_drawable = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void wm_surface_set_drawable(wmSurface *surface, bool activate)
|
||||
{
|
||||
BLI_assert(ELEM(g_drawable, NULL, surface));
|
||||
BLI_assert(ELEM(g_drawable, nullptr, surface));
|
||||
|
||||
g_drawable = surface;
|
||||
if (activate) {
|
||||
@@ -42,9 +42,7 @@
|
||||
#include "WM_toolsystem.h" /* own include */
|
||||
#include "WM_types.h"
|
||||
|
||||
static void toolsystem_reinit_with_toolref(bContext *C,
|
||||
WorkSpace *UNUSED(workspace),
|
||||
bToolRef *tref);
|
||||
static void toolsystem_reinit_with_toolref(bContext *C, WorkSpace * /*workspace*/, bToolRef *tref);
|
||||
static bToolRef *toolsystem_reinit_ensure_toolref(bContext *C,
|
||||
WorkSpace *workspace,
|
||||
const bToolKey *tkey,
|
||||
@@ -63,13 +61,12 @@ bToolRef *WM_toolsystem_ref_from_context(bContext *C)
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if ((area == NULL) || ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) {
|
||||
return NULL;
|
||||
if ((area == nullptr) || ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
const bToolKey tkey = {
|
||||
.space_type = area->spacetype,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype),
|
||||
};
|
||||
bToolKey tkey{};
|
||||
tkey.space_type = area->spacetype;
|
||||
tkey.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype);
|
||||
bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
|
||||
/* We could return 'area->runtime.tool' in this case. */
|
||||
if (area->runtime.is_tool_set) {
|
||||
@@ -81,7 +78,7 @@ bToolRef *WM_toolsystem_ref_from_context(bContext *C)
|
||||
bToolRef_Runtime *WM_toolsystem_runtime_from_context(bContext *C)
|
||||
{
|
||||
bToolRef *tref = WM_toolsystem_ref_from_context(C);
|
||||
return tref ? tref->runtime : NULL;
|
||||
return tref ? tref->runtime : nullptr;
|
||||
}
|
||||
|
||||
bToolRef *WM_toolsystem_ref_find(WorkSpace *workspace, const bToolKey *tkey)
|
||||
@@ -92,13 +89,13 @@ bToolRef *WM_toolsystem_ref_find(WorkSpace *workspace, const bToolKey *tkey)
|
||||
return tref;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bToolRef_Runtime *WM_toolsystem_runtime_find(WorkSpace *workspace, const bToolKey *tkey)
|
||||
{
|
||||
bToolRef *tref = WM_toolsystem_ref_find(workspace, tkey);
|
||||
return tref ? tref->runtime : NULL;
|
||||
return tref ? tref->runtime : nullptr;
|
||||
}
|
||||
|
||||
bool WM_toolsystem_ref_ensure(WorkSpace *workspace, const bToolKey *tkey, bToolRef **r_tref)
|
||||
@@ -108,7 +105,7 @@ bool WM_toolsystem_ref_ensure(WorkSpace *workspace, const bToolKey *tkey, bToolR
|
||||
*r_tref = tref;
|
||||
return false;
|
||||
}
|
||||
tref = MEM_callocN(sizeof(*tref), __func__);
|
||||
tref = static_cast<bToolRef *>(MEM_callocN(sizeof(*tref), __func__));
|
||||
BLI_addhead(&workspace->tools, tref);
|
||||
tref->space_type = tkey->space_type;
|
||||
tref->mode = tkey->mode;
|
||||
@@ -118,13 +115,13 @@ bool WM_toolsystem_ref_ensure(WorkSpace *workspace, const bToolKey *tkey, bToolR
|
||||
|
||||
/** \} */
|
||||
|
||||
static void toolsystem_unlink_ref(bContext *C, WorkSpace *UNUSED(workspace), bToolRef *tref)
|
||||
static void toolsystem_unlink_ref(bContext *C, WorkSpace * /*workspace*/, bToolRef *tref)
|
||||
{
|
||||
bToolRef_Runtime *tref_rt = tref->runtime;
|
||||
|
||||
if (tref_rt->gizmo_group[0]) {
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false);
|
||||
if (gzgt != NULL) {
|
||||
if (gzgt != nullptr) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
WM_gizmo_group_remove_by_tool(C, bmain, gzgt, tref);
|
||||
}
|
||||
@@ -144,7 +141,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
if (tref_rt->gizmo_group[0]) {
|
||||
const char *idname = tref_rt->gizmo_group;
|
||||
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false);
|
||||
if (gzgt != NULL) {
|
||||
if (gzgt != nullptr) {
|
||||
if ((gzgt->flag & WM_GIZMOGROUPTYPE_TOOL_INIT) == 0) {
|
||||
if (!WM_gizmo_group_type_ensure_ptr(gzgt)) {
|
||||
/* Even if the group-type was has been linked, it's possible the space types
|
||||
@@ -167,7 +164,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
const int i = RNA_enum_from_identifier(items, tref_rt->data_block);
|
||||
if (i != -1) {
|
||||
const int value = items[i].value;
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
@@ -181,26 +178,26 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
|
||||
BLI_assert(paint_mode != PAINT_MODE_INVALID);
|
||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
||||
BLI_assert(items != NULL);
|
||||
BLI_assert(items != nullptr);
|
||||
|
||||
const int i = items ? RNA_enum_from_identifier(items, tref_rt->data_block) : -1;
|
||||
if (i != -1) {
|
||||
const int slot_index = items[i].value;
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
BKE_paint_ensure_from_paintmode(scene, paint_mode);
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
|
||||
struct Brush *brush = BKE_paint_toolslots_brush_get(paint, slot_index);
|
||||
if (brush == NULL) {
|
||||
if (brush == nullptr) {
|
||||
/* Could make into a function. */
|
||||
brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, items[i].name);
|
||||
if (brush && slot_index == BKE_brush_tool_get(brush, paint)) {
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
brush = BKE_brush_add(bmain, items[i].name, paint->runtime.ob_mode);
|
||||
brush = BKE_brush_add(bmain, items[i].name, eObjectMode(paint->runtime.ob_mode));
|
||||
|
||||
BKE_brush_tool_set(brush, paint, slot_index);
|
||||
|
||||
@@ -220,7 +217,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
|
||||
|
||||
static void toolsystem_refresh_ref(bContext *C, WorkSpace *workspace, bToolRef *tref)
|
||||
{
|
||||
if (tref->runtime == NULL) {
|
||||
if (tref->runtime == nullptr) {
|
||||
return;
|
||||
}
|
||||
/* currently same operation. */
|
||||
@@ -280,10 +277,9 @@ void WM_toolsystem_reinit_all(bContext *C, wmWindow *win)
|
||||
}
|
||||
|
||||
WorkSpace *workspace = WM_window_get_active_workspace(win);
|
||||
const bToolKey tkey = {
|
||||
.space_type = area->spacetype,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype),
|
||||
};
|
||||
bToolKey tkey{};
|
||||
tkey.space_type = area->spacetype;
|
||||
tkey.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype);
|
||||
bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
|
||||
if (tref) {
|
||||
if (tref->tag == 0) {
|
||||
@@ -308,8 +304,8 @@ void WM_toolsystem_ref_set_from_runtime(bContext *C,
|
||||
|
||||
STRNCPY(tref->idname, idname);
|
||||
|
||||
if (tref->runtime == NULL) {
|
||||
tref->runtime = MEM_callocN(sizeof(*tref->runtime), __func__);
|
||||
if (tref->runtime == nullptr) {
|
||||
tref->runtime = static_cast<bToolRef_Runtime *>(MEM_callocN(sizeof(*tref->runtime), __func__));
|
||||
}
|
||||
|
||||
if (tref_rt != tref->runtime) {
|
||||
@@ -345,7 +341,7 @@ void WM_toolsystem_ref_set_from_runtime(bContext *C,
|
||||
/* Set the cursor if possible, if not - it's fine as entering the region will refresh it. */
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
if (win != NULL) {
|
||||
if (win != nullptr) {
|
||||
win->addmousemove = true;
|
||||
win->tag_cursor_refresh = true;
|
||||
}
|
||||
@@ -360,10 +356,10 @@ void WM_toolsystem_ref_set_from_runtime(bContext *C,
|
||||
void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToolRef *tref)
|
||||
{
|
||||
bToolRef_Runtime *tref_rt = tref->runtime;
|
||||
if ((tref_rt == NULL) || (tref_rt->data_block[0] == '\0')) {
|
||||
if ((tref_rt == nullptr) || (tref_rt->data_block[0] == '\0')) {
|
||||
return;
|
||||
}
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
if (workspace != WM_window_get_active_workspace(win)) {
|
||||
continue;
|
||||
@@ -374,7 +370,7 @@ void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToo
|
||||
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
const Object *ob = BKE_view_layer_active_object_get(view_layer);
|
||||
if (ob == NULL) {
|
||||
if (ob == nullptr) {
|
||||
/* pass */
|
||||
}
|
||||
if ((tref->space_type == SPACE_VIEW3D) && (tref->mode == CTX_MODE_PARTICLE)) {
|
||||
@@ -414,7 +410,7 @@ void WM_toolsystem_init(bContext *C)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
BLI_assert(CTX_wm_window(C) == NULL);
|
||||
BLI_assert(CTX_wm_window(C) == nullptr);
|
||||
|
||||
LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
|
||||
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
|
||||
@@ -451,12 +447,12 @@ int WM_toolsystem_mode_from_spacetype(const Scene *scene,
|
||||
int mode = -1;
|
||||
switch (space_type) {
|
||||
case SPACE_VIEW3D: {
|
||||
/* 'area' may be NULL in this case. */
|
||||
/* 'area' may be nullptr in this case. */
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Object *obact = BKE_view_layer_active_object_get(view_layer);
|
||||
if (obact != NULL) {
|
||||
if (obact != nullptr) {
|
||||
Object *obedit = OBEDIT_FROM_OBACT(obact);
|
||||
mode = CTX_data_mode_enum_ex(obedit, obact, obact->mode);
|
||||
mode = CTX_data_mode_enum_ex(obedit, obact, eObjectMode(obact->mode));
|
||||
}
|
||||
else {
|
||||
mode = CTX_MODE_OBJECT;
|
||||
@@ -464,7 +460,7 @@ int WM_toolsystem_mode_from_spacetype(const Scene *scene,
|
||||
break;
|
||||
}
|
||||
case SPACE_IMAGE: {
|
||||
SpaceImage *sima = area->spacedata.first;
|
||||
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
||||
mode = sima->mode;
|
||||
break;
|
||||
}
|
||||
@@ -473,7 +469,7 @@ int WM_toolsystem_mode_from_spacetype(const Scene *scene,
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ: {
|
||||
SpaceSeq *sseq = area->spacedata.first;
|
||||
SpaceSeq *sseq = static_cast<SpaceSeq *>(area->spacedata.first);
|
||||
mode = sseq->view;
|
||||
break;
|
||||
}
|
||||
@@ -489,7 +485,7 @@ bool WM_toolsystem_key_from_context(const Scene *scene,
|
||||
int space_type = SPACE_EMPTY;
|
||||
int mode = -1;
|
||||
|
||||
if (area != NULL) {
|
||||
if (area != nullptr) {
|
||||
space_type = area->spacetype;
|
||||
mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, space_type);
|
||||
}
|
||||
@@ -513,7 +509,9 @@ void WM_toolsystem_refresh_active(bContext *C)
|
||||
bool is_set;
|
||||
} context_prev = {0};
|
||||
|
||||
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
|
||||
for (wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first); wm;
|
||||
wm = static_cast<wmWindowManager *>(wm->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
WorkSpace *workspace = WM_window_get_active_workspace(win);
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
@@ -528,10 +526,9 @@ void WM_toolsystem_refresh_active(bContext *C)
|
||||
((space_type_mask_handled & space_type_mask) == 0))
|
||||
{
|
||||
space_type_mask_handled |= space_type_mask;
|
||||
const bToolKey tkey = {
|
||||
.space_type = area->spacetype,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype),
|
||||
};
|
||||
bToolKey tkey{};
|
||||
tkey.space_type = area->spacetype;
|
||||
tkey.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype);
|
||||
bToolRef *tref = WM_toolsystem_ref_find(workspace, &tkey);
|
||||
if (tref != area->runtime.tool) {
|
||||
if (context_prev.is_set == false) {
|
||||
@@ -544,7 +541,7 @@ void WM_toolsystem_refresh_active(bContext *C)
|
||||
CTX_wm_window_set(C, win);
|
||||
CTX_wm_area_set(C, area);
|
||||
|
||||
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
|
||||
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -577,7 +574,7 @@ void WM_toolsystem_refresh_screen_area(WorkSpace *workspace,
|
||||
ViewLayer *view_layer,
|
||||
ScrArea *area)
|
||||
{
|
||||
area->runtime.tool = NULL;
|
||||
area->runtime.tool = nullptr;
|
||||
area->runtime.is_tool_set = true;
|
||||
const int mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype);
|
||||
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
|
||||
@@ -601,7 +598,7 @@ void WM_toolsystem_refresh_screen_window(wmWindow *win)
|
||||
const Scene *scene = WM_window_get_active_scene(win);
|
||||
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
area->runtime.tool = NULL;
|
||||
area->runtime.tool = nullptr;
|
||||
area->runtime.is_tool_set = true;
|
||||
if (space_type_has_tools[area->spacetype]) {
|
||||
WM_toolsystem_refresh_screen_area(workspace, scene, view_layer, area);
|
||||
@@ -612,7 +609,9 @@ void WM_toolsystem_refresh_screen_window(wmWindow *win)
|
||||
void WM_toolsystem_refresh_screen_all(Main *bmain)
|
||||
{
|
||||
/* Update all ScrArea's tools */
|
||||
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
|
||||
for (wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first); wm;
|
||||
wm = static_cast<wmWindowManager *>(wm->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
WM_toolsystem_refresh_screen_window(win);
|
||||
}
|
||||
@@ -624,7 +623,9 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain,
|
||||
bToolRef *tref)
|
||||
{
|
||||
/* Update all ScrArea's tools */
|
||||
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
|
||||
for (wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first); wm;
|
||||
wm = static_cast<wmWindowManager *>(wm->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
if (workspace == WM_window_get_active_workspace(win)) {
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
@@ -649,17 +650,17 @@ bToolRef *WM_toolsystem_ref_set_by_id_ex(
|
||||
{
|
||||
wmOperatorType *ot = WM_operatortype_find("WM_OT_tool_set_by_id", false);
|
||||
/* On startup, Python operators are not yet loaded. */
|
||||
if (ot == NULL) {
|
||||
return NULL;
|
||||
if (ot == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Some contexts use the current space type (image editor for e.g.),
|
||||
* ensure this is set correctly or there is no area. */
|
||||
/* Some contexts use the current space type (image editor for e.g.),
|
||||
* ensure this is set correctly or there is no area. */
|
||||
#ifndef NDEBUG
|
||||
/* Exclude this check for some space types where the space type isn't used. */
|
||||
if ((1 << tkey->space_type) & WM_TOOLSYSTEM_SPACE_MASK_MODE_FROM_SPACE) {
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
BLI_assert(area == NULL || area->spacetype == tkey->space_type);
|
||||
BLI_assert(area == nullptr || area->spacetype == tkey->space_type);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -672,7 +673,7 @@ bToolRef *WM_toolsystem_ref_set_by_id_ex(
|
||||
RNA_enum_set(&op_props, "space_type", tkey->space_type);
|
||||
RNA_boolean_set(&op_props, "cycle", cycle);
|
||||
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &op_props, NULL);
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &op_props, nullptr);
|
||||
WM_operator_properties_free(&op_props);
|
||||
|
||||
bToolRef *tref = WM_toolsystem_ref_find(workspace, tkey);
|
||||
@@ -682,7 +683,7 @@ bToolRef *WM_toolsystem_ref_set_by_id_ex(
|
||||
toolsystem_refresh_screen_from_active_tool(bmain, workspace, tref);
|
||||
}
|
||||
|
||||
return (tref && STREQ(tref->idname, name)) ? tref : NULL;
|
||||
return (tref && STREQ(tref->idname, name)) ? tref : nullptr;
|
||||
}
|
||||
|
||||
bToolRef *WM_toolsystem_ref_set_by_id(bContext *C, const char *name)
|
||||
@@ -695,15 +696,14 @@ bToolRef *WM_toolsystem_ref_set_by_id(bContext *C, const char *name)
|
||||
WorkSpace *workspace = CTX_wm_workspace(C);
|
||||
return WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, name, false);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void toolsystem_reinit_with_toolref(bContext *C, WorkSpace *workspace, bToolRef *tref)
|
||||
{
|
||||
bToolKey tkey = {
|
||||
.space_type = tref->space_type,
|
||||
.mode = tref->mode,
|
||||
};
|
||||
bToolKey tkey{};
|
||||
tkey.space_type = tref->space_type;
|
||||
tkey.mode = tref->mode;
|
||||
WM_toolsystem_ref_set_by_id_ex(C, workspace, &tkey, tref->idname, false);
|
||||
}
|
||||
|
||||
@@ -771,7 +771,7 @@ static bToolRef *toolsystem_reinit_ensure_toolref(bContext *C,
|
||||
{
|
||||
bToolRef *tref;
|
||||
if (WM_toolsystem_ref_ensure(workspace, tkey, &tref)) {
|
||||
if (default_tool == NULL) {
|
||||
if (default_tool == nullptr) {
|
||||
default_tool = toolsystem_default_tool(tkey);
|
||||
}
|
||||
STRNCPY(tref->idname, default_tool);
|
||||
@@ -785,11 +785,10 @@ static void wm_toolsystem_update_from_context_view3d_impl(bContext *C, WorkSpace
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
int space_type = SPACE_VIEW3D;
|
||||
const bToolKey tkey = {
|
||||
.space_type = space_type,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, NULL, space_type),
|
||||
};
|
||||
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
|
||||
bToolKey tkey{};
|
||||
tkey.space_type = space_type;
|
||||
tkey.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, nullptr, space_type);
|
||||
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, nullptr);
|
||||
}
|
||||
|
||||
void WM_toolsystem_update_from_context_view3d(bContext *C)
|
||||
@@ -799,7 +798,7 @@ void WM_toolsystem_update_from_context_view3d(bContext *C)
|
||||
|
||||
/* Multi window support. */
|
||||
Main *bmain = CTX_data_main(C);
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
if (!BLI_listbase_is_single(&wm->windows)) {
|
||||
wmWindow *win_prev = CTX_wm_window(C);
|
||||
ScrArea *area_prev = CTX_wm_area(C);
|
||||
@@ -826,12 +825,11 @@ void WM_toolsystem_update_from_context_view3d(bContext *C)
|
||||
void WM_toolsystem_update_from_context(
|
||||
bContext *C, WorkSpace *workspace, const Scene *scene, ViewLayer *view_layer, ScrArea *area)
|
||||
{
|
||||
const bToolKey tkey = {
|
||||
.space_type = area->spacetype,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype),
|
||||
};
|
||||
bToolKey tkey{};
|
||||
tkey.space_type = area->spacetype;
|
||||
tkey.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype);
|
||||
if (toolsystem_key_ensure_check(&tkey)) {
|
||||
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL);
|
||||
toolsystem_reinit_ensure_toolref(C, workspace, &tkey, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -842,13 +840,13 @@ bool WM_toolsystem_active_tool_is_brush(const bContext *C)
|
||||
}
|
||||
|
||||
void WM_toolsystem_do_msg_notify_tag_refresh(bContext *C,
|
||||
wmMsgSubscribeKey *UNUSED(msg_key),
|
||||
wmMsgSubscribeKey * /*msg_key*/,
|
||||
wmMsgSubscribeValue *msg_val)
|
||||
{
|
||||
ScrArea *area = msg_val->user_data;
|
||||
ScrArea *area = static_cast<ScrArea *>(msg_val->user_data);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
wmWindow *win = ((wmWindowManager *)bmain->wm.first)->windows.first;
|
||||
if (win->next != NULL) {
|
||||
wmWindow *win = static_cast<wmWindow *>(((wmWindowManager *)bmain->wm.first)->windows.first);
|
||||
if (win->next != nullptr) {
|
||||
do {
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
if (BLI_findindex(&screen->areabase, area) != -1) {
|
||||
@@ -861,10 +859,9 @@ void WM_toolsystem_do_msg_notify_tag_refresh(bContext *C,
|
||||
const Scene *scene = WM_window_get_active_scene(win);
|
||||
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
||||
|
||||
const bToolKey tkey = {
|
||||
.space_type = area->spacetype,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype),
|
||||
};
|
||||
bToolKey tkey{};
|
||||
tkey.space_type = area->spacetype;
|
||||
tkey.mode = WM_toolsystem_mode_from_spacetype(scene, view_layer, area, area->spacetype);
|
||||
WM_toolsystem_refresh(C, workspace, &tkey);
|
||||
WM_toolsystem_refresh_screen_area(workspace, scene, view_layer, area);
|
||||
}
|
||||
@@ -872,11 +869,11 @@ void WM_toolsystem_do_msg_notify_tag_refresh(bContext *C,
|
||||
static IDProperty *idprops_ensure_named_group(IDProperty *group, const char *idname)
|
||||
{
|
||||
IDProperty *prop = IDP_GetPropertyFromGroup(group, idname);
|
||||
if ((prop == NULL) || (prop->type != IDP_GROUP)) {
|
||||
if ((prop == nullptr) || (prop->type != IDP_GROUP)) {
|
||||
IDPropertyTemplate val = {0};
|
||||
prop = IDP_New(IDP_GROUP, &val, __func__);
|
||||
STRNCPY(prop->name, idname);
|
||||
IDP_ReplaceInGroup_ex(group, prop, NULL);
|
||||
IDP_ReplaceInGroup_ex(group, prop, nullptr);
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
@@ -884,15 +881,15 @@ static IDProperty *idprops_ensure_named_group(IDProperty *group, const char *idn
|
||||
IDProperty *WM_toolsystem_ref_properties_get_idprops(bToolRef *tref)
|
||||
{
|
||||
IDProperty *group = tref->properties;
|
||||
if (group == NULL) {
|
||||
return NULL;
|
||||
if (group == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return IDP_GetPropertyFromGroup(group, tref->idname);
|
||||
}
|
||||
|
||||
IDProperty *WM_toolsystem_ref_properties_ensure_idprops(bToolRef *tref)
|
||||
{
|
||||
if (tref->properties == NULL) {
|
||||
if (tref->properties == nullptr) {
|
||||
IDPropertyTemplate val = {0};
|
||||
tref->properties = IDP_New(IDP_GROUP, &val, __func__);
|
||||
}
|
||||
@@ -905,9 +902,9 @@ bool WM_toolsystem_ref_properties_get_ex(bToolRef *tref,
|
||||
PointerRNA *r_ptr)
|
||||
{
|
||||
IDProperty *group = WM_toolsystem_ref_properties_get_idprops(tref);
|
||||
IDProperty *prop = group ? IDP_GetPropertyFromGroup(group, idname) : NULL;
|
||||
RNA_pointer_create(NULL, type, prop, r_ptr);
|
||||
return (prop != NULL);
|
||||
IDProperty *prop = group ? IDP_GetPropertyFromGroup(group, idname) : nullptr;
|
||||
RNA_pointer_create(nullptr, type, prop, r_ptr);
|
||||
return (prop != nullptr);
|
||||
}
|
||||
|
||||
void WM_toolsystem_ref_properties_ensure_ex(bToolRef *tref,
|
||||
@@ -917,7 +914,7 @@ void WM_toolsystem_ref_properties_ensure_ex(bToolRef *tref,
|
||||
{
|
||||
IDProperty *group = WM_toolsystem_ref_properties_ensure_idprops(tref);
|
||||
IDProperty *prop = idprops_ensure_named_group(group, idname);
|
||||
RNA_pointer_create(NULL, type, prop, r_ptr);
|
||||
RNA_pointer_create(nullptr, type, prop, r_ptr);
|
||||
}
|
||||
|
||||
void WM_toolsystem_ref_properties_init_for_keymap(bToolRef *tref,
|
||||
@@ -927,14 +924,14 @@ void WM_toolsystem_ref_properties_init_for_keymap(bToolRef *tref,
|
||||
{
|
||||
*dst_ptr = *src_ptr;
|
||||
if (dst_ptr->data) {
|
||||
dst_ptr->data = IDP_CopyProperty(dst_ptr->data);
|
||||
dst_ptr->data = IDP_CopyProperty(static_cast<const IDProperty *>(dst_ptr->data));
|
||||
}
|
||||
else {
|
||||
IDPropertyTemplate val = {0};
|
||||
dst_ptr->data = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
|
||||
}
|
||||
IDProperty *group = WM_toolsystem_ref_properties_get_idprops(tref);
|
||||
if (group != NULL) {
|
||||
if (group != nullptr) {
|
||||
IDProperty *prop = IDP_GetPropertyFromGroup(group, ot->idname);
|
||||
if (prop) {
|
||||
/* Important key-map items properties don't get overwritten by the tools.
|
||||
@@ -944,7 +941,7 @@ void WM_toolsystem_ref_properties_init_for_keymap(bToolRef *tref,
|
||||
* This way the default action can be to follow the top-bar tool-settings &
|
||||
* modifier keys can be used to perform different actions that aren't clobbered here.
|
||||
*/
|
||||
IDP_MergeGroup(dst_ptr->data, prop, false);
|
||||
IDP_MergeGroup(static_cast<IDProperty *>(dst_ptr->data), prop, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,9 @@ void WM_tooltip_immediate_init(
|
||||
WM_tooltip_timer_clear(C, win);
|
||||
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
if (screen->tool_tip == NULL) {
|
||||
screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__);
|
||||
if (screen->tool_tip == nullptr) {
|
||||
screen->tool_tip = static_cast<wmTooltipState *>(
|
||||
MEM_callocN(sizeof(*screen->tool_tip), __func__));
|
||||
}
|
||||
screen->tool_tip->area_from = area;
|
||||
screen->tool_tip->region_from = region;
|
||||
@@ -52,8 +53,9 @@ void WM_tooltip_timer_init_ex(
|
||||
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
if (screen->tool_tip == NULL) {
|
||||
screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__);
|
||||
if (screen->tool_tip == nullptr) {
|
||||
screen->tool_tip = static_cast<wmTooltipState *>(
|
||||
MEM_callocN(sizeof(*screen->tool_tip), __func__));
|
||||
}
|
||||
screen->tool_tip->area_from = area;
|
||||
screen->tool_tip->region_from = region;
|
||||
@@ -71,10 +73,10 @@ void WM_tooltip_timer_clear(bContext *C, wmWindow *win)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
if (screen->tool_tip != NULL) {
|
||||
if (screen->tool_tip->timer != NULL) {
|
||||
if (screen->tool_tip != nullptr) {
|
||||
if (screen->tool_tip->timer != nullptr) {
|
||||
WM_event_timer_remove(wm, win, screen->tool_tip->timer);
|
||||
screen->tool_tip->timer = NULL;
|
||||
screen->tool_tip->timer = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,14 +85,14 @@ void WM_tooltip_clear(bContext *C, wmWindow *win)
|
||||
{
|
||||
WM_tooltip_timer_clear(C, win);
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
if (screen->tool_tip != NULL) {
|
||||
if (screen->tool_tip != nullptr) {
|
||||
if (screen->tool_tip->region) {
|
||||
UI_tooltip_free(C, screen, screen->tool_tip->region);
|
||||
screen->tool_tip->region = NULL;
|
||||
screen->tool_tip->region = nullptr;
|
||||
g_tooltip_time_closed = PIL_check_seconds_timer();
|
||||
}
|
||||
MEM_freeN(screen->tool_tip);
|
||||
screen->tool_tip = NULL;
|
||||
screen->tool_tip = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +102,7 @@ void WM_tooltip_init(bContext *C, wmWindow *win)
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
if (screen->tool_tip->region) {
|
||||
UI_tooltip_free(C, screen, screen->tool_tip->region);
|
||||
screen->tool_tip->region = NULL;
|
||||
screen->tool_tip->region = nullptr;
|
||||
}
|
||||
const int pass_prev = screen->tool_tip->pass;
|
||||
double pass_delay = 0.0;
|
||||
@@ -125,7 +127,7 @@ void WM_tooltip_init(bContext *C, wmWindow *win)
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
screen->tool_tip->timer = WM_event_timer_add(wm, win, TIMER, pass_delay);
|
||||
}
|
||||
if (screen->tool_tip->region == NULL) {
|
||||
if (screen->tool_tip->region == nullptr) {
|
||||
WM_tooltip_clear(C, win);
|
||||
}
|
||||
}
|
||||
@@ -134,10 +136,10 @@ void WM_tooltip_refresh(bContext *C, wmWindow *win)
|
||||
{
|
||||
WM_tooltip_timer_clear(C, win);
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
if (screen->tool_tip != NULL) {
|
||||
if (screen->tool_tip != nullptr) {
|
||||
if (screen->tool_tip->region) {
|
||||
UI_tooltip_free(C, screen, screen->tool_tip->region);
|
||||
screen->tool_tip->region = NULL;
|
||||
screen->tool_tip->region = nullptr;
|
||||
}
|
||||
WM_tooltip_init(C, win);
|
||||
}
|
||||
@@ -31,12 +31,12 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
static GHash *uilisttypes_hash = NULL;
|
||||
static GHash *uilisttypes_hash = nullptr;
|
||||
|
||||
uiListType *WM_uilisttype_find(const char *idname, bool quiet)
|
||||
{
|
||||
if (idname[0]) {
|
||||
uiListType *ult = BLI_ghash_lookup(uilisttypes_hash, idname);
|
||||
uiListType *ult = static_cast<uiListType *>(BLI_ghash_lookup(uilisttypes_hash, idname));
|
||||
if (ult) {
|
||||
return ult;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ uiListType *WM_uilisttype_find(const char *idname, bool quiet)
|
||||
printf("search for unknown uilisttype %s\n", idname);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool WM_uilisttype_add(uiListType *ult)
|
||||
@@ -61,7 +61,7 @@ static void wm_uilisttype_unlink_from_region(const uiListType *ult, ARegion *reg
|
||||
if (list->type == ult) {
|
||||
/* Don't delete the list, it's not just runtime data but stored in files. Freeing would make
|
||||
* that data get lost. */
|
||||
list->type = NULL;
|
||||
list->type = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,9 @@ static void wm_uilisttype_unlink_from_area(const uiListType *ult, ScrArea *area)
|
||||
*/
|
||||
static void wm_uilisttype_unlink(Main *bmain, const uiListType *ult)
|
||||
{
|
||||
for (wmWindowManager *wm = bmain->wm.first; wm != NULL; wm = wm->id.next) {
|
||||
for (wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first); wm != nullptr;
|
||||
wm = static_cast<wmWindowManager *>(wm->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
LISTBASE_FOREACH (ScrArea *, global_area, &win->global_areas.areabase) {
|
||||
wm_uilisttype_unlink_from_area(ult, global_area);
|
||||
@@ -97,7 +99,9 @@ static void wm_uilisttype_unlink(Main *bmain, const uiListType *ult)
|
||||
}
|
||||
}
|
||||
|
||||
for (bScreen *screen = bmain->screens.first; screen != NULL; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen != nullptr;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
wm_uilisttype_unlink_from_area(ult, area);
|
||||
}
|
||||
@@ -112,7 +116,7 @@ void WM_uilisttype_remove_ptr(Main *bmain, uiListType *ult)
|
||||
{
|
||||
wm_uilisttype_unlink(bmain, ult);
|
||||
|
||||
bool ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN);
|
||||
bool ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, nullptr, MEM_freeN);
|
||||
|
||||
BLI_assert(ok);
|
||||
UNUSED_VARS_NDEBUG(ok);
|
||||
@@ -127,14 +131,14 @@ void WM_uilisttype_free(void)
|
||||
{
|
||||
GHashIterator gh_iter;
|
||||
GHASH_ITER (gh_iter, uilisttypes_hash) {
|
||||
uiListType *ult = BLI_ghashIterator_getValue(&gh_iter);
|
||||
uiListType *ult = static_cast<uiListType *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||
if (ult->rna_ext.free) {
|
||||
ult->rna_ext.free(ult->rna_ext.data);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_ghash_free(uilisttypes_hash, NULL, MEM_freeN);
|
||||
uilisttypes_hash = NULL;
|
||||
BLI_ghash_free(uilisttypes_hash, nullptr, MEM_freeN);
|
||||
uilisttypes_hash = nullptr;
|
||||
}
|
||||
|
||||
void WM_uilisttype_to_full_list_id(const uiListType *ult,
|
||||
@@ -25,14 +25,14 @@ void WM_generic_callback_free(wmGenericCallback *callback)
|
||||
MEM_freeN(callback);
|
||||
}
|
||||
|
||||
static void do_nothing(struct bContext *UNUSED(C), void *UNUSED(user_data)) {}
|
||||
static void do_nothing(struct bContext * /*C*/, void * /*user_data*/) {}
|
||||
|
||||
wmGenericCallback *WM_generic_callback_steal(wmGenericCallback *callback)
|
||||
{
|
||||
wmGenericCallback *new_callback = MEM_dupallocN(callback);
|
||||
wmGenericCallback *new_callback = static_cast<wmGenericCallback *>(MEM_dupallocN(callback));
|
||||
callback->exec = do_nothing;
|
||||
callback->free_user_data = NULL;
|
||||
callback->user_data = NULL;
|
||||
callback->free_user_data = nullptr;
|
||||
callback->user_data = nullptr;
|
||||
return new_callback;
|
||||
}
|
||||
|
||||
@@ -88,15 +88,16 @@
|
||||
#endif
|
||||
|
||||
/* the global to talk to ghost */
|
||||
static GHOST_SystemHandle g_system = NULL;
|
||||
static GHOST_SystemHandle g_system = nullptr;
|
||||
#if !(defined(WIN32) || defined(__APPLE__))
|
||||
static const char *g_system_backend_id = NULL;
|
||||
static const char *g_system_backend_id = nullptr;
|
||||
#endif
|
||||
|
||||
typedef enum eWinOverrideFlag {
|
||||
enum eWinOverrideFlag {
|
||||
WIN_OVERRIDE_GEOM = (1 << 0),
|
||||
WIN_OVERRIDE_WINSTATE = (1 << 1),
|
||||
} eWinOverrideFlag;
|
||||
};
|
||||
ENUM_OPERATORS(eWinOverrideFlag, WIN_OVERRIDE_WINSTATE)
|
||||
|
||||
#define GHOST_WINDOW_STATE_DEFAULT GHOST_kWindowStateMaximized
|
||||
|
||||
@@ -118,16 +119,12 @@ static struct WMInitStruct {
|
||||
int size_x, size_y;
|
||||
int start_x, start_y;
|
||||
|
||||
GHOST_TWindowState windowstate;
|
||||
GHOST_TWindowState windowstate = GHOST_WINDOW_STATE_DEFAULT;
|
||||
eWinOverrideFlag override_flag;
|
||||
|
||||
bool window_focus;
|
||||
bool native_pixels;
|
||||
} wm_init_state = {
|
||||
.windowstate = GHOST_WINDOW_STATE_DEFAULT,
|
||||
.window_focus = true,
|
||||
.native_pixels = true,
|
||||
};
|
||||
bool window_focus = true;
|
||||
bool native_pixels = true;
|
||||
} wm_init_state;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Modifier Constants
|
||||
@@ -213,19 +210,19 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
|
||||
wm_window_clear_drawable(wm);
|
||||
|
||||
if (win == wm->winactive) {
|
||||
wm->winactive = NULL;
|
||||
wm->winactive = nullptr;
|
||||
}
|
||||
|
||||
/* We need this window's GPU context active to discard it. */
|
||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||
GPU_context_active_set(win->gpuctx);
|
||||
GHOST_ActivateWindowDrawingContext(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
GPU_context_active_set(static_cast<GPUContext *>(win->gpuctx));
|
||||
|
||||
/* Delete local GPU context. */
|
||||
GPU_context_discard(win->gpuctx);
|
||||
GPU_context_discard(static_cast<GPUContext *>(win->gpuctx));
|
||||
|
||||
GHOST_DisposeWindow(g_system, win->ghostwin);
|
||||
win->ghostwin = NULL;
|
||||
win->gpuctx = NULL;
|
||||
GHOST_DisposeWindow(g_system, static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
win->ghostwin = nullptr;
|
||||
win->gpuctx = nullptr;
|
||||
}
|
||||
|
||||
void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
@@ -236,7 +233,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
WM_event_remove_handlers(C, &win->modalhandlers);
|
||||
|
||||
if (CTX_wm_window(C) == win) {
|
||||
CTX_wm_window_set(C, NULL);
|
||||
CTX_wm_window_set(C, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,14 +300,15 @@ static int find_free_winid(wmWindowManager *wm)
|
||||
|
||||
wmWindow *wm_window_new(const Main *bmain, wmWindowManager *wm, wmWindow *parent, bool dialog)
|
||||
{
|
||||
wmWindow *win = MEM_callocN(sizeof(wmWindow), "window");
|
||||
wmWindow *win = static_cast<wmWindow *>(MEM_callocN(sizeof(wmWindow), "window"));
|
||||
|
||||
BLI_addtail(&wm->windows, win);
|
||||
win->winid = find_free_winid(wm);
|
||||
|
||||
/* Dialogs may have a child window as parent. Otherwise, a child must not be a parent too. */
|
||||
win->parent = (!dialog && parent && parent->parent) ? parent->parent : parent;
|
||||
win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo 3D Format (window)");
|
||||
win->stereo3d_format = static_cast<Stereo3dFormat *>(
|
||||
MEM_callocN(sizeof(Stereo3dFormat), "Stereo 3D Format (window)"));
|
||||
win->workspace_hook = BKE_workspace_instance_hook_create(bmain, win->winid);
|
||||
|
||||
return win;
|
||||
@@ -322,7 +320,7 @@ wmWindow *wm_window_copy(Main *bmain,
|
||||
const bool duplicate_layout,
|
||||
const bool child)
|
||||
{
|
||||
const bool is_dialog = GHOST_IsDialogWindow(win_src->ghostwin);
|
||||
const bool is_dialog = GHOST_IsDialogWindow(static_cast<GHOST_WindowHandle>(win_src->ghostwin));
|
||||
wmWindow *win_parent = (child) ? win_src : win_src->parent;
|
||||
wmWindow *win_dst = wm_window_new(bmain, wm, win_parent, is_dialog);
|
||||
WorkSpace *workspace = WM_window_get_active_workspace(win_src);
|
||||
@@ -359,11 +357,11 @@ wmWindow *wm_window_copy_test(bContext *C,
|
||||
WM_check(C);
|
||||
|
||||
if (win_dst->ghostwin) {
|
||||
WM_event_add_notifier_ex(wm, CTX_wm_window(C), NC_WINDOW | NA_ADDED, NULL);
|
||||
WM_event_add_notifier_ex(wm, CTX_wm_window(C), NC_WINDOW | NA_ADDED, nullptr);
|
||||
return win_dst;
|
||||
}
|
||||
wm_window_close(C, wm, win_dst);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -372,7 +370,7 @@ wmWindow *wm_window_copy_test(bContext *C,
|
||||
/** \name Window Quit Confirmation Dialog
|
||||
* \{ */
|
||||
|
||||
static void wm_save_file_on_quit_dialog_callback(bContext *C, void *UNUSED(user_data))
|
||||
static void wm_save_file_on_quit_dialog_callback(bContext *C, void * /*user_data*/)
|
||||
{
|
||||
wm_exit_schedule_delayed(C);
|
||||
}
|
||||
@@ -383,7 +381,8 @@ static void wm_save_file_on_quit_dialog_callback(bContext *C, void *UNUSED(user_
|
||||
*/
|
||||
static void wm_confirm_quit(bContext *C)
|
||||
{
|
||||
wmGenericCallback *action = MEM_callocN(sizeof(*action), __func__);
|
||||
wmGenericCallback *action = static_cast<wmGenericCallback *>(
|
||||
MEM_callocN(sizeof(*action), __func__));
|
||||
action->exec = wm_save_file_on_quit_dialog_callback;
|
||||
wm_close_file_dialog(C, action);
|
||||
}
|
||||
@@ -425,13 +424,15 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
wmWindow *win_other;
|
||||
|
||||
/* First check if there is another main window remaining. */
|
||||
for (win_other = wm->windows.first; win_other; win_other = win_other->next) {
|
||||
if (win_other != win && win_other->parent == NULL && !WM_window_is_temp_screen(win_other)) {
|
||||
for (win_other = static_cast<wmWindow *>(wm->windows.first); win_other;
|
||||
win_other = win_other->next)
|
||||
{
|
||||
if (win_other != win && win_other->parent == nullptr && !WM_window_is_temp_screen(win_other)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (win->parent == NULL && win_other == NULL) {
|
||||
if (win->parent == nullptr && win_other == nullptr) {
|
||||
wm_quit_with_optional_confirmation_prompt(C, win);
|
||||
return;
|
||||
}
|
||||
@@ -454,7 +455,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
|
||||
WM_event_remove_handlers(C, &win->modalhandlers);
|
||||
|
||||
/* for regular use this will _never_ be NULL,
|
||||
/* for regular use this will _never_ be nullptr,
|
||||
* however we may be freeing an improperly initialized window. */
|
||||
if (screen) {
|
||||
ED_screen_exit(C, win, screen);
|
||||
@@ -468,7 +469,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
|
||||
BLI_assert(BKE_workspace_layout_screen_get(layout) == screen);
|
||||
BKE_workspace_layout_remove(bmain, workspace, layout);
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTDELETE, NULL);
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTDELETE, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,28 +483,29 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
|
||||
/* this is set to 1 if you don't have startup.blend open */
|
||||
const char *blendfile_path = BKE_main_blendfile_path_from_global();
|
||||
if (blendfile_path[0] != '\0') {
|
||||
char str[sizeof(((Main *)NULL)->filepath) + 24];
|
||||
char str[sizeof(((Main *)nullptr)->filepath) + 24];
|
||||
SNPRINTF(str,
|
||||
"Blender%s [%s%s]",
|
||||
wm->file_saved ? "" : "*",
|
||||
blendfile_path,
|
||||
G_MAIN->recovered ? " (Recovered)" : "");
|
||||
GHOST_SetTitle(win->ghostwin, str);
|
||||
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), str);
|
||||
}
|
||||
else {
|
||||
GHOST_SetTitle(win->ghostwin, "Blender");
|
||||
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), "Blender");
|
||||
}
|
||||
|
||||
/* Informs GHOST of unsaved changes, to set window modified visual indicator (macOS)
|
||||
* and to give hint of unsaved changes for a user warning mechanism in case of OS application
|
||||
* terminate request (e.g. OS Shortcut Alt+F4, Command+Q, (...), or session end). */
|
||||
GHOST_SetWindowModifiedState(win->ghostwin, (bool)!wm->file_saved);
|
||||
GHOST_SetWindowModifiedState(static_cast<GHOST_WindowHandle>(win->ghostwin),
|
||||
(bool)!wm->file_saved);
|
||||
}
|
||||
}
|
||||
|
||||
void WM_window_set_dpi(const wmWindow *win)
|
||||
{
|
||||
float auto_dpi = GHOST_GetDPIHint(win->ghostwin);
|
||||
float auto_dpi = GHOST_GetDPIHint(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
/* Clamp auto DPI to 96, since our font/interface drawing does not work well
|
||||
* with lower sizes. The main case we are interested in supporting is higher
|
||||
@@ -528,7 +530,7 @@ void WM_window_set_dpi(const wmWindow *win)
|
||||
/* Blender's UI drawing assumes DPI 72 as a good default following macOS
|
||||
* while Windows and Linux use DPI 96. GHOST assumes a default 96 so we
|
||||
* remap the DPI to Blender's convention. */
|
||||
auto_dpi *= GHOST_GetNativePixelSize(win->ghostwin);
|
||||
auto_dpi *= GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
U.dpi = auto_dpi * U.ui_scale * (72.0 / 96.0f);
|
||||
|
||||
/* Automatically set larger pixel size for high DPI. */
|
||||
@@ -566,11 +568,10 @@ static void wm_window_update_eventstate_modifiers(wmWindowManager *wm, wmWindow
|
||||
const uint8_t keymodifier = keymodifier_sided[0] | keymodifier_sided[1];
|
||||
const uint8_t keymodifier_eventstate = win->eventstate->modifier;
|
||||
if (keymodifier != keymodifier_eventstate) {
|
||||
GHOST_TEventKeyData kdata = {
|
||||
.key = GHOST_kKeyUnknown,
|
||||
.utf8_buf = {'\0'},
|
||||
.is_repeat = false,
|
||||
};
|
||||
GHOST_TEventKeyData kdata{};
|
||||
kdata.key = GHOST_kKeyUnknown;
|
||||
kdata.utf8_buf[0] = '\0';
|
||||
kdata.is_repeat = false;
|
||||
for (int i = 0; i < ARRAY_SIZE(g_modifier_table); i++) {
|
||||
if (keymodifier_eventstate & g_modifier_table[i].flag) {
|
||||
if ((keymodifier & g_modifier_table[i].flag) == 0) {
|
||||
@@ -626,14 +627,13 @@ static void wm_window_update_eventstate_modifiers_clear(wmWindowManager *wm, wmW
|
||||
const uint8_t keymodifier_unhandled = keymodifier_eventstate &
|
||||
~(keymodifier_l | keymodifier_r);
|
||||
const uint8_t keymodifier_sided[2] = {
|
||||
keymodifier_l | keymodifier_unhandled,
|
||||
uint8_t(keymodifier_l | keymodifier_unhandled),
|
||||
keymodifier_r,
|
||||
};
|
||||
GHOST_TEventKeyData kdata = {
|
||||
.key = GHOST_kKeyUnknown,
|
||||
.utf8_buf = {'\0'},
|
||||
.is_repeat = false,
|
||||
};
|
||||
GHOST_TEventKeyData kdata{};
|
||||
kdata.key = GHOST_kKeyUnknown;
|
||||
kdata.utf8_buf[0] = '\0';
|
||||
kdata.is_repeat = false;
|
||||
for (int i = 0; i < ARRAY_SIZE(g_modifier_table); i++) {
|
||||
if (keymodifier_eventstate & g_modifier_table[i].flag) {
|
||||
for (int side = 0; side < 2; side++) {
|
||||
@@ -659,7 +659,7 @@ static void wm_window_ensure_eventstate(wmWindow *win)
|
||||
return;
|
||||
}
|
||||
|
||||
win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
|
||||
win->eventstate = static_cast<wmEvent *>(MEM_callocN(sizeof(wmEvent), "window event state"));
|
||||
wm_window_update_eventstate(win);
|
||||
}
|
||||
|
||||
@@ -690,19 +690,20 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
|
||||
wmWindow *prev_windrawable = wm->windrawable;
|
||||
wm_window_clear_drawable(wm);
|
||||
|
||||
GHOST_WindowHandle ghostwin = GHOST_CreateWindow(g_system,
|
||||
(win->parent) ? win->parent->ghostwin : NULL,
|
||||
title,
|
||||
win->posx,
|
||||
posy,
|
||||
win->sizex,
|
||||
win->sizey,
|
||||
(GHOST_TWindowState)win->windowstate,
|
||||
is_dialog,
|
||||
gpuSettings);
|
||||
GHOST_WindowHandle ghostwin = GHOST_CreateWindow(
|
||||
g_system,
|
||||
static_cast<GHOST_WindowHandle>((win->parent) ? win->parent->ghostwin : nullptr),
|
||||
title,
|
||||
win->posx,
|
||||
posy,
|
||||
win->sizex,
|
||||
win->sizey,
|
||||
(GHOST_TWindowState)win->windowstate,
|
||||
is_dialog,
|
||||
gpuSettings);
|
||||
|
||||
if (ghostwin) {
|
||||
win->gpuctx = GPU_context_create(ghostwin, NULL);
|
||||
win->gpuctx = GPU_context_create(ghostwin, nullptr);
|
||||
GPU_render_begin();
|
||||
|
||||
/* needed so we can detect the graphics card below */
|
||||
@@ -718,10 +719,13 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
|
||||
wm_window_ensure_eventstate(win);
|
||||
|
||||
/* store actual window size in blender window */
|
||||
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(win->ghostwin);
|
||||
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(
|
||||
static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
/* win32: gives undefined window size when minimized */
|
||||
if (GHOST_GetWindowState(win->ghostwin) != GHOST_kWindowStateMinimized) {
|
||||
if (GHOST_GetWindowState(static_cast<GHOST_WindowHandle>(win->ghostwin)) !=
|
||||
GHOST_kWindowStateMinimized)
|
||||
{
|
||||
win->sizex = GHOST_GetWidthRectangle(bounds);
|
||||
win->sizey = GHOST_GetHeightRectangle(bounds);
|
||||
}
|
||||
@@ -753,7 +757,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
|
||||
|
||||
static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, bool is_dialog)
|
||||
{
|
||||
if (win->ghostwin == NULL) {
|
||||
if (win->ghostwin == nullptr) {
|
||||
if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) {
|
||||
win->posx = wm_init_state.start_x;
|
||||
win->posy = wm_init_state.start_y;
|
||||
@@ -782,7 +786,7 @@ static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, boo
|
||||
wm_window_ghostwindow_add(wm, "Blender", win, is_dialog);
|
||||
}
|
||||
|
||||
if (win->ghostwin != NULL) {
|
||||
if (win->ghostwin != nullptr) {
|
||||
/* If we have no `ghostwin` this is a buggy window that should be removed.
|
||||
* However we still need to initialize it correctly so the screen doesn't hang. */
|
||||
|
||||
@@ -841,7 +845,7 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm)
|
||||
BLI_assert(G.background == false);
|
||||
|
||||
LISTBASE_FOREACH_MUTABLE (wmWindow *, win, &wm->windows) {
|
||||
if (win->ghostwin == NULL) {
|
||||
if (win->ghostwin == nullptr) {
|
||||
wm_window_close(C, wm, win);
|
||||
}
|
||||
}
|
||||
@@ -850,7 +854,8 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm)
|
||||
/* Update window size and position based on data from GHOST window. */
|
||||
static bool wm_window_update_size_position(wmWindow *win)
|
||||
{
|
||||
GHOST_RectangleHandle client_rect = GHOST_GetClientBounds(win->ghostwin);
|
||||
GHOST_RectangleHandle client_rect = GHOST_GetClientBounds(
|
||||
static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
int l, t, r, b;
|
||||
GHOST_GetRectangle(client_rect, &l, &t, &r, &b);
|
||||
|
||||
@@ -895,7 +900,8 @@ wmWindow *WM_window_open(bContext *C,
|
||||
int sizey = BLI_rcti_size_y(rect_unscaled);
|
||||
rcti rect;
|
||||
|
||||
const float native_pixel_size = GHOST_GetNativePixelSize(win_prev->ghostwin);
|
||||
const float native_pixel_size = GHOST_GetNativePixelSize(
|
||||
static_cast<GHOST_WindowHandle>(win_prev->ghostwin));
|
||||
/* convert to native OS window coordinates */
|
||||
rect.xmin = win_prev->posx + (x / native_pixel_size);
|
||||
rect.ymin = win_prev->posy + (y / native_pixel_size);
|
||||
@@ -923,12 +929,12 @@ wmWindow *WM_window_open(bContext *C,
|
||||
wm_window_check_size(&rect);
|
||||
|
||||
/* Reuse temporary windows when they share the same single area. */
|
||||
wmWindow *win = NULL;
|
||||
wmWindow *win = nullptr;
|
||||
if (temp) {
|
||||
LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) {
|
||||
const bScreen *screen = WM_window_get_active_screen(win_iter);
|
||||
if (screen && screen->temp && BLI_listbase_is_single(&screen->areabase)) {
|
||||
ScrArea *area = screen->areabase.first;
|
||||
ScrArea *area = static_cast<ScrArea *>(screen->areabase.first);
|
||||
if (space_type == (area->butspacetype ? area->butspacetype : area->spacetype)) {
|
||||
win = win_iter;
|
||||
break;
|
||||
@@ -938,8 +944,8 @@ wmWindow *WM_window_open(bContext *C,
|
||||
}
|
||||
|
||||
/* add new window? */
|
||||
if (win == NULL) {
|
||||
win = wm_window_new(bmain, wm, toplevel ? NULL : win_prev, dialog);
|
||||
if (win == nullptr) {
|
||||
win = wm_window_new(bmain, wm, toplevel ? nullptr : win_prev, dialog);
|
||||
win->posx = rect.xmin;
|
||||
win->posy = rect.ymin;
|
||||
win->sizex = BLI_rcti_size_x(&rect);
|
||||
@@ -949,12 +955,12 @@ wmWindow *WM_window_open(bContext *C,
|
||||
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
|
||||
if (WM_window_get_active_workspace(win) == NULL) {
|
||||
if (WM_window_get_active_workspace(win) == nullptr) {
|
||||
WorkSpace *workspace = WM_window_get_active_workspace(win_prev);
|
||||
BKE_workspace_active_set(win->workspace_hook, workspace);
|
||||
}
|
||||
|
||||
if (screen == NULL) {
|
||||
if (screen == nullptr) {
|
||||
/* add new screen layout */
|
||||
WorkSpace *workspace = WM_window_get_active_workspace(win);
|
||||
WorkSpaceLayout *layout = ED_workspace_layout_add(bmain, workspace, win, "temp");
|
||||
@@ -974,13 +980,13 @@ wmWindow *WM_window_open(bContext *C,
|
||||
|
||||
/* make window active, and validate/resize */
|
||||
CTX_wm_window_set(C, win);
|
||||
const bool new_window = (win->ghostwin == NULL);
|
||||
const bool new_window = (win->ghostwin == nullptr);
|
||||
if (new_window) {
|
||||
wm_window_ghostwindow_ensure(wm, win, dialog);
|
||||
}
|
||||
WM_check(C);
|
||||
|
||||
/* It's possible `win->ghostwin == NULL`.
|
||||
/* It's possible `win->ghostwin == nullptr`.
|
||||
* instead of attempting to cleanup here (in a half finished state),
|
||||
* finish setting up the screen, then free it at the end of the function,
|
||||
* to avoid having to take into account a partially-created window.
|
||||
@@ -995,13 +1001,13 @@ wmWindow *WM_window_open(bContext *C,
|
||||
* otherwise it will attempt to make the empty area usable via #ED_area_init.
|
||||
* While refreshing the window could be postponed this makes the state of the
|
||||
* window less predictable to the caller. */
|
||||
ScrArea *area = screen->areabase.first;
|
||||
ScrArea *area = static_cast<ScrArea *>(screen->areabase.first);
|
||||
area_setup_fn(screen, area, area_setup_user_data);
|
||||
CTX_wm_area_set(C, area);
|
||||
}
|
||||
else if (space_type != SPACE_EMPTY) {
|
||||
/* Ensure it shows the right space-type editor. */
|
||||
ScrArea *area = screen->areabase.first;
|
||||
ScrArea *area = static_cast<ScrArea *>(screen->areabase.first);
|
||||
CTX_wm_area_set(C, area);
|
||||
ED_area_newspace(C, area, space_type, false);
|
||||
}
|
||||
@@ -1020,7 +1026,7 @@ wmWindow *WM_window_open(bContext *C,
|
||||
|
||||
if (win->ghostwin) {
|
||||
wm_window_raise(win);
|
||||
GHOST_SetTitle(win->ghostwin, title);
|
||||
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), title);
|
||||
return win;
|
||||
}
|
||||
|
||||
@@ -1028,7 +1034,7 @@ wmWindow *WM_window_open(bContext *C,
|
||||
wm_window_close(C, wm, win);
|
||||
CTX_wm_window_set(C, win_prev);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1037,7 +1043,7 @@ wmWindow *WM_window_open(bContext *C,
|
||||
/** \name Operators
|
||||
* \{ */
|
||||
|
||||
int wm_window_close_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
int wm_window_close_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
@@ -1051,9 +1057,9 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
|
||||
ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0);
|
||||
const rcti window_rect = {
|
||||
/*xmin*/ 0,
|
||||
/*xmax*/ win_src->sizex * 0.95f,
|
||||
/*xmax*/ int(win_src->sizex * 0.95f),
|
||||
/*ymin*/ 0,
|
||||
/*ymax*/ win_src->sizey * 0.9f,
|
||||
/*ymax*/ int(win_src->sizey * 0.9f),
|
||||
};
|
||||
|
||||
bool ok = (WM_window_open(C,
|
||||
@@ -1064,8 +1070,8 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
|
||||
false,
|
||||
false,
|
||||
WIN_ALIGN_PARENT_CENTER,
|
||||
NULL,
|
||||
NULL) != NULL);
|
||||
nullptr,
|
||||
nullptr) != nullptr);
|
||||
|
||||
if (!ok) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Failed to create window");
|
||||
@@ -1078,7 +1084,7 @@ int wm_window_new_main_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindow *win_src = CTX_wm_window(C);
|
||||
|
||||
bool ok = (wm_window_copy_test(C, win_src, true, false) != NULL);
|
||||
bool ok = (wm_window_copy_test(C, win_src, true, false) != nullptr);
|
||||
if (!ok) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Failed to create window");
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -1086,7 +1092,7 @@ int wm_window_new_main_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
wmWindow *window = CTX_wm_window(C);
|
||||
|
||||
@@ -1094,12 +1100,15 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
GHOST_TWindowState state = GHOST_GetWindowState(window->ghostwin);
|
||||
GHOST_TWindowState state = GHOST_GetWindowState(
|
||||
static_cast<GHOST_WindowHandle>(window->ghostwin));
|
||||
if (state != GHOST_kWindowStateFullScreen) {
|
||||
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen);
|
||||
GHOST_SetWindowState(static_cast<GHOST_WindowHandle>(window->ghostwin),
|
||||
GHOST_kWindowStateFullScreen);
|
||||
}
|
||||
else {
|
||||
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal);
|
||||
GHOST_SetWindowState(static_cast<GHOST_WindowHandle>(window->ghostwin),
|
||||
GHOST_kWindowStateNormal);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1113,7 +1122,7 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
void wm_cursor_position_from_ghost_client_coords(wmWindow *win, int *x, int *y)
|
||||
{
|
||||
float fac = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
float fac = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
*x *= fac;
|
||||
|
||||
*y = (win->sizey - 1) - *y;
|
||||
@@ -1122,7 +1131,7 @@ void wm_cursor_position_from_ghost_client_coords(wmWindow *win, int *x, int *y)
|
||||
|
||||
void wm_cursor_position_to_ghost_client_coords(wmWindow *win, int *x, int *y)
|
||||
{
|
||||
float fac = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
float fac = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
*x /= fac;
|
||||
*y /= fac;
|
||||
@@ -1131,14 +1140,14 @@ void wm_cursor_position_to_ghost_client_coords(wmWindow *win, int *x, int *y)
|
||||
|
||||
void wm_cursor_position_from_ghost_screen_coords(wmWindow *win, int *x, int *y)
|
||||
{
|
||||
GHOST_ScreenToClient(win->ghostwin, *x, *y, x, y);
|
||||
GHOST_ScreenToClient(static_cast<GHOST_WindowHandle>(win->ghostwin), *x, *y, x, y);
|
||||
wm_cursor_position_from_ghost_client_coords(win, x, y);
|
||||
}
|
||||
|
||||
void wm_cursor_position_to_ghost_screen_coords(wmWindow *win, int *x, int *y)
|
||||
{
|
||||
wm_cursor_position_to_ghost_client_coords(win, x, y);
|
||||
GHOST_ClientToScreen(win->ghostwin, *x, *y, x, y);
|
||||
GHOST_ClientToScreen(static_cast<GHOST_WindowHandle>(win->ghostwin), *x, *y, x, y);
|
||||
}
|
||||
|
||||
void wm_cursor_position_get(wmWindow *win, int *r_x, int *r_y)
|
||||
@@ -1148,7 +1157,7 @@ void wm_cursor_position_get(wmWindow *win, int *r_x, int *r_y)
|
||||
*r_y = win->eventstate->xy[1];
|
||||
return;
|
||||
}
|
||||
GHOST_GetCursorPosition(g_system, win->ghostwin, r_x, r_y);
|
||||
GHOST_GetCursorPosition(g_system, static_cast<GHOST_WindowHandle>(win->ghostwin), r_x, r_y);
|
||||
wm_cursor_position_from_ghost_client_coords(win, r_x, r_y);
|
||||
}
|
||||
|
||||
@@ -1168,19 +1177,19 @@ static uint8_t wm_ghost_modifier_query(const enum ModSide side)
|
||||
|
||||
static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate)
|
||||
{
|
||||
BLI_assert(ELEM(wm->windrawable, NULL, win));
|
||||
BLI_assert(ELEM(wm->windrawable, nullptr, win));
|
||||
|
||||
wm->windrawable = win;
|
||||
if (activate) {
|
||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||
GHOST_ActivateWindowDrawingContext(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
}
|
||||
GPU_context_active_set(win->gpuctx);
|
||||
GPU_context_active_set(static_cast<GPUContext *>(win->gpuctx));
|
||||
}
|
||||
|
||||
void wm_window_clear_drawable(wmWindowManager *wm)
|
||||
{
|
||||
if (wm->windrawable) {
|
||||
wm->windrawable = NULL;
|
||||
wm->windrawable = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1209,9 +1218,9 @@ void wm_window_reset_drawable(void)
|
||||
{
|
||||
BLI_assert(BLI_thread_is_main());
|
||||
BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get());
|
||||
wmWindowManager *wm = G_MAIN->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
|
||||
|
||||
if (wm == NULL) {
|
||||
if (wm == nullptr) {
|
||||
return;
|
||||
}
|
||||
wmWindow *win = wm->windrawable;
|
||||
@@ -1229,7 +1238,7 @@ void wm_window_reset_drawable(void)
|
||||
*/
|
||||
static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr)
|
||||
{
|
||||
bContext *C = C_void_ptr;
|
||||
bContext *C = static_cast<bContext *>(C_void_ptr);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
GHOST_TEventType type = GHOST_GetEventType(evt);
|
||||
#if 0
|
||||
@@ -1243,7 +1252,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
|
||||
wmWindow *win;
|
||||
if (ghostwin && GHOST_ValidWindow(g_system, ghostwin)) {
|
||||
win = GHOST_GetWindowUserData(ghostwin);
|
||||
win = static_cast<wmWindow *>(GHOST_GetWindowUserData(ghostwin));
|
||||
}
|
||||
else {
|
||||
win = wm->winactive;
|
||||
@@ -1277,7 +1286,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
puts("<!> event has invalid window");
|
||||
return true;
|
||||
}
|
||||
wmWindow *win = GHOST_GetWindowUserData(ghostwin);
|
||||
wmWindow *win = static_cast<wmWindow *>(GHOST_GetWindowUserData(ghostwin));
|
||||
|
||||
switch (type) {
|
||||
case GHOST_kEventWindowDeactivate: {
|
||||
@@ -1319,7 +1328,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
event.type = MOUSEMOVE;
|
||||
event.val = KM_NOTHING;
|
||||
copy_v2_v2_int(event.prev_xy, event.xy);
|
||||
event.flag = 0;
|
||||
event.flag = eWM_EventFlag(0);
|
||||
|
||||
wm_event_add(win, &event);
|
||||
|
||||
@@ -1335,7 +1344,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
}
|
||||
|
||||
wm_window_make_drawable(wm, win);
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1346,18 +1355,19 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
|
||||
wm_window_make_drawable(wm, win);
|
||||
#if 0
|
||||
/* NOTE(@ideasman42): Ideally we could swap-buffers to avoid a full redraw.
|
||||
* however this causes window flickering on resize with LIBDECOR under WAYLAND. */
|
||||
wm_window_swap_buffers(win);
|
||||
/* NOTE(@ideasman42): Ideally we could swap-buffers to avoid a full redraw.
|
||||
* however this causes window flickering on resize with LIBDECOR under WAYLAND. */
|
||||
wm_window_swap_buffers(win);
|
||||
#else
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventWindowSize:
|
||||
case GHOST_kEventWindowMove: {
|
||||
GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin);
|
||||
GHOST_TWindowState state = GHOST_GetWindowState(
|
||||
static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
win->windowstate = state;
|
||||
|
||||
WM_window_set_dpi(win);
|
||||
@@ -1377,7 +1387,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
/* debug prints */
|
||||
if (G.debug & G_DEBUG_EVENTS) {
|
||||
const char *state_str;
|
||||
state = GHOST_GetWindowState(win->ghostwin);
|
||||
state = GHOST_GetWindowState(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
if (state == GHOST_kWindowStateNormal) {
|
||||
state_str = "normal";
|
||||
@@ -1408,8 +1418,8 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
|
||||
wm_window_make_drawable(wm, win);
|
||||
BKE_icon_changed(screen->id.icon_id);
|
||||
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
|
||||
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, nullptr);
|
||||
|
||||
#if defined(__APPLE__) || defined(WIN32)
|
||||
/* MACOS and WIN32 don't return to the main-loop while resize. */
|
||||
@@ -1428,13 +1438,13 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
/* font's are stored at each DPI level, without this we can easy load 100's of fonts */
|
||||
BLF_cache_clear();
|
||||
|
||||
WM_main_add_notifier(NC_WINDOW, NULL); /* full redraw */
|
||||
WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); /* refresh region sizes */
|
||||
WM_main_add_notifier(NC_WINDOW, nullptr); /* full redraw */
|
||||
WM_main_add_notifier(NC_SCREEN | NA_EDITED, nullptr); /* refresh region sizes */
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventOpenMainFile: {
|
||||
const char *path = GHOST_GetEventData(evt);
|
||||
const char *path = static_cast<const char *>(GHOST_GetEventData(evt));
|
||||
|
||||
if (path) {
|
||||
wmOperatorType *ot = WM_operatortype_find("WM_OT_open_mainfile", false);
|
||||
@@ -1446,15 +1456,16 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
WM_operator_properties_create_ptr(&props_ptr, ot);
|
||||
RNA_string_set(&props_ptr, "filepath", path);
|
||||
RNA_boolean_set(&props_ptr, "display_file_selector", false);
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, NULL);
|
||||
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, nullptr);
|
||||
WM_operator_properties_free(&props_ptr);
|
||||
|
||||
CTX_wm_window_set(C, NULL);
|
||||
CTX_wm_window_set(C, nullptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventDraggingDropDone: {
|
||||
GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
|
||||
GHOST_TEventDragnDropData *ddd = static_cast<GHOST_TEventDragnDropData *>(
|
||||
GHOST_GetEventData(evt));
|
||||
|
||||
/* Ensure the event state matches modifiers (window was inactive). */
|
||||
wm_window_update_eventstate_modifiers(wm, win);
|
||||
@@ -1477,7 +1488,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
* Write this into the event state. */
|
||||
copy_v2_v2_int(win->eventstate->xy, event.xy);
|
||||
|
||||
event.flag = 0;
|
||||
event.flag = eWM_EventFlag(0);
|
||||
|
||||
/* No context change! `C->wm->windrawable` is drawable, or for area queues. */
|
||||
wm->winactive = win;
|
||||
@@ -1499,7 +1510,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
/* add drag data to wm for paths: */
|
||||
|
||||
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
|
||||
GHOST_TStringArray *stra = ddd->data;
|
||||
GHOST_TStringArray *stra = static_cast<GHOST_TStringArray *>(ddd->data);
|
||||
|
||||
for (int a = 0; a < stra->count; a++) {
|
||||
printf("drop file %s\n", stra->strings[a]);
|
||||
@@ -1526,25 +1537,25 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
||||
* size baked in and it's difficult to correct them. */
|
||||
CTX_wm_window_set(C, win);
|
||||
UI_popup_handlers_remove_all(C, &win->modalhandlers);
|
||||
CTX_wm_window_set(C, NULL);
|
||||
CTX_wm_window_set(C, nullptr);
|
||||
|
||||
wm_window_make_drawable(wm, win);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
|
||||
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, nullptr);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventTrackpad: {
|
||||
GHOST_TEventTrackpadData *pd = data;
|
||||
GHOST_TEventTrackpadData *pd = static_cast<GHOST_TEventTrackpadData *>(data);
|
||||
|
||||
wm_cursor_position_from_ghost_screen_coords(win, &pd->x, &pd->y);
|
||||
wm_event_add_ghostevent(wm, win, type, data);
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventCursorMove: {
|
||||
GHOST_TEventCursorData *cd = data;
|
||||
GHOST_TEventCursorData *cd = static_cast<GHOST_TEventCursorData *>(data);
|
||||
|
||||
wm_cursor_position_from_ghost_screen_coords(win, &cd->x, &cd->y);
|
||||
wm_event_add_ghostevent(wm, win, type, data);
|
||||
@@ -1612,7 +1623,7 @@ static bool wm_window_timers_process(const bContext *C)
|
||||
wm_autosave_timer(bmain, wm, wt);
|
||||
}
|
||||
else if (wt->event_type == TIMERNOTIFIER) {
|
||||
WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), NULL);
|
||||
WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), nullptr);
|
||||
}
|
||||
else if (win) {
|
||||
wmEvent event;
|
||||
@@ -1621,7 +1632,7 @@ static bool wm_window_timers_process(const bContext *C)
|
||||
event.type = wt->event_type;
|
||||
event.val = KM_NOTHING;
|
||||
event.keymodifier = 0;
|
||||
event.flag = 0;
|
||||
event.flag = eWM_EventFlag(0);
|
||||
event.custom = EVT_DATA_TIMER;
|
||||
event.customdata = wt;
|
||||
wm_event_add(win, &event);
|
||||
@@ -1676,7 +1687,7 @@ void wm_ghost_init(bContext *C)
|
||||
return;
|
||||
}
|
||||
|
||||
BLI_assert(C != NULL);
|
||||
BLI_assert(C != nullptr);
|
||||
BLI_assert_msg(!G.background, "Use wm_ghost_init_background instead");
|
||||
|
||||
GHOST_EventConsumerHandle consumer;
|
||||
@@ -1687,7 +1698,7 @@ void wm_ghost_init(bContext *C)
|
||||
|
||||
g_system = GHOST_CreateSystem();
|
||||
|
||||
if (UNLIKELY(g_system == NULL)) {
|
||||
if (UNLIKELY(g_system == nullptr)) {
|
||||
/* GHOST will have reported the back-ends that failed to load. */
|
||||
fprintf(stderr, "GHOST: unable to initialize, exiting!\n");
|
||||
/* This will leak memory, it's preferable to crashing. */
|
||||
@@ -1739,7 +1750,7 @@ void wm_ghost_exit(void)
|
||||
if (g_system) {
|
||||
GHOST_DisposeSystem(g_system);
|
||||
}
|
||||
g_system = NULL;
|
||||
g_system = nullptr;
|
||||
}
|
||||
|
||||
const char *WM_ghost_backend(void)
|
||||
@@ -1786,7 +1797,7 @@ GHOST_TDrawingContextType wm_ghost_drawing_context_type(const eGPUBackendType gp
|
||||
return GHOST_kDrawingContextTypeNone;
|
||||
}
|
||||
|
||||
static uiBlock *block_create_opengl_usage_warning(bContext *C, ARegion *region, void *UNUSED(arg1))
|
||||
static uiBlock *block_create_opengl_usage_warning(bContext *C, ARegion *region, void * /*arg1*/)
|
||||
{
|
||||
uiBlock *block = UI_block_begin(C, region, "autorun_warning_popup", UI_EMBOSS);
|
||||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
@@ -1835,7 +1846,7 @@ void wm_test_opengl_deprecation_warning(bContext *C)
|
||||
}
|
||||
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = (wm->winactive) ? wm->winactive : wm->windows.first;
|
||||
wmWindow *win = static_cast<wmWindow *>((wm->winactive) ? wm->winactive : wm->windows.first);
|
||||
|
||||
BKE_report(
|
||||
&wm->reports,
|
||||
@@ -1846,7 +1857,7 @@ void wm_test_opengl_deprecation_warning(bContext *C)
|
||||
if (win) {
|
||||
wmWindow *prevwin = CTX_wm_window(C);
|
||||
CTX_wm_window_set(C, win);
|
||||
UI_popup_block_invoke(C, block_create_opengl_usage_warning, NULL, NULL);
|
||||
UI_popup_block_invoke(C, block_create_opengl_usage_warning, nullptr, nullptr);
|
||||
CTX_wm_window_set(C, prevwin);
|
||||
}
|
||||
|
||||
@@ -1855,11 +1866,11 @@ void wm_test_opengl_deprecation_warning(bContext *C)
|
||||
|
||||
eWM_CapabilitiesFlag WM_capabilities_flag(void)
|
||||
{
|
||||
static eWM_CapabilitiesFlag flag = -1;
|
||||
static eWM_CapabilitiesFlag flag = eWM_CapabilitiesFlag(-1);
|
||||
if (flag != -1) {
|
||||
return flag;
|
||||
}
|
||||
flag = 0;
|
||||
flag = eWM_CapabilitiesFlag(0);
|
||||
|
||||
const GHOST_TCapabilityFlag ghost_flag = GHOST_GetCapabilities();
|
||||
if (ghost_flag & GHOST_kCapabilityCursorWarp) {
|
||||
@@ -1887,10 +1898,7 @@ eWM_CapabilitiesFlag WM_capabilities_flag(void)
|
||||
/** \name Event Timer
|
||||
* \{ */
|
||||
|
||||
void WM_event_timer_sleep(wmWindowManager *wm,
|
||||
wmWindow *UNUSED(win),
|
||||
wmTimer *timer,
|
||||
bool do_sleep)
|
||||
void WM_event_timer_sleep(wmWindowManager *wm, wmWindow * /*win*/, wmTimer *timer, bool do_sleep)
|
||||
{
|
||||
LISTBASE_FOREACH (wmTimer *, wt, &wm->timers) {
|
||||
if (wt->flags & WM_TIMER_TAGGED_FOR_REMOVAL) {
|
||||
@@ -1905,7 +1913,7 @@ void WM_event_timer_sleep(wmWindowManager *wm,
|
||||
|
||||
wmTimer *WM_event_timer_add(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)
|
||||
{
|
||||
wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer");
|
||||
wmTimer *wt = static_cast<wmTimer *>(MEM_callocN(sizeof(wmTimer), "window timer"));
|
||||
BLI_assert(timestep >= 0.0f);
|
||||
|
||||
wt->event_type = event_type;
|
||||
@@ -1925,7 +1933,7 @@ wmTimer *WM_event_timer_add_notifier(wmWindowManager *wm,
|
||||
uint type,
|
||||
double timestep)
|
||||
{
|
||||
wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer");
|
||||
wmTimer *wt = static_cast<wmTimer *>(MEM_callocN(sizeof(wmTimer), "window timer"));
|
||||
BLI_assert(timestep >= 0.0f);
|
||||
|
||||
wt->event_type = TIMERNOTIFIER;
|
||||
@@ -1957,9 +1965,9 @@ void wm_window_timers_delete_removed(wmWindowManager *wm)
|
||||
|
||||
void WM_event_timer_free_data(wmTimer *timer)
|
||||
{
|
||||
if (timer->customdata != NULL && (timer->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) {
|
||||
if (timer->customdata != nullptr && (timer->flags & WM_TIMER_NO_FREE_CUSTOM_DATA) == 0) {
|
||||
MEM_freeN(timer->customdata);
|
||||
timer->customdata = NULL;
|
||||
timer->customdata = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1968,13 +1976,13 @@ void WM_event_timers_free_all(wmWindowManager *wm)
|
||||
BLI_assert_msg(BLI_listbase_is_empty(&wm->windows),
|
||||
"This should only be called when freeing the window-manager");
|
||||
wmTimer *timer;
|
||||
while ((timer = BLI_pophead(&wm->timers))) {
|
||||
while ((timer = static_cast<wmTimer *>(BLI_pophead(&wm->timers)))) {
|
||||
WM_event_timer_free_data(timer);
|
||||
MEM_freeN(timer);
|
||||
}
|
||||
}
|
||||
|
||||
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
|
||||
void WM_event_timer_remove(wmWindowManager *wm, wmWindow * /*win*/, wmTimer *timer)
|
||||
{
|
||||
/* Extra security check. */
|
||||
if (BLI_findindex(&wm->timers, timer) == -1) {
|
||||
@@ -1985,14 +1993,14 @@ void WM_event_timer_remove(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
|
||||
|
||||
/* Clear existing references to the timer. */
|
||||
if (wm->reports.reporttimer == timer) {
|
||||
wm->reports.reporttimer = NULL;
|
||||
wm->reports.reporttimer = nullptr;
|
||||
}
|
||||
/* There might be events in queue with this timer as customdata. */
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
LISTBASE_FOREACH (wmEvent *, event, &win->event_queue) {
|
||||
if (event->customdata == timer) {
|
||||
event->customdata = NULL;
|
||||
event->type = EVENT_NONE; /* Timer users customdata, don't want `NULL == NULL`. */
|
||||
event->customdata = nullptr;
|
||||
event->type = EVENT_NONE; /* Timer users customdata, don't want `nullptr == nullptr`. */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2004,7 +2012,7 @@ void WM_event_timer_remove(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
|
||||
|
||||
void WM_event_timer_remove_notifier(wmWindowManager *wm, wmWindow *win, wmTimer *timer)
|
||||
{
|
||||
timer->customdata = NULL;
|
||||
timer->customdata = nullptr;
|
||||
WM_event_timer_remove(wm, win, timer);
|
||||
}
|
||||
|
||||
@@ -2021,13 +2029,13 @@ static char *wm_clipboard_text_get_ex(bool selection,
|
||||
{
|
||||
if (G.background) {
|
||||
*r_len = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char *buf = GHOST_getClipboard(selection);
|
||||
if (!buf) {
|
||||
*r_len = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int buf_len = strlen(buf);
|
||||
@@ -2041,7 +2049,7 @@ static char *wm_clipboard_text_get_ex(bool selection,
|
||||
}
|
||||
|
||||
/* always convert from \r\n to \n */
|
||||
char *newbuf = MEM_mallocN(buf_len + 1, __func__);
|
||||
char *newbuf = static_cast<char *>(MEM_mallocN(buf_len + 1, __func__));
|
||||
char *p2 = newbuf;
|
||||
|
||||
if (firstline) {
|
||||
@@ -2100,7 +2108,7 @@ void WM_clipboard_text_set(const char *buf, bool selection)
|
||||
}
|
||||
}
|
||||
|
||||
newbuf = MEM_callocN(newlen + 1, "WM_clipboard_text_set");
|
||||
newbuf = static_cast<char *>(MEM_callocN(newlen + 1, "WM_clipboard_text_set"));
|
||||
|
||||
for (p = buf, p2 = newbuf; *p; p++, p2++) {
|
||||
if (*p == '\n') {
|
||||
@@ -2132,17 +2140,17 @@ bool WM_clipboard_image_available(void)
|
||||
ImBuf *WM_clipboard_image_get(void)
|
||||
{
|
||||
if (G.background) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
|
||||
uint8_t *rgba = (uint8_t *)GHOST_getClipboardImage(&width, &height);
|
||||
if (!rgba) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ImBuf *ibuf = IMB_allocFromBuffer(rgba, NULL, width, height, 4);
|
||||
ImBuf *ibuf = IMB_allocFromBuffer(rgba, nullptr, width, height, 4);
|
||||
free(rgba);
|
||||
|
||||
return ibuf;
|
||||
@@ -2155,7 +2163,7 @@ bool WM_clipboard_image_set(ImBuf *ibuf)
|
||||
}
|
||||
|
||||
bool free_byte_buffer = false;
|
||||
if (ibuf->byte_buffer.data == NULL) {
|
||||
if (ibuf->byte_buffer.data == nullptr) {
|
||||
/* Add a byte buffer if it does not have one. */
|
||||
IMB_rect_from_float(ibuf);
|
||||
free_byte_buffer = true;
|
||||
@@ -2181,14 +2189,14 @@ void WM_progress_set(wmWindow *win, float progress)
|
||||
{
|
||||
/* In background mode we may have windows, but not actual GHOST windows. */
|
||||
if (win->ghostwin) {
|
||||
GHOST_SetProgressBar(win->ghostwin, progress);
|
||||
GHOST_SetProgressBar(static_cast<GHOST_WindowHandle>(win->ghostwin), progress);
|
||||
}
|
||||
}
|
||||
|
||||
void WM_progress_clear(wmWindow *win)
|
||||
{
|
||||
if (win->ghostwin) {
|
||||
GHOST_EndProgressBar(win->ghostwin);
|
||||
GHOST_EndProgressBar(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2206,7 +2214,7 @@ void wm_window_get_position(wmWindow *win, int *r_pos_x, int *r_pos_y)
|
||||
|
||||
void wm_window_set_size(wmWindow *win, int width, int height)
|
||||
{
|
||||
GHOST_SetClientSize(win->ghostwin, width, height);
|
||||
GHOST_SetClientSize(static_cast<GHOST_WindowHandle>(win->ghostwin), width, height);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -2217,16 +2225,18 @@ void wm_window_set_size(wmWindow *win, int width, int height)
|
||||
|
||||
void wm_window_lower(wmWindow *win)
|
||||
{
|
||||
GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderBottom);
|
||||
GHOST_SetWindowOrder(static_cast<GHOST_WindowHandle>(win->ghostwin), GHOST_kWindowOrderBottom);
|
||||
}
|
||||
|
||||
void wm_window_raise(wmWindow *win)
|
||||
{
|
||||
/* Restore window if minimized */
|
||||
if (GHOST_GetWindowState(win->ghostwin) == GHOST_kWindowStateMinimized) {
|
||||
GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateNormal);
|
||||
if (GHOST_GetWindowState(static_cast<GHOST_WindowHandle>(win->ghostwin)) ==
|
||||
GHOST_kWindowStateMinimized)
|
||||
{
|
||||
GHOST_SetWindowState(static_cast<GHOST_WindowHandle>(win->ghostwin), GHOST_kWindowStateNormal);
|
||||
}
|
||||
GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderTop);
|
||||
GHOST_SetWindowOrder(static_cast<GHOST_WindowHandle>(win->ghostwin), GHOST_kWindowOrderTop);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -2237,17 +2247,17 @@ void wm_window_raise(wmWindow *win)
|
||||
|
||||
void wm_window_swap_buffers(wmWindow *win)
|
||||
{
|
||||
GHOST_SwapWindowBuffers(win->ghostwin);
|
||||
GHOST_SwapWindowBuffers(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
}
|
||||
|
||||
void wm_window_set_swap_interval(wmWindow *win, int interval)
|
||||
{
|
||||
GHOST_SetSwapInterval(win->ghostwin, interval);
|
||||
GHOST_SetSwapInterval(static_cast<GHOST_WindowHandle>(win->ghostwin), interval);
|
||||
}
|
||||
|
||||
bool wm_window_get_swap_interval(wmWindow *win, int *intervalOut)
|
||||
{
|
||||
return GHOST_GetSwapInterval(win->ghostwin, intervalOut);
|
||||
return GHOST_GetSwapInterval(static_cast<GHOST_WindowHandle>(win->ghostwin), intervalOut);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -2265,10 +2275,10 @@ wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mv
|
||||
GHOST_WindowHandle ghostwin = GHOST_GetWindowUnderCursor(g_system, tmp[0], tmp[1]);
|
||||
|
||||
if (!ghostwin) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wmWindow *win_other = GHOST_GetWindowUserData(ghostwin);
|
||||
wmWindow *win_other = static_cast<wmWindow *>(GHOST_GetWindowUserData(ghostwin));
|
||||
wm_cursor_position_from_ghost_screen_coords(win_other, &tmp[0], &tmp[1]);
|
||||
copy_v2_v2_int(r_mval, tmp);
|
||||
return win_other;
|
||||
@@ -2282,7 +2292,7 @@ wmWindow *WM_window_find_by_area(wmWindowManager *wm, const ScrArea *area)
|
||||
return win;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -2367,7 +2377,7 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
|
||||
int oldx = x, oldy = y;
|
||||
|
||||
wm_cursor_position_to_ghost_client_coords(win, &x, &y);
|
||||
GHOST_SetCursorPosition(g_system, win->ghostwin, x, y);
|
||||
GHOST_SetCursorPosition(g_system, static_cast<GHOST_WindowHandle>(win->ghostwin), x, y);
|
||||
|
||||
win->eventstate->prev_xy[0] = oldx;
|
||||
win->eventstate->prev_xy[1] = oldy;
|
||||
@@ -2384,13 +2394,13 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
|
||||
|
||||
int WM_window_pixels_x(const wmWindow *win)
|
||||
{
|
||||
float f = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
float f = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
return (int)(f * (float)win->sizex);
|
||||
}
|
||||
int WM_window_pixels_y(const wmWindow *win)
|
||||
{
|
||||
float f = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
float f = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
|
||||
return (int)(f * (float)win->sizey);
|
||||
}
|
||||
@@ -2465,7 +2475,7 @@ Scene *WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ViewLayer *WM_windows_view_layer_get_from_screen(const wmWindowManager *wm, const bScreen *screen)
|
||||
@@ -2476,7 +2486,7 @@ ViewLayer *WM_windows_view_layer_get_from_screen(const wmWindowManager *wm, cons
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const bScreen *screen)
|
||||
@@ -2486,7 +2496,7 @@ WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const
|
||||
return WM_window_get_active_workspace(win);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Scene *WM_window_get_active_scene(const wmWindow *win)
|
||||
@@ -2519,15 +2529,15 @@ void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *
|
||||
ED_scene_change_update(bmain, scene, view_layer);
|
||||
|
||||
/* Complete redraw. */
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_WINDOW, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
|
||||
{
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
if (scene == NULL) {
|
||||
return NULL;
|
||||
if (scene == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ViewLayer *view_layer = BKE_view_layer_find(scene, win->view_layer_name);
|
||||
@@ -2545,10 +2555,10 @@ ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
|
||||
|
||||
void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
|
||||
{
|
||||
BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != NULL);
|
||||
BLI_assert(BKE_view_layer_find(WM_window_get_active_scene(win), view_layer->name) != nullptr);
|
||||
Main *bmain = G_MAIN;
|
||||
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
wmWindow *win_parent = (win->parent) ? win->parent : win;
|
||||
|
||||
/* Set view layer in parent and child windows. */
|
||||
@@ -2566,7 +2576,7 @@ void WM_window_ensure_active_view_layer(wmWindow *win)
|
||||
/* Update layer name is correct after scene changes, load without UI, etc. */
|
||||
Scene *scene = WM_window_get_active_scene(win);
|
||||
|
||||
if (scene && BKE_view_layer_find(scene, win->view_layer_name) == NULL) {
|
||||
if (scene && BKE_view_layer_find(scene, win->view_layer_name) == nullptr) {
|
||||
ViewLayer *view_layer = BKE_view_layer_default_view(scene);
|
||||
STRNCPY(win->view_layer_name, view_layer->name);
|
||||
}
|
||||
@@ -2599,7 +2609,8 @@ void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *works
|
||||
WorkSpaceLayout *WM_window_get_active_layout(const wmWindow *win)
|
||||
{
|
||||
const WorkSpace *workspace = WM_window_get_active_workspace(win);
|
||||
return (LIKELY(workspace != NULL) ? BKE_workspace_active_layout_get(win->workspace_hook) : NULL);
|
||||
return (LIKELY(workspace != nullptr) ? BKE_workspace_active_layout_get(win->workspace_hook) :
|
||||
nullptr);
|
||||
}
|
||||
void WM_window_set_active_layout(wmWindow *win, WorkSpace *workspace, WorkSpaceLayout *layout)
|
||||
{
|
||||
@@ -2609,8 +2620,9 @@ void WM_window_set_active_layout(wmWindow *win, WorkSpace *workspace, WorkSpaceL
|
||||
bScreen *WM_window_get_active_screen(const wmWindow *win)
|
||||
{
|
||||
const WorkSpace *workspace = WM_window_get_active_workspace(win);
|
||||
/* May be NULL in rare cases like closing Blender */
|
||||
return (LIKELY(workspace != NULL) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL);
|
||||
/* May be nullptr in rare cases like closing Blender */
|
||||
return (LIKELY(workspace != nullptr) ? BKE_workspace_active_screen_get(win->workspace_hook) :
|
||||
nullptr);
|
||||
}
|
||||
void WM_window_set_active_screen(wmWindow *win, WorkSpace *workspace, bScreen *screen)
|
||||
{
|
||||
@@ -2638,18 +2650,19 @@ void wm_window_IME_begin(wmWindow *win, int x, int y, int w, int h, bool complet
|
||||
BLI_assert(win);
|
||||
|
||||
/* Convert to native OS window coordinates. */
|
||||
float fac = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
float fac = GHOST_GetNativePixelSize(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
x /= fac;
|
||||
y /= fac;
|
||||
GHOST_BeginIME(win->ghostwin, x, win->sizey - y, w, h, complete);
|
||||
GHOST_BeginIME(
|
||||
static_cast<GHOST_WindowHandle>(win->ghostwin), x, win->sizey - y, w, h, complete);
|
||||
}
|
||||
|
||||
void wm_window_IME_end(wmWindow *win)
|
||||
{
|
||||
BLI_assert(win && win->ime_data);
|
||||
|
||||
GHOST_EndIME(win->ghostwin);
|
||||
win->ime_data = NULL;
|
||||
GHOST_EndIME(static_cast<GHOST_WindowHandle>(win->ghostwin));
|
||||
win->ime_data = nullptr;
|
||||
}
|
||||
#endif /* WITH_INPUT_IME */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/** \name Public API
|
||||
* \{ */
|
||||
|
||||
static wmMsgTypeInfo wm_msg_types[WM_MSG_TYPE_NUM] = {{{NULL}}};
|
||||
static wmMsgTypeInfo wm_msg_types[WM_MSG_TYPE_NUM] = {{{nullptr}}};
|
||||
|
||||
typedef void (*wmMsgTypeInitFn)(wmMsgTypeInfo *);
|
||||
|
||||
@@ -44,7 +44,7 @@ void WM_msgbus_types_init(void)
|
||||
|
||||
struct wmMsgBus *WM_msgbus_create(void)
|
||||
{
|
||||
struct wmMsgBus *mbus = MEM_callocN(sizeof(*mbus), __func__);
|
||||
struct wmMsgBus *mbus = static_cast<wmMsgBus *>(MEM_callocN(sizeof(*mbus), __func__));
|
||||
const uint gset_reserve = 512;
|
||||
for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
|
||||
wmMsgTypeInfo *info = &wm_msg_types[i];
|
||||
@@ -66,11 +66,16 @@ void WM_msgbus_destroy(struct wmMsgBus *mbus)
|
||||
void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner)
|
||||
{
|
||||
wmMsgSubscribeKey *msg_key, *msg_key_next;
|
||||
for (msg_key = mbus->messages.first; msg_key; msg_key = msg_key_next) {
|
||||
for (msg_key = static_cast<wmMsgSubscribeKey *>(mbus->messages.first); msg_key;
|
||||
msg_key = msg_key_next)
|
||||
{
|
||||
msg_key_next = msg_key->next;
|
||||
|
||||
wmMsgSubscribeValueLink *msg_lnk_next;
|
||||
for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk; msg_lnk = msg_lnk_next)
|
||||
for (wmMsgSubscribeValueLink *msg_lnk =
|
||||
static_cast<wmMsgSubscribeValueLink *>(msg_key->values.first);
|
||||
msg_lnk;
|
||||
msg_lnk = msg_lnk_next)
|
||||
{
|
||||
msg_lnk_next = msg_lnk->next;
|
||||
if (msg_lnk->params.owner == owner) {
|
||||
@@ -143,16 +148,16 @@ wmMsgSubscribeKey *WM_msg_subscribe_with_key(struct wmMsgBus *mbus,
|
||||
const wmMsgTypeInfo *info = &wm_msg_types[type];
|
||||
wmMsgSubscribeKey *key;
|
||||
|
||||
BLI_assert(wm_msg_subscribe_value_msg_cast(msg_key_test)->id != NULL);
|
||||
BLI_assert(wm_msg_subscribe_value_msg_cast(msg_key_test)->id != nullptr);
|
||||
|
||||
void **r_key;
|
||||
if (!BLI_gset_ensure_p_ex(mbus->messages_gset[type], msg_key_test, &r_key)) {
|
||||
key = *r_key = MEM_mallocN(info->msg_key_size, __func__);
|
||||
key = static_cast<wmMsgSubscribeKey *>(*r_key = MEM_mallocN(info->msg_key_size, __func__));
|
||||
memcpy(key, msg_key_test, info->msg_key_size);
|
||||
BLI_addtail(&mbus->messages, key);
|
||||
}
|
||||
else {
|
||||
key = *r_key;
|
||||
key = static_cast<wmMsgSubscribeKey *>(*r_key);
|
||||
LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) {
|
||||
if ((msg_lnk->params.notify == msg_val_params->notify) &&
|
||||
(msg_lnk->params.owner == msg_val_params->owner) &&
|
||||
@@ -163,7 +168,8 @@ wmMsgSubscribeKey *WM_msg_subscribe_with_key(struct wmMsgBus *mbus,
|
||||
}
|
||||
}
|
||||
|
||||
wmMsgSubscribeValueLink *msg_lnk = MEM_mallocN(sizeof(wmMsgSubscribeValueLink), __func__);
|
||||
wmMsgSubscribeValueLink *msg_lnk = static_cast<wmMsgSubscribeValueLink *>(
|
||||
MEM_mallocN(sizeof(wmMsgSubscribeValueLink), __func__));
|
||||
msg_lnk->params = *msg_val_params;
|
||||
BLI_addtail(&key->values, msg_lnk);
|
||||
return key;
|
||||
@@ -179,7 +185,7 @@ void WM_msg_publish_with_key(struct wmMsgBus *mbus, wmMsgSubscribeKey *msg_key)
|
||||
|
||||
LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &msg_key->values) {
|
||||
if (false) { /* make an option? */
|
||||
msg_lnk->params.notify(NULL, msg_key, &msg_lnk->params);
|
||||
msg_lnk->params.notify(nullptr, msg_key, &msg_lnk->params);
|
||||
}
|
||||
else {
|
||||
if (msg_lnk->params.tag == false) {
|
||||
@@ -194,7 +200,7 @@ void WM_msg_id_update(struct wmMsgBus *mbus, ID *id_src, ID *id_dst)
|
||||
{
|
||||
for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
|
||||
wmMsgTypeInfo *info = &wm_msg_types[i];
|
||||
if (info->update_by_id != NULL) {
|
||||
if (info->update_by_id != nullptr) {
|
||||
info->update_by_id(mbus, id_src, id_dst);
|
||||
}
|
||||
}
|
||||
@@ -204,7 +210,7 @@ void WM_msg_id_remove(struct wmMsgBus *mbus, const ID *id)
|
||||
{
|
||||
for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
|
||||
wmMsgTypeInfo *info = &wm_msg_types[i];
|
||||
if (info->remove_by_id != NULL) {
|
||||
if (info->remove_by_id != nullptr) {
|
||||
info->remove_by_id(mbus, id);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
#include "../wm_message_bus.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wmMsgBus {
|
||||
struct GSet *messages_gset[WM_MSG_TYPE_NUM];
|
||||
/** Messages in order of being added. */
|
||||
@@ -37,3 +41,7 @@ BLI_INLINE wmMsg *wm_msg_subscribe_value_msg_cast_mut(wmMsgSubscribeKey *key)
|
||||
{
|
||||
return &((wmMsgSubscribeKey_Generic *)key)->msg;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -36,7 +36,7 @@ BLI_INLINE uint void_hash_uint(const void *key)
|
||||
|
||||
static uint wm_msg_rna_gset_hash(const void *key_p)
|
||||
{
|
||||
const wmMsgSubscribeKey_RNA *key = key_p;
|
||||
const wmMsgSubscribeKey_RNA *key = static_cast<const wmMsgSubscribeKey_RNA *>(key_p);
|
||||
const wmMsgParams_RNA *params = &key->msg.params;
|
||||
// printf("%s\n", RNA_struct_identifier(params->ptr.type));
|
||||
uint k = void_hash_uint(params->ptr.type);
|
||||
@@ -55,14 +55,17 @@ static bool wm_msg_rna_gset_cmp(const void *key_a_p, const void *key_b_p)
|
||||
}
|
||||
static void wm_msg_rna_gset_key_free(void *key_p)
|
||||
{
|
||||
wmMsgSubscribeKey_RNA *key = key_p;
|
||||
wmMsgSubscribeKey_RNA *key = static_cast<wmMsgSubscribeKey_RNA *>(key_p);
|
||||
wmMsgSubscribeValueLink *msg_lnk_next;
|
||||
for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first; msg_lnk; msg_lnk = msg_lnk_next)
|
||||
for (wmMsgSubscribeValueLink *msg_lnk =
|
||||
static_cast<wmMsgSubscribeValueLink *>(key->head.values.first);
|
||||
msg_lnk;
|
||||
msg_lnk = msg_lnk_next)
|
||||
{
|
||||
msg_lnk_next = msg_lnk->next;
|
||||
wm_msg_subscribe_value_free(&key->head, msg_lnk);
|
||||
}
|
||||
if (key->msg.params.data_path != NULL) {
|
||||
if (key->msg.params.data_path != nullptr) {
|
||||
MEM_freeN(key->msg.params.data_path);
|
||||
}
|
||||
MEM_freeN(key);
|
||||
@@ -89,16 +92,20 @@ static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_ds
|
||||
GSetIterator gs_iter;
|
||||
BLI_gsetIterator_init(&gs_iter, gs);
|
||||
while (BLI_gsetIterator_done(&gs_iter) == false) {
|
||||
wmMsgSubscribeKey_RNA *key = BLI_gsetIterator_getKey(&gs_iter);
|
||||
wmMsgSubscribeKey_RNA *key = static_cast<wmMsgSubscribeKey_RNA *>(
|
||||
BLI_gsetIterator_getKey(&gs_iter));
|
||||
BLI_gsetIterator_step(&gs_iter);
|
||||
if (key->msg.params.ptr.owner_id == id_src) {
|
||||
|
||||
/* GSet always needs updating since the key changes. */
|
||||
BLI_gset_remove(gs, key, NULL);
|
||||
BLI_gset_remove(gs, key, nullptr);
|
||||
|
||||
/* Remove any non-persistent values, so a single persistent
|
||||
* value doesn't modify behavior for the rest. */
|
||||
for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk;
|
||||
for (wmMsgSubscribeValueLink *
|
||||
msg_lnk = static_cast<wmMsgSubscribeValueLink *>(key->head.values.first),
|
||||
*msg_lnk_next;
|
||||
msg_lnk;
|
||||
msg_lnk = msg_lnk_next)
|
||||
{
|
||||
msg_lnk_next = msg_lnk->next;
|
||||
@@ -126,9 +133,9 @@ static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_ds
|
||||
PointerRNA idptr;
|
||||
RNA_id_pointer_create(id_dst, &idptr);
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop = NULL;
|
||||
PropertyRNA *prop = nullptr;
|
||||
if (RNA_path_resolve(&idptr, key->msg.params.data_path, &ptr, &prop) &&
|
||||
(prop == NULL) == (key->msg.params.prop == NULL))
|
||||
(prop == nullptr) == (key->msg.params.prop == nullptr))
|
||||
{
|
||||
key->msg.params.ptr = ptr;
|
||||
key->msg.params.prop = prop;
|
||||
@@ -137,7 +144,10 @@ static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_ds
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk;
|
||||
for (wmMsgSubscribeValueLink *
|
||||
msg_lnk = static_cast<wmMsgSubscribeValueLink *>(key->head.values.first),
|
||||
*msg_lnk_next;
|
||||
msg_lnk;
|
||||
msg_lnk = msg_lnk_next)
|
||||
{
|
||||
msg_lnk_next = msg_lnk->next;
|
||||
@@ -169,11 +179,15 @@ static void wm_msg_rna_remove_by_id(struct wmMsgBus *mbus, const ID *id)
|
||||
GSetIterator gs_iter;
|
||||
BLI_gsetIterator_init(&gs_iter, gs);
|
||||
while (BLI_gsetIterator_done(&gs_iter) == false) {
|
||||
wmMsgSubscribeKey_RNA *key = BLI_gsetIterator_getKey(&gs_iter);
|
||||
wmMsgSubscribeKey_RNA *key = static_cast<wmMsgSubscribeKey_RNA *>(
|
||||
BLI_gsetIterator_getKey(&gs_iter));
|
||||
BLI_gsetIterator_step(&gs_iter);
|
||||
if (key->msg.params.ptr.owner_id == id) {
|
||||
/* Clear here so we can decrement 'messages_tag_count'. */
|
||||
for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk;
|
||||
for (wmMsgSubscribeValueLink *
|
||||
msg_lnk = static_cast<wmMsgSubscribeValueLink *>(key->head.values.first),
|
||||
*msg_lnk_next;
|
||||
msg_lnk;
|
||||
msg_lnk = msg_lnk_next)
|
||||
{
|
||||
msg_lnk_next = msg_lnk->next;
|
||||
@@ -184,7 +198,7 @@ static void wm_msg_rna_remove_by_id(struct wmMsgBus *mbus, const ID *id)
|
||||
}
|
||||
|
||||
BLI_remlink(&mbus->messages, key);
|
||||
BLI_gset_remove(gs, key, NULL);
|
||||
BLI_gset_remove(gs, key, nullptr);
|
||||
wm_msg_rna_gset_key_free(key);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +228,8 @@ wmMsgSubscribeKey_RNA *WM_msg_lookup_rna(struct wmMsgBus *mbus,
|
||||
{
|
||||
wmMsgSubscribeKey_RNA key_test;
|
||||
key_test.msg.params = *msg_key_params;
|
||||
return BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_RNA], &key_test);
|
||||
return static_cast<wmMsgSubscribeKey_RNA *>(
|
||||
BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_RNA], &key_test));
|
||||
}
|
||||
|
||||
void WM_msg_publish_rna_params(struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params)
|
||||
@@ -240,24 +255,24 @@ void WM_msg_publish_rna_params(struct wmMsgBus *mbus, const wmMsgParams_RNA *msg
|
||||
wmMsgParams_RNA msg_key_params_anon = *msg_key_params;
|
||||
|
||||
/* We might want to enable this later? */
|
||||
if (msg_key_params_anon.prop != NULL) {
|
||||
if (msg_key_params_anon.prop != nullptr) {
|
||||
/* All properties for this type. */
|
||||
msg_key_params_anon.prop = NULL;
|
||||
msg_key_params_anon.prop = nullptr;
|
||||
if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
|
||||
WM_msg_publish_with_key(mbus, &key->head);
|
||||
}
|
||||
msg_key_params_anon.prop = msg_key_params->prop;
|
||||
}
|
||||
|
||||
msg_key_params_anon.ptr.owner_id = NULL;
|
||||
msg_key_params_anon.ptr.data = NULL;
|
||||
msg_key_params_anon.ptr.owner_id = nullptr;
|
||||
msg_key_params_anon.ptr.data = nullptr;
|
||||
if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
|
||||
WM_msg_publish_with_key(mbus, &key->head);
|
||||
}
|
||||
|
||||
/* Support subscribers to a type. */
|
||||
if (msg_key_params->prop) {
|
||||
msg_key_params_anon.prop = NULL;
|
||||
msg_key_params_anon.prop = nullptr;
|
||||
if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
|
||||
WM_msg_publish_with_key(mbus, &key->head);
|
||||
}
|
||||
@@ -267,11 +282,10 @@ void WM_msg_publish_rna_params(struct wmMsgBus *mbus, const wmMsgParams_RNA *msg
|
||||
|
||||
void WM_msg_publish_rna(struct wmMsgBus *mbus, PointerRNA *ptr, PropertyRNA *prop)
|
||||
{
|
||||
WM_msg_publish_rna_params(mbus,
|
||||
&(wmMsgParams_RNA){
|
||||
.ptr = *ptr,
|
||||
.prop = prop,
|
||||
});
|
||||
wmMsgParams_RNA params{};
|
||||
params.ptr = *ptr;
|
||||
params.prop = prop;
|
||||
WM_msg_publish_rna_params(mbus, ¶ms);
|
||||
}
|
||||
|
||||
void WM_msg_subscribe_rna_params(struct wmMsgBus *mbus,
|
||||
@@ -279,7 +293,7 @@ void WM_msg_subscribe_rna_params(struct wmMsgBus *mbus,
|
||||
const wmMsgSubscribeValue *msg_val_params,
|
||||
const char *id_repr)
|
||||
{
|
||||
wmMsgSubscribeKey_RNA msg_key_test = {{NULL}};
|
||||
wmMsgSubscribeKey_RNA msg_key_test = {{nullptr}};
|
||||
|
||||
/* use when added */
|
||||
msg_key_test.msg.head.id = id_repr;
|
||||
@@ -301,7 +315,7 @@ void WM_msg_subscribe_rna_params(struct wmMsgBus *mbus,
|
||||
mbus, &msg_key_test.head, msg_val_params);
|
||||
|
||||
if (msg_val_params->is_persistent) {
|
||||
if (msg_key->msg.params.data_path == NULL) {
|
||||
if (msg_key->msg.params.data_path == nullptr) {
|
||||
if (msg_key->msg.params.ptr.data != msg_key->msg.params.ptr.owner_id) {
|
||||
/* We assume prop type can't change. */
|
||||
msg_key->msg.params.data_path = RNA_path_from_ID_to_struct(&msg_key->msg.params.ptr);
|
||||
@@ -316,13 +330,10 @@ void WM_msg_subscribe_rna(struct wmMsgBus *mbus,
|
||||
const wmMsgSubscribeValue *msg_val_params,
|
||||
const char *id_repr)
|
||||
{
|
||||
WM_msg_subscribe_rna_params(mbus,
|
||||
&(const wmMsgParams_RNA){
|
||||
.ptr = *ptr,
|
||||
.prop = prop,
|
||||
},
|
||||
msg_val_params,
|
||||
id_repr);
|
||||
wmMsgParams_RNA params{};
|
||||
params.ptr = *ptr;
|
||||
params.prop = prop;
|
||||
WM_msg_subscribe_rna_params(mbus, ¶ms, msg_val_params, id_repr);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -338,14 +349,14 @@ void WM_msg_subscribe_ID(struct wmMsgBus *mbus,
|
||||
const wmMsgSubscribeValue *msg_val_params,
|
||||
const char *id_repr)
|
||||
{
|
||||
wmMsgParams_RNA msg_key_params = {{NULL}};
|
||||
wmMsgParams_RNA msg_key_params = {{nullptr}};
|
||||
RNA_id_pointer_create(id, &msg_key_params.ptr);
|
||||
WM_msg_subscribe_rna_params(mbus, &msg_key_params, msg_val_params, id_repr);
|
||||
}
|
||||
|
||||
void WM_msg_publish_ID(struct wmMsgBus *mbus, ID *id)
|
||||
{
|
||||
wmMsgParams_RNA msg_key_params = {{NULL}};
|
||||
wmMsgParams_RNA msg_key_params = {{nullptr}};
|
||||
RNA_id_pointer_create(id, &msg_key_params.ptr);
|
||||
WM_msg_publish_rna_params(mbus, &msg_key_params);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
static uint wm_msg_static_gset_hash(const void *key_p)
|
||||
{
|
||||
const wmMsgSubscribeKey_Static *key = key_p;
|
||||
const wmMsgSubscribeKey_Static *key = static_cast<const wmMsgSubscribeKey_Static *>(key_p);
|
||||
const wmMsgParams_Static *params = &key->msg.params;
|
||||
uint k = params->event;
|
||||
return k;
|
||||
@@ -37,9 +37,13 @@ static bool wm_msg_static_gset_cmp(const void *key_a_p, const void *key_b_p)
|
||||
}
|
||||
static void wm_msg_static_gset_key_free(void *key_p)
|
||||
{
|
||||
wmMsgSubscribeKey *key = key_p;
|
||||
wmMsgSubscribeKey *key = static_cast<wmMsgSubscribeKey *>(key_p);
|
||||
wmMsgSubscribeValueLink *msg_lnk_next;
|
||||
for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk_next) {
|
||||
for (wmMsgSubscribeValueLink *msg_lnk =
|
||||
static_cast<wmMsgSubscribeValueLink *>(key->values.first);
|
||||
msg_lnk;
|
||||
msg_lnk = msg_lnk_next)
|
||||
{
|
||||
msg_lnk_next = msg_lnk->next;
|
||||
BLI_remlink(&key->values, msg_lnk);
|
||||
MEM_freeN(msg_lnk);
|
||||
@@ -76,7 +80,8 @@ wmMsgSubscribeKey_Static *WM_msg_lookup_static(struct wmMsgBus *mbus,
|
||||
{
|
||||
wmMsgSubscribeKey_Static key_test;
|
||||
key_test.msg.params = *msg_key_params;
|
||||
return BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_STATIC], &key_test);
|
||||
return static_cast<wmMsgSubscribeKey_Static *>(
|
||||
BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_STATIC], &key_test));
|
||||
}
|
||||
|
||||
void WM_msg_publish_static_params(struct wmMsgBus *mbus, const wmMsgParams_Static *msg_key_params)
|
||||
@@ -91,10 +96,9 @@ void WM_msg_publish_static_params(struct wmMsgBus *mbus, const wmMsgParams_Stati
|
||||
|
||||
void WM_msg_publish_static(struct wmMsgBus *mbus, int event)
|
||||
{
|
||||
WM_msg_publish_static_params(mbus,
|
||||
&(wmMsgParams_Static){
|
||||
.event = event,
|
||||
});
|
||||
wmMsgParams_Static params{};
|
||||
params.event = event;
|
||||
WM_msg_publish_static_params(mbus, ¶ms);
|
||||
}
|
||||
|
||||
void WM_msg_subscribe_static_params(struct wmMsgBus *mbus,
|
||||
@@ -102,7 +106,7 @@ void WM_msg_subscribe_static_params(struct wmMsgBus *mbus,
|
||||
const wmMsgSubscribeValue *msg_val_params,
|
||||
const char *id_repr)
|
||||
{
|
||||
wmMsgSubscribeKey_Static msg_key_test = {{NULL}};
|
||||
wmMsgSubscribeKey_Static msg_key_test = {{nullptr}};
|
||||
|
||||
/* use when added */
|
||||
msg_key_test.msg.head.id = id_repr;
|
||||
@@ -118,10 +122,7 @@ void WM_msg_subscribe_static(struct wmMsgBus *mbus,
|
||||
const wmMsgSubscribeValue *msg_val_params,
|
||||
const char *id_repr)
|
||||
{
|
||||
WM_msg_subscribe_static_params(mbus,
|
||||
&(const wmMsgParams_Static){
|
||||
.event = event,
|
||||
},
|
||||
msg_val_params,
|
||||
id_repr);
|
||||
wmMsgParams_Static params{};
|
||||
params.event = event;
|
||||
WM_msg_subscribe_static_params(mbus, ¶ms, msg_val_params, id_repr);
|
||||
}
|
||||
@@ -33,21 +33,21 @@
|
||||
#include "wm_surface.h"
|
||||
#include "wm_xr_intern.h"
|
||||
|
||||
typedef struct {
|
||||
struct wmXrErrorHandlerData {
|
||||
wmWindowManager *wm;
|
||||
} wmXrErrorHandlerData;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
static void wm_xr_error_handler(const GHOST_XrError *error)
|
||||
{
|
||||
wmXrErrorHandlerData *handler_data = error->customdata;
|
||||
wmXrErrorHandlerData *handler_data = static_cast<wmXrErrorHandlerData *>(error->customdata);
|
||||
wmWindowManager *wm = handler_data->wm;
|
||||
wmWindow *root_win = wm->xr.runtime ? wm->xr.runtime->session_root_win : NULL;
|
||||
wmWindow *root_win = wm->xr.runtime ? wm->xr.runtime->session_root_win : nullptr;
|
||||
|
||||
BKE_reports_clear(&wm->reports);
|
||||
WM_report(RPT_ERROR, error->user_message);
|
||||
/* Rely on the fallback when `root_win` is NULL. */
|
||||
/* Rely on the fallback when `root_win` is nullptr. */
|
||||
WM_report_banner_show(wm, root_win);
|
||||
|
||||
if (wm->xr.runtime) {
|
||||
@@ -74,9 +74,9 @@ bool wm_xr_init(wmWindowManager *wm)
|
||||
GHOST_kXrGraphicsD3D11,
|
||||
#endif
|
||||
};
|
||||
GHOST_XrContextCreateInfo create_info = {
|
||||
.gpu_binding_candidates = gpu_bindings_candidates,
|
||||
.gpu_binding_candidates_count = ARRAY_SIZE(gpu_bindings_candidates),
|
||||
GHOST_XrContextCreateInfo create_info{
|
||||
/*gpu_binding_candidates*/ gpu_bindings_candidates,
|
||||
/*gpu_binding_candidates_count*/ ARRAY_SIZE(gpu_bindings_candidates),
|
||||
};
|
||||
GHOST_XrContextHandle context;
|
||||
|
||||
@@ -114,12 +114,12 @@ bool wm_xr_init(wmWindowManager *wm)
|
||||
|
||||
void wm_xr_exit(wmWindowManager *wm)
|
||||
{
|
||||
if (wm->xr.runtime != NULL) {
|
||||
if (wm->xr.runtime != nullptr) {
|
||||
wm_xr_runtime_data_free(&wm->xr.runtime);
|
||||
}
|
||||
if (wm->xr.session_settings.shading.prop) {
|
||||
IDP_FreeProperty(wm->xr.session_settings.shading.prop);
|
||||
wm->xr.session_settings.shading.prop = NULL;
|
||||
wm->xr.session_settings.shading.prop = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,8 @@ bool wm_xr_events_handle(wmWindowManager *wm)
|
||||
|
||||
wmXrRuntimeData *wm_xr_runtime_data_create(void)
|
||||
{
|
||||
wmXrRuntimeData *runtime = MEM_callocN(sizeof(*runtime), __func__);
|
||||
wmXrRuntimeData *runtime = static_cast<wmXrRuntimeData *>(
|
||||
MEM_callocN(sizeof(*runtime), __func__));
|
||||
return runtime;
|
||||
}
|
||||
|
||||
@@ -155,21 +156,21 @@ void wm_xr_runtime_data_free(wmXrRuntimeData **runtime)
|
||||
{
|
||||
/* Note that this function may be called twice, because of an indirect recursion: If a session is
|
||||
* running while WM-XR calls this function, calling GHOST_XrContextDestroy() will call this
|
||||
* again, because it's also set as the session exit callback. So NULL-check and NULL everything
|
||||
* that is freed here. */
|
||||
* again, because it's also set as the session exit callback. So nullptr-check and nullptr
|
||||
* everything that is freed here. */
|
||||
|
||||
/* We free all runtime XR data here, so if the context is still alive, destroy it. */
|
||||
if ((*runtime)->context != NULL) {
|
||||
if ((*runtime)->context != nullptr) {
|
||||
GHOST_XrContextHandle context = (*runtime)->context;
|
||||
/* Prevent recursive GHOST_XrContextDestroy() call by NULL'ing the context pointer before the
|
||||
* first call, see comment above. */
|
||||
(*runtime)->context = NULL;
|
||||
/* Prevent recursive GHOST_XrContextDestroy() call by nullptr'ing the context pointer before
|
||||
* the first call, see comment above. */
|
||||
(*runtime)->context = nullptr;
|
||||
|
||||
if ((*runtime)->area) {
|
||||
wmWindowManager *wm = G_MAIN->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
|
||||
wmWindow *win = wm_xr_session_root_window_or_fallback_get(wm, (*runtime));
|
||||
ED_area_offscreen_free(wm, win, (*runtime)->area);
|
||||
(*runtime)->area = NULL;
|
||||
(*runtime)->area = nullptr;
|
||||
}
|
||||
wm_xr_session_data_free(&(*runtime)->session_state);
|
||||
WM_xr_actionmaps_clear(*runtime);
|
||||
@@ -33,14 +33,15 @@
|
||||
|
||||
static wmXrActionSet *action_set_create(const char *action_set_name)
|
||||
{
|
||||
wmXrActionSet *action_set = MEM_callocN(sizeof(*action_set), __func__);
|
||||
wmXrActionSet *action_set = static_cast<wmXrActionSet *>(
|
||||
MEM_callocN(sizeof(*action_set), __func__));
|
||||
action_set->name = BLI_strdup(action_set_name);
|
||||
return action_set;
|
||||
}
|
||||
|
||||
static void action_set_destroy(void *val)
|
||||
{
|
||||
wmXrActionSet *action_set = val;
|
||||
wmXrActionSet *action_set = static_cast<wmXrActionSet *>(val);
|
||||
|
||||
MEM_SAFE_FREE(action_set->name);
|
||||
|
||||
@@ -52,7 +53,8 @@ static void action_set_destroy(void *val)
|
||||
|
||||
static wmXrActionSet *action_set_find(wmXrData *xr, const char *action_set_name)
|
||||
{
|
||||
return GHOST_XrGetActionSetCustomdata(xr->runtime->context, action_set_name);
|
||||
return static_cast<wmXrActionSet *>(
|
||||
GHOST_XrGetActionSetCustomdata(xr->runtime->context, action_set_name));
|
||||
}
|
||||
|
||||
static wmXrAction *action_create(const char *action_name,
|
||||
@@ -68,7 +70,7 @@ static wmXrAction *action_create(const char *action_name,
|
||||
eXrActionFlag action_flag,
|
||||
eXrHapticFlag haptic_flag)
|
||||
{
|
||||
wmXrAction *action = MEM_callocN(sizeof(*action), __func__);
|
||||
wmXrAction *action = static_cast<wmXrAction *>(MEM_callocN(sizeof(*action), __func__));
|
||||
action->name = BLI_strdup(action_name);
|
||||
action->type = type;
|
||||
|
||||
@@ -76,8 +78,8 @@ static wmXrAction *action_create(const char *action_name,
|
||||
uint subaction_idx = 0;
|
||||
action->count_subaction_paths = count;
|
||||
|
||||
action->subaction_paths = MEM_mallocN(sizeof(*action->subaction_paths) * count,
|
||||
"XrAction_SubactionPaths");
|
||||
action->subaction_paths = static_cast<char **>(
|
||||
MEM_mallocN(sizeof(*action->subaction_paths) * count, "XrAction_SubactionPaths"));
|
||||
LISTBASE_FOREACH_INDEX (XrUserPath *, user_path, user_paths, subaction_idx) {
|
||||
action->subaction_paths[subaction_idx] = BLI_strdup(user_path->path);
|
||||
}
|
||||
@@ -105,12 +107,12 @@ static wmXrAction *action_create(const char *action_name,
|
||||
const bool is_float_action = ELEM(type, XR_FLOAT_INPUT, XR_VECTOR2F_INPUT);
|
||||
const bool is_button_action = (is_float_action || type == XR_BOOLEAN_INPUT);
|
||||
if (is_float_action) {
|
||||
action->float_thresholds = MEM_calloc_arrayN(
|
||||
count, sizeof(*action->float_thresholds), "XrAction_FloatThresholds");
|
||||
action->float_thresholds = static_cast<float *>(
|
||||
MEM_calloc_arrayN(count, sizeof(*action->float_thresholds), "XrAction_FloatThresholds"));
|
||||
}
|
||||
if (is_button_action) {
|
||||
action->axis_flags = MEM_calloc_arrayN(
|
||||
count, sizeof(*action->axis_flags), "XrAction_AxisFlags");
|
||||
action->axis_flags = static_cast<eXrAxisFlag *>(
|
||||
MEM_calloc_arrayN(count, sizeof(*action->axis_flags), "XrAction_AxisFlags"));
|
||||
}
|
||||
|
||||
action->ot = ot;
|
||||
@@ -133,7 +135,7 @@ static wmXrAction *action_create(const char *action_name,
|
||||
|
||||
static void action_destroy(void *val)
|
||||
{
|
||||
wmXrAction *action = val;
|
||||
wmXrAction *action = static_cast<wmXrAction *>(val);
|
||||
|
||||
MEM_SAFE_FREE(action->name);
|
||||
|
||||
@@ -158,7 +160,8 @@ static void action_destroy(void *val)
|
||||
|
||||
static wmXrAction *action_find(wmXrData *xr, const char *action_set_name, const char *action_name)
|
||||
{
|
||||
return GHOST_XrGetActionCustomdata(xr->runtime->context, action_set_name, action_name);
|
||||
return static_cast<wmXrAction *>(
|
||||
GHOST_XrGetActionCustomdata(xr->runtime->context, action_set_name, action_name));
|
||||
}
|
||||
|
||||
bool WM_xr_action_set_create(wmXrData *xr, const char *action_set_name)
|
||||
@@ -169,11 +172,10 @@ bool WM_xr_action_set_create(wmXrData *xr, const char *action_set_name)
|
||||
|
||||
wmXrActionSet *action_set = action_set_create(action_set_name);
|
||||
|
||||
GHOST_XrActionSetInfo info = {
|
||||
.name = action_set_name,
|
||||
.customdata_free_fn = action_set_destroy,
|
||||
.customdata = action_set,
|
||||
};
|
||||
GHOST_XrActionSetInfo info{};
|
||||
info.name = action_set_name;
|
||||
info.customdata_free_fn = action_set_destroy;
|
||||
info.customdata = action_set;
|
||||
|
||||
if (!GHOST_XrCreateActionSet(xr->runtime->context, &info)) {
|
||||
return false;
|
||||
@@ -194,13 +196,13 @@ void WM_xr_action_set_destroy(wmXrData *xr, const char *action_set_name)
|
||||
if (action_set == session_state->active_action_set) {
|
||||
if (action_set->controller_grip_action || action_set->controller_aim_action) {
|
||||
wm_xr_session_controller_data_clear(session_state);
|
||||
action_set->controller_grip_action = action_set->controller_aim_action = NULL;
|
||||
action_set->controller_grip_action = action_set->controller_aim_action = nullptr;
|
||||
}
|
||||
|
||||
BLI_freelistN(&action_set->active_modal_actions);
|
||||
BLI_freelistN(&action_set->active_haptic_actions);
|
||||
|
||||
session_state->active_action_set = NULL;
|
||||
session_state->active_action_set = nullptr;
|
||||
}
|
||||
|
||||
GHOST_XrDestroyActionSet(xr->runtime->context, action_set_name);
|
||||
@@ -241,23 +243,22 @@ bool WM_xr_action_create(wmXrData *xr,
|
||||
const uint count = (uint)BLI_listbase_count(user_paths);
|
||||
uint subaction_idx = 0;
|
||||
|
||||
char **subaction_paths = MEM_calloc_arrayN(
|
||||
count, sizeof(*subaction_paths), "XrAction_SubactionPathPointers");
|
||||
char **subaction_paths = static_cast<char **>(
|
||||
MEM_calloc_arrayN(count, sizeof(*subaction_paths), "XrAction_SubactionPathPointers"));
|
||||
|
||||
LISTBASE_FOREACH_INDEX (XrUserPath *, user_path, user_paths, subaction_idx) {
|
||||
subaction_paths[subaction_idx] = (char *)user_path->path;
|
||||
}
|
||||
|
||||
GHOST_XrActionInfo info = {
|
||||
.name = action_name,
|
||||
.count_subaction_paths = count,
|
||||
.subaction_paths = (const char **)subaction_paths,
|
||||
.states = action->states,
|
||||
.float_thresholds = action->float_thresholds,
|
||||
.axis_flags = (int16_t *)action->axis_flags,
|
||||
.customdata_free_fn = action_destroy,
|
||||
.customdata = action,
|
||||
};
|
||||
GHOST_XrActionInfo info{};
|
||||
info.name = action_name;
|
||||
info.count_subaction_paths = count;
|
||||
info.subaction_paths = (const char **)subaction_paths;
|
||||
info.states = action->states;
|
||||
info.float_thresholds = action->float_thresholds;
|
||||
info.axis_flags = (int16_t *)action->axis_flags;
|
||||
info.customdata_free_fn = action_destroy;
|
||||
info.customdata = action;
|
||||
|
||||
switch (type) {
|
||||
case XR_BOOLEAN_INPUT:
|
||||
@@ -304,11 +305,11 @@ void WM_xr_action_destroy(wmXrData *xr, const char *action_set_name, const char
|
||||
if (action_set == xr->runtime->session_state.active_action_set) {
|
||||
wm_xr_session_controller_data_clear(&xr->runtime->session_state);
|
||||
}
|
||||
action_set->controller_grip_action = action_set->controller_aim_action = NULL;
|
||||
action_set->controller_grip_action = action_set->controller_aim_action = nullptr;
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (LinkData *, ld, &action_set->active_modal_actions) {
|
||||
wmXrAction *active_modal_action = ld->data;
|
||||
wmXrAction *active_modal_action = static_cast<wmXrAction *>(ld->data);
|
||||
if (STREQ(active_modal_action->name, action_name)) {
|
||||
BLI_freelinkN(&action_set->active_modal_actions, ld);
|
||||
break;
|
||||
@@ -337,16 +338,17 @@ bool WM_xr_action_binding_create(wmXrData *xr,
|
||||
const uint count = (uint)BLI_listbase_count(user_paths);
|
||||
BLI_assert(count == (uint)BLI_listbase_count(component_paths));
|
||||
|
||||
GHOST_XrActionBindingInfo *binding_infos = MEM_calloc_arrayN(
|
||||
count, sizeof(*binding_infos), "XrActionBinding_Infos");
|
||||
GHOST_XrActionBindingInfo *binding_infos = static_cast<GHOST_XrActionBindingInfo *>(
|
||||
MEM_calloc_arrayN(count, sizeof(*binding_infos), "XrActionBinding_Infos"));
|
||||
|
||||
char **subaction_paths = MEM_calloc_arrayN(
|
||||
count, sizeof(*subaction_paths), "XrActionBinding_SubactionPathPointers");
|
||||
char **subaction_paths = static_cast<char **>(
|
||||
MEM_calloc_arrayN(count, sizeof(*subaction_paths), "XrActionBinding_SubactionPathPointers"));
|
||||
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
GHOST_XrActionBindingInfo *binding_info = &binding_infos[i];
|
||||
const XrUserPath *user_path = BLI_findlink(user_paths, i);
|
||||
const XrComponentPath *component_path = BLI_findlink(component_paths, i);
|
||||
const XrUserPath *user_path = static_cast<const XrUserPath *>(BLI_findlink(user_paths, i));
|
||||
const XrComponentPath *component_path = static_cast<const XrComponentPath *>(
|
||||
BLI_findlink(component_paths, i));
|
||||
|
||||
subaction_paths[i] = (char *)user_path->path;
|
||||
|
||||
@@ -363,13 +365,12 @@ bool WM_xr_action_binding_create(wmXrData *xr,
|
||||
}
|
||||
}
|
||||
|
||||
GHOST_XrActionProfileInfo profile_info = {
|
||||
.action_name = action_name,
|
||||
.profile_path = profile_path,
|
||||
.count_subaction_paths = count,
|
||||
.subaction_paths = (const char **)subaction_paths,
|
||||
.bindings = binding_infos,
|
||||
};
|
||||
GHOST_XrActionProfileInfo profile_info{};
|
||||
profile_info.action_name = action_name;
|
||||
profile_info.profile_path = profile_path;
|
||||
profile_info.count_subaction_paths = count;
|
||||
profile_info.subaction_paths = (const char **)subaction_paths;
|
||||
profile_info.bindings = binding_infos;
|
||||
|
||||
const bool success = GHOST_XrCreateActionBindings(
|
||||
xr->runtime->context, action_set_name, 1, &profile_info);
|
||||
@@ -47,7 +47,8 @@ XrActionMapBinding *WM_xr_actionmap_binding_new(XrActionMapItem *ami,
|
||||
return amb_prev;
|
||||
}
|
||||
|
||||
XrActionMapBinding *amb = MEM_callocN(sizeof(XrActionMapBinding), __func__);
|
||||
XrActionMapBinding *amb = static_cast<XrActionMapBinding *>(
|
||||
MEM_callocN(sizeof(XrActionMapBinding), __func__));
|
||||
STRNCPY(amb->name, name);
|
||||
if (amb_prev) {
|
||||
WM_xr_actionmap_binding_ensure_unique(ami, amb);
|
||||
@@ -70,7 +71,7 @@ static XrActionMapBinding *wm_xr_actionmap_binding_find_except(XrActionMapItem *
|
||||
return amb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_xr_actionmap_binding_ensure_unique(XrActionMapItem *ami, XrActionMapBinding *amb)
|
||||
@@ -102,12 +103,12 @@ void WM_xr_actionmap_binding_ensure_unique(XrActionMapItem *ami, XrActionMapBind
|
||||
|
||||
static XrActionMapBinding *wm_xr_actionmap_binding_copy(XrActionMapBinding *amb_src)
|
||||
{
|
||||
XrActionMapBinding *amb_dst = MEM_dupallocN(amb_src);
|
||||
amb_dst->prev = amb_dst->next = NULL;
|
||||
XrActionMapBinding *amb_dst = static_cast<XrActionMapBinding *>(MEM_dupallocN(amb_src));
|
||||
amb_dst->prev = amb_dst->next = nullptr;
|
||||
|
||||
BLI_listbase_clear(&amb_dst->component_paths);
|
||||
LISTBASE_FOREACH (XrComponentPath *, path, &amb_src->component_paths) {
|
||||
XrComponentPath *path_new = MEM_dupallocN(path);
|
||||
XrComponentPath *path_new = static_cast<XrComponentPath *>(MEM_dupallocN(path));
|
||||
BLI_addtail(&amb_dst->component_paths, path_new);
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ XrActionMapBinding *WM_xr_actionmap_binding_find(XrActionMapItem *ami, const cha
|
||||
return amb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -180,11 +181,11 @@ static void wm_xr_actionmap_item_properties_free(XrActionMapItem *ami)
|
||||
if (ami->op_properties_ptr) {
|
||||
WM_operator_properties_free(ami->op_properties_ptr);
|
||||
MEM_freeN(ami->op_properties_ptr);
|
||||
ami->op_properties_ptr = NULL;
|
||||
ami->op_properties = NULL;
|
||||
ami->op_properties_ptr = nullptr;
|
||||
ami->op_properties = nullptr;
|
||||
}
|
||||
else {
|
||||
BLI_assert(ami->op_properties == NULL);
|
||||
BLI_assert(ami->op_properties == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ void WM_xr_actionmap_item_properties_update_ot(XrActionMapItem *ami)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ami->op_properties_ptr == NULL) {
|
||||
if (ami->op_properties_ptr == nullptr) {
|
||||
wm_xr_actionmap_item_properties_set(ami);
|
||||
}
|
||||
else {
|
||||
@@ -251,7 +252,8 @@ XrActionMapItem *WM_xr_actionmap_item_new(XrActionMap *actionmap,
|
||||
return ami_prev;
|
||||
}
|
||||
|
||||
XrActionMapItem *ami = MEM_callocN(sizeof(XrActionMapItem), __func__);
|
||||
XrActionMapItem *ami = static_cast<XrActionMapItem *>(
|
||||
MEM_callocN(sizeof(XrActionMapItem), __func__));
|
||||
STRNCPY(ami->name, name);
|
||||
if (ami_prev) {
|
||||
WM_xr_actionmap_item_ensure_unique(actionmap, ami);
|
||||
@@ -274,7 +276,7 @@ static XrActionMapItem *wm_xr_actionmap_item_find_except(XrActionMap *actionmap,
|
||||
return ami;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_xr_actionmap_item_ensure_unique(XrActionMap *actionmap, XrActionMapItem *ami)
|
||||
@@ -306,8 +308,8 @@ void WM_xr_actionmap_item_ensure_unique(XrActionMap *actionmap, XrActionMapItem
|
||||
|
||||
static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami_src)
|
||||
{
|
||||
XrActionMapItem *ami_dst = MEM_dupallocN(ami_src);
|
||||
ami_dst->prev = ami_dst->next = NULL;
|
||||
XrActionMapItem *ami_dst = static_cast<XrActionMapItem *>(MEM_dupallocN(ami_src));
|
||||
ami_dst->prev = ami_dst->next = nullptr;
|
||||
|
||||
BLI_listbase_clear(&ami_dst->bindings);
|
||||
LISTBASE_FOREACH (XrActionMapBinding *, amb, &ami_src->bindings) {
|
||||
@@ -316,19 +318,20 @@ static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami_src)
|
||||
}
|
||||
|
||||
if (ami_dst->op_properties) {
|
||||
ami_dst->op_properties_ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
|
||||
ami_dst->op_properties_ptr = static_cast<PointerRNA *>(
|
||||
MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr"));
|
||||
WM_operator_properties_create(ami_dst->op_properties_ptr, ami_dst->op);
|
||||
ami_dst->op_properties = IDP_CopyProperty(ami_src->op_properties);
|
||||
ami_dst->op_properties_ptr->data = ami_dst->op_properties;
|
||||
}
|
||||
else {
|
||||
ami_dst->op_properties = NULL;
|
||||
ami_dst->op_properties_ptr = NULL;
|
||||
ami_dst->op_properties = nullptr;
|
||||
ami_dst->op_properties_ptr = nullptr;
|
||||
}
|
||||
|
||||
BLI_listbase_clear(&ami_dst->user_paths);
|
||||
LISTBASE_FOREACH (XrUserPath *, path, &ami_src->user_paths) {
|
||||
XrUserPath *path_new = MEM_dupallocN(path);
|
||||
XrUserPath *path_new = static_cast<XrUserPath *>(MEM_dupallocN(path));
|
||||
BLI_addtail(&ami_dst->user_paths, path_new);
|
||||
}
|
||||
|
||||
@@ -373,7 +376,7 @@ XrActionMapItem *WM_xr_actionmap_item_find(XrActionMap *actionmap, const char *n
|
||||
return ami;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -392,7 +395,7 @@ XrActionMap *WM_xr_actionmap_new(wmXrRuntimeData *runtime, const char *name, boo
|
||||
return am_prev;
|
||||
}
|
||||
|
||||
XrActionMap *am = MEM_callocN(sizeof(XrActionMap), __func__);
|
||||
XrActionMap *am = static_cast<XrActionMap *>(MEM_callocN(sizeof(XrActionMap), __func__));
|
||||
STRNCPY(am->name, name);
|
||||
if (am_prev) {
|
||||
WM_xr_actionmap_ensure_unique(runtime, am);
|
||||
@@ -413,7 +416,7 @@ static XrActionMap *wm_xr_actionmap_find_except(wmXrRuntimeData *runtime,
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_xr_actionmap_ensure_unique(wmXrRuntimeData *runtime, XrActionMap *actionmap)
|
||||
@@ -445,8 +448,8 @@ void WM_xr_actionmap_ensure_unique(wmXrRuntimeData *runtime, XrActionMap *action
|
||||
|
||||
static XrActionMap *wm_xr_actionmap_copy(XrActionMap *am_src)
|
||||
{
|
||||
XrActionMap *am_dst = MEM_dupallocN(am_src);
|
||||
am_dst->prev = am_dst->next = NULL;
|
||||
XrActionMap *am_dst = static_cast<XrActionMap *>(MEM_dupallocN(am_src));
|
||||
am_dst->prev = am_dst->next = nullptr;
|
||||
|
||||
BLI_listbase_clear(&am_dst->items);
|
||||
LISTBASE_FOREACH (XrActionMapItem *, ami, &am_src->items) {
|
||||
@@ -500,7 +503,7 @@ XrActionMap *WM_xr_actionmap_find(wmXrRuntimeData *runtime, const char *name)
|
||||
return am;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WM_xr_actionmap_clear(XrActionMap *actionmap)
|
||||
@@ -112,11 +112,16 @@ static void wm_xr_draw_viewport_buffers_to_active_framebuffer(
|
||||
const wmXrSurfaceData *surface_data,
|
||||
const GHOST_XrDrawViewInfo *draw_view)
|
||||
{
|
||||
const wmXrViewportPair *vp = BLI_findlink(&surface_data->viewports, draw_view->view_idx);
|
||||
const wmXrViewportPair *vp = static_cast<const wmXrViewportPair *>(
|
||||
BLI_findlink(&surface_data->viewports, draw_view->view_idx));
|
||||
BLI_assert(vp && vp->viewport);
|
||||
|
||||
const bool is_upside_down = GHOST_XrSessionNeedsUpsideDownDrawing(runtime_data->context);
|
||||
rcti rect = {.xmin = 0, .ymin = 0, .xmax = draw_view->width - 1, .ymax = draw_view->height - 1};
|
||||
rcti rect{};
|
||||
rect.xmin = 0;
|
||||
rect.ymin = 0;
|
||||
rect.xmax = draw_view->width - 1;
|
||||
rect.ymax = draw_view->height - 1;
|
||||
|
||||
wmViewport(&rect);
|
||||
|
||||
@@ -129,7 +134,7 @@ static void wm_xr_draw_viewport_buffers_to_active_framebuffer(
|
||||
|
||||
void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
|
||||
{
|
||||
wmXrDrawData *draw_data = customdata;
|
||||
wmXrDrawData *draw_data = static_cast<wmXrDrawData *>(customdata);
|
||||
wmXrData *xr_data = draw_data->xr_data;
|
||||
wmXrSurfaceData *surface_data = draw_data->surface_data;
|
||||
wmXrSessionState *session_state = &xr_data->runtime->session_state;
|
||||
@@ -149,7 +154,8 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
|
||||
return;
|
||||
}
|
||||
|
||||
const wmXrViewportPair *vp = BLI_findlink(&surface_data->viewports, draw_view->view_idx);
|
||||
const wmXrViewportPair *vp = static_cast<const wmXrViewportPair *>(
|
||||
BLI_findlink(&surface_data->viewports, draw_view->view_idx));
|
||||
BLI_assert(vp && vp->offscreen && vp->viewport);
|
||||
|
||||
/* In case a framebuffer is still bound from drawing the last eye. */
|
||||
@@ -174,7 +180,7 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
NULL,
|
||||
nullptr,
|
||||
false,
|
||||
vp->offscreen,
|
||||
vp->viewport);
|
||||
@@ -200,7 +206,7 @@ static GPUBatch *wm_xr_controller_model_batch_create(GHOST_XrContextHandle xr_co
|
||||
if (!GHOST_XrGetControllerModelData(xr_context, subaction_path, &model_data) ||
|
||||
model_data.count_vertices < 1)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GPUVertFormat format = {0};
|
||||
@@ -213,7 +219,7 @@ static GPUBatch *wm_xr_controller_model_batch_create(GHOST_XrContextHandle xr_co
|
||||
memcpy(
|
||||
vbo_data, model_data.vertices, model_data.count_vertices * sizeof(model_data.vertices[0]));
|
||||
|
||||
GPUIndexBuf *ibo = NULL;
|
||||
GPUIndexBuf *ibo = nullptr;
|
||||
if (model_data.count_indices > 0 && ((model_data.count_indices % 3) == 0)) {
|
||||
GPUIndexBufBuilder ibo_builder;
|
||||
const uint prim_len = model_data.count_indices / 3;
|
||||
@@ -383,9 +389,9 @@ static void wm_xr_controller_aim_draw(const XrSessionSettings *settings, wmXrSes
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
void wm_xr_draw_controllers(const bContext *UNUSED(C), ARegion *UNUSED(region), void *customdata)
|
||||
void wm_xr_draw_controllers(const bContext * /*C*/, ARegion * /*region*/, void *customdata)
|
||||
{
|
||||
wmXrData *xr = customdata;
|
||||
wmXrData *xr = static_cast<wmXrData *>(customdata);
|
||||
const XrSessionSettings *settings = &xr->session_settings;
|
||||
GHOST_XrContextHandle xr_context = xr->runtime->context;
|
||||
wmXrSessionState *state = &xr->runtime->session_state;
|
||||
@@ -12,6 +12,10 @@
|
||||
|
||||
#include "wm_xr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wmXrActionSet;
|
||||
|
||||
typedef struct wmXrSessionState {
|
||||
@@ -236,3 +240,7 @@ void wm_xr_pose_scale_to_imat(const GHOST_XrPose *pose, float scale, float r_ima
|
||||
*/
|
||||
void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata);
|
||||
void wm_xr_draw_controllers(const struct bContext *C, struct ARegion *region, void *customdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -63,7 +63,7 @@ static bool wm_xr_operator_test_event(const wmOperator *op, const wmEvent *event
|
||||
BLI_assert(event->custom == EVT_DATA_XR);
|
||||
BLI_assert(event->customdata);
|
||||
|
||||
wmXrActionData *actiondata = event->customdata;
|
||||
wmXrActionData *actiondata = static_cast<wmXrActionData *>(event->customdata);
|
||||
return (actiondata->ot == op->type &&
|
||||
IDP_EqualsProperties(actiondata->op_properties, op->properties));
|
||||
}
|
||||
@@ -80,7 +80,9 @@ static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data)
|
||||
{
|
||||
const bool session_exists = WM_xr_session_exists(xr_data);
|
||||
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (bScreen *screen = static_cast<bScreen *>(bmain->screens.first); screen;
|
||||
screen = static_cast<bScreen *>(screen->id.next))
|
||||
{
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, slink, &area->spacedata) {
|
||||
if (slink->spacetype == SPACE_VIEW3D) {
|
||||
@@ -91,7 +93,7 @@ static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data)
|
||||
}
|
||||
|
||||
if (session_exists) {
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
const Scene *scene = WM_windows_scene_get_from_screen(wm, screen);
|
||||
|
||||
ED_view3d_xr_shading_update(wm, v3d, scene);
|
||||
@@ -105,7 +107,7 @@ static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data)
|
||||
}
|
||||
}
|
||||
|
||||
WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL);
|
||||
WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, nullptr);
|
||||
}
|
||||
|
||||
static void wm_xr_session_update_screen_on_exit_cb(const wmXrData *xr_data)
|
||||
@@ -114,7 +116,7 @@ static void wm_xr_session_update_screen_on_exit_cb(const wmXrData *xr_data)
|
||||
wm_xr_session_update_screen(G_MAIN, xr_data);
|
||||
}
|
||||
|
||||
static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
static int wm_xr_session_toggle_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
@@ -131,7 +133,7 @@ static int wm_xr_session_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
wm_xr_session_toggle(wm, win, wm_xr_session_update_screen_on_exit_cb);
|
||||
wm_xr_session_update_screen(bmain, &wm->xr);
|
||||
|
||||
WM_event_add_notifier(C, NC_WM | ND_XR_DATA_CHANGED, NULL);
|
||||
WM_event_add_notifier(C, NC_WM | ND_XR_DATA_CHANGED, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -160,16 +162,16 @@ static void WM_OT_xr_session_toggle(wmOperatorType *ot)
|
||||
/** \name XR Grab Utilities
|
||||
* \{ */
|
||||
|
||||
typedef struct XrGrabData {
|
||||
struct XrGrabData {
|
||||
float mat_prev[4][4];
|
||||
float mat_other_prev[4][4];
|
||||
bool bimanual_prev;
|
||||
bool loc_lock, locz_lock, rot_lock, rotz_lock, scale_lock;
|
||||
} XrGrabData;
|
||||
};
|
||||
|
||||
static void wm_xr_grab_init(wmOperator *op)
|
||||
{
|
||||
BLI_assert(op->customdata == NULL);
|
||||
BLI_assert(op->customdata == nullptr);
|
||||
|
||||
op->customdata = MEM_callocN(sizeof(XrGrabData), __func__);
|
||||
}
|
||||
@@ -181,7 +183,7 @@ static void wm_xr_grab_uninit(wmOperator *op)
|
||||
|
||||
static void wm_xr_grab_update(wmOperator *op, const wmXrActionData *actiondata)
|
||||
{
|
||||
XrGrabData *data = op->customdata;
|
||||
XrGrabData *data = static_cast<XrGrabData *>(op->customdata);
|
||||
|
||||
quat_to_mat4(data->mat_prev, actiondata->controller_rot);
|
||||
copy_v3_v3(data->mat_prev[3], actiondata->controller_loc);
|
||||
@@ -401,7 +403,7 @@ static int wm_xr_navigation_grab_invoke(bContext *C, wmOperator *op, const wmEve
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
const wmXrActionData *actiondata = event->customdata;
|
||||
const wmXrActionData *actiondata = static_cast<const wmXrActionData *>(event->customdata);
|
||||
|
||||
wm_xr_grab_init(op);
|
||||
wm_xr_grab_update(op, actiondata);
|
||||
@@ -411,7 +413,7 @@ static int wm_xr_navigation_grab_invoke(bContext *C, wmOperator *op, const wmEve
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
static int wm_xr_navigation_grab_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int wm_xr_navigation_grab_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -463,12 +465,20 @@ static void wm_xr_navigation_grab_apply(wmXrData *xr,
|
||||
}
|
||||
|
||||
if (bimanual) {
|
||||
wm_xr_grab_compute_bimanual(
|
||||
actiondata, data, need_navinv ? nav_mat : NULL, need_navinv ? nav_inv : NULL, true, delta);
|
||||
wm_xr_grab_compute_bimanual(actiondata,
|
||||
data,
|
||||
need_navinv ? nav_mat : nullptr,
|
||||
need_navinv ? nav_inv : nullptr,
|
||||
true,
|
||||
delta);
|
||||
}
|
||||
else {
|
||||
wm_xr_grab_compute(
|
||||
actiondata, data, need_navinv ? nav_mat : NULL, need_navinv ? nav_inv : NULL, true, delta);
|
||||
wm_xr_grab_compute(actiondata,
|
||||
data,
|
||||
need_navinv ? nav_mat : nullptr,
|
||||
need_navinv ? nav_inv : nullptr,
|
||||
true,
|
||||
delta);
|
||||
}
|
||||
|
||||
mul_m4_m4m4(out, delta, nav_mat);
|
||||
@@ -517,8 +527,8 @@ static int wm_xr_navigation_grab_modal(bContext *C, wmOperator *op, const wmEven
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
const wmXrActionData *actiondata = event->customdata;
|
||||
XrGrabData *data = op->customdata;
|
||||
const wmXrActionData *actiondata = static_cast<const wmXrActionData *>(event->customdata);
|
||||
XrGrabData *data = static_cast<XrGrabData *>(op->customdata);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmXrData *xr = &wm->xr;
|
||||
|
||||
@@ -595,20 +605,18 @@ static void WM_OT_xr_navigation_grab(wmOperatorType *ot)
|
||||
static const float g_xr_default_raycast_axis[3] = {0.0f, 0.0f, -1.0f};
|
||||
static const float g_xr_default_raycast_color[4] = {0.35f, 0.35f, 1.0f, 1.0f};
|
||||
|
||||
typedef struct XrRaycastData {
|
||||
struct XrRaycastData {
|
||||
bool from_viewer;
|
||||
float origin[3];
|
||||
float direction[3];
|
||||
float end[3];
|
||||
float color[4];
|
||||
void *draw_handle;
|
||||
} XrRaycastData;
|
||||
};
|
||||
|
||||
static void wm_xr_raycast_draw(const bContext *UNUSED(C),
|
||||
ARegion *UNUSED(region),
|
||||
void *customdata)
|
||||
static void wm_xr_raycast_draw(const bContext * /*C*/, ARegion * /*region*/, void *customdata)
|
||||
{
|
||||
const XrRaycastData *data = customdata;
|
||||
const XrRaycastData *data = static_cast<const XrRaycastData *>(customdata);
|
||||
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
@@ -649,7 +657,7 @@ static void wm_xr_raycast_draw(const bContext *UNUSED(C),
|
||||
|
||||
static void wm_xr_raycast_init(wmOperator *op)
|
||||
{
|
||||
BLI_assert(op->customdata == NULL);
|
||||
BLI_assert(op->customdata == nullptr);
|
||||
|
||||
op->customdata = MEM_callocN(sizeof(XrRaycastData), __func__);
|
||||
|
||||
@@ -663,7 +671,7 @@ static void wm_xr_raycast_init(wmOperator *op)
|
||||
return;
|
||||
}
|
||||
|
||||
XrRaycastData *data = op->customdata;
|
||||
XrRaycastData *data = static_cast<XrRaycastData *>(op->customdata);
|
||||
data->draw_handle = ED_region_draw_cb_activate(
|
||||
art, wm_xr_raycast_draw, op->customdata, REGION_DRAW_POST_VIEW);
|
||||
}
|
||||
@@ -678,7 +686,7 @@ static void wm_xr_raycast_uninit(wmOperator *op)
|
||||
if (st) {
|
||||
ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_XR);
|
||||
if (art) {
|
||||
XrRaycastData *data = op->customdata;
|
||||
XrRaycastData *data = static_cast<XrRaycastData *>(op->customdata);
|
||||
ED_region_draw_cb_exit(art, data->draw_handle);
|
||||
}
|
||||
}
|
||||
@@ -690,7 +698,7 @@ static void wm_xr_raycast_update(wmOperator *op,
|
||||
const wmXrData *xr,
|
||||
const wmXrActionData *actiondata)
|
||||
{
|
||||
XrRaycastData *data = op->customdata;
|
||||
XrRaycastData *data = static_cast<XrRaycastData *>(op->customdata);
|
||||
float ray_length, axis[3];
|
||||
|
||||
data->from_viewer = RNA_boolean_get(op->ptr, "from_viewer");
|
||||
@@ -729,21 +737,21 @@ static void wm_xr_raycast(Scene *scene,
|
||||
/* Uses same raycast method as Scene.ray_cast(). */
|
||||
SnapObjectContext *sctx = ED_transform_snap_object_context_create(scene, 0);
|
||||
|
||||
ED_transform_snap_object_project_ray_ex(
|
||||
sctx,
|
||||
depsgraph,
|
||||
NULL,
|
||||
&(const struct SnapObjectParams){.snap_target_select = (selectable_only ?
|
||||
SCE_SNAP_TARGET_ONLY_SELECTABLE :
|
||||
SCE_SNAP_TARGET_ALL)},
|
||||
origin,
|
||||
direction,
|
||||
ray_dist,
|
||||
r_location,
|
||||
r_normal,
|
||||
r_index,
|
||||
r_ob,
|
||||
r_obmat);
|
||||
SnapObjectParams params{};
|
||||
params.snap_target_select = (selectable_only ? SCE_SNAP_TARGET_ONLY_SELECTABLE :
|
||||
SCE_SNAP_TARGET_ALL);
|
||||
ED_transform_snap_object_project_ray_ex(sctx,
|
||||
depsgraph,
|
||||
nullptr,
|
||||
¶ms,
|
||||
origin,
|
||||
direction,
|
||||
ray_dist,
|
||||
r_location,
|
||||
r_normal,
|
||||
r_index,
|
||||
r_ob,
|
||||
r_obmat);
|
||||
|
||||
ED_transform_snap_object_context_destroy(sctx);
|
||||
}
|
||||
@@ -760,7 +768,7 @@ static void wm_xr_raycast(Scene *scene,
|
||||
#define XR_DEFAULT_FLY_SPEED_MOVE 0.054f
|
||||
#define XR_DEFAULT_FLY_SPEED_TURN 0.03f
|
||||
|
||||
typedef enum eXrFlyMode {
|
||||
enum eXrFlyMode {
|
||||
XR_FLY_FORWARD = 0,
|
||||
XR_FLY_BACK = 1,
|
||||
XR_FLY_LEFT = 2,
|
||||
@@ -774,18 +782,19 @@ typedef enum eXrFlyMode {
|
||||
XR_FLY_VIEWER_LEFT = 10,
|
||||
XR_FLY_VIEWER_RIGHT = 11,
|
||||
XR_FLY_CONTROLLER_FORWARD = 12,
|
||||
} eXrFlyMode;
|
||||
};
|
||||
|
||||
typedef struct XrFlyData {
|
||||
struct XrFlyData {
|
||||
float viewer_rot[4];
|
||||
double time_prev;
|
||||
} XrFlyData;
|
||||
};
|
||||
|
||||
static void wm_xr_fly_init(wmOperator *op, const wmXrData *xr)
|
||||
{
|
||||
BLI_assert(op->customdata == NULL);
|
||||
BLI_assert(op->customdata == nullptr);
|
||||
|
||||
XrFlyData *data = op->customdata = MEM_callocN(sizeof(XrFlyData), __func__);
|
||||
XrFlyData *data = static_cast<XrFlyData *>(
|
||||
op->customdata = MEM_callocN(sizeof(XrFlyData), __func__));
|
||||
|
||||
WM_xr_session_state_viewer_pose_rotation_get(xr, data->viewer_rot);
|
||||
data->time_prev = PIL_check_seconds_timer();
|
||||
@@ -915,7 +924,7 @@ static int wm_xr_navigation_fly_invoke(bContext *C, wmOperator *op, const wmEven
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
static int wm_xr_navigation_fly_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int wm_xr_navigation_fly_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -931,8 +940,8 @@ static int wm_xr_navigation_fly_modal(bContext *C, wmOperator *op, const wmEvent
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
const wmXrActionData *actiondata = event->customdata;
|
||||
XrFlyData *data = op->customdata;
|
||||
const wmXrActionData *actiondata = static_cast<const wmXrActionData *>(event->customdata);
|
||||
XrFlyData *data = static_cast<XrFlyData *>(op->customdata);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmXrData *xr = &wm->xr;
|
||||
eXrFlyMode mode;
|
||||
@@ -1140,7 +1149,7 @@ static void WM_OT_xr_navigation_fly(wmOperatorType *ot)
|
||||
0,
|
||||
"Controller Forward",
|
||||
"Move along controller's forward axis"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static const float default_speed_p0[2] = {0.0f, 0.0f};
|
||||
@@ -1222,7 +1231,7 @@ static void wm_xr_navigation_teleport(bContext *C,
|
||||
float location[3];
|
||||
float normal[3];
|
||||
int index;
|
||||
Object *ob = NULL;
|
||||
Object *ob = nullptr;
|
||||
float obmat[4][4];
|
||||
|
||||
wm_xr_raycast(scene,
|
||||
@@ -1288,7 +1297,7 @@ static int wm_xr_navigation_teleport_invoke(bContext *C, wmOperator *op, const w
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int wm_xr_navigation_teleport_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
||||
static int wm_xr_navigation_teleport_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -1299,7 +1308,7 @@ static int wm_xr_navigation_teleport_modal(bContext *C, wmOperator *op, const wm
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
const wmXrActionData *actiondata = event->customdata;
|
||||
const wmXrActionData *actiondata = static_cast<const wmXrActionData *>(event->customdata);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmXrData *xr = &wm->xr;
|
||||
|
||||
@@ -1309,7 +1318,7 @@ static int wm_xr_navigation_teleport_modal(bContext *C, wmOperator *op, const wm
|
||||
case KM_PRESS:
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
case KM_RELEASE: {
|
||||
XrRaycastData *data = op->customdata;
|
||||
XrRaycastData *data = static_cast<XrRaycastData *>(op->customdata);
|
||||
bool selectable_only, teleport_axes[3];
|
||||
float teleport_t, teleport_ofs, ray_dist;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "wm_window.h"
|
||||
#include "wm_xr_intern.h"
|
||||
|
||||
static wmSurface *g_xr_surface = NULL;
|
||||
static wmSurface *g_xr_surface = nullptr;
|
||||
static CLG_LogRef LOG = {"wm.xr"};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -54,7 +54,7 @@ static CLG_LogRef LOG = {"wm.xr"};
|
||||
static void wm_xr_session_create_cb(void)
|
||||
{
|
||||
Main *bmain = G_MAIN;
|
||||
wmWindowManager *wm = bmain->wm.first;
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
wmXrData *xr_data = &wm->xr;
|
||||
wmXrSessionState *state = &xr_data->runtime->session_state;
|
||||
XrSessionSettings *settings = &xr_data->session_settings;
|
||||
@@ -77,7 +77,7 @@ static void wm_xr_session_controller_data_free(wmXrSessionState *state)
|
||||
ListBase *lb = &state->controllers;
|
||||
wmXrController *c;
|
||||
|
||||
while ((c = BLI_pophead(lb))) {
|
||||
while ((c = static_cast<wmXrController *>(BLI_pophead(lb)))) {
|
||||
if (c->model) {
|
||||
GPU_batch_discard(c->model);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ void wm_xr_session_data_free(wmXrSessionState *state)
|
||||
|
||||
static void wm_xr_session_exit_cb(void *customdata)
|
||||
{
|
||||
wmXrData *xr_data = customdata;
|
||||
wmXrData *xr_data = static_cast<wmXrData *>(customdata);
|
||||
if (!xr_data->runtime) {
|
||||
return;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ static void wm_xr_session_draw_data_populate(wmXrData *xr_data,
|
||||
r_draw_data->scene = scene;
|
||||
r_draw_data->depsgraph = depsgraph;
|
||||
r_draw_data->xr_data = xr_data;
|
||||
r_draw_data->surface_data = g_xr_surface->customdata;
|
||||
r_draw_data->surface_data = static_cast<wmXrSurfaceData *>(g_xr_surface->customdata);
|
||||
|
||||
wm_xr_session_base_pose_calc(
|
||||
r_draw_data->scene, settings, &r_draw_data->base_pose, &r_draw_data->base_scale);
|
||||
@@ -224,7 +224,7 @@ wmWindow *wm_xr_session_root_window_or_fallback_get(const wmWindowManager *wm,
|
||||
return runtime_data->session_root_win;
|
||||
}
|
||||
/* Otherwise, fallback. */
|
||||
return wm->windows.first;
|
||||
return static_cast<wmWindow *>(wm->windows.first);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,12 +250,12 @@ static void wm_xr_session_scene_and_depsgraph_get(const wmWindowManager *wm,
|
||||
*r_depsgraph = depsgraph;
|
||||
}
|
||||
|
||||
typedef enum wmXrSessionStateEvent {
|
||||
enum wmXrSessionStateEvent {
|
||||
SESSION_STATE_EVENT_NONE = 0,
|
||||
SESSION_STATE_EVENT_START,
|
||||
SESSION_STATE_EVENT_RESET_TO_BASE_POSE,
|
||||
SESSION_STATE_EVENT_POSITION_TRACKING_TOGGLE,
|
||||
} wmXrSessionStateEvent;
|
||||
};
|
||||
|
||||
static bool wm_xr_session_draw_data_needs_reset_to_base_pose(const wmXrSessionState *state,
|
||||
const XrSessionSettings *settings)
|
||||
@@ -307,7 +307,7 @@ void wm_xr_session_draw_data_update(wmXrSessionState *state,
|
||||
copy_v3_fl(draw_data->eye_position_ofs, 0.0f);
|
||||
}
|
||||
break;
|
||||
/* This should be triggered by the VR add-on if a landmark changes. */
|
||||
/* This should be triggered by the VR add-on if a landmark changes. */
|
||||
case SESSION_STATE_EVENT_RESET_TO_BASE_POSE:
|
||||
if (use_position_tracking) {
|
||||
/* Switch exactly to base pose, so use eye offset to cancel out current position delta. */
|
||||
@@ -389,12 +389,12 @@ void wm_xr_session_state_update(const XrSessionSettings *settings,
|
||||
|
||||
wmXrSessionState *WM_xr_session_state_handle_get(const wmXrData *xr)
|
||||
{
|
||||
return xr->runtime ? &xr->runtime->session_state : NULL;
|
||||
return xr->runtime ? &xr->runtime->session_state : nullptr;
|
||||
}
|
||||
|
||||
ScrArea *WM_xr_session_area_get(const wmXrData *xr)
|
||||
{
|
||||
return xr->runtime ? xr->runtime->area : NULL;
|
||||
return xr->runtime ? xr->runtime->area : nullptr;
|
||||
}
|
||||
|
||||
bool WM_xr_session_state_viewer_pose_location_get(const wmXrData *xr, float r_location[3])
|
||||
@@ -446,8 +446,8 @@ bool WM_xr_session_state_controller_grip_location_get(const wmXrData *xr,
|
||||
return false;
|
||||
}
|
||||
|
||||
const wmXrController *controller = BLI_findlink(&xr->runtime->session_state.controllers,
|
||||
subaction_idx);
|
||||
const wmXrController *controller = static_cast<const wmXrController *>(
|
||||
BLI_findlink(&xr->runtime->session_state.controllers, subaction_idx));
|
||||
BLI_assert(controller);
|
||||
copy_v3_v3(r_location, controller->grip_pose.position);
|
||||
return true;
|
||||
@@ -464,8 +464,8 @@ bool WM_xr_session_state_controller_grip_rotation_get(const wmXrData *xr,
|
||||
return false;
|
||||
}
|
||||
|
||||
const wmXrController *controller = BLI_findlink(&xr->runtime->session_state.controllers,
|
||||
subaction_idx);
|
||||
const wmXrController *controller = static_cast<const wmXrController *>(
|
||||
BLI_findlink(&xr->runtime->session_state.controllers, subaction_idx));
|
||||
BLI_assert(controller);
|
||||
copy_qt_qt(r_rotation, controller->grip_pose.orientation_quat);
|
||||
return true;
|
||||
@@ -482,8 +482,8 @@ bool WM_xr_session_state_controller_aim_location_get(const wmXrData *xr,
|
||||
return false;
|
||||
}
|
||||
|
||||
const wmXrController *controller = BLI_findlink(&xr->runtime->session_state.controllers,
|
||||
subaction_idx);
|
||||
const wmXrController *controller = static_cast<const wmXrController *>(
|
||||
BLI_findlink(&xr->runtime->session_state.controllers, subaction_idx));
|
||||
BLI_assert(controller);
|
||||
copy_v3_v3(r_location, controller->aim_pose.position);
|
||||
return true;
|
||||
@@ -500,8 +500,8 @@ bool WM_xr_session_state_controller_aim_rotation_get(const wmXrData *xr,
|
||||
return false;
|
||||
}
|
||||
|
||||
const wmXrController *controller = BLI_findlink(&xr->runtime->session_state.controllers,
|
||||
subaction_idx);
|
||||
const wmXrController *controller = static_cast<const wmXrController *>(
|
||||
BLI_findlink(&xr->runtime->session_state.controllers, subaction_idx));
|
||||
BLI_assert(controller);
|
||||
copy_qt_qt(r_rotation, controller->aim_pose.orientation_quat);
|
||||
return true;
|
||||
@@ -670,9 +670,9 @@ static void wm_xr_session_controller_data_update(const XrSessionSettings *settin
|
||||
static const GHOST_XrPose *wm_xr_session_controller_aim_pose_find(const wmXrSessionState *state,
|
||||
const char *subaction_path)
|
||||
{
|
||||
const wmXrController *controller = BLI_findstring(
|
||||
&state->controllers, subaction_path, offsetof(wmXrController, subaction_path));
|
||||
return controller ? &controller->aim_pose : NULL;
|
||||
const wmXrController *controller = static_cast<const wmXrController *>(BLI_findstring(
|
||||
&state->controllers, subaction_path, offsetof(wmXrController, subaction_path)));
|
||||
return controller ? &controller->aim_pose : nullptr;
|
||||
}
|
||||
|
||||
BLI_INLINE bool test_float_state(const float *state, float threshold, eXrAxisFlag flag)
|
||||
@@ -729,7 +729,7 @@ static bool wm_xr_session_modal_action_test(const ListBase *active_modal_actions
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (LinkData *, ld, active_modal_actions) {
|
||||
wmXrAction *active_modal_action = ld->data;
|
||||
wmXrAction *active_modal_action = static_cast<wmXrAction *>(ld->data);
|
||||
if (action == active_modal_action) {
|
||||
if (r_found) {
|
||||
*r_found = true;
|
||||
@@ -753,7 +753,7 @@ static void wm_xr_session_modal_action_test_add(ListBase *active_modal_actions,
|
||||
{
|
||||
bool found;
|
||||
if (wm_xr_session_modal_action_test(active_modal_actions, action, &found) && !found) {
|
||||
LinkData *ld = MEM_callocN(sizeof(LinkData), __func__);
|
||||
LinkData *ld = static_cast<LinkData *>(MEM_callocN(sizeof(LinkData), __func__));
|
||||
ld->data = (void *)action;
|
||||
BLI_addtail(active_modal_actions, ld);
|
||||
}
|
||||
@@ -779,7 +779,7 @@ static wmXrHapticAction *wm_xr_session_haptic_action_find(ListBase *active_hapti
|
||||
return ha;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void wm_xr_session_haptic_action_add(ListBase *active_haptic_actions,
|
||||
@@ -794,7 +794,7 @@ static void wm_xr_session_haptic_action_add(ListBase *active_haptic_actions,
|
||||
ha->time_start = time_now;
|
||||
}
|
||||
else {
|
||||
ha = MEM_callocN(sizeof(wmXrHapticAction), __func__);
|
||||
ha = static_cast<wmXrHapticAction *>(MEM_callocN(sizeof(wmXrHapticAction), __func__));
|
||||
ha->action = (wmXrAction *)action;
|
||||
ha->subaction_path = subaction_path;
|
||||
ha->time_start = time_now;
|
||||
@@ -835,7 +835,7 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr,
|
||||
{
|
||||
const char *haptic_subaction_path = ((action->haptic_flag & XR_HAPTIC_MATCHUSERPATHS) != 0) ?
|
||||
action->subaction_paths[subaction_idx] :
|
||||
NULL;
|
||||
nullptr;
|
||||
bool curr = false;
|
||||
bool prev = false;
|
||||
|
||||
@@ -944,7 +944,7 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr,
|
||||
*r_val = KM_RELEASE;
|
||||
if (modal && (action->subaction_paths[subaction_idx] == action->active_modal_path)) {
|
||||
/* Unset active modal path. */
|
||||
action->active_modal_path = NULL;
|
||||
action->active_modal_path = nullptr;
|
||||
/* Remove from active modal actions. */
|
||||
wm_xr_session_modal_action_remove(active_modal_actions, action);
|
||||
}
|
||||
@@ -1039,7 +1039,8 @@ static wmXrActionData *wm_xr_session_event_create(const char *action_set_name,
|
||||
uint subaction_idx_other,
|
||||
bool bimanual)
|
||||
{
|
||||
wmXrActionData *data = MEM_callocN(sizeof(wmXrActionData), __func__);
|
||||
wmXrActionData *data = static_cast<wmXrActionData *>(
|
||||
MEM_callocN(sizeof(wmXrActionData), __func__));
|
||||
STRNCPY(data->action_set, action_set_name);
|
||||
STRNCPY(data->action, action->name);
|
||||
STRNCPY(data->user_path, action->subaction_paths[subaction_idx]);
|
||||
@@ -1119,7 +1120,8 @@ static void wm_xr_session_events_dispatch(wmXrData *xr,
|
||||
ListBase *active_modal_actions = &action_set->active_modal_actions;
|
||||
ListBase *active_haptic_actions = &action_set->active_haptic_actions;
|
||||
|
||||
wmXrAction **actions = MEM_calloc_arrayN(count, sizeof(*actions), __func__);
|
||||
wmXrAction **actions = static_cast<wmXrAction **>(
|
||||
MEM_calloc_arrayN(count, sizeof(*actions), __func__));
|
||||
|
||||
GHOST_XrGetActionCustomdataArray(xr_context, action_set_name, (void **)actions);
|
||||
|
||||
@@ -1131,7 +1133,7 @@ static void wm_xr_session_events_dispatch(wmXrData *xr,
|
||||
if (action && action->ot) {
|
||||
const bool modal = action->ot->modal;
|
||||
const bool haptic = (GHOST_XrGetActionCustomdata(
|
||||
xr_context, action_set_name, action->haptic_name) != NULL);
|
||||
xr_context, action_set_name, action->haptic_name) != nullptr);
|
||||
|
||||
for (uint subaction_idx = 0; subaction_idx < action->count_subaction_paths; ++subaction_idx)
|
||||
{
|
||||
@@ -1150,7 +1152,7 @@ static void wm_xr_session_events_dispatch(wmXrData *xr,
|
||||
&val);
|
||||
|
||||
const bool is_active_modal_action = wm_xr_session_modal_action_test(
|
||||
active_modal_actions, action, NULL);
|
||||
active_modal_actions, action, nullptr);
|
||||
const bool is_active_modal_subaction = (!action->active_modal_path ||
|
||||
(action->subaction_paths[subaction_idx] ==
|
||||
action->active_modal_path));
|
||||
@@ -1159,7 +1161,7 @@ static void wm_xr_session_events_dispatch(wmXrData *xr,
|
||||
(!modal || (is_active_modal_action && is_active_modal_subaction))) {
|
||||
const GHOST_XrPose *aim_pose = wm_xr_session_controller_aim_pose_find(
|
||||
session_state, action->subaction_paths[subaction_idx]);
|
||||
const GHOST_XrPose *aim_pose_other = NULL;
|
||||
const GHOST_XrPose *aim_pose_other = nullptr;
|
||||
uint subaction_idx_other = 0;
|
||||
|
||||
/* Test for bimanual interaction. */
|
||||
@@ -1216,7 +1218,7 @@ void wm_xr_session_actions_update(wmWindowManager *wm)
|
||||
wmXrActionSet *active_action_set = state->active_action_set;
|
||||
|
||||
const bool synced = GHOST_XrSyncActions(xr_context,
|
||||
active_action_set ? active_action_set->name : NULL);
|
||||
active_action_set ? active_action_set->name : nullptr);
|
||||
if (!synced) {
|
||||
return;
|
||||
}
|
||||
@@ -1240,7 +1242,7 @@ void wm_xr_session_actions_update(wmWindowManager *wm)
|
||||
}
|
||||
|
||||
/* Set XR area object type flags for operators. */
|
||||
View3D *v3d = xr->runtime->area->spacedata.first;
|
||||
View3D *v3d = static_cast<View3D *>(xr->runtime->area->spacedata.first);
|
||||
v3d->object_type_exclude_viewport = settings->object_type_exclude_viewport;
|
||||
v3d->object_type_exclude_select = settings->object_type_exclude_select;
|
||||
|
||||
@@ -1264,7 +1266,8 @@ void wm_xr_session_controller_data_populate(const wmXrAction *grip_action,
|
||||
wm_xr_session_controller_data_free(state);
|
||||
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
wmXrController *controller = MEM_callocN(sizeof(*controller), __func__);
|
||||
wmXrController *controller = static_cast<wmXrController *>(
|
||||
MEM_callocN(sizeof(*controller), __func__));
|
||||
|
||||
BLI_assert(STREQ(grip_action->subaction_paths[i], aim_action->subaction_paths[i]));
|
||||
STRNCPY(controller->subaction_path, grip_action->subaction_paths[i]);
|
||||
@@ -1274,7 +1277,7 @@ void wm_xr_session_controller_data_populate(const wmXrAction *grip_action,
|
||||
|
||||
/* Activate draw callback. */
|
||||
if (g_xr_surface) {
|
||||
wmXrSurfaceData *surface_data = g_xr_surface->customdata;
|
||||
wmXrSurfaceData *surface_data = static_cast<wmXrSurfaceData *>(g_xr_surface->customdata);
|
||||
if (surface_data && !surface_data->controller_draw_handle) {
|
||||
if (surface_data->controller_art) {
|
||||
surface_data->controller_draw_handle = ED_region_draw_cb_activate(
|
||||
@@ -1290,12 +1293,12 @@ void wm_xr_session_controller_data_clear(wmXrSessionState *state)
|
||||
|
||||
/* Deactivate draw callback. */
|
||||
if (g_xr_surface) {
|
||||
wmXrSurfaceData *surface_data = g_xr_surface->customdata;
|
||||
wmXrSurfaceData *surface_data = static_cast<wmXrSurfaceData *>(g_xr_surface->customdata);
|
||||
if (surface_data && surface_data->controller_draw_handle) {
|
||||
if (surface_data->controller_art) {
|
||||
ED_region_draw_cb_exit(surface_data->controller_art, surface_data->controller_draw_handle);
|
||||
}
|
||||
surface_data->controller_draw_handle = NULL;
|
||||
surface_data->controller_draw_handle = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1359,13 +1362,14 @@ static void wm_xr_session_do_depsgraph(bContext *C)
|
||||
bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data,
|
||||
const GHOST_XrDrawViewInfo *draw_view)
|
||||
{
|
||||
wmXrViewportPair *vp = NULL;
|
||||
wmXrViewportPair *vp = nullptr;
|
||||
if (draw_view->view_idx >= BLI_listbase_count(&surface_data->viewports)) {
|
||||
vp = MEM_callocN(sizeof(*vp), __func__);
|
||||
vp = static_cast<wmXrViewportPair *>(MEM_callocN(sizeof(*vp), __func__));
|
||||
BLI_addtail(&surface_data->viewports, vp);
|
||||
}
|
||||
else {
|
||||
vp = BLI_findlink(&surface_data->viewports, draw_view->view_idx);
|
||||
vp = static_cast<wmXrViewportPair *>(
|
||||
BLI_findlink(&surface_data->viewports, draw_view->view_idx));
|
||||
}
|
||||
BLI_assert(vp);
|
||||
|
||||
@@ -1411,7 +1415,7 @@ bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data,
|
||||
viewport = vp->viewport = GPU_viewport_create();
|
||||
if (!viewport) {
|
||||
GPU_offscreen_free(offscreen);
|
||||
offscreen = vp->offscreen = NULL;
|
||||
offscreen = vp->offscreen = nullptr;
|
||||
failure = true;
|
||||
}
|
||||
}
|
||||
@@ -1429,11 +1433,11 @@ bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data,
|
||||
|
||||
static void wm_xr_session_surface_free_data(wmSurface *surface)
|
||||
{
|
||||
wmXrSurfaceData *data = surface->customdata;
|
||||
wmXrSurfaceData *data = static_cast<wmXrSurfaceData *>(surface->customdata);
|
||||
ListBase *lb = &data->viewports;
|
||||
wmXrViewportPair *vp;
|
||||
|
||||
while ((vp = BLI_pophead(lb))) {
|
||||
while ((vp = static_cast<wmXrViewportPair *>(BLI_pophead(lb)))) {
|
||||
if (vp->viewport) {
|
||||
GPU_viewport_free(vp->viewport);
|
||||
}
|
||||
@@ -1450,7 +1454,7 @@ static void wm_xr_session_surface_free_data(wmSurface *surface)
|
||||
|
||||
MEM_freeN(surface->customdata);
|
||||
|
||||
g_xr_surface = NULL;
|
||||
g_xr_surface = nullptr;
|
||||
}
|
||||
|
||||
static wmSurface *wm_xr_session_surface_create(void)
|
||||
@@ -1460,9 +1464,11 @@ static wmSurface *wm_xr_session_surface_create(void)
|
||||
return g_xr_surface;
|
||||
}
|
||||
|
||||
wmSurface *surface = MEM_callocN(sizeof(*surface), __func__);
|
||||
wmXrSurfaceData *data = MEM_callocN(sizeof(*data), "XrSurfaceData");
|
||||
data->controller_art = MEM_callocN(sizeof(*(data->controller_art)), "XrControllerRegionType");
|
||||
wmSurface *surface = static_cast<wmSurface *>(MEM_callocN(sizeof(*surface), __func__));
|
||||
wmXrSurfaceData *data = static_cast<wmXrSurfaceData *>(
|
||||
MEM_callocN(sizeof(*data), "XrSurfaceData"));
|
||||
data->controller_art = static_cast<ARegionType *>(
|
||||
MEM_callocN(sizeof(*(data->controller_art)), "XrControllerRegionType"));
|
||||
|
||||
surface->draw = wm_xr_session_surface_draw;
|
||||
surface->do_depsgraph = wm_xr_session_do_depsgraph;
|
||||
@@ -1470,8 +1476,8 @@ static wmSurface *wm_xr_session_surface_create(void)
|
||||
surface->activate = DRW_xr_drawing_begin;
|
||||
surface->deactivate = DRW_xr_drawing_end;
|
||||
|
||||
surface->system_gpu_context = DRW_system_gpu_context_get();
|
||||
surface->blender_gpu_context = DRW_xr_blender_gpu_context_get();
|
||||
surface->system_gpu_context = static_cast<GHOST_ContextHandle>(DRW_system_gpu_context_get());
|
||||
surface->blender_gpu_context = static_cast<GPUContext *>(DRW_xr_blender_gpu_context_get());
|
||||
|
||||
data->controller_art->regionid = RGN_TYPE_XR;
|
||||
surface->customdata = data;
|
||||
@@ -1489,12 +1495,12 @@ void *wm_xr_session_gpu_binding_context_create(void)
|
||||
|
||||
/* Some regions may need to redraw with updated session state after the session is entirely up
|
||||
* and running. */
|
||||
WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL);
|
||||
WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, nullptr);
|
||||
|
||||
return surface->system_gpu_context;
|
||||
}
|
||||
|
||||
void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle UNUSED(context))
|
||||
void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle /*context*/)
|
||||
{
|
||||
if (g_xr_surface) { /* Might have been freed already */
|
||||
wm_surface_remove(g_xr_surface);
|
||||
@@ -1504,17 +1510,17 @@ void wm_xr_session_gpu_binding_context_destroy(GHOST_ContextHandle UNUSED(contex
|
||||
|
||||
/* Some regions may need to redraw with updated session state after the session is entirely
|
||||
* stopped. */
|
||||
WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, NULL);
|
||||
WM_main_add_notifier(NC_WM | ND_XR_DATA_CHANGED, nullptr);
|
||||
}
|
||||
|
||||
ARegionType *WM_xr_surface_controller_region_type_get(void)
|
||||
{
|
||||
if (g_xr_surface) {
|
||||
wmXrSurfaceData *data = g_xr_surface->customdata;
|
||||
wmXrSurfaceData *data = static_cast<wmXrSurfaceData *>(g_xr_surface->customdata);
|
||||
return data->controller_art;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */ /* XR-Session Surface */
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wmWindowManager;
|
||||
struct wmXrData;
|
||||
|
||||
@@ -23,3 +27,7 @@ bool wm_xr_events_handle(wmWindowManager *wm);
|
||||
/* wm_xr_operators.c */
|
||||
|
||||
void wm_xr_operatortypes_register(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user