/**
	 * sets a new vertex to a certain position of the grid 
	 */
	void CGUISceneEffectGrid3D::SetVertex( uint32 uX, uint32 uY, const SVertexFormat_V3F& rVertex )
	{
		GUI_ASSERT( uX <= m_aGridSize.m_uWidth && uY <= m_aGridSize.m_uHeight, "invalid pos" );

		int	index = (uX * (m_aGridSize.m_uHeight+1) + uY);
		m_pVertices[index] = rVertex;
	}
示例#2
0
	//------------------------------------------------------------------------------
	CGUITextureImp::CGUITextureImp(IGUIInterfaceRender* pRender)
		:m_pRender(pRender)
		,m_pTexture(NULL)
		,m_ePixelFormat(GUI_PF_UNKNOEWN)
	{
		GUI_ASSERT( pRender, "no render" );
	}
	/** 
	* returns the non-transformed vertex than belongs to certain position in the grid 
	*/
	const SVertexFormat_V3F& CGUISceneEffectGrid3D::GetOriginalVertex( uint32 uX, uint32 uY )
	{
		GUI_ASSERT( uX <= m_aGridSize.m_uWidth && uY <= m_aGridSize.m_uHeight, "invalid pos" );
		
		int	index = (uX * (m_aGridSize.m_uHeight+1) + uY);
		return m_pOriginalVertices[index];
	}
示例#4
0
	//------------------------------------------------------------------------------
	CGUIMouseCursor::CGUIMouseCursor()
		:m_pAnimation(NULL)
		,m_bVisible(false)
	{
		GUI_ASSERT( !m_pSingleton, "[CGUIMouseCursor::CGUIMouseCursor]:instance has been created" ); 
		m_pSingleton = this; 
	}
示例#5
0
void TRenderObject::resize(const TSize& size) {
    auto currentSize = renderTexture->getSize();
    if (currentSize.x != size.x || currentSize.y != size.y) {
        GUI_ASSERT(renderTexture->create(size.x, size.y) == true,
            "Failed to create a RenderTexture.");
        drawingObject->setOrigin(0.f, size.y);
    }
}
示例#6
0
/*==============================================================================
 * - cbi_create_default()
 *
 * - create a cbi from a picture file, init it callback function with default,
 *   and register it.
 */
