Commit Graph

17 Commits

Author SHA1 Message Date
Luke De Feo
01f7fa34e5 Remove per node snapshot in favour of single top level snapshot
Summary: In order to support focus mode we need to have only 1 snapshot. In practice this is the case but we are making this more apparant in this diff.

Reviewed By: lblasa

Differential Revision: D41493003

fbshipit-source-id: 19ed7213d15adaea4732f4ec60309efa8dae6f94
2022-11-24 09:23:16 -08:00
Lorenzo Blasa
43f44652f4 Change snapshots format to png
Summary:
There was an issue whereas snapshots were not properly rendered on retina devices.

After running a few tests, the issue seems to be solved by changing the snapshot format from jpeg to png.

Reviewed By: antonk52

Differential Revision: D41520939

fbshipit-source-id: 1563fe89162e41f71418357a7e58caaf46581f04
2022-11-24 07:14:55 -08:00
Luke De Feo
1d920efe10 Change hit test to explore all nodes
Summary:
Previously we would only consider a node hit if the nouse pos was inside every parents. There are a few reason why this isnt ideal:
1. Fragments are return 0 bounds
2. Many hierachys (particually in litho ) have nonsensical strucutres where your parent may have hieght 0, or children overflow parents bounds. Therefore it was impossible to select many nodes but unclear why

Reviewed By: lblasa

Differential Revision: D41304499

fbshipit-source-id: d75c8060f71fa0b972f136cb11258b62a9c98ebc
2022-11-16 10:38:23 -08:00
Luke De Feo
477eae1993 Hit test can produce multiple nodes
Summary:
There are situations where multiple siblings overlap and they are both hit. Previously we picked the first one in the hierachy. Now we produce a list of hit children. The list will not have 2 nodes in the same ancestor path.

We store the hovered nodes as a list as we may want to present a modal in future to ask user which node they indented to select. That said simply sorting nodes by area seems to give decent results so we can start with this

Reviewed By: lblasa

Differential Revision: D41220271

fbshipit-source-id: 643a369113da28e8c4749725a7aee7aa5d08c401
2022-11-14 07:05:58 -08:00
Luke De Feo
062e87f50f Use mouse position for hit test for 2D vizualizer
Summary:
The Dom events for the divs that are very close together were not firing correctly causing the old implementation to not track the hovered node correctly. This was really frustrating trying to select a node amongst many close neighbours.

The new approach uses the mouse x,y position and performs a hit test. Currently we do a dfs looking for the first deepest child that interests the mouse x,y. In a future diff we will extract a list when there are multiple candidates.

Hovered node was removed from react props since both the tree and visualisor depend on it meaning when hover state changes the whole app is rerendered. Instead we have moved hover state to an atom which is subscribed to by each visualsation node. Only if the old or new value matches the particular nodes id do we set state. The viz nodes were memo'd to prevent children renderning. The result is that for a hover change at most 2 nodes out of the 500 or so will rerender.

I attempted to do the same with the tree but it wasnt working with the controlled tree environment + focus state. The perf seems fine as is so will leave it for now

Reviewed By: lblasa

Differential Revision: D41218324

fbshipit-source-id: 7f80bcee256abad2689a88d7e209f92417aab672
2022-11-14 07:05:58 -08:00
Luke De Feo
bfe098485f Nested node structure for vizualiser
Summary: This structure makes sense for the vizualiser which itself is a nested structure. It also saves the awkward branch of there is no key in the map.

Reviewed By: lblasa

Differential Revision: D40670371

fbshipit-source-id: 6c1b960a77749be9e8a193decf6b8d50ce6c7968
2022-11-14 07:05:58 -08:00
Luke De Feo
b2c7d67586 More subtile selection and hover state for vizualizer
Summary:
Old hover state is now selection state
New hover state is a slightly thicker border

Reviewed By: lblasa

Differential Revision: D40637724

fbshipit-source-id: 7b13bc864bc1f626cf0982517befcb80615e7cc0
2022-10-25 07:10:38 -07:00
Luke De Feo
f282a5eb8a Ant tree -> React complex tree
Summary:
Upgraded from ant tree library to the much more capable React complex tree. Added the following:
1. Ability to expand / collapse nodes while automatically expanding / collapsing active/inactive children when they change
2. Keyboard controls of tree all the time
3. Basic search functionality
4. Selecting node in tree focuses and scrolls in the tree
5. Hover state for tree

Reviewed By: lblasa

Differential Revision: D40633876

