From 6509f1a1e595b4d804aff9cee2262366ff63ff97 Mon Sep 17 00:00:00 2001 From: Daniel Kurka Date: Sat, 30 Aug 2014 21:19:32 +0200 Subject: [PATCH 01/53] [maven-release-plugin] prepare release 2.0.0-rc2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 66aef213a..be2f1bcf4 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.googlecode.mgwt mgwt - 2.0.0-SNAPSHOT + 2.0.0-rc2 jar mgwt From 13d22a9561b0b6f8037d0434aca1ea0f39f979fc Mon Sep 17 00:00:00 2001 From: Daniel Kurka Date: Sat, 30 Aug 2014 21:19:36 +0200 Subject: [PATCH 02/53] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index be2f1bcf4..66aef213a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.googlecode.mgwt mgwt - 2.0.0-rc2 + 2.0.0-SNAPSHOT jar mgwt From 68362f7a0c350fe2eb6fbd0aed5235c56942ee76 Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Sun, 31 Aug 2014 21:01:24 +0200 Subject: [PATCH 03/53] Add more editor support --- .../ui/client/editor/MValueBoxEditor.java | 112 ++++++++ .../editor/MValueBoxEditorDecorator.java | 241 +++++++++--------- .../ui/client/widget/input/MDoubleBox.java | 12 +- .../ui/client/widget/input/MIntegerBox.java | 12 +- .../mgwt/ui/client/widget/input/MLongBox.java | 12 +- 5 files changed, 262 insertions(+), 127 deletions(-) create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditor.java diff --git a/src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditor.java b/src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditor.java new file mode 100644 index 000000000..c840d79ee --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditor.java @@ -0,0 +1,112 @@ +/* + * Copyright 2014 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.editor; + +import java.text.ParseException; + +import com.google.gwt.editor.client.EditorDelegate; +import com.google.gwt.editor.client.HasEditorDelegate; +import com.google.gwt.editor.client.adapters.TakesValueEditor; +import com.google.gwt.user.client.ui.ValueBoxBase; +import com.googlecode.mgwt.ui.client.widget.base.MValueBoxBase; + +/** + * Adapts the {@link ValueBoxBase} interface to the Editor framework. This + * adapter uses {@link ValueBoxBase#getValueOrThrow()} to report parse errors to + * the Editor framework. + * + * @param + * the type of value to be edited + */ +public class MValueBoxEditor extends TakesValueEditor implements + HasEditorDelegate { + + /** + * Returns a new TakesValueEditor that adapts a {@link ValueBoxBase} instance. + * + * @param valueBox + * a {@link ValueBoxBase} instance to adapt + * @return a ValueBoxEditor instance of the same type as the adapted + * {@link ValueBoxBase} instance + */ + public static MValueBoxEditor of(MValueBoxBase valueBox) { + return new MValueBoxEditor(valueBox); + } + + private EditorDelegate delegate; + private final MValueBoxBase peer; + private T value; + + /** + * Constructs a new ValueBoxEditor that adapts a {@link ValueBoxBase} peer + * instance. + * + * @param peer + * a {@link ValueBoxBase} instance of type T + */ + protected MValueBoxEditor(MValueBoxBase peer) { + super(peer); + this.peer = peer; + } + + /** + * Returns the {@link EditorDelegate} for this instance. + * + * @return an {@link EditorDelegate}, or {@code null} + * @see #setDelegate(EditorDelegate) + */ + public EditorDelegate getDelegate() { + return delegate; + } + + /** + * Calls {@link ValueBoxBase#getValueOrThrow()}. If a {@link ParseException} + * is thrown, it will be available through + * {@link com.google.gwt.editor.client.EditorError#getUserData() + * EditorError.getUserData()}. + * + * @return a value of type T + * @see #setValue(Object) + */ + @Override + public T getValue() { + try { + value = peer.getValueOrThrow(); + } catch (ParseException e) { + // TODO i18n + getDelegate().recordError("Bad value (" + peer.getText() + ")", + peer.getText(), e); + } + return value; + } + + /** + * Sets the {@link EditorDelegate} for this instance. This method is only + * called by the driver. + * + * @param delegate + * an {@link EditorDelegate}, or {@code null} + * @see #getDelegate() + */ + public void setDelegate(EditorDelegate delegate) { + this.delegate = delegate; + } + + @Override + public void setValue(T value) { + peer.setValue(this.value = value); + } +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditorDecorator.java b/src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditorDecorator.java index a5ef8cc84..8007a6353 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditorDecorator.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/editor/MValueBoxEditorDecorator.java @@ -1,5 +1,17 @@ -/** - * +/* + * Copyright 2014 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. */ package com.googlecode.mgwt.ui.client.editor; @@ -27,7 +39,7 @@ * This MValueBoxEditorDecorator is more or less a copy clone of * {@link ValueBoxEditor} and is needed to do JSR-303 BeanValidation. Only * difference is the child added here must be of type {@link MValueBoxBase}. - * + * *

*

Use in UiBinder Templates

*

@@ -35,12 +47,12 @@ * <e:valuebox> child tag. *

* For example: - * + * *

  * @UiField
  * MValueBoxEditorDecorator<String> name;
  * 
- * + * *
  * <e:MValueBoxEditorDecorator ui:field='name'>
  *   <e:mvaluebox>
@@ -48,123 +60,122 @@
  *   </e:mvaluebox>
  * </e:MValueBoxEditorDecorator>
  * 
- * + * * @param * the type which is edited, i.e. String for {@link MTextBox}. - * + * * @author Christoph Guse - * + * */ public class MValueBoxEditorDecorator extends Composite implements - HasEditorErrors, IsEditor> { - - interface Binder extends UiBinder> { - Binder BINDER = GWT.create(Binder.class); - } - - private ValueBoxEditor editor; - - @UiField - SimplePanel contents; - - @UiField - DivElement errorLabel; - - /** - * Constructs a ValueBoxEditorDecorator, UI is taken from - * MValueBoxEditorDecorator.ui.xml. - */ - @UiConstructor - public MValueBoxEditorDecorator() { - initWidget(Binder.BINDER.createAndBindUi(this)); - } - - /** - * Constructs a ValueBoxEditorDecorator using a {@link ValueBoxBase} widget - * and a {@link ValueBoxEditor} editor. - * - * @param widget - * the widget - * @param editor - * the editor - */ - public MValueBoxEditorDecorator(MValueBoxBase widget, - ValueBoxEditor editor) { - this(); - contents.add(widget); - this.editor = editor; - } - - /** - * Returns the associated {@link ValueBoxEditor}. - * - * @return a {@link ValueBoxEditor} instance - * @see #setEditor(ValueBoxEditor) - */ - @Override - public ValueBoxEditor asEditor() { - return editor; - } - - /** - * Sets the associated {@link ValueBoxEditor}. - * - * @param editor - * a {@link ValueBoxEditor} instance - * @see #asEditor() - */ - public void setEditor(ValueBoxEditor editor) { - this.editor = editor; - } - - /** - * Set the widget that the EditorPanel will display. This method will - * automatically call {@link #setEditor}. - * - * @param widget - * a {@link ValueBoxBase} widget - */ - @UiChild(limit = 1, tagname = "mvaluebox") - public void setMValueBox(MValueBoxBase widget) { - contents.add(widget); - setEditor(widget.asEditor()); - } - - /** - * The default implementation will display, but not consume, received errors - * whose {@link EditorError#getEditor() getEditor()} method returns the - * Editor passed into {@link #setEditor}. - * - * @param errors - * a List of {@link EditorError} instances - */ - @Override - public void showErrors(List errors) { - StringBuilder sb = new StringBuilder(); - for (EditorError error : errors) { - if (error.getEditor().equals(editor)) { - sb.append("\n").append(error.getMessage()); - } - } - - if (sb.length() == 0) { - errorLabel.setInnerText(""); - errorLabel.getStyle().setDisplay(Display.NONE); - return; - } - - errorLabel.setInnerText(sb.substring(1)); - errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK); + HasEditorErrors, IsEditor> { + + interface Binder extends UiBinder> { + Binder BINDER = GWT.create(Binder.class); + } + + private ValueBoxEditor editor; + + @UiField + SimplePanel contents; + + @UiField + DivElement errorLabel; + + /** + * Constructs a ValueBoxEditorDecorator, UI is taken from + * MValueBoxEditorDecorator.ui.xml. + */ + @UiConstructor + public MValueBoxEditorDecorator() { + initWidget(Binder.BINDER.createAndBindUi(this)); + } + + /** + * Constructs a ValueBoxEditorDecorator using a {@link ValueBoxBase} widget + * and a {@link ValueBoxEditor} editor. + * + * @param widget + * the widget + * @param editor + * the editor + */ + public MValueBoxEditorDecorator(MValueBoxBase widget, + ValueBoxEditor editor) { + this(); + contents.add(widget); + this.editor = editor; + } + + /** + * Returns the associated {@link ValueBoxEditor}. + * + * @return a {@link ValueBoxEditor} instance + * @see #setEditor(ValueBoxEditor) + */ + @Override + public ValueBoxEditor asEditor() { + return editor; + } + + /** + * Sets the associated {@link ValueBoxEditor}. + * + * @param editor + * a {@link ValueBoxEditor} instance + * @see #asEditor() + */ + public void setEditor(ValueBoxEditor editor) { + this.editor = editor; + } + + /** + * Set the widget that the EditorPanel will display. This method will + * automatically call {@link #setEditor}. + * + * @param widget + * a {@link ValueBoxBase} widget + */ + @UiChild(limit = 1, tagname = "mvaluebox") + public void setMValueBox(MValueBoxBase widget) { + contents.add(widget); + setEditor(widget.asEditor()); + } + + /** + * The default implementation will display, but not consume, received errors + * whose {@link EditorError#getEditor() getEditor()} method returns the Editor + * passed into {@link #setEditor}. + * + * @param errors + * a List of {@link EditorError} instances + */ + @Override + public void showErrors(List errors) { + StringBuilder sb = new StringBuilder(); + for (EditorError error : errors) { + if (error.getEditor().equals(editor)) { + sb.append("\n").append(error.getMessage()); + } } - /** - * Shows the given error message. - * - * @param errorMessage - */ - public void showError(String errorMessage) { - errorLabel.setInnerText(errorMessage); - errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK); + if (sb.length() == 0) { + errorLabel.setInnerText(""); + errorLabel.getStyle().setDisplay(Display.NONE); + return; } + errorLabel.setInnerText(sb.substring(1)); + errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK); + } + + /** + * Shows the given error message. + * + * @param errorMessage + */ + public void showError(String errorMessage) { + errorLabel.setInnerText(errorMessage); + errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK); + } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java index b0bf7ff4e..93d4daf56 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Daniel Kurka - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -22,7 +22,7 @@ /** * A input box that accepts doubles - * + * * @author Daniel Kurka */ public class MDoubleBox extends MValueBoxBase { @@ -31,6 +31,10 @@ private static class SDoubleBox extends DoubleBox implements HasSource { private Object source; + public SDoubleBox() { + setStylePrimaryName("gwt-DoubleBox"); + } + @Override protected HandlerManager createHandlerManager() { return new HandlerManager(source); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java index 8c7cd1175..961900098 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Daniel Kurka - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -22,7 +22,7 @@ /** * An input element that handles integers - * + * * @author Daniel Kurka */ public class MIntegerBox extends MValueBoxBase { @@ -31,6 +31,10 @@ private static class SIntegerBox extends IntegerBox implements HasSource { private Object source; + public SIntegerBox() { + setStylePrimaryName("gwt-IntegerBox"); + } + @Override protected HandlerManager createHandlerManager() { return new HandlerManager(source); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java index 66ae4313a..08dc1a709 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Daniel Kurka - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -22,7 +22,7 @@ /** * An input element that handles longs - * + * * @author Daniel Kurka */ public class MLongBox extends MValueBoxBase { @@ -30,6 +30,10 @@ public class MLongBox extends MValueBoxBase { private static class SLongBox extends LongBox implements HasSource { private Object source; + public SLongBox() { + setStylePrimaryName("gwt-LongBox"); + } + @Override public void setSource(Object source) { this.source = source; From a64ba6d467ac5fddcb80af70c9126544b050848e Mon Sep 17 00:00:00 2001 From: Daniel Kurka Date: Mon, 1 Sep 2014 22:08:51 +0200 Subject: [PATCH 04/53] [maven-release-plugin] prepare release 2.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 66aef213a..f06313030 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.googlecode.mgwt mgwt - 2.0.0-SNAPSHOT + 2.0.0 jar mgwt From 7e46ed4e0b12cb7ddb6ab95acc3060e1a2b24b21 Mon Sep 17 00:00:00 2001 From: Daniel Kurka Date: Mon, 1 Sep 2014 22:09:39 +0200 Subject: [PATCH 05/53] [maven-release-plugin] rollback the release of 2.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f06313030..66aef213a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.googlecode.mgwt mgwt - 2.0.0 + 2.0.0-SNAPSHOT jar mgwt From f6f11ea2d2535d95bfc063b1792ba4da5b1a910b Mon Sep 17 00:00:00 2001 From: Daniel Kurka Date: Mon, 1 Sep 2014 22:13:29 +0200 Subject: [PATCH 06/53] [maven-release-plugin] prepare release 2.0.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 66aef213a..f06313030 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.googlecode.mgwt mgwt - 2.0.0-SNAPSHOT + 2.0.0 jar mgwt From 933f1c82d6b55510de20cbaff5ab81c0c3f51e8e Mon Sep 17 00:00:00 2001 From: Daniel Kurka Date: Mon, 1 Sep 2014 22:13:34 +0200 Subject: [PATCH 07/53] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f06313030..0e62cbf2c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.googlecode.mgwt mgwt - 2.0.0 + 2.0.1-SNAPSHOT jar mgwt From 4b207e2f111f2a6f9b278243d33130e1c8bb0790 Mon Sep 17 00:00:00 2001 From: Andrei Volgin Date: Tue, 2 Sep 2014 00:09:52 -0400 Subject: [PATCH 08/53] Fixed spelling error in the word "appearance". --- ...InputApperanceHolder.java => InputAppearanceHolder.java} | 6 +++--- .../googlecode/mgwt/ui/client/widget/input/MDateBox.java | 2 +- .../googlecode/mgwt/ui/client/widget/input/MDoubleBox.java | 2 +- .../mgwt/ui/client/widget/input/MEmailTextBox.java | 2 +- .../googlecode/mgwt/ui/client/widget/input/MIntegerBox.java | 2 +- .../googlecode/mgwt/ui/client/widget/input/MLongBox.java | 2 +- .../mgwt/ui/client/widget/input/MNumberTextBox.java | 2 +- .../mgwt/ui/client/widget/input/MPasswordTextBox.java | 2 +- .../mgwt/ui/client/widget/input/MPhoneNumberTextBox.java | 2 +- .../googlecode/mgwt/ui/client/widget/input/MTextArea.java | 2 +- .../googlecode/mgwt/ui/client/widget/input/MTextBox.java | 2 +- .../googlecode/mgwt/ui/client/widget/input/MUrlTextBox.java | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) rename src/main/java/com/googlecode/mgwt/ui/client/widget/input/{InputApperanceHolder.java => InputAppearanceHolder.java} (80%) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputApperanceHolder.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputAppearanceHolder.java similarity index 80% rename from src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputApperanceHolder.java rename to src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputAppearanceHolder.java index 2bdc8f96e..a013fbd54 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputApperanceHolder.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputAppearanceHolder.java @@ -17,9 +17,9 @@ import com.google.gwt.core.shared.GWT; -public class InputApperanceHolder { +public class InputAppearanceHolder { - public static final InputAppearance DEFAULT_APPERAERANCE = GWT.create(InputAppearance.class); + public static final InputAppearance DEFAULT_APPEARANCE = GWT.create(InputAppearance.class); - private InputApperanceHolder() {} + private InputAppearanceHolder() {} } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java index ee5507eb1..de73d5928 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java @@ -154,7 +154,7 @@ public Date parse(CharSequence text) throws ParseException { private DateTimeFormat format; public MDateBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MDateBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java index 93d4daf56..2c11cf0d6 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java @@ -46,7 +46,7 @@ public void setSource(Object source) { } public MDoubleBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MDoubleBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MEmailTextBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MEmailTextBox.java index 2a3c55d04..1aabba361 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MEmailTextBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MEmailTextBox.java @@ -24,7 +24,7 @@ public class MEmailTextBox extends MTextBox { public MEmailTextBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java index 961900098..89ca8a12f 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MIntegerBox.java @@ -48,7 +48,7 @@ public void setSource(Object source) { } public MIntegerBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MIntegerBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java index 08dc1a709..e68c2743f 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MLongBox.java @@ -47,7 +47,7 @@ protected HandlerManager createHandlerManager() { } public MLongBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MLongBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MNumberTextBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MNumberTextBox.java index d1ca04ef1..58e0af7d3 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MNumberTextBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MNumberTextBox.java @@ -24,7 +24,7 @@ public class MNumberTextBox extends MTextBox { public MNumberTextBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MNumberTextBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPasswordTextBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPasswordTextBox.java index e6b40f2c1..5da10c999 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPasswordTextBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPasswordTextBox.java @@ -40,7 +40,7 @@ protected HandlerManager createHandlerManager() { } public MPasswordTextBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MPasswordTextBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPhoneNumberTextBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPhoneNumberTextBox.java index 1fb01c792..74ed25421 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPhoneNumberTextBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MPhoneNumberTextBox.java @@ -24,7 +24,7 @@ public class MPhoneNumberTextBox extends MTextBox { public MPhoneNumberTextBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MPhoneNumberTextBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextArea.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextArea.java index bf2fc00e3..8730984f8 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextArea.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextArea.java @@ -45,7 +45,7 @@ protected HandlerManager createHandlerManager() { } public MTextArea() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MTextArea(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java index 79633f6e7..b3ddb7e5b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java @@ -43,7 +43,7 @@ protected HandlerManager createHandlerManager() { } public MTextBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MTextBox(InputAppearance appearance) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MUrlTextBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MUrlTextBox.java index 4dbfb4bc2..5e7639276 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MUrlTextBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MUrlTextBox.java @@ -21,7 +21,7 @@ */ public class MUrlTextBox extends MTextBox { public MUrlTextBox() { - this(InputApperanceHolder.DEFAULT_APPERAERANCE); + this(InputAppearanceHolder.DEFAULT_APPEARANCE); } public MUrlTextBox(InputAppearance appearance) { From 30c78c0e4692890c1119d4e6f57f57a04e8deca1 Mon Sep 17 00:00:00 2001 From: Andrei Volgin Date: Thu, 4 Sep 2014 00:09:06 -0400 Subject: [PATCH 09/53] Added "space-around" option to Justification. I see no reason to leave it out. --- .gitignore | 1 + .../mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0b9bf2965..57dab39f9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ mgwt.iml gwt-unitCache war/ www-test/ +/bin diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java index 4c71034e9..f729fe76b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java @@ -38,7 +38,7 @@ private String getCssValue() { } public static enum Justification { - START("flex-start"), END("flex-end"), CENTER("center"), SPACE_BETWEEN("space-between"); + START("flex-start"), END("flex-end"), CENTER("center"), SPACE_BETWEEN("space-between"), SPACE_AROUND("space-around"); private final String cssValue; @@ -148,6 +148,9 @@ public static void setJustification(Element el, Justification value) { case SPACE_BETWEEN: el.getStyle().setProperty("WebkitBoxPack", "justify"); break; + case SPACE_AROUND: + el.getStyle().setProperty("WebkitBoxPack", "justify"); + break; default: throw new RuntimeException(); } From 5075c0a76c37ff6c68fff26068b50dcd72bfc9b7 Mon Sep 17 00:00:00 2001 From: Andrei Volgin Date: Sat, 6 Sep 2014 03:23:40 -0400 Subject: [PATCH 10/53] Fixed spelling error. --- .../googlecode/mgwt/ui/generator/DeviceDensityGenerator.java | 2 +- .../com/googlecode/mgwt/ui/generator/FormFactorGenerator.java | 2 +- .../googlecode/mgwt/ui/generator/OsDetectionGenerator.java | 2 +- .../com/googlecode/mgwt/ui/generator/RebindingGenerator.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/generator/DeviceDensityGenerator.java b/src/main/java/com/googlecode/mgwt/ui/generator/DeviceDensityGenerator.java index d6083d7e1..5d2064059 100644 --- a/src/main/java/com/googlecode/mgwt/ui/generator/DeviceDensityGenerator.java +++ b/src/main/java/com/googlecode/mgwt/ui/generator/DeviceDensityGenerator.java @@ -31,7 +31,7 @@ */ public class DeviceDensityGenerator extends RebindingGenerator { - protected void writeImplementatioon(TreeLogger logger, SelectionProperty property, SourceWriter writer) { + protected void writeImplementation(TreeLogger logger, SelectionProperty property, SourceWriter writer) { writer.println("public boolean isMidDPI() {"); writer.println("return " + property.getCurrentValue().equals("mid") + ";"); writer.println("}"); diff --git a/src/main/java/com/googlecode/mgwt/ui/generator/FormFactorGenerator.java b/src/main/java/com/googlecode/mgwt/ui/generator/FormFactorGenerator.java index fb339bf02..fe2244ed4 100644 --- a/src/main/java/com/googlecode/mgwt/ui/generator/FormFactorGenerator.java +++ b/src/main/java/com/googlecode/mgwt/ui/generator/FormFactorGenerator.java @@ -32,7 +32,7 @@ public class FormFactorGenerator extends RebindingGenerator { @Override - protected void writeImplementatioon(TreeLogger logger, SelectionProperty property, + protected void writeImplementation(TreeLogger logger, SelectionProperty property, SourceWriter writer) { writer.println("public boolean isPhone() {"); writer.println("return " + property.getCurrentValue().equals("phone") + ";"); diff --git a/src/main/java/com/googlecode/mgwt/ui/generator/OsDetectionGenerator.java b/src/main/java/com/googlecode/mgwt/ui/generator/OsDetectionGenerator.java index ea51be5d7..9eacff4b5 100644 --- a/src/main/java/com/googlecode/mgwt/ui/generator/OsDetectionGenerator.java +++ b/src/main/java/com/googlecode/mgwt/ui/generator/OsDetectionGenerator.java @@ -30,7 +30,7 @@ public class OsDetectionGenerator extends RebindingGenerator { @Override - protected void writeImplementatioon(TreeLogger logger, SelectionProperty property, + protected void writeImplementation(TreeLogger logger, SelectionProperty property, SourceWriter writer) { writer.println("public boolean isAndroid() {"); writer.println("return isAndroidTablet() || isAndroidPhone();"); diff --git a/src/main/java/com/googlecode/mgwt/ui/generator/RebindingGenerator.java b/src/main/java/com/googlecode/mgwt/ui/generator/RebindingGenerator.java index 1ba9636d1..6891b54eb 100644 --- a/src/main/java/com/googlecode/mgwt/ui/generator/RebindingGenerator.java +++ b/src/main/java/com/googlecode/mgwt/ui/generator/RebindingGenerator.java @@ -71,13 +71,13 @@ public String generate(TreeLogger logger, GeneratorContext context, String typeN // start writing the implementation SourceWriter writer = writeHolder.composer.createSourceWriter(context, writeHolder.printWriter); - writeImplementatioon(logger, property, writer); + writeImplementation(logger, property, writer); return writeHolder.fullName; } protected abstract String getSelectionPropertyName(); - protected abstract void writeImplementatioon(TreeLogger logger, SelectionProperty property, SourceWriter writer); + protected abstract void writeImplementation(TreeLogger logger, SelectionProperty property, SourceWriter writer); private JClassType getClassType(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException { From 87b6344379641715fabde792e9cddbe8ab3c140d Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Tue, 16 Sep 2014 21:34:37 -0700 Subject: [PATCH 11/53] Fixed CSS typos in FlexPropertyHelper. --- .../mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java index f729fe76b..79ed4a360 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java @@ -84,13 +84,13 @@ public static void setFlex(Element el, double flex) { private static void setFlexProperty(Element el, String name, String value) { setStyleProperty(el, "MozFlex" + name, value); - setStyleProperty(el, "webkitFlex" + name, value); + setStyleProperty(el, "WebkitFlex" + name, value); setStyleProperty(el, "flex" + name, value); } private static void setProperty(Element el, String name, String value) { setStyleProperty(el, "Moz" + name, value); - setStyleProperty(el, "webkit" + name, value); + setStyleProperty(el, "Webkit" + name, value); setStyleProperty(el, name, value); } From 772855d547e6a36a7e6d1ca247aa584e0de2d87b Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Thu, 18 Sep 2014 21:11:42 -0700 Subject: [PATCH 12/53] Added missing ensureInjected calls. --- .../client/theme/platform/header/HeaderAndroidAppearance.java | 1 + .../list/celllist/GroupingCellListAndroidAppearance.java | 1 + .../platform/list/celllist/GroupingCellListIOSAppearance.java | 2 +- .../widget/list/celllist/GroupingCellListDefaultAppearance.java | 1 + .../ui/client/widget/panel/pull/PullPanelDefaultAppearance.java | 1 - 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/header/HeaderAndroidAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/header/HeaderAndroidAppearance.java index 9d69cd8c4..df3e99aef 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/header/HeaderAndroidAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/header/HeaderAndroidAppearance.java @@ -9,6 +9,7 @@ public class HeaderAndroidAppearance extends HeaderAbstractAppearance { static { Resources.INSTANCE.cssPanel().ensureInjected(); + Resources.INSTANCE.cssTitle().ensureInjected(); } interface CssPanel extends HeaderPanelCss {} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListAndroidAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListAndroidAppearance.java index 5b427aefc..e6acd2ecb 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListAndroidAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListAndroidAppearance.java @@ -10,6 +10,7 @@ public class GroupingCellListAndroidAppearance extends GroupingCellListAbstractA static { Resources.INSTANCE.css().ensureInjected(); + Resources.INSTANCE.groupCss().ensureInjected(); } interface Css extends CellListCss {} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListIOSAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListIOSAppearance.java index 3f31b0031..8bb359ae9 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListIOSAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/list/celllist/GroupingCellListIOSAppearance.java @@ -3,13 +3,13 @@ import com.google.gwt.core.shared.GWT; import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.DataResource; - import com.googlecode.mgwt.ui.client.widget.list.celllist.GroupingCellListAbstractAppearance; public class GroupingCellListIOSAppearance extends GroupingCellListAbstractAppearance { static { Resources.INSTANCE.css().ensureInjected(); + Resources.INSTANCE.groupCss().ensureInjected(); } interface Css extends CellListCss {} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/GroupingCellListDefaultAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/GroupingCellListDefaultAppearance.java index 9e96d5e3f..aff53525b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/GroupingCellListDefaultAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/GroupingCellListDefaultAppearance.java @@ -23,6 +23,7 @@ public class GroupingCellListDefaultAppearance extends GroupingCellListAbstractA static { Resources.INSTANCE.css().ensureInjected(); + Resources.INSTANCE.groupCss().ensureInjected(); } interface Resources extends ClientBundle { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/PullPanelDefaultAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/PullPanelDefaultAppearance.java index 3728a911e..59e7346b5 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/PullPanelDefaultAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/PullPanelDefaultAppearance.java @@ -37,7 +37,6 @@ interface Resources extends ClientBundle { @Source("error.png") ImageResource errorImage(); - } @Override From 3fd1752fb34429f43637fc29c577d1a75a1d6f7a Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Mon, 29 Sep 2014 21:14:05 -0700 Subject: [PATCH 13/53] Changed mgwt to work with GWT 2.7 --- .../com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java index 503fdc1d7..95bb61353 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java @@ -254,7 +254,6 @@ public void setSelectionRange(int pos, int length) { box.setSelectionRange(pos, length); } - @Override public void setText(String text) { box.setText(text); } From 0dea28ad6467b107105d6f9e7f30a616195a5d86 Mon Sep 17 00:00:00 2001 From: Wayne Dyck Date: Tue, 21 Oct 2014 16:43:35 -0700 Subject: [PATCH 14/53] Remove background image gradient. It's no longer used in iOS 7/8 theme. --- .../ui/client/theme/platform/input/search/searchbox-ios.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/input/search/searchbox-ios.css b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/input/search/searchbox-ios.css index a55e5a51a..0e7a3c1dc 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/input/search/searchbox-ios.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/input/search/searchbox-ios.css @@ -7,7 +7,7 @@ @if user.agent safari { .mgwt-SearchBox { - background-image: literal('-webkit-gradient(linear,left bottom,left top,color-stop(0, #A8ACB9),color-stop(1, #eee))'); + background-color: #C9C9CE; } } From ee3e638ff5a39bb9ab6a25dba7358bca8eab7021 Mon Sep 17 00:00:00 2001 From: Wayne Dyck Date: Wed, 22 Oct 2014 09:52:54 -0700 Subject: [PATCH 15/53] Correct spelling of appearance. --- .../widget/button/ImageButtonAbstractAppearance.ui.xml | 8 ++++---- .../ui/client/widget/button/ImageButtonAppearance.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAbstractAppearance.ui.xml b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAbstractAppearance.ui.xml index 80848cce8..2d3570f8e 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAbstractAppearance.ui.xml +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAbstractAppearance.ui.xml @@ -1,8 +1,8 @@ - -
-
-
+ +
+
+
\ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java index d8a946c4b..4ac0dac8a 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java @@ -19,7 +19,7 @@ import com.google.gwt.uibinder.client.UiBinder; /** - * The apperance for all ImageButtons. + * The appearance for all ImageButtons. */ public interface ImageButtonAppearance extends ButtonBaseAppearance { From 791d23886740e1c557c6baa0e327a02473f22811 Mon Sep 17 00:00:00 2001 From: Andrei Volgin Date: Fri, 24 Oct 2014 19:29:30 -0400 Subject: [PATCH 16/53] Replaced flex-flow with flex-direction to avoid conflicts when flex-direction property is set using setOrientation. --- .../googlecode/mgwt/ui/client/widget/carousel/carousel.css | 2 +- .../com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css | 4 ++-- .../com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css index b912d0e36..45a99122e 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css @@ -18,7 +18,7 @@ .mgwt-Carousel { position: relative; flex:1; - flex-flow: column; + flex-direction: column; overflow: visible; } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css index c481f710c..b8c2c57b5 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css @@ -7,7 +7,7 @@ display: -webkit-box; /* iOS < 7 && Android < 4.4*/ display: -webkit-flex; -webkit-box-orient: vertical; /* iOS < 7 && Android < 4.4*/ - -webkit-flex-flow: column; + -webkit-flex-direction: column; } } @@ -19,7 +19,7 @@ .mgwt-FlexPanel { display: flex; - flex-flow: column; + flex-direction: column; } .mgwt-RootFlexPanel { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css index ad760ced3..37a563a97 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css @@ -21,7 +21,7 @@ .mgwt-TabPanel { display: flex; flex: 1; - flex-flow: column; + flex-direction: column; } @if user.agent safari { From de4deab712460f7941307f182563316284dffebc Mon Sep 17 00:00:00 2001 From: Andreas Kohn Date: Thu, 30 Oct 2014 10:18:58 +0100 Subject: [PATCH 17/53] Add HasText to the implemented interfaces of MValueBoxBase This restores compatibility with GWT 2.6, where HasText came from AutoDirectionHandler.Target. Note that this reverts 3fd1752fb34429f43637fc29c577d1a75a1d6f7a again. --- .../googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java index 95bb61353..b1514792f 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java @@ -44,6 +44,7 @@ import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HasEnabled; import com.google.gwt.user.client.ui.HasName; +import com.google.gwt.user.client.ui.HasText; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.ValueBoxBase; import com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment; @@ -66,7 +67,7 @@ public class MValueBoxBase extends Composite implements AutoDirectionHandler.Target, HasAllKeyHandlers, HasAutoCapitalize, HasAutoCorrect, HasBlurHandlers, HasChangeHandlers, HasDirectionEstimator, HasEnabled, HasFocusHandlers, HasName, HasPlaceHolder, HasTouchHandlers, - HasValue, IsEditor> { + HasText, HasValue, IsEditor> { public interface HasSource { public void setSource(Object source); @@ -254,6 +255,7 @@ public void setSelectionRange(int pos, int length) { box.setSelectionRange(pos, length); } + @Override public void setText(String text) { box.setText(text); } From 5c773af7c593282ce796bc3084fea0ae55a090a5 Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Sun, 9 Nov 2014 20:10:07 +0100 Subject: [PATCH 18/53] Added 3 digit hex support in ImageConverter Fixes #220. --- .../mgwt/image/client/ImageConverter.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java b/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java index 2db64d1df..4050da085 100644 --- a/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java +++ b/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java @@ -110,6 +110,8 @@ public ImageResource convert(ImageResource resource, String color) { throw new IllegalArgumentException(); } + color = maybeExpandColor(color); + int hexColor = Integer.parseInt(color.substring(1), 16); int red = hexColor >> 16 & 0xFF; @@ -155,4 +157,21 @@ protected native ImageElement loadImage(String dataUrl, int width, int height) / img.src = dataUrl; return img; }-*/; + + private String maybeExpandColor(String color) { + + if (color.length() != 4) { + return color; + } + + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("#"); + stringBuilder.append(color.charAt(1)); + stringBuilder.append(color.charAt(1)); + stringBuilder.append(color.charAt(2)); + stringBuilder.append(color.charAt(2)); + stringBuilder.append(color.charAt(3)); + stringBuilder.append(color.charAt(3)); + return stringBuilder.toString(); + } } From f892ab8d29741ce56e34d37cac6292de9fc7d449 Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Tue, 11 Nov 2014 17:05:00 +0100 Subject: [PATCH 19/53] Added update HeaderList header on scrolling. Fixed #219 --- .../event/mouse/SimulatedTouchMoveEvent.java | 12 +++++ .../event/mouse/SimulatedTouchStartEvent.java | 12 +++++ .../scroll/impl/ScrollPanelTouchImpl.java | 44 +++++++------------ 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java index a770dc416..aa7b2a284 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java @@ -14,6 +14,7 @@ package com.googlecode.mgwt.dom.client.event.mouse; import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Touch; import com.google.gwt.event.dom.client.MouseMoveEvent; import com.google.gwt.event.dom.client.TouchMoveEvent; @@ -43,6 +44,17 @@ public SimulatedTouchMoveEvent(MouseMoveEvent event, int touchId) { setSource(event.getSource()); } + public SimulatedTouchMoveEvent(int clientX, int clientY, int pageX, + int pageY, int touchId, NativeEvent event, Object source) { + this.touchId = touchId; + this.clientX = clientX; + this.clientY = clientY; + this.pageX = pageX; + this.pageY = pageY; + setNativeEvent(event); + setSource(source); + } + @Override public JsArray getChangedTouches() { JsArray array = SimulatedTouch.createTouchArray(); diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java index 128e0041e..7ba582587 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java @@ -14,6 +14,7 @@ package com.googlecode.mgwt.dom.client.event.mouse; import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Touch; import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.TouchStartEvent; @@ -44,6 +45,17 @@ public SimulatedTouchStartEvent(MouseDownEvent event, int touchId) { setSource(event.getSource()); } + public SimulatedTouchStartEvent(int clientX, int clientY, int pageX, + int pageY, int touchId, NativeEvent event, Object source) { + this.touchId = touchId; + this.clientX = clientX; + this.clientY = clientY; + this.pageX = pageX; + this.pageY = pageY; + setNativeEvent(event); + setSource(source); + } + @Override public JsArray getChangedTouches() { JsArray array = SimulatedTouch.createTouchArray(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java index 3e2fde207..7141aac7b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java @@ -32,12 +32,15 @@ import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; - import com.googlecode.mgwt.collection.shared.CollectionFactory; import com.googlecode.mgwt.collection.shared.LightArray; import com.googlecode.mgwt.collection.shared.LightArrayInt; import com.googlecode.mgwt.dom.client.event.animation.TransitionEndEvent; import com.googlecode.mgwt.dom.client.event.animation.TransitionEndHandler; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent; +import com.googlecode.mgwt.dom.client.event.mouse.TouchStartToMouseDownHandler; import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent; import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; @@ -347,7 +350,6 @@ public ScrollPanelTouchImpl() { this.scrollBar[DIRECTION.HORIZONTAL.ordinal()] = this.hScroll; this.scrollBar[DIRECTION.VERTICAL.ordinal()] = this.vScroll; - } public void setUseTransistion(boolean useTransistion) { @@ -398,7 +400,6 @@ private void scrollBar(final DIRECTION direction) { if (scrollBarWrapper[dir] != null) { if (CssUtil.hasTransform()) { CssUtil.resetTransForm(scrollBarIndicator[dir]); - } if (scrollBarWrapper[dir].getParentNode() != null) { @@ -407,9 +408,7 @@ private void scrollBar(final DIRECTION direction) { scrollBarWrapper[dir] = null; scrollBarIndicator[dir] = null; - } - return; } @@ -437,18 +436,14 @@ private void scrollBar(final DIRECTION direction) { bar.addClassName(css.scrollBarBar()); if (direction == DIRECTION.HORIZONTAL) { - bar.getStyle().setHeight(100, Unit.PCT); - } else { - bar.getStyle().setWidth(100, Unit.PCT); } scrollBarWrapper[dir].appendChild(bar); scrollBarIndicator[dir] = bar; this.scrollBarIndicator[dir].addClassName(css.scrollBarBar()); - } // only append if size fits! @@ -460,7 +455,6 @@ private void scrollBar(final DIRECTION direction) { } else { if (this.wrapperHeight < this.scrollerHeight) { this.wrapper.getElement().appendChild(this.scrollBarWrapper[dir]); - } } @@ -497,7 +491,6 @@ public void run() { scrollbarPos(direction, true); } }.schedule(delay); - } private void resize() { @@ -521,7 +514,6 @@ private void pos(int x, int y) { // TODO scroller.getElement().getStyle().setLeft(x, Unit.PX); scroller.getElement().getStyle().setTop(y, Unit.PX); - } this.x = x; @@ -529,7 +521,6 @@ private void pos(int x, int y) { scrollbarPos(DIRECTION.HORIZONTAL, false); scrollbarPos(DIRECTION.VERTICAL, false); - } private void scrollbarPos(DIRECTION direction, boolean hidden) { @@ -554,7 +545,6 @@ private void scrollbarPos(DIRECTION direction, boolean hidden) { } else { this.scrollBarIndicator[dir].getStyle().setHeight(size, Unit.PX); } - } pos = 0; } else { @@ -584,9 +574,7 @@ private void scrollbarPos(DIRECTION direction, boolean hidden) { CssUtil.translate(this.scrollBarIndicator[dir], (int) pos, 0); } else { CssUtil.translate(this.scrollBarIndicator[dir], 0, (int) pos); - } - } private void start(TouchStartEvent event) { @@ -805,7 +793,6 @@ private void end(final TouchEvent event) { // TODO fire onzoomend return; - } if (!this.moved) { @@ -855,7 +842,6 @@ public void run() { if ((this.y > this.minScrollY && newPosY > this.minScrollY) || (this.y < this.maxScrollY && newPosY < this.maxScrollY)) { momentumY = Momentum.ZERO_MOMENTUM; } - } int distX = 0; @@ -877,7 +863,6 @@ public void run() { newPosY = snap.getY(); newDuration = Math.max(snap.getTime(), newDuration); } - } scrollTo(newPosX, newPosY, newDuration); @@ -901,12 +886,10 @@ public void run() { // fire on touch end return; - } resetPos(200); // TODO fire on touch end - } private void resetPos(int time) { @@ -925,23 +908,22 @@ private void resetPos(int time) { if (this.scrollBar[DIRECTION.HORIZONTAL.ordinal()] && this.hideScrollBar) { CssUtil.setTransitionsDelay(this.scrollBarWrapper[DIRECTION.HORIZONTAL.ordinal()], 300); CssUtil.setOpacity(this.scrollBarWrapper[DIRECTION.HORIZONTAL.ordinal()], 0); - } if (this.scrollBar[DIRECTION.VERTICAL.ordinal()] && this.hideScrollBar) { CssUtil.setTransitionsDelay(this.scrollBarWrapper[DIRECTION.VERTICAL.ordinal()], 300); CssUtil.setOpacity(this.scrollBarWrapper[DIRECTION.VERTICAL.ordinal()], 0); - } - return; } scrollTo(resetX, resetY, time); - } - private void wheel(int wheelDeltaX, int wheelDeltaY, int pageX, int pageY) { + private void wheel(int wheelDeltaX, int wheelDeltaY, MouseWheelEvent event) { + + int pageX = event.getClientX(); + int pageY = event.getClientY(); if (wheelActionZoom) { double deltaScale = this.scale * Math.pow(2, 1.0 / 3 * (wheelDeltaY != 0 ? wheelDeltaY / Math.abs(wheelDeltaY) : 0)); @@ -966,7 +948,6 @@ public void run() { if (ScrollPanelTouchImpl.this.wheelZoomCount == 0) { // TODO maybe fire zoom end } - } }.schedule(400); @@ -987,8 +968,15 @@ else if (deltaX < this.maxScrollX) else if (deltaY < this.maxScrollY) deltaY = this.maxScrollY; + SimulatedTouchStartEvent simulatedTouchStartEvent = new SimulatedTouchStartEvent(this.x, this.y, this.x + getAbsoluteLeft(), this.y + getAbsoluteTop(), TouchStartToMouseDownHandler.lastTouchId, event.getNativeEvent(), this); + fireEvent(new ScrollStartEvent(simulatedTouchStartEvent)); + scrollTo(deltaX, deltaY, 0); + SimulatedTouchMoveEvent simulatedTouchMoveEvent = new SimulatedTouchMoveEvent(deltaX, deltaY, deltaX + getAbsoluteLeft(), deltaY + getAbsoluteTop(), TouchStartToMouseDownHandler.lastTouchId, event.getNativeEvent(), this); + fireEvent(new ScrollMoveEvent(simulatedTouchMoveEvent)); + + fireEvent(new ScrollEndEvent()); } private void mouseOut(MouseOutEvent event) { @@ -1691,7 +1679,7 @@ public void onMouseWheel(MouseWheelEvent event) { if (isScrollingEnabledY()) { wheelDeltaY = getMouseWheelVelocityY(event.getNativeEvent()) / 10; } - wheel(wheelDeltaX, wheelDeltaY, event.getClientX(), event.getClientY()); + wheel(wheelDeltaX, wheelDeltaY, event); } }, MouseWheelEvent.getType()); From 307640a93943a4dd962c88f2803b8b80c9a8243d Mon Sep 17 00:00:00 2001 From: Ingo Schroepfer Date: Wed, 12 Nov 2014 15:41:54 +0100 Subject: [PATCH 20/53] Fix MainResourceAppearance in platform themes --- .../mgwt/ui/client/theme/platform/main/MainResource.gwt.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/MainResource.gwt.xml b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/MainResource.gwt.xml index 043e5955f..fb7f02bae 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/MainResource.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/MainResource.gwt.xml @@ -14,6 +14,6 @@ under the License. - + \ No newline at end of file From 1ffe19f72d824a9fb154f79cfaf1e0052f04a01b Mon Sep 17 00:00:00 2001 From: Thad Humphries Date: Sat, 15 Nov 2014 06:49:51 -0500 Subject: [PATCH 21/53] Add UiChild to WidgetList.setHeader() Allows declaring header widget in UiBinder. --- pom.xml | 2 +- .../mgwt/ui/client/widget/list/widgetlist/WidgetList.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 66aef213a..0e62cbf2c 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.googlecode.mgwt mgwt - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT jar mgwt diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java index 65c74fd9d..ea82f580c 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java @@ -18,6 +18,7 @@ import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.uibinder.client.UiChild; import com.google.gwt.uibinder.client.UiFactory; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.AcceptsOneWidget; @@ -221,6 +222,7 @@ public void setSelectAble(int index, boolean group) { } } + @UiChild(limit = 1, tagname = "header") public void setHeader(Widget header) { headerContainer.setVisible(header != null); headerContainer.clear(); From 8aff744372855b4e5513c0774912cf0a7b741e15 Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Wed, 12 Nov 2014 18:48:28 +0100 Subject: [PATCH 22/53] Added method to set position of imagebutton text. Fixes #164. --- .../ui/client/widget/button/ImageButton.java | 18 +++++++++++++++++- .../widget/button/ImageButtonAppearance.java | 3 +++ .../ui/client/widget/button/imagebutton.css | 11 +++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButton.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButton.java index 968de7e4d..8b41e8101 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButton.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButton.java @@ -25,7 +25,6 @@ import com.google.gwt.resources.client.ImageResource; import com.google.gwt.uibinder.client.UiFactory; import com.google.gwt.uibinder.client.UiField; - import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; import com.googlecode.mgwt.ui.client.MGWT; import com.googlecode.mgwt.ui.client.util.IconHandler; @@ -41,6 +40,10 @@ public class ImageButton extends ButtonBase implements IsSizeable { private final ImageButtonAppearance appearance; + public enum TextPosition { + LEFT, RIGHT; + } + @UiField public Element text; @@ -123,6 +126,19 @@ public void setText(String text) { this.text.setInnerText(text); } + public void setTextPosition(TextPosition pos) { + switch (pos) { + case LEFT: + addStyleName(appearance.css().reverseOrder()); + break; + case RIGHT: + removeStyleName(appearance.css().reverseOrder()); + break; + default: + throw new RuntimeException("should never get here"); + } + } + public void setIcon(ImageResource icon) { this.icon = icon; updateIcon(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java index d8a946c4b..7f3670d64 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ImageButtonAppearance.java @@ -44,6 +44,9 @@ interface ImageButtonCss extends ButtonBaseCss { @ClassName("mgwt-ImageButton-small") String small(); + @ClassName("mgwt-ImageButton-reverse-order") + String reverseOrder(); + String ICON_BACKGROUND_COLOR(); String ICON_BACKGROUND_COLOR_ACTIVE(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css index a8ada1935..e0951f493 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css @@ -2,6 +2,7 @@ @external mgwt-ImageButton, mgwt-ImageButton-active; @external mgwt-ImageButton-disabled, mgwt-ImageButton-image; @external mgwt-ImageButton-small; + @external mgwt-ImageButton-reverse-order; } @def ICON_BACKGROUND_COLOR #454545; @@ -26,6 +27,16 @@ } } +@if user.agent safari { + .mgwt-ImageButton-reverse-order { + -webkit-flex-direction: row-reverse; + } +} + +.mgwt-ImageButton-reverse-order { + flex-direction: row-reverse; +} + .mgwt-ImageButton { display: flex; color: #454545; From d787a787be3e69cc7f8e7ed55b80cb0fbd6bf1e4 Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Tue, 18 Nov 2014 12:27:26 +0100 Subject: [PATCH 23/53] Added missing UiFactory method. Fixes #228 --- .../mgwt/ui/client/widget/dialog/panel/DialogPanel.java | 7 ++++++- .../mgwt/ui/client/widget/list/widgetlist/WidgetList.java | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/DialogPanel.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/DialogPanel.java index 4e7212017..1165416eb 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/DialogPanel.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/DialogPanel.java @@ -14,13 +14,13 @@ package com.googlecode.mgwt.ui.client.widget.dialog.panel; import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiFactory; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHTML; import com.google.gwt.user.client.ui.HasWidgets; - import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; /** @@ -140,4 +140,9 @@ public void showOkButton(boolean show) { public HasHTML getDialogTitle() { return title; } + + @UiFactory + public DialogPanelAppearance getAppearance() { + return appearance; + } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java index ea82f580c..5dacb26be 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/WidgetList.java @@ -81,6 +81,11 @@ public void setWidget(IsWidget w) { public HandlerRegistration addTapHandler(TapHandler handler) { return addHandler(handler, TapEvent.getType()); } + + @UiFactory + public WidgetListAppearance getAppearance() { + return appearance; + } } private static class Entry { From 56e03c226b9e9498c68d1499092a54840f168b3b Mon Sep 17 00:00:00 2001 From: Katharina Fahnenbruck Date: Wed, 19 Nov 2014 18:20:57 +0100 Subject: [PATCH 24/53] Fixed wrong focus when tabbing into MTextBox in Chrome. Fixes #213 --- .../googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java | 5 +++++ .../mgwt/ui/client/widget/input/InputAppearance.java | 3 +++ .../com/googlecode/mgwt/ui/client/widget/input/MTextBox.java | 1 - .../com/googlecode/mgwt/ui/client/widget/input/input.css | 5 ++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java index b1514792f..5640966a0 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/base/MValueBoxBase.java @@ -116,6 +116,11 @@ public MValueBoxBase(InputAppearance appearance, final ValueBoxBase box) { main.add(box); + if (MGWT.getOsDetection().isAndroid4_3_orLower()) { + main.addStyleName(appearance.css().fixWhiteBackgroundBugOnAndroid43AndLower()); + box.addStyleName(appearance.css().fixWhiteBackgroundBugOnAndroid43AndLower()); + } + ((HasSource) box).setSource(this); box.addBlurHandler(new BlurHandler() { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputAppearance.java index 0cb31ca84..096735103 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/InputAppearance.java @@ -37,6 +37,9 @@ public interface InputCss extends MGWTCssResource { @ClassName("mgwt-InputBox-invalid") String invalid(); + + @ClassName("mgwt-TextBox-fix-white-background-bug-android43") + String fixWhiteBackgroundBugOnAndroid43AndLower(); } InputCss css(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java index b3ddb7e5b..cfc6c2ea1 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTextBox.java @@ -18,7 +18,6 @@ import com.google.gwt.dom.client.InputElement; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.ui.TextBox; - import com.googlecode.mgwt.ui.client.widget.base.MTextBoxBase; /** diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css index 56a30e7e6..cebf45383 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css @@ -13,7 +13,6 @@ -webkit-appearance: none; -webkit-user-select: text; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); - -webkit-user-modify: read-write-plaintext-only; } } @@ -55,3 +54,7 @@ .mgwt-InputBox-invalid::-webkit-input-placeholder { color: rgb(197, 3, 3); } + +.mgwt-TextBox-fix-white-background-bug-android43 { + -webkit-user-modify: read-write-plaintext-only; +} From c1defa1139368664f7d65dda054b618df5dcc5c3 Mon Sep 17 00:00:00 2001 From: Wayne Dyck Date: Thu, 8 Jan 2015 15:10:58 -0800 Subject: [PATCH 25/53] Fix for black background gradient not being applied on Android. The linear gradient is never applied on Chrome 39 both on the desktop and Android browser when mgwt.os is set to 'android'. The result is the background stays the default #ECEBF1 color with white text making it difficult to read. I'm not sure if the body::before pseudo element is still needed for legacy reasons, however, the submitted change does work in Chrome 39. --- .../com/googlecode/mgwt/ui/client/theme/platform/main/main.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/main.css b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/main.css index cfbd21d84..7fcc1c3f4 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/main.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/theme/platform/main/main.css @@ -7,6 +7,7 @@ @if mgwt.os android { body { background-attachment: fixed; + background-image: literal('-webkit-gradient(linear, left top, left bottom, from(#000000), to(rgb(46, 54, 60)))'); color: white; } From da1a2dd8a3f32ad8385272a149508945a5fcaef3 Mon Sep 17 00:00:00 2001 From: guillaume-rebesche Date: Mon, 23 Feb 2015 19:22:02 -0500 Subject: [PATCH 26/53] Added a simple time input --- .../googlecode/mgwt/ui/client/util/Time.java | 42 +++++++ .../mgwt/ui/client/widget/input/MTimeBox.java | 111 ++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/util/Time.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTimeBox.java diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/Time.java b/src/main/java/com/googlecode/mgwt/ui/client/util/Time.java new file mode 100644 index 000000000..44cda86d5 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/Time.java @@ -0,0 +1,42 @@ +package com.googlecode.mgwt.ui.client.util; + +/** + * Simple data structure to store time (only hours and minutes) + *

+ * Created by Guillaume on 2014-11-16. + */ +public class Time { + private int hours; + private int minutes; + + public Time() { + this(0, 0); + } + + public Time(int hours, int minutes) { + this.setHours(hours); + this.setMinutes(minutes); + } + + public int getHours() { + return hours; + } + + public void setHours(int hours) { + if (hours < 0 || hours > 23) { + throw new IllegalArgumentException("hours should be between 0 and 23"); + } + this.hours = hours; + } + + public int getMinutes() { + return minutes; + } + + public void setMinutes(int minutes) { + if (minutes < 0 || minutes > 59) { + throw new IllegalArgumentException("minutes should be between 0 and 59"); + } + this.minutes = minutes; + } +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTimeBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTimeBox.java new file mode 100644 index 000000000..410ce145d --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MTimeBox.java @@ -0,0 +1,111 @@ +/* + * Copyright 2011 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.input; + + +import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.i18n.client.DateTimeFormat; +import com.google.gwt.text.shared.Parser; +import com.google.gwt.text.shared.Renderer; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.ValueBoxBase; +import com.googlecode.mgwt.ui.client.util.Time; +import com.googlecode.mgwt.ui.client.widget.base.MValueBoxBase; + +import java.io.IOException; +import java.text.ParseException; +import java.util.Date; + +/** + * An input element that handles time + * + * @author Guillaume Rebesche + */ +public class MTimeBox extends MValueBoxBase

@@ -122,6 +121,9 @@ public void setJustification(Justification value) { FlexPropertyHelper.setJustification(getElement(), value); } + public void setFlex(double flex) { + FlexPropertyHelper.setFlex(getElement(), flex); + } public void clearAlignment() { FlexPropertyHelper.clearAlignment(getElement()); From 8836742250d30deed072a30292197c48dd4a278c Mon Sep 17 00:00:00 2001 From: Andrei Volgin Date: Tue, 7 Apr 2015 15:56:51 -0400 Subject: [PATCH 28/53] setFlex method should only change flex-grow property. --- .../ui/client/widget/panel/flex/FlexPropertyHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java index 79ed4a360..f622d5dec 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java @@ -75,11 +75,11 @@ private String getCssValue() { public static void setFlex(Element el, double flex) { /* iOS < 7 && Android < 4.4*/ - el.getStyle().setProperty("WebkitBoxFlex", Double.toString(flex)); + el.getStyle().setProperty("WebkitBoxFlexGrow", Double.toString(flex)); - el.getStyle().setProperty("MozFlex", Double.toString(flex)); - el.getStyle().setProperty("WebkitFlex", Double.toString(flex)); - el.getStyle().setProperty("flex", Double.toString(flex)); + el.getStyle().setProperty("MozFlexGrow", Double.toString(flex)); + el.getStyle().setProperty("WebkitFlexGrow", Double.toString(flex)); + el.getStyle().setProperty("flexGrow", Double.toString(flex)); } private static void setFlexProperty(Element el, String name, String value) { From a801a7232470af8dd3bd0968aff5c043cba44292 Mon Sep 17 00:00:00 2001 From: guillaume-rebesche Date: Thu, 16 Apr 2015 20:27:50 -0400 Subject: [PATCH 29/53] Fix the issue with big numbers in MDoubleBox --- .../ui/client/widget/input/MDoubleBox.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java index 2c11cf0d6..04787dafc 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDoubleBox.java @@ -15,8 +15,13 @@ */ package com.googlecode.mgwt.ui.client.widget.input; +import com.google.gwt.dom.client.Document; import com.google.gwt.event.shared.HandlerManager; -import com.google.gwt.user.client.ui.DoubleBox; +import com.google.gwt.i18n.client.NumberFormat; +import com.google.gwt.text.client.DoubleParser; +import com.google.gwt.text.shared.AbstractRenderer; +import com.google.gwt.text.shared.Renderer; +import com.google.gwt.user.client.ui.ValueBox; import com.googlecode.mgwt.ui.client.widget.base.MValueBoxBase; @@ -27,11 +32,13 @@ */ public class MDoubleBox extends MValueBoxBase { - private static class SDoubleBox extends DoubleBox implements HasSource { + private static class SDoubleBox extends ValueBox implements HasSource { private Object source; public SDoubleBox() { + super(Document.get().createTextInputElement(), DoubleRenderer.instance(), + DoubleParser.instance()); setStylePrimaryName("gwt-DoubleBox"); } @@ -54,4 +61,30 @@ public MDoubleBox(InputAppearance appearance) { impl.setType(box.getElement(), "number"); addStyleName(appearance.css().textBox()); } + + public static class DoubleRenderer extends AbstractRenderer { + private static DoubleRenderer INSTANCE; + private static NumberFormat formatter = NumberFormat.getFormat("#.###"); + + /** + * Returns the instance. + */ + public static Renderer instance() { + if (INSTANCE == null) { + INSTANCE = new DoubleRenderer(); + } + return INSTANCE; + } + + protected DoubleRenderer() { + } + + public String render(Double object) { + if (object == null) { + return ""; + } + + return formatter.format(object); + } + } } From 24aa01f54d03d4800cec02138cf5288947a77037 Mon Sep 17 00:00:00 2001 From: Paul French Date: Fri, 28 Nov 2014 16:39:00 +0000 Subject: [PATCH 30/53] First draft of WP8/WP8.1 (desktop IE10, mobile IE10) support. Includes fix for emulated icon handling. Capture pointer events by default so we get the same behaviour as IOS. We call setPointerCapture on the element that receives the pointer down event. Added FlexPropertyHelper enhancements to support IE10 do not blurBeforeAnimation if the node is the body element since this causes the IE10 browser to disappear behind other windows on going fixes. For ie10 use -ms-flex: 1 1 instead of -ms-flex: 1 since ie10 sets shrink to 0 by default if not specified whereas webkit sets it to 1. Do not do event.preventDefault in the CellList if we are running on windows phone, prevents the scroll panel the CellList is in scrolling properly. for ie10/ie11 desktop needed to add a focus fix where when using pointer capture, input elements failed to get the focus properly. See https://stackoverflow.com/questions/27355271/desktop-ie10-ie11-on-windows-input-elements-fail-to-get-focus-when-pointer-cap capturing pointer events on input or textarea elements causes many issues, so we no longer capture pointer events if the target element is an input or textarea. Turned on default behaviour for textarea so we can scroll textarea. However this can cause a bounce when scrolling a text area to the start or end. However this is better then not being able to scroll at all like currently in IOS remove drop down arrow on select fixed issue where scroll panel did not work on windows phone 8.1 update but worked fine on windows phone 8. Had to force getComputedStyle to return a 3D matrix for the transform property by specifying a non-zero z value (-1px). We now detect the device density correctly for ie10/11 (we use the screen object). We do not try and detect ie11 user agent, we assume if using ie11 that the meta tag ie10 compatibilty is set. User agent strings for ie11 are now even more complex. They specify webkit, iphone, gecko etc etc as part of the string. This makes OS detection more difficult using the user agent string. added flexwrap to FlexInputHelper, corrected name of MozAlignSelf in Mozilla implementation of FlexInputHelper Need access to ButtonBaseAppearance so subclass can override the default touch handlers added that do not always give you the required behaviour Added correct orientation support for windows phone 8.1 In IEOrientationHandler removed window.alert left in by mistake. Added !important to portraitonly and landscapeonly css since not always easy to ensure this css gets priority over other css Avoid long emulation in ScrollPanel fix minor bug when specifying ie10 compatibility. Does not seem to make any diferrence. Looks like you have to specify in the html file as a meta tag and not rely on it being dynamically added and picked up by ie10/11 due to poor performance of ScrollPanel in IE10/11 when a reasonable amount of DOM added, attempting to eliminate any translate3d type issues. Use 0px instead of -1px for the z co-ordinate and check what transform matrix returned, either 2d or 3D and extract the relevant co-ordinates removed -ms-touch-action: none, which is applied to elements since need to use native scrollable divs to get better performance then using the MGWT ScrollPanel. Unfortunately one side effect of this is we start to get application bounce when scrolling limits are reached of a scrollbale div. Only apply ios71 body bug fix when ios71. Also stop possible re-creation of orientation handler if current orientation handler not removed correctly. Remove the orientation handler correctly when orientation event fired. Added more position information to the TapEvent via the Touch object. When preventing scrolling for IOS we no longer preventDefault the TouchMove event if it originates from an INPUT, TEXTAREA or SELECT element. This solves a multitude of issues with these input types where default behaviour of the browser is required so that they function as expected. Also on more sensitive touch devices like the ipad air 2 the input type elements were very hard to tap and navigate between if a TouchMove event was generated as part of the touch and the TouchMove vent is prevent defaulted. Updated to use GWT 2.7 ImageConverter modified to wait for the image to be loaded before trying to convert it Fixes #220. Revert "Updated to use GWT 2.7" This reverts commit 073e6a0c61ba67b31d29759903c3123f0d5102bf. --- .../gwt/user/client/impl/DOMImplIE10.java | 67 ++++++ .../rebind/UserAgentPropertyGenerator.java | 104 ++++++++ .../java/com/googlecode/mgwt/dom/DOM.gwt.xml | 28 ++- .../event/pointer/MsPointerCancelEvent.java | 59 +++++ .../event/pointer/MsPointerCancelHandler.java | 31 +++ .../event/pointer/MsPointerDownEvent.java | 59 +++++ .../event/pointer/MsPointerDownHandler.java | 31 +++ .../client/event/pointer/MsPointerEvent.java | 39 +++ .../event/pointer/MsPointerMoveEvent.java | 59 +++++ .../event/pointer/MsPointerMoveHandler.java | 31 +++ .../event/pointer/MsPointerUpEvent.java | 59 +++++ .../event/pointer/MsPointerUpHandler.java | 31 +++ .../client/event/pointer/SimulatedTouch.java | 60 +++++ .../pointer/SimulatedTouchCancelEvent.java | 12 + .../event/pointer/SimulatedTouchEndEvent.java | 65 +++++ .../pointer/SimulatedTouchMoveEvent.java | 66 ++++++ .../pointer/SimulatedTouchStartEvent.java | 67 ++++++ .../TouchCancelToMsPointerCancelHandler.java | 35 +++ .../pointer/TouchEndToMsPointerUpHandler.java | 35 +++ .../TouchMoveToMsPointerMoveHandler.java | 53 +++++ .../TouchStartToMsPointerDownHandler.java | 35 +++ .../mgwt/dom/client/event/tap/TapEvent.java | 35 +-- .../dom/client/recognizer/TapRecognizer.java | 10 +- .../mgwt/image/client/ImageConverter.java | 99 +++++--- .../image/client/ImageConverterCallback.java | 8 + .../mgwt/image/client/LoadImageCallback.java | 8 + .../java/com/googlecode/mgwt/ui/UI.gwt.xml | 51 +++- .../com/googlecode/mgwt/ui/client/MGWT.java | 40 +++- .../mgwt/ui/client/OsDetection.java | 6 + .../ui/client/OsDetectionRuntimeImpl.java | 21 +- .../mgwt/ui/client/TouchSupport.java | 100 ++++++++ .../mgwt/ui/client/util/IconHandler.java | 32 ++- .../ui/client/util/impl/CssUtilIE10Impl.java | 130 ++++++++++ .../util/impl/IEOrientationHandler.java | 171 ++++++++++++++ .../widget/animation/bundle/dissolve.css | 36 +++ .../client/widget/animation/bundle/fade.css | 35 +++ .../client/widget/animation/bundle/flip.css | 48 ++++ .../ui/client/widget/animation/bundle/pop.css | 48 ++++ .../widget/animation/bundle/slide-up.css | 50 ++++ .../client/widget/animation/bundle/slide.css | 54 +++++ .../client/widget/animation/bundle/swap.css | 85 +++++++ .../impl/AnimationWidgetKeyFrameImpl.java | 2 +- .../animation/impl/animation-display.css | 30 ++- .../ui/client/widget/button/ButtonBase.java | 125 +++++----- .../ui/client/widget/button/imagebutton.css | 4 +- .../ui/client/widget/buttonbar/buttonbar.css | 11 +- .../ui/client/widget/carousel/carousel.css | 13 + .../widget/dialog/options/options-dialog.css | 6 + .../widget/dialog/panel/dialog-button.css | 7 + .../ui/client/widget/dialog/panel/dialog.css | 31 ++- .../mgwt/ui/client/widget/form/form.css | 23 +- .../widget/input/checkbox/MCheckBox.java | 9 +- .../client/widget/input/checkbox/checkbox.css | 50 +++- .../mgwt/ui/client/widget/input/input.css | 13 + .../client/widget/input/listbox/mlistbox.css | 11 + .../widget/input/radio/mradiobutton.css | 19 ++ .../client/widget/input/search/searchbox.css | 108 +++++++-- .../ui/client/widget/input/slider/Slider.java | 9 +- .../client/widget/list/celllist/CellList.java | 13 +- .../client/widget/list/celllist/celllist.css | 6 + .../list/celllist/grouping-celllist.css | 19 ++ .../widget/list/widgetlist/widgetlist.css | 6 + .../ui/client/widget/main/IOS71BodyBug.java | 26 +- .../mgwt/ui/client/widget/main/main.css | 72 ++++-- .../mgwt/ui/client/widget/main/selection.css | 24 ++ .../mgwt/ui/client/widget/main/util.css | 4 +- .../widget/menu/overlay/overlay-menu.css | 17 +- .../client/widget/menu/swipe/swipe-menu.css | 9 + .../widget/panel/flex/FlexPanel.gwt.xml | 26 ++ .../widget/panel/flex/FlexPropertyHelper.java | 192 ++++++--------- .../panel/flex/FlexPropertyHelperIE10.java | 184 +++++++++++++++ .../panel/flex/FlexPropertyHelperMoz.java | 175 ++++++++++++++ .../flex/FlexPropertyHelperStandard.java | 175 ++++++++++++++ .../panel/flex/FlexPropertyHelperWebkit.java | 207 ++++++++++++++++ .../mgwt/ui/client/widget/panel/flex/flex.css | 13 + .../ui/client/widget/panel/pull/pullpanel.css | 26 ++ .../scroll/impl/ScrollPanelTouchImpl.java | 53 ++--- .../widget/panel/scroll/scrollpanel.css | 27 +++ .../ui/client/widget/progress/progressbar.css | 25 +- .../widget/progress/progressindicator.css | 36 +++ .../widget/progress/progressspinner.css | 222 +++++++++++++----- .../ui/client/widget/tabbar/tabbar-button.css | 21 +- .../mgwt/ui/client/widget/tabbar/tabbar.css | 37 ++- .../ui/client/widget/touch/TouchPanel.java | 10 +- .../ui/client/widget/touch/TouchWidget.java | 17 +- .../client/widget/touch/TouchWidgetImpl.java | 117 +-------- .../widget/touch/TouchWidgetPointerImpl.java | 57 +++++ .../widget/touch/TouchWidgetStandardImpl.java | 86 +++++++ .../widget/touch/TouchWidgetTouchImpl.java | 47 ++++ .../client/ImageConverterGwtTestCase.java | 24 +- .../input/search/MSearchBoxGwtTest.java | 2 +- 91 files changed, 3949 insertions(+), 590 deletions(-) create mode 100644 src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java create mode 100644 src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouch.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchCancelEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchEndEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchMoveEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchStartEvent.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchCancelToMsPointerCancelHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchEndToMsPointerUpHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchMoveToMsPointerMoveHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchStartToMsPointerDownHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java create mode 100644 src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/util/impl/IEOrientationHandler.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java diff --git a/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java new file mode 100644 index 000000000..b8b4c0035 --- /dev/null +++ b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.user.client.impl; + +import com.google.gwt.core.client.JavaScriptObject; + + +/** + * IE10 implementation of {@link com.google.gwt.user.client.impl.DOMImplStandard}. + */ +public class DOMImplIE10 extends DOMImplIE9 { + + static + { + DOMImplStandard.addCaptureEventDispatchers(getCaptureEventDispatchers()); + DOMImplStandard.addBitlessEventDispatchers(getBitlessEventDispatchers()); + capturePointerEvents(); + } + + /** + * Lets have the same behaviour as IOS where the target element continues to receive Pointer events + * even when the pointer has moved off the element up until MSPointerUp has occurred. + * + * Do not do pointer capture on input or textarea elements, all sorts of problems arise if you do! + */ + private native static void capturePointerEvents() /*-{ + $wnd.addEventListener('MSPointerDown', + $entry(function(evt) { + if ((evt.target.tagName !== 'INPUT') && (evt.target.tagName !== 'TEXTAREA')) { + evt.target.msSetPointerCapture(evt.pointerId); + } + }), true); + }-*/; + + + public static native JavaScriptObject getCaptureEventDispatchers() /*-{ + return { + MSPointerDown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + MSPointerUp: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + MSPointerMove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + MSPointerCancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*) + }; + }-*/; + + public static native JavaScriptObject getBitlessEventDispatchers() /*-{ + return { + MSPointerDown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + MSPointerUp: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + MSPointerMove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + MSPointerCancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*) + }; + }-*/; + +} diff --git a/src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java b/src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java new file mode 100644 index 000000000..9f7483ed0 --- /dev/null +++ b/src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java @@ -0,0 +1,104 @@ + +package com.google.gwt.useragent.rebind; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.linker.ConfigurationProperty; +import com.google.gwt.core.ext.linker.PropertyProviderGenerator; +import com.google.gwt.user.rebind.SourceWriter; +import com.google.gwt.user.rebind.StringSourceWriter; + +import java.util.HashSet; +import java.util.Set; +import java.util.SortedSet; + +/** + * Generator which writes out the JavaScript for determining the value of the + * user.agent selection property. + */ +public class UserAgentPropertyGenerator implements PropertyProviderGenerator { + + /** + * The list of {@code user.agent} values listed here should be kept in sync with + * {@code UserAgent.gwt.xml}. + *

Note that the order of enums matter as the script selection is based on running + * these predicates in order and matching the first one that returns {@code true}. + *

Also note that, {@code docMode < 11} in predicates for older IEs exists to + * ensures we never choose them for IE11 (we know that they will not work for IE11). + */ + private enum UserAgent { + safari("return ((ua.indexOf('webkit') != -1) && !(ua.indexOf('trident') != -1));"), + ie10("return (ua.indexOf('msie') != -1 && (docMode >= 10 && docMode < 11)) || " + + "(ua.indexOf('iemobile') != -1 && (docMode >= 10 && docMode < 11))"), + ie9("return (ua.indexOf('msie') != -1 && (docMode >= 9 && docMode < 11));"), + ie8("return (ua.indexOf('msie') != -1 && (docMode >= 8 && docMode < 11));"), + gecko1_8("return (ua.indexOf('gecko') != -1 || docMode >= 11);"); + + private final String predicateBlock; + + private UserAgent(String predicateBlock) { + this.predicateBlock = predicateBlock; + } + + private static Set getKnownAgents() { + HashSet userAgents = new HashSet(); + for (UserAgent userAgent : values()) { + userAgents.add(userAgent.name()); + } + return userAgents; + } + } + + /** + * Writes out the JavaScript function body for determining the value of the + * user.agent selection property. This method is used to create + * the selection script and by {@link UserAgentGenerator} to assert at runtime + * that the correct user agent permutation is executing. + */ + static void writeUserAgentPropertyJavaScript(SourceWriter body, + SortedSet possibleValues, String fallback) { + + // write preamble + body.println("var ua = navigator.userAgent.toLowerCase();"); + body.println("var docMode = $doc.documentMode;"); + + for (UserAgent userAgent : UserAgent.values()) { + // write only selected user agents + if (possibleValues.contains(userAgent.name())) { + body.println("if ((function() { "); + body.indentln(userAgent.predicateBlock); + body.println("})()) return '%s';", userAgent.name()); + } + } + + // default return + if (fallback == null) { + fallback = "unknown"; + } + body.println("return '" + fallback + "';"); + } + + @Override + public String generate(TreeLogger logger, SortedSet possibleValues, String fallback, + SortedSet configProperties) { + assertUserAgents(logger, possibleValues); + + StringSourceWriter body = new StringSourceWriter(); + body.println("{"); + body.indent(); + writeUserAgentPropertyJavaScript(body, possibleValues, fallback); + body.outdent(); + body.println("}"); + + return body.toString(); + } + + private static void assertUserAgents(TreeLogger logger, SortedSet possibleValues) { + HashSet unknownValues = new HashSet(possibleValues); + unknownValues.removeAll(UserAgent.getKnownAgents()); + if (!unknownValues.isEmpty()) { + logger.log(TreeLogger.WARN, "Unrecognized " + UserAgentGenerator.PROPERTY_USER_AGENT + + " values " + unknownValues + ", possibly due to UserAgent.gwt.xml and " + + UserAgentPropertyGenerator.class.getName() + " being out of sync."); + } + } +} diff --git a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml index 707540f71..07446025e 100644 --- a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml @@ -38,7 +38,10 @@ // Detect form factor from user agent. var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("iphone") != -1 || ua.indexOf("ipod") != -1) { + if (ua.indexOf("windows phone 8") != -1) { + // windows phone 8/8.1 + return "phone"; + } else if (ua.indexOf("iphone") != -1 || ua.indexOf("ipod") != -1) { // iphone and ipod. return "phone"; } else if (ua.indexOf("ipad") != -1) { @@ -57,6 +60,14 @@ ]]> + + + + + + + + + + + + + + + diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelEvent.java new file mode 100644 index 000000000..89568c2bd --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelEvent.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.DomEvent; + +/** + * Represents a native MsPointerCancelEvent. + */ +public class MsPointerCancelEvent extends MsPointerEvent { + + /** + * Event type for MsPointerCancelEvent. Represents the meta-data associated with + * this event. + */ + private static final Type TYPE = new Type( + MsPointerEvent.MSPOINTERCANCEL, new MsPointerCancelEvent()); + + /** + * Gets the event type associated with pointer cancel events. + * + * @return the handler type + */ + public static Type getType() { + return TYPE; + } + + /** + * Protected constructor, use + * {@link DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent, com.google.gwt.event.shared.HasHandlers)} + * to fire pointer up events. + */ + protected MsPointerCancelEvent() { + } + + @Override + public final Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(MsPointerCancelHandler handler) { + handler.onPointerCancel(this); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelHandler.java new file mode 100644 index 000000000..f94cc3500 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerCancelHandler.java @@ -0,0 +1,31 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler interface for {@link MsPointerCancelEvent} events. + */ +public interface MsPointerCancelHandler extends EventHandler { + + /** + * Called when MsPointerCancelEvent is fired. + * + * @param event the {@link MsPointerCancelEvent} that was fired + */ + void onPointerCancel(MsPointerCancelEvent event); +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownEvent.java new file mode 100644 index 000000000..1c043a725 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownEvent.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.DomEvent; + +/** + * Represents a native MsPointerDownEvent. + */ +public class MsPointerDownEvent extends MsPointerEvent { + + /** + * Event type for MsPointerDownEvent. Represents the meta-data associated with + * this event. + */ + private static final Type TYPE = new Type( + MsPointerEvent.MSPOINTERDOWN, new MsPointerDownEvent()); + + /** + * Gets the event type associated with MsPointerDownEvent events. + * + * @return the handler type + */ + public static Type getType() { + return TYPE; + } + + /** + * Protected constructor, use + * {@link DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent, com.google.gwt.event.shared.HasHandlers)} + * to fire pointer down events. + */ + protected MsPointerDownEvent() { + } + + @Override + public final Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(MsPointerDownHandler handler) { + handler.onPointerDown(this); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownHandler.java new file mode 100644 index 000000000..f57d6cc01 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerDownHandler.java @@ -0,0 +1,31 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler interface for {@link MsPointerDownEvent} events. + */ +public interface MsPointerDownHandler extends EventHandler { + + /** + * Called when MsPointerDownEvent is fired. + * + * @param event the {@link MsPointerDownEvent} that was fired + */ + void onPointerDown(MsPointerDownEvent event); +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java new file mode 100644 index 000000000..c944e77de --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.MouseEvent; +import com.google.gwt.event.shared.EventHandler; + +/** + * Abstract class representing MsPointer events. + * + * @param handler type + * + */ +public abstract class MsPointerEvent extends MouseEvent { + + public static final String MSPOINTERDOWN = "MSPointerDown"; + public static final String MSPOINTERMOVE = "MSPointerMove"; + public static final String MSPOINTEROUT = "MSPointerOut"; + public static final String MSPOINTEROVER = "MSPointerOver"; + public static final String MSPOINTERUP = "MSPointerUp"; + public static final String MSPOINTERCANCEL = "MSPointerCancel"; + + public final native int getPointerId() /*-{ + var e = this.@com.google.gwt.event.dom.client.DomEvent::nativeEvent; + return e.pointerId; + }-*/; + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveEvent.java new file mode 100644 index 000000000..beabbe74b --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveEvent.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.DomEvent; + +/** + * Represents a native MsPointerMoveEvent event. + */ +public class MsPointerMoveEvent extends MsPointerEvent { + + /** + * Event type for MsPointerMoveEvent. Represents the meta-data associated with + * this event. + */ + private static final Type TYPE = new Type( + MsPointerEvent.MSPOINTERMOVE, new MsPointerMoveEvent()); + + /** + * Gets the event type associated with MsPointerMoveEvent. + * + * @return the handler type + */ + public static Type getType() { + return TYPE; + } + + /** + * Protected constructor, use + * {@link DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent, com.google.gwt.event.shared.HasHandlers)} + * to fire pointer down events. + */ + protected MsPointerMoveEvent() { + } + + @Override + public final Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(MsPointerMoveHandler handler) { + handler.onPointerMove(this); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveHandler.java new file mode 100644 index 000000000..1bf66801a --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerMoveHandler.java @@ -0,0 +1,31 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler interface for {@link MsPointerMoveEvent} events. + */ +public interface MsPointerMoveHandler extends EventHandler { + + /** + * Called when MsPointerMoveEvent is fired. + * + * @param event the {@link MsPointerMoveEvent} that was fired + */ + void onPointerMove(MsPointerMoveEvent event); +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpEvent.java new file mode 100644 index 000000000..d3bee93c2 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpEvent.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.DomEvent; + +/** + * Represents a native MsPointerUpEvent. + */ +public class MsPointerUpEvent extends MsPointerEvent { + + /** + * Event type for MsPointerUpEvent. Represents the meta-data associated with + * this event. + */ + private static final Type TYPE = new Type( + MsPointerEvent.MSPOINTERUP, new MsPointerUpEvent()); + + /** + * Gets the event type associated with MsPointerUpEvent. + * + * @return the handler type + */ + public static Type getType() { + return TYPE; + } + + /** + * Protected constructor, use + * {@link DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent, com.google.gwt.event.shared.HasHandlers)} + * to fire pointer down events. + */ + protected MsPointerUpEvent() { + } + + @Override + public final Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(MsPointerUpHandler handler) { + handler.onPointerUp(this); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpHandler.java new file mode 100644 index 000000000..4f3268b96 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerUpHandler.java @@ -0,0 +1,31 @@ +/* + * Copyright 2013 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler interface for {@link MsPointerUpEvent} events. + */ +public interface MsPointerUpHandler extends EventHandler { + + /** + * Called when MsPointerUpEvent is fired. + * + * @param event the {@link MsPointerUpEvent} that was fired + */ + void onPointerUp(MsPointerUpEvent event); +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouch.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouch.java new file mode 100644 index 000000000..e7279cf69 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouch.java @@ -0,0 +1,60 @@ +/* + * Copyright 2014 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.Touch; + +public class SimulatedTouch extends Touch { + + public static native SimulatedTouch createTouch() /*-{ + // need to native for GwtMockito to work + return {}; + }-*/; + + public native static JsArray createTouchArray() /*-{ + return []; + }-*/; + + protected SimulatedTouch() { + } + + public final native void setClientX(int clientX) /*-{ + this.clientX = clientX; + }-*/; + + public final native void setClientY(int clientY) /*-{ + this.clientY = clientY; + }-*/; + + public final native void setPageX(int pageX) /*-{ + this.pageX = pageX; + }-*/; + + public final native void setPageY(int pageY) /*-{ + this.pageY = pageY; + }-*/; + + public final native void setScreenX(int screenX) /*-{ + this.screenX = screenX; + }-*/; + + public final native void setScreenY(int screenY) /*-{ + this.screenY = screenY; + }-*/; + + public final native void setId(int touchId) /*-{ + this.identifier = touchId + }-*/; +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchCancelEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchCancelEvent.java new file mode 100644 index 000000000..8b10b189b --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchCancelEvent.java @@ -0,0 +1,12 @@ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.TouchCancelEvent; + +public class SimulatedTouchCancelEvent extends TouchCancelEvent +{ + public SimulatedTouchCancelEvent(MsPointerCancelEvent event) { + setNativeEvent(event.getNativeEvent()); + setSource(event.getSource()); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchEndEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchEndEvent.java new file mode 100644 index 000000000..c0d2bae55 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchEndEvent.java @@ -0,0 +1,65 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.Touch; +import com.google.gwt.event.dom.client.TouchEndEvent; + +/** + * A simulated TouchEndEvent is really a MsPointerUpEvent + */ +public class SimulatedTouchEndEvent extends TouchEndEvent { + + private final int clientX; + private final int clientY; + private final int pageX; + private final int pageY; + private int touchId; + + /** + * Construct a simulated TouchEndEvent from a {@link MsPointerUpEvent} + * + * @param event the data for the simulated event; + * @param multiTouch + */ + public SimulatedTouchEndEvent(MsPointerUpEvent event) { + this.touchId = event.getPointerId(); + clientX = event.getClientX(); + clientY = event.getClientY(); + pageX = event.getScreenX(); + pageY = event.getScreenY(); + setNativeEvent(event.getNativeEvent()); + setSource(event.getSource()); + } + + @Override + public JsArray getChangedTouches() { + JsArray array = SimulatedTouch.createTouchArray(); + SimulatedTouch touch = SimulatedTouch.createTouch(); + touch.setClientX(clientX); + touch.setClientY(clientY); + touch.setPageX(pageX); + touch.setPageY(pageY); + touch.setId(touchId); + array.push(touch); + return array; + } + + @Override + public JsArray getTouches() { + return SimulatedTouch.createTouchArray(); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchMoveEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchMoveEvent.java new file mode 100644 index 000000000..715ddbc0a --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchMoveEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.Touch; +import com.google.gwt.event.dom.client.TouchMoveEvent; + +/** + * A simulated TouchMoveEvent is really a MS Pointer move event + */ +public class SimulatedTouchMoveEvent extends TouchMoveEvent { + + private final int clientX; + private final int clientY; + private final int pageX; + private final int pageY; + private int touchId; + + public SimulatedTouchMoveEvent(MsPointerMoveEvent event) { + this.touchId = event.getPointerId(); + clientX = event.getClientX(); + clientY = event.getClientY(); + pageX = event.getScreenX(); + pageY = event.getScreenY(); + setNativeEvent(event.getNativeEvent()); + setSource(event.getSource()); + } + + @Override + public JsArray getChangedTouches() { + JsArray array = SimulatedTouch.createTouchArray(); + SimulatedTouch touch = SimulatedTouch.createTouch(); + touch.setClientX(clientX); + touch.setClientY(clientY); + touch.setPageX(pageX); + touch.setPageY(pageY); + touch.setId(touchId); + array.push(touch); + return array; + } + + @Override + public JsArray getTouches() { + JsArray array = SimulatedTouch.createTouchArray(); + SimulatedTouch touch = SimulatedTouch.createTouch(); + touch.setClientX(clientX); + touch.setClientY(clientY); + touch.setPageX(pageX); + touch.setPageY(pageY); + touch.setId(touchId); + array.push(touch); + return array; + } +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchStartEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchStartEvent.java new file mode 100644 index 000000000..0e1a852b5 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/SimulatedTouchStartEvent.java @@ -0,0 +1,67 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.Touch; +import com.google.gwt.event.dom.client.TouchStartEvent; + +/** + * A simulated TouchStartEvent is really a MS Pointer down event + */ +public class SimulatedTouchStartEvent extends TouchStartEvent { + + private final int clientX; + private final int clientY; + private final int pageX; + private final int pageY; + private int touchId; + + public SimulatedTouchStartEvent(MsPointerDownEvent event) { + this.touchId = event.getPointerId(); + clientX = event.getClientX(); + clientY = event.getClientY(); + pageX = event.getScreenX(); + pageY = event.getScreenY(); + setNativeEvent(event.getNativeEvent()); + setSource(event.getSource()); + } + + @Override + public JsArray getChangedTouches() { + JsArray array = SimulatedTouch.createTouchArray(); + SimulatedTouch touch = SimulatedTouch.createTouch(); + touch.setClientX(clientX); + touch.setClientY(clientY); + touch.setPageX(pageX); + touch.setPageY(pageY); + touch.setId(touchId); + array.push(touch); + return array; + } + + @Override + public JsArray getTouches() { + JsArray array = SimulatedTouch.createTouchArray(); + SimulatedTouch touch = SimulatedTouch.createTouch(); + touch.setClientX(clientX); + touch.setClientY(clientY); + touch.setPageX(pageX); + touch.setPageY(pageY); + touch.setId(touchId); + array.push(touch); + return array; + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchCancelToMsPointerCancelHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchCancelToMsPointerCancelHandler.java new file mode 100644 index 000000000..6ca0470d6 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchCancelToMsPointerCancelHandler.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.TouchCancelHandler; + +/** + * Convert TouchCancelHandlers to MSPointer cancel handlers + */ +public class TouchCancelToMsPointerCancelHandler implements MsPointerCancelHandler { + + private final TouchCancelHandler handler; + + public TouchCancelToMsPointerCancelHandler(TouchCancelHandler handler) { + this.handler = handler; + } + + @Override + public void onPointerCancel(MsPointerCancelEvent event) { + SimulatedTouchCancelEvent simulatedTouchCancelEvent = new SimulatedTouchCancelEvent(event); + handler.onTouchCancel(simulatedTouchCancelEvent); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchEndToMsPointerUpHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchEndToMsPointerUpHandler.java new file mode 100644 index 000000000..ea02e8af9 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchEndToMsPointerUpHandler.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.TouchEndHandler; + +/** + * Convert TouchEndHandlers to MsPointerUpHandlers + */ +public class TouchEndToMsPointerUpHandler implements MsPointerUpHandler { + private final TouchEndHandler handler; + + public TouchEndToMsPointerUpHandler(TouchEndHandler handler) { + this.handler = handler; + } + + /** {@inheritDoc} */ + @Override + public void onPointerUp(MsPointerUpEvent event) { + SimulatedTouchEndEvent simulatedTouchEndEvent = new SimulatedTouchEndEvent(event); + handler.onTouchEnd(simulatedTouchEndEvent); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchMoveToMsPointerMoveHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchMoveToMsPointerMoveHandler.java new file mode 100644 index 000000000..c3670fffe --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchMoveToMsPointerMoveHandler.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.TouchMoveHandler; + +/** + * Convert TouchMoveHandlers to MsPointerMoveHandlers for pointer devices + * + */ +public class TouchMoveToMsPointerMoveHandler implements MsPointerMoveHandler, MsPointerDownHandler, MsPointerUpHandler { + + private boolean ignoreEvent; + private final TouchMoveHandler touchMoveHandler; + + public TouchMoveToMsPointerMoveHandler(TouchMoveHandler touchMoveHandler) { + this.touchMoveHandler = touchMoveHandler; + ignoreEvent = true; + } + + @Override + public void onPointerMove(MsPointerMoveEvent event) { + if (ignoreEvent) + return; + touchMoveHandler.onTouchMove(new SimulatedTouchMoveEvent(event)); + } + + @Override + public void onPointerUp(MsPointerUpEvent event) + { + ignoreEvent = true; + } + + @Override + public void onPointerDown(MsPointerDownEvent event) + { + ignoreEvent = false; + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchStartToMsPointerDownHandler.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchStartToMsPointerDownHandler.java new file mode 100644 index 000000000..14ebe9d58 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/TouchStartToMsPointerDownHandler.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.pointer; + +import com.google.gwt.event.dom.client.TouchStartHandler; + +/** + * Convert TouchStartHandlers to MSPointer down handlers + */ +public class TouchStartToMsPointerDownHandler implements MsPointerDownHandler { + + private final TouchStartHandler handler; + + public TouchStartToMsPointerDownHandler(TouchStartHandler handler) { + this.handler = handler; + } + + @Override + public void onPointerDown(MsPointerDownEvent event) { + SimulatedTouchStartEvent simulatedTouchStartEvent = new SimulatedTouchStartEvent(event); + handler.onTouchStart(simulatedTouchStartEvent); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java index 8981c8fa5..1cc8885f4 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java @@ -16,6 +16,7 @@ package com.googlecode.mgwt.dom.client.event.tap; import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Touch; import com.google.gwt.event.shared.GwtEvent; /** @@ -28,16 +29,14 @@ public class TapEvent extends GwtEvent { private static final Type TYPE = new Type(); - private final int startX; - private final int startY; + private final Touch touch; private final Element targetElement; - public TapEvent(Object source, Element targetElement, int startX, int startY) { - this.targetElement = targetElement; - this.startX = startX; - this.startY = startY; - setSource(source); - } + public TapEvent(Object source, Element targetElement, Touch touch) { + this.targetElement = targetElement; + this.touch = touch; + setSource(source); + } @Override public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { @@ -54,15 +53,23 @@ public static Type getType() { return TYPE; } - public int getStartX() { - return startX; + /** + * Get access to other useful position information related to the tap event + * @return + */ + public Touch getTouch() { + return touch; } - public int getStartY() { - return startY; - } + public int getStartX() { + return touch.getPageX(); + } - /** + public int getStartY() { + return touch.getPageY(); + } + + /** * Returns the element that was the actual target of the Tap event. */ public Element getTargetElement() { diff --git a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java index 47f40de34..5d4a10710 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java @@ -44,6 +44,8 @@ public class TapRecognizer implements TouchHandler { private boolean hasMoved; + private Touch touch; + private int start_x; private int start_y; @@ -78,9 +80,9 @@ public void onTouchStart(TouchStartEvent event) { }else { targetElement = null; } - - start_x = event.getTouches().get(0).getPageX(); - start_y = event.getTouches().get(0).getPageY(); + touch = event.getTouches().get(0); + start_x = touch.getPageX(); + start_y = touch.getPageY(); } @Override @@ -94,7 +96,7 @@ public void onTouchMove(TouchMoveEvent event) { @Override public void onTouchEnd(TouchEndEvent event) { if (!hasMoved && !touchCanceled) { - TapEvent tapEvent = new TapEvent(source, targetElement, start_x, start_y); + TapEvent tapEvent = new TapEvent(source, targetElement, touch); getEventPropagator().fireEvent(source, tapEvent); } } diff --git a/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java b/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java index 4050da085..3f4846b49 100644 --- a/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java +++ b/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java @@ -100,7 +100,7 @@ public boolean isAnimated() { } } - public ImageResource convert(ImageResource resource, String color) { + public void convert(final ImageResource resource, String color, final ImageConverterCallback imageConverterCallback) { if (color == null) { throw new IllegalArgumentException(); @@ -112,50 +112,71 @@ public ImageResource convert(ImageResource resource, String color) { color = maybeExpandColor(color); - int hexColor = Integer.parseInt(color.substring(1), 16); - - int red = hexColor >> 16 & 0xFF; - int green = hexColor >> 8 & 0xFF; - int blue = hexColor & 0xFF; - - int height = resource.getHeight(); - int width = resource.getWidth(); - - ImageElement imageElement = loadImage(resource.getSafeUri().asString(), - width, height); - - Canvas canvas = Canvas.createIfSupported(); - canvas.getElement().setPropertyInt("height", height); - canvas.getElement().setPropertyInt("width", width); - - Context2d context = canvas.getContext2d(); - context.drawImage(imageElement, 0, 0); - ImageData imageData = context.getImageData(0, 0, width, - height); - - CanvasPixelArray canvasPixelArray = imageData.getData(); - - for (int i = 0; i < canvasPixelArray.getLength(); i += 4) { - canvasPixelArray.set(i, red); - canvasPixelArray.set(i + 1, green); - canvasPixelArray.set(i + 2, blue); - canvasPixelArray.set(i + 3, - canvasPixelArray.get(i + 3)); - } - context.putImageData(imageData, 0, 0); - - - return new ConvertedImageResource( - canvas.toDataUrl("image/png"), resource.getWidth(), - resource.getHeight()); + final int hexColor = Integer.parseInt(color.substring(1), 16); + + final int red = hexColor >> 16 & 0xFF; + final int green = hexColor >> 8 & 0xFF; + final int blue = hexColor & 0xFF; + + final int height = resource.getHeight(); + final int width = resource.getWidth(); + + loadImage(resource.getSafeUri().asString(), width, height, new LoadImageCallback() { + @Override + public void onFailure(Throwable caught) + { + imageConverterCallback.onFailure(caught); + } + + @Override + public void onSuccess(ImageElement imageElement) + { + try + { + Canvas canvas = Canvas.createIfSupported(); + canvas.getElement().setPropertyInt("height", height); + canvas.getElement().setPropertyInt("width", width); + + Context2d context = canvas.getContext2d(); + context.drawImage(imageElement, 0, 0); + ImageData imageData = context.getImageData(0, 0, width, height); + + CanvasPixelArray canvasPixelArray = imageData.getData(); + + for (int i = 0; i < canvasPixelArray.getLength(); i += 4) { + canvasPixelArray.set(i, red); + canvasPixelArray.set(i + 1, green); + canvasPixelArray.set(i + 2, blue); + canvasPixelArray.set(i + 3, + canvasPixelArray.get(i + 3)); + } + context.putImageData(imageData, 0, 0); + imageConverterCallback.onSuccess(new ConvertedImageResource( + canvas.toDataUrl("image/png"), resource.getWidth(), + resource.getHeight())); + } + catch(Throwable e) + { + this.onFailure(e); + } + } + }); } - protected native ImageElement loadImage(String dataUrl, int width, int height) /*-{ + protected native void loadImage(String dataUrl, int width, int height, LoadImageCallback callback) /*-{ var img = new Image(); img.width = width; img.height = height; img.src = dataUrl; - return img; + img.onload = $entry(function(){ + callback.@com.googlecode.mgwt.image.client.LoadImageCallback::onSuccess(Lcom/google/gwt/dom/client/ImageElement;)(img); + }); + img.onerror = $entry(function(e){ + callback.@com.googlecode.mgwt.image.client.LoadImageCallback::onFailure(Ljava/lang/Throwable;)(e); + }); + img.onabort = $entry(function(e){ + callback.@com.googlecode.mgwt.image.client.LoadImageCallback::onFailure(Ljava/lang/Throwable;)(e); + }); }-*/; private String maybeExpandColor(String color) { diff --git a/src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java b/src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java new file mode 100644 index 000000000..6a5754627 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java @@ -0,0 +1,8 @@ +package com.googlecode.mgwt.image.client; + +import com.google.gwt.resources.client.ImageResource; + +public interface ImageConverterCallback{ + public void onSuccess(ImageResource imageResource); + public void onFailure(Throwable e); +} diff --git a/src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java b/src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java new file mode 100644 index 000000000..aafdb1dda --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java @@ -0,0 +1,8 @@ +package com.googlecode.mgwt.image.client; + +import com.google.gwt.dom.client.ImageElement; + +public interface LoadImageCallback{ + public void onSuccess(ImageElement imageElement); + public void onFailure(Throwable e); +} diff --git a/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml b/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml index 00b36e544..b168089c0 100644 --- a/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml @@ -53,10 +53,6 @@ under * the License. - - - - @@ -65,16 +61,23 @@ under * the License. - + - + + + + + + + + @@ -103,10 +106,34 @@ under * the License. + + + + + + + + + + + + + + + + + + + + + + + + @@ -160,8 +187,20 @@ under * the License. + + + + + + + + + + + + diff --git a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java index c940e96cf..52880b8c8 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java @@ -33,7 +33,6 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.RootPanel; - import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent; import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent.ORIENTATION; import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler; @@ -151,6 +150,25 @@ public static void applySettings(MGWTSettings settings) { } scrollingDisabled = settings.isPreventScrolling(); + + if (TouchSupport.isTouchEventsEmulatedUsingPointerEvents()) + { + MetaElement ieCompatible = Document.get().createMetaElement(); + ieCompatible.setHttpEquiv("x-ua-compatible"); + ieCompatible.setContent("IE=10"); + head.appendChild(ieCompatible); + + MetaElement tapHighlight = Document.get().createMetaElement(); + tapHighlight.setName("msapplication-tap-highlight"); + tapHighlight.setContent("no"); + head.appendChild(tapHighlight); + + if (settings.isPreventScrolling()) { + BodyElement body = Document.get().getBody(); + setupPreventScrollingIE10(body); + } + } + if (settings.isPreventScrolling() && getOsDetection().isIOs()) { BodyElement body = Document.get().getBody(); setupPreventScrolling(body); @@ -296,15 +314,21 @@ private static Element getHead() { } private static native void setupPreventScrolling(Element el)/*-{ - var func = function(event) { - event.preventDefault(); - return false; - }; - - el.ontouchmove = func; - + var func = function(event) { + var tagName = event.target.tagName; + if ((tagName == 'INPUT') || (tagName == 'SELECT') || (tagName == 'TEXTAREA')) { + return true; + } + event.preventDefault(); + return false; + }; + el.ontouchmove = func; }-*/; + private static void setupPreventScrollingIE10(Element el) { + el.setAttribute("style", "-ms-touch-action: none;"); + } + /** * A utility method to hide the soft keyboard */ diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java index 0c6e3580f..47655359a 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java @@ -124,6 +124,12 @@ public interface OsDetection { */ public boolean isPhone(); + /** + * Are we running on Windows Phone 8/8.1 + * @return + */ + public boolean isWindowsPhone(); + /** * Are we running on a blackberry device * diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java index 5118feade..01b9c8dc7 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java @@ -78,7 +78,17 @@ public boolean isAndroidPhone() { @Override public boolean isPhone() { - return isIPhone() || isRetina() || isAndroidPhone(); + return isIPhone() || isRetina() || isAndroidPhone() || isWindowsPhone(); + } + + @Override + public boolean isWindowsPhone() + { + String userAgent = getUserAgent(); + if (userAgent.contains("windows phone 8")) { + return true; + } + return false; } @Override @@ -109,6 +119,14 @@ native String getUserAgent() /*-{ }-*/; native double getDevicePixelRatio() /*-{ + if (!$wnd.devicePixelRatio) { + try { + if ('deviceXDPI' in $wnd.screen) { + $wnd.devicePixelRatio = $wnd.screen.deviceXDPI / $wnd.screen.logicalXDPI; + } + } + catch(e) {} + } return $wnd.devicePixelRatio || 1; }-*/; @@ -140,4 +158,5 @@ public boolean isAndroid4_3_orLower() { return false; } + } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java b/src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java new file mode 100644 index 000000000..cf70e7c73 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java @@ -0,0 +1,100 @@ +package com.googlecode.mgwt.ui.client; + +import com.google.gwt.core.shared.GWT; + +public abstract class TouchSupport { + + private static TouchSupport impl = GWT.create(TouchSupport.class); + + protected abstract boolean _isTouchEventsEmulatedUsingMouseEvents(); + + protected abstract boolean _isTouchEventsEmulatedUsingPointerEvents(); + + protected abstract boolean _isTouchEventsSupported(); + + public static boolean isTouchEventsEmulatedUsingMouseEvents() { + return impl._isTouchEventsEmulatedUsingMouseEvents(); + } + + public static boolean isTouchEventsEmulatedUsingPointerEvents() { + return impl._isTouchEventsEmulatedUsingPointerEvents(); + } + + public static boolean isTouchEventsSupported() { + return impl._isTouchEventsSupported(); + } + + public static class TouchSupportStandard extends TouchSupport { + + private static boolean hasTouchSupport; + private static TouchSupport delegate; + + static { + hasTouchSupport = hasTouch(); + if (hasTouchSupport) { + delegate = new TouchSupportNative(); + } + } + + private static native boolean hasTouch() /*-{ + return 'ontouchstart' in $doc.documentElement; + }-*/; + + + @Override + protected boolean _isTouchEventsEmulatedUsingMouseEvents() { + if (hasTouchSupport) { + return delegate._isTouchEventsEmulatedUsingMouseEvents(); + } + return true; + } + + @Override + protected boolean _isTouchEventsEmulatedUsingPointerEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsSupported() { + if (hasTouchSupport) { + return delegate._isTouchEventsSupported(); + } + return false; + } + } + + public static class TouchSupportEmulatedPointer extends TouchSupport { + @Override + protected boolean _isTouchEventsEmulatedUsingMouseEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsEmulatedUsingPointerEvents() { + return true; + } + + @Override + protected boolean _isTouchEventsSupported() { + return false; + } + } + + public static class TouchSupportNative extends TouchSupport { + @Override + protected boolean _isTouchEventsEmulatedUsingMouseEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsEmulatedUsingPointerEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsSupported() { + return true; + } + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java b/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java index a5fa29d9a..edbd0329d 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java @@ -19,8 +19,8 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.resources.client.ImageResource; - import com.googlecode.mgwt.image.client.ImageConverter; +import com.googlecode.mgwt.image.client.ImageConverterCallback; import com.googlecode.mgwt.ui.client.MGWT; public class IconHandler { @@ -86,20 +86,30 @@ private static class IconHandlerEmulatedImpl extends IconHandlerNativeImpl { private static final ImageConverter converter = new ImageConverter(); @Override - public void setIcons(Element element, ImageResource icon, String color) { + public void setIcons(final Element element, ImageResource icon, String color) { if (icon == null) { return; } - element.getStyle().setBackgroundColor("transparent"); - ImageResource convertImageResource = converter.convert(icon, color); - Dimension dimensions = calculateDimensions(convertImageResource); - element.getStyle().setWidth(dimensions.width, Unit.PX); - element.getStyle().setHeight(dimensions.height, Unit.PX); - element.getStyle().setBackgroundImage( - "url(" + convertImageResource.getSafeUri().asString() + ")"); - element.getStyle().setProperty("backgroundSize", - dimensions.width + "px " + dimensions.height + "px"); + converter.convert(icon, color, new ImageConverterCallback() { + + @Override + public void onFailure(Throwable caught) { + } + + @Override + public void onSuccess(ImageResource convertImageResource) { + element.getStyle().setBackgroundColor("transparent"); + Dimension dimensions = calculateDimensions(convertImageResource); + element.getStyle().setWidth(dimensions.width, Unit.PX); + element.getStyle().setHeight(dimensions.height, Unit.PX); + element.getStyle().setBackgroundImage( + "url(" + convertImageResource.getSafeUri().asString() + ")"); + element.getStyle().setProperty("backgroundSize", + dimensions.width + "px " + dimensions.height + "px"); + } + + }); } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java new file mode 100644 index 000000000..2ea02f48e --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java @@ -0,0 +1,130 @@ +package com.googlecode.mgwt.ui.client.util.impl; + +import com.google.gwt.core.client.JsArrayInteger; +import com.google.gwt.dom.client.Element; + +/** + * No idea why but there is a slight difference between Windows Phone 8.1 and + * Windows Phone 8.1 Update. When using translate3d with z=0 getComputedStyle returns + * a 3D matrix on Windows Phone 8.1 but for Windows Phone 8.1 Update it returns + * a 2D matrix. So we check which matrix is returned before using the relevant elements + */ +public class CssUtilIE10Impl implements CssUtilImpl { + + public CssUtilIE10Impl() { + } + + @Override + public void translate(Element el, int x, int y) { + String cssText = "translate3d(" + x + "px," + y + "px,0px)"; + _translate(el, cssText); + } + + @Override + public native void setDelay(Element el, int milliseconds) /*-{ + el.style.transitionDelay = milliseconds + "ms"; + }-*/; + + @Override + public native void setOpacity(Element el, double opacity) /*-{ + el.style.opacity = opacity; + }-*/; + + @Override + public native void setDuration(Element el, int time) /*-{ + el.style.transitionDuration = time + "ms"; + }-*/; + + private native void _translate(Element el, String css)/*-{ + el.style.transform = css; + }-*/; + + @Override + public void rotate(Element el, int degree) { + el.getStyle().setProperty("transform", "rotateZ(" + degree + "deg)"); + } + + @Override + public boolean hasTransform() { + return true; + } + + @Override + public boolean hasTransistionEndEvent() { + return true; + } + + @Override + public boolean has3d() { + return true; + } + + @Override + public String getTransformProperty() { + return "transform"; + } + + @Override + public int[] getPositionFromTransForm(Element element) { + JsArrayInteger array = getPositionFromTransform(element); + return new int[] {array.get(0), array.get(1)}; + } + + private native JsArrayInteger getPositionFromTransform(Element el)/*-{ + var matrix = getComputedStyle(el, null)['transform'].replace( + /[^0-9-.,]/g, '').split(','); + if (matrix.length === 6) { + var x = matrix[4] * 1; + var y = matrix[5] * 1; + return [ x, y ]; + } + else { + var x = matrix[12] * 1; + var y = matrix[13] * 1; + return [ x, y ]; + } + }-*/; + + @Override + public native int getTopPositionFromCssPosition(Element element) /*-{ + return getComputedStyle(element, null).top.replace(/[^0-9-]/g, '') * 1; + }-*/; + + @Override + public native int getLeftPositionFromCssPosition(Element element)/*-{ + return getComputedStyle(element, null).left.replace(/[^0-9-]/g, '') * 1; + }-*/; + + @Override + public native void resetTransform(Element el) /*-{ + el.style.transform = ""; + }-*/; + + @Override + public native void setTransistionProperty(Element element, String string) /*-{ + element.transitionProperty = string; + }-*/; + + @Override + public native void setTransFormOrigin(Element el, int x, int y) /*-{ + el.transformOrigin = x + " " + y; + }-*/; + + @Override + public native void setTransistionTimingFunction(Element element, String string) /*-{ + el.transitionTimingFunction = string; + }-*/; + + @Override + public void setTranslateAndZoom(Element el, int x, int y, double scale) { + String cssText = "translate3d(" + x + "px, " + y + "px,0px) scale(" + scale + ")"; + el.getStyle().setProperty("transform", cssText); + } + + @Override + public void translatePercent(Element el, double x, double y) { + String cssText = "translate3d(" + x + "%, " + y + "%,0%)"; + _translate(el, cssText); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/IEOrientationHandler.java b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/IEOrientationHandler.java new file mode 100644 index 000000000..271f16790 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/IEOrientationHandler.java @@ -0,0 +1,171 @@ +package com.googlecode.mgwt.ui.client.util.impl; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.dom.client.Document; +import com.google.gwt.event.logical.shared.CloseEvent; +import com.google.gwt.event.logical.shared.CloseHandler; +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; +import com.google.gwt.user.client.Window; +import com.google.web.bindery.event.shared.EventBus; +import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent; +import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent.ORIENTATION; +import com.googlecode.mgwt.ui.client.util.OrientationHandler; +import com.googlecode.mgwt.ui.client.widget.main.MainResourceAppearance.UtilCss; +import com.googlecode.mgwt.ui.client.widget.main.MainResourceHolder; + +/** + * IE11 on windows 8 or windows phone 8.1 supports orientation events but via + * the Screen object, IE10 on windows phone 8 does not support orientation events. + * IE10 on windows phone/desktop does support resize events but they do not appear to + * fire on wp8 when the viewport is set to device-width. We fallback to resize events anyhow. + */ +public class IEOrientationHandler implements OrientationHandler { + + private static native JavaScriptObject setupOrientation0(IEOrientationHandler handler)/*-{ + var func = $entry(function(evt) { + handler.@com.googlecode.mgwt.ui.client.util.impl.IEOrientationHandler::onorientationChange(Ljava/lang/String;)(evt.target.msOrientation); + }); + $wnd.screen.onmsorientationchange = func; + return func; + }-*/; + + private static native void destroyOrientation(JavaScriptObject o)/*-{ + $wnd.screen.onmsorientationchange = null; + }-*/; + + private boolean orientationSupported = isOrientationSupported(); + + // update styles on body + private static void setClasses(ORIENTATION o) { + + UtilCss utilCss = MainResourceHolder.getUtilCss(); + switch (o) { + + case PORTRAIT: + Document.get().getBody().addClassName(utilCss.portrait()); + Document.get().getBody().removeClassName(utilCss.landscape()); + break; + case LANDSCAPE: + Document.get().getBody().addClassName(utilCss.landscape()); + Document.get().getBody().removeClassName(utilCss.portrait()); + break; + + default: + break; + } + } + + protected static ORIENTATION currentOrientation; + protected static boolean orientationInitialized; + protected JavaScriptObject nativeJsFunction; + + private EventBus manager; + + @Override + public final void maybeSetupOrientation(EventBus manager) { + this.manager = manager; + if (orientationInitialized) + return; + if (!GWT.isClient()) { + return; + } + doSetupOrientation(); + orientationInitialized = true; + setClasses(getOrientation()); + } + + protected void setupNativeBrowerOrientationHandler() { + nativeJsFunction = setupOrientation0(this); + Window.addCloseHandler(new CloseHandler() { + + @Override + public void onClose(CloseEvent event) { + destroyOrientation(nativeJsFunction); + } + }); + } + + protected static native String getOrientation0()/*-{ + if (typeof ($wnd.screen.msOrientation) == 'undefined') { + return "portrait-primary"; + } + return $wnd.screen.msOrientation; + }-*/; + + protected static ORIENTATION getBrowserOrientation() { + String orientation = getOrientation0(); + + ORIENTATION o; + if ("landscape-primary".equals(orientation) || "landscape-secondary".equals(orientation)) { + o = ORIENTATION.LANDSCAPE; + } + else { + o = ORIENTATION.PORTRAIT; + } + return o; + } + + void fireOrientationChangedEvent(ORIENTATION orientation) { + setClasses(orientation); + manager.fireEvent(new OrientationChangeEvent(orientation)); + } + + private void onorientationChange(String orientation) { + ORIENTATION o; + if ("landscape-primary".equals(orientation) || "landscape-secondary".equals(orientation)) { + o = ORIENTATION.LANDSCAPE; + } + else { + o = ORIENTATION.PORTRAIT; + } + currentOrientation = o; + fireOrientationChangedEvent(o); + } + + public void doSetupOrientation() { + + if (!orientationSupported) { + Window.addResizeHandler(new ResizeHandler() { + + @Override + public void onResize(ResizeEvent event) { + ORIENTATION orientation = getOrientation(); + if (orientation != currentOrientation) { + currentOrientation = orientation; + fireOrientationChangedEvent(orientation); + } + } + }); + } else { + setupNativeBrowerOrientationHandler(); + } + + } + + /** + * Get the current orientation of the device + * + * @return the current orientation of the device + */ + public ORIENTATION getOrientation() { + if (!orientationSupported) { + int height = Window.getClientHeight(); + int width = Window.getClientWidth(); + + if (width > height) { + return ORIENTATION.LANDSCAPE; + } else { + return ORIENTATION.PORTRAIT; + } + } else { + return getBrowserOrientation(); + } + } + + private static native boolean isOrientationSupported() /*-{ + return "msOrientation" in $wnd.screen; + }-*/; + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css index ee13eed55..de55a77c2 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css @@ -1,3 +1,4 @@ +@if user.agent safari { .in, .out { -webkit-animation-timing-function: ease-in-out; -webkit-animation-duration: 300ms; @@ -29,3 +30,38 @@ from { opacity: 0; } to { opacity: 1; } } +} + +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: appear; + } + + .out { + animation-name: dissolve; + } + + .in.reverse { + animation-name: appear; + } + + .out.reverse { + animation-name: dissolve; + } + + @keyframes dissolve { + from { opacity: 1; } + to { opacity: 0; } + } + + @keyframes appear { + from { opacity: 0; } + to { opacity: 1; } + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css index 602c79db9..998e59438 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css @@ -1,3 +1,4 @@ +@if user.agent safari { .in, .out { -webkit-animation-timing-function: ease-in-out; -webkit-animation-duration: 300ms; @@ -28,3 +29,37 @@ from { opacity: 1; } to { opacity: 0; } } +} + +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: fadein; + } + .out { + animation-name: fadeout; + } + + .in.reverse { + animation-name: fadein; + } + + .out.reverse { + animation-name: fadeout; + } + + @keyframes fadein { + from { opacity: 0; } + to { opacity: 1; } + } + + @keyframes fadeout { + from { opacity: 1; } + to { opacity: 0; } + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css index cb9df89f4..dcda09138 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css @@ -1,3 +1,4 @@ +@if user.agent safari { .in, .out { -webkit-animation-timing-function: ease-in-out; -webkit-animation-duration: 300ms; @@ -41,3 +42,50 @@ from { -webkit-transform: rotateY(0) scale(1); } to { -webkit-transform: rotateY(180deg) scale(.8); } } +} + +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + animation-duration: .65s; + backface-visibility: hidden; + } + + .in { + animation-name: flipinfromleft; + } + + .out { + animation-name: flipouttoleft; + } + + .in.reverse { + animation-name: flipinfromright; + } + + .out.reverse { + animation-name: flipouttoright; + } + + @keyframes flipinfromright { + from { transform: rotateY(-180deg) scale(.8); } + to { transform: rotateY(0) scale(1); } + } + + @keyframes flipinfromleft { + from { transform: rotateY(180deg) scale(.8); } + to { transform: rotateY(0) scale(1); } + } + + @keyframes flipouttoleft { + from { transform: rotateY(0) scale(1); } + to { transform: rotateY(-180deg) scale(.8); } + } + + @keyframes flipouttoright { + from { transform: rotateY(0) scale(1); } + to { transform: rotateY(180deg) scale(.8); } + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css index 58689fa58..37bad2cf8 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css @@ -1,3 +1,4 @@ +@if user.agent safari { .in, .out { -webkit-animation-timing-function: ease-in-out; -webkit-animation-duration: 300ms; @@ -41,3 +42,50 @@ opacity: 0; } } +} + +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: popin; + } + + .out { + animation-name: popout; + } + + .in.reverse { + animation-name: popin; + } + + .out.reverse { + animation-name: popout; + } + + @keyframes popin { + from { + transform: scale(.3); + opacity: 0; + } + to { + transform: scale(1); + opacity: 1; + } + } + + @keyframes popout { + from { + transform: scale(1); + opacity: 1; + } + to { + transform: scale(.3); + opacity: 0; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css index 9fc0ea77e..34870a237 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css @@ -1,3 +1,4 @@ +@if user.agent safari { .in, .out { -webkit-animation-timing-function: ease-in-out; -webkit-animation-duration: 300ms; @@ -43,3 +44,52 @@ from { -webkit-transform: translateY(-100%); } to { -webkit-transform: translateY(0%); } } +} + +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: slideupfrombottom; + z-index: 10; + } + + .out { + animation-name: slideupfrommiddle; + z-index: 0; + } + + .out.reverse { + z-index: 10; + animation-name: slidedownfrommiddle; + } + + .in.reverse { + z-index: 0; + animation-name: slidedownfromtop; + } + + @keyframes slideupfrombottom { + from { transform: translateY(100%); } + to { transform: translateY(0); } + } + + @keyframes slidedownfrommiddle { + from { transform: translateY(0); } + to { transform: translateY(100%); } + } + + @keyframes slideupfrommiddle { + from { transform: translateY(0); } + to { transform: translateY(-100%); } + } + + @keyframes slidedownfromtop { + from { transform: translateY(-100%); } + to { transform: translateY(0%); } + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css index 407ff7c55..ef0b389a9 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css @@ -1,3 +1,4 @@ +@if user.agent safari { .in, .out { -webkit-animation-timing-function: ease-in-out; -webkit-animation-duration: 300ms; @@ -47,3 +48,56 @@ from { -webkit-transform: translateX(0); } to { -webkit-transform: translateX(100%); } } +} + +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + z-index:10; + } + + .out{ + z-index: 0 !important; + } + + .in { + animation-name: slideinfromright; + } + + .out { + animation-name: slideouttoleft; + } + + .in.reverse { + animation-name: slideinfromleft; + } + + .out.reverse { + animation-name: slideouttoright; + } + + @keyframes slideinfromright { + from { transform: translateX(100%); } + to { transform: translateX(0); } + } + + @keyframes slideinfromleft { + from { transform: translateX(-100%); } + to { transform: translateX(0); } + } + + @keyframes slideouttoleft { + from { transform: translateX(0); } + to { transform: translateX(-100%); } + } + + @keyframes slideouttoright { + from { transform: translateX(0); } + to { transform: translateX(100%); } + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css index 18d2e6db5..b06722ddd 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css @@ -1,3 +1,4 @@ +@if user.agent safari { .in, .out { -webkit-animation-timing-function: ease-in-out; -webkit-animation-fill-mode: both; @@ -79,3 +80,87 @@ -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); } } +} + +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-fill-mode: both; + transform: perspective(800); + animation-duration: .7s; + } + + .out { + animation-name: swapouttoleft; + } + .in { + animation-name: swapinfromright; + } + .out.reverse { + animation-name: swapouttoright; + } + .in.reverse { + animation-name: swapinfromleft; + } + + + @keyframes swapouttoright { + 0% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + animation-timing-function: ease-in-out; + } + 50% { + transform: translate3d(-180px, 0px, -400px) rotateY(20deg); + animation-timing-function: ease-in; + opacity: 0.8; + } + 100% { + transform: translate3d(0px, 0px, -800px) rotateY(70deg); + opacity: 0; + } + } + + @keyframes swapouttoleft { + 0% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + animation-timing-function: ease-in-out; + } + 50% { + transform: translate3d(180px, 0px, -400px) rotateY(-20deg); + animation-timing-function: ease-in; + opacity: 0.8; + } + 100% { + transform: translate3d(0px, 0px, -800px) rotateY(-70deg); + opacity: 0; + } + } + + @keyframes swapinfromright { + 0% { + transform: translate3d(0px, 0px, -800px) rotateY(70deg); + animation-timing-function: ease-out; + } + 50% { + transform: translate3d(-180px, 0px, -400px) rotateY(20deg); + animation-timing-function: ease-in-out; + } + 100% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + } + } + + @keyframes swapinfromleft { + 0% { + transform: translate3d(0px, 0px, -800px) rotateY(-70deg); + animation-timing-function: ease-out; + } + 50% { + transform: translate3d(180px, 0px, -400px) rotateY(-20deg); + animation-timing-function: ease-in-out; + } + 100% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/AnimationWidgetKeyFrameImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/AnimationWidgetKeyFrameImpl.java index b0ff2375e..a5d79a18b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/AnimationWidgetKeyFrameImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/AnimationWidgetKeyFrameImpl.java @@ -186,7 +186,7 @@ public void setSecondWidget(IsWidget w) { private native void blurBeforeAnimation() /*-{ var node = $doc.querySelector(":focus"); - if (node != null) { + if ((node != null) && !((node.nodeType === 1) && (node.nodeName === "BODY"))) { if (typeof (node.blur) == "function") { node.blur(); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/animation-display.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/animation-display.css index 7ad9c9954..1ddb0ea40 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/animation-display.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/impl/animation-display.css @@ -3,7 +3,6 @@ width: 100%; height: 100%; overflow:hidden; - -webkit-backface-visibility: hidden; } .display { @@ -13,8 +12,29 @@ right: 0px; bottom: 0px; overflow:hidden; - -webkit-transform-style: preserve-3d; - -webkit-backface-visibility: hidden; - -webkit-transform: translate3d(0,0,0) rotate(0) scale(1); - -webkit-perspective: 800; } + + +@if user.agent safari { + .displayContainer { + -webkit-backface-visibility: hidden; + } + + .display { + -webkit-transform-style: preserve-3d; + -webkit-backface-visibility: hidden; + -webkit-transform: translate3d(0,0,0) rotate(0) scale(1); + -webkit-perspective: 800; + } +} +@if user.agent ie10 { + .displayContainer { + backface-visibility: hidden; + } + + .display { + backface-visibility: hidden; + transform: translate3d(0,0,0) rotate(0) scale(1); + perspective: 800; + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java index d838e6570..9905dad22 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java @@ -18,12 +18,12 @@ import com.google.gwt.event.dom.client.TouchMoveEvent; import com.google.gwt.event.dom.client.TouchStartEvent; import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.HasText; - import com.googlecode.mgwt.dom.client.event.tap.TapEvent; import com.googlecode.mgwt.dom.client.event.tap.TapHandler; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -import com.googlecode.mgwt.ui.client.MGWT; +import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.widget.touch.TouchWidget; /** @@ -32,7 +32,11 @@ public abstract class ButtonBase extends TouchWidget implements HasText { private boolean active; - + // a temp fix where we no longer add the default touch handlers to the button + // until a call is made to set the element for the widget. This is required since + // it is not possible to add a bitless dom handler until the element has been set + private boolean defaultHandlersAdded; + private final ButtonBaseAppearance baseAppearance; /** @@ -43,56 +47,6 @@ public abstract class ButtonBase extends TouchWidget implements HasText { */ public ButtonBase(ButtonBaseAppearance appearance) { this.baseAppearance = appearance; - - addTouchHandler(new TouchHandler() { - - @Override - public void onTouchCancel(TouchCancelEvent event) { - event.stopPropagation(); - event.preventDefault(); - removeStyleName(ButtonBase.this.baseAppearance.css().active()); - if (MGWT.getFormFactor().isDesktop()) { - DOM.releaseCapture(getElement()); - } - active = false; - } - - @Override - public void onTouchEnd(TouchEndEvent event) { - event.stopPropagation(); - event.preventDefault(); - removeStyleName(ButtonBase.this.baseAppearance.css().active()); - if (MGWT.getFormFactor().isDesktop()) { - DOM.releaseCapture(getElement()); - } - active = false; - } - - @Override - public void onTouchMove(TouchMoveEvent event) { - event.preventDefault(); - event.stopPropagation(); - } - - @Override - public void onTouchStart(TouchStartEvent event) { - event.stopPropagation(); - event.preventDefault(); - addStyleName(ButtonBase.this.baseAppearance.css().active()); - if (MGWT.getFormFactor().isDesktop()) { - DOM.setCapture(getElement()); - } - active = true; - } - }); - - addTapHandler(new TapHandler() { - - @Override - public void onTap(TapEvent event) { - removeStyleName(ButtonBase.this.baseAppearance.css().active()); - } - }); } @Override @@ -108,4 +62,69 @@ public void setText(String text) { public boolean isActive() { return active; } + + @Override + protected void setElement(Element elem) + { + super.setElement(elem); + + if (!defaultHandlersAdded) + { + addTouchHandler(new TouchHandler() { + + @Override + public void onTouchCancel(TouchCancelEvent event) { + event.stopPropagation(); + event.preventDefault(); + removeStyleName(ButtonBase.this.baseAppearance.css().active()); + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + DOM.releaseCapture(getElement()); + } + active = false; + } + + @Override + public void onTouchEnd(TouchEndEvent event) { + event.stopPropagation(); + event.preventDefault(); + removeStyleName(ButtonBase.this.baseAppearance.css().active()); + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + DOM.releaseCapture(getElement()); + } + active = false; + } + + @Override + public void onTouchMove(TouchMoveEvent event) { + event.preventDefault(); + event.stopPropagation(); + } + + @Override + public void onTouchStart(TouchStartEvent event) { + event.stopPropagation(); + event.preventDefault(); + addStyleName(ButtonBase.this.baseAppearance.css().active()); + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + DOM.setCapture(getElement()); + } + active = true; + } + }); + + addTapHandler(new TapHandler() { + + @Override + public void onTap(TapEvent event) { + removeStyleName(ButtonBase.this.baseAppearance.css().active()); + } + }); + defaultHandlersAdded = true; + } + } + + public ButtonBaseAppearance getAppearance() { + return baseAppearance; + } + } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css index e0951f493..b087d34ba 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css @@ -15,9 +15,9 @@ } } -@if user.agent gecko1_8 { +@if user.agent ie10 { .mgwt-ImageButton { - display: -moz-box; + display: -ms-flexbox; } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/buttonbar/buttonbar.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/buttonbar/buttonbar.css index 936a6c2a9..fd0e425b7 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/buttonbar/buttonbar.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/buttonbar/buttonbar.css @@ -26,12 +26,19 @@ } } -@if user.agent ie9 ie10 { +@if user.agent ie9 { .mgwt-ButtonBar { display: table; } } +@if user.agent ie10 { + .mgwt-ButtonBar { + display: -ms-flexbox; + -ms-flex-direction: horizontal; + } +} + .mgwt-ButtonBar { display: flex; align-items: center; @@ -46,7 +53,7 @@ font-weight: bold; } -@if user.agent ie9 ie10 { +@if user.agent ie9 { .mgwt-ButtonBar-text { display: table-cell; vertical-align: middle; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css index 45a99122e..1d090f735 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/carousel.css @@ -15,6 +15,13 @@ } } +@if user.agent ie10 { + .mgwt-Carousel { + display: -ms-flexbox; + -ms-flex: 1 1; + } +} + .mgwt-Carousel { position: relative; flex:1; @@ -29,6 +36,12 @@ } } +@if user.agent ie10 { + .mgwt-Carousel-Scroller, .mgwt-Carousel-Container { + -ms-flex: 1 1; + } +} + .mgwt-Carousel-Scroller { flex: 1 } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/options/options-dialog.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/options/options-dialog.css index 25e727cc2..fea2b8593 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/options/options-dialog.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/options/options-dialog.css @@ -11,4 +11,10 @@ background-image: literal('-webkit-gradient(linear, 0% 0, 0% 100%, from(rgba(50, 74, 103, 0.9)), color-stop(0.02, rgba(20, 25, 35, 0.9) ), to(rgba(0, 0, 0, 0.0) ) )'); border-top: 1px solid #030506; padding: 10px; +} + +@if user.agent ie10 { + .mgwt-OptionsDialog { + background-image: linear-gradient(to bottom, rgba(50, 74, 103, 0.9) 0%, rgba(20, 25, 35, 0.9) 2%, rgba(0, 0, 0, 0.0) 100%); + } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog-button.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog-button.css index dfb2020ae..5685a856a 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog-button.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog-button.css @@ -3,6 +3,7 @@ @external mgwt-DialogButton-cancel, mgwt-DialogButton-active; } .mgwt-DialogButton { + -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; padding: 9px 13px; @@ -23,6 +24,12 @@ } } +@if user.agent ie10 { + .mgwt-DialogButton { + -ms-flex: 1 1; + } +} + .mgwt-DialogButton-ok, .mgwt-DialogButton-cancel { margin-top: 10px; margin-right: 5px; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog.css index 8b45fc404..7c89bac5b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/panel/dialog.css @@ -33,15 +33,32 @@ text-align: center; } +@if user.agent ie10 { + .mgwt-DialogPanel-footer { + display: -ms-flexbox; + -ms-flex-pack: center; + } +} + +@if user.agent safari { + .mgwt-DialogPanel-footer { + display: -webkit-box; /* iOS < 7 && Android < 4.4*/ + display: -webkit-flex; + -webkit-box-pack: center; /* iOS < 7 && Android < 4.4*/ + -webkit-justify-content: center; + } +} + +@if user.agent gecko1_8 { + .mgwt-DialogPanel-footer { + display: -moz-box; + -moz-justify-content: center; + } +} + .mgwt-DialogPanel-footer { margin-top: 10px; - display: -webkit-box; /* iOS < 7 && Android < 4.4*/ - display: -moz-box; - display: -ms-flexbox; - display: -webkit-flex; display: flex; - -webkit-box-pack: center; /* iOS < 7 && Android < 4.4*/ - -webkit-justify-content: center; - -moz-justify-content: center; justify-content: center; } + diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/form/form.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/form/form.css index cfe769c52..89a59f55c 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/form/form.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/form/form.css @@ -27,12 +27,18 @@ } } +@if user.agent ie10 { + .mgwt-Form-Entry { + display: -ms-flexbox; + -ms-flex-pack: center; + } +} + @if user.agent gecko1_8 { .mgwt-Form-Entry { width: 100%; -moz-justify-content: center; display: -moz-box; - display: -ms-flexbox; /* IE is in FF permutation */ } } @@ -57,6 +63,13 @@ } } +@if user.agent ie10 { + .mgwt-Form-Entry-label { + width: 30%; + display: -ms-flexbox; + } +} + @if user.agent gecko1_8 { .mgwt-Form-Entry-label { width: 30%; @@ -81,6 +94,14 @@ } } +@if user.agent ie10 { + .mgwt-Form-Entry-container { + -ms-flex: 1 1; + -ms-flex-pack: end; + display: -ms-flexbox; + } +} + @if user.agent gecko1_8 { .mgwt-Form-Entry-container { -moz-box-flex: 1; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java index a479b7788..f24fb1bbc 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java @@ -31,9 +31,8 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.HasValue; - import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -import com.googlecode.mgwt.ui.client.MGWT; +import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.util.CssUtil; import com.googlecode.mgwt.ui.client.widget.touch.TouchWidget; @@ -59,7 +58,7 @@ public void onTouchCancel(TouchCancelEvent event) { } event.stopPropagation(); event.preventDefault(); - if (MGWT.getFormFactor().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.releaseCapture(getElement()); } setValue(getValue()); @@ -73,7 +72,7 @@ public void onTouchEnd(TouchEndEvent event) { event.stopPropagation(); event.preventDefault(); - if (MGWT.getFormFactor().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.releaseCapture(getElement()); } @@ -120,7 +119,7 @@ public void onTouchStart(TouchStartEvent event) { } event.stopPropagation(); event.preventDefault(); - if (MGWT.getFormFactor().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.setCapture(getElement()); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/checkbox.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/checkbox.css index 648fe6eba..19238862c 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/checkbox.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/checkbox.css @@ -41,6 +41,12 @@ } } +@if user.agent ie10 { + .mgwt-CheckBox-middle { + transition: all 0.1s ease-in-out; + } +} + @if user.agent gecko1_8 { .mgwt-CheckBox-middle { -moz-transition: all 0.1s ease-in-out; @@ -63,6 +69,12 @@ } } +@if user.agent ie10 { + .mgwt-CheckBox-middle-content { + box-sizing: border-box; + } +} + @if user.agent gecko1_8 { .mgwt-CheckBox-middle-content { -moz-box-sizing: border-box; @@ -85,6 +97,12 @@ } } +@if user.agent ie10 { + .mgwt-CheckBox-on { + transition: all 0.1s ease-in-out; + } +} + @if user.agent gecko1_8 { .mgwt-CheckBox-on { -moz-transition: all 0.1s ease-in-out; @@ -108,6 +126,12 @@ } } +@if user.agent ie10 { + .mgwt-CheckBox-off { + transition: all 0.1s ease-in-out; + } +} + @if user.agent gecko1_8 { .mgwt-CheckBox-off { -moz-transition: all 0.1s ease-in-out; @@ -138,6 +162,30 @@ } } +@if user.agent ie10 { + .mgwt-CheckBox-important .mgwt-CheckBox-on { + background-color: #fe9c12; + } + .mgwt-CheckBox-notchecked .mgwt-CheckBox-middle { + transform: translate3d(-41px,0,0); + } + .mgwt-CheckBox-checked .mgwt-CheckBox-middle { + transform: translate3d(0px,0,0); + } + .mgwt-CheckBox-notchecked .mgwt-CheckBox-off { + transform: translate3d(-41px,0,0); + } + .mgwt-CheckBox-checked .mgwt-CheckBox-off { + transform: translate3d(10px,0,0); + } + .mgwt-CheckBox-notchecked .mgwt-CheckBox-on { + transform: translate3d(-81px,0,0); + } + .mgwt-CheckBox-checked .mgwt-CheckBox-on { + transform: translate3d(0px,0,0); + } +} + @if user.agent gecko1_8 { .mgwt-CheckBox-important .mgwt-CheckBox-on { border: solid 1px #d87101; @@ -164,7 +212,7 @@ } /*TODO add browser....*/ -@if user.agent ie8 ie9 ie10 { +@if user.agent ie8 ie9 { .mgwt-CheckBox-important .mgwt-CheckBox-on {} .mgwt-CheckBox-notchecked .mgwt-CheckBox-middle {} .mgwt-CheckBox-checked .mgwt-CheckBox-middle {} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css index cebf45383..ccaf6448f 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css @@ -16,6 +16,19 @@ } } +@if user.agent ie10 { + .mgwt-TextBox, .mgwt-InputBox-box, .mgwt-PasswordTextBox, + .mgwt-InputBox-box, .mgwt-TextArea, .mgwt-InputBox-box { + display: -ms-flexbox; + -ms-flex: 1 1; + -ms-user-select: text; + } + + textarea.mgwt-InputBox-box { + -ms-touch-action: pan-y; + } +} + @if user.agent gecko1_8 { .mgwt-TextBox, .mgwt-InputBox-box, .mgwt-PasswordTextBox, .mgwt-InputBox-box, .mgwt-TextArea, .mgwt-InputBox-box { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/listbox/mlistbox.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/listbox/mlistbox.css index 600144b7a..b6e5e1176 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/listbox/mlistbox.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/listbox/mlistbox.css @@ -16,6 +16,17 @@ } } +@if user.agent ie10 { + .mgwt-ListBox { + display: -ms-flexbox; + -ms-user-select: text; + } + + select::-ms-expand { + display: none; + } +} + @if user.agent gecko1_8 { .mgwt-ListBox { display: -moz-box; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/radio/mradiobutton.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/radio/mradiobutton.css index c2eff4c5a..0023f4f8b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/radio/mradiobutton.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/radio/mradiobutton.css @@ -29,6 +29,18 @@ } } +@if user.agent ie10 { + .mgwt-RadioButton { + display: -ms-flexbox; + -ms-flex-direction: row; + -ms-flex: 1 1; + } + .mgwt-RadioButton-label { + display: -ms-flexbox; + -ms-flex: 1 1; + } +} + @if user.agent gecko1_8 { .mgwt-RadioButton { display: -moz-box; @@ -83,6 +95,13 @@ } } +@if user.agent ie10 { + .mgwt-RadioButton-input { + } + .mgwt-RadioButton-input:CHECKED { + } +} + @if user.agent gecko1_8 { .mgwt-RadioButton-input { -moz-appearance: none !important; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css index 4947d2f9a..b5e3208fc 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css @@ -7,7 +7,9 @@ @external mgwt-SearchBox-icon; } -::-webkit-search-cancel-button { -webkit-appearance: none; } +@if user.agent safari { + ::-webkit-search-cancel-button { -webkit-appearance: none; } +} .mgwt-SearchBox { height: 44px; @@ -38,6 +40,12 @@ } } +@if user.agent ie10 { + .mgwt-SearchBox-input { + width: literal("calc(100% - 47px)"); + } +} + @if user.agent gecko1_8 { .mgwt-SearchBox-input { width: literal("-moz-calc(100% - 47px);"); @@ -52,6 +60,12 @@ } } +@if user.agent ie10 { + .mgwt-SearchBox-input { + -ms-user-select: text; + } +} + @if user.agent gecko1_8 { .mgwt-SearchBox-input { top: 5px; @@ -61,7 +75,7 @@ } } -@if user.agent ie9 ie10 { +@if user.agent ie9 { .mgwt-SearchBox-input { top: 5px; } @@ -93,6 +107,13 @@ } } +@if user.agent ie10 { + .mgwt-SearchBox-icon { + background-image: searchImage; + background-repeat: no-repeat; + } +} + .mgwt-SearchBox-icon { position: relative; top: 7px; @@ -102,19 +123,20 @@ background-color: #78787E; } -@if mgwt.density high { - .mgwt-SearchBox-icon { - -webkit-mask-size: 17px 17px; - } -} - -@if mgwt.density xhigh { - .mgwt-SearchBox-icon { - -webkit-mask-size: 12px 12px; - } -} - @if user.agent safari { + + @if mgwt.density high { + .mgwt-SearchBox-icon { + -webkit-mask-size: 17px 17px; + } + } + + @if mgwt.density xhigh { + .mgwt-SearchBox-icon { + -webkit-mask-size: 12px 12px; + } + } + .mgwt-SearchBox-clear { -webkit-mask-image: clearImage; -webkit-mask-position: center center; @@ -122,6 +144,28 @@ } } +@if user.agent ie10 { + + @if mgwt.density high { + .mgwt-SearchBox-icon { + background-size: 17px 17px; + } + } + + @if mgwt.density xhigh { + .mgwt-SearchBox-icon { + background-size: 12px 12px; + } + } + + .mgwt-SearchBox-clear { + background-image: clearImage; + background-position: center center; + background-repeat: no-repeat; + } +} + + .mgwt-SearchBox-clear { position: absolute; top: -2px; @@ -131,14 +175,32 @@ background-color: #78787E; } -@if mgwt.density high { - .mgwt-SearchBox-clear { - -webkit-mask-size: 19px 19px; - } -} +@if user.agent safari { -@if mgwt.density xhigh { - .mgwt-SearchBox-clear { - -webkit-mask-size: 14px 14px; - } + @if mgwt.density high { + .mgwt-SearchBox-clear { + -webkit-mask-size: 19px 19px; + } + } + + @if mgwt.density xhigh { + .mgwt-SearchBox-clear { + -webkit-mask-size: 14px 14px; + } + } +} + +@if user.agent ie10 { + + @if mgwt.density high { + .mgwt-SearchBox-clear { + background-size: 19px 19px; + } + } + + @if mgwt.density xhigh { + .mgwt-SearchBox-clear { + background-size: 14px 14px; + } + } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java index fbfac2043..ccb6ccebc 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java @@ -30,9 +30,8 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.Widget; - import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -import com.googlecode.mgwt.ui.client.MGWT; +import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.util.CssUtil; import com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl; @@ -48,7 +47,7 @@ private class SliderTouchHandler implements TouchHandler { @Override public void onTouchStart(TouchStartEvent event) { setValueContrained(event.getTouches().get(0).getClientX()); - if (MGWT.getFormFactor().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.setCapture(getElement()); } event.stopPropagation(); @@ -65,7 +64,7 @@ public void onTouchMove(TouchMoveEvent event) { @Override public void onTouchEnd(TouchEndEvent event) { - if (MGWT.getFormFactor().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.releaseCapture(getElement()); } event.stopPropagation(); @@ -74,7 +73,7 @@ public void onTouchEnd(TouchEndEvent event) { @Override public void onTouchCancel(TouchCancelEvent event) { - if (MGWT.getFormFactor().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.releaseCapture(getElement()); } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java index 111e581ae..061541520 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java @@ -13,6 +13,8 @@ */ package com.googlecode.mgwt.ui.client.widget.list.celllist; +import java.util.List; + import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.EventTarget; @@ -29,14 +31,12 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Widget; - import com.googlecode.mgwt.dom.client.event.tap.Tap; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; import com.googlecode.mgwt.dom.client.recognizer.EventPropagator; +import com.googlecode.mgwt.ui.client.MGWT; import com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl; -import java.util.List; - /** * * A widget that renders its children as a list @@ -123,7 +123,12 @@ public void onTouchStart(TouchStartEvent event) { return; } - event.preventDefault(); + // if windows phone then do not prevent default, causes scrolling issues when + // in scroll panel (not sure why), ie10 desktop is fine + if (!MGWT.getOsDetection().isWindowsPhone()) + { + event.preventDefault(); + } // text node use the parent.. if (Node.is(eventTarget) && !Element.is(eventTarget)) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/celllist.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/celllist.css index 605fcc0e2..6ec315966 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/celllist.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/celllist.css @@ -71,6 +71,12 @@ } } +@if user.agent ie10 { + .mgwt-List-Head-Element, .mgwt-List > .mgwt-List-Head-Element { + background-color: #288ede; + } +} + @if user.agent gecko1_8 { .mgwt-List-Head-Element, .mgwt-List > .mgwt-List-Head-Element { background-color: #288ede; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/grouping-celllist.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/grouping-celllist.css index e43c31bd5..f4ed2ed0b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/grouping-celllist.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/grouping-celllist.css @@ -9,6 +9,12 @@ } } +@if user.agent ie10 { + .mgwt-GroupingList { + display: -ms-flexbox; + } +} + @if user.agent gecko1_8 { .mgwt-GroupingList { display: -moz-box; @@ -45,6 +51,13 @@ } } +@if user.agent ie10 { + .mgwt-GroupingList-Selection-Bar { + display: -ms-flexbox; + -ms-flex-direction: column; + } +} + @if user.agent gecko1_8 { .mgwt-GroupingList-Selection-Bar { display: -moz-box; @@ -69,6 +82,12 @@ } } +@if user.agent ie10 { + .mgwt-GroupingList-Selection-Bar > li{ + -ms-flex: 1 1; + } +} + @if user.agent gecko1_8 { .mgwt-GroupingList-Selection-Bar > li{ -moz-box-flex: 1; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/widgetlist.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/widgetlist.css index c735fefe3..1cfbd8a52 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/widgetlist.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/widgetlist/widgetlist.css @@ -43,6 +43,12 @@ } } +@if user.agent ie10 { + .mgwt-WidgetList-Entry { + display: -ms-flexbox; + } +} + @if user.agent gecko1_8 { .mgwt-WidgetList-Entry { width: 100%; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/IOS71BodyBug.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/IOS71BodyBug.java index 37227190b..1dde0bb9a 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/IOS71BodyBug.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/IOS71BodyBug.java @@ -45,30 +45,36 @@ interface Resources extends ClientBundle { TextResource css(); } + /** + * Only apply fix if ios71 + */ public static void applyWorkaround() { - // iOS bug fix needs only be applied in portrait orientation. - // Fix is deferred until the orientation change event is fired. - if (MGWT.getOrientation() == ORIENTATION.PORTRAIT) { - registerOrientationChangeEvent(); - return; + if (isIOS71() && (MGWT.getOsDetection().isIPad() || MGWT.getOsDetection().isIPadRetina())) { + // iOS bug fix needs only be applied in portrait orientation. + // Fix is deferred until the orientation change event is fired. + if (MGWT.getOrientation() == ORIENTATION.PORTRAIT) { + registerOrientationChangeEvent(); + return; + } + applyFix(); } + } - if (MGWT.getOsDetection().isIPad() || MGWT.getOsDetection().isIPadRetina()) { - if (isIOS71() && windowInnerHeight() == 672) { + private static void applyFix() { + if (windowInnerHeight() == 672) { String text = Resources.INSTANCE.css().getText(); StyleInjector.inject(text); Document.get().getBody().addClassName("__fixIOS7BodyBug"); } - } } - private static void registerOrientationChangeEvent() { orientationChangeHandler = MGWT.addOrientationChangeHandler(new OrientationChangeHandler() { @Override public void onOrientationChanged(OrientationChangeEvent event) { + orientationChangeHandler.removeHandler(); orientationChangeHandler = null; - applyWorkaround(); + applyFix(); } }); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/main.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/main.css index a13553213..ff97e38a9 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/main.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/main.css @@ -1,39 +1,38 @@ @external body, *; + * { - -webkit-text-size-adjust: none; - -webkit-touch-callout: none; - -webkit-text-size-adjust: none; margin: 0px; padding: 0px; font-family: Helvetica, sans-serif; } +@if user.agent safari { +* { + -webkit-text-size-adjust: none; + -webkit-touch-callout: none; + -webkit-text-size-adjust: none; + -webkit-user-select: none; + } -body { - margin: 0; - padding: 0; - background: #dfe2e2; - color: #000; - font-weight: 400; - -webkit-perspective: 800; - -webkit-transform-style: preserve-3d; - position: absolute; - width: 100%; - height: 100%; -} - -:focus { - outline-color: transparent; - outline-style: none; + input , textarea{ + -webkit-user-select: text; + } } -@if user.agent gecko1_8 { +@if user.agent ie10 { * { - -webkit-user-select: none; + -ms-user-select: none; + -ms-text-size-adjust: none; + -ms-touch-select: none; + -ms-flex: 0 1 auto; + } + + input , textarea{ + -ms-user-select: text; } - input, textarea { - -webkit-user-select: text; + a img { + border: none; } } @@ -47,6 +46,33 @@ body { } } + +@if user.agent safari { +body { + -webkit-perspective: 800; + -webkit-transform-style: preserve-3d; + } +} + +body { + margin: 0; + padding: 0; + background: #dfe2e2; + color: #000; + font-weight: 400; + position: absolute; + width: 100%; + height: 100%; + perspective: 800; + transform-style: preserve-3d; +} + + +:focus { + outline-color: transparent; + outline-style: none; +} + input:FOCUS,button:FOCUS { outline: none; } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/selection.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/selection.css index 7d6f24c66..b150c90b0 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/selection.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/selection.css @@ -8,6 +8,12 @@ } } +@if user.agent ie10 { + .userSelectNone { + -ms-user-select: none; + } +} + @if user.agent gecko1_8 { .userSelectNone { -moz-user-select: none; @@ -26,6 +32,12 @@ } } +@if user.agent ie10 { + .userSelectText { + -ms-user-select: text; + } +} + @if user.agent gecko1_8 { .userSelectText { -moz-user-select: text; @@ -44,6 +56,12 @@ } } +@if user.agent ie10 { + .userSelectAll { + -ms-user-select: all; + } +} + @if user.agent gecko1_8 { .userSelectAll { -moz-user-select: all; @@ -62,6 +80,12 @@ } } +@if user.agent ie10 { + .userSelectElement { + -ms-user-select: element; + } +} + @if user.agent gecko1_8 { .userSelectElement { -moz-user-select: element; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/util.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/util.css index 81a67de77..a4ed37733 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/main/util.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/main/util.css @@ -1,11 +1,11 @@ @media (orientation:portrait) { .landscapeonly { - display: none; + display: none !important; } } @media (orientation:landscape) { .portraitonly { - display: none; + display: none !important; } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/overlay-menu.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/overlay-menu.css index 616dd80fb..2df185205 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/overlay-menu.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/overlay-menu.css @@ -39,18 +39,27 @@ @if user.agent safari { .mgwt-OverlayMenu-nav { - -webkit-transform-property: opacity; + -webkit-transition-property: opacity; } .mgwt-OverlayMenu-main { - -webkit-transform-property: left; + -webkit-transition-property: left; + } +} + +@if user.agent ie10 { + .mgwt-OverlayMenu-nav { + transition-property: opacity; + } + .mgwt-OverlayMenu-main { + transition-property: left; } } @if user.agent gecko1_8 { .mgwt-OverlayMenu-nav { - -moz-transform-property: opacity; + -moz-transition-property: opacity; } .mgwt-OverlayMenu-main { - -moz-transform-property: left; + -moz-transition-property: left; } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/swipe/swipe-menu.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/swipe/swipe-menu.css index 0733b6fa3..529097fc7 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/swipe/swipe-menu.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/swipe/swipe-menu.css @@ -40,6 +40,15 @@ } } +@if user.agent ie10 { + .opened { + transform: translate3d(0, 0, 0); + } + .closed { + transform: translate3d(-40%, 0, 0); + } +} + @if user.agent gecko1_8 { .opened { -moz-transform: translate3d(0, 0, 0); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPanel.gwt.xml b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPanel.gwt.xml index d3e37785d..064ea73d9 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPanel.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPanel.gwt.xml @@ -15,4 +15,30 @@ under * the License. + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java index f622d5dec..255695009 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java @@ -15,160 +15,106 @@ */ package com.googlecode.mgwt.ui.client.widget.panel.flex; +import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; -public final class FlexPropertyHelper { +public abstract class FlexPropertyHelper { + private static final FlexPropertyHelper impl = GWT.create(FlexPropertyHelper.class); + public static enum Alignment { - START("flex-start"), END("flex-end"), CENTER("center"), STRETCH("stretch"), BASELINE("baseline"); - - private final String cssValue; - - private Alignment(String cssValue) { - this.cssValue = cssValue; - } - - private static String getCssProperty() { - return "AlignItems"; - } + START, END, CENTER, STRETCH, BASELINE, NONE; + } - private String getCssValue() { - return cssValue; - } + public static enum AlignmentSelf { + START, END, CENTER, STRETCH, BASELINE, AUTO; } public static enum Justification { - START("flex-start"), END("flex-end"), CENTER("center"), SPACE_BETWEEN("space-between"), SPACE_AROUND("space-around"); - - private final String cssValue; - - private Justification(String cssValue) { - this.cssValue = cssValue; - } - - private static String getCssProperty() { - return "JustifyContent"; - } - - private String getCssValue() { - return cssValue; - } + START, END, CENTER, SPACE_BETWEEN, SPACE_AROUND, NONE; } - + public static enum Orientation { - HORIZONTAL("row"), VERTICAL("column"); + HORIZONTAL, HORIZONTAL_REVERSE, VERTICAL, VERTICAL_REVERSE; + } - private final String cssValue; + public static enum FlexWrap { + NOWRAP, WRAP, WRAP_REVERSE; + } - private Orientation(String cssValue) { - this.cssValue = cssValue; + public static void setElementAsFlexContainer(Element el) + { + setElementAsFlexContainer(el, null); + } + + public static void setElementAsFlexContainer(Element el, Orientation orientation) + { + if (orientation == null) + { + orientation = Orientation.HORIZONTAL; // the default } + impl._setElementAsFlexContainer(el, orientation); + } - private static String getCssProperty() { - return "Direction"; - } + public static void setFlex(Element el, double grow) { + setFlex(el, grow, "0%"); + } - private String getCssValue() { - return cssValue; - } + public static void setFlex(Element el, double grow, double shrink) { + setFlex(el, grow, shrink, "0%"); } - public static void setFlex(Element el, double flex) { - /* iOS < 7 && Android < 4.4*/ - el.getStyle().setProperty("WebkitBoxFlexGrow", Double.toString(flex)); + public static void setFlex(Element el, double grow, double shrink, String basis) { + impl._setFlex(el, grow, shrink, basis); + } - el.getStyle().setProperty("MozFlexGrow", Double.toString(flex)); - el.getStyle().setProperty("WebkitFlexGrow", Double.toString(flex)); - el.getStyle().setProperty("flexGrow", Double.toString(flex)); + public static void setFlex(Element el, double grow, String basis) { + impl._setFlex(el, grow, basis); } - private static void setFlexProperty(Element el, String name, String value) { - setStyleProperty(el, "MozFlex" + name, value); - setStyleProperty(el, "WebkitFlex" + name, value); - setStyleProperty(el, "flex" + name, value); + public static void setFlexOrder(Element el, int order) { + impl._setFlexOrder(el, order); } - private static void setProperty(Element el, String name, String value) { - setStyleProperty(el, "Moz" + name, value); - setStyleProperty(el, "Webkit" + name, value); - setStyleProperty(el, name, value); + public static void setAlignment(Element el, Alignment alignment) { + impl._setAlignmentProperty(el, alignment); } - public static void setOrientation(Element el, Orientation value) { - // iOS6 & Android < 4.4 - switch (value) { - case HORIZONTAL: - el.getStyle().setProperty("WebkitBoxOrient", "horizontal"); - break; - case VERTICAL: - el.getStyle().setProperty("WebkitBoxOrient", "vertical"); - break; - default: - throw new RuntimeException(); - } - setFlexProperty(el, Orientation.getCssProperty(), value.getCssValue()); - } - - public static void setAlignment(Element el, Alignment value) { - // iOS6 & Android < 4.4 - switch (value) { - case START: - el.getStyle().setProperty("WebkitBoxAlign", "start"); - break; - case CENTER: - el.getStyle().setProperty("WebkitBoxAlign", "center"); - break; - case END: - el.getStyle().setProperty("WebkitBoxAlign", "end"); - break; - case BASELINE: - el.getStyle().setProperty("WebkitBoxAlign", "baseline"); - break; - case STRETCH: - el.getStyle().setProperty("WebkitBoxAlign", "stretch"); - break; - default: - throw new RuntimeException(); - } - setProperty(el, Alignment.getCssProperty(), value.getCssValue()); - } - - public static void setJustification(Element el, Justification value) { - // iOS6 & Android < 4.4 - switch (value) { - case START: - el.getStyle().setProperty("WebkitBoxPack", "start"); - break; - case CENTER: - el.getStyle().setProperty("WebkitBoxPack", "center"); - break; - case END: - el.getStyle().setProperty("WebkitBoxPack", "end"); - break; - case SPACE_BETWEEN: - el.getStyle().setProperty("WebkitBoxPack", "justify"); - break; - case SPACE_AROUND: - el.getStyle().setProperty("WebkitBoxPack", "justify"); - break; - default: - throw new RuntimeException(); - } - setProperty(el, Justification.getCssProperty(), value.getCssValue()); + public static void setAlignmentSelf(Element el, AlignmentSelf alignmentSelf) { + impl._setAlignmentSelfProperty(el, alignmentSelf); } - private static void setStyleProperty(Element el, String property, String value) { - el.getStyle().setProperty(property, value); + public static void setOrientation(Element el, Orientation orientation) { + impl._setOrientationProperty(el, orientation); + } + + public static void setJustification(Element el, Justification justification) { + impl._setJustificationProperty(el, justification); } - private FlexPropertyHelper() { + public static void setFlexWrap(Element el, FlexWrap flexWrap) { + impl._setFlexWrapProperty(el, flexWrap); } - public static void clearAlignment(Element element) { - setProperty(element, Alignment.getCssProperty(), ""); + public static void clearAlignment(Element el) { + impl._setAlignmentProperty(el,Alignment.NONE); } - public static void clearJustification(Element element) { - setProperty(element, Justification.getCssProperty(), ""); + public static void clearJustification(Element el) { + impl._setJustificationProperty(el,Justification.NONE); + } + + protected void setStyleProperty(Element el, String property, String value) { + el.getStyle().setProperty(property, value); } + + protected abstract void _setElementAsFlexContainer(Element el, Orientation orientation); + protected abstract void _setFlex(Element el, double grow, String basis); + protected abstract void _setFlex(Element el, double grow, double shrink, String basis); + protected abstract void _setFlexOrder(Element el, int order); + protected abstract void _setAlignmentProperty(Element el, Alignment alignment); + protected abstract void _setAlignmentSelfProperty(Element el, AlignmentSelf alignmentSelf); + protected abstract void _setOrientationProperty(Element el, Orientation orientation); + protected abstract void _setJustificationProperty(Element el, Justification justification); + protected abstract void _setFlexWrapProperty(Element el, FlexWrap flexWrap); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java new file mode 100644 index 000000000..0a27520fe --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java @@ -0,0 +1,184 @@ +package com.googlecode.mgwt.ui.client.widget.panel.flex; + +import com.google.gwt.dom.client.Element; + +/** + * Unbelievable - IE10 does not obey the camel case rule correctly + * @author pfrench + * + */ +public class FlexPropertyHelperIE10 extends FlexPropertyHelper { + + @Override + public void _setAlignmentProperty(Element el, Alignment alignment) { + String value; + switch (alignment) { + case START: { + value = "start"; + break; + } + case END: { + value = "end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case STRETCH: { + value = "stretch"; + break; + } + case BASELINE: { + value = "baseline"; + break; + } + default: { + value = ""; + } + } + setStyleProperty(el, "msFlexAlign", value); + } + + @Override + public void _setOrientationProperty(Element el, Orientation orientation) { + String value; + switch (orientation) { + case HORIZONTAL: { + value = "row"; + break; + } + case VERTICAL: { + value = "column"; + break; + } + case HORIZONTAL_REVERSE: { + value = "row-reverse"; + break; + } + case VERTICAL_REVERSE: { + value = "column-reverse"; + break; + } + default: { + value = ""; + break; + } + } + setStyleProperty(el, "msFlexDirection", value); + } + + @Override + public void _setJustificationProperty(Element el, Justification justification) { + String value; + switch (justification) { + case START: { + value = "start"; + break; + } + case END: { + value = "end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case SPACE_AROUND: { + value = "distribute"; + break; + } + case SPACE_BETWEEN: { + value = "justify"; + break; + } + default: { + value = ""; + } + } + setStyleProperty(el, "msFlexPack", value); + } + + @Override + protected void _setAlignmentSelfProperty(Element el, AlignmentSelf alignmentSelf) + { + String value; + switch (alignmentSelf) { + case START: { + value = "start"; + break; + } + case END: { + value = "end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case STRETCH: { + value = "stretch"; + break; + } + case BASELINE: { + value = "baseline"; + break; + } + default: { + value = "auto"; + } + } + setStyleProperty(el, "msFlexItemAlign", value); + } + + @Override + protected void _setFlexWrapProperty(Element el, FlexWrap flexWrap) + { + String value; + switch (flexWrap) { + case NOWRAP: { + value = "nowrap"; + break; + } + case WRAP: { + value = "wrap"; + break; + } + case WRAP_REVERSE: { + value = "wrap-reverse"; + break; + } + default: { + value = "nowrap"; + break; + } + } + setStyleProperty(el, "msFlexWrap", value); + } + + + /** + * IE10/11 sets flex-shrink to 0 if omitted whereas webkit sets to 1, so lets copy webkit + */ + @Override + protected void _setFlex(Element el, double grow, String basis) { + _setFlex(el,grow,1,basis); + } + + @Override + protected void _setFlex(Element el, double grow, double shrink, String basis) { + setStyleProperty(el,"msFlex", Double.toString(grow)+" "+Double.toString(shrink)+" "+(basis == null ? "0%" : basis)); + } + + @Override + public void _setFlexOrder(Element el, int order) { + setStyleProperty(el,"msFlexOrder", Integer.toString(order)); + } + + @Override + protected void _setElementAsFlexContainer(Element el, Orientation orientation) { + setStyleProperty(el,"display", "-ms-flexbox"); + _setOrientationProperty(el,orientation); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java new file mode 100644 index 000000000..b55116f17 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java @@ -0,0 +1,175 @@ +package com.googlecode.mgwt.ui.client.widget.panel.flex; + +import com.google.gwt.dom.client.Element; + +public class FlexPropertyHelperMoz extends FlexPropertyHelper { + + @Override + public void _setAlignmentProperty(Element el, Alignment alignment) { + String value; + switch (alignment) { + case START: { + value = "flex-start"; + break; + } + case END: { + value = "flex-end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case STRETCH: { + value = "stretch"; + break; + } + case BASELINE: { + value = "baseline"; + break; + } + default: { + value = ""; + } + } + setStyleProperty(el, "MozAlignItems", value); + } + + @Override + public void _setOrientationProperty(Element el, Orientation orientation) { + String value; + switch (orientation) { + case HORIZONTAL: { + value = "row"; + break; + } + case VERTICAL: { + value = "column"; + break; + } + case HORIZONTAL_REVERSE: { + value = "row-reverse"; + break; + } + case VERTICAL_REVERSE: { + value = "column-reverse"; + break; + } + default: { + value = ""; + break; + } + } + setStyleProperty(el, "MozFlexDirection", value); + } + + @Override + public void _setJustificationProperty(Element el, Justification justification) { + String value; + switch (justification) { + case START: { + value = "flex-start"; + break; + } + case END: { + value = "flex-end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case SPACE_AROUND: { + value = "space-around"; + break; + } + case SPACE_BETWEEN: { + value = "space-between"; + break; + } + default: { + value = ""; + } + } + setStyleProperty(el, "MozJustifyContent", value); + } + + @Override + protected void _setAlignmentSelfProperty(Element el, AlignmentSelf alignmentSelf) + { + String value; + switch (alignmentSelf) { + case START: { + value = "flex-start"; + break; + } + case END: { + value = "flex-end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case STRETCH: { + value = "stretch"; + break; + } + case BASELINE: { + value = "baseline"; + break; + } + default: { + value = "auto"; + } + } + setStyleProperty(el, "MozAlignSelf", value); + } + + @Override + protected void _setFlexWrapProperty(Element el, FlexWrap flexWrap) + { + String value; + switch (flexWrap) { + case NOWRAP: { + value = "nowrap"; + break; + } + case WRAP: { + value = "wrap"; + break; + } + case WRAP_REVERSE: { + value = "wrap-reverse"; + break; + } + default: { + value = "nowrap"; + break; + } + } + setStyleProperty(el, "MozFlexWrap", value); + } + + @Override + protected void _setFlex(Element el, double grow, String basis) { + setStyleProperty(el,"MozFlex", Double.toString(grow)+" "+(basis == null ? "0%" : basis)); + } + + @Override + protected void _setFlex(Element el, double grow, double shrink, String basis) { + setStyleProperty(el,"MozFlex", Double.toString(grow)+" "+Double.toString(shrink)+" "+(basis == null ? "0%" : basis)); + } + + @Override + public void _setFlexOrder(Element el, int order) { + setStyleProperty(el,"MozOrder", Integer.toString(order)); + } + + @Override + protected void _setElementAsFlexContainer(Element el, Orientation orientation) { + setStyleProperty(el,"display", "-moz-flex"); + _setOrientationProperty(el,orientation); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java new file mode 100644 index 000000000..02c502e32 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java @@ -0,0 +1,175 @@ +package com.googlecode.mgwt.ui.client.widget.panel.flex; + +import com.google.gwt.dom.client.Element; + +public class FlexPropertyHelperStandard extends FlexPropertyHelper { + + @Override + public void _setAlignmentProperty(Element el, Alignment alignment) { + String value; + switch (alignment) { + case START: { + value = "flex-start"; + break; + } + case END: { + value = "flex-end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case STRETCH: { + value = "stretch"; + break; + } + case BASELINE: { + value = "baseline"; + break; + } + default: { + value = ""; + } + } + setStyleProperty(el, "alignItems", value); + } + + @Override + public void _setOrientationProperty(Element el, Orientation orientation) { + String value; + switch (orientation) { + case HORIZONTAL: { + value = "row"; + break; + } + case VERTICAL: { + value = "column"; + break; + } + case HORIZONTAL_REVERSE: { + value = "row-reverse"; + break; + } + case VERTICAL_REVERSE: { + value = "column-reverse"; + break; + } + default: { + value = ""; + break; + } + } + setStyleProperty(el, "flexDirection", value); + } + + @Override + public void _setJustificationProperty(Element el, Justification justification) { + String value; + switch (justification) { + case START: { + value = "flex-start"; + break; + } + case END: { + value = "flex-end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case SPACE_AROUND: { + value = "space-around"; + break; + } + case SPACE_BETWEEN: { + value = "space-between"; + break; + } + default: { + value = ""; + } + } + setStyleProperty(el, "justifyContent", value); + } + + @Override + protected void _setAlignmentSelfProperty(Element el, AlignmentSelf alignmentSelf) + { + String value; + switch (alignmentSelf) { + case START: { + value = "flex-start"; + break; + } + case END: { + value = "flex-end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case STRETCH: { + value = "stretch"; + break; + } + case BASELINE: { + value = "baseline"; + break; + } + default: { + value = "auto"; + } + } + setStyleProperty(el, "alignSelf", value); + } + + @Override + protected void _setFlexWrapProperty(Element el, FlexWrap flexWrap) + { + String value; + switch (flexWrap) { + case NOWRAP: { + value = "nowrap"; + break; + } + case WRAP: { + value = "wrap"; + break; + } + case WRAP_REVERSE: { + value = "wrap-reverse"; + break; + } + default: { + value = "nowrap"; + break; + } + } + setStyleProperty(el, "flexWrap", value); + } + + @Override + protected void _setFlex(Element el, double grow, String basis) { + setStyleProperty(el,"flex", Double.toString(grow)+" "+(basis == null ? "0%" : basis)); + } + + @Override + protected void _setFlex(Element el, double grow, double shrink, String basis) { + setStyleProperty(el,"flex", Double.toString(grow)+" "+Double.toString(shrink)+" "+(basis == null ? "0%" : basis)); + } + + @Override + public void _setFlexOrder(Element el, int order) { + setStyleProperty(el,"order", Integer.toString(order)); + } + + @Override + protected void _setElementAsFlexContainer(Element el, Orientation orientation) { + setStyleProperty(el,"display", "flex"); + _setOrientationProperty(el,orientation); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java new file mode 100644 index 000000000..39cd292d4 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java @@ -0,0 +1,207 @@ +package com.googlecode.mgwt.ui.client.widget.panel.flex; + +import com.google.gwt.dom.client.Element; + +public class FlexPropertyHelperWebkit extends FlexPropertyHelper { + + @Override + public void _setAlignmentProperty(Element el, Alignment alignment) { + String alignItemOldSyntax, alignItemNewSyntax; + switch (alignment) { + case START: { + alignItemOldSyntax = "start"; + alignItemNewSyntax = "flex-start"; + break; + } + case END: { + alignItemOldSyntax = "end"; + alignItemNewSyntax = "flex-end"; + break; + } + case CENTER: { + alignItemOldSyntax = "center"; + alignItemNewSyntax = "center"; + break; + } + case STRETCH: { + alignItemOldSyntax = ""; // not implemented + alignItemNewSyntax = "stretch"; + break; + } + case BASELINE: { + alignItemOldSyntax = ""; // not implemented + alignItemNewSyntax = "baseline"; + break; + } + default: { + alignItemOldSyntax = ""; + alignItemNewSyntax = ""; + } + } + setStyleProperty(el, "WebkitBoxAlign", alignItemOldSyntax); + setStyleProperty(el, "WebkitAlignItems", alignItemNewSyntax); + } + + @Override + public void _setOrientationProperty(Element el, Orientation orientation) { + String orientationOldSyntax, orientationNewSyntax; + boolean reverse = false; + switch (orientation) { + case HORIZONTAL: { + orientationOldSyntax = "horizontal"; + orientationNewSyntax = "row"; + break; + } + case VERTICAL: { + orientationOldSyntax = "vertical"; + orientationNewSyntax = "column"; + break; + } + case HORIZONTAL_REVERSE: { + orientationOldSyntax = "horizontal"; reverse = true; + orientationNewSyntax = "row-reverse"; + break; + } + case VERTICAL_REVERSE: { + orientationOldSyntax = "vertical"; reverse = true; + orientationNewSyntax = "column-reverse"; + break; + } + default: { + orientationOldSyntax = ""; + orientationNewSyntax = ""; + break; + } + } + setStyleProperty(el, "WebkitBoxOrient", orientationOldSyntax); + setStyleProperty(el, "WebkitBoxDirection", reverse ? "reverse" : "normal"); + setStyleProperty(el, "WebkitFlexDirection", orientationNewSyntax); + } + + @Override + public void _setJustificationProperty(Element el, Justification justification) { + String justificationOldSyntax, justificationNewSyntax; + switch (justification) { + case START: { + justificationOldSyntax = "start"; + justificationNewSyntax = "flex-start"; + break; + } + case END: { + justificationOldSyntax = "end"; + justificationNewSyntax = "flex-end"; + break; + } + case CENTER: { + justificationOldSyntax = "center"; + justificationNewSyntax = "center"; + break; + } + case SPACE_AROUND: { + justificationOldSyntax = ""; // not implemented + justificationNewSyntax = "space-around"; + break; + } + case SPACE_BETWEEN: { + justificationOldSyntax = "justify"; + justificationNewSyntax = "space-between"; + break; + } + default: { + justificationOldSyntax = ""; + justificationNewSyntax = ""; + } + } + setStyleProperty(el, "WebkitBoxPack", justificationOldSyntax); + setStyleProperty(el, "WebkitJustifyContent", justificationNewSyntax); + } + + @Override + protected void _setAlignmentSelfProperty(Element el, AlignmentSelf alignmentSelf) + { + String value; + switch (alignmentSelf) { + case START: { + value = "flex-start"; + break; + } + case END: { + value = "flex-end"; + break; + } + case CENTER: { + value = "center"; + break; + } + case STRETCH: { + value = "stretch"; + break; + } + case BASELINE: { + value = "baseline"; + break; + } + default: { + value = "auto"; + } + } + setStyleProperty(el, "WebkitAlignSelf", value); + } + + @Override + protected void _setFlexWrapProperty(Element el, FlexWrap flexWrap) + { + String flexWrapOldSyntax, flexWrapNewSyntax; + switch (flexWrap) { + case NOWRAP: { + flexWrapOldSyntax = "single"; + flexWrapNewSyntax = "nowrap"; + break; + } + case WRAP: { + flexWrapOldSyntax = "multiple"; + flexWrapNewSyntax = "wrap"; + break; + } + case WRAP_REVERSE: { + flexWrapOldSyntax = "multiple"; + flexWrapNewSyntax = "wrap"; + break; + } + default: { + flexWrapOldSyntax = "single"; + flexWrapNewSyntax = "nowrap"; + break; + } + } + setStyleProperty(el, "WebkitBoxLines", flexWrapOldSyntax); + setStyleProperty(el, "WebkitFlexWrap", flexWrapNewSyntax); + } + + @Override + public void _setFlex(Element el, double grow, String basis) { + setStyleProperty(el,"WebkitBoxFlex", Double.toString(grow)); + setStyleProperty(el,"WebkitFlex", Double.toString(grow)+(basis == null ? "0%" : basis)); + } + + @Override + protected void _setFlex(Element el, double grow, double shrink, String basis) { + setStyleProperty(el,"WebkitBoxFlex", Double.toString(grow)); // shrink and basis not supported + setStyleProperty(el,"WebkitFlex", Double.toString(grow)+" "+Double.toString(shrink)+" "+(basis == null ? "0%" : basis)); + } + + @Override + public void _setFlexOrder(Element el, int order) { + setStyleProperty(el,"WebkitBoxOrdinalGroup", Integer.toString(order)); + setStyleProperty(el,"WebkitOrder", Integer.toString(order)); + } + + + @Override + protected void _setElementAsFlexContainer(Element el, Orientation orientation) { + setStyleProperty(el,"display", "-webkit-box"); + setStyleProperty(el,"display", "-webkit-flex"); + _setOrientationProperty(el,orientation); + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css index b8c2c57b5..7a2a6e502 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/flex.css @@ -17,6 +17,13 @@ } } +@if user.agent ie10 { + .mgwt-FlexPanel { + display: -ms-flexbox; + -ms-flex-direction: column; + } +} + .mgwt-FlexPanel { display: flex; flex-direction: column; @@ -37,6 +44,12 @@ } } +@if user.agent ie10 { + .mgwt-FlexPanel-flex { + -ms-flex: 1 1; + } +} + @if user.agent gecko1_8 { .mgwt-FlexPanel-flex { -moz-flex: 1; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/pullpanel.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/pullpanel.css index 58ccf23bb..c16730f1a 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/pullpanel.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/pull/pullpanel.css @@ -5,11 +5,31 @@ @external mgwt-PullToRefresh-text, .mgwt-PullToRefresh-arrowFooter; } +@if user.agent safari { + .mgwt-PullPanel { + -webkit-box-flex: 1; /* iOS < 7 && Android < 4.4*/ + -webkit-flex: 1; + } +} + +@if user.agent ie10 { + .mgwt-PullPanel { + -ms-flex: 1 1; + } +} + +@if user.agent gecko1_8 { + .mgwt-PullPanel { + -moz-flex: 1; + } +} + .mgwt-PullPanel { flex: 1; overflow: hidden; } + .mgwt-PullPanel-container{} .mgwt-PullPanel-main{} @@ -41,6 +61,12 @@ } } +@if user.agent ie10 { + .mgwt-PullToRefresh-arrow { + transform-origin: 12px 9px; + } +} + @if user.agent gecko1_8 { .mgwt-PullToRefresh-arrow { -moz-transform-origin: 12px 9px; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java index 7141aac7b..115da214a 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java @@ -3,6 +3,7 @@ import com.google.gwt.animation.client.AnimationScheduler; import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback; import com.google.gwt.animation.client.AnimationScheduler.AnimationHandle; +import com.google.gwt.core.client.Duration; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; @@ -23,12 +24,9 @@ import com.google.gwt.event.dom.client.TouchEvent; import com.google.gwt.event.dom.client.TouchMoveEvent; import com.google.gwt.event.dom.client.TouchStartEvent; -import com.google.gwt.event.logical.shared.ResizeEvent; -import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; @@ -45,6 +43,7 @@ import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; import com.googlecode.mgwt.ui.client.MGWT; +import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.util.CssUtil; import com.googlecode.mgwt.ui.client.widget.panel.scroll.BeforeScrollEndEvent; import com.googlecode.mgwt.ui.client.widget.panel.scroll.BeforeScrollMoveEvent; @@ -253,7 +252,7 @@ public int getTime() { private int startY; private int pointX; private int pointY; - private long startTime; + private double startTime; private double touchesDist; private double lastScale; private boolean bounce; @@ -337,7 +336,7 @@ public ScrollPanelTouchImpl() { this.fixedScrollbar = MGWT.getOsDetection().isAndroid() && !MGWT.getOsDetection().isAndroid4_4_OrHigher(); this.hideScrollBar = true; - this.fadeScrollBar = MGWT.getOsDetection().isIOs() && CssUtil.has3d(); + this.fadeScrollBar = (MGWT.getOsDetection().isIOs() || MGWT.getOsDetection().isWindowsPhone()) && CssUtil.has3d(); // array for scrollbars this.scrollBar = new boolean[2]; @@ -661,7 +660,7 @@ private void move(TouchMoveEvent event) { int deltaY = touches.get(0).getPageY() - this.pointY; int newX = this.x + deltaX; int newY = this.y + deltaY; - long timeStamp = System.currentTimeMillis(); + double timeStamp = Duration.currentTimeMillis(); // fire onbeforescroll event fireEvent(new BeforeScrollMoveEvent(event)); @@ -762,7 +761,7 @@ private void end(final TouchEvent event) { return; } - long duration = System.currentTimeMillis() - this.startTime; + double duration = Duration.currentTimeMillis() - this.startTime; int newPosX = this.x; int newPosY = this.y; Momentum momentumX = Momentum.ZERO_MOMENTUM; @@ -1069,7 +1068,7 @@ private void startAnimation(final boolean issueEvent) { return; } - final long startTime = System.currentTimeMillis(); + final double startTime = Duration.currentTimeMillis(); final AnimationCallback animationCallback = new AnimationCallback() { @@ -1116,7 +1115,7 @@ private void setTransistionTime(int time) { } - private Momentum momentum(int dist, long time, int maxDistUpper, int maxDistLower, int size) { + private Momentum momentum(int dist, double time, int maxDistUpper, int maxDistLower, int size) { double deceleration = 0.0006; double speed = ((double) (Math.abs(dist))) / time; double newDist = (speed * speed) / (2 * deceleration); @@ -1584,7 +1583,7 @@ public void setWidget(Widget w) { // clear old event handlers unbindStartEvent(); unbindResizeEvent(); - if (MGWT.getOsDetection().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { unbindMouseoutEvent(); unbindMouseWheelEvent(); } @@ -1604,7 +1603,7 @@ public void setWidget(Widget w) { if (isAttached()) { bindResizeEvent(); bindStartEvent(); - if (MGWT.getOsDetection().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { bindMouseoutEvent(); bindMouseWheelEvent(); } @@ -1638,7 +1637,7 @@ protected void onAttach() { // bind events bindResizeEvent(); bindStartEvent(); - if (MGWT.getOsDetection().isDesktop()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { bindMouseoutEvent(); bindMouseWheelEvent(); } @@ -1763,30 +1762,16 @@ private void unbindMoveEvent() { * */ private void bindResizeEvent() { - if (!MGWT.getFormFactor().isDesktop()) { - orientationChangeRegistration = MGWT.addOrientationChangeHandler(new OrientationChangeHandler() { - - @Override - public void onOrientationChanged(OrientationChangeEvent event) { - if (shouldHandleResize) { - resize(); - } - - } - }); - } else { - orientationChangeRegistration = Window.addResizeHandler(new ResizeHandler() { - - @Override - public void onResize(ResizeEvent event) { - if (shouldHandleResize) { - resize(); - } + orientationChangeRegistration = MGWT.addOrientationChangeHandler(new OrientationChangeHandler() { + @Override + public void onOrientationChanged(OrientationChangeEvent event) { + if (shouldHandleResize) { + resize(); } - }); - } - + } + + }); } private void unbindResizeEvent() { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css index 21e49a97f..991661198 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css @@ -21,6 +21,13 @@ } } +@if user.agent ie10 { + .mgwt-ScrollPanel-container { + transition-property: transform; + transition-timing-function: cubic-bezier(0, 0, 0.25, 1); + } +} + @if user.agent gecko1_8 { .mgwt-ScrollPanel-container { -moz-transition-property: literal('-moz-transform'); @@ -44,6 +51,14 @@ } } +@if user.agent ie10 { + .mgwt-Scrollbar { + transition-duration: 300ms; + transition-delay: 0ms; + transition-property: opacity; + } +} + @if user.agent gecko1_8 { .mgwt-Scrollbar { -moz-transition-duration: 300ms; @@ -86,6 +101,18 @@ } } +@if user.agent ie10 { + .mgwt-Scrollbar-Bar { + background-clip:padding-box; + box-sizing:border-box; + border-radius:3px; + transition-property:transform; + transition-timing-function:cubic-bezier(0.33,0.66,0.66,1); + transform: translate3d('0,0, 0'); + transition-duration:0; + } +} + @if user.agent gecko1_8 { .mgwt-Scrollbar-Bar { -moz-background-clip:padding-box; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressbar.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressbar.css index 8eab117bd..716b4eadb 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressbar.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressbar.css @@ -28,6 +28,20 @@ } } +@if user.agent ie10 { + .mgwt-ProgressBar { + animation-duration: 9s; + animation-name: anmiateProgressBar; + animation-iteration-count: infinite; + animation-timing-function: linear; + } + + @keyframes anmiateProgressBar { + 0% { background-position-x: 0%; } + 100% { background-position-x: 100%; } + } +} + @if user.agent gecko1_8 { .mgwt-ProgressBar { -moz-animation-duration: 9s; @@ -57,6 +71,15 @@ } } +@if user.agent ie10 { + .mgwt-ProgressBar { + background-size: 25px 15px; + box-shadow: 0 3px 3px rgba(0, 0, 0, 0.5); + box-sizing: border-box; + background-image: linear-gradient(60deg, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0.7) 30%, rgba(255, 255, 255, 1) 30%, rgba(255, 255, 255, 1) 70%, rgba(255, 255, 255, 0.7) 70%, rgba(255, 255, 255, 0) 80%), linear-gradient(to bottom, rgba(0, 0, 0, .2) 5%, rgba(255, 255, 255, .8) 6%, rgba(255, 255, 255, .05) 40%, rgba(0, 0, 0, .05) 60%, rgba(0, 0, 0, .2) 90%, rgba(0, 0, 0, .5) 98%), linear-gradient(to bottom, transparent 20%, rgba(255, 255, 255, .5) 20%, rgba(255, 255, 255, .5) 50%, transparent 50%); + } +} + @if user.agent gecko1_8 { .mgwt-ProgressBar { background-size: 25px 15px; @@ -66,7 +89,7 @@ } } -@if user.agent ie9 ie10 { +@if user.agent ie9 { .mgwt-ProgressBar { -ms-background-size: 25px 15px; -ms-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.5); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressindicator.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressindicator.css index 4848ee5f5..f8c70cbbf 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressindicator.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressindicator.css @@ -21,6 +21,7 @@ -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -webkit-animation-name: progressIndicatorAnimation; + -webkit-transform: scale(0.25); } .mgwt-ProgressIndicator > span:nth-child\(2\) { @@ -48,12 +49,47 @@ } } +@if user.agent ie10 { + .mgwt-ProgressIndicator > span { + animation-duration: 1s; + animation-iteration-count: infinite; + animation-timing-function: linear; + animation-name: progressIndicatorAnimation; + transform: scale(0.25); + } + + .mgwt-ProgressIndicator > span:nth-child\(2\) { + animation-delay: 0.33s; + } + .mgwt-ProgressIndicator > span:nth-child\(3\) { + animation-delay: 0.66s; + } + + @keyframes progressIndicatorAnimation { + 0% { + transform: scale(0.25); + background-color: #1e7dc8; + } + 16% { + transform: scale(1.0); + background-color: #1e7dc8; + } + 33% { + transform: scale(0.25); + } + 100% { + transform: scale(0.25); + } + } +} + @if user.agent gecko1_8 { .mgwt-ProgressIndicator > span { -moz-animation-duration: 1s; -moz-animation-iteration-count: infinite; -moz-animation-timing-function: linear; -moz-animation-name: progressIndicatorAnimation; + -moz-transform: scale(0.25); } .mgwt-ProgressIndicator > span:nth-child\(2\) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressspinner.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressspinner.css index 7e3865f52..22cfc0538 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressspinner.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/progress/progressspinner.css @@ -20,63 +20,62 @@ border-radius: 2px; } -.mgwt-ProgressSpinner > span:nth-child\(1\) { - -webkit-transform: translate3d(0, -10px, 0); -} - -.mgwt-ProgressSpinner > span:nth-child\(2\) { - -webkit-transform: translate3d(5px, -8.66px, 0) rotate(30deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(3\) { - -webkit-transform: translate3d(8.66px, -5px, 0) rotate(60deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(4\) { - -webkit-transform: translate3d(10px, 0, 0) rotate(90deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(5\) { - -webkit-transform: translate3d(8.66px, 5px, 0) rotate(120deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(6\) { - -webkit-transform: translate3d(5px, 8.66px, 0) rotate(150deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(7\) { - -webkit-transform: translate3d(0px, 10px, 0); -} - -.mgwt-ProgressSpinner > span:nth-child\(8\) { - -webkit-transform: translate3d(-5px, 8.66px, 0) rotate(210deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(9\) { - -webkit-transform: translate3d(-8.66px, 5px, 0) rotate(240deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(10\) { - -webkit-transform: translate3d(-10px, 0, 0) rotate(90deg);; -} - -.mgwt-ProgressSpinner > span:nth-child\(11\) { - -webkit-transform: translate3d(-8.66px, -5px, 0) rotate(300deg); -} - -.mgwt-ProgressSpinner > span:nth-child\(12\) { - -webkit-transform: translate3d(-5px, -8.66px, 0) rotate(330deg); -} - - -.mgwt-ProgressSpinner > span { - -webkit-animation-iteration-count: infinite; - -webkit-animation-timing-function: linear; - -webkit-animation-duration: ANIMATION_DURATION; - -webkit-animation-name: animationProgressSpinner; -} - @if user.agent safari { + .mgwt-ProgressSpinner > span:nth-child\(1\) { + -webkit-transform: translate3d(0, -10px, 0); + } + + .mgwt-ProgressSpinner > span:nth-child\(2\) { + -webkit-transform: translate3d(5px, -8.66px, 0) rotate(30deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(3\) { + -webkit-transform: translate3d(8.66px, -5px, 0) rotate(60deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(4\) { + -webkit-transform: translate3d(10px, 0, 0) rotate(90deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(5\) { + -webkit-transform: translate3d(8.66px, 5px, 0) rotate(120deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(6\) { + -webkit-transform: translate3d(5px, 8.66px, 0) rotate(150deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(7\) { + -webkit-transform: translate3d(0px, 10px, 0); + } + + .mgwt-ProgressSpinner > span:nth-child\(8\) { + -webkit-transform: translate3d(-5px, 8.66px, 0) rotate(210deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(9\) { + -webkit-transform: translate3d(-8.66px, 5px, 0) rotate(240deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(10\) { + -webkit-transform: translate3d(-10px, 0, 0) rotate(90deg);; + } + + .mgwt-ProgressSpinner > span:nth-child\(11\) { + -webkit-transform: translate3d(-8.66px, -5px, 0) rotate(300deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(12\) { + -webkit-transform: translate3d(-5px, -8.66px, 0) rotate(330deg); + } + + .mgwt-ProgressSpinner > span { + -webkit-animation-iteration-count: infinite; + -webkit-animation-timing-function: linear; + -webkit-animation-duration: ANIMATION_DURATION; + -webkit-animation-name: animationProgressSpinner; + } + @-webkit-keyframes animationProgressSpinner { 0% { background: transparent;} 8% { background: #464F5D;} @@ -92,9 +91,7 @@ 92% { background: #DCDCE4;} 100% { background: transparent;} } -} -@if user.agent safari { .mgwt-ProgressSpinner > span:nth-child\(2\) { -webkit-animation-delay: 0.08s; } @@ -129,3 +126,112 @@ -webkit-animation-delay: 0.92s; } } + +@if user.agent ie10 { + .mgwt-ProgressSpinner > span:nth-child\(1\) { + transform: translate3d(0, -10px, 0); + } + + .mgwt-ProgressSpinner > span:nth-child\(2\) { + transform: translate3d(5px, -8.66px, 0) rotate(30deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(3\) { + transform: translate3d(8.66px, -5px, 0) rotate(60deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(4\) { + transform: translate3d(10px, 0, 0) rotate(90deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(5\) { + transform: translate3d(8.66px, 5px, 0) rotate(120deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(6\) { + transform: translate3d(5px, 8.66px, 0) rotate(150deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(7\) { + transform: translate3d(0px, 10px, 0); + } + + .mgwt-ProgressSpinner > span:nth-child\(8\) { + transform: translate3d(-5px, 8.66px, 0) rotate(210deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(9\) { + transform: translate3d(-8.66px, 5px, 0) rotate(240deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(10\) { + transform: translate3d(-10px, 0, 0) rotate(90deg);; + } + + .mgwt-ProgressSpinner > span:nth-child\(11\) { + transform: translate3d(-8.66px, -5px, 0) rotate(300deg); + } + + .mgwt-ProgressSpinner > span:nth-child\(12\) { + transform: translate3d(-5px, -8.66px, 0) rotate(330deg); + } + + .mgwt-ProgressSpinner > span { + animation-iteration-count: infinite; + animation-timing-function: linear; + animation-duration: ANIMATION_DURATION; + animation-name: animationProgressSpinner; + } + + @keyframes animationProgressSpinner { + 0% { background: transparent;} + 8% { background: #464F5D;} + 17% { background: #59606C;} + 25% { background: #656C78;} + 33% { background: #747B85;} + 41% { background: #828791;} + 50% { background: #8D929B;} + 58% { background: #A0A4AD;} + 67% { background: #ADB0BA;} + 75% { background: #BCBEC7;} + 83% { background: #CDCED5;} + 92% { background: #DCDCE4;} + 100% { background: transparent;} + } + + .mgwt-ProgressSpinner > span:nth-child\(2\) { + animation-delay: 0.08s; + } + .mgwt-ProgressSpinner > span:nth-child\(3\) { + animation-delay: 0.17s; + } + .mgwt-ProgressSpinner > span:nth-child\(4\) { + animation-delay: 0.25s; + } + .mgwt-ProgressSpinner > span:nth-child\(5\) { + animation-delay: 0.33s; + } + .mgwt-ProgressSpinner > span:nth-child\(6\) { + animation-delay: 0.41s; + } + .mgwt-ProgressSpinner > span:nth-child\(7\) { + animation-delay: 0.5s; + } + .mgwt-ProgressSpinner > span:nth-child\(8\) { + animation-delay: 0.58s; + } + .mgwt-ProgressSpinner > span:nth-child\(9\) { + animation-delay: 0.67s; + } + .mgwt-ProgressSpinner > span:nth-child\(10\) { + animation-delay: 0.75s; + } + .mgwt-ProgressSpinner > span:nth-child\(11\) { + animation-delay: 0.83s; + } + .mgwt-ProgressSpinner > span:nth-child\(12\) { + animation-delay: 0.92s; + } +} + + diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar-button.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar-button.css index a0a5475c1..29ae02215 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar-button.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar-button.css @@ -12,22 +12,37 @@ @if user.agent safari { .mgwt-TabBar-Button { + display: -webkit-box; /* iOS < 7 && Android < 4.4*/ + display: -webkit-flex; + -webkit-box-orient: vertical; /* iOS < 7 && Android < 4.4*/ + -webkit-flex-direction: column; + -webkit-box-flex: 1; /* iOS < 7 && Android < 4.4*/ + -webkit-flex: 1; -webkit-appearance: none; - -webkit-box-flex: 1; + } +} + +@if user.agent ie10 { + .mgwt-TabBar-Button { + display: -ms-flexbox; + -ms-flex-direction: column; + -ms-flex: 1 1; } } @if user.agent gecko1_8 { .mgwt-TabBar-Button { - -moz-appearance: none; + display: -moz-box; + -moz-flex-direction: column; -moz-box-flex: 1; + -moz-appearance: none; } } .mgwt-TabBar-Button { display: flex; - flex: 1; flex-direction: column; + flex: 1; min-width: 60px; background-color: transparent; height: 39px; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css index 37a563a97..6688cb18f 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/tabbar/tabbar.css @@ -5,14 +5,25 @@ @if user.agent safari { .mgwt-TabPanel { display: -webkit-box; + display: -webkit-flex; -webkit-box-flex: 1; + -webkit-flex: 1; -webkit-box-orient: vertical; + -webkit-flex-direction: column; + } +} + +@if user.agent ie10 { + .mgwt-TabPanel { + display: -ms-flexbox; + -ms-flex: 1 1; + -ms-flex-direction: column; } } @if user.agent gecko1_8 { .mgwt-TabPanel { - display: -webkit-box; + display: -moz-box; -moz-box-flex: 1; -moz-box-orient: vertical; } @@ -27,14 +38,25 @@ @if user.agent safari { .mgwt-TabPanel-container { display: -webkit-box; + display: -webkit-flex; -webkit-box-flex: 1; + -webkit-flex: 1; -webkit-box-orient: vertical; + -webkit-flex-direction: column; + } +} + +@if user.agent ie10 { + .mgwt-TabPanel-container { + display: -ms-flexbox; + -ms-flex: 1 1; + -ms-flex-direction: column; } } @if user.agent gecko1_8 { .mgwt-TabPanel-container { - display: -webkit-box; + display: -moz-box; -moz-box-flex: 1; -moz-box-orient: vertical; } @@ -44,14 +66,25 @@ overflow: hidden; display: flex; flex:1; + flex-direction: column; } @if user.agent safari { .mgwt-TabBar { display: -webkit-box; + display: -webkit-flex; -webkit-box-orient: horizontal; + -webkit-flex-direction: row; } } + +@if user.agent ie10 { + .mgwt-TabBar { + display: -ms-flexbox; + -ms-flex-direction: row; + } +} + @if user.agent gecko1_8 { .mgwt-TabBar { display: -moz-box; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java index dcf1b9236..8d9523f61 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java @@ -23,8 +23,6 @@ import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.FlowPanel; - -import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; import com.googlecode.mgwt.dom.client.event.tap.TapEvent; import com.googlecode.mgwt.dom.client.event.tap.TapHandler; @@ -83,13 +81,7 @@ public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { @Override public HandlerRegistration addTouchHandler(TouchHandler handler) { - HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); - - handlerRegistrationCollection.addHandlerRegistration(addTouchCancelHandler(handler)); - handlerRegistrationCollection.addHandlerRegistration(addTouchStartHandler(handler)); - handlerRegistrationCollection.addHandlerRegistration(addTouchEndHandler(handler)); - handlerRegistrationCollection.addHandlerRegistration(addTouchMoveHandler(handler)); - return handlerRegistrationCollection; + return impl.addTouchHandler(this, handler); } @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java index 14f576ecf..5f3cf4a02 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java @@ -22,8 +22,6 @@ import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.Widget; - -import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; import com.googlecode.mgwt.dom.client.event.tap.TapEvent; import com.googlecode.mgwt.dom.client.event.tap.TapHandler; @@ -83,13 +81,14 @@ public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { @Override public HandlerRegistration addTouchHandler(TouchHandler handler) { - HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); - - handlerRegistrationCollection.addHandlerRegistration(addTouchCancelHandler(handler)); - handlerRegistrationCollection.addHandlerRegistration(addTouchStartHandler(handler)); - handlerRegistrationCollection.addHandlerRegistration(addTouchEndHandler(handler)); - handlerRegistrationCollection.addHandlerRegistration(addTouchMoveHandler(handler)); - return handlerRegistrationCollection; + return impl.addTouchHandler(this, handler); +// HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); +// +// handlerRegistrationCollection.addHandlerRegistration(addTouchCancelHandler(handler)); +// handlerRegistrationCollection.addHandlerRegistration(addTouchStartHandler(handler)); +// handlerRegistrationCollection.addHandlerRegistration(addTouchEndHandler(handler)); +// handlerRegistrationCollection.addHandlerRegistration(addTouchMoveHandler(handler)); +// return handlerRegistrationCollection; } @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java index feb8b2ff4..0eabd2476 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java @@ -15,26 +15,13 @@ */ package com.googlecode.mgwt.ui.client.widget.touch; -import com.google.gwt.event.dom.client.MouseDownEvent; -import com.google.gwt.event.dom.client.MouseMoveEvent; -import com.google.gwt.event.dom.client.MouseUpEvent; -import com.google.gwt.event.dom.client.TouchCancelEvent; import com.google.gwt.event.dom.client.TouchCancelHandler; -import com.google.gwt.event.dom.client.TouchEndEvent; import com.google.gwt.event.dom.client.TouchEndHandler; -import com.google.gwt.event.dom.client.TouchMoveEvent; import com.google.gwt.event.dom.client.TouchMoveHandler; -import com.google.gwt.event.dom.client.TouchStartEvent; import com.google.gwt.event.dom.client.TouchStartHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.Widget; - -import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; -import com.googlecode.mgwt.dom.client.event.mouse.TouchEndToMouseUpHandler; -import com.googlecode.mgwt.dom.client.event.mouse.TouchMoveToMouseMoveHandler; -import com.googlecode.mgwt.dom.client.event.mouse.TouchStartToMouseDownHandler; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -import com.googlecode.mgwt.ui.client.util.NoopHandlerRegistration; /** * The touch widget interface is used to abstract implementation details for @@ -42,109 +29,7 @@ * * @author Daniel Kurka */ -public abstract class TouchWidgetImpl { - - private static class TouchWidgetMobileImpl extends TouchWidgetImpl { - - @Override - public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { - return w.addDomHandler(handler, TouchStartEvent.getType()); - } - - @Override - public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { - return w.addDomHandler(handler, TouchMoveEvent.getType()); - } - - @Override - public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { - return w.addDomHandler(handler, TouchCancelEvent.getType()); - } - - @Override - public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { - return w.addDomHandler(handler, TouchEndEvent.getType()); - } - - @Override - public HandlerRegistration addTouchHandler(Widget w, TouchHandler handler) { - HandlerRegistrationCollection hrc = new HandlerRegistrationCollection(); - hrc.addHandlerRegistration(addTouchStartHandler(w, handler)); - hrc.addHandlerRegistration(addTouchMoveHandler(w, handler)); - hrc.addHandlerRegistration(addTouchEndHandler(w, handler)); - hrc.addHandlerRegistration(addTouchCancelHandler(w, handler)); - return hrc; - } - } - - // Used with deffered binding - @SuppressWarnings("unused") - private static class TouchWidgetRuntimeImpl extends TouchWidgetImpl { - private static boolean hasTouchSupport; - private static TouchWidgetImpl delegate; - - static { - hasTouchSupport = hasTouch(); - if (hasTouchSupport) { - delegate = new TouchWidgetMobileImpl(); - } - } - - private static native boolean hasTouch() /*-{ - return 'ontouchstart' in $doc.documentElement; - }-*/; - - - @Override - public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchStartHandler(w, handler); - } - return w.addDomHandler(new TouchStartToMouseDownHandler(handler), MouseDownEvent.getType()); - } - - @Override - public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchMoveHandler(w, handler); - } - TouchMoveToMouseMoveHandler touchMoveToMouseMoveHandler = new TouchMoveToMouseMoveHandler(handler); - HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); - handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseDownEvent.getType())); - handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseUpEvent.getType())); - handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseMoveEvent.getType())); - return handlerRegistrationCollection; - } - - @Override - public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchCancelHandler(w, handler); - } - return new NoopHandlerRegistration(); - } - - @Override - public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchEndHandler(w, handler); - } - return w.addDomHandler(new TouchEndToMouseUpHandler(handler), MouseUpEvent.getType()); - } - - @Override - public HandlerRegistration addTouchHandler(Widget w, TouchHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchHandler(w, handler); - } - HandlerRegistrationCollection hrc = new HandlerRegistrationCollection(); - hrc.addHandlerRegistration(addTouchStartHandler(w, handler)); - hrc.addHandlerRegistration(addTouchMoveHandler(w, handler)); - hrc.addHandlerRegistration(addTouchEndHandler(w, handler)); - hrc.addHandlerRegistration(addTouchCancelHandler(w, handler)); - return hrc; - } - } +public interface TouchWidgetImpl { /** * Add a touch start handler to a widget diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java new file mode 100644 index 000000000..2f5ecb767 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java @@ -0,0 +1,57 @@ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.event.dom.client.TouchCancelHandler; +import com.google.gwt.event.dom.client.TouchEndHandler; +import com.google.gwt.event.dom.client.TouchMoveHandler; +import com.google.gwt.event.dom.client.TouchStartHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; +import com.googlecode.mgwt.dom.client.event.pointer.MsPointerCancelEvent; +import com.googlecode.mgwt.dom.client.event.pointer.MsPointerDownEvent; +import com.googlecode.mgwt.dom.client.event.pointer.MsPointerMoveEvent; +import com.googlecode.mgwt.dom.client.event.pointer.MsPointerUpEvent; +import com.googlecode.mgwt.dom.client.event.pointer.TouchCancelToMsPointerCancelHandler; +import com.googlecode.mgwt.dom.client.event.pointer.TouchEndToMsPointerUpHandler; +import com.googlecode.mgwt.dom.client.event.pointer.TouchMoveToMsPointerMoveHandler; +import com.googlecode.mgwt.dom.client.event.pointer.TouchStartToMsPointerDownHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; + +public class TouchWidgetPointerImpl implements TouchWidgetImpl +{ + @Override + public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { + return w.addBitlessDomHandler(new TouchStartToMsPointerDownHandler(handler), MsPointerDownEvent.getType()); + } + + @Override + public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { + TouchMoveToMsPointerMoveHandler touchMoveToMsPointerMoveHandler = new TouchMoveToMsPointerMoveHandler(handler); + HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); + handlerRegistrationCollection.addHandlerRegistration(w.addBitlessDomHandler(touchMoveToMsPointerMoveHandler, MsPointerDownEvent.getType())); + handlerRegistrationCollection.addHandlerRegistration(w.addBitlessDomHandler(touchMoveToMsPointerMoveHandler, MsPointerUpEvent.getType())); + handlerRegistrationCollection.addHandlerRegistration(w.addBitlessDomHandler(touchMoveToMsPointerMoveHandler, MsPointerMoveEvent.getType())); + return handlerRegistrationCollection; + } + + @Override + public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { + return w.addBitlessDomHandler(new TouchCancelToMsPointerCancelHandler(handler), MsPointerCancelEvent.getType()); + } + + @Override + public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { + return w.addBitlessDomHandler(new TouchEndToMsPointerUpHandler(handler), MsPointerUpEvent.getType()); + } + + @Override + public HandlerRegistration addTouchHandler(Widget w, TouchHandler handler) { + HandlerRegistrationCollection hrc = new HandlerRegistrationCollection(); + hrc.addHandlerRegistration(addTouchStartHandler(w, handler)); + hrc.addHandlerRegistration(addTouchMoveHandler(w, handler)); + hrc.addHandlerRegistration(addTouchEndHandler(w, handler)); + hrc.addHandlerRegistration(addTouchCancelHandler(w, handler)); + return hrc; + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java new file mode 100644 index 000000000..0a5988bc1 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java @@ -0,0 +1,86 @@ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseMoveEvent; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.TouchCancelHandler; +import com.google.gwt.event.dom.client.TouchEndHandler; +import com.google.gwt.event.dom.client.TouchMoveHandler; +import com.google.gwt.event.dom.client.TouchStartHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; +import com.googlecode.mgwt.dom.client.event.mouse.TouchEndToMouseUpHandler; +import com.googlecode.mgwt.dom.client.event.mouse.TouchMoveToMouseMoveHandler; +import com.googlecode.mgwt.dom.client.event.mouse.TouchStartToMouseDownHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.ui.client.util.NoopHandlerRegistration; + +public class TouchWidgetStandardImpl implements TouchWidgetImpl +{ + private static boolean hasTouchSupport; + private static TouchWidgetImpl delegate; + + static { + hasTouchSupport = hasTouch(); + if (hasTouchSupport) { + delegate = new TouchWidgetTouchImpl(); + } + } + + private static native boolean hasTouch() /*-{ + return 'ontouchstart' in $doc.documentElement; + }-*/; + + + @Override + public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { + if (hasTouchSupport) { + return delegate.addTouchStartHandler(w, handler); + } + return w.addDomHandler(new TouchStartToMouseDownHandler(handler), MouseDownEvent.getType()); + } + + @Override + public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { + if (hasTouchSupport) { + return delegate.addTouchMoveHandler(w, handler); + } + TouchMoveToMouseMoveHandler touchMoveToMouseMoveHandler = new TouchMoveToMouseMoveHandler(handler); + HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); + handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseDownEvent.getType())); + handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseUpEvent.getType())); + handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseMoveEvent.getType())); + return handlerRegistrationCollection; + } + + @Override + public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { + if (hasTouchSupport) { + return delegate.addTouchCancelHandler(w, handler); + } + return new NoopHandlerRegistration(); + } + + @Override + public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { + if (hasTouchSupport) { + return delegate.addTouchEndHandler(w, handler); + } + return w.addDomHandler(new TouchEndToMouseUpHandler(handler), MouseUpEvent.getType()); + } + + @Override + public HandlerRegistration addTouchHandler(Widget w, TouchHandler handler) { + if (hasTouchSupport) { + return delegate.addTouchHandler(w, handler); + } + HandlerRegistrationCollection hrc = new HandlerRegistrationCollection(); + hrc.addHandlerRegistration(addTouchStartHandler(w, handler)); + hrc.addHandlerRegistration(addTouchMoveHandler(w, handler)); + hrc.addHandlerRegistration(addTouchEndHandler(w, handler)); + hrc.addHandlerRegistration(addTouchCancelHandler(w, handler)); + return hrc; + } + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java new file mode 100644 index 000000000..23b10a387 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java @@ -0,0 +1,47 @@ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.event.dom.client.TouchCancelEvent; +import com.google.gwt.event.dom.client.TouchCancelHandler; +import com.google.gwt.event.dom.client.TouchEndEvent; +import com.google.gwt.event.dom.client.TouchEndHandler; +import com.google.gwt.event.dom.client.TouchMoveEvent; +import com.google.gwt.event.dom.client.TouchMoveHandler; +import com.google.gwt.event.dom.client.TouchStartEvent; +import com.google.gwt.event.dom.client.TouchStartHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; + +public class TouchWidgetTouchImpl implements TouchWidgetImpl +{ + @Override + public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { + return w.addDomHandler(handler, TouchStartEvent.getType()); + } + + @Override + public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { + return w.addDomHandler(handler, TouchMoveEvent.getType()); + } + + @Override + public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { + return w.addDomHandler(handler, TouchCancelEvent.getType()); + } + + @Override + public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { + return w.addDomHandler(handler, TouchEndEvent.getType()); + } + + @Override + public HandlerRegistration addTouchHandler(Widget w, TouchHandler handler) { + HandlerRegistrationCollection hrc = new HandlerRegistrationCollection(); + hrc.addHandlerRegistration(addTouchStartHandler(w, handler)); + hrc.addHandlerRegistration(addTouchMoveHandler(w, handler)); + hrc.addHandlerRegistration(addTouchEndHandler(w, handler)); + hrc.addHandlerRegistration(addTouchCancelHandler(w, handler)); + return hrc; + } +} diff --git a/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java b/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java index 2c7759636..66f2f7819 100644 --- a/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java +++ b/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java @@ -40,9 +40,29 @@ public String getModuleName() { @DoNotRunWith(Platform.HtmlUnitUnknown) public void testConvert_withKnownImage() { ImageConverter imageConverter = new ImageConverter(); - ImageResource convertedResource = imageConverter.convert( - ImageConverterTestBundle.INSTANCE.knownImage(), "#0000F1"); + ImageResource convertedResource = null; + + ImageConverterCallback callback = new ImageConverterCallback() + { + public ImageResource convertedResource = null; + + @Override + public void onFailure(Throwable caught) + { + } + @Override + public void onSuccess(ImageResource convertedResource) + { + this.convertedResource = convertedResource; + } + + }; + + imageConverter.convert(ImageConverterTestBundle.INSTANCE.knownImage(), "#0000F1", callback); + + delayTestFinish(200); + /* * Dirty hack to test, should be improved. */ diff --git a/src/test/java/com/googlecode/mgwt/ui/client/widget/input/search/MSearchBoxGwtTest.java b/src/test/java/com/googlecode/mgwt/ui/client/widget/input/search/MSearchBoxGwtTest.java index 68f8cd1a6..8fd0e3fe7 100644 --- a/src/test/java/com/googlecode/mgwt/ui/client/widget/input/search/MSearchBoxGwtTest.java +++ b/src/test/java/com/googlecode/mgwt/ui/client/widget/input/search/MSearchBoxGwtTest.java @@ -93,7 +93,7 @@ public void execute() { assertEquals(4, valueChangeEventCount); assertEquals(0, clearCount); - mSearchBox.clearButton.fireEvent(new TapEvent(this, null, 0, 0)); + mSearchBox.clearButton.fireEvent(new TapEvent(this, null, null)); assertEquals("", mSearchBox.getValue()); assertEquals(2, submitCount); From 2e42eb3e8b9ad486d7463ef14767c46f4a497154 Mon Sep 17 00:00:00 2001 From: Paul French Date: Thu, 25 Jun 2015 10:06:34 +0100 Subject: [PATCH 31/53] Amendments due to Daniel Kurka's review comments from the first quick initial review. Also added a better fix for IOS to stop screen bounce but also allow MTextArea to function. We only preventDefault on the first TouchMove event and do not prevent default on subsequent TouchMove events. This allows the MTextArea to be scrollable unlike before. --- .../gwt/user/client/impl/DOMImplIE10.java | 2 + .../rebind/UserAgentPropertyGenerator.java | 104 ------ .../java/com/googlecode/mgwt/dom/DOM.gwt.xml | 7 +- .../event/animation/TransitionEndEvent.java | 8 + .../TouchMoveToMsPointerMoveHandler.java | 18 +- .../mgwt/dom/client/event/tap/TapEvent.java | 33 +- .../dom/client/event/touch/TouchCopy.java | 50 ++- .../mgwt/image/client/ImageConverter.java | 76 ++--- .../image/client/ImageConverterCallback.java | 8 - .../mgwt/image/client/LoadImageCallback.java | 8 - .../com/googlecode/mgwt/ui/client/MGWT.java | 41 ++- .../ui/client/OsDetectionRuntimeImpl.java | 7 +- .../mgwt/ui/client/util/IconHandler.java | 6 +- .../ui/client/util/impl/CssUtilIE10Impl.java | 12 +- .../widget/animation/bundle/dissolve.css | 126 ++++---- .../client/widget/animation/bundle/fade.css | 122 +++---- .../client/widget/animation/bundle/flip.css | 175 +++++----- .../ui/client/widget/animation/bundle/pop.css | 166 +++++----- .../widget/animation/bundle/slide-up.css | 182 +++++------ .../client/widget/animation/bundle/slide.css | 198 ++++++------ .../client/widget/animation/bundle/swap.css | 298 +++++++++--------- .../ui/client/widget/button/ButtonBase.java | 7 +- .../ui/client/widget/button/imagebutton.css | 6 + .../panel/flex/FlexPropertyHelperIE10.java | 13 + .../panel/flex/FlexPropertyHelperMoz.java | 13 + .../flex/FlexPropertyHelperStandard.java | 13 + .../panel/flex/FlexPropertyHelperWebkit.java | 15 +- .../scroll/impl/ScrollPanelTouchImpl.java | 34 +- .../widget/touch/TouchWidgetPointerImpl.java | 20 +- .../widget/touch/TouchWidgetStandardImpl.java | 13 + .../widget/touch/TouchWidgetTouchImpl.java | 13 + .../client/ImageConverterGwtTestCase.java | 6 +- 32 files changed, 910 insertions(+), 890 deletions(-) delete mode 100644 src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java delete mode 100644 src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java delete mode 100644 src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java diff --git a/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java index b8b4c0035..8d60a9962 100644 --- a/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java +++ b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java @@ -35,6 +35,8 @@ public class DOMImplIE10 extends DOMImplIE9 { * even when the pointer has moved off the element up until MSPointerUp has occurred. * * Do not do pointer capture on input or textarea elements, all sorts of problems arise if you do! + * For example if you type into a password field you cannot set the cursor to the end of + * the text when re-entering it and so you cannot edit your password */ private native static void capturePointerEvents() /*-{ $wnd.addEventListener('MSPointerDown', diff --git a/src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java b/src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java deleted file mode 100644 index 9f7483ed0..000000000 --- a/src/main/java/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java +++ /dev/null @@ -1,104 +0,0 @@ - -package com.google.gwt.useragent.rebind; - -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.linker.ConfigurationProperty; -import com.google.gwt.core.ext.linker.PropertyProviderGenerator; -import com.google.gwt.user.rebind.SourceWriter; -import com.google.gwt.user.rebind.StringSourceWriter; - -import java.util.HashSet; -import java.util.Set; -import java.util.SortedSet; - -/** - * Generator which writes out the JavaScript for determining the value of the - * user.agent selection property. - */ -public class UserAgentPropertyGenerator implements PropertyProviderGenerator { - - /** - * The list of {@code user.agent} values listed here should be kept in sync with - * {@code UserAgent.gwt.xml}. - *

Note that the order of enums matter as the script selection is based on running - * these predicates in order and matching the first one that returns {@code true}. - *

Also note that, {@code docMode < 11} in predicates for older IEs exists to - * ensures we never choose them for IE11 (we know that they will not work for IE11). - */ - private enum UserAgent { - safari("return ((ua.indexOf('webkit') != -1) && !(ua.indexOf('trident') != -1));"), - ie10("return (ua.indexOf('msie') != -1 && (docMode >= 10 && docMode < 11)) || " - + "(ua.indexOf('iemobile') != -1 && (docMode >= 10 && docMode < 11))"), - ie9("return (ua.indexOf('msie') != -1 && (docMode >= 9 && docMode < 11));"), - ie8("return (ua.indexOf('msie') != -1 && (docMode >= 8 && docMode < 11));"), - gecko1_8("return (ua.indexOf('gecko') != -1 || docMode >= 11);"); - - private final String predicateBlock; - - private UserAgent(String predicateBlock) { - this.predicateBlock = predicateBlock; - } - - private static Set getKnownAgents() { - HashSet userAgents = new HashSet(); - for (UserAgent userAgent : values()) { - userAgents.add(userAgent.name()); - } - return userAgents; - } - } - - /** - * Writes out the JavaScript function body for determining the value of the - * user.agent selection property. This method is used to create - * the selection script and by {@link UserAgentGenerator} to assert at runtime - * that the correct user agent permutation is executing. - */ - static void writeUserAgentPropertyJavaScript(SourceWriter body, - SortedSet possibleValues, String fallback) { - - // write preamble - body.println("var ua = navigator.userAgent.toLowerCase();"); - body.println("var docMode = $doc.documentMode;"); - - for (UserAgent userAgent : UserAgent.values()) { - // write only selected user agents - if (possibleValues.contains(userAgent.name())) { - body.println("if ((function() { "); - body.indentln(userAgent.predicateBlock); - body.println("})()) return '%s';", userAgent.name()); - } - } - - // default return - if (fallback == null) { - fallback = "unknown"; - } - body.println("return '" + fallback + "';"); - } - - @Override - public String generate(TreeLogger logger, SortedSet possibleValues, String fallback, - SortedSet configProperties) { - assertUserAgents(logger, possibleValues); - - StringSourceWriter body = new StringSourceWriter(); - body.println("{"); - body.indent(); - writeUserAgentPropertyJavaScript(body, possibleValues, fallback); - body.outdent(); - body.println("}"); - - return body.toString(); - } - - private static void assertUserAgents(TreeLogger logger, SortedSet possibleValues) { - HashSet unknownValues = new HashSet(possibleValues); - unknownValues.removeAll(UserAgent.getKnownAgents()); - if (!unknownValues.isEmpty()) { - logger.log(TreeLogger.WARN, "Unrecognized " + UserAgentGenerator.PROPERTY_USER_AGENT - + " values " + unknownValues + ", possibly due to UserAgent.gwt.xml and " - + UserAgentPropertyGenerator.class.getName() + " being out of sync."); - } - } -} diff --git a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml index 07446025e..edfad43b1 100644 --- a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml @@ -61,12 +61,9 @@ { private static final Type TYPE = new Type(); - private final Touch touch; + private final TouchCopy touchCopy; private final Element targetElement; public TapEvent(Object source, Element targetElement, Touch touch) { this.targetElement = targetElement; - this.touch = touch; + this.touchCopy = TouchCopy.copy(touch); setSource(source); } @@ -53,20 +54,28 @@ public static Type getType() { return TYPE; } - /** - * Get access to other useful position information related to the tap event - * @return - */ - public Touch getTouch() { - return touch; - } - public int getStartX() { - return touch.getPageX(); + return touchCopy.getPageX(); } public int getStartY() { - return touch.getPageY(); + return touchCopy.getPageY(); + } + + public int getClientX() { + return touchCopy.getClientX(); + } + + public int getClientY() { + return touchCopy.getClientY(); + } + + public int getScreenX() { + return touchCopy.getScreenX(); + } + + public int getScreenY() { + return touchCopy.getScreenY(); } /** diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCopy.java b/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCopy.java index 63b14367b..db6c77a48 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCopy.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCopy.java @@ -20,25 +20,59 @@ public class TouchCopy { public static TouchCopy copy(Touch touch) { - return new TouchCopy(touch.getPageX(), touch.getPageY(), touch.getIdentifier()); + return new TouchCopy(touch); } - private final int x; - private final int y; + private final int pageX; + private final int pageY; + private final int clientX; + private final int clientY; + private final int screenX; + private final int screenY; private final int id; - public TouchCopy(int x, int y, int id) { - this.x = x; - this.y = y; + public TouchCopy(int pageX, int pageY, int id) { + this.pageX = pageX; + this.pageY = pageY; + this.clientX = 0; + this.clientY = 0; + this.screenX = 0; + this.screenY = 0; this.id = id; } + public TouchCopy(Touch touch) { + this.pageX = touch.getPageX(); + this.pageY = touch.getPageY(); + this.clientX = touch.getClientX(); + this.clientY = touch.getClientY(); + this.screenX = touch.getScreenX(); + this.screenY = touch.getScreenY(); + this.id = touch.getIdentifier(); + } + public int getPageX() { - return x; + return pageX; } public int getPageY() { - return y; + return pageY; + } + + public int getClientX() { + return clientX; + } + + public int getClientY() { + return clientY; + } + + public int getScreenX() { + return screenX; + } + + public int getScreenY() { + return screenY; } public int getIdentifier() { diff --git a/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java b/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java index 3f4846b49..2d64309cf 100644 --- a/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java +++ b/src/main/java/com/googlecode/mgwt/image/client/ImageConverter.java @@ -31,6 +31,14 @@ static class ConversionContext { CanvasPixelArray canvasPixelArray; } + private interface LoadImageCallback{ + public void onSuccess(ImageElement imageElement); + } + + public interface ImageConverterCallback{ + public void onSuccess(ImageResource imageResource); + } + private class ConvertedImageResource implements ImageResource { private final String dataUrl; @@ -122,43 +130,31 @@ public void convert(final ImageResource resource, String color, final ImageConve final int width = resource.getWidth(); loadImage(resource.getSafeUri().asString(), width, height, new LoadImageCallback() { - @Override - public void onFailure(Throwable caught) - { - imageConverterCallback.onFailure(caught); - } @Override - public void onSuccess(ImageElement imageElement) - { - try - { - Canvas canvas = Canvas.createIfSupported(); - canvas.getElement().setPropertyInt("height", height); - canvas.getElement().setPropertyInt("width", width); - - Context2d context = canvas.getContext2d(); - context.drawImage(imageElement, 0, 0); - ImageData imageData = context.getImageData(0, 0, width, height); - - CanvasPixelArray canvasPixelArray = imageData.getData(); - - for (int i = 0; i < canvasPixelArray.getLength(); i += 4) { - canvasPixelArray.set(i, red); - canvasPixelArray.set(i + 1, green); - canvasPixelArray.set(i + 2, blue); - canvasPixelArray.set(i + 3, - canvasPixelArray.get(i + 3)); - } - context.putImageData(imageData, 0, 0); - imageConverterCallback.onSuccess(new ConvertedImageResource( - canvas.toDataUrl("image/png"), resource.getWidth(), - resource.getHeight())); - } - catch(Throwable e) - { - this.onFailure(e); + public void onSuccess(ImageElement imageElement) { + + Canvas canvas = Canvas.createIfSupported(); + canvas.getElement().setPropertyInt("height", height); + canvas.getElement().setPropertyInt("width", width); + + Context2d context = canvas.getContext2d(); + context.drawImage(imageElement, 0, 0); + ImageData imageData = context.getImageData(0, 0, width, height); + + CanvasPixelArray canvasPixelArray = imageData.getData(); + + for (int i = 0; i < canvasPixelArray.getLength(); i += 4) { + canvasPixelArray.set(i, red); + canvasPixelArray.set(i + 1, green); + canvasPixelArray.set(i + 2, blue); + canvasPixelArray.set(i + 3, + canvasPixelArray.get(i + 3)); } + context.putImageData(imageData, 0, 0); + imageConverterCallback.onSuccess(new ConvertedImageResource( + canvas.toDataUrl("image/png"), resource.getWidth(), + resource.getHeight())); } }); } @@ -169,14 +165,12 @@ protected native void loadImage(String dataUrl, int width, int height, LoadImage img.height = height; img.src = dataUrl; img.onload = $entry(function(){ - callback.@com.googlecode.mgwt.image.client.LoadImageCallback::onSuccess(Lcom/google/gwt/dom/client/ImageElement;)(img); - }); - img.onerror = $entry(function(e){ - callback.@com.googlecode.mgwt.image.client.LoadImageCallback::onFailure(Ljava/lang/Throwable;)(e); - }); - img.onabort = $entry(function(e){ - callback.@com.googlecode.mgwt.image.client.LoadImageCallback::onFailure(Ljava/lang/Throwable;)(e); + callback.@com.googlecode.mgwt.image.client.ImageConverter.LoadImageCallback::onSuccess(Lcom/google/gwt/dom/client/ImageElement;)(img); }); + img.onerror = function(e){ + @com.google.gwt.core.client.GWT::reportUncaughtException(Ljava/lang/Throwable;)(e); + return true; + }; }-*/; private String maybeExpandColor(String color) { diff --git a/src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java b/src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java deleted file mode 100644 index 6a5754627..000000000 --- a/src/main/java/com/googlecode/mgwt/image/client/ImageConverterCallback.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.googlecode.mgwt.image.client; - -import com.google.gwt.resources.client.ImageResource; - -public interface ImageConverterCallback{ - public void onSuccess(ImageResource imageResource); - public void onFailure(Throwable e); -} diff --git a/src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java b/src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java deleted file mode 100644 index aafdb1dda..000000000 --- a/src/main/java/com/googlecode/mgwt/image/client/LoadImageCallback.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.googlecode.mgwt.image.client; - -import com.google.gwt.dom.client.ImageElement; - -public interface LoadImageCallback{ - public void onSuccess(ImageElement imageElement); - public void onFailure(Throwable e); -} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java index 52880b8c8..8e7b57110 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java @@ -153,11 +153,6 @@ public static void applySettings(MGWTSettings settings) { if (TouchSupport.isTouchEventsEmulatedUsingPointerEvents()) { - MetaElement ieCompatible = Document.get().createMetaElement(); - ieCompatible.setHttpEquiv("x-ua-compatible"); - ieCompatible.setContent("IE=10"); - head.appendChild(ieCompatible); - MetaElement tapHighlight = Document.get().createMetaElement(); tapHighlight.setName("msapplication-tap-highlight"); tapHighlight.setContent("no"); @@ -313,16 +308,36 @@ private static Element getHead() { return elementsByTagName.getItem(0); } - private static native void setupPreventScrolling(Element el)/*-{ - var func = function(event) { - var tagName = event.target.tagName; - if ((tagName == 'INPUT') || (tagName == 'SELECT') || (tagName == 'TEXTAREA')) { - return true; + /** + * Only call preventDefault on the first TouchMove event. It stops the screen bounce + * and allows other scrollable widgets to function with their default behaviour e.g MTextArea + * @param el + */ + private static native void setupPreventScrolling(Element el) /*-{ + var onGoingTouches = {}; + + var handleTouchMove = function(touchMoveEvent) { + var touches = touchMoveEvent.changedTouches; + for (var i=0; i < touches.length; i++) { + if (!(touches[i].identifier in onGoingTouches)) { + onGoingTouches[touches[i].identifier] = ""; + touchMoveEvent.preventDefault(); + } + } + }; + + var cleanup = function(event) { + var touches = event.changedTouches; + for (var i=0; i < touches.length; i++) { + if (touches[i].identifier in onGoingTouches) { + delete onGoingTouches[touches[i].identifier]; + } } - event.preventDefault(); - return false; }; - el.ontouchmove = func; + + el.addEventListener("touchend", cleanup, false); + el.addEventListener("touchcancel", cleanup, false); + el.addEventListener("touchmove", handleTouchMove, false); }-*/; private static void setupPreventScrollingIE10(Element el) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java index 01b9c8dc7..5e64c7853 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java @@ -120,12 +120,9 @@ native String getUserAgent() /*-{ native double getDevicePixelRatio() /*-{ if (!$wnd.devicePixelRatio) { - try { - if ('deviceXDPI' in $wnd.screen) { - $wnd.devicePixelRatio = $wnd.screen.deviceXDPI / $wnd.screen.logicalXDPI; - } + if ('deviceXDPI' in $wnd.screen) { + $wnd.devicePixelRatio = $wnd.screen.deviceXDPI / $wnd.screen.logicalXDPI; } - catch(e) {} } return $wnd.devicePixelRatio || 1; }-*/; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java b/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java index edbd0329d..bcbf53c93 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java @@ -20,7 +20,7 @@ import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.resources.client.ImageResource; import com.googlecode.mgwt.image.client.ImageConverter; -import com.googlecode.mgwt.image.client.ImageConverterCallback; +import com.googlecode.mgwt.image.client.ImageConverter.ImageConverterCallback; import com.googlecode.mgwt.ui.client.MGWT; public class IconHandler { @@ -93,10 +93,6 @@ public void setIcons(final Element element, ImageResource icon, String color) { converter.convert(icon, color, new ImageConverterCallback() { - @Override - public void onFailure(Throwable caught) { - } - @Override public void onSuccess(ImageResource convertImageResource) { element.getStyle().setBackgroundColor("transparent"); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java index 2ea02f48e..3aafd5038 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java @@ -19,7 +19,7 @@ public void translate(Element el, int x, int y) { String cssText = "translate3d(" + x + "px," + y + "px,0px)"; _translate(el, cssText); } - + @Override public native void setDelay(Element el, int milliseconds) /*-{ el.style.transitionDelay = milliseconds + "ms"; @@ -35,7 +35,7 @@ public native void setDuration(Element el, int time) /*-{ el.style.transitionDuration = time + "ms"; }-*/; - private native void _translate(Element el, String css)/*-{ + private native void _translate(Element el, String css) /*-{ el.style.transform = css; }-*/; @@ -70,7 +70,7 @@ public int[] getPositionFromTransForm(Element element) { return new int[] {array.get(0), array.get(1)}; } - private native JsArrayInteger getPositionFromTransform(Element el)/*-{ + private native JsArrayInteger getPositionFromTransform(Element el) /*-{ var matrix = getComputedStyle(el, null)['transform'].replace( /[^0-9-.,]/g, '').split(','); if (matrix.length === 6) { @@ -87,12 +87,12 @@ private native JsArrayInteger getPositionFromTransform(Element el)/*-{ @Override public native int getTopPositionFromCssPosition(Element element) /*-{ - return getComputedStyle(element, null).top.replace(/[^0-9-]/g, '') * 1; + return getComputedStyle(element, null).top.replace(/[^0-9-]/g, '') * 1; }-*/; @Override - public native int getLeftPositionFromCssPosition(Element element)/*-{ - return getComputedStyle(element, null).left.replace(/[^0-9-]/g, '') * 1; + public native int getLeftPositionFromCssPosition(Element element) /*-{ + return getComputedStyle(element, null).left.replace(/[^0-9-]/g, '') * 1; }-*/; @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css index de55a77c2..5effc3e27 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/dissolve.css @@ -1,67 +1,67 @@ -@if user.agent safari { -.in, .out { - -webkit-animation-timing-function: ease-in-out; - -webkit-animation-duration: 300ms; - -webkit-animation-fill-mode: both; -} - -.in { - -webkit-animation-name: appear; -} - -.out { - -webkit-animation-name: dissolve; -} - -.in.reverse { - -webkit-animation-name: appear; -} - -.out.reverse { - -webkit-animation-name: dissolve; -} - -@-webkit-keyframes dissolve { - from { opacity: 1; } - to { opacity: 0; } -} - -@-webkit-keyframes appear { - from { opacity: 0; } - to { opacity: 1; } -} +@if !user.agent ie10 { + .in, .out { + -webkit-animation-timing-function: ease-in-out; + -webkit-animation-duration: 300ms; + -webkit-animation-fill-mode: both; + } + + .in { + -webkit-animation-name: appear; + } + + .out { + -webkit-animation-name: dissolve; + } + + .in.reverse { + -webkit-animation-name: appear; + } + + .out.reverse { + -webkit-animation-name: dissolve; + } + + @-webkit-keyframes dissolve { + from { opacity: 1; } + to { opacity: 0; } + } + + @-webkit-keyframes appear { + from { opacity: 0; } + to { opacity: 1; } + } } @if user.agent ie10 { - .in, .out { - animation-timing-function: ease-in-out; - animation-duration: 300ms; - animation-fill-mode: both; - } - - .in { - animation-name: appear; - } - - .out { - animation-name: dissolve; - } - - .in.reverse { - animation-name: appear; - } - - .out.reverse { - animation-name: dissolve; - } - - @keyframes dissolve { - from { opacity: 1; } - to { opacity: 0; } - } - - @keyframes appear { - from { opacity: 0; } - to { opacity: 1; } - } + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: appear; + } + + .out { + animation-name: dissolve; + } + + .in.reverse { + animation-name: appear; + } + + .out.reverse { + animation-name: dissolve; + } + + @keyframes dissolve { + from { opacity: 1; } + to { opacity: 0; } + } + + @keyframes appear { + from { opacity: 0; } + to { opacity: 1; } + } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css index 998e59438..69f0520e6 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/fade.css @@ -1,65 +1,65 @@ -@if user.agent safari { -.in, .out { - -webkit-animation-timing-function: ease-in-out; - -webkit-animation-duration: 300ms; - -webkit-animation-fill-mode: both; -} - -.in { - -webkit-animation-name: fadein; -} -.out { - -webkit-animation-name: fadeout; -} - -.in.reverse { - -webkit-animation-name: fadein; -} - -.out.reverse { - -webkit-animation-name: fadeout; -} - -@-webkit-keyframes fadein { - from { opacity: 0; } - to { opacity: 1; } -} - -@-webkit-keyframes fadeout { - from { opacity: 1; } - to { opacity: 0; } -} +@if !user.agent ie10 { + .in, .out { + -webkit-animation-timing-function: ease-in-out; + -webkit-animation-duration: 300ms; + -webkit-animation-fill-mode: both; + } + + .in { + -webkit-animation-name: fadein; + } + .out { + -webkit-animation-name: fadeout; + } + + .in.reverse { + -webkit-animation-name: fadein; + } + + .out.reverse { + -webkit-animation-name: fadeout; + } + + @-webkit-keyframes fadein { + from { opacity: 0; } + to { opacity: 1; } + } + + @-webkit-keyframes fadeout { + from { opacity: 1; } + to { opacity: 0; } + } } @if user.agent ie10 { - .in, .out { - animation-timing-function: ease-in-out; - animation-duration: 300ms; - animation-fill-mode: both; - } - - .in { - animation-name: fadein; - } - .out { - animation-name: fadeout; - } - - .in.reverse { - animation-name: fadein; - } - - .out.reverse { - animation-name: fadeout; - } - - @keyframes fadein { - from { opacity: 0; } - to { opacity: 1; } - } - - @keyframes fadeout { - from { opacity: 1; } - to { opacity: 0; } - } + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: fadein; + } + .out { + animation-name: fadeout; + } + + .in.reverse { + animation-name: fadein; + } + + .out.reverse { + animation-name: fadeout; + } + + @keyframes fadein { + from { opacity: 0; } + to { opacity: 1; } + } + + @keyframes fadeout { + from { opacity: 1; } + to { opacity: 0; } + } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css index dcda09138..d032b9b34 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/flip.css @@ -1,91 +1,92 @@ -@if user.agent safari { -.in, .out { - -webkit-animation-timing-function: ease-in-out; - -webkit-animation-duration: 300ms; - -webkit-animation-fill-mode: both; - -webkit-animation-duration: .65s; - -webkit-backface-visibility: hidden; -} - -.in { - -webkit-animation-name: flipinfromleft; -} - -.out { - -webkit-animation-name: flipouttoleft; -} - -.in.reverse { - -webkit-animation-name: flipinfromright; -} - -.out.reverse { - -webkit-animation-name: flipouttoright; -} - -@-webkit-keyframes flipinfromright { - from { -webkit-transform: rotateY(-180deg) scale(.8); } - to { -webkit-transform: rotateY(0) scale(1); } -} - -@-webkit-keyframes flipinfromleft { - from { -webkit-transform: rotateY(180deg) scale(.8); } - to { -webkit-transform: rotateY(0) scale(1); } -} - -@-webkit-keyframes flipouttoleft { - from { -webkit-transform: rotateY(0) scale(1); } - to { -webkit-transform: rotateY(-180deg) scale(.8); } -} - -@-webkit-keyframes flipouttoright { - from { -webkit-transform: rotateY(0) scale(1); } - to { -webkit-transform: rotateY(180deg) scale(.8); } -} +@if !user.agent ie10 { + .in, .out { + -webkit-animation-timing-function: ease-in-out; + -webkit-animation-fill-mode: both; + -webkit-animation-duration: 0.65s; + -webkit-backface-visibility: hidden; + -webkit-transform-style: preserve-3d; + } + + .in { + -webkit-animation-name: flipinfromleft; + } + + .out { + -webkit-animation-name: flipouttoleft; + } + + .in.reverse { + -webkit-animation-name: flipinfromright; + -webkit-backface-visibility: hidden; + } + + .out.reverse { + -webkit-animation-name: flipouttoright; + -webkit-backface-visibility: hidden; + } + + @-webkit-keyframes flipinfromright { + from { -webkit-transform: rotateY(-180deg) scale(.8); } + to { -webkit-transform: rotateY(0) scale(1); } + } + + @-webkit-keyframes flipinfromleft { + from { -webkit-transform: rotateY(180deg) scale(.8); } + to { -webkit-transform: rotateY(0) scale(1); } + } + + @-webkit-keyframes flipouttoleft { + from { -webkit-transform: rotateY(0) scale(1); } + to { -webkit-transform: rotateY(-180deg) scale(.8); } + } + + @-webkit-keyframes flipouttoright { + from { -webkit-transform: rotateY(0) scale(1); } + to { -webkit-transform: rotateY(180deg) scale(.8); } + } } @if user.agent ie10 { - .in, .out { - animation-timing-function: ease-in-out; - animation-duration: 300ms; - animation-fill-mode: both; - animation-duration: .65s; - backface-visibility: hidden; - } - - .in { - animation-name: flipinfromleft; - } - - .out { - animation-name: flipouttoleft; - } - - .in.reverse { - animation-name: flipinfromright; - } - - .out.reverse { - animation-name: flipouttoright; - } - - @keyframes flipinfromright { - from { transform: rotateY(-180deg) scale(.8); } - to { transform: rotateY(0) scale(1); } - } - - @keyframes flipinfromleft { - from { transform: rotateY(180deg) scale(.8); } - to { transform: rotateY(0) scale(1); } - } - - @keyframes flipouttoleft { - from { transform: rotateY(0) scale(1); } - to { transform: rotateY(-180deg) scale(.8); } - } - - @keyframes flipouttoright { - from { transform: rotateY(0) scale(1); } - to { transform: rotateY(180deg) scale(.8); } - } + .in, .out { + animation-timing-function: ease-in-out; + animation-fill-mode: both; + animation-duration: .65s; + backface-visibility: hidden; + } + + .in { + animation-name: flipinfromleft; + } + + .out { + animation-name: flipouttoleft; + } + + .in.reverse { + animation-name: flipinfromright; + } + + .out.reverse { + animation-name: flipouttoright; + } + + @keyframes flipinfromright { + from { transform: rotateY(-180deg) scale(.8); } + to { transform: rotateY(0) scale(1); } + } + + @keyframes flipinfromleft { + from { transform: rotateY(180deg) scale(.8); } + to { transform: rotateY(0) scale(1); } + } + + @keyframes flipouttoleft { + from { transform: rotateY(0) scale(1); } + to { transform: rotateY(-180deg) scale(.8); } + } + + @keyframes flipouttoright { + from { transform: rotateY(0) scale(1); } + to { transform: rotateY(180deg) scale(.8); } + } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css index 37bad2cf8..041de08a8 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/pop.css @@ -1,91 +1,91 @@ -@if user.agent safari { -.in, .out { - -webkit-animation-timing-function: ease-in-out; - -webkit-animation-duration: 300ms; - -webkit-animation-fill-mode: both; -} - -.in { - -webkit-animation-name: popin; -} - -.out { - -webkit-animation-name: popout; -} - -.in.reverse { - -webkit-animation-name: popin; -} - -.out.reverse { - -webkit-animation-name: popout; -} - -@-webkit-keyframes popin { - from { - -webkit-transform: scale(.3); - opacity: 0; +@if !user.agent ie10 { + .in, .out { + -webkit-animation-timing-function: ease-in-out; + -webkit-animation-duration: 300ms; + -webkit-animation-fill-mode: both; } - to { - -webkit-transform: scale(1); - opacity: 1; + + .in { + -webkit-animation-name: popin; } -} - -@-webkit-keyframes popout { - from { - -webkit-transform: scale(1); - opacity: 1; + + .out { + -webkit-animation-name: popout; } - to { - -webkit-transform: scale(.3); - opacity: 0; + + .in.reverse { + -webkit-animation-name: popin; + } + + .out.reverse { + -webkit-animation-name: popout; + } + + @-webkit-keyframes popin { + from { + -webkit-transform: scale(.3); + opacity: 0; + } + to { + -webkit-transform: scale(1); + opacity: 1; + } + } + + @-webkit-keyframes popout { + from { + -webkit-transform: scale(1); + opacity: 1; + } + to { + -webkit-transform: scale(.3); + opacity: 0; + } } -} } @if user.agent ie10 { - .in, .out { - animation-timing-function: ease-in-out; - animation-duration: 300ms; - animation-fill-mode: both; - } - - .in { - animation-name: popin; - } - - .out { - animation-name: popout; - } - - .in.reverse { - animation-name: popin; - } - - .out.reverse { - animation-name: popout; - } - - @keyframes popin { - from { - transform: scale(.3); - opacity: 0; - } - to { - transform: scale(1); - opacity: 1; - } - } - - @keyframes popout { - from { - transform: scale(1); - opacity: 1; - } - to { - transform: scale(.3); - opacity: 0; - } - } + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: popin; + } + + .out { + animation-name: popout; + } + + .in.reverse { + animation-name: popin; + } + + .out.reverse { + animation-name: popout; + } + + @keyframes popin { + from { + transform: scale(.3); + opacity: 0; + } + to { + transform: scale(1); + opacity: 1; + } + } + + @keyframes popout { + from { + transform: scale(1); + opacity: 1; + } + to { + transform: scale(.3); + opacity: 0; + } + } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css index 34870a237..f6fae4b09 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide-up.css @@ -1,95 +1,95 @@ -@if user.agent safari { -.in, .out { - -webkit-animation-timing-function: ease-in-out; - -webkit-animation-duration: 300ms; - -webkit-animation-fill-mode: both; -} - -.in { - -webkit-animation-name: slideupfrombottom; - z-index: 10; -} - -.out { - -webkit-animation-name: slideupfrommiddle; - z-index: 0; -} - -.out.reverse { - z-index: 10; - -webkit-animation-name: slidedownfrommiddle; -} - -.in.reverse { - z-index: 0; - -webkit-animation-name: slidedownfromtop; -} - -@-webkit-keyframes slideupfrombottom { - from { -webkit-transform: translateY(100%); } - to { -webkit-transform: translateY(0); } -} - -@-webkit-keyframes slidedownfrommiddle { - from { -webkit-transform: translateY(0); } - to { -webkit-transform: translateY(100%); } -} - -@-webkit-keyframes slideupfrommiddle { - from { -webkit-transform: translateY(0); } - to { -webkit-transform: translateY(-100%); } -} - -@-webkit-keyframes slidedownfromtop { - from { -webkit-transform: translateY(-100%); } - to { -webkit-transform: translateY(0%); } -} +@if !user.agent ie10 { + .in, .out { + -webkit-animation-timing-function: ease-in-out; + -webkit-animation-duration: 300ms; + -webkit-animation-fill-mode: both; + } + + .in { + -webkit-animation-name: slideupfrombottom; + z-index: 10; + } + + .out { + -webkit-animation-name: slideupfrommiddle; + z-index: 0; + } + + .out.reverse { + z-index: 10; + -webkit-animation-name: slidedownfrommiddle; + } + + .in.reverse { + z-index: 0; + -webkit-animation-name: slidedownfromtop; + } + + @-webkit-keyframes slideupfrombottom { + from { -webkit-transform: translateY(100%); } + to { -webkit-transform: translateY(0); } + } + + @-webkit-keyframes slidedownfrommiddle { + from { -webkit-transform: translateY(0); } + to { -webkit-transform: translateY(100%); } + } + + @-webkit-keyframes slideupfrommiddle { + from { -webkit-transform: translateY(0); } + to { -webkit-transform: translateY(-100%); } + } + + @-webkit-keyframes slidedownfromtop { + from { -webkit-transform: translateY(-100%); } + to { -webkit-transform: translateY(0%); } + } } @if user.agent ie10 { - .in, .out { - animation-timing-function: ease-in-out; - animation-duration: 300ms; - animation-fill-mode: both; - } - - .in { - animation-name: slideupfrombottom; - z-index: 10; - } - - .out { - animation-name: slideupfrommiddle; - z-index: 0; - } - - .out.reverse { - z-index: 10; - animation-name: slidedownfrommiddle; - } - - .in.reverse { - z-index: 0; - animation-name: slidedownfromtop; - } - - @keyframes slideupfrombottom { - from { transform: translateY(100%); } - to { transform: translateY(0); } - } - - @keyframes slidedownfrommiddle { - from { transform: translateY(0); } - to { transform: translateY(100%); } - } - - @keyframes slideupfrommiddle { - from { transform: translateY(0); } - to { transform: translateY(-100%); } - } - - @keyframes slidedownfromtop { - from { transform: translateY(-100%); } - to { transform: translateY(0%); } - } + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + animation-name: slideupfrombottom; + z-index: 10; + } + + .out { + animation-name: slideupfrommiddle; + z-index: 0; + } + + .out.reverse { + z-index: 10; + animation-name: slidedownfrommiddle; + } + + .in.reverse { + z-index: 0; + animation-name: slidedownfromtop; + } + + @keyframes slideupfrombottom { + from { transform: translateY(100%); } + to { transform: translateY(0); } + } + + @keyframes slidedownfrommiddle { + from { transform: translateY(0); } + to { transform: translateY(100%); } + } + + @keyframes slideupfrommiddle { + from { transform: translateY(0); } + to { transform: translateY(-100%); } + } + + @keyframes slidedownfromtop { + from { transform: translateY(-100%); } + to { transform: translateY(0%); } + } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css index ef0b389a9..9e3a208bb 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/slide.css @@ -1,103 +1,103 @@ -@if user.agent safari { -.in, .out { - -webkit-animation-timing-function: ease-in-out; - -webkit-animation-duration: 300ms; - -webkit-animation-fill-mode: both; -} - -.in { - z-index:10; -} - -.out{ - z-index: 0 !important; -} - -.in { - -webkit-animation-name: slideinfromright; -} - -.out { - -webkit-animation-name: slideouttoleft; -} - -.in.reverse { - -webkit-animation-name: slideinfromleft; -} - -.out.reverse { - -webkit-animation-name: slideouttoright; -} - -@-webkit-keyframes slideinfromright { - from { -webkit-transform: translateX(100%); } - to { -webkit-transform: translateX(0); } -} - -@-webkit-keyframes slideinfromleft { - from { -webkit-transform: translateX(-100%); } - to { -webkit-transform: translateX(0); } -} - -@-webkit-keyframes slideouttoleft { - from { -webkit-transform: translateX(0); } - to { -webkit-transform: translateX(-100%); } -} - -@-webkit-keyframes slideouttoright { - from { -webkit-transform: translateX(0); } - to { -webkit-transform: translateX(100%); } -} +@if !user.agent ie10 { + .in, .out { + -webkit-animation-timing-function: ease-in-out; + -webkit-animation-duration: 300ms; + -webkit-animation-fill-mode: both; + } + + .in { + z-index:10; + } + + .out{ + z-index: 0 !important; + } + + .in { + -webkit-animation-name: slideinfromright; + } + + .out { + -webkit-animation-name: slideouttoleft; + } + + .in.reverse { + -webkit-animation-name: slideinfromleft; + } + + .out.reverse { + -webkit-animation-name: slideouttoright; + } + + @-webkit-keyframes slideinfromright { + from { -webkit-transform: translateX(100%); } + to { -webkit-transform: translateX(0); } + } + + @-webkit-keyframes slideinfromleft { + from { -webkit-transform: translateX(-100%); } + to { -webkit-transform: translateX(0); } + } + + @-webkit-keyframes slideouttoleft { + from { -webkit-transform: translateX(0); } + to { -webkit-transform: translateX(-100%); } + } + + @-webkit-keyframes slideouttoright { + from { -webkit-transform: translateX(0); } + to { -webkit-transform: translateX(100%); } + } } @if user.agent ie10 { - .in, .out { - animation-timing-function: ease-in-out; - animation-duration: 300ms; - animation-fill-mode: both; - } - - .in { - z-index:10; - } - - .out{ - z-index: 0 !important; - } - - .in { - animation-name: slideinfromright; - } - - .out { - animation-name: slideouttoleft; - } - - .in.reverse { - animation-name: slideinfromleft; - } - - .out.reverse { - animation-name: slideouttoright; - } - - @keyframes slideinfromright { - from { transform: translateX(100%); } - to { transform: translateX(0); } - } - - @keyframes slideinfromleft { - from { transform: translateX(-100%); } - to { transform: translateX(0); } - } - - @keyframes slideouttoleft { - from { transform: translateX(0); } - to { transform: translateX(-100%); } - } - - @keyframes slideouttoright { - from { transform: translateX(0); } - to { transform: translateX(100%); } - } + .in, .out { + animation-timing-function: ease-in-out; + animation-duration: 300ms; + animation-fill-mode: both; + } + + .in { + z-index:10; + } + + .out{ + z-index: 0 !important; + } + + .in { + animation-name: slideinfromright; + } + + .out { + animation-name: slideouttoleft; + } + + .in.reverse { + animation-name: slideinfromleft; + } + + .out.reverse { + animation-name: slideouttoright; + } + + @keyframes slideinfromright { + from { transform: translateX(100%); } + to { transform: translateX(0); } + } + + @keyframes slideinfromleft { + from { transform: translateX(-100%); } + to { transform: translateX(0); } + } + + @keyframes slideouttoleft { + from { transform: translateX(0); } + to { transform: translateX(-100%); } + } + + @keyframes slideouttoright { + from { transform: translateX(0); } + to { transform: translateX(100%); } + } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css index b06722ddd..12f6b2642 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/animation/bundle/swap.css @@ -1,166 +1,166 @@ -@if user.agent safari { -.in, .out { - -webkit-animation-timing-function: ease-in-out; - -webkit-animation-fill-mode: both; - -webkit-transform: perspective(800); - -webkit-animation-duration: .7s; - -webkit-transform-style: preserve-3d; -} - -.out { - -webkit-animation-name: swapouttoleft; -} -.in { - -webkit-animation-name: swapinfromright; -} -.out.reverse { - -webkit-animation-name: swapouttoright; -} -.in.reverse { - -webkit-animation-name: swapinfromleft; -} - - -@-webkit-keyframes swapouttoright { - 0% { - -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); +@if !user.agent ie10 { + .in, .out { -webkit-animation-timing-function: ease-in-out; + -webkit-animation-fill-mode: both; + -webkit-transform: perspective(800); + -webkit-animation-duration: .7s; + -webkit-transform-style: preserve-3d; + } + + .out { + -webkit-animation-name: swapouttoleft; + } + .in { + -webkit-animation-name: swapinfromright; + } + .out.reverse { + -webkit-animation-name: swapouttoright; } - 50% { - -webkit-transform: translate3d(-180px, 0px, -400px) rotateY(20deg); - -webkit-animation-timing-function: ease-in; - opacity: 0.8; + .in.reverse { + -webkit-animation-name: swapinfromleft; } - 100% { - -webkit-transform: translate3d(0px, 0px, -800px) rotateY(70deg); + + + @-webkit-keyframes swapouttoright { + 0% { + -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); + -webkit-animation-timing-function: ease-in-out; + } + 50% { + -webkit-transform: translate3d(-180px, 0px, -400px) rotateY(20deg); + -webkit-animation-timing-function: ease-in; + opacity: 0.8; + } + 100% { + -webkit-transform: translate3d(0px, 0px, -800px) rotateY(70deg); + opacity: 0; + } + } + + @-webkit-keyframes swapouttoleft { + 0% { + -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); + -webkit-animation-timing-function: ease-in-out; + } + 50% { + -webkit-transform: translate3d(180px, 0px, -400px) rotateY(-20deg); + -webkit-animation-timing-function: ease-in; + opacity: 0.8; + } + 100% { + -webkit-transform: translate3d(0px, 0px, -800px) rotateY(-70deg); opacity: 0; + } + } + + @-webkit-keyframes swapinfromright { + 0% { + -webkit-transform: translate3d(0px, 0px, -800px) rotateY(70deg); + -webkit-animation-timing-function: ease-out; + } + 50% { + -webkit-transform: translate3d(-180px, 0px, -400px) rotateY(20deg); + -webkit-animation-timing-function: ease-in-out; + } + 100% { + -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); + } + } + + @-webkit-keyframes swapinfromleft { + 0% { + -webkit-transform: translate3d(0px, 0px, -800px) rotateY(-70deg); + -webkit-animation-timing-function: ease-out; + } + 50% { + -webkit-transform: translate3d(180px, 0px, -400px) rotateY(-20deg); + -webkit-animation-timing-function: ease-in-out; + } + 100% { + -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); + } } } -@-webkit-keyframes swapouttoleft { - 0% { - -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); - -webkit-animation-timing-function: ease-in-out; +@if user.agent ie10 { + .in, .out { + animation-timing-function: ease-in-out; + animation-fill-mode: both; + transform: perspective(800); + animation-duration: .7s; } - 50% { - -webkit-transform: translate3d(180px, 0px, -400px) rotateY(-20deg); - -webkit-animation-timing-function: ease-in; - opacity: 0.8; + + .out { + animation-name: swapouttoleft; } - 100% { - -webkit-transform: translate3d(0px, 0px, -800px) rotateY(-70deg); - opacity: 0; + .in { + animation-name: swapinfromright; } -} - -@-webkit-keyframes swapinfromright { - 0% { - -webkit-transform: translate3d(0px, 0px, -800px) rotateY(70deg); - -webkit-animation-timing-function: ease-out; + .out.reverse { + animation-name: swapouttoright; } - 50% { - -webkit-transform: translate3d(-180px, 0px, -400px) rotateY(20deg); - -webkit-animation-timing-function: ease-in-out; + .in.reverse { + animation-name: swapinfromleft; } - 100% { - -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); + + + @keyframes swapouttoright { + 0% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + animation-timing-function: ease-in-out; + } + 50% { + transform: translate3d(-180px, 0px, -400px) rotateY(20deg); + animation-timing-function: ease-in; + opacity: 0.8; + } + 100% { + transform: translate3d(0px, 0px, -800px) rotateY(70deg); + opacity: 0; + } } -} - -@-webkit-keyframes swapinfromleft { - 0% { - -webkit-transform: translate3d(0px, 0px, -800px) rotateY(-70deg); - -webkit-animation-timing-function: ease-out; + + @keyframes swapouttoleft { + 0% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + animation-timing-function: ease-in-out; + } + 50% { + transform: translate3d(180px, 0px, -400px) rotateY(-20deg); + animation-timing-function: ease-in; + opacity: 0.8; + } + 100% { + transform: translate3d(0px, 0px, -800px) rotateY(-70deg); + opacity: 0; + } } - 50% { - -webkit-transform: translate3d(180px, 0px, -400px) rotateY(-20deg); - -webkit-animation-timing-function: ease-in-out; + + @keyframes swapinfromright { + 0% { + transform: translate3d(0px, 0px, -800px) rotateY(70deg); + animation-timing-function: ease-out; + } + 50% { + transform: translate3d(-180px, 0px, -400px) rotateY(20deg); + animation-timing-function: ease-in-out; + } + 100% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + } } - 100% { - -webkit-transform: translate3d(0px, 0px, 0px) rotateY(0deg); + + @keyframes swapinfromleft { + 0% { + transform: translate3d(0px, 0px, -800px) rotateY(-70deg); + animation-timing-function: ease-out; + } + 50% { + transform: translate3d(180px, 0px, -400px) rotateY(-20deg); + animation-timing-function: ease-in-out; + } + 100% { + transform: translate3d(0px, 0px, 0px) rotateY(0deg); + } } -} -} - -@if user.agent ie10 { - .in, .out { - animation-timing-function: ease-in-out; - animation-fill-mode: both; - transform: perspective(800); - animation-duration: .7s; - } - - .out { - animation-name: swapouttoleft; - } - .in { - animation-name: swapinfromright; - } - .out.reverse { - animation-name: swapouttoright; - } - .in.reverse { - animation-name: swapinfromleft; - } - - - @keyframes swapouttoright { - 0% { - transform: translate3d(0px, 0px, 0px) rotateY(0deg); - animation-timing-function: ease-in-out; - } - 50% { - transform: translate3d(-180px, 0px, -400px) rotateY(20deg); - animation-timing-function: ease-in; - opacity: 0.8; - } - 100% { - transform: translate3d(0px, 0px, -800px) rotateY(70deg); - opacity: 0; - } - } - - @keyframes swapouttoleft { - 0% { - transform: translate3d(0px, 0px, 0px) rotateY(0deg); - animation-timing-function: ease-in-out; - } - 50% { - transform: translate3d(180px, 0px, -400px) rotateY(-20deg); - animation-timing-function: ease-in; - opacity: 0.8; - } - 100% { - transform: translate3d(0px, 0px, -800px) rotateY(-70deg); - opacity: 0; - } - } - - @keyframes swapinfromright { - 0% { - transform: translate3d(0px, 0px, -800px) rotateY(70deg); - animation-timing-function: ease-out; - } - 50% { - transform: translate3d(-180px, 0px, -400px) rotateY(20deg); - animation-timing-function: ease-in-out; - } - 100% { - transform: translate3d(0px, 0px, 0px) rotateY(0deg); - } - } - - @keyframes swapinfromleft { - 0% { - transform: translate3d(0px, 0px, -800px) rotateY(-70deg); - animation-timing-function: ease-out; - } - 50% { - transform: translate3d(180px, 0px, -400px) rotateY(-20deg); - animation-timing-function: ease-in-out; - } - 100% { - transform: translate3d(0px, 0px, 0px) rotateY(0deg); - } - } } \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java index 9905dad22..9e1fe8e90 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java @@ -64,12 +64,11 @@ public boolean isActive() { } @Override - protected void setElement(Element elem) - { + protected void setElement(Element elem) { super.setElement(elem); - if (!defaultHandlersAdded) - { + if (!defaultHandlersAdded) { + addTouchHandler(new TouchHandler() { @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css index b087d34ba..f87aeb988 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/imagebutton.css @@ -15,6 +15,12 @@ } } +@if user.agent gecko1_8 { + .mgwt-ImageButton { + display: -moz-box; + } +} + @if user.agent ie10 { .mgwt-ImageButton { display: -ms-flexbox; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java index 0a27520fe..af7e09fa3 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperIE10.java @@ -1,3 +1,16 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.mgwt.ui.client.widget.panel.flex; import com.google.gwt.dom.client.Element; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java index b55116f17..e9d987a89 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperMoz.java @@ -1,3 +1,16 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.mgwt.ui.client.widget.panel.flex; import com.google.gwt.dom.client.Element; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java index 02c502e32..035c5fa6d 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperStandard.java @@ -1,3 +1,16 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.mgwt.ui.client.widget.panel.flex; import com.google.gwt.dom.client.Element; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java index 39cd292d4..76da0f65f 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelperWebkit.java @@ -1,3 +1,16 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.mgwt.ui.client.widget.panel.flex; import com.google.gwt.dom.client.Element; @@ -181,7 +194,7 @@ protected void _setFlexWrapProperty(Element el, FlexWrap flexWrap) @Override public void _setFlex(Element el, double grow, String basis) { setStyleProperty(el,"WebkitBoxFlex", Double.toString(grow)); - setStyleProperty(el,"WebkitFlex", Double.toString(grow)+(basis == null ? "0%" : basis)); + setStyleProperty(el,"WebkitFlex", Double.toString(grow)+" "+(basis == null ? "0%" : basis)); } @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java index 115da214a..68c154553 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java @@ -24,9 +24,12 @@ import com.google.gwt.event.dom.client.TouchEvent; import com.google.gwt.event.dom.client.TouchMoveEvent; import com.google.gwt.event.dom.client.TouchStartEvent; +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; @@ -35,7 +38,6 @@ import com.googlecode.mgwt.collection.shared.LightArrayInt; import com.googlecode.mgwt.dom.client.event.animation.TransitionEndEvent; import com.googlecode.mgwt.dom.client.event.animation.TransitionEndHandler; -import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent; import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent; import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent; import com.googlecode.mgwt.dom.client.event.mouse.TouchStartToMouseDownHandler; @@ -1762,16 +1764,30 @@ private void unbindMoveEvent() { * */ private void bindResizeEvent() { - orientationChangeRegistration = MGWT.addOrientationChangeHandler(new OrientationChangeHandler() { + if (!MGWT.getFormFactor().isDesktop()) { + orientationChangeRegistration = MGWT.addOrientationChangeHandler(new OrientationChangeHandler() { + + @Override + public void onOrientationChanged(OrientationChangeEvent event) { + if (shouldHandleResize) { + resize(); + } - @Override - public void onOrientationChanged(OrientationChangeEvent event) { - if (shouldHandleResize) { - resize(); } - } - - }); + }); + } else { + orientationChangeRegistration = Window.addResizeHandler(new ResizeHandler() { + + @Override + public void onResize(ResizeEvent event) { + if (shouldHandleResize) { + resize(); + } + + } + }); + } + } private void unbindResizeEvent() { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java index 2f5ecb767..caca84519 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java @@ -1,3 +1,16 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.mgwt.ui.client.widget.touch; import com.google.gwt.event.dom.client.TouchCancelHandler; @@ -26,12 +39,7 @@ public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler hand @Override public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { - TouchMoveToMsPointerMoveHandler touchMoveToMsPointerMoveHandler = new TouchMoveToMsPointerMoveHandler(handler); - HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); - handlerRegistrationCollection.addHandlerRegistration(w.addBitlessDomHandler(touchMoveToMsPointerMoveHandler, MsPointerDownEvent.getType())); - handlerRegistrationCollection.addHandlerRegistration(w.addBitlessDomHandler(touchMoveToMsPointerMoveHandler, MsPointerUpEvent.getType())); - handlerRegistrationCollection.addHandlerRegistration(w.addBitlessDomHandler(touchMoveToMsPointerMoveHandler, MsPointerMoveEvent.getType())); - return handlerRegistrationCollection; + return w.addBitlessDomHandler(new TouchMoveToMsPointerMoveHandler(handler), MsPointerMoveEvent.getType()); } @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java index 0a5988bc1..8ad849b1b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java @@ -1,3 +1,16 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.mgwt.ui.client.widget.touch; import com.google.gwt.event.dom.client.MouseDownEvent; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java index 23b10a387..5fe946287 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java @@ -1,3 +1,16 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.googlecode.mgwt.ui.client.widget.touch; import com.google.gwt.event.dom.client.TouchCancelEvent; diff --git a/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java b/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java index 66f2f7819..652548f87 100644 --- a/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java +++ b/src/test/java/com/googlecode/mgwt/image/client/ImageConverterGwtTestCase.java @@ -21,6 +21,7 @@ import com.google.gwt.junit.client.GWTTestCase; import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.ImageResource; +import com.googlecode.mgwt.image.client.ImageConverter.ImageConverterCallback; public class ImageConverterGwtTestCase extends GWTTestCase { @@ -46,11 +47,6 @@ public void testConvert_withKnownImage() { { public ImageResource convertedResource = null; - @Override - public void onFailure(Throwable caught) - { - } - @Override public void onSuccess(ImageResource convertedResource) { From e6e3ac5a7fc67307a9cef768ae77c91245e51a7c Mon Sep 17 00:00:00 2001 From: Paul French Date: Thu, 16 Jul 2015 14:04:32 +0100 Subject: [PATCH 32/53] Fix animated dialogue issue where you get 'Animation is already running' exception when show and then hide a dialogue quickly --- .../widget/dialog/overlay/DialogOverlay.java | 121 ++++++++++++------ 1 file changed, 81 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/overlay/DialogOverlay.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/overlay/DialogOverlay.java index 21d44701b..72c94fef2 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/overlay/DialogOverlay.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/dialog/overlay/DialogOverlay.java @@ -13,6 +13,10 @@ */ package com.googlecode.mgwt.ui.client.widget.dialog.overlay; +import java.util.Iterator; + +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.shared.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.EventTarget; @@ -30,7 +34,6 @@ import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; - import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; import com.googlecode.mgwt.dom.client.event.tap.TapHandler; @@ -46,8 +49,6 @@ import com.googlecode.mgwt.ui.client.widget.panel.flex.RootFlexPanel; import com.googlecode.mgwt.ui.client.widget.touch.TouchDelegate; -import java.util.Iterator; - /** * Baseclass for creating dialogs that are animated * @@ -55,12 +56,42 @@ */ public abstract class DialogOverlay implements HasWidgets, HasTouchHandlers, HasTapHandlers, Dialog { - - private static class NoopAnimationEndCallback implements AnimationEndCallback { + + private class HideAnimationEndCallback implements AnimationEndCallback { public void onAnimationEnd() { + HasWidgets panel = getPanelToOverlay(); + panel.remove(display.asWidget()); + // see issue 247 => http://code.google.com/p/mgwt/issues/detail?id=247 + MGWTUtil.forceFullRepaint(); + + transitionState = TransitionState.NOTVISIBLE; + if (requestShow) { + requestShow = false; + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override + public void execute() { + show(); + } + }); + } } } + private class ShowAnimationEndCallback implements AnimationEndCallback { + public void onAnimationEnd() { + transitionState = TransitionState.VISIBLE; + if (requestHide) { + requestHide = false; + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override + public void execute() { + hide(); + } + }); + } + } + } + private class InternalTouchHandler implements TouchHandler { private final Element shadow; private Element startTarget; @@ -111,7 +142,8 @@ public void onTouchStart(TouchStartEvent event) { } } - private static final NoopAnimationEndCallback NOOP_CALLBACK = new NoopAnimationEndCallback(); + private final AnimationEndCallback SHOW_ANIMATION_CALLBACK = new ShowAnimationEndCallback(); + private final AnimationEndCallback HIDE_ANIMATION_CALLBACK = new HideAnimationEndCallback(); public static final DialogOverlayAppearance DEFAULT_APPEARANCE = GWT .create(DialogOverlayAppearance.class); @@ -124,9 +156,13 @@ public void onTouchStart(TouchStartEvent event) { private boolean centerChildren; private boolean autoHide; - private boolean isVisible; private TouchDelegate touchDelegateForDisplay; - + private enum TransitionState { + HIDING, SHOWING, VISIBLE, NOTVISIBLE; + } + private TransitionState transitionState = TransitionState.NOTVISIBLE; + private boolean requestHide = false; + private boolean requestShow = false; public DialogOverlay() { this(DEFAULT_APPEARANCE); @@ -215,21 +251,19 @@ public HasWidgets getPanelToOverlay() { * hide the dialog if it is visible */ public void hide() { - if (!isVisible) - return; - isVisible = false; - Animation animation = getHideAnimation(); - - display.animate(animation, false, new AnimationEndCallback() { - - @Override - public void onAnimationEnd() { - HasWidgets panel = getPanelToOverlay(); - panel.remove(display.asWidget()); - // see issue 247 => http://code.google.com/p/mgwt/issues/detail?id=247 - MGWTUtil.forceFullRepaint(); - } - }); + if (transitionState == TransitionState.SHOWING) { + // not finished showing yet so request to hide once show complete + requestHide = true; + } + else if (transitionState == TransitionState.VISIBLE) { + requestHide = false; + transitionState = TransitionState.HIDING; + display.animate(getHideAnimation(), false, HIDE_ANIMATION_CALLBACK); + } + else if (transitionState == TransitionState.HIDING) { + // not finished hiding yet so remove requestShow if set + requestShow = false; + } } /** @@ -292,27 +326,34 @@ public void setShadow(boolean shadow) { } public void show() { - if (isVisible) { - return; + if (transitionState == TransitionState.HIDING) { + // not finished hiding yet so request to show once hide complete + requestShow = true; } - isVisible = true; + else if (transitionState == TransitionState.NOTVISIBLE) { + requestShow = false; + transitionState = TransitionState.SHOWING; + // add overlay to DOM + HasWidgets panel = getPanelToOverlay(); + panel.add(display.asWidget()); + + if (centerChildren) { + container.setAlignment(Alignment.CENTER); + container.setJustification(Justification.CENTER); + } else { + container.clearAlignment(); + container.clearJustification(); + } - // add overlay to DOM - HasWidgets panel = getPanelToOverlay(); - panel.add(display.asWidget()); + display.setFirstWidget(container); - if (centerChildren) { - container.setAlignment(Alignment.CENTER); - container.setJustification(Justification.CENTER); - } else { - container.clearAlignment(); - container.clearJustification(); + // and animiate + display.animate(getShowAnimation(), true, SHOW_ANIMATION_CALLBACK); + } + else if (transitionState == TransitionState.SHOWING) { + // not finished showing yet so remove requestHide if set + requestHide = false; } - - display.setFirstWidget(container); - - // and animiate - display.animate(getShowAnimation(), true, NOOP_CALLBACK); } protected abstract Animation getShowAnimation(); From 6bff1e731f7ecd3f22ba18cec302386dae3c61c9 Mon Sep 17 00:00:00 2001 From: Paul French Date: Mon, 27 Jul 2015 12:59:17 +0100 Subject: [PATCH 33/53] Bug in translatePercent, you cannot specify 0% for the z translate3d value, you must specify 0. Bug in TapRecognizer, do not store Touch events since they can be re-used --- .../googlecode/mgwt/dom/client/recognizer/TapRecognizer.java | 5 ++--- .../googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java index 5d4a10710..6599fda5c 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java @@ -44,8 +44,6 @@ public class TapRecognizer implements TouchHandler { private boolean hasMoved; - private Touch touch; - private int start_x; private int start_y; @@ -80,7 +78,7 @@ public void onTouchStart(TouchStartEvent event) { }else { targetElement = null; } - touch = event.getTouches().get(0); + Touch touch = event.getTouches().get(0); start_x = touch.getPageX(); start_y = touch.getPageY(); } @@ -96,6 +94,7 @@ public void onTouchMove(TouchMoveEvent event) { @Override public void onTouchEnd(TouchEndEvent event) { if (!hasMoved && !touchCanceled) { + Touch touch = event.getChangedTouches().get(0); TapEvent tapEvent = new TapEvent(source, targetElement, touch); getEventPropagator().fireEvent(source, tapEvent); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java index 3aafd5038..5ffae8da6 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java @@ -123,7 +123,7 @@ public void setTranslateAndZoom(Element el, int x, int y, double scale) { @Override public void translatePercent(Element el, double x, double y) { - String cssText = "translate3d(" + x + "%, " + y + "%,0%)"; + String cssText = "translate3d(" + x + "%, " + y + "%,0)"; _translate(el, cssText); } From d3ab64796411ad168bcd135e809a30dbbd74ff70 Mon Sep 17 00:00:00 2001 From: Paul French Date: Mon, 27 Jul 2015 14:10:10 +0100 Subject: [PATCH 34/53] minor code formatting issue --- .../googlecode/mgwt/dom/client/recognizer/TapRecognizer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java index 6599fda5c..595abab28 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java @@ -94,7 +94,7 @@ public void onTouchMove(TouchMoveEvent event) { @Override public void onTouchEnd(TouchEndEvent event) { if (!hasMoved && !touchCanceled) { - Touch touch = event.getChangedTouches().get(0); + Touch touch = event.getChangedTouches().get(0); TapEvent tapEvent = new TapEvent(source, targetElement, touch); getEventPropagator().fireEvent(source, tapEvent); } From 3ba3ca5cdf5f83826d80ebdac3a72462d55c10dc Mon Sep 17 00:00:00 2001 From: Paul French Date: Mon, 27 Jul 2015 14:16:25 +0100 Subject: [PATCH 35/53] re-format again, get rid of tabs, and use 2 spaces for each tab --- .../dom/client/recognizer/TapRecognizer.java | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java index 595abab28..5fa4c69ab 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java @@ -36,90 +36,90 @@ */ public class TapRecognizer implements TouchHandler { - public static final int DEFAULT_DISTANCE = 15; + public static final int DEFAULT_DISTANCE = 15; - private final int distance; + private final int distance; - private boolean touchCanceled; + private boolean touchCanceled; - private boolean hasMoved; + private boolean hasMoved; - private int start_x; + private int start_x; - private int start_y; + private int start_y; - private Element targetElement; + private Element targetElement; - private final HasHandlers source; + private final HasHandlers source; - private EventPropagator eventPropagator; + private EventPropagator eventPropagator; - private static EventPropagator DEFAULT_EVENT_PROPAGATOR; + private static EventPropagator DEFAULT_EVENT_PROPAGATOR; - public TapRecognizer(HasHandlers source) { - this(source, DEFAULT_DISTANCE); - } + public TapRecognizer(HasHandlers source) { + this(source, DEFAULT_DISTANCE); + } - public TapRecognizer(HasHandlers source, int distance) { - if (source == null) - throw new IllegalArgumentException("source can not be null"); - if (distance < 0) - throw new IllegalArgumentException("distance has to be greater than zero"); - this.source = source; - this.distance = distance; - } + public TapRecognizer(HasHandlers source, int distance) { + if (source == null) + throw new IllegalArgumentException("source can not be null"); + if (distance < 0) + throw new IllegalArgumentException("distance has to be greater than zero"); + this.source = source; + this.distance = distance; + } - @Override - public void onTouchStart(TouchStartEvent event) { - touchCanceled = false; - hasMoved = false; - if(event.getNativeEvent() != null){ - targetElement = event.getNativeEvent().getEventTarget().cast(); - }else { - targetElement = null; - } - Touch touch = event.getTouches().get(0); - start_x = touch.getPageX(); - start_y = touch.getPageY(); - } + @Override + public void onTouchStart(TouchStartEvent event) { + touchCanceled = false; + hasMoved = false; + if(event.getNativeEvent() != null){ + targetElement = event.getNativeEvent().getEventTarget().cast(); + }else { + targetElement = null; + } + Touch touch = event.getTouches().get(0); + start_x = touch.getPageX(); + start_y = touch.getPageY(); + } - @Override - public void onTouchMove(TouchMoveEvent event) { - Touch touch = event.getTouches().get(0); - if (Math.abs(touch.getPageX() - start_x) > distance || Math.abs(touch.getPageY() - start_y) > distance) { - hasMoved = true; - } - } + @Override + public void onTouchMove(TouchMoveEvent event) { + Touch touch = event.getTouches().get(0); + if (Math.abs(touch.getPageX() - start_x) > distance || Math.abs(touch.getPageY() - start_y) > distance) { + hasMoved = true; + } + } - @Override - public void onTouchEnd(TouchEndEvent event) { - if (!hasMoved && !touchCanceled) { + @Override + public void onTouchEnd(TouchEndEvent event) { + if (!hasMoved && !touchCanceled) { Touch touch = event.getChangedTouches().get(0); - TapEvent tapEvent = new TapEvent(source, targetElement, touch); - getEventPropagator().fireEvent(source, tapEvent); - } - } + TapEvent tapEvent = new TapEvent(source, targetElement, touch); + getEventPropagator().fireEvent(source, tapEvent); + } + } @Override public void onTouchCancel(TouchCancelEvent event) { touchCanceled = true; } - public int getDistance() { - return distance; - } - - protected EventPropagator getEventPropagator() { - if (eventPropagator == null) { - if (DEFAULT_EVENT_PROPAGATOR == null) { - DEFAULT_EVENT_PROPAGATOR = GWT.create(EventPropagator.class); - } - eventPropagator = DEFAULT_EVENT_PROPAGATOR; - } - return eventPropagator; - } - - public Element getTargetElement() { - return targetElement; - } + public int getDistance() { + return distance; + } + + protected EventPropagator getEventPropagator() { + if (eventPropagator == null) { + if (DEFAULT_EVENT_PROPAGATOR == null) { + DEFAULT_EVENT_PROPAGATOR = GWT.create(EventPropagator.class); + } + eventPropagator = DEFAULT_EVENT_PROPAGATOR; + } + return eventPropagator; + } + + public Element getTargetElement() { + return targetElement; + } } From cb8048c11cd718fc5b416bdd091a4dd835d9ef60 Mon Sep 17 00:00:00 2001 From: Paul French Date: Fri, 14 Aug 2015 17:14:33 +0100 Subject: [PATCH 36/53] Minor changes so TapRecognizer tests do not fail. Basically use the TouchStart event and not the TouchEnd event for the properties of the TapEvent --- .../mgwt/dom/client/event/tap/TapEvent.java | 5 ++--- .../mgwt/dom/client/recognizer/TapRecognizer.java | 13 +++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java index f9c1fea1e..4343da231 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java @@ -16,7 +16,6 @@ package com.googlecode.mgwt.dom.client.event.tap; import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.Touch; import com.google.gwt.event.shared.GwtEvent; import com.googlecode.mgwt.dom.client.event.touch.TouchCopy; @@ -33,9 +32,9 @@ public class TapEvent extends GwtEvent { private final TouchCopy touchCopy; private final Element targetElement; - public TapEvent(Object source, Element targetElement, Touch touch) { + public TapEvent(Object source, Element targetElement, TouchCopy touchCopy) { this.targetElement = targetElement; - this.touchCopy = TouchCopy.copy(touch); + this.touchCopy = touchCopy; setSource(source); } diff --git a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java index 5fa4c69ab..0034ead78 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java @@ -25,6 +25,7 @@ import com.google.gwt.event.shared.HasHandlers; import com.googlecode.mgwt.dom.client.event.tap.TapEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchCopy; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; /** @@ -44,9 +45,7 @@ public class TapRecognizer implements TouchHandler { private boolean hasMoved; - private int start_x; - - private int start_y; + private TouchCopy touchStartCopy; private Element targetElement; @@ -79,14 +78,13 @@ public void onTouchStart(TouchStartEvent event) { targetElement = null; } Touch touch = event.getTouches().get(0); - start_x = touch.getPageX(); - start_y = touch.getPageY(); + touchStartCopy = TouchCopy.copy(touch); } @Override public void onTouchMove(TouchMoveEvent event) { Touch touch = event.getTouches().get(0); - if (Math.abs(touch.getPageX() - start_x) > distance || Math.abs(touch.getPageY() - start_y) > distance) { + if (Math.abs(touch.getPageX() - touchStartCopy.getPageX()) > distance || Math.abs(touch.getPageY() - touchStartCopy.getPageY()) > distance) { hasMoved = true; } } @@ -94,8 +92,7 @@ public void onTouchMove(TouchMoveEvent event) { @Override public void onTouchEnd(TouchEndEvent event) { if (!hasMoved && !touchCanceled) { - Touch touch = event.getChangedTouches().get(0); - TapEvent tapEvent = new TapEvent(source, targetElement, touch); + TapEvent tapEvent = new TapEvent(source, targetElement, touchStartCopy); getEventPropagator().fireEvent(source, tapEvent); } } From 94bf0a0cdeb5827d7755f4f37100f66ac80bdb05 Mon Sep 17 00:00:00 2001 From: Paul French Date: Thu, 27 Aug 2015 14:53:15 +0100 Subject: [PATCH 37/53] OSDetection.isDesktop() did not take into account Windows Phone 8/8.1 --- .../com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java index 5e64c7853..54460f520 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java @@ -50,7 +50,7 @@ public boolean isIPadRetina() { @Override public boolean isDesktop() { - return !isIOs() && !isAndroid(); + return !isIOs() && !isAndroid() && !isWindowsPhone(); } @Override From 9bd9b5c2e23e07ff67e62e7c6fd22a204c0da5d9 Mon Sep 17 00:00:00 2001 From: paulf_000 Date: Mon, 7 Sep 2015 18:49:49 +0100 Subject: [PATCH 38/53] Added support for IE11 (using the unprefixed pointer event model) so no need to specify the meta tag IE10 compatible in the html host page. Other minor changes required so mgwt works in ie11 moble/desktop. Code made ready so can add IE Edge support shortly. GWT UserAgent generation has been overridden in MGWT to support the additional user agent strings we need to check for. OS Detection updated to take into account ie11 user agent strings. OS Detection tests updated as well. IE Desktop bugs fixed for Slider and CheckBox widgets. TapRecognizer bug when in desktop has been fixed. Strange IE11 bug in Carousel widget where onScrollRefresh called twice in quick succession causing a null pointer. touch-action added to css everywhere where -ms-touch-action specified. --- .../gwt/user/client/impl/DOMImplIE10.java | 57 ++++++--- .../java/com/googlecode/mgwt/MGWTMin.gwt.xml | 1 + .../java/com/googlecode/mgwt/dom/DOM.gwt.xml | 7 +- .../client/event/pointer/MsPointerEvent.java | 35 +++++- .../dom/client/recognizer/TapRecognizer.java | 12 +- .../com/googlecode/mgwt/ui/client/MGWT.java | 2 +- .../ui/client/OsDetectionRuntimeImpl.java | 8 +- .../ui/client/widget/carousel/Carousel.java | 21 ++-- .../mgwt/ui/client/widget/header/header.css | 1 + .../widget/input/checkbox/MCheckBox.java | 8 +- .../mgwt/ui/client/widget/input/input.css | 1 + .../ui/client/widget/input/slider/Slider.java | 16 ++- .../mgwt/useragent/UserAgent.gwt.xml | 27 ++++ .../rebind/UserAgentAsserterGenerator.java | 54 ++++++++ .../useragent/rebind/UserAgentGenerator.java | 105 ++++++++++++++++ .../rebind/UserAgentPropertyGenerator.java | 119 ++++++++++++++++++ .../propertyprovider/test/UserAgents.java | 4 + .../ui/client/OsDetectionRuntimeImplTest.java | 103 +++++++++++++++ 18 files changed, 533 insertions(+), 48 deletions(-) create mode 100644 src/main/java/com/googlecode/mgwt/useragent/UserAgent.gwt.xml create mode 100644 src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentAsserterGenerator.java create mode 100644 src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java create mode 100644 src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentPropertyGenerator.java diff --git a/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java index 8d60a9962..65c5d5204 100644 --- a/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java +++ b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java @@ -23,8 +23,7 @@ */ public class DOMImplIE10 extends DOMImplIE9 { - static - { + static { DOMImplStandard.addCaptureEventDispatchers(getCaptureEventDispatchers()); DOMImplStandard.addBitlessEventDispatchers(getBitlessEventDispatchers()); capturePointerEvents(); @@ -39,31 +38,61 @@ public class DOMImplIE10 extends DOMImplIE9 { * the text when re-entering it and so you cannot edit your password */ private native static void capturePointerEvents() /*-{ + if ($wnd.navigator.pointerEnabled) { + $wnd.addEventListener('pointerdown', + $entry(function(evt) { + if ((evt.target.tagName !== 'INPUT') && (evt.target.tagName !== 'TEXTAREA')) { + evt.target.setPointerCapture(evt.pointerId); + } + }), true); + } + else { $wnd.addEventListener('MSPointerDown', $entry(function(evt) { if ((evt.target.tagName !== 'INPUT') && (evt.target.tagName !== 'TEXTAREA')) { evt.target.msSetPointerCapture(evt.pointerId); } }), true); + } }-*/; public static native JavaScriptObject getCaptureEventDispatchers() /*-{ - return { - MSPointerDown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), - MSPointerUp: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), - MSPointerMove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), - MSPointerCancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*) - }; + if ($wnd.navigator.pointerEnabled) { + return { + pointerdown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + pointerup: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + pointermove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + pointercancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*) + }; + } + else { + return { + MSPointerDown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + MSPointerUp: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + MSPointerMove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + MSPointerCancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*) + }; + } }-*/; public static native JavaScriptObject getBitlessEventDispatchers() /*-{ - return { - MSPointerDown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), - MSPointerUp: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), - MSPointerMove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), - MSPointerCancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*) - }; + if ($wnd.navigator.pointerEnabled) { + return { + pointerdown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + pointerup: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + pointermove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + pointercancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*) + }; + } + else { + return { + MSPointerDown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + MSPointerUp: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + MSPointerMove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + MSPointerCancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*) + }; + } }-*/; } diff --git a/src/main/java/com/googlecode/mgwt/MGWTMin.gwt.xml b/src/main/java/com/googlecode/mgwt/MGWTMin.gwt.xml index cde2a87ea..1dbfdd14c 100644 --- a/src/main/java/com/googlecode/mgwt/MGWTMin.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/MGWTMin.gwt.xml @@ -25,6 +25,7 @@ @see http://code.google.com/p/mgwt/issues/detail?id=215 --> + diff --git a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml index edfad43b1..5ab7fc375 100644 --- a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml @@ -23,8 +23,9 @@ = 0) { var value = args.substring(start); @@ -35,7 +36,7 @@ } return value.substring(begin, end); } - + } // Detect form factor from user agent. var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("windows phone 8") != -1) { diff --git a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java index c944e77de..65c2bd213 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/event/pointer/MsPointerEvent.java @@ -24,13 +24,36 @@ */ public abstract class MsPointerEvent extends MouseEvent { - public static final String MSPOINTERDOWN = "MSPointerDown"; - public static final String MSPOINTERMOVE = "MSPointerMove"; - public static final String MSPOINTEROUT = "MSPointerOut"; - public static final String MSPOINTEROVER = "MSPointerOver"; - public static final String MSPOINTERUP = "MSPointerUp"; - public static final String MSPOINTERCANCEL = "MSPointerCancel"; + private native static boolean isIE10PointerEventModel() /*-{ + return (!$wnd.navigator.pointerEnabled); + }-*/; + + public static final String MSPOINTERDOWN; + public static final String MSPOINTERMOVE; + public static final String MSPOINTEROUT; + public static final String MSPOINTEROVER; + public static final String MSPOINTERUP; + public static final String MSPOINTERCANCEL; + static { + if (isIE10PointerEventModel()) { + MSPOINTERDOWN = "MSPointerDown"; + MSPOINTERMOVE = "MSPointerMove"; + MSPOINTEROUT = "MSPointerOut"; + MSPOINTEROVER = "MSPointerOver"; + MSPOINTERUP = "MSPointerUp"; + MSPOINTERCANCEL = "MSPointerCancel"; + } + else { + MSPOINTERDOWN = "pointerdown"; + MSPOINTERMOVE = "pointermove"; + MSPOINTEROUT = "pointerout"; + MSPOINTEROVER = "pointerover"; + MSPOINTERUP = "pointerup"; + MSPOINTERCANCEL = "pointercancel"; + } + } + public final native int getPointerId() /*-{ var e = this.@com.google.gwt.event.dom.client.DomEvent::nativeEvent; return e.pointerId; diff --git a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java index 0034ead78..9b2cc02d2 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java @@ -83,18 +83,22 @@ public void onTouchStart(TouchStartEvent event) { @Override public void onTouchMove(TouchMoveEvent event) { - Touch touch = event.getTouches().get(0); - if (Math.abs(touch.getPageX() - touchStartCopy.getPageX()) > distance || Math.abs(touch.getPageY() - touchStartCopy.getPageY()) > distance) { - hasMoved = true; + if (touchStartCopy != null) { + Touch touch = event.getTouches().get(0); + if (Math.abs(touch.getPageX() - touchStartCopy.getPageX()) > distance || Math.abs(touch.getPageY() - touchStartCopy.getPageY()) > distance) { + hasMoved = true; + touchStartCopy = null; + } } } @Override public void onTouchEnd(TouchEndEvent event) { - if (!hasMoved && !touchCanceled) { + if (!hasMoved && !touchCanceled && (touchStartCopy != null)) { TapEvent tapEvent = new TapEvent(source, targetElement, touchStartCopy); getEventPropagator().fireEvent(source, tapEvent); } + touchStartCopy = null; } @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java index 8e7b57110..ae23acc35 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java @@ -341,7 +341,7 @@ private static native void setupPreventScrolling(Element el) /*-{ }-*/; private static void setupPreventScrollingIE10(Element el) { - el.setAttribute("style", "-ms-touch-action: none;"); + el.setAttribute("style", "-ms-touch-action: none; touch-action: none;"); } /** diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java index 54460f520..f66f1acb1 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java @@ -10,7 +10,7 @@ public boolean isAndroid() { @Override public boolean isIPhone() { String userAgent = getUserAgent(); - if (userAgent.contains("iphone") && getDevicePixelRatio() < 2) { + if (!isWindowsPhone() && userAgent.contains("iphone") && getDevicePixelRatio() < 2) { return true; } return false; @@ -33,7 +33,7 @@ public boolean isIOs() { @Override public boolean isRetina() { String userAgent = getUserAgent(); - if (userAgent.contains("iphone") && getDevicePixelRatio() >= 2) { + if (!isWindowsPhone() && userAgent.contains("iphone") && getDevicePixelRatio() >= 2) { return true; } return false; @@ -61,7 +61,7 @@ public boolean isTablet() { @Override public boolean isAndroidTablet() { String userAgent = getUserAgent(); - if (userAgent.contains("android") && !userAgent.contains("mobile")) { + if (!isWindowsPhone() && userAgent.contains("android") && !userAgent.contains("mobile")) { return true; } return false; @@ -70,7 +70,7 @@ public boolean isAndroidTablet() { @Override public boolean isAndroidPhone() { String userAgent = getUserAgent(); - if (userAgent.contains("android") && userAgent.contains("mobile")) { + if (!isWindowsPhone() && userAgent.contains("android") && userAgent.contains("mobile")) { return true; } return false; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java index 1c50668b3..c11ba91f6 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java @@ -308,16 +308,19 @@ public void run() { @Override public void onScrollRefresh(ScrollRefreshEvent event) { - refreshHandler.removeHandler(); - refreshHandler = null; - LightArrayInt pagesX = scrollPanel.getPagesX(); - if (currentPage < 0) { - currentPage = 0; - } else if(currentPage >= pagesX.length()) { - currentPage = pagesX.length() - 1; + // on desktop IE11 can be called twice + if (refreshHandler != null) { + refreshHandler.removeHandler(); + refreshHandler = null; + LightArrayInt pagesX = scrollPanel.getPagesX(); + if (currentPage < 0) { + currentPage = 0; + } else if(currentPage >= pagesX.length()) { + currentPage = pagesX.length() - 1; + } + scrollPanel.scrollToPage(currentPage, 0, 0); + hasScollData = true; } - scrollPanel.scrollToPage(currentPage, 0, 0); - hasScollData = true; } }); scrollPanel.refresh(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/header/header.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/header/header.css index deea02696..39fab9c3d 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/header/header.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/header/header.css @@ -8,6 +8,7 @@ .mgwt-HeaderPanel { height: 40px; + min-height: 40px; border-bottom: 1px solid rgb(45, 54, 66); background: #e5e9e8; color: #454545; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java index f24fb1bbc..c173c9f63 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java @@ -50,9 +50,11 @@ private final class TouchHandlerImplementation implements TouchHandler { private int offset; private boolean moved; private int now_x; - + private boolean active = false; + @Override public void onTouchCancel(TouchCancelEvent event) { + active = false; if (isReadOnly()) { return; } @@ -66,6 +68,7 @@ public void onTouchCancel(TouchCancelEvent event) { @Override public void onTouchEnd(TouchEndEvent event) { + active = false; if (isReadOnly()) { return; } @@ -85,7 +88,7 @@ public void onTouchEnd(TouchEndEvent event) { @Override public void onTouchMove(TouchMoveEvent event) { - if (isReadOnly()) { + if (!active || isReadOnly()) { return; } event.stopPropagation(); @@ -117,6 +120,7 @@ public void onTouchStart(TouchStartEvent event) { if (isReadOnly()) { return; } + active = true; event.stopPropagation(); event.preventDefault(); if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css index ccaf6448f..895d20627 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/input.css @@ -26,6 +26,7 @@ textarea.mgwt-InputBox-box { -ms-touch-action: pan-y; + touch-action: pan-y; } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java index ccb6ccebc..94c239d73 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java @@ -42,6 +42,8 @@ */ public class Slider extends Widget implements HasValue, LeafValueEditor { + private boolean active = false; + private class SliderTouchHandler implements TouchHandler { @Override @@ -50,16 +52,18 @@ public void onTouchStart(TouchStartEvent event) { if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.setCapture(getElement()); } + active = true; event.stopPropagation(); event.preventDefault(); - } + } @Override public void onTouchMove(TouchMoveEvent event) { - - setValueContrained(event.getTouches().get(0).getClientX()); - event.stopPropagation(); - event.preventDefault(); + if (active) { + setValueContrained(event.getTouches().get(0).getClientX()); + event.stopPropagation(); + event.preventDefault(); + } } @Override @@ -69,6 +73,7 @@ public void onTouchEnd(TouchEndEvent event) { } event.stopPropagation(); event.preventDefault(); + active = false; } @Override @@ -76,6 +81,7 @@ public void onTouchCancel(TouchCancelEvent event) { if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { DOM.releaseCapture(getElement()); } + active = false; } } diff --git a/src/main/java/com/googlecode/mgwt/useragent/UserAgent.gwt.xml b/src/main/java/com/googlecode/mgwt/useragent/UserAgent.gwt.xml new file mode 100644 index 000000000..e9a53a40a --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/useragent/UserAgent.gwt.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + diff --git a/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentAsserterGenerator.java b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentAsserterGenerator.java new file mode 100644 index 000000000..b476de8ec --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentAsserterGenerator.java @@ -0,0 +1,54 @@ +/* + * Copyright 2014 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.useragent.rebind; + +import com.google.gwt.core.ext.BadPropertyValueException; +import com.google.gwt.core.ext.ConfigurationProperty; +import com.google.gwt.core.ext.Generator; +import com.google.gwt.core.ext.GeneratorContext; +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.UnableToCompleteException; +import com.google.gwt.useragent.client.UserAgentAsserter; +import com.google.gwt.useragent.client.UserAgentAsserter.UserAgentAsserterDisabled; + +/** + * Generator to enable/disable {@link UserAgentAsserter}. This generator exists because we can't + * deferred-bind via configuration property. + */ +public class UserAgentAsserterGenerator extends Generator { + + private static final String PROPERTY_USER_AGENT_RUNTIME_WARNING = "user.agent.runtimeWarning"; + + private static final String USER_AGENT_ASSERTER = UserAgentAsserter.class.getCanonicalName(); + private static final String USER_AGENT_ASSERTER_DISABLED = + UserAgentAsserterDisabled.class.getCanonicalName(); + + @Override + public String generate(TreeLogger logger, GeneratorContext context, String typeName) + throws UnableToCompleteException { + try { + ConfigurationProperty property = + context.getPropertyOracle().getConfigurationProperty(PROPERTY_USER_AGENT_RUNTIME_WARNING); + if (Boolean.valueOf(property.getValues().get(0)) == false) { + return USER_AGENT_ASSERTER_DISABLED; + } + } catch (BadPropertyValueException e) { + logger.log(TreeLogger.WARN, + "Unable to find value for '" + PROPERTY_USER_AGENT_RUNTIME_WARNING + "'", e); + } + return USER_AGENT_ASSERTER; + } +} diff --git a/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java new file mode 100644 index 000000000..098053228 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java @@ -0,0 +1,105 @@ +/* + * Copyright 2014 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.useragent.rebind; + +import com.google.gwt.core.ext.BadPropertyValueException; +import com.google.gwt.core.ext.Generator; +import com.google.gwt.core.ext.GeneratorContext; +import com.google.gwt.core.ext.PropertyOracle; +import com.google.gwt.core.ext.SelectionProperty; +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.UnableToCompleteException; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; +import com.google.gwt.core.ext.typeinfo.TypeOracle; +import com.google.gwt.core.shared.impl.StringCase; +import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; +import com.google.gwt.user.rebind.SourceWriter; + +import java.io.PrintWriter; + +/** + * Generator for {@link com.google.gwt.useragent.client.UserAgent}. + */ +public class UserAgentGenerator extends Generator { + static final String PROPERTY_USER_AGENT = "user.agent"; + + @Override + public String generate(TreeLogger logger, GeneratorContext context, String typeName) + throws UnableToCompleteException { + TypeOracle typeOracle = context.getTypeOracle(); + + JClassType userType; + try { + userType = typeOracle.getType(typeName); + } catch (NotFoundException e) { + logger.log(TreeLogger.ERROR, "Unable to find metadata for type: " + typeName, e); + throw new UnableToCompleteException(); + } + String packageName = userType.getPackage().getName(); + String className = userType.getName(); + className = className.replace('.', '_'); + + if (userType.isInterface() == null) { + logger.log(TreeLogger.ERROR, userType.getQualifiedSourceName() + " is not an interface", null); + throw new UnableToCompleteException(); + } + + PropertyOracle propertyOracle = context.getPropertyOracle(); + + String userAgentValue; + SelectionProperty selectionProperty; + try { + selectionProperty = propertyOracle.getSelectionProperty(logger, PROPERTY_USER_AGENT); + userAgentValue = selectionProperty.getCurrentValue(); + } catch (BadPropertyValueException e) { + logger.log(TreeLogger.ERROR, "Unable to find value for '" + PROPERTY_USER_AGENT + "'", e); + throw new UnableToCompleteException(); + } + + String userAgentValueInitialCap = StringCase.toUpper(userAgentValue.substring(0, 1)) + + userAgentValue.substring(1); + className = className + "Impl" + userAgentValueInitialCap; + + ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory( + packageName, className); + composerFactory.addImplementedInterface(userType.getQualifiedSourceName()); + + PrintWriter pw = context.tryCreate(logger, packageName, className); + if (pw != null) { + SourceWriter sw = composerFactory.createSourceWriter(context, pw); + + sw.println(); + sw.println("public native String getRuntimeValue() /*-{"); + sw.indent(); + UserAgentPropertyGenerator.writeUserAgentPropertyJavaScript(sw, + selectionProperty.getPossibleValues(), null); + sw.outdent(); + sw.println("}-*/;"); + sw.println(); + + sw.println(); + sw.println("public String getCompileTimeValue() {"); + sw.indent(); + sw.println("return \"" + userAgentValue.trim() + "\";"); + sw.outdent(); + sw.println("}"); + + sw.commit(logger); + } + return composerFactory.getCreatedClassName(); + } +} diff --git a/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentPropertyGenerator.java b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentPropertyGenerator.java new file mode 100644 index 000000000..d50cd11a7 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentPropertyGenerator.java @@ -0,0 +1,119 @@ +/* + * Copyright 2014 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.useragent.rebind; + +import java.util.HashSet; +import java.util.Set; +import java.util.SortedSet; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.linker.ConfigurationProperty; +import com.google.gwt.core.ext.linker.PropertyProviderGenerator; +import com.google.gwt.user.rebind.SourceWriter; +import com.google.gwt.user.rebind.StringSourceWriter; +import com.google.gwt.useragent.rebind.UserAgentGenerator; + +/** + * Generator which writes out the JavaScript for determining the value of the + * user.agent selection property. + */ +public class UserAgentPropertyGenerator implements PropertyProviderGenerator { + + /** + * The list of {@code user.agent} values listed here should be kept in sync with + * {@code UserAgent.gwt.xml}. + *

Note that the order of enums matter as the script selection is based on running + * these predicates in order and matching the first one that returns {@code true}. + *

Also note that, {@code docMode < 11} in predicates for older IEs exists to + * ensures we never choose them for IE11 (we know that they will not work for IE11). + */ + private enum UserAgent { + ie10("return (ua.indexOf('iemobile/11') != -1) || (ua.indexOf('trident/7') != -1) || "+ + "(ua.indexOf('msie 10.') != -1) || (ua.indexOf('iemobile/10') != -1);"), + ie9("return (ua.indexOf('msie') != -1 && (docMode >= 9 && docMode < 11));"), + ie8("return (ua.indexOf('msie') != -1 && (docMode >= 8 && docMode < 11));"), + safari("return (ua.indexOf('webkit') != -1);"), + gecko1_8("return (ua.indexOf('gecko') != -1 || docMode >= 11);"); + + private final String predicateBlock; + + private UserAgent(String predicateBlock) { + this.predicateBlock = predicateBlock; + } + + private static Set getKnownAgents() { + HashSet userAgents = new HashSet(); + for (UserAgent userAgent : values()) { + userAgents.add(userAgent.name()); + } + return userAgents; + } + } + + /** + * Writes out the JavaScript function body for determining the value of the + * user.agent selection property. This method is used to create + * the selection script and by {@link UserAgentGenerator} to assert at runtime + * that the correct user agent permutation is executing. + */ + static void writeUserAgentPropertyJavaScript(SourceWriter body, + SortedSet possibleValues, String fallback) { + + // write preamble + body.println("var ua = navigator.userAgent.toLowerCase();"); + body.println("var docMode = $doc.documentMode;"); + + for (UserAgent userAgent : UserAgent.values()) { + // write only selected user agents + if (possibleValues.contains(userAgent.name())) { + body.println("if ((function() { "); + body.indentln(userAgent.predicateBlock); + body.println("})()) return '%s';", userAgent.name()); + } + } + + // default return + if (fallback == null) { + fallback = "unknown"; + } + body.println("return '" + fallback + "';"); + } + + @Override + public String generate(TreeLogger logger, SortedSet possibleValues, String fallback, + SortedSet configProperties) { + assertUserAgents(logger, possibleValues); + + StringSourceWriter body = new StringSourceWriter(); + body.println("{"); + body.indent(); + writeUserAgentPropertyJavaScript(body, possibleValues, fallback); + body.outdent(); + body.println("}"); + + return body.toString(); + } + + private static void assertUserAgents(TreeLogger logger, SortedSet possibleValues) { + HashSet unknownValues = new HashSet(possibleValues); + unknownValues.removeAll(UserAgent.getKnownAgents()); + if (!unknownValues.isEmpty()) { + logger.log(TreeLogger.WARN, "Unrecognized user.agent" + + " values " + unknownValues + ", possibly due to UserAgent.gwt.xml and " + + UserAgentPropertyGenerator.class.getName() + " being out of sync."); + } + } +} diff --git a/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java b/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java index 9fc438388..d69d3a91f 100644 --- a/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java +++ b/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java @@ -21,6 +21,10 @@ public interface UserAgents { public static final String IPHONE_IOS5_USER_AGENT = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"; public static final String DESKTOP_OPERA = "Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00"; public static final String DESKTOP_IE9 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; + public static final String DESKTOP_IE10 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"; + public static final String DESKTOP_IE11 = "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"; + public static final String WP8_IE10 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; HTC; Windows Phone 8X by HTC)"; + public static final String WP81_IE11 = "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537"; diff --git a/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java b/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java index 710353598..5f214ff2a 100644 --- a/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java +++ b/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java @@ -55,6 +55,7 @@ public void testNexus5() { Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isRetina()); Assert.assertFalse(osDetection.isTablet()); + Assert.assertFalse(osDetection.isWindowsPhone()); } @Test @@ -77,6 +78,7 @@ public void testNexus7() { Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isWindowsPhone()); } @Test @@ -100,6 +102,7 @@ public void testIphoneIOS7() { Assert.assertFalse(osDetection.isIPad()); Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); + Assert.assertFalse(osDetection.isWindowsPhone()); } @Test @@ -123,6 +126,7 @@ public void testIPadMiniIOS7() { Assert.assertFalse(osDetection.isIOS6()); Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isWindowsPhone()); } @Test @@ -145,6 +149,7 @@ public void testIPadIOS7() { Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isWindowsPhone()); } @Test @@ -168,6 +173,7 @@ public void testIPadIOS6() { Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isWindowsPhone()); } @Test @@ -191,5 +197,102 @@ public void testIPhoneIOS6() { Assert.assertFalse(osDetection.isIPad()); Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); + Assert.assertFalse(osDetection.isWindowsPhone()); + } + + @Test + public void testDesktopIE10() { + userAgent = UserAgents.DESKTOP_IE10; + devicePixelRatio = 2; + + Assert.assertFalse(osDetection.isIOs()); + Assert.assertFalse(osDetection.isPhone()); + Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isIOS6()); + + Assert.assertFalse(osDetection.isAndroid()); + Assert.assertFalse(osDetection.isAndroid4_4_OrHigher()); + Assert.assertFalse(osDetection.isAndroidTablet()); + Assert.assertFalse(osDetection.isTablet()); + Assert.assertFalse(osDetection.isAndroid2x()); + Assert.assertFalse(osDetection.isAndroidPhone()); + Assert.assertFalse(osDetection.isBlackBerry()); + Assert.assertTrue(osDetection.isDesktop()); + Assert.assertFalse(osDetection.isIPad()); + Assert.assertFalse(osDetection.isIPadRetina()); + Assert.assertFalse(osDetection.isIPhone()); + Assert.assertFalse(osDetection.isWindowsPhone()); + } + + @Test + public void testDesktopIE11() { + userAgent = UserAgents.DESKTOP_IE11; + devicePixelRatio = 2; + + Assert.assertFalse(osDetection.isIOs()); + Assert.assertFalse(osDetection.isPhone()); + Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isIOS6()); + + Assert.assertFalse(osDetection.isAndroid()); + Assert.assertFalse(osDetection.isAndroid4_4_OrHigher()); + Assert.assertFalse(osDetection.isAndroidTablet()); + Assert.assertFalse(osDetection.isTablet()); + Assert.assertFalse(osDetection.isAndroid2x()); + Assert.assertFalse(osDetection.isAndroidPhone()); + Assert.assertFalse(osDetection.isBlackBerry()); + Assert.assertTrue(osDetection.isDesktop()); + Assert.assertFalse(osDetection.isIPad()); + Assert.assertFalse(osDetection.isIPadRetina()); + Assert.assertFalse(osDetection.isIPhone()); + Assert.assertFalse(osDetection.isWindowsPhone()); + } + + @Test + public void testMobileIE10() { + userAgent = UserAgents.WP8_IE10; + devicePixelRatio = 2; + + Assert.assertFalse(osDetection.isIOs()); + Assert.assertTrue(osDetection.isPhone()); + Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isIOS6()); + + Assert.assertFalse(osDetection.isAndroid()); + Assert.assertFalse(osDetection.isAndroid4_4_OrHigher()); + Assert.assertFalse(osDetection.isAndroidTablet()); + Assert.assertFalse(osDetection.isTablet()); + Assert.assertFalse(osDetection.isAndroid2x()); + Assert.assertFalse(osDetection.isAndroidPhone()); + Assert.assertFalse(osDetection.isBlackBerry()); + Assert.assertFalse(osDetection.isDesktop()); + Assert.assertFalse(osDetection.isIPad()); + Assert.assertFalse(osDetection.isIPadRetina()); + Assert.assertFalse(osDetection.isIPhone()); + Assert.assertTrue(osDetection.isWindowsPhone()); + } + + @Test + public void testMobileIE11() { + userAgent = UserAgents.WP81_IE11; + devicePixelRatio = 2; + + Assert.assertFalse(osDetection.isIOs()); + Assert.assertTrue(osDetection.isPhone()); + Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isIOS6()); + + Assert.assertFalse(osDetection.isAndroid()); + Assert.assertFalse(osDetection.isAndroid4_4_OrHigher()); + Assert.assertFalse(osDetection.isAndroidTablet()); + Assert.assertFalse(osDetection.isTablet()); + Assert.assertFalse(osDetection.isAndroid2x()); + Assert.assertFalse(osDetection.isAndroidPhone()); + Assert.assertFalse(osDetection.isBlackBerry()); + Assert.assertFalse(osDetection.isDesktop()); + Assert.assertFalse(osDetection.isIPad()); + Assert.assertFalse(osDetection.isIPadRetina()); + Assert.assertFalse(osDetection.isIPhone()); + Assert.assertTrue(osDetection.isWindowsPhone()); } } From a996aedc9d697ca82d5780165ded274a890c9619 Mon Sep 17 00:00:00 2001 From: paulf_000 Date: Wed, 16 Sep 2015 16:27:07 +0100 Subject: [PATCH 39/53] Added support to detect IE Edge at runtime. We let IE Edge run as the safari permutation but we still need to emulate the IconHandler --- .../mgwt/ui/client/OsDetection.java | 4 +- .../ui/client/OsDetectionRuntimeImpl.java | 34 ++++++++--- .../mgwt/ui/client/util/IconHandler.java | 2 +- .../propertyprovider/test/UserAgents.java | 2 + .../ui/client/OsDetectionRuntimeImplTest.java | 61 +++++++++++++++++++ 5 files changed, 91 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java index 47655359a..d00c558f3 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetection.java @@ -125,7 +125,7 @@ public interface OsDetection { public boolean isPhone(); /** - * Are we running on Windows Phone 8/8.1 + * Are we running on Windows Phone 8/8.1/10 * @return */ public boolean isWindowsPhone(); @@ -145,4 +145,6 @@ public interface OsDetection { boolean isIOS6(); boolean isAndroid4_3_orLower(); + + boolean isIEEdge(); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java index f66f1acb1..e00e3a2a7 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java @@ -10,7 +10,7 @@ public boolean isAndroid() { @Override public boolean isIPhone() { String userAgent = getUserAgent(); - if (!isWindowsPhone() && userAgent.contains("iphone") && getDevicePixelRatio() < 2) { + if (!isIEEdge(userAgent) && !isWindowsPhone() && userAgent.contains("iphone") && getDevicePixelRatio() < 2) { return true; } return false; @@ -19,7 +19,7 @@ public boolean isIPhone() { @Override public boolean isIPad() { String userAgent = getUserAgent(); - if (userAgent.contains("ipad") && getDevicePixelRatio() < 2) { + if (!isIEEdge(userAgent) && userAgent.contains("ipad") && getDevicePixelRatio() < 2) { return true; } return false; @@ -33,7 +33,7 @@ public boolean isIOs() { @Override public boolean isRetina() { String userAgent = getUserAgent(); - if (!isWindowsPhone() && userAgent.contains("iphone") && getDevicePixelRatio() >= 2) { + if (!isIEEdge(userAgent) && !isWindowsPhone() && userAgent.contains("iphone") && getDevicePixelRatio() >= 2) { return true; } return false; @@ -42,7 +42,7 @@ public boolean isRetina() { @Override public boolean isIPadRetina() { String userAgent = getUserAgent(); - if (userAgent.contains("ipad") && getDevicePixelRatio() >= 2) { + if (!isIEEdge(userAgent) && userAgent.contains("ipad") && getDevicePixelRatio() >= 2) { return true; } return false; @@ -61,7 +61,7 @@ public boolean isTablet() { @Override public boolean isAndroidTablet() { String userAgent = getUserAgent(); - if (!isWindowsPhone() && userAgent.contains("android") && !userAgent.contains("mobile")) { + if (!isIEEdge(userAgent) && !isWindowsPhone() && userAgent.contains("android") && !userAgent.contains("mobile")) { return true; } return false; @@ -70,7 +70,7 @@ public boolean isAndroidTablet() { @Override public boolean isAndroidPhone() { String userAgent = getUserAgent(); - if (!isWindowsPhone() && userAgent.contains("android") && userAgent.contains("mobile")) { + if (!isIEEdge(userAgent) && !isWindowsPhone() && userAgent.contains("android") && userAgent.contains("mobile")) { return true; } return false; @@ -85,7 +85,7 @@ public boolean isPhone() { public boolean isWindowsPhone() { String userAgent = getUserAgent(); - if (userAgent.contains("windows phone 8")) { + if (userAgent.contains("windows phone 8") || userAgent.contains("windows phone 10")) { return true; } return false; @@ -99,7 +99,7 @@ public boolean isBlackBerry() { @Override public boolean isAndroid4_4_OrHigher() { String userAgent = getUserAgent(); - if (userAgent.contains("android") && userAgent.contains("chrome")) { + if (!isIEEdge(userAgent) && userAgent.contains("android") && userAgent.contains("chrome")) { return true; } return false; @@ -108,7 +108,7 @@ public boolean isAndroid4_4_OrHigher() { @Override public boolean isAndroid2x() { String userAgent = getUserAgent(); - if (userAgent.contains("android 2.")) { + if (!isIEEdge(userAgent) && userAgent.contains("android 2.")) { return true; } return false; @@ -149,11 +149,25 @@ public boolean isAndroid4_3_orLower() { } String userAgent = getUserAgent(); - if (userAgent.contains("android")) { + if (!isIEEdge(userAgent) && userAgent.contains("android")) { return true; } return false; } + private boolean isIEEdge(String userAgent) + { + if (userAgent.contains("edge/12")) { + return true; + } + return false; + } + + @Override + public boolean isIEEdge() + { + return isIEEdge(getUserAgent()); + } + } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java b/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java index bcbf53c93..d79de1c0b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/IconHandler.java @@ -26,7 +26,7 @@ public class IconHandler { static { - if (MGWT.getOsDetection().isAndroid4_3_orLower()) { + if (MGWT.getOsDetection().isAndroid4_3_orLower() || MGWT.getOsDetection().isIEEdge()) { ICON_HANDLER = new IconHandlerEmulatedImpl(); } else { ICON_HANDLER = GWT.create(IconHandlerImpl.class); diff --git a/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java b/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java index d69d3a91f..d6ee94bbd 100644 --- a/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java +++ b/src/test/java/com/googlecode/mgwt/linker/server/propertyprovider/test/UserAgents.java @@ -25,6 +25,8 @@ public interface UserAgents { public static final String DESKTOP_IE11 = "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"; public static final String WP8_IE10 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; HTC; Windows Phone 8X by HTC)"; public static final String WP81_IE11 = "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537"; + public static final String DESKTOP_IE_EDGE = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12."; + public static final String MOBILE_IE_EDGE = "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12."; diff --git a/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java b/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java index 5f214ff2a..90dc6d327 100644 --- a/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java +++ b/src/test/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImplTest.java @@ -56,6 +56,7 @@ public void testNexus5() { Assert.assertFalse(osDetection.isRetina()); Assert.assertFalse(osDetection.isTablet()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -79,6 +80,7 @@ public void testNexus7() { Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -103,6 +105,7 @@ public void testIphoneIOS7() { Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -127,6 +130,7 @@ public void testIPadMiniIOS7() { Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -150,6 +154,7 @@ public void testIPadIOS7() { Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -174,6 +179,7 @@ public void testIPadIOS6() { Assert.assertFalse(osDetection.isPhone()); Assert.assertFalse(osDetection.isRetina()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -198,6 +204,7 @@ public void testIPhoneIOS6() { Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -222,6 +229,7 @@ public void testDesktopIE10() { Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -246,6 +254,7 @@ public void testDesktopIE11() { Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -270,6 +279,7 @@ public void testMobileIE10() { Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); Assert.assertTrue(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); } @Test @@ -294,5 +304,56 @@ public void testMobileIE11() { Assert.assertFalse(osDetection.isIPadRetina()); Assert.assertFalse(osDetection.isIPhone()); Assert.assertTrue(osDetection.isWindowsPhone()); + Assert.assertFalse(osDetection.isIEEdge()); + } + + @Test + public void testDesktopIEEdge() { + userAgent = UserAgents.DESKTOP_IE_EDGE; + devicePixelRatio = 2; + + Assert.assertFalse(osDetection.isIOs()); + Assert.assertFalse(osDetection.isPhone()); + Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isIOS6()); + + Assert.assertFalse(osDetection.isAndroid()); + Assert.assertFalse(osDetection.isAndroid4_4_OrHigher()); + Assert.assertFalse(osDetection.isAndroidTablet()); + Assert.assertFalse(osDetection.isTablet()); + Assert.assertFalse(osDetection.isAndroid2x()); + Assert.assertFalse(osDetection.isAndroidPhone()); + Assert.assertFalse(osDetection.isBlackBerry()); + Assert.assertTrue(osDetection.isDesktop()); + Assert.assertFalse(osDetection.isIPad()); + Assert.assertFalse(osDetection.isIPadRetina()); + Assert.assertFalse(osDetection.isIPhone()); + Assert.assertFalse(osDetection.isWindowsPhone()); + Assert.assertTrue(osDetection.isIEEdge()); + } + + @Test + public void testMobileIEEdge() { + userAgent = UserAgents.MOBILE_IE_EDGE; + devicePixelRatio = 2; + + Assert.assertFalse(osDetection.isIOs()); + Assert.assertTrue(osDetection.isPhone()); + Assert.assertFalse(osDetection.isRetina()); + Assert.assertFalse(osDetection.isIOS6()); + + Assert.assertFalse(osDetection.isAndroid()); + Assert.assertFalse(osDetection.isAndroid4_4_OrHigher()); + Assert.assertFalse(osDetection.isAndroidTablet()); + Assert.assertFalse(osDetection.isTablet()); + Assert.assertFalse(osDetection.isAndroid2x()); + Assert.assertFalse(osDetection.isAndroidPhone()); + Assert.assertFalse(osDetection.isBlackBerry()); + Assert.assertFalse(osDetection.isDesktop()); + Assert.assertFalse(osDetection.isIPad()); + Assert.assertFalse(osDetection.isIPadRetina()); + Assert.assertFalse(osDetection.isIPhone()); + Assert.assertTrue(osDetection.isWindowsPhone()); + Assert.assertTrue(osDetection.isIEEdge()); } } From 664f1d59a06c01d1650a2ccdf6e38d311c87aab3 Mon Sep 17 00:00:00 2001 From: paulf_000 Date: Thu, 17 Sep 2015 11:53:29 +0100 Subject: [PATCH 40/53] Fixes look and feel of Search Box on IE10/11 and WP8.1. Does not fix for IEEdge since the widget will need a total revamp --- .../client/widget/input/search/searchbox.css | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css index b5e3208fc..950f49490 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css @@ -81,6 +81,12 @@ } } +@if user.agent ie10 { + .mgwt-SearchBox-input { + top: 5px; + } +} + .mgwt-SearchBox-clear-active { } @@ -146,17 +152,10 @@ @if user.agent ie10 { - @if mgwt.density high { - .mgwt-SearchBox-icon { - background-size: 17px 17px; - } - } - - @if mgwt.density xhigh { - .mgwt-SearchBox-icon { + .mgwt-SearchBox-icon { + background-color: transparent; background-size: 12px 12px; - } - } + } .mgwt-SearchBox-clear { background-image: clearImage; @@ -192,15 +191,9 @@ @if user.agent ie10 { - @if mgwt.density high { - .mgwt-SearchBox-clear { - background-size: 19px 19px; - } - } - - @if mgwt.density xhigh { - .mgwt-SearchBox-clear { + .mgwt-SearchBox-clear { + background-color: transparent; background-size: 14px 14px; - } } + } From e492b2858e82ac720a1b92c6b479079d0f7908ff Mon Sep 17 00:00:00 2001 From: paulf_000 Date: Fri, 18 Sep 2015 12:28:28 +0100 Subject: [PATCH 41/53] minor change to searchbox so works IEEdge --- .../client/widget/input/search/searchbox.css | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css index 950f49490..50f577b97 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/search/searchbox.css @@ -106,20 +106,6 @@ background-color: white; } -@if user.agent safari { - .mgwt-SearchBox-icon { - -webkit-mask-image: searchImage; - -webkit-mask-repeat: no-repeat; - } -} - -@if user.agent ie10 { - .mgwt-SearchBox-icon { - background-image: searchImage; - background-repeat: no-repeat; - } -} - .mgwt-SearchBox-icon { position: relative; top: 7px; @@ -143,6 +129,20 @@ } } + .mgwt-SearchBox-icon { + -webkit-mask-image: searchImage; + -webkit-mask-repeat: no-repeat; + } + + @if (com.googlecode.mgwt.ui.client.MGWT.getOsDetection().isIEEdge()) { + .mgwt-SearchBox-icon { + background-image: searchImage; + background-repeat: no-repeat; + background-color: inherit; + } + + } + .mgwt-SearchBox-clear { -webkit-mask-image: clearImage; -webkit-mask-position: center center; @@ -153,6 +153,8 @@ @if user.agent ie10 { .mgwt-SearchBox-icon { + background-image: searchImage; + background-repeat: no-repeat; background-color: transparent; background-size: 12px 12px; } From ed3aa7d5b6a57b82c643c7193c0773731d3661bf Mon Sep 17 00:00:00 2001 From: paulf_000 Date: Fri, 6 Nov 2015 17:35:38 +0000 Subject: [PATCH 42/53] IE11 via a micro update have dropped support for the -ms prefix to flex commands and gone to the latest model. So it depends on what IE11 version you run now. Hence the FlexInputHelper now adds both, the user agent specific flex commands as well as standard flex ones --- .../client/widget/panel/flex/FlexPropertyHelper.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java index 255695009..e2cd7dc7e 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/flex/FlexPropertyHelper.java @@ -21,6 +21,7 @@ public abstract class FlexPropertyHelper { private static final FlexPropertyHelper impl = GWT.create(FlexPropertyHelper.class); + private static final FlexPropertyHelper std = GWT.create(FlexPropertyHelperStandard.class); public static enum Alignment { START, END, CENTER, STRETCH, BASELINE, NONE; @@ -54,6 +55,7 @@ public static void setElementAsFlexContainer(Element el, Orientation orientation orientation = Orientation.HORIZONTAL; // the default } impl._setElementAsFlexContainer(el, orientation); + std._setElementAsFlexContainer(el, orientation); } public static void setFlex(Element el, double grow) { @@ -66,42 +68,52 @@ public static void setFlex(Element el, double grow, double shrink) { public static void setFlex(Element el, double grow, double shrink, String basis) { impl._setFlex(el, grow, shrink, basis); + std._setFlex(el, grow, shrink, basis); } public static void setFlex(Element el, double grow, String basis) { impl._setFlex(el, grow, basis); + std._setFlex(el, grow, basis); } public static void setFlexOrder(Element el, int order) { impl._setFlexOrder(el, order); + std._setFlexOrder(el, order); } public static void setAlignment(Element el, Alignment alignment) { impl._setAlignmentProperty(el, alignment); + std._setAlignmentProperty(el, alignment); } public static void setAlignmentSelf(Element el, AlignmentSelf alignmentSelf) { impl._setAlignmentSelfProperty(el, alignmentSelf); + std._setAlignmentSelfProperty(el, alignmentSelf); } public static void setOrientation(Element el, Orientation orientation) { impl._setOrientationProperty(el, orientation); + std._setOrientationProperty(el, orientation); } public static void setJustification(Element el, Justification justification) { impl._setJustificationProperty(el, justification); + std._setJustificationProperty(el, justification); } public static void setFlexWrap(Element el, FlexWrap flexWrap) { impl._setFlexWrapProperty(el, flexWrap); + std._setFlexWrapProperty(el, flexWrap); } public static void clearAlignment(Element el) { impl._setAlignmentProperty(el,Alignment.NONE); + std._setAlignmentProperty(el,Alignment.NONE); } public static void clearJustification(Element el) { impl._setJustificationProperty(el,Justification.NONE); + std._setJustificationProperty(el,Justification.NONE); } protected void setStyleProperty(Element el, String property, String value) { From 9ffad8972fe8d6d1bbfb39b4a757e58d64bb4cc7 Mon Sep 17 00:00:00 2001 From: paulf_000 Date: Tue, 8 Dec 2015 17:34:50 +0000 Subject: [PATCH 43/53] Removed usage of a GWT 2.7 feature so compiles fine against GWT 2.6.1 as required --- .../mgwt/useragent/rebind/UserAgentGenerator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java index 098053228..f910c830e 100644 --- a/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java +++ b/src/main/java/com/googlecode/mgwt/useragent/rebind/UserAgentGenerator.java @@ -15,6 +15,9 @@ */ package com.googlecode.mgwt.useragent.rebind; +import java.io.PrintWriter; +import java.util.Locale; + import com.google.gwt.core.ext.BadPropertyValueException; import com.google.gwt.core.ext.Generator; import com.google.gwt.core.ext.GeneratorContext; @@ -25,12 +28,9 @@ import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.NotFoundException; import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.core.shared.impl.StringCase; import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; import com.google.gwt.user.rebind.SourceWriter; -import java.io.PrintWriter; - /** * Generator for {@link com.google.gwt.useragent.client.UserAgent}. */ @@ -70,7 +70,7 @@ public String generate(TreeLogger logger, GeneratorContext context, String typeN throw new UnableToCompleteException(); } - String userAgentValueInitialCap = StringCase.toUpper(userAgentValue.substring(0, 1)) + String userAgentValueInitialCap = userAgentValue.substring(0, 1).toUpperCase(Locale.ENGLISH) + userAgentValue.substring(1); className = className + "Impl" + userAgentValueInitialCap; From 26a025899c6907afb8dc2850fe41693d7d0d2427 Mon Sep 17 00:00:00 2001 From: paulf_000 Date: Mon, 11 Jan 2016 15:59:53 +0000 Subject: [PATCH 44/53] removed touchStart.preventDefault since breaks native scrolling by obviously preventing the default behaviour which is to sroll the list --- .../mgwt/ui/client/widget/list/celllist/CellList.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java index 061541520..7e8f9d7ee 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/list/celllist/CellList.java @@ -123,13 +123,6 @@ public void onTouchStart(TouchStartEvent event) { return; } - // if windows phone then do not prevent default, causes scrolling issues when - // in scroll panel (not sure why), ie10 desktop is fine - if (!MGWT.getOsDetection().isWindowsPhone()) - { - event.preventDefault(); - } - // text node use the parent.. if (Node.is(eventTarget) && !Element.is(eventTarget)) { Node target = Node.as(eventTarget); From 938b1d33ac419856b02257137bcddce2bf5884bd Mon Sep 17 00:00:00 2001 From: hoffmann Date: Tue, 8 Dec 2015 14:28:23 +0100 Subject: [PATCH 45/53] Added MenuImageButton --- .../widget/button/image/MenuImageButton.java | 26 ++++++++++++++++++ .../ui/client/widget/image/ImageHolder.java | 2 ++ .../image/ImageHolderDefaultAppearance.java | 3 ++ .../ImageHolderDefaultHighAppearance.java | 3 ++ .../ImageHolderDefaultXHighAppearance.java | 3 ++ .../image/resources/ic_action_menu_hdpi.png | Bin 0 -> 222 bytes .../image/resources/ic_action_menu_mdpi.png | Bin 0 -> 148 bytes .../image/resources/ic_action_menu_xhdpi.png | Bin 0 -> 304 bytes .../image/resources/ic_action_menu_xxhdpi.png | Bin 0 -> 548 bytes .../resources/ic_action_menu_xxxhdpi.png | Bin 0 -> 862 bytes 10 files changed, 37 insertions(+) create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/button/image/MenuImageButton.java create mode 100755 src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_hdpi.png create mode 100755 src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_mdpi.png create mode 100755 src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_xhdpi.png create mode 100755 src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_xxhdpi.png create mode 100755 src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_xxxhdpi.png diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/image/MenuImageButton.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/image/MenuImageButton.java new file mode 100644 index 000000000..5f8033a54 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/image/MenuImageButton.java @@ -0,0 +1,26 @@ + +/* + * Copyright 2014 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.button.image; + +import com.googlecode.mgwt.ui.client.widget.button.ImageButton; +import com.googlecode.mgwt.ui.client.widget.image.ImageHolder; + +public class MenuImageButton extends ImageButton { + public MenuImageButton() { + super(ImageHolder.get().menu()); + } +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolder.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolder.java index 760f02217..fba411867 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolder.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolder.java @@ -165,6 +165,8 @@ public interface Images { ImageResource map(); + ImageResource menu(); + ImageResource merge(); ImageResource mic(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultAppearance.java index 6c65c9805..b42c80424 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultAppearance.java @@ -239,6 +239,9 @@ interface Resources extends ClientBundle, Images { @Source("resources/ic_action_map_mdpi.png") ImageResource map(); + @Source("resources/ic_action_menu_mdpi.png") + ImageResource menu(); + @Source("resources/ic_action_merge_mdpi.png") ImageResource merge(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultHighAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultHighAppearance.java index d1a5d5092..829bfe7e1 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultHighAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultHighAppearance.java @@ -239,6 +239,9 @@ interface Resources extends ClientBundle, Images { @Source("resources/ic_action_map_hdpi.png") ImageResource map(); + @Source("resources/ic_action_menu_hdpi.png") + ImageResource menu(); + @Source("resources/ic_action_merge_hdpi.png") ImageResource merge(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultXHighAppearance.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultXHighAppearance.java index 06632fc05..8f3554853 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultXHighAppearance.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/ImageHolderDefaultXHighAppearance.java @@ -239,6 +239,9 @@ interface Resources extends ClientBundle, Images { @Source("resources/ic_action_map_xhdpi.png") ImageResource map(); + @Source("resources/ic_action_menu_xhdpi.png") + ImageResource menu(); + @Source("resources/ic_action_merge_xhdpi.png") ImageResource merge(); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_hdpi.png b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_hdpi.png new file mode 100755 index 0000000000000000000000000000000000000000..b15e99a5b219a94776fe35dc32c08655aed2b54f GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtrJgR1AsNnZrv>sgDDWJ8@~{0G zw}j9o_O#7^-oLz+YOwB6y2$_kr`h(ItzhJJVCoZK={RlLAb60>a+uF zhq(TwEASNf$Gq0v!X9Z6%AC01bm3awiix`C5AS(UFCO_*kjwwTydBq~Gx#?ZtYSOl zF#U0qw8nn7+=R*nwO%a~=XPZ8ZS`X~a{mH@8waxq1LLD2-h>td2W9~UJ^lO#jNc`B V3>Eip2fCMm!PC{xWt~$(695ZnQLq32 literal 0 HcmV?d00001 diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_mdpi.png b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_mdpi.png new file mode 100755 index 0000000000000000000000000000000000000000..b15b3375aed8e7d06cd313c1951e0ec4e182bd49 GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJXipc%kO=p;Qx5V1C5|L`$Og4v zS+AnD??c5E#s@*wJ38lgf0t%dU}%(XoEmd>!{(HRi9QSFf1bEOrE%Ju12vWoyiemN vtZ|Tu-^5zP^eNbf_bHzM1CziHuLR~D|F{$*`wUhCtzqzV^>bP0l+XkKaD6j9 literal 0 HcmV?d00001 diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_xhdpi.png b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_xhdpi.png new file mode 100755 index 0000000000000000000000000000000000000000..4941477ee9b601f0d24d8b95ae8e02fc9281f700 GIT binary patch literal 304 zcmV-00nh%4P)lnB@lNiKi^ z$Y5TfH0kpph=dz-R}UFq2%!jy|D}tfsF&oTcG|D6k;}4q7X3mbVBDC zAei)M2?RWPyu#riKrpHPPf?a3fs$ki%Mi2pB#V0`WA;uum9_jabCA9H}n;ak7u zXX%}}S}b~!b*5#N<~M%kTDxC?oHkd#os#FAAn(W|q#!)ub+iLh3R6)nw?~7I!@7J% z&Iz0+zUnG48ZqwN$ExC>rf_|G1Ir1PC%?odFwAU-xsR&pM>A91lkfqZV$x@g1V6f5`T*Sp8l0{!d5jxHrYoy#Cv|5 zy5vue@Pvl-Y6|rhU(#h;f4jX|A_lTZ<$;R>-$M7^L%I*Z0>QP4E((ks*X`ys*anvv zlEV7a*|1Nz?mZ*W*niShQ4C34hd4bBbT-I1^-HxzAMn)0Cb0aMQ-=eSz`9xs#_DA+ elIX?y!TPvZA~EToyC*RA89ZJ6T-G@yGywoNWYh}) literal 0 HcmV?d00001 diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_xxxhdpi.png b/src/main/java/com/googlecode/mgwt/ui/client/widget/image/resources/ic_action_menu_xxxhdpi.png new file mode 100755 index 0000000000000000000000000000000000000000..2b23ad3c5ec6a45afb72689bb99210faf672c060 GIT binary patch literal 862 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrU{>{XaSW-5dpkGK&)JcO`C&@O zWMw}#r#-?cO1anN{>?r1ZBK*N);;@w2G2cEy|w!6eohBV7A6ITr<_x6e`n%wsAPKj zZ7%~;z&wYYwfYSVQ`7_U?sHRFx7u^@HPzq7XMjetsg;D}hedgoSo?Or;%1m=4^Ip3z|ClEfIXqQBokR%s){hi_tP z3-~5RFo?Z+tQ^qp@#oFIqqY`|Djztv)CH<=>O1Z(WE3h|@l}Cg>(&3#;tY%${tNEx z6L(-ZC9JXiJ*z;&Czexhs~K4q*fbXXjzg8+U&v^8%Gf6N|7@KNj1BX7lz0ntfzFwK zm$hNK2gFv7{Ol-@Qx8OSrU-zX+VExDGFOnp)=c$aTL^L(K_x$K-rC;eSsPRRXKg~> zLC)hsH+C=_pZ2}Al8Nbn@t&$ChL~9S_&A1&ws3!ehSjehpXO#b|KSxUQ$cBMO(o+4 z$v9g_hIQ-u_4OHS4zE_{IB@mr$EU0f=@nmD76qcQuDabhEsn}wnh8bGvZY&AY yqI Date: Mon, 14 Dec 2015 22:39:54 +0100 Subject: [PATCH 46/53] =?UTF-8?q?Bug=20fix=20of=20CssUtil=20impl=20?= =?UTF-8?q?=E2=80=93=20wrong=20variable=20references=20in=20native=20metho?= =?UTF-8?q?ds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mgwt/ui/client/util/impl/CssUtilIE10Impl.java | 2 +- .../mgwt/ui/client/util/impl/FireFoxCssUtilImpl.java | 4 ++-- .../mgwt/ui/client/util/impl/WebkitCssUtilImpl.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java index 5ffae8da6..b24105e9c 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/CssUtilIE10Impl.java @@ -111,7 +111,7 @@ public native void setTransFormOrigin(Element el, int x, int y) /*-{ }-*/; @Override - public native void setTransistionTimingFunction(Element element, String string) /*-{ + public native void setTransistionTimingFunction(Element el, String string) /*-{ el.transitionTimingFunction = string; }-*/; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/FireFoxCssUtilImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/FireFoxCssUtilImpl.java index a919d1ba8..29e511d71 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/FireFoxCssUtilImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/FireFoxCssUtilImpl.java @@ -100,13 +100,13 @@ public native void setTransFormOrigin(Element el, int x, int y) /*-{ }-*/; @Override - public native void setTransistionTimingFunction(Element element, String string) /*-{ + public native void setTransistionTimingFunction(Element el, String string) /*-{ el.mozTransitionTimingFunction = string; }-*/; @Override public void setTranslateAndZoom(Element el, int x, int y, double scale) { - String cssText = null; + final String cssText; cssText = "translate( " + x + "px, " + y + "px ) scale( + " + scale + ")"; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/WebkitCssUtilImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/WebkitCssUtilImpl.java index 725de9cb0..cd8fc7df3 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/util/impl/WebkitCssUtilImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/util/impl/WebkitCssUtilImpl.java @@ -15,7 +15,7 @@ public WebkitCssUtilImpl() { @Override public void translate(Element el, int x, int y) { - String cssText = null; + final String cssText; if (has3d() && !MGWT.getOsDetection().isDesktop()) { cssText = "translate3d(" + x + "px, " + y + "px, 0px)"; } else { @@ -125,13 +125,13 @@ public native void setTransFormOrigin(Element el, int x, int y) /*-{ }-*/; @Override - public native void setTransistionTimingFunction(Element element, String string) /*-{ + public native void setTransistionTimingFunction(Element el, String string) /*-{ el.webkitTransitionTimingFunction = string; }-*/; @Override public void setTranslateAndZoom(Element el, int x, int y, double scale) { - String cssText = null; + final String cssText; if (MGWT.getOsDetection().isAndroid() || MGWT.getOsDetection().isDesktop()) { cssText = "translate( " + x + "px, " + y + "px ) scale(" + scale + ")"; } else { @@ -143,7 +143,7 @@ public void setTranslateAndZoom(Element el, int x, int y, double scale) { @Override public void translatePercent(Element el, double x, double y) { - String cssText = null; + final String cssText; if (has3d() && !MGWT.getOsDetection().isDesktop()) { cssText = "translate3d(" + x + "%, " + y + "%, 0px)"; } else { From f2509fb7bf150c3c9ec7931c66f61e43adc208e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Beringer?= Date: Wed, 27 Aug 2014 18:24:02 +0200 Subject: [PATCH 47/53] Add support for tap events on carousel indicators --- .../ui/client/widget/carousel/Carousel.java | 145 +++++++++++++++--- 1 file changed, 123 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java index c11ba91f6..863650239 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java @@ -31,10 +31,11 @@ import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.HandlerRegistration; - import com.googlecode.mgwt.collection.shared.LightArrayInt; import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent; import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler; +import com.googlecode.mgwt.dom.client.event.tap.TapEvent; +import com.googlecode.mgwt.dom.client.event.tap.TapHandler; import com.googlecode.mgwt.ui.client.MGWT; import com.googlecode.mgwt.ui.client.widget.carousel.CarouselAppearance.CarouselCss; import com.googlecode.mgwt.ui.client.widget.panel.flex.FlexPanel; @@ -59,17 +60,20 @@ */ public class Carousel extends Composite implements HasWidgets, HasSelectionHandlers { - private static class CarouselIndicatorContainer extends Composite { + private class CarouselIndicatorContainer extends Composite { private FlexPanel main; + private FlexPanel container; private final CarouselCss css; private ArrayList indicators; private int selectedIndex; + private boolean handleTapEvent; - public CarouselIndicatorContainer(CarouselCss css, int numberOfPages) { + public CarouselIndicatorContainer(CarouselCss css, int numberOfPages, boolean handleTapEvent) { if (numberOfPages < 0) { throw new IllegalArgumentException(); } this.css = css; + this.handleTapEvent = handleTapEvent; main = new FlexPanel(); initWidget(main); main.setOrientation(Orientation.HORIZONTAL); @@ -77,7 +81,7 @@ public CarouselIndicatorContainer(CarouselCss css, int numberOfPages) { main.addStyleName(this.css.indicatorMain()); - FlexPanel container = new FlexPanel(); + container = new FlexPanel(); container.addStyleName(this.css.indicatorContainer()); container.setOrientation(Orientation.HORIZONTAL); main.add(container); @@ -86,13 +90,45 @@ public CarouselIndicatorContainer(CarouselCss css, int numberOfPages) { selectedIndex = 0; for (int i = 0; i < numberOfPages; i++) { - CarouselIndicator indicator = new CarouselIndicator(css); + CarouselIndicator indicator = new CarouselIndicator(css, i, handleTapEvent); indicators.add(indicator); container.add(indicator); } setSelectedIndex(selectedIndex); } + + public void updateNumberOfPages(int numberOfPages) { + if (numberOfPages > indicators.size()) { + for (int i = indicators.size(); i < numberOfPages; i++) { + CarouselIndicator indicator = new CarouselIndicator(css, i, handleTapEvent); + indicators.add(indicator); + container.add(indicator); + } + } else { + while (numberOfPages < indicators.size()) { + int lastIndex = indicators.size() - 1; + CarouselIndicator indicator = indicators.get(lastIndex); + indicator.clean(); + indicators.remove(lastIndex); + } + } + } + + public void setHandleTapEvent(boolean handleTapEvent) { + if (this.handleTapEvent != handleTapEvent) { + this.handleTapEvent = handleTapEvent; + for (CarouselIndicator indicator : indicators) { + indicator.setHandleTapEvent(handleTapEvent); + } + } + } + + public void clean() { + for (CarouselIndicator indicator : indicators) { + indicator.clean(); + } + } public void setSelectedIndex(int index) { if (indicators.isEmpty()) { @@ -110,15 +146,21 @@ public void setSelectedIndex(int index) { } } - private static class CarouselIndicator extends TouchWidget { + private class CarouselIndicator extends TouchWidget { private final CarouselCss css; + private int index; + private com.google.gwt.event.shared.HandlerRegistration tapHandlerRegistration; - public CarouselIndicator(CarouselCss css) { + public CarouselIndicator(CarouselCss css, int index, boolean handleTapEvent) { this.css = css; + this.index = index; setElement(Document.get().createDivElement()); addStyleName(css.indicator()); + if (handleTapEvent) { + tapHandlerRegistration = addTapHandler(); + } } public void setActive(boolean active) { @@ -128,6 +170,32 @@ public void setActive(boolean active) { removeStyleName(css.indicatorActive()); } } + + public void setHandleTapEvent(boolean handleTapEvent) { + if (!handleTapEvent && tapHandlerRegistration != null) { + tapHandlerRegistration.removeHandler(); + tapHandlerRegistration = null; + } + if (handleTapEvent && tapHandlerRegistration == null) { + tapHandlerRegistration = addTapHandler(); + } + } + + public void clean() { + if (tapHandlerRegistration != null) { + tapHandlerRegistration.removeHandler(); + tapHandlerRegistration = null; + } + } + + private com.google.gwt.event.shared.HandlerRegistration addTapHandler() { + return addTapHandler(new TapHandler() { + @Override + public void onTap(TapEvent event) { + Carousel.this.setSelectedPage(index); + } + }); + } } @UiField @@ -138,6 +206,7 @@ public void setActive(boolean active) { public FlowPanel container; private CarouselIndicatorContainer carouselIndicatorContainer; private boolean isVisibleCarouselIndicator = true; + private boolean supportCarouselIndicatorTap = false; private int currentPage; @@ -151,12 +220,17 @@ public void setActive(boolean active) { private boolean hasScollData; public Carousel() { - this(DEFAULT_APPEARANCE); + this(DEFAULT_APPEARANCE, false); } - + public Carousel(CarouselAppearance appearance) { + this(appearance, false); + } + + public Carousel(CarouselAppearance appearance, boolean supportCarouselIndicatorTap) { this.appearance = appearance; + this.supportCarouselIndicatorTap = supportCarouselIndicatorTap; initWidget(this.appearance.carouselBinder().createAndBindUi(this)); childToHolder = new HashMap(); @@ -240,6 +314,11 @@ public void add(Widget w) { @Override public void clear() { + if (carouselIndicatorContainer != null) { + carouselIndicatorContainer.clean(); + carouselIndicatorContainer.removeFromParent(); + carouselIndicatorContainer = null; + } container.clear(); childToHolder.clear(); } @@ -285,17 +364,15 @@ public void run() { scrollPanel.setShowVerticalScrollBar(false); scrollPanel.setShowHorizontalScrollBar(false); - if (carouselIndicatorContainer != null) { - carouselIndicatorContainer.removeFromParent(); - - } - int widgetCount = container.getWidgetCount(); - carouselIndicatorContainer = new CarouselIndicatorContainer(appearance.cssCarousel(), widgetCount); - - if(isVisibleCarouselIndicator){ - main.add(carouselIndicatorContainer); + if (carouselIndicatorContainer == null) { + carouselIndicatorContainer = new CarouselIndicatorContainer(appearance.cssCarousel(), widgetCount, supportCarouselIndicatorTap); + if(isVisibleCarouselIndicator){ + main.add(carouselIndicatorContainer); + } + } else { + carouselIndicatorContainer.updateNumberOfPages(widgetCount); } if (currentPage >= widgetCount) { @@ -328,7 +405,6 @@ public void onScrollRefresh(ScrollRefreshEvent event) { }.schedule(delay); - } public void setSelectedPage(int index) { @@ -405,18 +481,43 @@ public void adjust(Widget main, FlowPanel container) { * Set if carousel indicator is displayed. */ public void setShowCarouselIndicator(boolean isVisibleCarouselIndicator) { - if (!isVisibleCarouselIndicator && carouselIndicatorContainer != null) { - carouselIndicatorContainer.removeFromParent(); + if (this.isVisibleCarouselIndicator != isVisibleCarouselIndicator && carouselIndicatorContainer != null) { + if (!isVisibleCarouselIndicator) { + carouselIndicatorContainer.removeFromParent(); + } + if (isVisibleCarouselIndicator) { + main.add(carouselIndicatorContainer); + } } this.isVisibleCarouselIndicator = isVisibleCarouselIndicator; } + /** + * Set if carousel indicator support tap events. + */ + public void setSupportCarouselIndicatorTap(boolean supportCarouselIndicatorTap) { + if (supportCarouselIndicatorTap != this.supportCarouselIndicatorTap) { + this.supportCarouselIndicatorTap = supportCarouselIndicatorTap; + carouselIndicatorContainer.setHandleTapEvent(supportCarouselIndicatorTap); + } + } + + /** + * Set if carousel indicator support tap events. + */ + public void setSupportCarouselIndicatorTap(boolean supportCarouselIndicatorTap) { + if (supportCarouselIndicatorTap != this.supportCarouselIndicatorTap) { + this.supportCarouselIndicatorTap = supportCarouselIndicatorTap; + carouselIndicatorContainer.setHandleTapEvent(supportCarouselIndicatorTap); + } + } + public ScrollPanel getScrollPanel() { return scrollPanel; } @UiFactory public CarouselAppearance getAppearance() { - return appearance; + return appearance; } } From 230fb13cc63fc28b3fee2c26ed81bd68cc7222f5 Mon Sep 17 00:00:00 2001 From: Wayne Dyck Date: Tue, 23 Feb 2016 15:16:14 -0800 Subject: [PATCH 48/53] Remove duplicate method setSupportCarouselIndicatorTap(boolean) --- .../mgwt/ui/client/widget/carousel/Carousel.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java index 863650239..cff4e7afb 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/carousel/Carousel.java @@ -492,16 +492,6 @@ public void setShowCarouselIndicator(boolean isVisibleCarouselIndicator) { this.isVisibleCarouselIndicator = isVisibleCarouselIndicator; } - /** - * Set if carousel indicator support tap events. - */ - public void setSupportCarouselIndicatorTap(boolean supportCarouselIndicatorTap) { - if (supportCarouselIndicatorTap != this.supportCarouselIndicatorTap) { - this.supportCarouselIndicatorTap = supportCarouselIndicatorTap; - carouselIndicatorContainer.setHandleTapEvent(supportCarouselIndicatorTap); - } - } - /** * Set if carousel indicator support tap events. */ From abddb09d494a69f984c4a9a94402456cc96eae20 Mon Sep 17 00:00:00 2001 From: Stefano Rova Date: Sun, 14 Feb 2016 17:22:29 +0100 Subject: [PATCH 49/53] =?UTF-8?q?Clear=20the=20=E2=80=98display=E2=80=99?= =?UTF-8?q?=20CSS=20style=20property=20in=20OverlayMenu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OverlayMenu did not clear the ‘display’ style property in the TransitionEndHandler when the menu was show programmatically (i.e. with a overlayMenu.showNav(true);). The ‘display’ property is correctly set to ‘block’ when the showing transaction starts, but if not cleared, the menu content is not visible. --- .../mgwt/ui/client/widget/menu/overlay/OverlayMenu.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/OverlayMenu.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/OverlayMenu.java index 947d15c64..5c99c5e96 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/OverlayMenu.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/menu/overlay/OverlayMenu.java @@ -131,6 +131,7 @@ public void onTransitionEnd(TransitionEndEvent event) { if (showNavHandler != null) { showNavHandler.removeHandler(); showNavHandler = null; + nav.getElement().getStyle().clearDisplay(); } } }, TransitionEndEvent.getType()); From 966bbfed698c63e7ced1e31caaae5b49b58c0f36 Mon Sep 17 00:00:00 2001 From: Wayne Dyck Date: Sat, 27 Feb 2016 09:28:31 -0800 Subject: [PATCH 50/53] Working date picker but not showing placeholder text This is by design. The W3C HTML5 specification does not allow the placeholder attribute on input[type="date"]. http://w3c.github.io/html/sec-forms.html#date-state-typedate --- .../mgwt/ui/client/widget/input/MDateBox.java | 87 +++++++------------ 1 file changed, 31 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java index de73d5928..af2c3f96b 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/MDateBox.java @@ -13,14 +13,17 @@ * License for the specific language governing permissions and limitations under * the License. */ + package com.googlecode.mgwt.ui.client.widget.input; +import java.io.IOException; +import java.text.ParseException; +import java.util.Date; + import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; -import com.google.gwt.event.dom.client.FocusEvent; -import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.i18n.client.DateTimeFormat; @@ -28,14 +31,9 @@ import com.google.gwt.text.shared.Renderer; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.ValueBoxBase; - import com.googlecode.mgwt.ui.client.MGWT; import com.googlecode.mgwt.ui.client.widget.base.MValueBoxBase; -import java.io.IOException; -import java.text.ParseException; -import java.util.Date; - /** * A simple Date input widget. So far it uses <input type="date" /> on iOS with a nice looking * native date picker. @@ -49,10 +47,6 @@ * * On other platforms you can set the format to fit what you like. * - * - * - * @author Daniel Kurka - * */ public class MDateBox extends MValueBoxBase { @@ -164,57 +158,22 @@ public MDateBox(InputAppearance appearance) { addStyleName(appearance.css().textBox()); - // fix ios issue with onchange event + // try and set input type to date + setInputType("date"); - if (MGWT.getOsDetection().isAndroid4_4_OrHigher()) { - // only set input type to date if there is a native picker - impl.setType(box.getElement(), "date"); - // use w3c format + // use w3c format if type set to date + if (isInputTypeDate()) { format = W3C_FORMAT; } - if (MGWT.getOsDetection().isRetina()) { - // IOS needs a workaround for empty date picker - // Since it will not render them properly (iOS7) - format = W3C_FORMAT; - box.addFocusHandler(new FocusHandler() { - - @Override - public void onFocus(FocusEvent event) { - impl.setType(box.getElement(), "date"); - } - }); - - box.addBlurHandler(new BlurHandler() { - - @Override - public void onBlur(BlurEvent event) { - impl.setType(box.getElement(), "text"); - } - }); - } - - if (MGWT.getOsDetection().isIPadRetina() || MGWT.getOsDetection().isIPad()) { - // for iPad workaround does not work - // adding default date, not happy about this - impl.setType(box.getElement(), "date"); - format = W3C_FORMAT; - - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - - @Override - public void execute() { - box.setValue(new Date()); - } - }); - } - - // apply format to parsers getBox().getDateParser().setFormat(format); getBox().getDateRenderer().setFormat(format); if (MGWT.getOsDetection().isIOs()) { + impl.setType(box.getElement(), "date"); + box.setHeight("20px"); + addBlurHandler(new BlurHandler() { @Override @@ -226,10 +185,8 @@ public void execute() { Date value = box.getValue(); ValueChangeEvent.fireIfNotEqual(box, lastValue, value); lastValue = value; - } }); - } }); lastValue = null; @@ -237,6 +194,25 @@ public void execute() { } + /** + * + * @param type + */ + private void setInputType(String type) { + try { + impl.setType(box.getElement(), type); + } catch (Exception e) { + } + } + + /** + * + * @return + */ + private boolean isInputTypeDate() { + return box.getElement().getAttribute("type").equalsIgnoreCase("date"); + } + /** * set the format to use in the datebox. Important: This should only be set on non iOS devices, * since iOS handles locale on dates under the cover. @@ -254,7 +230,6 @@ public void setFormat(String pattern) { getBox().getDateParser().setFormat(format); getBox().getDateRenderer().setFormat(format); - } protected DateValueBoxBase getBox() { From a3925a5df6a00e066daff41fdd9d43205407edec Mon Sep 17 00:00:00 2001 From: Wayne Rasmuss Date: Wed, 30 Mar 2016 21:47:22 -0500 Subject: [PATCH 51/53] Added height:100%. to .mgwt-ScrollPanel css class. I think this is consistent with previous versions of MGWT --- .../mgwt/ui/client/widget/panel/scroll/scrollpanel.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css index 21e49a97f..c73833884 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/scrollpanel.css @@ -8,6 +8,7 @@ position: relative; z-index: 0; width: 100%; + height: 100%; } .mgwt-ScrollPanel-container { From 8c5af7e3a7883d02b57af57750dcc70f51220594 Mon Sep 17 00:00:00 2001 From: hoffmann Date: Tue, 8 Dec 2015 20:39:59 +0100 Subject: [PATCH 52/53] Bug Fix of LongTapRecognizer (incomplete reset led to wrong move detection in onTouchMove) And removing unnecessary semi colon) --- .../mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java index 4b0a64343..f18c2dd87 100644 --- a/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java +++ b/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java @@ -43,7 +43,7 @@ public class LongTapRecognizer implements TouchHandler { protected enum State { INVALID, READY, FINGERS_DOWN, FINGERS_UP, WAITING - }; + } protected State state; private final HasHandlers source; @@ -231,6 +231,7 @@ public void onTouchCancel(TouchCancelEvent event) { protected void reset() { state = State.READY; touchCount = 0; + startPositions = CollectionFactory.constructArray(); } // Visible for testing From 5a5797620d49de59552827462268dfa32be4c1da Mon Sep 17 00:00:00 2001 From: Paul French Date: Thu, 21 Apr 2016 18:20:54 +0100 Subject: [PATCH 53/53] Support mouse and touch simultaneously if required. Make sure for ie edge we always use the pointer model always even though it is currently using the safari permutation. Added another binding property mgwt.pointermodel to avoid adding another user.agent which would have caused a lot of changes in css files where fallbacks do not work. We also stop propagation of mouse events (excluding the gesture event MouseClick) if a touch is in progress. We also stop propagation of mouse events for up to 2 seconds after a touch has completed (this caters for mopping up the compatible mouse events fired by the browser after a touch has completed) Mouse wheel support in the scroll panel is working on IE Edge, however it no longer works on IE 11. This will be raised as a separate issue. --- .../gwt/user/client/impl/DOMImplIE10.java | 8 +- .../client/impl/DOMImplWebkitPointer.java | 52 ++++++ .../java/com/googlecode/mgwt/dom/DOM.gwt.xml | 53 ++++-- .../java/com/googlecode/mgwt/ui/UI.gwt.xml | 26 +-- .../com/googlecode/mgwt/ui/client/MGWT.java | 8 +- .../ui/client/OsDetectionRuntimeImpl.java | 2 +- .../mgwt/ui/client/TouchSupport.java | 100 ----------- .../ui/client/widget/button/ButtonBase.java | 10 +- .../widget/input/checkbox/MCheckBox.java | 10 +- .../ui/client/widget/input/slider/Slider.java | 10 +- .../scroll/impl/ScrollPanelTouchImpl.java | 14 +- .../ui/client/widget/touch/TouchSupport.java | 157 ++++++++++++++++++ .../ui/client/widget/touch/TouchWidget.java | 7 - ...java => TouchWidgetMouseAndTouchImpl.java} | 61 ++++--- .../widget/touch/TouchWidgetPointerImpl.java | 3 + ...mpl.java => TouchWidgetTouchOnlyImpl.java} | 7 +- 16 files changed, 330 insertions(+), 198 deletions(-) create mode 100644 src/main/java/com/google/gwt/user/client/impl/DOMImplWebkitPointer.java delete mode 100644 src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java create mode 100644 src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchSupport.java rename src/main/java/com/googlecode/mgwt/ui/client/widget/touch/{TouchWidgetStandardImpl.java => TouchWidgetMouseAndTouchImpl.java} (58%) rename src/main/java/com/googlecode/mgwt/ui/client/widget/touch/{TouchWidgetTouchImpl.java => TouchWidgetTouchOnlyImpl.java} (91%) diff --git a/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java index 65c5d5204..3cdaa07c4 100644 --- a/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java +++ b/src/main/java/com/google/gwt/user/client/impl/DOMImplIE10.java @@ -31,14 +31,14 @@ public class DOMImplIE10 extends DOMImplIE9 { /** * Lets have the same behaviour as IOS where the target element continues to receive Pointer events - * even when the pointer has moved off the element up until MSPointerUp has occurred. + * even when the pointer has moved off the element up until PointerUp has occurred. * * Do not do pointer capture on input or textarea elements, all sorts of problems arise if you do! * For example if you type into a password field you cannot set the cursor to the end of * the text when re-entering it and so you cannot edit your password */ private native static void capturePointerEvents() /*-{ - if ($wnd.navigator.pointerEnabled) { + if ($wnd.PointerEvent) { $wnd.addEventListener('pointerdown', $entry(function(evt) { if ((evt.target.tagName !== 'INPUT') && (evt.target.tagName !== 'TEXTAREA')) { @@ -58,7 +58,7 @@ private native static void capturePointerEvents() /*-{ public static native JavaScriptObject getCaptureEventDispatchers() /*-{ - if ($wnd.navigator.pointerEnabled) { + if ($wnd.PointerEvent) { return { pointerdown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), pointerup: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), @@ -77,7 +77,7 @@ public static native JavaScriptObject getCaptureEventDispatchers() /*-{ }-*/; public static native JavaScriptObject getBitlessEventDispatchers() /*-{ - if ($wnd.navigator.pointerEnabled) { + if ($wnd.PointerEvent) { return { pointerdown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), pointerup: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), diff --git a/src/main/java/com/google/gwt/user/client/impl/DOMImplWebkitPointer.java b/src/main/java/com/google/gwt/user/client/impl/DOMImplWebkitPointer.java new file mode 100644 index 000000000..153a0be63 --- /dev/null +++ b/src/main/java/com/google/gwt/user/client/impl/DOMImplWebkitPointer.java @@ -0,0 +1,52 @@ +package com.google.gwt.user.client.impl; + +import com.google.gwt.core.client.JavaScriptObject; + +/** + * Required by Safari permutation using pointer event model e.g. IEEdge + */ +public class DOMImplWebkitPointer extends DOMImplWebkit +{ + static { + DOMImplStandard.addCaptureEventDispatchers(getCaptureEventDispatchers()); + DOMImplStandard.addBitlessEventDispatchers(getBitlessEventDispatchers()); + capturePointerEvents(); + } + + /** + * Lets have the same behaviour as IOS where the target element continues to receive Pointer events + * even when the pointer has moved off the element up until PointerUp has occurred. + * + * Do not do pointer capture on input or textarea elements, all sorts of problems arise if you do! + * For example if you type into a password field you cannot set the cursor to the end of + * the text when re-entering it and so you cannot edit your password + */ + private native static void capturePointerEvents() /*-{ + $wnd.addEventListener('pointerdown', + $entry(function(evt) { + if ((evt.target.tagName !== 'INPUT') && (evt.target.tagName !== 'TEXTAREA')) { + evt.target.setPointerCapture(evt.pointerId); + } + }), true); + }-*/; + + + public static native JavaScriptObject getCaptureEventDispatchers() /*-{ + return { + pointerdown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + pointerup: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + pointermove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*), + pointercancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent(*) + }; + }-*/; + + public static native JavaScriptObject getBitlessEventDispatchers() /*-{ + return { + pointerdown: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + pointerup: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + pointermove: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*), + pointercancel: @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent(*) + }; + }-*/; + +} diff --git a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml index 5ab7fc375..530aaff61 100644 --- a/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml @@ -16,13 +16,32 @@ */ --> - - - - + + + + + + - - + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + diff --git a/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml b/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml index b168089c0..d2687ed6c 100644 --- a/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml +++ b/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml @@ -61,21 +61,21 @@ under * the License. - + - + - + - - + + @@ -116,21 +116,21 @@ under * the License. - - + + - - + + - + - - + + - + diff --git a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java index ae23acc35..6ff781e81 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/MGWT.java @@ -40,6 +40,7 @@ import com.googlecode.mgwt.ui.client.util.OrientationHandler; import com.googlecode.mgwt.ui.client.widget.main.IOS71BodyBug; import com.googlecode.mgwt.ui.client.widget.main.MainResourceHolder; +import com.googlecode.mgwt.ui.client.widget.touch.TouchSupport; /** * The MGWT Object is used to apply settings for an MGWT App. It also provides an instance of @@ -167,9 +168,14 @@ public static void applySettings(MGWTSettings settings) { if (settings.isPreventScrolling() && getOsDetection().isIOs()) { BodyElement body = Document.get().getBody(); setupPreventScrolling(body); - } + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents() && TouchSupport.isTouchEventsSupported()) { + // we cancel mouse events on devices that might support touch and a native + // touch is in progress + TouchSupport.cancelMouseEventsDuringTouch(); + } + if (settings.isDisablePhoneNumberDetection()) { MetaElement fullScreenMetaTag = Document.get().createMetaElement(); fullScreenMetaTag.setName("format-detection"); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java index e00e3a2a7..9d9860511 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/OsDetectionRuntimeImpl.java @@ -158,7 +158,7 @@ public boolean isAndroid4_3_orLower() { private boolean isIEEdge(String userAgent) { - if (userAgent.contains("edge/12")) { + if (userAgent.contains("edge/")) { return true; } return false; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java b/src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java deleted file mode 100644 index cf70e7c73..000000000 --- a/src/main/java/com/googlecode/mgwt/ui/client/TouchSupport.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.googlecode.mgwt.ui.client; - -import com.google.gwt.core.shared.GWT; - -public abstract class TouchSupport { - - private static TouchSupport impl = GWT.create(TouchSupport.class); - - protected abstract boolean _isTouchEventsEmulatedUsingMouseEvents(); - - protected abstract boolean _isTouchEventsEmulatedUsingPointerEvents(); - - protected abstract boolean _isTouchEventsSupported(); - - public static boolean isTouchEventsEmulatedUsingMouseEvents() { - return impl._isTouchEventsEmulatedUsingMouseEvents(); - } - - public static boolean isTouchEventsEmulatedUsingPointerEvents() { - return impl._isTouchEventsEmulatedUsingPointerEvents(); - } - - public static boolean isTouchEventsSupported() { - return impl._isTouchEventsSupported(); - } - - public static class TouchSupportStandard extends TouchSupport { - - private static boolean hasTouchSupport; - private static TouchSupport delegate; - - static { - hasTouchSupport = hasTouch(); - if (hasTouchSupport) { - delegate = new TouchSupportNative(); - } - } - - private static native boolean hasTouch() /*-{ - return 'ontouchstart' in $doc.documentElement; - }-*/; - - - @Override - protected boolean _isTouchEventsEmulatedUsingMouseEvents() { - if (hasTouchSupport) { - return delegate._isTouchEventsEmulatedUsingMouseEvents(); - } - return true; - } - - @Override - protected boolean _isTouchEventsEmulatedUsingPointerEvents() { - return false; - } - - @Override - protected boolean _isTouchEventsSupported() { - if (hasTouchSupport) { - return delegate._isTouchEventsSupported(); - } - return false; - } - } - - public static class TouchSupportEmulatedPointer extends TouchSupport { - @Override - protected boolean _isTouchEventsEmulatedUsingMouseEvents() { - return false; - } - - @Override - protected boolean _isTouchEventsEmulatedUsingPointerEvents() { - return true; - } - - @Override - protected boolean _isTouchEventsSupported() { - return false; - } - } - - public static class TouchSupportNative extends TouchSupport { - @Override - protected boolean _isTouchEventsEmulatedUsingMouseEvents() { - return false; - } - - @Override - protected boolean _isTouchEventsEmulatedUsingPointerEvents() { - return false; - } - - @Override - protected boolean _isTouchEventsSupported() { - return true; - } - } - -} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java index 9e1fe8e90..34ee61616 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/button/ButtonBase.java @@ -20,10 +20,11 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.HasText; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent; import com.googlecode.mgwt.dom.client.event.tap.TapEvent; import com.googlecode.mgwt.dom.client.event.tap.TapHandler; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.widget.touch.TouchWidget; /** @@ -76,9 +77,6 @@ public void onTouchCancel(TouchCancelEvent event) { event.stopPropagation(); event.preventDefault(); removeStyleName(ButtonBase.this.baseAppearance.css().active()); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { - DOM.releaseCapture(getElement()); - } active = false; } @@ -87,7 +85,7 @@ public void onTouchEnd(TouchEndEvent event) { event.stopPropagation(); event.preventDefault(); removeStyleName(ButtonBase.this.baseAppearance.css().active()); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (event instanceof SimulatedTouchEndEvent) { DOM.releaseCapture(getElement()); } active = false; @@ -104,7 +102,7 @@ public void onTouchStart(TouchStartEvent event) { event.stopPropagation(); event.preventDefault(); addStyleName(ButtonBase.this.baseAppearance.css().active()); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (event instanceof SimulatedTouchStartEvent) { DOM.setCapture(getElement()); } active = true; diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java index c173c9f63..89c43984d 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/checkbox/MCheckBox.java @@ -31,8 +31,9 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.HasValue; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.util.CssUtil; import com.googlecode.mgwt.ui.client.widget.touch.TouchWidget; @@ -60,9 +61,6 @@ public void onTouchCancel(TouchCancelEvent event) { } event.stopPropagation(); event.preventDefault(); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { - DOM.releaseCapture(getElement()); - } setValue(getValue()); } @@ -75,7 +73,7 @@ public void onTouchEnd(TouchEndEvent event) { event.stopPropagation(); event.preventDefault(); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (event instanceof SimulatedTouchEndEvent) { DOM.releaseCapture(getElement()); } @@ -123,7 +121,7 @@ public void onTouchStart(TouchStartEvent event) { active = true; event.stopPropagation(); event.preventDefault(); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (event instanceof SimulatedTouchStartEvent) { DOM.setCapture(getElement()); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java index 94c239d73..9b1fc0619 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/input/slider/Slider.java @@ -30,8 +30,9 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent; +import com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.util.CssUtil; import com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl; @@ -49,7 +50,7 @@ private class SliderTouchHandler implements TouchHandler { @Override public void onTouchStart(TouchStartEvent event) { setValueContrained(event.getTouches().get(0).getClientX()); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (event instanceof SimulatedTouchStartEvent) { DOM.setCapture(getElement()); } active = true; @@ -68,7 +69,7 @@ public void onTouchMove(TouchMoveEvent event) { @Override public void onTouchEnd(TouchEndEvent event) { - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (event instanceof SimulatedTouchEndEvent) { DOM.releaseCapture(getElement()); } event.stopPropagation(); @@ -78,9 +79,6 @@ public void onTouchEnd(TouchEndEvent event) { @Override public void onTouchCancel(TouchCancelEvent event) { - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { - DOM.releaseCapture(getElement()); - } active = false; } } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java index 68c154553..bdf1346a5 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/panel/scroll/impl/ScrollPanelTouchImpl.java @@ -1,5 +1,8 @@ package com.googlecode.mgwt.ui.client.widget.panel.scroll.impl; +import java.util.Iterator; +import java.util.logging.Logger; + import com.google.gwt.animation.client.AnimationScheduler; import com.google.gwt.animation.client.AnimationScheduler.AnimationCallback; import com.google.gwt.animation.client.AnimationScheduler.AnimationHandle; @@ -45,7 +48,6 @@ import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; import com.googlecode.mgwt.ui.client.MGWT; -import com.googlecode.mgwt.ui.client.TouchSupport; import com.googlecode.mgwt.ui.client.util.CssUtil; import com.googlecode.mgwt.ui.client.widget.panel.scroll.BeforeScrollEndEvent; import com.googlecode.mgwt.ui.client.widget.panel.scroll.BeforeScrollMoveEvent; @@ -60,9 +62,7 @@ import com.googlecode.mgwt.ui.client.widget.panel.scroll.ScrollRefreshEvent; import com.googlecode.mgwt.ui.client.widget.panel.scroll.ScrollStartEvent; import com.googlecode.mgwt.ui.client.widget.touch.TouchDelegate; - -import java.util.Iterator; -import java.util.logging.Logger; +import com.googlecode.mgwt.ui.client.widget.touch.TouchSupport; public class ScrollPanelTouchImpl extends ScrollPanelImpl { @@ -1585,7 +1585,7 @@ public void setWidget(Widget w) { // clear old event handlers unbindStartEvent(); unbindResizeEvent(); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents() || TouchSupport.isTouchEventsEmulatedUsingPointerEvents()) { unbindMouseoutEvent(); unbindMouseWheelEvent(); } @@ -1605,7 +1605,7 @@ public void setWidget(Widget w) { if (isAttached()) { bindResizeEvent(); bindStartEvent(); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents() || TouchSupport.isTouchEventsEmulatedUsingPointerEvents()) { bindMouseoutEvent(); bindMouseWheelEvent(); } @@ -1639,7 +1639,7 @@ protected void onAttach() { // bind events bindResizeEvent(); bindStartEvent(); - if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents()) { + if (TouchSupport.isTouchEventsEmulatedUsingMouseEvents() || TouchSupport.isTouchEventsEmulatedUsingPointerEvents()) { bindMouseoutEvent(); bindMouseWheelEvent(); } diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchSupport.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchSupport.java new file mode 100644 index 000000000..bb28fa1d8 --- /dev/null +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchSupport.java @@ -0,0 +1,157 @@ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.core.shared.GWT; + +public abstract class TouchSupport { + + private static TouchSupport impl = GWT.create(TouchSupport.class); + + private static final boolean hasTouchSupport; + + static { + hasTouchSupport = hasTouch(); + } + + /** + * If true this means the client could support touch but + * the device it runs on may not support touch. + * If false then it means the client does not support touch. + * @return + */ + private static native boolean hasTouch() /*-{ + return 'ontouchstart' in $doc.documentElement; + }-*/; + + protected abstract boolean _isTouchEventsEmulatedUsingMouseEvents(); + + protected abstract boolean _isTouchEventsEmulatedUsingPointerEvents(); + + protected abstract boolean _isTouchEventsSupported(); + + /** + * Some devices support both touch and mouse simultaneously so a touch event maybe a + * real touch event or a simulated one + * @return + */ + public static boolean isTouchEventsEmulatedUsingMouseEvents() { + return impl._isTouchEventsEmulatedUsingMouseEvents(); + } + + public static boolean isTouchEventsEmulatedUsingPointerEvents() { + return impl._isTouchEventsEmulatedUsingPointerEvents(); + } + + public static boolean isTouchEventsSupported() { + return impl._isTouchEventsSupported(); + } + + /** + * Touch is emulated via mouse events but the device may also support native touch events + */ + public static class TouchSupportMouseAndTouch extends TouchSupport { + + @Override + protected boolean _isTouchEventsEmulatedUsingMouseEvents() { + return true; + } + + @Override + protected boolean _isTouchEventsEmulatedUsingPointerEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsSupported() { + return hasTouchSupport; + } + } + + /** + * Browser uses pointer model and so touch is emulated via pointer events + */ + public static class TouchSupportEmulatedPointer extends TouchSupport { + @Override + protected boolean _isTouchEventsEmulatedUsingMouseEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsEmulatedUsingPointerEvents() { + return true; + } + + @Override + protected boolean _isTouchEventsSupported() { + return false; + } + } + + /** + * We believe device has touch support only - we assume this is the case + * for phones only + */ + public static class TouchSupportTouchOnly extends TouchSupport { + @Override + protected boolean _isTouchEventsEmulatedUsingMouseEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsEmulatedUsingPointerEvents() { + return false; + } + + @Override + protected boolean _isTouchEventsSupported() { + return true; + } + } + + /** + * Only setup if touch and mouse could be supported. For example, for phones we assume only + * touch is supported but this may change in time?? + * We need to cater for devices that support both touch and mouse + * where we need to stopPropagation mouse events (except for a mouse click since a gesture) + * when a touch is in progress so we do not call our touch handlers twice. Compatible mouse events + * can be fired after a touch event completes so we cancel these events as well by cancelling all + * mouse events for specified time period e.g. 2 seconds, after the touch completes + */ + public static native void cancelMouseEventsDuringTouch() /*-{ + var cancelMouseEvents = false; + var timerRunning = false; + + var touchStart = function(event) { + cancelMouseEvents = true; + } + + var timerFunction = function() { + cancelMouseEvents = false; + timerRunning = false; + }; + + var touchEndCancel = function(event) { + if (!timerRunning && event.touches.length == 0) { + timerRunning = true; + $wnd.setTimeout(timerFunction,2000); + } + } + + var maybeCancel = function(event) { + if (cancelMouseEvents == true) { + event.stopPropagation(); + } + } + + $doc.body.addEventListener("touchstart", touchStart, true); + $doc.body.addEventListener("touchend", touchEndCancel, true); + $doc.body.addEventListener("touchcancel", touchEndCancel, true); + + $doc.body.addEventListener("mousedown", maybeCancel, true); + $doc.body.addEventListener("mousemove", maybeCancel, true); + $doc.body.addEventListener("mouseup", maybeCancel, true); + $doc.body.addEventListener("mouseover", maybeCancel, true); + $doc.body.addEventListener("mouseout", maybeCancel, true); + }-*/; + + +} diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java index 5f3cf4a02..11fd80fc2 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java @@ -82,13 +82,6 @@ public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { @Override public HandlerRegistration addTouchHandler(TouchHandler handler) { return impl.addTouchHandler(this, handler); -// HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); -// -// handlerRegistrationCollection.addHandlerRegistration(addTouchCancelHandler(handler)); -// handlerRegistrationCollection.addHandlerRegistration(addTouchStartHandler(handler)); -// handlerRegistrationCollection.addHandlerRegistration(addTouchEndHandler(handler)); -// handlerRegistrationCollection.addHandlerRegistration(addTouchMoveHandler(handler)); -// return handlerRegistrationCollection; } @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetMouseAndTouchImpl.java similarity index 58% rename from src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java rename to src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetMouseAndTouchImpl.java index 8ad849b1b..810e6c1e9 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetStandardImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetMouseAndTouchImpl.java @@ -29,47 +29,42 @@ import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; import com.googlecode.mgwt.ui.client.util.NoopHandlerRegistration; -public class TouchWidgetStandardImpl implements TouchWidgetImpl +/** + * Supports mouse but also supports Touch simultaneously if touch possibly supported + */ +public class TouchWidgetMouseAndTouchImpl implements TouchWidgetImpl { - private static boolean hasTouchSupport; - private static TouchWidgetImpl delegate; - - static { - hasTouchSupport = hasTouch(); - if (hasTouchSupport) { - delegate = new TouchWidgetTouchImpl(); - } - } - - private static native boolean hasTouch() /*-{ - return 'ontouchstart' in $doc.documentElement; - }-*/; - + private static final TouchWidgetImpl delegate = new TouchWidgetTouchOnlyImpl(); @Override public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchStartHandler(w, handler); + if (TouchSupport.isTouchEventsSupported()) { + HandlerRegistrationCollection handlerRegistrations = new HandlerRegistrationCollection(); + handlerRegistrations.addHandlerRegistration(delegate.addTouchStartHandler(w, handler)); + handlerRegistrations.addHandlerRegistration(w.addDomHandler(new TouchStartToMouseDownHandler(handler), MouseDownEvent.getType())); + return handlerRegistrations; + } + else { + return w.addDomHandler(new TouchStartToMouseDownHandler(handler), MouseDownEvent.getType()); } - return w.addDomHandler(new TouchStartToMouseDownHandler(handler), MouseDownEvent.getType()); } @Override public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchMoveHandler(w, handler); + HandlerRegistrationCollection handlerRegistrations = new HandlerRegistrationCollection(); + if (TouchSupport.isTouchEventsSupported()) { + handlerRegistrations.addHandlerRegistration(delegate.addTouchMoveHandler(w, handler)); } TouchMoveToMouseMoveHandler touchMoveToMouseMoveHandler = new TouchMoveToMouseMoveHandler(handler); - HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); - handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseDownEvent.getType())); - handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseUpEvent.getType())); - handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseMoveEvent.getType())); - return handlerRegistrationCollection; + handlerRegistrations.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseDownEvent.getType())); + handlerRegistrations.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseUpEvent.getType())); + handlerRegistrations.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseMoveEvent.getType())); + return handlerRegistrations; } @Override public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { - if (hasTouchSupport) { + if (TouchSupport.isTouchEventsSupported()) { return delegate.addTouchCancelHandler(w, handler); } return new NoopHandlerRegistration(); @@ -77,17 +72,19 @@ public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler ha @Override public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchEndHandler(w, handler); + if (TouchSupport.isTouchEventsSupported()) { + HandlerRegistrationCollection handlerRegistrations = new HandlerRegistrationCollection(); + handlerRegistrations.addHandlerRegistration(delegate.addTouchEndHandler(w, handler)); + handlerRegistrations.addHandlerRegistration(w.addDomHandler(new TouchEndToMouseUpHandler(handler), MouseUpEvent.getType())); + return handlerRegistrations; + } + else { + return w.addDomHandler(new TouchEndToMouseUpHandler(handler), MouseUpEvent.getType()); } - return w.addDomHandler(new TouchEndToMouseUpHandler(handler), MouseUpEvent.getType()); } @Override public HandlerRegistration addTouchHandler(Widget w, TouchHandler handler) { - if (hasTouchSupport) { - return delegate.addTouchHandler(w, handler); - } HandlerRegistrationCollection hrc = new HandlerRegistrationCollection(); hrc.addHandlerRegistration(addTouchStartHandler(w, handler)); hrc.addHandlerRegistration(addTouchMoveHandler(w, handler)); diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java index caca84519..e0d3423ff 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetPointerImpl.java @@ -30,6 +30,9 @@ import com.googlecode.mgwt.dom.client.event.pointer.TouchStartToMsPointerDownHandler; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +/** + * Supports pointer model only + */ public class TouchWidgetPointerImpl implements TouchWidgetImpl { @Override diff --git a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchOnlyImpl.java similarity index 91% rename from src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java rename to src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchOnlyImpl.java index 5fe946287..58d7dca0d 100644 --- a/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchImpl.java +++ b/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetTouchOnlyImpl.java @@ -26,7 +26,10 @@ import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; -public class TouchWidgetTouchImpl implements TouchWidgetImpl +/** + * Supports Touch only (does not support mouse) i.e. mostly phones + */ +public class TouchWidgetTouchOnlyImpl implements TouchWidgetImpl { @Override public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { @@ -44,7 +47,7 @@ public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler ha } @Override - public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { + public HandlerRegistration addTouchEndHandler(Widget w, final TouchEndHandler handler) { return w.addDomHandler(handler, TouchEndEvent.getType()); }