diff --git a/desktop/plugins/public/ui-debugger/DesktopTypes.tsx b/desktop/plugins/public/ui-debugger/DesktopTypes.tsx index af147172d..8c7f56da9 100644 --- a/desktop/plugins/public/ui-debugger/DesktopTypes.tsx +++ b/desktop/plugins/public/ui-debugger/DesktopTypes.tsx @@ -26,6 +26,7 @@ export type LiveClientState = { export type UIState = { viewMode: Atom; + wireFrameMode: Atom; isConnected: Atom; isPaused: Atom; streamState: Atom; @@ -47,6 +48,8 @@ type TransformToReadOnly = { [P in keyof T]: T[P] extends Atom ? _ReadOnlyAtom : T[P]; }; +export type WireFrameMode = 'All' | 'SelectedAndChildren' | 'SelectedOnly'; + export type ReadOnlyUIState = TransformToReadOnly; export type StreamFlowState = {paused: boolean}; @@ -91,6 +94,7 @@ export type UIActions = { ) => void; onPlayPauseToggled: () => void; onSearchTermUpdated: (searchTerm: string) => void; + onSetWireFrameMode: (WireFrameMode: WireFrameMode) => void; }; export type SelectionSource = 'visualiser' | 'tree' | 'keyboard'; diff --git a/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx b/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx index c5c5200b7..2d92469d6 100644 --- a/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx +++ b/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx @@ -9,7 +9,7 @@ import React, {useEffect, useMemo, useRef, useState} from 'react'; import {Bounds, Coordinate, Id, ClientNode} from '../../ClientTypes'; -import {NestedNode, OnSelectNode} from '../../DesktopTypes'; +import {NestedNode, OnSelectNode, WireFrameMode} from '../../DesktopTypes'; import { produce, @@ -42,6 +42,7 @@ export const Visualization2D: React.FC< const selectedNodeId = useValue(instance.uiState.selectedNode); const hoveredNodes = useValue(instance.uiState.hoveredNodes); const hoveredNodeId = head(hoveredNodes); + const wireFrameMode = useValue(instance.uiState.wireFrameMode); const [targetMode, setTargetMode] = useState({ state: 'disabled', @@ -141,6 +142,8 @@ export const Visualization2D: React.FC< return ( )} @@ -238,19 +244,30 @@ export const Visualization2D: React.FC< const MemoedVisualizationNode2D = React.memo( Visualization2DNode, (prev, next) => { - return prev.node === next.node; + return ( + prev.node === next.node && + prev.selectedNode === next.selectedNode && + prev.wireframeMode === next.wireframeMode + ); }, ); function Visualization2DNode({ + wireframeMode, + isSelectedOrChildOrSelected, + selectedNode, node, onSelectNode, }: { + wireframeMode: WireFrameMode; + isSelectedOrChildOrSelected: boolean; + selectedNode?: Id; node: NestedNode; onSelectNode: OnSelectNode; }) { const instance = usePlugin(plugin); + const isSelected = node.id === selectedNode; const ref = useRef(null); let nestedChildren: NestedNode[]; @@ -268,6 +285,9 @@ function Visualization2DNode({ const children = nestedChildren.map((child) => ( - + {showBorder && } {children} diff --git a/desktop/plugins/public/ui-debugger/components/visualizer/VisualizerControls.tsx b/desktop/plugins/public/ui-debugger/components/visualizer/VisualizerControls.tsx index ab2ade8da..ea91f16f2 100644 --- a/desktop/plugins/public/ui-debugger/components/visualizer/VisualizerControls.tsx +++ b/desktop/plugins/public/ui-debugger/components/visualizer/VisualizerControls.tsx @@ -7,7 +7,7 @@ * @format */ -import {Button, Slider, Tooltip, Typography} from 'antd'; +import {Button, Dropdown, Menu, Slider, Tooltip, Typography} from 'antd'; import {Layout, produce, theme, usePlugin} from 'flipper-plugin'; import {Id} from '../../ClientTypes'; import {plugin} from '../../index'; @@ -16,10 +16,11 @@ import { AimOutlined, FullscreenExitOutlined, FullscreenOutlined, + PicCenterOutlined, } from '@ant-design/icons'; import {tracker} from '../../utils/tracker'; import {debounce} from 'lodash'; - +import {WireFrameMode} from '../../DesktopTypes'; export type TargetModeState = | { state: 'selected'; @@ -38,7 +39,11 @@ export function VisualiserControls({ setTargetMode, selectedNode, focusedNode, + wireFrameMode, + onSetWireFrameMode, }: { + wireFrameMode: WireFrameMode; + onSetWireFrameMode: (mode: WireFrameMode) => void; selectedNode?: Id; focusedNode?: Id; setTargetMode: (targetMode: TargetModeState) => void; @@ -54,7 +59,7 @@ export function VisualiserControls({ : 'Remove focus'; const targetToolTip = - targetMode.state === 'disabled' ? 'TargetMode' : 'Exit target mode'; + targetMode.state === 'disabled' ? 'Target Mode' : 'Exit target mode'; return ( @@ -81,13 +86,43 @@ export function VisualiserControls({ targetMode.targetedNodes[value], 'visualiser', ); + debouncedReportTargetAdjusted(); }} /> )} - + + + + + + + }> + + + +