fbshipit-source-id: 8dcef5ec2c277e476a3eb3cdaef62b15c25323c0
2022-10-25 07:10:38 -07:00
Luke De Feo
0c52ad307e Improve selection in vizualizer
Summary:
Clicking on a node a second time will unselect which was impossible before.

The behaviour of the on click handler doesnt always line up what is currently hovered, this is a temporary work around. There are deeper issues with this in that on exit we hover the parent, but in some situations the parent is too small to propagate. In future we will use the mouse position and do a hit test and drive selection / hover from that

Reviewed By: lblasa

Differential Revision: D40637356

fbshipit-source-id: 9df19dbf619845891bb46624730d7cf74f73cf25
2022-10-25 07:10:38 -07:00
Lorenzo Blasa
5089f0319f Hide overflow
Summary: ^

Reviewed By: mweststrate

Differential Revision: D40316441

fbshipit-source-id: 235d0d3260743e3cdd85921aa27d20eef8217cae
2022-10-18 02:49:58 -07:00
Luke De Feo
941225e3d6 Only show node name when hovered
Summary: This makes the vizualiser a lot less cluttered

Reviewed By: lblasa

Differential Revision: D40021837

fbshipit-source-id: 8901c9bff6f05ee3fa4517e103c770be1fcfa403
2022-10-10 04:13:06 -07:00
Luke De Feo
78e84a0cc3 added metrics for snapshot
Reviewed By: lblasa

Differential Revision: D39886448

fbshipit-source-id: b229f6947d199026c6e4bdc89def6ac0a0fa9d0a
2022-09-29 05:31:18 -07:00
Lorenzo Blasa
ee9415a8d4 Be able to handle different snapshots for different roots
Summary:
^

This change allows to take different snapshots for different nodes and render them each on the visualiser.

At the moment, more than likely, this is not really used. At the same time, it fixes an issue whereas any subtree update can override and set the only visible snapshot.

Reviewed By: LukeDefeo, antonk52

Differential Revision: D39821920

fbshipit-source-id: ab8f6a4a2a5e96801c951a4e3009cc571a617f22
2022-09-27 13:00:04 -07:00
Lorenzo Blasa
945e26d0f1 Snapshots on Visualiser
Summary:
^

TODO: the snapshot corresponds to the referring subtree update. However, the snapshot is getting applied as if it was the current top view of the running app. This is true in most cases but it doesn't for some. To solve this, we need to use the rootId for the subtree and apply the snapshot only if appropriate.

Having said that, is good enough for the current submission as we keep iterating on it.

Reviewed By: LukeDefeo

Differential Revision: D39813307

fbshipit-source-id: 33b6aff6e9dd085934150ebd2f247062447a59ff
2022-09-27 13:00:04 -07:00
Luke De Feo
67ff09563c Improved interaction between tree and visualizer
Summary:
Improved the 2 way relationship between tree and vizualiser. There are 3 states.
1. Select, this is when you click on either tree node or view. View is highlighted darker colour, sidebar shows up for that node and select is persisted when you mouse away
2. Hover, this is when you hover over a tree node or in the vizualizer, the node is highlighted a lighter colur
3. Hover while holding control - same as hover but we dont draw any children, this lets you see how parent nodes appear without their children

Reviewed By: lblasa

Differential Revision: D39695661

fbshipit-source-id: 623e479fb03567e9f15a4a4f9201b2c7884cabe4
2022-09-22 04:26:18 -07:00
Luke De Feo
f3b7552338 2D wire frame highlight from tree, select from wireframe
Summary:
Introduced some basic bidirectional link between tree and wireframe, the specific interaction will need some tweaking but this should get us started.

When hovering over the tree we halt the rendering of the wireframe up to that point, this allows us to explore parent views that layout child views.

When clicking a view in the wireframe it is 'seleceted' as if it was clicked in the tree. This set the tree selection so you can identify it in the tree as well as opens the side bar

Reviewed By: lblasa

Differential Revision: D39539277

fbshipit-source-id: 3beb1ad4cb56b398c640ac3e7fac2cc97f3f1a18
2022-09-21 07:02:48 -07:00
Luke De Feo
cf176bb071 Basic 2D wireframe
Summary: Basic visual wireframe for the purposes of verifying that our captured view hierachy is correct, the actual version we ship will hopefully be a lot better :)

Reviewed By: lblasa

Differential Revision: D39539278

fbshipit-source-id: 73d926ff1990f09ca9877430cb227f690d05d1d4
2022-09-21 07:02:48 -07:00