public static final String SCROLL_VIEW = "ScrollView"; //$NON-NLS-1$
public static final String RADIO_BUTTON = "RadioButton"; //$NON-NLS-1$
public static final String RADIO_GROUP = "RadioGroup"; //$NON-NLS-1$
+ public static final String SPACE = "Space"; //$NON-NLS-1$
public static final String EXPANDABLE_LIST_VIEW = "ExpandableListView";//$NON-NLS-1$
public static final String GESTURE_OVERLAY_VIEW = "GestureOverlayView";//$NON-NLS-1$
public static final String HORIZONTAL_SCROLL_VIEW = "HorizontalScrollView"; //$NON-NLS-1$
/** The fully qualified class name of a RadioGroup */
public static final String FQCN_RADIO_GROUP = "android.widgets.RadioGroup"; //$NON-NLS-1$
+ /** The fully qualified class name of a Space */
+ public static final String FQCN_SPACE = "android.widget.Space"; //$NON-NLS-1$
+
public static final String ATTR_SRC = "src"; //$NON-NLS-1$
// like fill_parent for API 8
package com.android.ide.eclipse.adt.internal.editors.layout.gle2;
+import static com.android.ide.common.layout.LayoutConstants.FQCN_SPACE;
import static com.android.ide.common.layout.LayoutConstants.GESTURE_OVERLAY_VIEW;
import static com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors.VIEW_MERGE;
/**
* Returns all the children of the canvas view info where each child corresponds to a
- * unique node. This is intended for use by the outline for example, where only the
- * actual nodes are displayed, not the views themselves.
+ * unique node that the user can see and select. This is intended for use by the
+ * outline for example, where only the actual nodes are displayed, not the views
+ * themselves.
* <p>
* Most views have their own nodes, so this is generally the same as
* {@link #getChildren}, except in the case where you for example include a view that
* never null
*/
public List<CanvasViewInfo> getUniqueChildren() {
+ boolean haveHidden = false;
+
for (CanvasViewInfo info : mChildren) {
if (info.mNodeSiblings != null) {
// We have secondary children; must create a new collection containing
}
return children;
}
+
+ haveHidden |= info.isHidden();
+ }
+
+ if (haveHidden) {
+ List<CanvasViewInfo> children = new ArrayList<CanvasViewInfo>(mChildren.size());
+ for (CanvasViewInfo vi : mChildren) {
+ if (!vi.isHidden()) {
+ children.add(vi);
+ }
+ }
+
+ return children;
}
return mChildren;
* Returns the name of the {@link CanvasViewInfo}.
* Could be null, although unlikely.
* Experience shows this is the full qualified Java name of the View.
+ * TODO: Rename this method to getFqcn.
*
* @return the name of the view info, or null
*
* @return True if this is a tiny layout or invisible view
*/
public boolean isInvisible() {
+ if (isHidden()) {
+ // Don't expand and highlight hidden widgets
+ return false;
+ }
+
if (mAbsRect.width < SELECTION_MIN_SIZE || mAbsRect.height < SELECTION_MIN_SIZE) {
return mUiViewNode != null && (mUiViewNode.getDescriptor().hasChildren() ||
mAbsRect.width <= 0 || mAbsRect.height <= 0);
}
/**
+ * Returns true if this {@link CanvasViewInfo} represents a widget that should be
+ * hidden, such as a {@code <Space>} which are typically not manipulated by the user
+ * through dragging etc.
+ *
+ * @return true if this is a hidden view
+ */
+ public boolean isHidden() {
+ return FQCN_SPACE.equals(mName);
+ }
+
+ /**
* Is this {@link CanvasViewInfo} a view that has had its padding inflated in order to
* make it visible during selection or dragging? Note that this is NOT considered to
* be the case in the explode-all-views mode where all nodes have their padding
if (!insideSelection) {
CanvasViewInfo vi = mCanvas.getViewHierarchy().findViewInfoAt(p);
- if (vi != null && !vi.isRoot()) {
+ if (vi != null && !vi.isRoot() && !vi.isHidden()) {
selectionManager.selectSingle(vi);
insideSelection = true;
}
} else {
// Only drag non-root items.
for (SelectionItem cs : selections) {
- if (!cs.isRoot()) {
+ if (!cs.isRoot() && !cs.isHidden()) {
mDragSelection.add(cs);
}
}
// If you are dragging a non-selected item, select it
if (mDragSelection.isEmpty()) {
CanvasViewInfo vi = mCanvas.getViewHierarchy().findViewInfoAt(p);
- if (vi != null && !vi.isRoot()) {
+ if (vi != null && !vi.isRoot() && !vi.isHidden()) {
selectionManager.selectSingle(vi);
mDragSelection.addAll(selections);
}
// If you drag on the -background-, we make that into a marquee
// selection
- if (!e.doit || (imageCount == 1 && mDragSelection.get(0).isRoot())) {
+ if (!e.doit || (imageCount == 1
+ && (mDragSelection.get(0).isRoot() || mDragSelection.get(0).isHidden()))) {
boolean toggle = (mLastStateMask & (SWT.CTRL | SWT.SHIFT | SWT.COMMAND)) != 0;
startGesture(controlPoint,
new MarqueeGesture(mCanvas, toggle), mLastStateMask);
CanvasViewInfo vi = mViewHierarchy.findViewInfoAt(p);
// We don't hover on the root since it's not a widget per see and it is always there.
- if (vi != null && vi.isRoot()) {
+ // We also skip spacers...
+ if (vi != null && (vi.isRoot() || vi.isHidden())) {
vi = null;
}
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.SessionParams;
-import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
+import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.resources.ResourceResolver;
import com.android.ide.common.resources.configuration.ScreenSizeQualifier;
import com.android.ide.eclipse.adt.AdtPlugin;
}
/**
+ * Returns true if this item represents a widget that should not be manipulated by the
+ * user.
+ *
+ * @return True if this widget should not be manipulated directly by the user
+ */
+ public boolean isHidden() {
+ return mCanvasViewInfo.isHidden();
+ }
+
+ /**
* Returns the selected view info. Cannot be null.
*
* @return the selected view info. Cannot be null.
CanvasViewInfo vi = mCanvas.getViewHierarchy().findViewInfoAt(p);
+ if (vi != null && vi.isHidden()) {
+ vi = vi.getParent();
+ }
+
if (isMultiClick && !isCycleClick) {
// Case where shift is pressed: pointed object is toggled.
mSelections.clear();
for (CanvasViewInfo viewInfo : viewInfos) {
+ if (viewInfo.isHidden()) {
+ continue;
+ }
mSelections.add(createSelection(viewInfo));
}
for (INode node : nodes) {
CanvasViewInfo viewInfo = mCanvas.getViewHierarchy().findViewInfoFor(node);
if (viewInfo != null) {
+ if (nodes.size() > 1 && viewInfo.isHidden()) {
+ // Skip spacers - unless you're dropping just one
+ continue;
+ }
newChildren.add(viewInfo);
}
}