Ejemplo n.º 1
0
 void updateOpacityForDisabledWidgets()
 {
     float const opac = (self().isDisabled()? .3f : 1.f);
     if (opacityWhenDisabled.target() != opac)
     {
         opacityWhenDisabled.setValue(opac, .3f);
     }
     if (firstUpdateAfterCreation ||
        !attribs.testFlag(AnimateOpacityWhenEnabledOrDisabled))
     {
         opacityWhenDisabled.finish();
     }
 }
Ejemplo n.º 2
0
    void drawBlurredBackground()
    {
        if (background.type == Background::SharedBlur ||
            background.type == Background::SharedBlurWithBorderGlow)
        {
            // Use another widget's blur.
            DENG2_ASSERT(background.blur != 0);
            if (background.blur)
            {
                background.blur->drawBlurredRect(self().rule().recti(), background.solidFill);
            }
            return;
        }

        if (background.type != Background::Blurred &&
            background.type != Background::BlurredWithBorderGlow &&
            background.type != Background::BlurredWithSolidFill)
        {
            deinitBlur();
            return;
        }

        // Make sure blurring is initialized.
        initBlur();

        DENG2_ASSERT(blur->fb[0]->isReady());

        // Pass 1: render all the widgets behind this one onto the first blur
        // texture, downsampled.
        GLState::push()
                .setTarget(*blur->fb[0])
                .setViewport(Rectangleui::fromSize(blur->size));
        blur->fb[0]->clear(GLFramebuffer::Depth);
        self().root().drawUntil(self());
        GLState::pop();

        blur->fb[0]->resolveSamples();

        // Pass 2: apply the horizontal blur filter to draw the background
        // contents onto the second blur texture.
        GLState::push()
                .setTarget(*blur->fb[1])
                .setViewport(Rectangleui::fromSize(blur->size));
        blur->uTex = blur->fb[0]->colorTexture();
        blur->uMvpMatrix = Matrix4f::ortho(0, 1, 0, 1);
        blur->uWindow = Vector4f(0, 0, 1, 1);
        blur->drawable.setProgram(blur->drawable.program());
        blur->drawable.draw();
        GLState::pop();

        blur->fb[1]->resolveSamples();

        // Pass 3: apply the vertical blur filter, drawing the final result
        // into the original target.
        Vector4f blurColor = background.solidFill;
        float blurOpacity  = self().visibleOpacity();
        if (background.type == Background::BlurredWithSolidFill)
        {
            blurColor.w = 1;
        }
        if (!attribs.testFlag(DontDrawContent) && blurColor.w > 0 && blurOpacity > 0)
        {
            self().drawBlurredRect(self().rule().recti(), blurColor, blurOpacity);
        }
    }