Search in sources :

Example 11 with ViewGroupHandler

use of com.android.tools.idea.uibuilder.api.ViewGroupHandler in project android by JetBrains.

the class ResizeInteraction method begin.

@Override
public void begin(@SwingCoordinate int x, @SwingCoordinate int y, @InputEventMask int startMask) {
    super.begin(x, y, startMask);
    NlComponent parent = myComponent.getParent();
    if (parent != null) {
        ViewGroupHandler viewGroupHandler = ViewHandlerManager.get(myScreenView.getModel().getFacet()).findLayoutHandler(parent, false);
        if (viewGroupHandler != null) {
            ViewEditor editor = new ViewEditorImpl(myScreenView);
            myResizeHandler = viewGroupHandler.createResizeHandler(editor, myComponent, myHorizontalEdge, myVerticalEdge);
            if (myResizeHandler != null) {
                int androidX = Coordinates.getAndroidX(myScreenView, myStartX);
                int androidY = Coordinates.getAndroidY(myScreenView, myStartY);
                myResizeHandler.start(androidX, androidY, startMask);
            }
        }
    }
}
Also used : ViewEditor(com.android.tools.idea.uibuilder.api.ViewEditor) ViewGroupHandler(com.android.tools.idea.uibuilder.api.ViewGroupHandler) ViewEditorImpl(com.android.tools.idea.uibuilder.handlers.ViewEditorImpl)

Example 12 with ViewGroupHandler

use of com.android.tools.idea.uibuilder.api.ViewGroupHandler in project android by JetBrains.

the class SceneDeleteWidgetTest method testDelete.

public void testDelete() {
    SceneComponent layout = myScene.getSceneComponent("root");
    NlComponent layoutComponent = layout.getNlComponent();
    ViewGroupHandler handler = (ViewGroupHandler) layoutComponent.getViewHandler();
    ArrayList<NlComponent> deleted = new ArrayList<>();
    deleted.add(myScene.getSceneComponent("button2").getNlComponent());
    handler.deleteChildren(layoutComponent, deleted);
    myScreen.get("@id/button").expectXml("<TextView\n" + "    android:id=\"@id/button\"\n" + "    android:layout_width=\"100dp\"\n" + "    android:layout_height=\"50dp\"\n" + "      app:layout_constraintLeft_toLeftOf=\"parent\"\n" + "    android:layout_marginLeft=\"8dp\"\n" + "      tools:layout_editor_absoluteY=\"185dp\" />");
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) ArrayList(java.util.ArrayList) ViewGroupHandler(com.android.tools.idea.uibuilder.api.ViewGroupHandler)

Example 13 with ViewGroupHandler

use of com.android.tools.idea.uibuilder.api.ViewGroupHandler in project android by JetBrains.

the class PreferenceScreenDragHandlerTest method newPreferenceScreenDragHandler.

@NotNull
private static PreferenceGroupDragHandler newPreferenceScreenDragHandler(@NotNull NlComponent group) {
    ViewEditor editor = PreferenceScreenTestFactory.mockEditor();
    List<NlComponent> preferences = Collections.singletonList(Mockito.mock(NlComponent.class));
    return new PreferenceScreenDragHandler(editor, new ViewGroupHandler(), group, preferences, DragType.MOVE);
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) ViewEditor(com.android.tools.idea.uibuilder.api.ViewEditor) ViewGroupHandler(com.android.tools.idea.uibuilder.api.ViewGroupHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ViewGroupHandler

use of com.android.tools.idea.uibuilder.api.ViewGroupHandler in project android by JetBrains.

the class PreferenceCategoryDragHandlerTest method newPreferenceCategoryDragHandler.

@NotNull
private static PreferenceGroupDragHandler newPreferenceCategoryDragHandler(@NotNull NlComponent category) {
    ViewEditor editor = PreferenceScreenTestFactory.mockEditor();
    List<NlComponent> preferences = Collections.singletonList(Mockito.mock(NlComponent.class));
    return new PreferenceCategoryDragHandler(editor, new ViewGroupHandler(), category, preferences, DragType.MOVE);
}
Also used : NlComponent(com.android.tools.idea.uibuilder.model.NlComponent) ViewEditor(com.android.tools.idea.uibuilder.api.ViewEditor) ViewGroupHandler(com.android.tools.idea.uibuilder.api.ViewGroupHandler) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ViewGroupHandler (com.android.tools.idea.uibuilder.api.ViewGroupHandler)14 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)9 ViewHandler (com.android.tools.idea.uibuilder.api.ViewHandler)6 ViewEditor (com.android.tools.idea.uibuilder.api.ViewEditor)5 ViewEditorImpl (com.android.tools.idea.uibuilder.handlers.ViewEditorImpl)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 ViewInfo (com.android.ide.common.rendering.api.ViewInfo)1 InsertType (com.android.tools.idea.uibuilder.api.InsertType)1 ScrollHandler (com.android.tools.idea.uibuilder.api.ScrollHandler)1 ComponentDescriptor (com.android.tools.idea.uibuilder.fixtures.ComponentDescriptor)1 ViewHandlerManager (com.android.tools.idea.uibuilder.handlers.ViewHandlerManager)1 AdViewHandler (com.android.tools.idea.uibuilder.handlers.google.AdViewHandler)1 MapViewHandler (com.android.tools.idea.uibuilder.handlers.google.MapViewHandler)1 NlModel (com.android.tools.idea.uibuilder.model.NlModel)1 FontRenderContext (java.awt.font.FontRenderContext)1 Rectangle2D (java.awt.geom.Rectangle2D)1