20 lines
631 B
Python
20 lines
631 B
Python
from __future__ import annotations
|
|
|
|
from dpg_map.interaction import calculate_hit_rect
|
|
from dpg_map.sizing import SizeMeasurement, apply_size_measurement
|
|
from dpg_map.state import create_map_state
|
|
|
|
|
|
def test_hit_rect_uses_effective_map_size() -> None:
|
|
state = create_map_state(tag="hit-rect")
|
|
apply_size_measurement(state, SizeMeasurement(width=400, height=250, visible=True))
|
|
|
|
rect = calculate_hit_rect(state, (10.0, 20.0))
|
|
|
|
assert rect.x == 10.0
|
|
assert rect.y == 20.0
|
|
assert rect.width == 400
|
|
assert rect.height == 250
|
|
assert rect.contains(410.0, 270.0)
|
|
assert not rect.contains(411.0, 270.0)
|