]> source.dussan.org Git - vaadin-framework.git/commitdiff
Further reduce the size calculations for VFilterSelect (#8313)
authorLeif Åstrand <leif@vaadin.com>
Wed, 22 Feb 2012 12:40:26 +0000 (14:40 +0200)
committerLeif Åstrand <leif@vaadin.com>
Wed, 22 Feb 2012 12:40:26 +0000 (14:40 +0200)
WebContent/VAADIN/themes/reindeer/select/select.css
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

index 4b444262fe5ee2ac0d044abc956933c5b84fe0fe..903066e4ab3d9f1e09b3a736020b86a921caa336 100644 (file)
@@ -3,6 +3,7 @@
        background-repeat: no-repeat;
        background-image: url(img/left.png); /** sprite-ref: verticals; sprite-margin-bottom: 1px */
        padding-left: 2px;
+       padding-right: 25px; /* Space for the button */
 }
 .v-app .v-filterselect-input,
 .v-window .v-filterselect-input,
@@ -17,7 +18,6 @@
 .v-window input.v-filterselect-input,
 .v-popupview-popup input.v-filterselect-input {
        padding: 4px 0 4px 2px;
-       width: 128px;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
 }
@@ -39,6 +39,7 @@
        height: 24px;
        background-image: url(img/right.png); /** sprite-ref: verticals ; sprite-margin-bottom: 1px */
        cursor: default;
+       margin-right: -25px;
 }
 .v-filterselect-button:hover {
        background-image: url(img/right-hover.png); /** sprite-ref: verticals */
index ec5f90e812d85d84de0ef8b2e277c29995de4bbe..83956ecf03efce281e8732df3459ec71c10eb01d 100644 (file)
@@ -46,7 +46,6 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.BrowserInfo;
 import com.vaadin.terminal.gwt.client.EventId;
 import com.vaadin.terminal.gwt.client.Focusable;
-import com.vaadin.terminal.gwt.client.MeasuredSize;
 import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.Util;
 import com.vaadin.terminal.gwt.client.VConsole;
@@ -1564,14 +1563,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
         VPaintableWidget paintable = VPaintableMap.get(client).getPaintable(
                 this);
         if (paintable.isUndefinedWidth()) {
-            /*
-             * When the width is not specified we must specify width for root
-             * div so the popupopener won't wrap to the next line and also so
-             * the size of the combobox won't change over time.
-             */
-            int tbWidth = Util.getRequiredWidth(tb);
-
-            int w = tbWidth + getNonTextboxSpace();
 
             /*
              * When the select has a undefined with we need to check that we are
@@ -1580,35 +1571,14 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
              * when the popup is used to view longer items than the text box is
              * wide.
              */
+            int w = Util.getRequiredWidth(this);
             if ((!initDone || currentPage + 1 < 0)
                     && suggestionPopupMinWidth > w) {
-                setTextboxWidth(suggestionPopupMinWidth);
+                setWidth(suggestionPopupMinWidth + "px");
             }
-
-        } else {
-            /*
-             * When the width is specified we also want to explicitly specify
-             * width for textbox
-             */
-            setTextboxWidth(getMainWidth());
-
         }
     }
 
-    /**
-     * Only use the first page popup width so the textbox will not get resized
-     * whenever the popup is resized. This also resolves issue where toggling
-     * combo box between read only and normal state makes it grow larger.
-     * 
-     * @return Width of popup opener
-     */
-    private int getPopUpOpenerWidth() {
-        if (popupWidth < 0) {
-            popupWidth = Util.getRequiredWidth(popupOpener);
-        }
-        return popupWidth;
-    }
-
     /**
      * Get the width of the select in pixels where the text area and icon has
      * been included.
@@ -1619,27 +1589,14 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
         return getOffsetWidth();
     }
 
-    /**
-     * Sets the text box width in pixels.
-     * 
-     * @param componentWidth
-     *            The width of the combo box in pixels
-     */
-    private void setTextboxWidth(int componentWidth) {
-        int extraSpace = getNonTextboxSpace();
-        int textboxWidth = componentWidth - extraSpace;
-        if (textboxWidth < 0) {
-            textboxWidth = 0;
+    @Override
+    public void setWidth(String width) {
+        super.setWidth(width);
+        if (width.length() == 0) {
+            tb.setWidth("");
+        } else {
+            tb.setWidth("100%");
         }
-        tb.setWidth(textboxWidth + "px");
-    }
-
-    private int getNonTextboxSpace() {
-        MeasuredSize measuredSize = VPaintableMap.get(client)
-                .getPaintable(this).getMeasuredSize();
-        int extraSpace = getPopUpOpenerWidth() + measuredSize.getPaddingWidth()
-                + measuredSize.getBorderWidth();
-        return extraSpace;
     }
 
     /**