Gizmo: 2d select now takes region coords
Was taking an event, when only the region coords are needed.
This commit is contained in:
parent
eb7b450c0c
commit
3daf5cc1ce
|
@ -140,15 +140,15 @@ static int gizmo_arrow2d_invoke(
|
|||
}
|
||||
|
||||
static int gizmo_arrow2d_test_select(
|
||||
bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
|
||||
bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
|
||||
{
|
||||
const float mval[2] = {event->mval[0], event->mval[1]};
|
||||
const float mval_fl[2] = {UNPACK2(mval)};
|
||||
const float arrow_length = RNA_float_get(gz->ptr, "length");
|
||||
const float arrow_angle = RNA_float_get(gz->ptr, "angle");
|
||||
const float line_len = arrow_length * gz->scale_final;
|
||||
float mval_local[2];
|
||||
|
||||
copy_v2_v2(mval_local, mval);
|
||||
copy_v2_v2(mval_local, mval_fl);
|
||||
sub_v2_v2(mval_local, gz->matrix_basis[3]);
|
||||
|
||||
float line[2][2];
|
||||
|
|
|
@ -232,20 +232,20 @@ static void gizmo_button2d_draw(const bContext *C, wmGizmo *gz)
|
|||
}
|
||||
|
||||
static int gizmo_button2d_test_select(
|
||||
bContext *C, wmGizmo *gz, const wmEvent *event)
|
||||
bContext *C, wmGizmo *gz, const int mval[2])
|
||||
{
|
||||
float point_local[2];
|
||||
|
||||
if (0) {
|
||||
/* correct, but unnecessarily slow. */
|
||||
if (gizmo_window_project_2d(
|
||||
C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
|
||||
C, gz, (const float[2]){UNPACK2(mval)}, 2, true, point_local) == false)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
copy_v2_v2(point_local, (float[2]){UNPACK2(event->mval)});
|
||||
copy_v2_v2(point_local, (float[2]){UNPACK2(mval)});
|
||||
sub_v2_v2(point_local, gz->matrix_basis[3]);
|
||||
mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC));
|
||||
}
|
||||
|
|
|
@ -718,7 +718,7 @@ static int gizmo_cage2d_get_cursor(wmGizmo *gz)
|
|||
}
|
||||
|
||||
static int gizmo_cage2d_test_select(
|
||||
bContext *C, wmGizmo *gz, const wmEvent *event)
|
||||
bContext *C, wmGizmo *gz, const int mval[2])
|
||||
{
|
||||
float point_local[2];
|
||||
float dims[2];
|
||||
|
@ -726,7 +726,7 @@ static int gizmo_cage2d_test_select(
|
|||
const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
|
||||
|
||||
if (gizmo_window_project_2d(
|
||||
C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
|
||||
C, gz, (const float[2]){UNPACK2(mval)}, 2, true, point_local) == false)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -293,12 +293,12 @@ static int gizmo_grab_invoke(
|
|||
|
||||
|
||||
static int gizmo_grab_test_select(
|
||||
bContext *C, wmGizmo *gz, const wmEvent *event)
|
||||
bContext *C, wmGizmo *gz, const int mval[2])
|
||||
{
|
||||
float point_local[2];
|
||||
|
||||
if (gizmo_window_project_2d(
|
||||
C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false)
|
||||
C, gz, (const float[2]){UNPACK2(mval)}, 2, true, point_local) == false)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -343,9 +343,9 @@ static void gizmo_axis_draw(const bContext *C, wmGizmo *gz)
|
|||
}
|
||||
|
||||
static int gizmo_axis_test_select(
|
||||
bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
|
||||
bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
|
||||
{
|
||||
float point_local[2] = {UNPACK2(event->mval)};
|
||||
float point_local[2] = {UNPACK2(mval)};
|
||||
sub_v2_v2(point_local, gz->matrix_basis[3]);
|
||||
mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC));
|
||||
|
||||
|
|
|
@ -799,10 +799,10 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz)
|
|||
}
|
||||
|
||||
static int gizmo_ruler_test_select(
|
||||
bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
|
||||
bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
|
||||
{
|
||||
RulerItem *ruler_item_pick = (RulerItem *)gz;
|
||||
float mval_fl[2] = {UNPACK2(event->mval)};
|
||||
float mval_fl[2] = {UNPACK2(mval)};
|
||||
int co_index;
|
||||
|
||||
/* select and drag */
|
||||
|
|
|
@ -111,7 +111,7 @@ static void rna_gizmo_draw_select_cb(
|
|||
}
|
||||
|
||||
static int rna_gizmo_test_select_cb(
|
||||
struct bContext *C, struct wmGizmo *gz, const struct wmEvent *event)
|
||||
struct bContext *C, struct wmGizmo *gz, const int location[2])
|
||||
{
|
||||
extern FunctionRNA rna_Gizmo_test_select_func;
|
||||
wmGizmoGroup *gzgroup = gz->parent_gzgroup;
|
||||
|
@ -123,7 +123,7 @@ static int rna_gizmo_test_select_cb(
|
|||
func = &rna_Gizmo_test_select_func;
|
||||
RNA_parameter_list_create(&list, &gz_ptr, func);
|
||||
RNA_parameter_set_lookup(&list, "context", &C);
|
||||
RNA_parameter_set_lookup(&list, "event", &event);
|
||||
RNA_parameter_set_lookup(&list, "location", location);
|
||||
gzgroup->type->ext.call((bContext *)C, &gz_ptr, func, &list);
|
||||
|
||||
void *ret;
|
||||
|
@ -966,7 +966,7 @@ static void rna_def_gizmo(BlenderRNA *brna, PropertyRNA *cprop)
|
|||
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
||||
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||
parm = RNA_def_pointer(func, "event", "Event", "", "");
|
||||
parm = RNA_def_int_array(func, "location", 2, NULL, INT_MIN, INT_MAX, "Location", "Region coordinates", INT_MIN, INT_MAX);
|
||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||
parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
|
||||
RNA_def_function_return(func, parm);
|
||||
|
|
|
@ -153,7 +153,7 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo(
|
|||
{
|
||||
for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
|
||||
if (gz->type->test_select && (gz->flag & WM_GIZMO_HIDDEN) == 0) {
|
||||
if ((*r_part = gz->type->test_select(C, gz, event)) != -1) {
|
||||
if ((*r_part = gz->type->test_select(C, gz, event->mval)) != -1) {
|
||||
return gz;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ typedef void (*wmGizmoGroupFnMsgBusSubscribe)(
|
|||
typedef void (*wmGizmoFnSetup)(struct wmGizmo *);
|
||||
typedef void (*wmGizmoFnDraw)(const struct bContext *, struct wmGizmo *);
|
||||
typedef void (*wmGizmoFnDrawSelect)(const struct bContext *, struct wmGizmo *, int);
|
||||
typedef int (*wmGizmoFnTestSelect)(struct bContext *, struct wmGizmo *, const struct wmEvent *);
|
||||
typedef int (*wmGizmoFnTestSelect)(struct bContext *, struct wmGizmo *, const int mval[2]);
|
||||
typedef int (*wmGizmoFnModal)(struct bContext *, struct wmGizmo *, const struct wmEvent *, eWM_GizmoFlagTweak);
|
||||
typedef void (*wmGizmoFnPropertyUpdate)(struct wmGizmo *, struct wmGizmoProperty *);
|
||||
typedef void (*wmGizmoFnMatrixBasisGet)(const struct wmGizmo *, float[4][4]);
|
||||
|
|
Loading…
Reference in New Issue