/*
 * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.lttng.scope.tmf2.views.ui.timeline.widgets.timegraph;

import org.eclipse.jdt.annotation.Nullable;

import javafx.animation.FadeTransition;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;

class LoadingOverlay extends Rectangle {

    private final DebugOptions fOpts;

    private @Nullable FadeTransition fCurrentFadeIn;
    private @Nullable FadeTransition fCurrentFadeOut;

    public LoadingOverlay(DebugOptions opts) {
        fOpts = opts;

        setFill(fOpts.loadingOverlayColor.get());
        setOpacity(fOpts.loadingOverlayTransparentOpacity.get());

        /*
         * The overlay should not catch mouse events. Note we could use
         * .setPickOnBounds(false) if we wanted to handle events but also allow
         * them to go "through".
         */
        setMouseTransparent(true);
    }

    public synchronized void fadeIn() {
        if (fCurrentFadeIn != null) {
            /* We're already fading in, let it continue. */
            return;
        }
        if (fCurrentFadeOut != null) {
            /*
             * Don't use stop() because that would revert to the initial opacity
             * right away.
             */
            fCurrentFadeOut.pause();
            fCurrentFadeOut = null;
        }

        double fullOpacity = fOpts.loadingOverlayFullOpacity.get();
        double fullFadeInDuration = fOpts.loadingOverlayFadeInDuration.get();
        double startOpacity = getOpacity();

        /* Do a rule-of-three to determine the duration of fade-in we need. */
        double neededDuration = ((fullOpacity - startOpacity) / fullOpacity) * fullFadeInDuration;
        FadeTransition fadeIn = new FadeTransition(new Duration(neededDuration), this);
        fadeIn.setFromValue(startOpacity);
        fadeIn.setToValue(fullOpacity);
        fadeIn.play();
        fCurrentFadeIn = fadeIn;
    }

    public synchronized void fadeOut() {
        if (fCurrentFadeOut != null) {
            /* We're already fading out, let it continue. */
            return;
        }
        if (fCurrentFadeIn != null) {
            fCurrentFadeIn.pause();
            fCurrentFadeIn = null;
        }

        double fullOpacity = fOpts.loadingOverlayFullOpacity.get();
        double transparentOpacity = fOpts.loadingOverlayTransparentOpacity.get();
        double fullFadeOutDuration = fOpts.loadingOverlayFadeOutDuration.get();
        double startOpacity = getOpacity();

        /* Do a rule-of-three to determine the duration of fade-in we need. */
        double neededDuration = (startOpacity / fullOpacity) * fullFadeOutDuration;
        FadeTransition fadeOut = new FadeTransition(new Duration(neededDuration), this);
        fadeOut.setFromValue(startOpacity);
        fadeOut.setToValue(transparentOpacity);
        fadeOut.play();
        fCurrentFadeOut = fadeOut;
    }

}

@@ -825,49 +825,480 @@
     
-setFill(fOpts.loadingOverlayColor.get());
+/*%0A         * Set the fill (color) by binding the property to the corresponding%0A         * config option. That way if the use changes the configured value, this%0A         * overlay will follow.%0A         */%0A        fillProperty().bind(fOpts.loadingOverlayColor);%0A%0A        /*%0A         * The opacity property on the other hand will change through normal%0A         * operation of the overlay. We are just setting the initial value here,%0A         * no permanent bind.%0A         */
 %0A   

Use a property bind for the overlay color