コード例 #1
0
ファイル: UIDisplay.cpp プロジェクト: justy989/MultiFall
void UIDisplay::buildWindowVB( UIWindow& window, float aspectRatio )
{
    //Build window border
    buildBorderVB( &window, aspectRatio );

    if( window.getTabCount() > 1 ) {
        //Buil Tabs after subtracting the title bar and border
        buildTabVB( window, aspectRatio );
    } else {
        //Calculate the inside of a window
        UIWindow w;
        float borderWidth = mBorderDimension;
        float borderHeight = borderWidth * aspectRatio;

        w.setPosition( XMFLOAT2(window.getPosition().x + borderWidth, (window.getPosition().y + UIWINDOW_TITLE_BAR_HEIGHT) ) );
        w.setDimension( XMFLOAT2(window.getDimension().x - ( borderWidth * 2.0f ), (window.getDimension().y - UIWINDOW_TITLE_BAR_HEIGHT ) - borderHeight ) );
        buildBorderVB( &w, aspectRatio );
    }

    //Build BG
    buildBGVB( &window, mBGColor );

    UIWindow::Tab& t = window.getTab( window.getCurrentTab() );

    mBuildingElements = true;

    //Loop through and build elements in the current tab
    for(int i = 0; i < t.elementCount; i++) {
        buildBorderVB( t.elements[i], aspectRatio, window.getPosition() );

        if( t.elements[i]->getElemType() == UIElement::ElemType::Slider ) {
            UISlider* slider = *(UISlider**)(t.elements + i);

            UIWindow w;
            w.setPosition( XMFLOAT2( slider->getPosition().x + window.getPosition().x, slider->getPosition().y + window.getPosition().y ) );
            w.setDimension( XMFLOAT2( slider->getDimension().x * slider->getPercent(), slider->getDimension().y ) );

            XMFLOAT4 pctColor = XMFLOAT4( 1.0f, 0.0f, 0.0f, 0.3f );

            buildBGVB( &w, pctColor );
        } else if( t.elements[i]->getElemType() == UIElement::ElemType::CheckBox ) {
            UICheckbox* cb = *(UICheckbox**)(t.elements + i);

            if( cb->isChecked() ) {
                UICheckbox b;

                b.setPosition( XMFLOAT2( cb->getPosition().x + window.getPosition().x, cb->getPosition().y + window.getPosition().y ) );
                b.setDimension( XMFLOAT2( cb->getDimension().x, cb->getDimension().y ) );
                buildCheckboxVB( &b );
            }
        }
    }

    mBuildingElements = false;
}
コード例 #2
0
ファイル: UICanvas.cpp プロジェクト: GrimshawA/Nephilim
UIWindow* UICanvas::addSurface(const String& name)
{
	UIWindow* surface = new UIWindow();
	surface->setName(name);
	surface->setPosition(m_bounds.left, m_bounds.top);
	surface->setSize(m_bounds.width, m_bounds.height);
	surface->setContext(&m_state);
	surface->m_parentDocument = this;

	if(m_surfaceContainerLock == 0)
	{
		m_surfaces.push_back(surface);
	}
	else
	{
		// Schedule add
		PendingChange change;
		change.type = Add;
		change.surface = surface;
		m_pendingChanges.push_back(change);
	}

	return surface;
};