Exemple #1
0
coResult coImGui::Render(coRenderCommandBuffer& _commandBuffer)
{
	ImGui::Render();
	ImDrawData* data = ImGui::GetDrawData();

	coUint vertexOffset = 0;
	coUint indexOffset = 0;
	for (coUint i = 0; i < coUint(data->CmdListsCount); ++i)
	{
		const ImDrawList* cmdList = data->CmdLists[i];
		const auto& cmdBuffer = cmdList->CmdBuffer;
		for (coUint j = 0; j < coUint(cmdBuffer.Size); ++j)
		{
			const ImDrawCmd& cmd = cmdBuffer[j];
			if (cmd.UserCallback)
			{
				cmd.UserCallback(cmdList, &cmd);
			}
			else
			{
				const coUint x = coUint(coMax(0, coInt(cmd.ClipRect.x)));
				const coUint y = coUint(coMax(0, coInt(cmd.ClipRect.y)));
				const coUint width = coUint(cmd.ClipRect.z - cmd.ClipRect.x);
				const coUint height = coUint(cmd.ClipRect.w - cmd.ClipRect.y + 1); // FIXME: Why +1 here?
				_commandBuffer.PushSetScissor(x, y, width, height);
				_commandBuffer.PushDraw(cmd.ElemCount, vertexOffset, indexOffset);
			}
			indexOffset += cmd.ElemCount;
		}
		vertexOffset += cmdList->VtxBuffer.Size;
	}

	return true;
}
Exemple #2
0
void coBackground::setSize(float nw, float nh, float nd)
{
    myWidth = coMax(minWidth, nw);
    myHeight = coMax(minHeight, nh);
    myDepth = coMax(minDepth, nd);
    resizeGeometry();
    if (getParent())
    {
        getParent()->childResized();
    }
}
Exemple #3
0
void coBackground::resizeToParent(float x, float y, float z, bool shrink)
{
    //  fprintf(stderr,"coBackground::resizeToParent(%f,%f,%f,%s)\n",
    //                 x,y,z,((shrink)?"true":"false"));

    // only shrink when required
    // (quite stupid here because it is not used for own resizing,
    //  but maybe children need it...)
    if (shrink)
    {
        shrinkToMin();
    }

    myWidth = coMax(x, minWidth);
    myHeight = coMax(y, minHeight);
    myDepth = coMax(z, minDepth);

    for (list<coUIElement *>::iterator i = elements.begin(); i != elements.end(); ++i)
    {
        (*i)->resizeToParent(x, y, z);
    }

    float mw = 0;
    float mh = 0;
    float md = 0;

    for (list<coUIElement *>::iterator i = elements.begin(); i != elements.end(); ++i)
    {
        if ((*i)->getWidth() > mw)
        {
            mw = (*i)->getWidth();
        }
        if ((*i)->getHeight() > mh)
        {
            mh = (*i)->getHeight();
        }
        if ((*i)->getDepth() > md)
        {
            md = (*i)->getDepth();
        }
    }

    myWidth = coMax(mw, x);
    myHeight = coMax(mh, y);
    myDepth = coMax(md, z);
    myWidth = coMax(myWidth, minWidth);
    myHeight = coMax(myHeight, minHeight);
    myDepth = coMax(myDepth, minDepth);
    resizeGeometry();
    realign();

    // fprintf(stderr,"W/H/D = %8f,%8f,%8f\n",myWidth,myHeight,myDepth);
}
Exemple #4
0
/** set the depth of the background element explicitely
    @param f new depth
*/
void coBackground::setDepth(float f)
{
    myDepth = coMax(minDepth, f);
    if (getParent())
    {
        getParent()->childResized();
    }
}
Exemple #5
0
/** set the height of the background element explicitely
    @param f new height
*/
void coBackground::setHeight(float f)
{
    myHeight = coMax(minHeight, f);
    if (getParent())
    {
        getParent()->childResized();
    }
}
Exemple #6
0
/** set the minimum width of the background element
    @param f minimum width
*/
void coBackground::setMinWidth(float f)
{
    myWidth = coMax(myWidth, f);
    minWidth = f;
    if (getParent())
    {
        getParent()->childResized();
    }
}
Exemple #7
0
/// Shrinks itself! This includes shrinking all children.
void coBackground::shrinkToMin()
{

    float mw = 0;
    float mh = 0;
    float md = 0;

    // walk through elements

    for (list<coUIElement *>::iterator i = elements.begin(); i != elements.end(); ++i)
    {
        // shrink them
        (*i)->shrinkToMin();

        // get max
        if ((*i)->getWidth() > mw)
        {
            mw = (*i)->getWidth();
        }

        if ((*i)->getHeight() > mh)
        {
            mh = (*i)->getHeight();
        }

        if ((*i)->getDepth() > md)
        {
            md = (*i)->getDepth();
        }
    }

    // set own size to max
    myWidth = coMax(minWidth, mw);
    myHeight = coMax(minHeight, mh);
    myDepth = coMax(minDepth, md);
    resizeGeometry();
}