Cleanup: Rename and add comment for RadialControl#initial_mouse
Attempt to clarify that this value is not the raw initial event so that usage is more clear during operator processing. Pull Request: https://projects.blender.org/blender/blender/pulls/144519
This commit is contained in:
@@ -2556,8 +2556,10 @@ struct RadialControl {
|
||||
float current_value = 0.0f;
|
||||
float min_value = 0.0f;
|
||||
float max_value = 0.0f;
|
||||
int initial_mouse[2] = {};
|
||||
/* Original region space coordinates that the operator is started on */
|
||||
int initial_co[2] = {};
|
||||
/* Modified value of #initial_co to simplify calculating new values */
|
||||
int initial_radial_center[2] = {};
|
||||
int slow_mouse[2] = {};
|
||||
bool slow_mode = false;
|
||||
Dial *dial = nullptr;
|
||||
@@ -2614,7 +2616,7 @@ static void radial_control_set_initial_mouse(RadialControl *rc, const wmEvent *e
|
||||
float d[2] = {0, 0};
|
||||
float zoom[2] = {1, 1};
|
||||
|
||||
copy_v2_v2_int(rc->initial_mouse, event->xy);
|
||||
copy_v2_v2_int(rc->initial_radial_center, event->xy);
|
||||
copy_v2_v2_int(rc->initial_co, event->xy);
|
||||
|
||||
switch (rc->subtype) {
|
||||
@@ -2645,8 +2647,8 @@ static void radial_control_set_initial_mouse(RadialControl *rc, const wmEvent *e
|
||||
d[1] *= zoom[1];
|
||||
}
|
||||
|
||||
rc->initial_mouse[0] -= d[0];
|
||||
rc->initial_mouse[1] -= d[1];
|
||||
rc->initial_radial_center[0] -= d[0];
|
||||
rc->initial_radial_center[1] -= d[1];
|
||||
}
|
||||
|
||||
static void radial_control_set_tex(RadialControl *rc)
|
||||
@@ -2835,8 +2837,8 @@ static void radial_control_paint_cursor(bContext * /*C*/,
|
||||
if (rc->subtype == PROP_ANGLE) {
|
||||
/* Use the initial mouse position to draw the rotation preview. This avoids starting the
|
||||
* rotation in a random direction. */
|
||||
x = rc->initial_mouse[0];
|
||||
y = rc->initial_mouse[1];
|
||||
x = rc->initial_radial_center[0];
|
||||
y = rc->initial_radial_center[1];
|
||||
}
|
||||
else {
|
||||
/* Keep cursor in the original place. */
|
||||
@@ -3310,8 +3312,8 @@ static wmOperatorStatus radial_control_modal(bContext *C, wmOperator *op, const
|
||||
if (rc->slow_mode) {
|
||||
if (rc->subtype == PROP_ANGLE) {
|
||||
/* Calculate the initial angle here first. */
|
||||
delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
|
||||
delta[1] = rc->initial_mouse[1] - rc->slow_mouse[1];
|
||||
delta[0] = rc->initial_radial_center[0] - rc->slow_mouse[0];
|
||||
delta[1] = rc->initial_radial_center[1] - rc->slow_mouse[1];
|
||||
|
||||
/* Precision angle gets calculated from dial and gets added later. */
|
||||
angle_precision = -0.1f * BLI_dial_angle(rc->dial,
|
||||
@@ -3319,7 +3321,7 @@ static wmOperatorStatus radial_control_modal(bContext *C, wmOperator *op, const
|
||||
float(event->xy[1])});
|
||||
}
|
||||
else {
|
||||
delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0];
|
||||
delta[0] = rc->initial_radial_center[0] - rc->slow_mouse[0];
|
||||
delta[1] = 0.0f;
|
||||
|
||||
if (rc->zoom_prop) {
|
||||
@@ -3339,8 +3341,8 @@ static wmOperatorStatus radial_control_modal(bContext *C, wmOperator *op, const
|
||||
}
|
||||
}
|
||||
else {
|
||||
delta[0] = float(rc->initial_mouse[0] - event->xy[0]);
|
||||
delta[1] = float(rc->initial_mouse[1] - event->xy[1]);
|
||||
delta[0] = float(rc->initial_radial_center[0] - event->xy[0]);
|
||||
delta[1] = float(rc->initial_radial_center[1] - event->xy[1]);
|
||||
if (rc->zoom_prop) {
|
||||
RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom);
|
||||
delta[0] /= zoom[0];
|
||||
@@ -3411,8 +3413,8 @@ static wmOperatorStatus radial_control_modal(bContext *C, wmOperator *op, const
|
||||
rc->slow_mouse[1] = event->xy[1];
|
||||
rc->slow_mode = true;
|
||||
if (rc->subtype == PROP_ANGLE) {
|
||||
const float initial_position[2] = {float(rc->initial_mouse[0]),
|
||||
float(rc->initial_mouse[1])};
|
||||
const float initial_position[2] = {float(rc->initial_radial_center[0]),
|
||||
float(rc->initial_radial_center[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. */
|
||||
|
||||
Reference in New Issue
Block a user