Search in sources :

Example 1 with AnimationCallback

use of com.google.gwt.layout.client.Layout.AnimationCallback in project rstudio by rstudio.

the class HistoryPane method animate.

private void animate(final Widget from, final Widget to, boolean rightToLeft, final HasHistory fromFocus, final HasHistory toFocus, final boolean focus) {
    assert from != to;
    if (focus)
        toFocus.getFocusTarget().addClassName(styles_.inboundFocus());
    setVisible(to, toFocus.getFocusTarget(), true);
    int width = getOffsetWidth();
    mainPanel_.setWidgetLeftWidth(from, 0, Unit.PX, width, Unit.PX);
    mainPanel_.setWidgetLeftWidth(to, rightToLeft ? width : -width, Unit.PX, width, Unit.PX);
    mainPanel_.forceLayout();
    mainPanel_.setWidgetLeftWidth(from, rightToLeft ? -width : width, Unit.PX, width, Unit.PX);
    mainPanel_.setWidgetLeftWidth(to, 0, Unit.PX, width, Unit.PX);
    mainPanel_.animate(300, new AnimationCallback() {

        public void onAnimationComplete() {
            setVisible(from, fromFocus.getFocusTarget(), false);
            mainPanel_.setWidgetLeftRight(to, 0, Unit.PX, 0, Unit.PX);
            mainPanel_.forceLayout();
            if (focus) {
                DomUtils.setActive(toFocus.getFocusTarget());
                toFocus.getFocusTarget().removeClassName(styles_.inboundFocus());
            }
        }

        public void onLayout(Layer layer, double progress) {
        }
    });
}
Also used : AnimationCallback(com.google.gwt.layout.client.Layout.AnimationCallback) Layer(com.google.gwt.layout.client.Layout.Layer)

Example 2 with AnimationCallback

use of com.google.gwt.layout.client.Layout.AnimationCallback in project rstudio by rstudio.

the class ConnectionsPane method transitionMainPanel.

private void transitionMainPanel(final Widget from, final Widget to, boolean rightToLeft, boolean animate, final Command onComplete) {
    assert from != to;
    int width = getOffsetWidth();
    mainPanel_.setWidgetLeftWidth(from, 0, Unit.PX, width, Unit.PX);
    mainPanel_.setWidgetLeftWidth(to, rightToLeft ? width : -width, Unit.PX, width, Unit.PX);
    mainPanel_.forceLayout();
    mainPanel_.setWidgetLeftWidth(from, rightToLeft ? -width : width, Unit.PX, width, Unit.PX);
    mainPanel_.setWidgetLeftWidth(to, 0, Unit.PX, width, Unit.PX);
    to.setVisible(true);
    from.setVisible(true);
    final Command completeLayout = new Command() {

        @Override
        public void execute() {
            mainPanel_.setWidgetLeftRight(to, 0, Unit.PX, 0, Unit.PX);
            from.setVisible(false);
            mainPanel_.forceLayout();
            onComplete.execute();
        }
    };
    if (animate) {
        mainPanel_.animate(300, new AnimationCallback() {

            public void onAnimationComplete() {
                completeLayout.execute();
            }

            public void onLayout(Layer layer, double progress) {
            }
        });
    } else {
        completeLayout.execute();
    }
}
Also used : Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) AnimationCallback(com.google.gwt.layout.client.Layout.AnimationCallback) Layer(com.google.gwt.layout.client.Layout.Layer)

Example 3 with AnimationCallback

use of com.google.gwt.layout.client.Layout.AnimationCallback in project rstudio by rstudio.

the class Wizard method animate.

private void animate(final Widget from, final Widget to, boolean rightToLeft, final Command onCompleted) {
    // protect against multiple calls
    if (isAnimating_)
        return;
    bodyPanel_.setWidgetVisible(to, true);
    int width = getOffsetWidth();
    bodyPanel_.setWidgetLeftWidth(from, 0, Unit.PX, width, Unit.PX);
    bodyPanel_.setWidgetLeftWidth(to, rightToLeft ? width : -width, Unit.PX, width, Unit.PX);
    bodyPanel_.forceLayout();
    bodyPanel_.setWidgetLeftWidth(from, rightToLeft ? -width : width, Unit.PX, width, Unit.PX);
    bodyPanel_.setWidgetLeftWidth(to, 0, Unit.PX, width, Unit.PX);
    isAnimating_ = true;
    bodyPanel_.animate(300, new AnimationCallback() {

        @Override
        public void onAnimationComplete() {
            bodyPanel_.setWidgetVisible(from, false);
            bodyPanel_.setWidgetLeftRight(to, 0, Unit.PX, 0, Unit.PX);
            bodyPanel_.forceLayout();
            isAnimating_ = false;
            onCompleted.execute();
        }

        @Override
        public void onLayout(Layer layer, double progress) {
        }
    });
}
Also used : AnimationCallback(com.google.gwt.layout.client.Layout.AnimationCallback) Layer(com.google.gwt.layout.client.Layout.Layer)

Example 4 with AnimationCallback

use of com.google.gwt.layout.client.Layout.AnimationCallback in project gwt-test-utils by gwt-test-utils.

the class LayoutPanelTest method animate.

@Test
public void animate() {
    // Given
    AnimationCallback callback = new AnimationCallback() {

        public void onAnimationComplete() {
            onAnimationComplete = true;
        }

        public void onLayout(Layer layer, double progress) {
        // never called in gwt-test-utils
        }
    };
    // When
    panel.animate(4, callback);
    // Then
    assertThat(onAnimationComplete).isTrue();
}
Also used : AnimationCallback(com.google.gwt.layout.client.Layout.AnimationCallback) Layer(com.google.gwt.layout.client.Layout.Layer) Test(org.junit.Test)

Aggregations

AnimationCallback (com.google.gwt.layout.client.Layout.AnimationCallback)4 Layer (com.google.gwt.layout.client.Layout.Layer)4 Command (com.google.gwt.user.client.Command)1 Test (org.junit.Test)1 AppCommand (org.rstudio.core.client.command.AppCommand)1