use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class WidgetNavigatorPanel method updateComponents.
/**
* Set the selected component. If no component is selected, it will set the root of the previous selected component as the selected one
*
* @param selectedComponents
*/
public void updateComponents(@Nullable List<NlComponent> selectedComponents) {
if (selectedComponents != null && !selectedComponents.isEmpty()) {
myComponent = selectedComponents.get(0);
} else if (myComponent != null) {
// If not component are selected, displays the full screen
myComponent = myComponent.getRoot();
} else if (myDesignSurface != null) {
final ScreenView currentScreenView = myDesignSurface.getCurrentScreenView();
if (currentScreenView != null) {
final List<NlComponent> components = currentScreenView.getModel().getComponents();
myComponent = !components.isEmpty() ? components.get(0) : null;
}
}
myMiniMap.repaint();
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class WidgetConstraintPanel method setVerticalBias.
public void setVerticalBias() {
float bias = 1f - (mVerticalSlider.getValue() / 100f);
NlComponent component = mComponent;
if (NlComponentUtils.isVerticalChain(mComponent)) {
component = NlComponentUtils.getTopMostInChain(mComponent);
}
setSherpaAttribute(SdkConstants.ATTR_LAYOUT_VERTICAL_BIAS, Float.toString(bias));
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class WidgetConstraintPanel method configureUI.
/**
* This loads the parameters form component the ConstraintWidget
*/
private void configureUI() {
if (mComponent == null) {
return;
}
mConfiguringUI = true;
final String sherpaNamespace = SdkConstants.SHERPA_URI;
int top = getMargin(CONNECTION_TOP);
int left = getMargin(CONNECTION_LEFT);
int right = getMargin(CONNECTION_RIGHT);
int bottom = getMargin(CONNECTION_BOTTOM);
String ratioString = mComponent.getLiveAttribute(sherpaNamespace, SdkConstants.ATTR_LAYOUT_DIMENSION_RATIO);
String horizontalBias = mComponent.getLiveAttribute(sherpaNamespace, SdkConstants.ATTR_LAYOUT_HORIZONTAL_BIAS);
String verticalBias = mComponent.getLiveAttribute(sherpaNamespace, SdkConstants.ATTR_LAYOUT_VERTICAL_BIAS);
boolean baseline = hasBaseline();
boolean showVerticalSlider = bottom != UNCONNECTED && top != UNCONNECTED;
boolean showHorizontalSlider = left != UNCONNECTED && right != UNCONNECTED;
if (showHorizontalSlider) {
if (NlComponentUtils.isHorizontalChain(mComponent)) {
NlComponent ctl = NlComponentUtils.getLeftMostInChain(mComponent);
horizontalBias = ctl.getLiveAttribute(sherpaNamespace, SdkConstants.ATTR_LAYOUT_HORIZONTAL_BIAS);
}
float bias = parseFloat(horizontalBias, 0.5f);
mHorizontalSlider.setValue((int) (bias * 100));
}
if (showVerticalSlider) {
if (NlComponentUtils.isVerticalChain(mComponent)) {
NlComponent ctl = NlComponentUtils.getTopMostInChain(mComponent);
verticalBias = ctl.getLiveAttribute(sherpaNamespace, SdkConstants.ATTR_LAYOUT_VERTICAL_BIAS);
}
float bias = parseFloat(verticalBias, 0.5f);
mVerticalSlider.setValue(100 - (int) (bias * 100));
}
mVerticalSlider.setEnabled(showVerticalSlider);
mHorizontalSlider.setEnabled(showHorizontalSlider);
mHorizontalSlider.invalidate();
mVerticalSlider.invalidate();
mVerticalSlider.setToolTipText(showVerticalSlider ? VERTICAL_TOOL_TIP_TEXT : null);
mHorizontalSlider.setToolTipText(showHorizontalSlider ? HORIZONTAL_TOOL_TIP_TEXT : null);
int widthValue = convertFromNL(SdkConstants.ATTR_LAYOUT_WIDTH);
int heightValue = convertFromNL(SdkConstants.ATTR_LAYOUT_HEIGHT);
mMain.configureUi(bottom, top, left, right, baseline, widthValue, heightValue, ratioString);
mConfiguringUI = false;
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class WidgetConstraintPanel method setHorizontalBias.
public void setHorizontalBias() {
float bias = (mHorizontalSlider.getValue() / 100f);
NlComponent component = mComponent;
if (NlComponentUtils.isHorizontalChain(mComponent)) {
component = NlComponentUtils.getLeftMostInChain(mComponent);
}
setSherpaAttribute(SdkConstants.ATTR_LAYOUT_HORIZONTAL_BIAS, Float.toString(bias));
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class GridInfo method getSize.
@AndroidCoordinate
private Dimension getSize() {
Dimension size = new Dimension();
if (layout.children != null) {
Insets padding = layout.getPadding();
for (NlComponent child : layout.children) {
size.width = Math.max(child.x - layout.x - padding.left + child.w, size.width);
size.height = Math.max(child.y - layout.y - padding.top + child.h, size.height);
}
}
return size;
}
Aggregations