Fix: Frist retiming key can not be selected.

Area for clicking on keys was wider than strip which caused problems.
Instead of finding best strip candidate and then a key, make clickable
area wider, but inside of the strip itself.
This commit is contained in:
Richard Antalik
2024-01-11 21:09:24 +01:00
parent 766cec9e9a
commit c2a2e422ad

View File

@@ -155,8 +155,6 @@ static rctf keys_box_get(const bContext *C, const Sequence *seq)
rctf rect = strip_box_get(C, seq);
rect.ymax = KEY_CENTER + KEY_SIZE / 2;
rect.ymin = KEY_CENTER - KEY_SIZE / 2;
rect.xmax += RETIME_KEY_MOUSEOVER_THRESHOLD;
rect.xmin -= RETIME_KEY_MOUSEOVER_THRESHOLD;
return rect;
}
@@ -231,7 +229,14 @@ static SeqRetimingKey *mouse_over_key_get_from_strip(const bContext *C,
int distance = round_fl_to_int(
fabsf(UI_view2d_view_to_region_x(v2d, key_x_get(scene, seq, &key)) - mval[0]));
if (distance < RETIME_KEY_MOUSEOVER_THRESHOLD && distance < best_distance) {
int threshold = RETIME_KEY_MOUSEOVER_THRESHOLD;
if (key_x_get(scene, seq, &key) == SEQ_time_left_handle_frame_get(scene, seq) ||
key_x_get(scene, seq, &key) == SEQ_time_right_handle_frame_get(scene, seq))
{
threshold *= 2; /* Make first and last key easier to select. */
}
if (distance < threshold && distance < best_distance) {
best_distance = distance;
best_key = &key;
}
@@ -243,7 +248,6 @@ static SeqRetimingKey *mouse_over_key_get_from_strip(const bContext *C,
SeqRetimingKey *retiming_mousover_key_get(const bContext *C, const int mval[2], Sequence **r_seq)
{
for (Sequence *seq : sequencer_visible_strips_get(C)) {
rctf box = keys_box_get(C, seq);
if (!BLI_rctf_isect_pt(&box, mval[0], mval[1])) {
continue;