diff options
author | Tor Norbye <tnorbye@google.com> | 2012-08-07 11:48:03 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-08-08 15:18:48 -0700 |
commit | 0cb8e647ef345f5c2a6b7eb08b517421131bca4e (patch) | |
tree | 0952bed29c8c937cb6a2e0a6339efbe234e3e9a7 /rule_api | |
parent | 880f28a8a6f1abde140e5a201e5d38f62a8db1ae (diff) | |
download | sdk-0cb8e647ef345f5c2a6b7eb08b517421131bca4e.zip sdk-0cb8e647ef345f5c2a6b7eb08b517421131bca4e.tar.gz sdk-0cb8e647ef345f5c2a6b7eb08b517421131bca4e.tar.bz2 |
Improvements to relative layout move and delete operations
This changeset improves the way the RelativeLayout editing support in
the layout editor handles deletions and moves.
First, during a move, if the move is simply within the same layout,
then the layout constraints are left alone such that if you for
example have
A
v
B < C < D
and you move B up to be next to A, you end up with
A < B < C < D
(It will however remove cycles if the move would result in them.)
Second, it now handles deletion better where deleting a view will
cause all references to any deleted views to be replaced by transitive
constraints.
For example, if you hve
A < B < C < D
and you delete B and C, you end up with
A < D
Change-Id: Icb9d3552e60aee20192f7941fe52be71ba52557f
Diffstat (limited to 'rule_api')
-rw-r--r-- | rule_api/src/com/android/ide/common/api/AbstractViewRule.java | 40 | ||||
-rw-r--r-- | rule_api/src/com/android/ide/common/api/IViewRule.java | 29 |
2 files changed, 41 insertions, 28 deletions
diff --git a/rule_api/src/com/android/ide/common/api/AbstractViewRule.java b/rule_api/src/com/android/ide/common/api/AbstractViewRule.java index 7f05809..068580f 100644 --- a/rule_api/src/com/android/ide/common/api/AbstractViewRule.java +++ b/rule_api/src/com/android/ide/common/api/AbstractViewRule.java @@ -47,8 +47,6 @@ public class AbstractViewRule implements IViewRule { return null; } - // ==== Selection ==== - @Override @Nullable public List<String> getSelectionHint(@NonNull INode parentNode, @NonNull INode childNode) { @@ -69,12 +67,10 @@ public class AbstractViewRule implements IViewRule { @NonNull List<? extends INode> childNodes, @Nullable Object view) { } - // ==== Drag & drop support ==== - - // By default Views do not accept drag'n'drop. @Override @Nullable - public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, @Nullable IDragElement[] elements) { + public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView, + @Nullable IDragElement[] elements) { return null; } @@ -86,7 +82,8 @@ public class AbstractViewRule implements IViewRule { } @Override - public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements, @Nullable DropFeedback feedback) { + public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements, + @Nullable DropFeedback feedback) { // ignore } @@ -101,39 +98,42 @@ public class AbstractViewRule implements IViewRule { @Override - public void onPaste(@NonNull INode targetNode, @Nullable Object targetView, @NonNull IDragElement[] pastedElements) { + public void onPaste(@NonNull INode targetNode, @Nullable Object targetView, + @NonNull IDragElement[] pastedElements) { } - // ==== Create/Remove hooks ==== - @Override - public void onCreate(@NonNull INode node, @NonNull INode parent, @NonNull InsertType insertType) { + public void onCreate(@NonNull INode node, @NonNull INode parent, + @NonNull InsertType insertType) { } @Override - public void onChildInserted(@NonNull INode child, @NonNull INode parent, @NonNull InsertType insertType) { + public void onChildInserted(@NonNull INode child, @NonNull INode parent, + @NonNull InsertType insertType) { } @Override - public void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent) { + public void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent, + boolean moved) { } - // ==== Resizing ==== - @Override @Nullable - public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent, @Nullable SegmentType horizontalEdge, - @Nullable SegmentType verticalEdge, @Nullable Object childView, @Nullable Object parentView) { + public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent, + @Nullable SegmentType horizontalEdge, + @Nullable SegmentType verticalEdge, @Nullable Object childView, + @Nullable Object parentView) { return null; } @Override - public void onResizeUpdate(@Nullable DropFeedback feedback, @NonNull INode child, @NonNull INode parent, @NonNull Rect newBounds, + public void onResizeUpdate(@Nullable DropFeedback feedback, @NonNull INode child, + @NonNull INode parent, @NonNull Rect newBounds, int modifierMask) { } @Override - public void onResizeEnd(@Nullable DropFeedback feedback, @NonNull INode child, final @NonNull INode parent, - final @NonNull Rect newBounds) { + public void onResizeEnd(@Nullable DropFeedback feedback, @NonNull INode child, + @NonNull INode parent, @NonNull Rect newBounds) { } } diff --git a/rule_api/src/com/android/ide/common/api/IViewRule.java b/rule_api/src/com/android/ide/common/api/IViewRule.java index c115795..b16df26 100644 --- a/rule_api/src/com/android/ide/common/api/IViewRule.java +++ b/rule_api/src/com/android/ide/common/api/IViewRule.java @@ -298,19 +298,32 @@ public interface IViewRule { @NonNull InsertType insertType); /** - * Called when one or more children are about to be deleted by the user. Note that - * children deleted programmatically from view rules (via + * Called when one or more children are about to be deleted by the user. + * Note that children deleted programmatically from view rules (via * {@link INode#removeChild(INode)}) will not notify about deletion. * <p> - * Note that this method will be called under an edit lock, so rules can directly - * add/remove nodes and attributes as part of the deletion handling (and their - * actions will be part of the same undo-unit.) + * Note that this method will be called under an edit lock, so rules can + * directly add/remove nodes and attributes as part of the deletion handling + * (and their actions will be part of the same undo-unit.) + * <p> + * Note that when children are moved (such as when you drag a child within a + * LinearLayout to move it from one position among the children to another), + * that will also result in a + * {@link #onChildInserted(INode, INode, InsertType)} (with the + * {@code InsertType} set to {@link InsertType#MOVE_WITHIN}) and a remove + * via this {@link #onRemovingChildren(List, INode, boolean)} method. When + * the deletion is occurring as part of a local move (insert + delete), the + * {@code moved} parameter to this method is set to true. * * @param deleted a nonempty list of children about to be deleted - * @param parent the parent of the deleted children (which still contains the children - * since this method is called before the deletion is performed) + * @param parent the parent of the deleted children (which still contains + * the children since this method is called before the deletion + * is performed) + * @param moved when true, the nodes are being deleted as part of a local + * move (where copies are inserted elsewhere) */ - void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent); + void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent, + boolean moved); /** * Called by the IDE on the parent layout when a child widget is being resized. This |