Esempio n. 1
0
void Layer::beginClip( View *view, Renderer *ren )
{
	Rectf viewWorldBounds = view->getWorldBounds();
	vec2 lowerLeft = viewWorldBounds.getLowerLeft();
	if( mRootView->mRendersToFrameBuffer ) {
		// get bounds of view relative to framebuffer. // TODO: need a method like convertPointToView( view, point );
		Rectf frameBufferWorldBounds = mRootView->getWorldBounds();
 		Rectf viewBoundsInFrameBuffer = viewWorldBounds - frameBufferWorldBounds.getUpperLeft();

		// Take lower left relative to FrameBuffer, which might actually be larger than mFrameBufferBounds
		lowerLeft = viewBoundsInFrameBuffer.getLowerLeft();
		lowerLeft.y = mFrameBuffer->getHeight() - lowerLeft.y;

		// TODO: reason through if this makes sense in general
		// - needed to add it when rendering to virtual canvas but stroked rect went beyond borders
		lowerLeft.y += mFrameBufferBounds.y1;
	}
	else {
		// rendering to window, flip y relative to Graph's bottom left using its clipping size
		ivec2 clippingSize = mRootView->getGraph()->getClippingSize();
		lowerLeft.y = clippingSize.y - lowerLeft.y;
	}

	auto ctx = gl::context();
	ctx->pushBoolState( GL_SCISSOR_TEST, GL_TRUE );
	ctx->pushScissor( std::pair<ivec2, ivec2>( lowerLeft, view->getSize() ) );
}
    void WordSuggest::specialDraw() const
    {
        // *** BACKGROUND ***
        if (getStyle()->backgroundColor.a > 0)
        {
            // Bind, fill and draw background
            mpBackground->bind();
            mpBackground->getShader()->fillValue("matrix", mFullDrawMatrix);
            mpBackground->getShader()->fillValue("color", getStyle()->backgroundColor);
            mpBackground->getShader()->fillValue("alpha", getMultipliedDimmedAlpha());
            mpBackground->draw();
        }

        // *** SUGGESTIONS ***
        if (!mSuggestions.empty())
        {
            // Push scissor to prohibit text simple assets to draw outside of this element
            pushScissor(mX, mY, mWidth, mHeight);

            // Draw suggestions
            for (const std::unique_ptr<TextSimple>& rSuggestion : mSuggestions)
            {
                rSuggestion->draw(getStyle()->fontColor, mAlpha);
            }

            // Draw thresholds (should be same number as suggestions
            int count = (int)mSuggestions.size();
            for (int i = 0; i < count; i++)
            {
                // Get threshold for that suggestion
                float threshold = mThresholds[i].getValue();

                // Only draw necessary stuff
                if (threshold > 0)
                {
                    // Calculate matrix
                    glm::mat4 matrix = calculateDrawMatrix(
                        mpLayout->getLayoutWidth(),
                        mpLayout->getLayoutHeight(),
                        mSuggestions[i]->getX() - (mDelta / 2),
                        mY,
                        mSuggestions[i]->getWidth() + mDelta,
                        mHeight);

                    // Draw threshold
                    mpThresholdItem->bind();
                    mpThresholdItem->getShader()->fillValue("matrix", matrix);
                    mpThresholdItem->getShader()->fillValue("thresholdColor", getStyle()->thresholdColor);
                    mpThresholdItem->getShader()->fillValue("threshold", threshold);
                    mpThresholdItem->getShader()->fillValue("alpha", mAlpha);
                    mpThresholdItem->getShader()->fillValue("orientation", 1.f); // vertical threshold
                    mpThresholdItem->getShader()->fillValue("mask", 0); // mask is always in slot 0
                    mpThresholdItem->draw();
                }
            }

            // Draw chosen suggestions
            for (const auto& rChosenSuggestion : mChosenSuggestions)
            {
                rChosenSuggestion.upText->draw(getStyle()->fontColor, rChosenSuggestion.alpha);
            }

            popScissor();
        }

        // Draw stuff like highlighting
        InteractiveElement::specialDraw();
    }
Esempio n. 3
0
void mui::Helpers::pushScissor( Container * c, ofRectangle rect ){
	pushScissor(c, rect.x, rect.y, rect.width, rect.height ); 
}