fix drag polling during overlay updates
This commit is contained in:
@@ -11,6 +11,7 @@ from dpg_map.interaction import (
|
||||
handle_mouse_release,
|
||||
handle_mouse_wheel,
|
||||
pan_state_by_pixels,
|
||||
update_drag_from_button_state,
|
||||
)
|
||||
from dpg_map.sizing import SizeMeasurement, apply_size_measurement
|
||||
from dpg_map.state import DirtyFlags, create_map_state, get_map_state
|
||||
@@ -60,6 +61,19 @@ def test_mouse_drag_uses_active_drag_state() -> None:
|
||||
assert state.center[1] < 0.0
|
||||
|
||||
|
||||
def test_polled_drag_starts_and_moves_while_button_is_down() -> None:
|
||||
state = create_map_state(tag="polled-drag", center=(0.0, 0.0), zoom=3)
|
||||
apply_size_measurement(state, SizeMeasurement(width=400, height=300, visible=True))
|
||||
rect = calculate_hit_rect(state, (10.0, 20.0))
|
||||
|
||||
update_drag_from_button_state(state, mouse_pos=(20.0, 30.0), hit_rect=rect, is_down=True)
|
||||
update_drag_from_button_state(state, mouse_pos=(45.0, 30.0), hit_rect=rect, is_down=True)
|
||||
update_drag_from_button_state(state, mouse_pos=(45.0, 30.0), hit_rect=rect, is_down=False)
|
||||
|
||||
assert state.interaction.active_drag is False
|
||||
assert state.center[1] < 0.0
|
||||
|
||||
|
||||
def test_wheel_zoom_keeps_cursor_latlon_stable() -> None:
|
||||
state = create_map_state(tag="wheel", center=(47.9029, 1.9093), zoom=8)
|
||||
apply_size_measurement(state, SizeMeasurement(width=800, height=600, visible=True))
|
||||
|
||||
Reference in New Issue
Block a user