GUI_CBI *cbi_create_default (const char     *pic_file_name,
                             const GUI_COOR *p_left_up,
                             GUI_SIZE       *p_cbi_size,
                             BOOL            save_data)
{
    int i;
    GUI_CBI *pCBI = NULL;

    if (p_left_up == NULL) {
        goto _finish;
    }

    /* show picture at <p_left_up> with <p_cbi_size> size */
    /* if <p_cbi_size> is biger than picture size the left is black,
     * otherwise failed */
    /* if <p_cbi_size> is {0, 0}, then it will be changed to equal the pic size */
    if (jpeg_dump_pic (pic_file_name, p_left_up, p_cbi_size)
            == OS_STATUS_ERROR) {
        goto _finish;
    }

    /* alloc cbi struct */
    pCBI = malloc (sizeof (GUI_CBI));

    if (pCBI == NULL) {
        goto _finish;
    }

    /* calculate left_up and right_down coordinate  */
    pCBI->left_up.x = p_left_up->x;
    pCBI->left_up.y = p_left_up->y;
    pCBI->right_down.x = p_left_up->x + p_cbi_size->w - 1;
    pCBI->right_down.y = p_left_up->y + p_cbi_size->h - 1;

    /* save picture data if need */
    if (save_data) {
        pCBI->data = (uint16 *)malloc (p_cbi_size->w * p_cbi_size->h * sizeof (uint16));
        if (pCBI->data != NULL) {
            for (i = pCBI->left_up.y; i <= pCBI->right_down.y; i++) {
                memcpy (pCBI->data + (i - pCBI->left_up.y) * p_cbi_size->w,   /* dst */
                        lcd_get_addr (i, pCBI->left_up.x),                    /* src */
                        p_cbi_size->w * sizeof (uint16));                     /* size */
            }
        }
    } else {
        pCBI->data = NULL;
    }

    /* init cbi's name as picture file nanme */
    strlcpy (pCBI->name, pic_file_name, GUI_CBI_NAME_LEN_MAX);

    /* init cbi's callback function as default */
    cbi_init_cb (pCBI);

_finish:
    GUI_ASSERT (pCBI != NULL);
    return pCBI;
}
示例#7
0
TRenderObject::TRenderObject(const TSize& size) :
    renderTexture(new sf::RenderTexture()),
    drawingObject(new sf::Sprite())
{
    GUI_ASSERT(renderTexture->create(size.x, size.y) == true,
        "Failed to create a RenderTexture.");
    drawingObject->setOrigin(0.f, size.y);
    drawingObject->setScale(1.f, -1.f);
}
示例#8
0
TWidget::Child TWidget::RemoveChild(const Name& name) {
    GUI_ASSERT(HasChild(name) == true,
        "Menu object '" + GetName() + "' does not contain "
        "child with name '" + name + "'.");

    Child child = children[name];
    children.erase(name);
    child->SetParent(TWidgetWeakRef());
    return child;
}
示例#9
0
	//------------------------------------------------------------------------------
	void CGUIAsWidgetChildrenAlpha::ApplyValue( )
	{
		GUI_ASSERT( GetReceiver(), "no receiver");
		CGUIWidget* pChild = GetReceiver()->GetChild();
		while( pChild )
		{
			pChild->SetAlpha(GetCurrentValue());
			pChild = pChild->GetNextSibling();
		}
	}
	//------------------------------------------------------------------------------
	void CGUIWgtBox2DDynamicBody::InitializeBox2D()
	{
		CGUIWgtBox2DBase::InitializeBox2D();

		GUI_ASSERT( m_pBody == NULL, "invalid static body pointer");

		b2World * pWorld = CGUIInterfaceManager::Instance()->GetInterfacePhysicsWithTypeCheck<IGUIPhysics_box2d>()->GetWorld();
		if( !pWorld )
		{
			return;
		}

		//get position,size and so on
		CGUIVector2 aPos;
		CGUIVector2 aCenter;
		CGUISize aSize;
		real fRot = 0.0f;
		GetBox2dPosition( aPos );
		GetBox2dSize( aSize );
		GetBox2dCenter( aCenter );
		GetBox2dRot( fRot );

		//create body
		b2BodyDef aBodyDef;
		aBodyDef.type = b2_dynamicBody;
		aBodyDef.position.Set( aPos.x, aPos.y );
		aBodyDef.angle = fRot;
		aBodyDef.bullet = true;
		m_pBody = pWorld->CreateBody( &aBodyDef );

		//create fixture
		b2PolygonShape aBox;
		aBox.SetAsBox( aSize.m_fWidth, aSize.m_fHeight, b2Vec2( aCenter.x, aCenter.y), 0.0f );
		b2FixtureDef fixtureDef;
		fixtureDef.shape = &aBox;
		fixtureDef.density = 1.0f;
		fixtureDef.friction = 0.3f;
		m_pBody->CreateFixture( &fixtureDef );

		//set user data
		m_pBody->SetUserData( this );
	}
示例#11
0
	//------------------------------------------------------------------------------
	void IGUIFont_ft2::DestroyFontData( CGUIFontData* pData )
	{
		GUI_ASSERT( pData, "invalid parameter" );

		//check
		CGUIFontData_ft2* pFontData = m_arrayFontDatas[pData->GetFontID()];
		if( pFontData != pData )
		{
			GUI_THROW( GUI_FORMAT(
				"[IGUIFont_ft2::DestroyFontData]: the font<%s:%s> doesn't existing", 
				pData->GetName().c_str(),
				pData->GetSceneName().c_str()));
			return;
		}

		//update font face
		TMapFontFace::iterator itor = m_mapFontFace.find( pData->GetFontPath() );
		if( itor == m_mapFontFace.end() )
		{
			GUI_THROW( GUI_FORMAT(
				"[IGUIFont_ft2::DestroyFontData]: failed to font font face by path <%s>", 
				pData->GetFontPath().c_str()));
			return;
		}
		itor->second->RefRelease();
		//delete font face
		if( itor->second->GetRefCount() == 0 )
		{
			delete itor->second;
			m_mapFontFace.erase( itor );
		}

		//clear font
		m_arrayFontDatas[pData->GetFontID()] = NULL;
		delete pData;
	}
