Beispiel #1
0
void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);

    if (!shouldPaint(paintInfo, paintOffset))
        return;

    LayoutPoint adjustedPaintOffset = paintOffset + location();

    if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection))
        paintBoxDecorations(paintInfo, adjustedPaintOffset);

    if (paintInfo.phase == PaintPhaseMask) {
        paintMask(paintInfo, adjustedPaintOffset);
        return;
    }

    if (paintInfo.phase == PaintPhaseClippingMask && (!hasLayer() || !layer()->hasCompositedClippingMask()))
        return;

    LayoutRect paintRect = LayoutRect(adjustedPaintOffset, size());
    if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
        paintOutline(paintInfo, paintRect);

    if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && !canHaveChildren() && paintInfo.phase != PaintPhaseClippingMask)
        return;

    if (!paintInfo.shouldPaintWithinRoot(this))
        return;

    bool drawSelectionTint = selectionState() != SelectionNone && !document().printing();
    if (paintInfo.phase == PaintPhaseSelection) {
        if (selectionState() == SelectionNone)
            return;
        drawSelectionTint = false;
    }

    bool completelyClippedOut = false;
    if (style()->hasBorderRadius()) {
        LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size());

        if (borderRect.isEmpty())
            completelyClippedOut = true;
        else {
            // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
            paintInfo.context->save();
            RoundedRect roundedInnerRect = style()->getRoundedInnerBorderFor(paintRect,
                paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true);
            clipRoundedInnerRect(paintInfo.context, paintRect, roundedInnerRect);
        }
    }

    if (!completelyClippedOut) {
        if (paintInfo.phase == PaintPhaseClippingMask) {
            paintClippingMask(paintInfo, adjustedPaintOffset);
        } else {
            paintReplaced(paintInfo, adjustedPaintOffset);
        }

        if (style()->hasBorderRadius())
            paintInfo.context->restore();
    }

    // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of
    // surrounding content.
    if (drawSelectionTint) {
        LayoutRect selectionPaintingRect = localSelectionRect();
        selectionPaintingRect.moveBy(adjustedPaintOffset);
        paintInfo.context->fillRect(pixelSnappedIntRect(selectionPaintingRect), selectionBackgroundColor());
    }
}
Beispiel #2
0
void ofxFlashStage :: updateMouse ()
{
	bool bHitDisplayObjectChanged = false;
	bHitDisplayObjectChanged = ( topMostHitDisplayObject != topMostHitDisplayObjectPrev );
	
	if( !bHitDisplayObjectChanged && !bMousePressed && !bMouseReleased )	// update if either of these is true, otherwise return.
	{
		return;
	}
	
//	cout << ofGetFrameNum() << endl;		// debug - check when this method gets to this point by spitting out the frame num.

	//=========================================== CREATE CHILD / PARENT LINES.

	ofxFlashDisplayObject* dispObj;
	ofxFlashInteractiveObject* intObj;
	
	if( bHitDisplayObjectChanged )
	{
		lineTopDownPrev		= lineTopDown;
		lineBottomUpPrev	= lineBottomUp;
		lineTopDown.clear();
		lineBottomUp.clear();
		
		if( topMostHitDisplayObject )			// check topMostHitDisplayObject is not null.
		{
			dispObj = topMostHitDisplayObject;
			while( dispObj != this )			// go down through child / parent nesting until stage is reached.
			{
				if( isInteractiveObject( dispObj ) )
				{
					ofxFlashInteractiveObject* intObj;
					intObj = (ofxFlashInteractiveObject*)dispObj;
					
					lineTopDown.push_back( intObj );
					lineBottomUp.insert ( lineBottomUp.begin(), intObj );
				}
				
				dispObj	= dispObj->parent;
			}
		}
	}
	
	//=========================================== RESET PREVIOUS MOUSE STATES.
	
	if( topMostHitDisplayObjectPrev )		// clear mouse states from previous line of display objects.
	{
		for( int i=0; i<lineTopDownPrev.size(); i++ )			// go down through child / parent nesting until stage is reached.
		{
			intObj = lineTopDownPrev[ i ];

			if( topMostHitDisplayObject )
			{
				intObj->mouseOverDirty = false;		// reset mouse over, dirty value used for further checks.
				intObj->mouseDownDirty = false;		// reset mouse down, dirty value used for further checks.
			}
			else
			{
				intObj->mouseOver( false );			// reset mouse over.
				intObj->mouseDown( false );			// reset mouse down.
			}
		}
	}
	
	if( !topMostHitDisplayObject )		// check if anything is hit, return if not.
	{
		bMouseDown = false;				// if topMostHitDisplayObject is not found, mouse is not over anything and so mouse down is no longer valid.
		return;							// no display object registered under mouse, nothing to update.
	}
	
	//=========================================== CHECK MOUSE ENABLED FLAG - TOP DOWN.
	
	bool bMouseEnabled = false;			// assume all display objects in nest have mouseEnabled set to false.
	
	for( int i=0; i<lineTopDown.size(); i++ )			// go down through child / parent nesting until stage is reached.
	{
		intObj = lineTopDown[ i ];

		// if bEnabled is still false, check if next display object down has mouseEnabled set to true.
		// once one mouseEnable has been found, all display objects below are now considered to be enabled.
		
		if( !bMouseEnabled )
		{
			bMouseEnabled = bMouseEnabled || intObj->mouseEnabled();
		}
		
		intObj->mouseOverDirty = bMouseEnabled;
	}
	
	//=========================================== CHECK MOUSE CHILDREN FLAG - BOTTOM UP.
	
	bool bMouseChildren = true;		// assume all display objects in nest have mouseChildren set to true.
	
	for( int i=0; i<lineBottomUp.size(); i++ )
	{
		intObj = lineBottomUp[ i ];

		bool bMouseOver;
		bMouseOver = intObj->mouseOverDirty;			// check if display object has already been set to mouse over with previous checks.
		bMouseOver = bMouseOver && bMouseChildren;		// if bMouseChildren is false from previous display object, then turn off mouse over.
		
		intObj->mouseOverDirty = bMouseOver;
		
		if( bMouseChildren )						// if still true, check if mouseChildren has changed to false.
		{
			if( canHaveChildren( intObj ) )
			{
				ofxFlashDisplayObjectContainer* objCont;
				objCont = (ofxFlashDisplayObjectContainer*)intObj;
				
				bMouseChildren = bMouseChildren && objCont->mouseChildren();
			}
		}
	}
	
	//=========================================== CHECK MOUSE DOWN.
	
	if( bMouseDown )		// if any of the states change in the line while the mouse is down, turn mouse down off.
	{
		for( int i=0; i<lineTopDown.size(); i++ )		// go down through child / parent nesting until stage is reached.
		{
			intObj = lineTopDown[ i ];
			
			if( intObj->mouseOver() != intObj->mouseOverDirty )		// check for a state change. if true, mouse is no longer down.
			{
				bMouseDown = false;
				break;
			}
		}
		
		for( int i=0; i<lineTopDownPrev.size(); i++ )		// go down through child / parent nesting until stage is reached.
		{
			intObj = lineTopDownPrev[ i ];
			
			if( intObj->mouseOver() != intObj->mouseOverDirty )		// check for a state change. if true, mouse is no longer down.
			{
				bMouseDown = false;
				break;
			}
		}
	}
	
	//=========================================== FINALISE MOUSE VALUES.

	for( int i=0; i<lineTopDown.size(); i++ )					// go down through child / parent nesting until stage is reached.
	{
		intObj = lineTopDown[ i ];
		
		intObj->mouseOver( intObj->mouseOverDirty );
		intObj->mouseDown( intObj->mouseOverDirty && bMouseDown );
	}
	
	if( !topMostHitDisplayObjectPrev )
		return;
	
	for( int i=0; i<lineTopDownPrev.size(); i++ )				// go down through child / parent nesting until stage is reached.
	{
		intObj = lineTopDownPrev[ i ];
		
		intObj->mouseOver( intObj->mouseOverDirty );
		intObj->mouseDown( intObj->mouseOverDirty && bMouseDown );
	}
}
Beispiel #3
0
void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    if (!shouldPaint(paintInfo, paintOffset))
        return;

