use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class ActionBar method getBounds.
@Nullable
private static Rectangle getBounds(@NotNull List<NlComponent> items) {
if (items.isEmpty()) {
return null;
}
NlComponent firstItem = items.get(0);
Rectangle bounds = new Rectangle(firstItem.x, firstItem.y, firstItem.w, firstItem.h);
items.subList(1, items.size()).forEach(item -> bounds.add(new Rectangle(item.x, item.y, item.w, item.h)));
return bounds;
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class GroupDragHandler method drawOverflowGroupDropZoneLines.
private void drawOverflowGroupDropZoneLines(@NotNull NlGraphics graphics) {
List<NlComponent> overflowItems = myActionBar.getOverflowItems();
int midpointY = myActiveItem.getMidpointY();
graphics.useStyle(NlDrawingStyle.DROP_ZONE);
for (int i = 1, size = overflowItems.size(); i < size; i++) {
NlComponent item = overflowItems.get(i);
if (myActiveItem == overflowItems.get(i - 1)) {
if (lastY < midpointY) {
graphics.drawTop(item);
}
} else if (myActiveItem == item) {
if (lastY >= midpointY) {
graphics.drawTop(item);
}
} else {
graphics.drawTop(item);
}
}
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class IdAnalyzer method reserveAllIdsWithTransitiveReferencesToSelectedIds.
// Avoid creating a circular list of references
private void reserveAllIdsWithTransitiveReferencesToSelectedIds(@NotNull NlComponent parent) {
Multimap<String, String> referenceMap = HashMultimap.create();
for (NlComponent component : parent.getChildren()) {
String id = component.getId();
if (!StringUtil.isEmpty(id)) {
for (String attribute : myPropertyGroup.myAttributes) {
String referenced = NlComponent.stripId(component.getAttribute(myPropertyGroup.myNamespace, attribute));
if (referenced != null) {
referenceMap.put(referenced, id);
}
}
}
}
Set<String> references = new HashSet<>(myReservedIds);
while (!references.isEmpty()) {
String reference = references.iterator().next();
references.remove(reference);
myReservedIds.add(reference);
referenceMap.get(reference).stream().filter(id -> !myReservedIds.contains(id)).forEach(references::add);
}
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class SceneDragHandler method commit.
@Override
public void commit(@AndroidCoordinate int x, @AndroidCoordinate int y, int modifiers, @NotNull InsertType insertType) {
Scene scene = ((ViewEditorImpl) editor).getScreenView().getScene();
if (myComponent != null) {
NlComponent nlComponent = components.get(0);
NlComponent root = nlComponent.getRoot();
root.ensureNamespace(SdkConstants.SHERPA_PREFIX, SdkConstants.AUTO_URI);
SceneComponent component = scene.getSceneComponent(myComponent);
if (component != null) {
ArrayList<Target> targets = component.getTargets();
int dx = x - myComponent.w / 2;
int dy = y - myComponent.h / 2;
for (int i = 0; i < targets.size(); i++) {
if (targets.get(i) instanceof DragDndTarget) {
DragDndTarget target = (DragDndTarget) targets.get(i);
target.mouseRelease(scene.pxToDp(dx), scene.pxToDp(dy), nlComponent);
break;
}
}
}
}
insertComponents(-1, insertType);
scene.setDnDComponent(null);
scene.checkRequestLayoutStatus();
}
use of com.android.tools.idea.uibuilder.model.NlComponent in project android by JetBrains.
the class IdInspectorProviderTest method mockComponentWithTag.
private static NlComponent mockComponentWithTag(@NotNull String tagName) {
NlComponent component = mock(NlComponent.class);
when(component.getTagName()).thenReturn(tagName);
return component;
}
Aggregations