Search in sources :

Example 1 with CFG_DEVICE

use of com.android.tools.idea.configurations.ConfigurationListener.CFG_DEVICE in project android by JetBrains.

the class Scene method add.

/**
   * Add the NlComponents contained in the given NlModel to the Scene
   *
   * @param model the NlModel to use
   */
public void add(@NotNull NlModel model) {
    ConfigurationListener listener = (flags) -> {
        if ((flags & CFG_DEVICE) != 0 && !isManualDpiFactor) {
            float newDpiFactor = model.getConfiguration().getDensity().getDpiValue() / 160f;
            if (myDpiFactor != newDpiFactor) {
                // Update from the model to update the dpi
                updateFrom(model);
            }
        }
        return true;
    };
    model.getConfiguration().addListener(listener);
    Disposer.register(model, () -> model.getConfiguration().removeListener(listener));
    List<NlComponent> components = model.getComponents();
    if (components.size() != 0) {
        NlComponent rootComponent = components.get(0).getRoot();
        myAnimate = false;
        myRoot = updateFromComponent(rootComponent);
        myAnimate = true;
        addTargets(myRoot);
    }
    model.addListener(this);
    myModel = model;
    // let's make sure the selection is correct
    if (myScreenView != null) {
        selectionChanged(myScreenView.getSelectionModel(), myScreenView.getSelectionModel().getSelection());
    }
}
Also used : ConfigurationListener(com.android.tools.idea.configurations.ConfigurationListener) ViewGroupHandler(com.android.tools.idea.uibuilder.api.ViewGroupHandler) InputEvent(java.awt.event.InputEvent) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) java.util(java.util) SdkConstants(com.android.SdkConstants) com.android.tools.idea.uibuilder.scene.target(com.android.tools.idea.uibuilder.scene.target) ConfigurationListener(com.android.tools.idea.configurations.ConfigurationListener) java.awt(java.awt) VisibleForTesting(com.android.annotations.VisibleForTesting) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) com.android.tools.idea.uibuilder.model(com.android.tools.idea.uibuilder.model) ScreenView(com.android.tools.idea.uibuilder.surface.ScreenView) ConstraintLayoutHandler(com.android.tools.idea.uibuilder.handlers.constraint.ConstraintLayoutHandler) Disposer(com.intellij.openapi.util.Disposer) ViewHandler(com.android.tools.idea.uibuilder.api.ViewHandler) ApplicationManager(com.intellij.openapi.application.ApplicationManager) DisplayList(com.android.tools.idea.uibuilder.scene.draw.DisplayList) NotNull(org.jetbrains.annotations.NotNull) CFG_DEVICE(com.android.tools.idea.configurations.ConfigurationListener.CFG_DEVICE)

Aggregations

SdkConstants (com.android.SdkConstants)1 VisibleForTesting (com.android.annotations.VisibleForTesting)1 ConfigurationListener (com.android.tools.idea.configurations.ConfigurationListener)1 CFG_DEVICE (com.android.tools.idea.configurations.ConfigurationListener.CFG_DEVICE)1 ViewGroupHandler (com.android.tools.idea.uibuilder.api.ViewGroupHandler)1 ViewHandler (com.android.tools.idea.uibuilder.api.ViewHandler)1 ConstraintLayoutHandler (com.android.tools.idea.uibuilder.handlers.constraint.ConstraintLayoutHandler)1 com.android.tools.idea.uibuilder.model (com.android.tools.idea.uibuilder.model)1 DisplayList (com.android.tools.idea.uibuilder.scene.draw.DisplayList)1 com.android.tools.idea.uibuilder.scene.target (com.android.tools.idea.uibuilder.scene.target)1 ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 Disposer (com.intellij.openapi.util.Disposer)1 java.awt (java.awt)1 InputEvent (java.awt.event.InputEvent)1 java.util (java.util)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1