11
11
defmodule Scenic.ViewPort.Input do
12
12
@ moduledoc false
13
13
alias Scenic.Scene
14
- # alias Scenic.Utilities
15
- # alias Scenic.Graph
16
14
alias Scenic.ViewPort.Context
17
15
alias Scenic.ViewPort
18
16
alias Scenic.Primitive
@@ -32,17 +30,14 @@ defmodule Scenic.ViewPort.Input do
32
30
| { :cursor_scroll , { offset :: Math . point ( ) , position :: Math . point ( ) } }
33
31
| { :cursor_pos , position :: Math . point ( ) }
34
32
| { :viewport_enter , position :: Math . point ( ) }
35
- # |
36
33
| { :viewport_exit , position :: Math . point ( ) }
37
- # {:viewport_reshape, size :: Math.point}
38
34
39
35
@ type class ::
40
36
:codepoint
41
37
| :key
42
38
| :cursor_button
43
39
| :cursor_scroll
44
40
| :cursor_pos
45
- # | :viewport_reshape
46
41
| :viewport_enter
47
42
| :viewport_exit
48
43
@@ -86,7 +81,7 @@ defmodule Scenic.ViewPort.Input do
86
81
87
82
# #--------------------------------------------------------
88
83
# # do nothing if the size isn't actually changing
89
- # def handle_cast( {:input, {:viewport_reshape, new_size}}, %{size: old_size} = state )
84
+ # def handle_cast( {:input, {:viewport_reshape, new_size}}, %{size: old_size} = state )
90
85
# when new_size == old_size do
91
86
# {:noreply, state}
92
87
# end
@@ -583,18 +578,17 @@ defmodule Scenic.ViewPort.Input do
583
578
point = Matrix . project_vector ( context . inverse_tx , point )
584
579
585
580
with { :ok , graph } <- ViewPort.Tables . get_graph ( context . graph_key ) do
586
- do_find_by_captured_point (
587
- point ,
588
- 0 ,
589
- graph ,
590
- Matrix . identity ( ) ,
591
- Matrix . identity ( ) ,
592
- max_depth
593
- )
594
- |> case do
595
- nil -> { nil , nil , point }
596
- out -> out
597
- end
581
+ point =
582
+ do_find_by_captured_point (
583
+ point ,
584
+ 0 ,
585
+ graph ,
586
+ Matrix . identity ( ) ,
587
+ Matrix . identity ( ) ,
588
+ max_depth
589
+ )
590
+
591
+ if point , do: point , else: { nil , nil , point }
598
592
else
599
593
_ -> { nil , nil , point }
600
594
end
@@ -637,12 +631,8 @@ defmodule Scenic.ViewPort.Input do
637
631
local_point = Matrix . project_vector ( inv_tx , point )
638
632
639
633
# test if the point is in the primitive
640
- case mod . contains_point? ( data , local_point ) do
641
- true ->
642
- { uid , p [ :id ] , point }
643
-
644
- false ->
645
- nil
634
+ if mod . contains_point? ( data , local_point ) do
635
+ { uid , p [ :id ] , point }
646
636
end
647
637
end
648
638
end
@@ -651,7 +641,7 @@ defmodule Scenic.ViewPort.Input do
651
641
# find the indicated primitive in the graph given a point in screen coordinates.
652
642
# to do this, we need to project the point into primitive local coordinates by
653
643
# projecting it with the primitive's inverse final matrix.
654
- #
644
+ #
655
645
# Since the last primitive drawn is always on top, we should walk the tree
656
646
# backwards and return the first hit we find. We could just reduct the whole
657
647
# thing and return the last one found (that was my first try), but this is
@@ -729,16 +719,12 @@ defmodule Scenic.ViewPort.Input do
729
719
local_point = Matrix . project_vector ( inv_tx , { x , y } )
730
720
731
721
# test if the point is in the primitive
732
- case mod . contains_point? ( data , local_point ) do
733
- true ->
734
- id = p [ :id ]
735
- # Return the point in graph coordinates. Local was good for the hit test
736
- # but graph coords makes more sense for the graph_key logic
737
- graph_point = Matrix . project_vector ( graph_inv_tx , { x , y } )
738
- { graph_point , { uid , id , graph_key } , { graph_tx , graph_inv_tx } }
739
-
740
- false ->
741
- nil
722
+ if mod . contains_point? ( data , local_point ) do
723
+ id = p [ :id ]
724
+ # Return the point in graph coordinates. Local was good for the hit test
725
+ # but graph coords makes more sense for the graph_key logic
726
+ graph_point = Matrix . project_vector ( graph_inv_tx , { x , y } )
727
+ { graph_point , { uid , id , graph_key } , { graph_tx , graph_inv_tx } }
742
728
end
743
729
end
744
730
end
0 commit comments