示例#12
0
	//------------------------------------------------------------------------------
	void CGUITextureImp::Destroy()
	{
		GUI_ASSERT( m_pRender, "invalid render pointer" );
		m_pRender->DestroyTexture( this );
	}
示例#13
0
	//------------------------------------------------------------------------------
	CGUIMouseCursor* CGUIMouseCursor::Instance()
	{
		GUI_ASSERT( m_pSingleton, "not initialized" );
		return m_pSingleton; 
	}
示例#14
0
	//------------------------------------------------------------------------------
	void CGUIAsWidgetScale::ApplyValue( )
	{
		GUI_ASSERT( GetReceiver(), "no receiver");
		GetReceiver()->SetScale(GetCurrentValue());
	}
示例#15
0
	//------------------------------------------------------------------------------
	void CGUIAsWidgetRotation::ApplyValue( )
	{
		GUI_ASSERT( GetReceiver(), "no receiver");
		GetReceiver()->SetRotation(GetCurrentValue());
	}
示例#16
0
/*==============================================================================
 * - app_album()
 *
 * - album application entry
 */
OS_STATUS app_album (GUI_CBI *pCBI_album, GUI_COOR *coor)
{
    GUI_COOR pic_left_up = {gra_scr_w(), 0};
    GUI_SIZE album_size = {gra_scr_w(), gra_scr_h()};

    GUI_CBI *pCBI = malloc (sizeof (GUI_CBI));
    if (pCBI == NULL) {
        return OS_STATUS_ERROR;
    }
    strcpy (pCBI->name, "album cbi");

    pCBI->left_up.x = 0;
    pCBI->left_up.y = 0;
    pCBI->right_down.x = gra_scr_w() - 1;
    pCBI->right_down.y = gra_scr_h() - 1;

    pCBI->func_press   = cbf_noop;
    pCBI->func_leave   = cbf_noop;
    pCBI->func_release = _album_cb_change;
    pCBI->func_drag    = cbf_hw_drag;

    pCBI->data = NULL;

    cbi_delete_all ();   /* delete all other cbis */

    _album_add_file (ALBUM_PIC_PATH, ".jpg");
    _album_add_file (ALBUM_PIC_PATH, ".JPG");

    _G_right_pic = (PIC_NAME_NODE *)DL_FIRST(&_G_pic_list);
    _G_left_pic  = (PIC_NAME_NODE *)DL_LAST(&_G_pic_list);
    GUI_ASSERT(_G_right_pic != NULL);

    jpeg_dump_pic (_G_right_pic->name, &pic_left_up, &album_size);

    gra_set_show_fb (1); /* show frame buffer 1 */

    font_printf (&pic_left_up, GUI_COLOR_GREEN,
                 "There are %d picture(s) in \""ALBUM_PIC_PATH"\" directory!",
                 dlist_count (&_G_pic_list));

    _G_right_pic = (PIC_NAME_NODE *)DL_NEXT(_G_right_pic);

    /* dump first and last picture in frame buffer */
    pic_left_up.x = 0;
    jpeg_dump_pic (_G_left_pic->name, &pic_left_up, &album_size);
    pic_left_up.x = gra_scr_w() * 2;
    jpeg_dump_pic (_G_right_pic->name, &pic_left_up, &album_size);

    cbi_register (pCBI);

    /* home cbi */
    {
        GUI_CBI *pCBI_home = NULL;
        GUI_COOR left_up = {gra_scr_w() - ICON_SIZE, 0};
        GUI_SIZE size = {0, 0};
        pCBI_home = cbi_create_default ("/n1/gui/cbi_home.jpg", &left_up, &size, FALSE);
        pCBI_home->func_release = _album_cb_home;

        cbi_register (pCBI_home);
    }


    return OS_STATUS_OK;
}
示例#17
0
	//------------------------------------------------------------------------------
	CGUIWgtParticle2D::~CGUIWgtParticle2D()
	{
		GUI_ASSERT( !m_pParticle2DSystem, "resource leak" );
	}
	//------------------------------------------------------------------------------
	void CGUIParticle2DSystemQuad::UpdateQuadWithParticle( CGUIParticle2D* particle, const CGUIVector2& rNewPos )
	{
		uint32 particleIdx = particle - m_pParticles;
		GUI_ASSERT( particleIdx < m_uParticleCount, "invalid particle" );

		// colors
		SVertexFormat_V2F_T2F_C4UB_Quad *quad = &(m_pQuads[particleIdx]);
		for( uint32 i=0; i<4; ++i )
		{
			quad->vertices[i].colors.abgr = particle->color.GetAsABGR();
		}

		// vertices
		real size_2 = particle->size/2;
		if( particle->rotation )
		{
			real x1 = -size_2;
			real y1 = -size_2;

			real x2 = size_2;
			real y2 = size_2;
			real x = rNewPos.x;
			real y = rNewPos.y;

			real r = (real)-CGUIMath::DegreesToRadians(particle->rotation);
			real cr = cosf(r);
			real sr = sinf(r);
			real ax = x1 * cr - y1 * sr + x;
			real ay = x1 * sr + y1 * cr + y;
			real bx = x2 * cr - y1 * sr + x;
			real by = x2 * sr + y1 * cr + y;
			real cx = x2 * cr - y2 * sr + x;
			real cy = x2 * sr + y2 * cr + y;
			real dx = x1 * cr - y2 * sr + x;
			real dy = x1 * sr + y2 * cr + y;

			// bottom-left
			quad->vertices[eQuad_BottomLeft].vertices.x = ax;
			quad->vertices[eQuad_BottomLeft].vertices.y = ay;

			// bottom-right vertex:
			quad->vertices[eQuad_BottomRight].vertices.x = bx;
			quad->vertices[eQuad_BottomRight].vertices.y = by;

			// top-left vertex:
			quad->vertices[eQuad_TopLeft].vertices.x = dx;
			quad->vertices[eQuad_TopLeft].vertices.y = dy;

			// top-right vertex:
			quad->vertices[eQuad_TopRight].vertices.x = cx;
			quad->vertices[eQuad_TopRight].vertices.y = cy;
		} 
		else
		{
			// bottom-left vertex:
			quad->vertices[eQuad_BottomLeft].vertices.x = rNewPos.x - size_2;
			quad->vertices[eQuad_BottomLeft].vertices.y = rNewPos.y + size_2;

			// bottom-right vertex:
			quad->vertices[eQuad_BottomRight].vertices.x = rNewPos.x + size_2;
			quad->vertices[eQuad_BottomRight].vertices.y = rNewPos.y + size_2;

			// top-left vertex:
			quad->vertices[eQuad_TopLeft].vertices.x = rNewPos.x - size_2;
			quad->vertices[eQuad_TopLeft].vertices.y = rNewPos.y - size_2;

			// top-right vertex:
			quad->vertices[eQuad_TopRight].vertices.x = rNewPos.x + size_2;
			quad->vertices[eQuad_TopRight].vertices.y = rNewPos.y - size_2;				
		}
	}
示例#19
0
	//------------------------------------------------------------------------------
	void CGUIShaderImp::Destroy()
	{
		GUI_ASSERT( m_pRender, "invalid render pointer" );
		m_pRender->DestroyShader( this );
	}
示例#20
0
void TWidget::AddChild(const TWidgetRef& obj) {
    GUI_ASSERT(obj != nullptr,
        "Can not add null object as a child to '" + name + "'.")

    obj->SetParent(shared_from_this());
}