• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.ide.common.layout;
17 
18 import static com.android.ide.common.layout.LayoutConstants.FQCN_TABLE_LAYOUT;
19 
20 import com.android.ide.common.api.DropFeedback;
21 import com.android.ide.common.api.INode;
22 import com.android.ide.common.api.IViewRule;
23 import com.android.ide.common.api.InsertType;
24 import com.android.ide.common.api.RuleAction;
25 import com.android.ide.common.api.SegmentType;
26 
27 import java.util.List;
28 
29 /**
30  * An {@link IViewRule} for android.widget.TableRow.
31  */
32 public class TableRowRule extends LinearLayoutRule {
33     @Override
isVertical(INode node)34     protected boolean isVertical(INode node) {
35         return false;
36     }
37 
38     @Override
supportsOrientation()39     protected boolean supportsOrientation() {
40         return false;
41     }
42 
43     @Override
onChildInserted(INode child, INode parent, InsertType insertType)44     public void onChildInserted(INode child, INode parent, InsertType insertType) {
45         // Overridden to inhibit the setting of layout_width/layout_height since
46         // the table row will enforce match_parent and wrap_content for width and height
47         // respectively.
48     }
49 
50     @Override
addLayoutActions(List<RuleAction> actions, final INode parentNode, final List<? extends INode> children)51     public void addLayoutActions(List<RuleAction> actions, final INode parentNode,
52             final List<? extends INode> children) {
53         super.addLayoutActions(actions, parentNode, children);
54 
55         // Also apply table-specific actions on the table row such that you can
56         // select something in a table row and still get offered actions on the surrounding
57         // table.
58         if (children != null) {
59             INode grandParent = parentNode.getParent();
60             if (grandParent != null && grandParent.getFqcn().equals(FQCN_TABLE_LAYOUT)) {
61                 TableLayoutRule.addTableLayoutActions(mRulesEngine, actions, grandParent,
62                         children);
63             }
64         }
65     }
66 
67     @Override
onResizeBegin(INode child, INode parent, SegmentType horizontalEdge, SegmentType verticalEdge, Object childView, Object parentView)68     public DropFeedback onResizeBegin(INode child, INode parent, SegmentType horizontalEdge,
69             SegmentType verticalEdge, Object childView, Object parentView) {
70         // No resizing in TableRows; the width is *always* match_parent and the height is
71         // *always* wrap_content.
72         return null;
73     }
74 }
75