diff options
author | Tor Norbye <tnorbye@google.com> | 2011-01-24 09:12:47 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2011-01-30 18:38:21 -0800 |
commit | 9155df4effaf2079215d5f77dc2e70dd145a6fdf (patch) | |
tree | b28e8da332ade0c9804fcb587b652d30996e47c7 /eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java | |
parent | ee0afac0a60af6f3f186e5bbb3f773b4c0eb56a4 (diff) | |
download | sdk-9155df4effaf2079215d5f77dc2e70dd145a6fdf.zip sdk-9155df4effaf2079215d5f77dc2e70dd145a6fdf.tar.gz sdk-9155df4effaf2079215d5f77dc2e70dd145a6fdf.tar.bz2 |
Cluster of improvements for merge tag views
This changeset contains various improvements around usage of the
<merge> tag. Some of these fixes require layoutlib 5.
* Use the new layoutlib support for rendering multiple children at the
root level - they now show up in the Outline (provided you are
running layoutlib 5), can be selected in the layout editor, etc.
* Add a drop handler such that you can drag into the <merge> view and
get drop feedback (similar to the FrameLayout)
* If the <merge> is empty, we don't get any ViewInfos, so in that case
manufacture a dummy view sized to the screen. Similarly, if we get
back ViewInfos that are children of a <merge> tag in the UI model,
create a <merge> view initialized to the bounding rectangle of these
views and reparent the views to it.
* Support highlighting multiple views simultaneously when you select
an include tag that renders into multiple views (because the root of
the included layout was a <merge> tag). Similarly, make "Show
Included In" work properly for <merge> views, and make the overlay
mask used to hide all included content also reveal only the primary
selected views (when a view is included more than once.) (Also tweak
the visual appearance of the mask, and use better icon for the view
root in the included-root scenario.)
* Improve the algorithm which deals with render results with null
keys. Use adjacent children that -do- have keys as constraints when
attempting to match up views without keys and unreferenced model
nodes. This fixes issue
http://code.google.com/p/android/issues/detail?id=14188
* Improve the way we pick views under the mouse. This used to search
down the view hierarchy in sibling order. Instead, search in reverse
sibling order since this will match what is drawn in the layout. For
views like FrameLayout and <merge> views, the children are painted
on top of ech other, so clicking on whatever is on top should choose
that view, not some earlier sibling below it.
* Fix such that when you drag into the canvas, we *always* target the
root node, even if it is not under the mouse. This is particularly
important with <merge> tags, but this also helps if you for example
have a LinearLayout as the root element, and the layout_height
property is wrap_content instead of match_parent. In that case, the
LinearLayout will *only* cover its children, so if you drag over the
visual screen, it looks like you should be able to drop into the
layout, but you cannot since it only covers its children. With this
fix, all positions outside the root element's actual bounds are also
considered targetting the root.
* Fix broken unit test, add new unit tests.
Change-Id: Id96a06a8763d02845af4531a47fe32afe703df2f
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java')
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java new file mode 100644 index 0000000..77f5c22 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/MergeRule.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.eclipse.org/org/documents/epl-v10.php + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.common.layout; + +import com.android.ide.common.api.INode; +import com.android.ide.common.api.MenuAction; + +import java.util.List; + +/** + * Drop handler for the {@code <merge>} tag + */ +public class MergeRule extends FrameLayoutRule { + // The <merge> tag behaves a lot like the FrameLayout; all children are added + // on top of each other at (0,0) + + @Override + public List<MenuAction> getContextMenu(INode selectedNode) { + // Deliberately ignore super.getContextMenu(); we don't want to attempt to list + // properties for the <merge> tag + return null; + } +} |