From 712a7f9d3b2a5b22a2b33017a3c959e6faa33973 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 22 Feb 2012 14:40:26 +0200 Subject: [PATCH] Further reduce the size calculations for VFilterSelect (#8313) --- .../VAADIN/themes/reindeer/select/select.css | 3 +- .../terminal/gwt/client/ui/VFilterSelect.java | 61 +++---------------- 2 files changed, 11 insertions(+), 53 deletions(-) diff --git a/WebContent/VAADIN/themes/reindeer/select/select.css b/WebContent/VAADIN/themes/reindeer/select/select.css index 4b444262fe..903066e4ab 100644 --- a/WebContent/VAADIN/themes/reindeer/select/select.css +++ b/WebContent/VAADIN/themes/reindeer/select/select.css @@ -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 */ diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index ec5f90e812..83956ecf03 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -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; } /** -- 2.39.5