drawRect in COffscreenContext [Solved]

A user interface toolkit mainly for audio plug-ins (VST, AudioUnit, etc).
Post Reply
xavier
Posts: 9
Joined: Thu Jul 21, 2016 9:46 am

drawRect in COffscreenContext [Solved]

Post by xavier »

Hi,

I'm trying to draw a view container and its subview in a COffscreenContext.
I can't achieve this, but don't see where miss something.


The code is quite simple yet, overwriting CViewContainer:

void CViewContainerPanel:drawRect (CDrawContext* pContext, const CRect& updateRect)
{
COffscreenContext * pContextCourant = COffscreenContext::create(getFrame(), Image->getWidth(), Image->getHeight());
pContextCourant->beginDraw ();
CViewContainer::drawRect (pContextCourant, updateRect);
pContextCourant->endDraw ();

Panel = pContextCourant->getBitmap();
Panel->draw(pContext, size,Point (0,0));
pContextCourant->forget();

}
But only the CViewContainer::drawRect do nothing.

If I replace pContextCourant with pContext, removing the image draw, it's working fine

Any help would be appreciated

Thanks in advance

Best regards
Xavier
Last edited by xavier on Mon Feb 13, 2017 10:32 am, edited 1 time in total.

xavier
Posts: 9
Joined: Thu Jul 21, 2016 9:46 am

Re: drawRect in COffscreenContext

Post by xavier »

Hi,

For those who need it, adding the transform translate helps

Best regards
Xavier

void CViewContainerPanel:drawRect (CDrawContext* pContext, const CRect& updateRect)
{
COffscreenContext * pContextCourant = COffscreenContext::create(getFrame(), Image->getWidth(), Image->getHeight());
pContextCourant->beginDraw ();
CDrawContext::Transform transform (*pContextCourant, CGraphicsTransform ().translate (-getViewSize ().left, -getViewSize ().top));

CViewContainer::draw (pContextCourant);
pContextCourant->endDraw ();

Panel = pContextCourant->getBitmap();
Panel->draw(pContext, size,Point (0,0));
pContextCourant->forget();

}

Post Reply