Search in sources :

Example 1 with DEFAULT_GALLERY_THUMBNAIL_SIZE

use of com.android.tools.idea.wizard.WizardConstants.DEFAULT_GALLERY_THUMBNAIL_SIZE in project android by JetBrains.

the class ChooseModuleTypeStep method createGallery.

@NotNull
private JComponent createGallery() {
    myFormFactorGallery = new ASGallery<ModuleGalleryEntry>(JBList.createDefaultListModel(), image -> image.getIcon() == null ? null : IconUtil.toImage(image.getIcon()), label -> label == null ? message("android.wizard.gallery.item.none") : label.getName(), DEFAULT_GALLERY_THUMBNAIL_SIZE, null) {

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            // The default implementations assigns a height as tall as the screen.
            // When calling setVisibleRowCount(2), the underlying implementation is buggy, and  will have a gap on the right and when the user
            // resizes, it enters on an adjustment loop at some widths (can't decide to fit 3 or for elements, and loops between the two)
            Dimension cellSize = computeCellSize();
            int heightInsets = getInsets().top + getInsets().bottom;
            int widthInsets = getInsets().left + getInsets().right;
            // Don't want to show an exact number of rows, since then it's not obvious there's another row available.
            return new Dimension(cellSize.width * 5 + widthInsets, (int) (cellSize.height * 2.2) + heightInsets);
        }
    };
    myFormFactorGallery.setBorder(BorderFactory.createLineBorder(JBColor.border()));
    AccessibleContext accessibleContext = myFormFactorGallery.getAccessibleContext();
    if (accessibleContext != null) {
        accessibleContext.setAccessibleDescription(getTitle());
    }
    return new JBScrollPane(myFormFactorGallery);
}
Also used : JBList(com.intellij.ui.components.JBList) AndroidBundle.message(org.jetbrains.android.util.AndroidBundle.message) FormScalingUtil(com.android.tools.swing.util.FormScalingUtil) java.util(java.util) ATTR_INCLUDE_FORM_FACTOR(com.android.tools.idea.templates.TemplateMetadata.ATTR_INCLUDE_FORM_FACTOR) FormFactor(com.android.tools.idea.npw.FormFactor) StringUtil(com.intellij.openapi.util.text.StringUtil) HashMap(com.intellij.util.containers.HashMap) ModelWizard(com.android.tools.idea.wizard.model.ModelWizard) AccessibleContext(javax.accessibility.AccessibleContext) ModelWizardStep(com.android.tools.idea.wizard.model.ModelWizardStep) ActionEvent(java.awt.event.ActionEvent) ASGallery(com.android.tools.idea.ui.ASGallery) JBScrollPane(com.intellij.ui.components.JBScrollPane) SkippableWizardStep(com.android.tools.idea.wizard.model.SkippableWizardStep) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Lists(com.google.common.collect.Lists) DEFAULT_GALLERY_THUMBNAIL_SIZE(com.android.tools.idea.wizard.WizardConstants.DEFAULT_GALLERY_THUMBNAIL_SIZE) NotNull(org.jetbrains.annotations.NotNull) JBColor(com.intellij.ui.JBColor) IconUtil(com.intellij.util.IconUtil) javax.swing(javax.swing) AccessibleContext(javax.accessibility.AccessibleContext) JBScrollPane(com.intellij.ui.components.JBScrollPane) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FormFactor (com.android.tools.idea.npw.FormFactor)1 ATTR_INCLUDE_FORM_FACTOR (com.android.tools.idea.templates.TemplateMetadata.ATTR_INCLUDE_FORM_FACTOR)1 ASGallery (com.android.tools.idea.ui.ASGallery)1 DEFAULT_GALLERY_THUMBNAIL_SIZE (com.android.tools.idea.wizard.WizardConstants.DEFAULT_GALLERY_THUMBNAIL_SIZE)1 ModelWizard (com.android.tools.idea.wizard.model.ModelWizard)1 ModelWizardStep (com.android.tools.idea.wizard.model.ModelWizardStep)1 SkippableWizardStep (com.android.tools.idea.wizard.model.SkippableWizardStep)1 FormScalingUtil (com.android.tools.swing.util.FormScalingUtil)1 Lists (com.google.common.collect.Lists)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 JBColor (com.intellij.ui.JBColor)1 JBList (com.intellij.ui.components.JBList)1 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 IconUtil (com.intellij.util.IconUtil)1 HashMap (com.intellij.util.containers.HashMap)1 java.awt (java.awt)1 ActionEvent (java.awt.event.ActionEvent)1 java.util (java.util)1 List (java.util.List)1 AccessibleContext (javax.accessibility.AccessibleContext)1