#ifndef NDEBUG
    SetLayoutNeededForbiddenScope scope(this);
#endif
    LayoutPoint adjustedPaintOffset = paintOffset + location();
    
    if (hasBoxDecorations() && paintInfo.phase == PaintPhaseForeground)
        paintBoxDecorations(paintInfo, adjustedPaintOffset);
    
    if (paintInfo.phase == PaintPhaseMask) {
        paintMask(paintInfo, adjustedPaintOffset);
        return;
    }

    LayoutRect paintRect = LayoutRect(adjustedPaintOffset, size());
    if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style().outlineWidth())
        paintOutline(paintInfo, paintRect);
    
    if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && !canHaveChildren())
        return;
    
    if (!paintInfo.shouldPaintWithinRoot(*this))
        return;
    
    bool drawSelectionTint = shouldDrawSelectionTint();
    if (paintInfo.phase == PaintPhaseSelection) {
        if (selectionState() == SelectionNone)
            return;
        drawSelectionTint = false;
    }

    bool completelyClippedOut = false;
    if (style().hasBorderRadius()) {
        LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size());

        if (borderRect.isEmpty())
            completelyClippedOut = true;
        else {
            // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
            paintInfo.context->save();
            FloatRoundedRect roundedInnerRect = FloatRoundedRect(style().getRoundedInnerBorderFor(paintRect,
                paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true));
            clipRoundedInnerRect(paintInfo.context, paintRect, roundedInnerRect);
        }
    }

    if (!completelyClippedOut) {
        paintReplaced(paintInfo, adjustedPaintOffset);

        if (style().hasBorderRadius())
            paintInfo.context->restore();
    }
        
    // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of
    // surrounding content.
    if (drawSelectionTint) {
        LayoutRect selectionPaintingRect = localSelectionRect();
        selectionPaintingRect.moveBy(adjustedPaintOffset);
        paintInfo.context->fillRect(snappedIntRect(selectionPaintingRect), selectionBackgroundColor(), style().colorSpace());
    }
}