Highlight section
Summary: as title, highlight a section when hovering over it Depends on D13900729 Reviewed By: astreet Differential Revision: D13900789 fbshipit-source-id: 552554f5ecf9a9dd3edf4724581b7dee6a8a855d
This commit is contained in:
committed by
Facebook Github Bot
parent
ec98c857c2
commit
8855687963
@@ -6,8 +6,14 @@
|
||||
*/
|
||||
package com.facebook.flipper.plugins.litho;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.support.v4.view.MarginLayoutParamsCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.facebook.flipper.core.FlipperDynamic;
|
||||
import com.facebook.flipper.core.FlipperObject;
|
||||
import com.facebook.flipper.plugins.inspector.HighlightedOverlay;
|
||||
import com.facebook.flipper.plugins.inspector.Named;
|
||||
import com.facebook.flipper.plugins.inspector.NodeDescriptor;
|
||||
import com.facebook.flipper.plugins.inspector.Touch;
|
||||
@@ -58,7 +64,59 @@ public class DebugSectionDescriptor extends NodeDescriptor<DebugSection> {
|
||||
@Override
|
||||
public void setHighlighted(DebugSection node, boolean selected, boolean isAlignmentMode)
|
||||
throws Exception {
|
||||
// TODO T39526148
|
||||
final int childCount = getChildCount(node);
|
||||
|
||||
if (node.isDiffSectionSpec()) {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View view = (View) getChildAt(node, i);
|
||||
highlightChildView(view, selected, isAlignmentMode);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final Object child = getChildAt(node, i);
|
||||
final NodeDescriptor descriptor = descriptorForClass(child.getClass());
|
||||
descriptor.setHighlighted(child, selected, isAlignmentMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is similar to the implementation in ViewDescriptor but doesn't
|
||||
// target the parent view.
|
||||
private void highlightChildView(View node, boolean selected, boolean isAlignmentMode) {
|
||||
if (!selected) {
|
||||
HighlightedOverlay.removeHighlight(node);
|
||||
return;
|
||||
}
|
||||
|
||||
final Rect padding =
|
||||
new Rect(
|
||||
ViewCompat.getPaddingStart(node),
|
||||
node.getPaddingTop(),
|
||||
ViewCompat.getPaddingEnd(node),
|
||||
node.getPaddingBottom());
|
||||
|
||||
final Rect margin;
|
||||
final ViewGroup.LayoutParams params = node.getLayoutParams();
|
||||
if (params instanceof ViewGroup.MarginLayoutParams) {
|
||||
final ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) params;
|
||||
margin =
|
||||
new Rect(
|
||||
MarginLayoutParamsCompat.getMarginStart(marginParams),
|
||||
marginParams.topMargin,
|
||||
MarginLayoutParamsCompat.getMarginEnd(marginParams),
|
||||
marginParams.bottomMargin);
|
||||
} else {
|
||||
margin = new Rect();
|
||||
}
|
||||
|
||||
final int left = node.getLeft();
|
||||
final int top = node.getTop();
|
||||
|
||||
final Rect contentBounds = new Rect(left, top, left + node.getWidth(), top + node.getHeight());
|
||||
|
||||
contentBounds.offset(-left, -top);
|
||||
|
||||
HighlightedOverlay.setHighlighted(node, margin, padding, contentBounds, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user