コード例 #1
0
void ImageComponent::render(const Eigen::Affine3f& parentTrans)
{
	Eigen::Affine3f trans = parentTrans * getTransform();
	Renderer::setMatrix(trans);
	
	if(mTexture && getOpacity() > 0)
	{
		GLfloat points[12], texs[12];
		GLubyte colors[6*4];

		if(mTiled)
		{
			float xCount = mSize.x() / getTextureSize().x();
			float yCount = mSize.y() / getTextureSize().y();
			
			Renderer::buildGLColorArray(colors, 0xFFFFFF00 | (getOpacity()), 6);
			buildImageArray(0, 0, points, texs, xCount, yCount);
		}else{
			Renderer::buildGLColorArray(colors, 0xFFFFFF00 | (getOpacity()), 6);
			buildImageArray(0, 0, points, texs);
		}

		drawImageArray(points, texs, colors, 6);
	}

	GuiComponent::renderChildren(trans);
}
コード例 #2
0
	void PopUpMenu::logic( double timeElapsed )
	{
		agui::PopUpMenu::logic(timeElapsed);
		if(getOpacity() < 1.0f)
		{
			setOpacity(getOpacity() + m_opacityRate);
		}
	}
コード例 #3
0
void SplitPanel::drawInternal(Graphics* const Graphics, Real32 Opacity) const
{
    // draw the two contained components and the divider
    if (getMinComponent() != NULL)
        getMinComponent()->draw(Graphics, getOpacity()*Opacity);
    if (getMaxComponent() != NULL)
        getMaxComponent()->draw(Graphics, getOpacity()*Opacity);
    if (getDividerDrawObject() != NULL)
        getDividerDrawObject()->draw(Graphics, getOpacity()*Opacity);
}
コード例 #4
0
void ProgressBar::drawInternal(Graphics* const Graphics, Real32 Opacity) const
{

	//Draw The ProgressBar
    UIDrawObjectCanvasRefPtr DrawObject(getDrawnDrawObject());
    if(DrawObject != NULL)
    {
        if(DrawObject->getPosition() != _ProgressBarPosition)
        {
            DrawObject->setPosition(_ProgressBarPosition);
        }
        if(DrawObject->getSize() != _ProgressBarSize)
        {
            DrawObject->setSize(_ProgressBarSize);
        }
        DrawObject->draw(Graphics,getOpacity()*Opacity);
    }
	
	//Draw The Progress String
	if(getEnableProgressString() && getFont() != NULL)
	{
		Pnt2f TopLeft, BottomRight;
		getInsideBorderBounds(TopLeft, BottomRight);

		//Draw the progress String
		std::string StringToDraw;
		if(getProgressString().compare("") == 0)
		{
            if(!getIndeterminate())
            {
			    UInt32 Percent(static_cast<Int32>( osgFloor(getPercentComplete() * 100.0f) ));

			    std::stringstream TempSStream;
			    TempSStream << Percent;

			    StringToDraw = TempSStream.str() + std::string("%");
            }
		}
		else
		{
			StringToDraw = getProgressString();
		}

		//Calculate Alignment
		Pnt2f AlignedPosition;
		Pnt2f TextTopLeft, TextBottomRight;
		getFont()->getBounds(StringToDraw, TextTopLeft, TextBottomRight);

		AlignedPosition = calculateAlignment(TopLeft, (BottomRight-TopLeft), (TextBottomRight - TextTopLeft),getAlignment().y(), getAlignment().x());

		//Draw the Text
		Graphics->drawText(AlignedPosition, StringToDraw, getFont(), getDrawnTextColor(), getOpacity()*Opacity);
	}
}
コード例 #5
0
ファイル: UILayout.cpp プロジェクト: ShortTailLab/cocos2d-x
void UILayout::setBackGroundImage(const char* fileName,TextureResType texType)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }
    if (m_pBackGroundImage == NULL)
    {
        addBackGroundImage();
    }
    m_strBackGroundImageFileName = fileName;
    m_eBGImageTexType = texType;
    if (m_bBackGroundScale9Enabled)
    {
        switch (m_eBGImageTexType)
        {
            case UI_TEX_TYPE_LOCAL:
                dynamic_cast<CCScale9Sprite*>(m_pBackGroundImage)->initWithFile(fileName);
                break;
            case UI_TEX_TYPE_PLIST:
                dynamic_cast<CCScale9Sprite*>(m_pBackGroundImage)->initWithSpriteFrameName(fileName);
                break;
            default:
                break;
        }
        dynamic_cast<CCScale9Sprite*>(m_pBackGroundImage)->setPreferredSize(m_size);
    }
    else
    {
        switch (m_eBGImageTexType)
        {
            case UI_TEX_TYPE_LOCAL:
                dynamic_cast<CCSprite*>(m_pBackGroundImage)->initWithFile(fileName);
                break;
            case UI_TEX_TYPE_PLIST:
                dynamic_cast<CCSprite*>(m_pBackGroundImage)->initWithSpriteFrameName(fileName);
                break;
            default:
                break;
        }
    }
    if (m_bBackGroundScale9Enabled)
    {
        dynamic_cast<CCScale9Sprite*>(m_pBackGroundImage)->setColor(getColor());
        dynamic_cast<CCScale9Sprite*>(m_pBackGroundImage)->setOpacity(getOpacity());
    }
    else
    {
        dynamic_cast<CCSprite*>(m_pBackGroundImage)->setColor(getColor());
        dynamic_cast<CCSprite*>(m_pBackGroundImage)->setOpacity(getOpacity());
    }
    m_backGroundImageTextureSize = m_pBackGroundImage->getContentSize();
    m_pBackGroundImage->setPosition(ccp(m_size.width/2.0f, m_size.height/2.0f));
}
コード例 #6
0
void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
#if 0
    SkString str1, str2;
 //   getMatrix().toDumpString(&str1);
 //   getChildrenMatrix().toDumpString(&str2);
    SkDebugf("--- drawlayer %p opacity %g size [%g %g] pos [%g %g] matrix %s children %s\n",
             this, opacity * getOpacity(), m_size.width(), m_size.height(),
             m_position.fX, m_position.fY, str1.c_str(), str2.c_str());
#endif

    opacity = SkScalarMul(opacity, getOpacity());
    if (opacity <= 0) {
//        SkDebugf("---- abort drawing %p opacity %g\n", this, opacity);
        return;
    }

    SkAutoCanvasRestore acr(canvas, true);

    // apply our local transform
    {
        SkMatrix tmp;
        getLocalTransform(&tmp);
        if (shouldInheritFromRootTransform()) {
            // should we also apply the root's childrenMatrix?
            canvas->setMatrix(getRootLayer()->getMatrix());
        }
        canvas->concat(tmp);
    }

    onDraw(canvas, opacity);

#ifdef DEBUG_DRAW_LAYER_BOUNDS
    {
        SkRect r = SkRect::MakeSize(getSize());
        SkPaint p;
        p.setAntiAlias(true);
        p.setStyle(SkPaint::kStroke_Style);
        p.setStrokeWidth(SkIntToScalar(2));
        p.setColor(0xFFFF44DD);
        canvas->drawRect(r, p);
        canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, p);
        canvas->drawLine(r.fLeft, r.fBottom, r.fRight, r.fTop, p);
    }
#endif

    int count = countChildren();
    if (count > 0) {
        canvas->concat(getChildrenMatrix());
        for (int i = 0; i < count; i++) {
            getChild(i)->draw(canvas, opacity);
        }
    }
}
コード例 #7
0
ファイル: UIImageView.cpp プロジェクト: Srinoid/cocos2d-x
void ImageView::loadTexture(const char *fileName, TextureResType texType)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }
    _textureFile = fileName;
    _imageTexType = texType;
    switch (_imageTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (_scale9Enabled)
            {
                extension::CCScale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
                imageRendererScale9->initWithFile(fileName);
                imageRendererScale9->setColor(getColor());
                imageRendererScale9->setOpacity(getOpacity());
                imageRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                CCSprite* imageRenderer = STATIC_CAST_CCSPRITE;
                imageRenderer->initWithFile(fileName);
                imageRenderer->setColor(getColor());
                imageRenderer->setOpacity(getOpacity());
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (_scale9Enabled)
            {
                extension::CCScale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
                imageRendererScale9->initWithSpriteFrameName(fileName);
                imageRendererScale9->setColor(getColor());
                imageRendererScale9->setOpacity(getOpacity());
                imageRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                CCSprite* imageRenderer = STATIC_CAST_CCSPRITE;
                imageRenderer->initWithSpriteFrameName(fileName);
                imageRenderer->setColor(getColor());
                imageRenderer->setOpacity(getOpacity());
            }
            break;
        default:
            break;
    }
    _imageTextureSize = _imageRenderer->getContentSize();
    updateDisplayedColor(getColor());
    updateDisplayedOpacity(getOpacity());
    updateAnchorPoint();
    imageTextureScaleChangedWithSize();
}
コード例 #8
0
void LayerColorOpacityPropagated::setOpacity(GLubyte opacity)
{
	auto children = this->getChildren();
	for (auto child : children)
	{
		float co = child->getOpacity();
		float o = getOpacity();
		float op = co*(float)opacity / getOpacity()==0?1:getOpacity();
		child->setOpacity((GLubyte)op);
	}
	return Layer::setOpacity(opacity);
}
コード例 #9
0
ファイル: TeachLayer.cpp プロジェクト: LeeWei92/CocosGui
void TeachLayer::onEnter()
{
    auto pNode = this ->getParent();
    if (pNode && dynamic_cast<LayerColor*>(pNode))
    {
        if (0 < pNode->getOpacity())
        {
            _pNodeOriginalOpacity = pNode->getOpacity();
            pNode->setOpacity(0);
        }
    }
    Layer::onEnter();
}
コード例 #10
0
ファイル: OSGSlider.cpp プロジェクト: Langkamp/OpenSGToolbox
void Slider::drawInternal(const GraphicsWeakPtr TheGraphics, Real32 Opacity) const
{

    //Draw the Major Tick Marks
    if(getDrawMajorTicks())
    {
        for(UInt32 i(0) ; i<getMFMajorTickPositions()->size() ; ++i)
        {
            glPushMatrix();
            glTranslatef(getMajorTickPositions(i).x(), getMajorTickPositions(i).y(), 0.0f);
            if(getOrientation() != VERTICAL_ORIENTATION)
            {
                glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
            }

            //Draw the Draw Objects
            for(UInt32 j(0) ; j<getMFMajorTickDrawObjects()->size(); ++j)
            {
                getMajorTickDrawObjects(j)->draw(TheGraphics,getOpacity()*Opacity);
            }

            glPopMatrix();
        }

    }

    //Draw the Minor Tick Marks
    if(getDrawMinorTicks())
    {
        for(UInt32 i(0) ; i<getMFMinorTickPositions()->size() ; ++i)
        {
            glPushMatrix();
            glTranslatef(getMinorTickPositions(i).x(), getMinorTickPositions(i).y(), 0.0f);
            if(getOrientation() != VERTICAL_ORIENTATION)
            {
                glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
            }

            //Draw the Draw Objects
            for(UInt32 j(0) ; j<getMFMinorTickDrawObjects()->size(); ++j)
            {
                getMinorTickDrawObjects(j)->draw(TheGraphics, getOpacity()*Opacity);
            }

            glPopMatrix();
        }
    }


    Inherited::drawInternal(TheGraphics,Opacity);
}
コード例 #11
0
ファイル: FSprite.cpp プロジェクト: Sleicreider/hazelnut2k15
void FSprite::update(float delta)
{
#ifdef ETC1
    if(previous_opacity_ != (float)getOpacity())
    {
        //Update opacity in shader
        getGLProgramState()->setUniformFloat(opacity_location_, (float)getOpacity()/255.0);
        
        previous_opacity_ = (float) getOpacity();
    }
#endif
    
    AnimationUpdate();
}
コード例 #12
0
void TabPanel::drawTab(UInt32 TabIndex, Graphics* const TheGraphics, Real32 Opacity) const
{
    Pnt2f TabPosition(getTabs(TabIndex)->getPosition()), 
          TabBorderPosition;
    Vec2f TabSize(getTabs(TabIndex)->getSize()), 
          TabBorderSize;

    BorderRefPtr DrawnTabBorder(getDrawnTabBorder(TabIndex));

    LayerRefPtr DrawnTabBackground(getDrawnTabBackground(TabIndex));

    Real32 TabBorderLeftWidth, TabBorderRightWidth,TabBorderTopWidth, TabBorderBottomWidth;
    calculateTabBorderLengths(DrawnTabBorder, TabBorderLeftWidth, TabBorderRightWidth,TabBorderTopWidth, TabBorderBottomWidth);

    TabBorderPosition.setValues(TabPosition.x() - TabBorderLeftWidth, TabPosition.y() - TabBorderTopWidth);
    TabBorderSize.setValues(TabSize.x() + TabBorderLeftWidth + TabBorderRightWidth,
                            TabSize.y() + TabBorderTopWidth + TabBorderBottomWidth);

    if(DrawnTabBorder != NULL)
    {
        DrawnTabBorder->draw(TheGraphics,
                             TabBorderPosition.x(), TabBorderPosition.y(),
                             TabBorderSize.x(), TabBorderSize.y(),
                             getOpacity()*Opacity);
        //DrawnTabBorder->activateInternalDrawConstraints(TheGraphics,
        //                 TabBorderPosition.x(), TabBorderPosition.y(),
        //				 TabBorderSize.x(), TabBorderSize.y());
    }

    if(DrawnTabBackground != NULL)
    {
        DrawnTabBackground->draw(TheGraphics, 
                                 TabPosition, 
                                 TabPosition + TabSize, 
                                 getOpacity()*Opacity);
    }

    //Draw the tab component
    getTabs(TabIndex)->draw(TheGraphics, getOpacity()*Opacity);

    setupClipping(TheGraphics);

    if(DrawnTabBorder != NULL)
    {
        DrawnTabBorder->deactivateInternalDrawConstraints(TheGraphics,
                                                          TabBorderPosition.x(), TabBorderPosition.y(),
                                                          TabBorderSize.x(), TabBorderSize.y());
    }
}
コード例 #13
0
ファイル: Map.cpp プロジェクト: pecore/LEFT
void Map::draw()
{
  MapObject * o = 0;
  foreach(MapObjectList, o, mMapObjects) {
    o->setAlpha(getOpacity(o->pos()));
    o->draw();
  }
コード例 #14
0
ファイル: RippleNode.cpp プロジェクト: agiantwhale/segments
void RippleNode::draw()
{
    CCNodeRGBA::draw();
    
    ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    
    ccDrawInit();
    
    ccDrawColor4B(getColor().r, getColor().g, getColor().b, getOpacity());
    
    glLineWidth(3.f * SCREEN_SCALE());
    ccPointSize(3.f * SCREEN_SCALE() * 0.5f);
    
    Rig rig;
    rig.reserve(RIG_VERTEXES());
    for(int i = 0; i < RIG_VERTEXES(); i++)
    {
        CCPoint vertex = ccpRotateByAngle(CCPointMake(0, 200.f * SCREEN_SCALE()), CCPointZero, M_PI * 2 * i / RIG_VERTEXES() + getRotation());
        rig.push_back(vertex);
    }
    
    ccDrawPoly(&rig[0], rig.size(), true);
    
    ccDrawPoint(CCPointZero);
    
    ccDrawFree();
    
    ccGLBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
    
    CC_INCREMENT_GL_DRAWS(1);
}
コード例 #15
0
ファイル: color_list_widget.cpp プロジェクト: sikmir/mapper
void ColorListWidget::cellChange(int row, int column)
{
	if (!react_to_changes)
		return;
	
	react_to_changes = false;
	
	auto color = map->getMapColor(row);
	auto text = color_table->item(row, column)->text().trimmed();
	
	if (column == 1)
	{
		color->setName(text);
		react_to_changes = true;
	}
	else if (column == 6) // Opacity
	{
		auto opacity = color_table->item(row, column)->data(Qt::DisplayRole).toFloat();
		if (!qFuzzyCompare(1.0f+opacity, 1.0f+color->getOpacity()))
		{
			color->setOpacity(qBound(0.0f, opacity, 1.0f));
			updateRow(row);
		}
		react_to_changes = true;
	}
	else 
	{
		react_to_changes = true;
		return;
	}
	
	map->setColor(color, row); // trigger colorChanged signal
	map->setColorsDirty();
	map->updateAllObjects();
}
コード例 #16
0
void Graphics3DExtrude::drawText(const Pnt2f& Position, const std::string& Text, const UIFontUnrecPtr TheFont, const Color4f& Color, const Real32& Opacity) const
{
   TextLayoutParam layoutParam;
   layoutParam.spacing = 1.1;
   layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN;
   layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN;
 
   TextLayoutResult layoutResult;
   TheFont->layout(Text, layoutParam, layoutResult);

   TheFont->getTexture()->activate(getDrawEnv());

   Real32 Alpha(Color.alpha() * Opacity * getOpacity());
	
   //Setup the blending equations properly
   glPushAttrib(GL_COLOR_BUFFER_BIT);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);

   glColor4f(Color.red(), Color.green(), Color.blue(), Alpha );
   glPushMatrix();
   glTranslatef(Position.x(), Position.y(), 0.0);
   glScalef(TheFont->getSize(), TheFont->getSize(), 1);
   drawCharacters(layoutResult, TheFont);
   glPopMatrix();

   TheFont->getTexture()->deactivate(getDrawEnv());

	glDisable(GL_BLEND);
   glPopAttrib();
}
コード例 #17
0
void ComponentMenuItem::drawInternal(Graphics* const TheGraphics, Real32 Opacity) const
{
    if(getComponent() != NULL)
    {
        getComponent()->draw(TheGraphics, getOpacity()*Opacity);
    }
}
コード例 #18
0
void CCLineNode::draw()
{
	const ccColor3B& tColor(getColor());
	ccDrawColor4B(tColor.r, tColor.g, tColor.b, getOpacity());
	CCPoint tOrigin(isIgnoreAnchorPointForPosition() ? CCPointZero : getAnchorPointInPoints());
	ccDrawLine(tOrigin, ccpShift(tOrigin, getContentSize()));
}
コード例 #19
0
ファイル: textlayer.cpp プロジェクト: andrejsavikin/mishira
void TextLayer::render(
	VidgfxContext *gfx, Scene *scene, uint frameNum, int numDropped)
{
	// Has the layer width changed since we rendered the document texture?
	if(m_rect.width() != m_document.textWidth()) {
		// It has, we need to repaint the document texture
		m_isTexDirty = true;
		updateResources(gfx);
	}

	VidgfxVertBuf *vertBuf = vidgfx_texdecalbuf_get_vert_buf(m_vertBuf);
	if(m_texture == NULL || vertBuf == NULL)
		return; // Nothing to render

	vidgfx_context_set_shader(gfx, GfxTexDecalShader);
	vidgfx_context_set_topology(
		gfx, vidgfx_texdecalbuf_get_topology(m_vertBuf));
	vidgfx_context_set_blending(gfx, GfxAlphaBlending);
	QColor prevCol = vidgfx_context_get_tex_decal_mod_color(gfx);
	vidgfx_context_set_tex_decal_mod_color(
		gfx, QColor(255, 255, 255, (int)(getOpacity() * 255.0f)));
	vidgfx_context_set_tex(gfx, m_texture);
	vidgfx_context_set_tex_filter(gfx, GfxBilinearFilter);
	vidgfx_context_draw_buf(gfx, vertBuf);
	vidgfx_context_set_tex_decal_mod_color(gfx, prevCol);
}
コード例 #20
0
void UIDrawObjectCanvas::drawInternal(Graphics* const Graphics, Real32 Opacity) const
{
    for(UInt32 i(0) ; i<getMFDrawObjects()->size(); ++i)
    {
        getDrawObjects(i)->draw(Graphics, getOpacity()*Opacity);
    }
}
コード例 #21
0
void RotatedComponent::drawInternal(Graphics* const TheGraphics, Real32 Opacity) const
{
    if(getInternalComponent() != NULL)
    {
        Pnt2f TopLeft, BottomRight;
        getInsideInsetsBounds(TopLeft, BottomRight);

        TheGraphics->incrDrawBounderiesNesting();

        TheGraphics->initAddDrawBounderies();
        TheGraphics->drawRect(TopLeft, BottomRight,Color4f(0.0f,0.0f,0.0f,1.0f),1.0);
        TheGraphics->uninitAddDrawBounderies();

        TheGraphics->activateDrawBounderiesTest();


        glPushMatrix();
        glTranslatef(static_cast<Real32>(getSize().x())/2.0,static_cast<Real32>(getSize().y())/2.0,0.0);
        glRotatef(-osgRad2Degree(getAngle()), 0.0,0.0,1.0);
        glTranslatef(-static_cast<Real32>(getInternalComponent()->getSize().x())/2.0,-static_cast<Real32>(getInternalComponent()->getSize().y())/2.0,0.0);
        getInternalComponent()->draw(TheGraphics, getOpacity()*Opacity);
        glPopMatrix();


        TheGraphics->decrDrawBounderiesNestring();
        TheGraphics->initRemoveDrawBounderies();
        TheGraphics->drawRect(TopLeft, BottomRight,Color4f(0.0f,0.0f,0.0f,1.0f),1.0);
        TheGraphics->uninitRemoveDrawBounderies();
        TheGraphics->activateDrawBounderiesTest();
    }
}
コード例 #22
0
void Graphics3DExtrude::drawArc(const Pnt2f& Center, const Real32& Width, const Real32& Height, const Real32& StartAngleRad, const Real32& EndAngleRad, const Real32& LineWidth, const UInt16& SubDivisions, const Color4f& Color, const Real32& Opacity) const
{
	GLfloat previousLineWidth;
	glGetFloatv(GL_LINE_WIDTH, &previousLineWidth);
	Real32 angleNow = StartAngleRad;
	Real32 angleDiff = (EndAngleRad-StartAngleRad)/(static_cast<Real32>(SubDivisions));
	//If andle difference is bigger to a circle, set it to equal to a circle
	if(EndAngleRad-StartAngleRad > 2*3.1415926535)
		angleDiff = 2*3.1415926535/static_cast<Real32>(SubDivisions);
   Real32 Alpha(Color.alpha() * Opacity * getOpacity());
	if(Alpha < 1.0)
	{
		//Setup the blending equations properly
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
	}
	glLineWidth(LineWidth);
	glBegin(GL_LINE_STRIP);
      glColor4f(Color.red(), Color.green(), Color.blue(), Alpha );
		//draw vertex lines
      for(UInt16 i = 0 ; i<SubDivisions+1 ; ++i)
      {
			glVertex2f( static_cast<Real32>(Center.x()) + static_cast<Real32>(Width)*osgCos(angleNow ),static_cast<Real32>(Center.y()) +static_cast<Real32>(Height)*osgSin(angleNow));
			//glVertex2f(Center.x() + Width*osgCos(angleNow + angleDiff), Center.y() + Height*osgSin(angleNow+angleDiff));
			angleNow += angleDiff;
		}
	glEnd();

	
	if(Alpha < 1.0)
	{
		glDisable(GL_BLEND);
	}
   glLineWidth(previousLineWidth);
}
コード例 #23
0
void LoadingBar::loadTexture(const char* texture,TextureResType texType)
{
    if (!texture || strcmp(texture, "") == 0)
    {
        return;
    }
    _renderBarTexType = texType;
    _textureFile = texture;
    switch (_renderBarTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (_scale9Enabled)
            {
                extension::Scale9Sprite* barRendererScale9 = static_cast<extension::Scale9Sprite*>(_barRenderer);
                barRendererScale9->initWithFile(texture);
                barRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                static_cast<Sprite*>(_barRenderer)->setTexture(texture);
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (_scale9Enabled)
            {
                extension::Scale9Sprite* barRendererScale9 = static_cast<extension::Scale9Sprite*>(_barRenderer);
                barRendererScale9->initWithSpriteFrameName(texture);
                barRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                static_cast<Sprite*>(_barRenderer)->setSpriteFrame(texture);
            }
            break;
        default:
            break;
    }
    updateDisplayedColor(getColor());
    updateDisplayedOpacity(getOpacity());
    _barRendererTextureSize = _barRenderer->getContentSize();
    
    switch (_barType)
    {
    case LoadingBarTypeLeft:
        _barRenderer->setAnchorPoint(Point(0.0f,0.5f));
        if (!_scale9Enabled)
        {
            static_cast<Sprite*>(_barRenderer)->setFlippedX(false);
        }
        break;
    case LoadingBarTypeRight:
        _barRenderer->setAnchorPoint(Point(1.0f,0.5f));
        if (!_scale9Enabled)
        {
            static_cast<Sprite*>(_barRenderer)->setFlippedX(true);
        }
        break;
    }
    barRendererScaleChangedWithSize();
}
コード例 #24
0
void InternalWindow::drawInternal(Graphics* const TheGraphics, Real32 Opacity) const
{
    Inherited::drawInternal(TheGraphics, Opacity);

    //If I have an active TitleBar then draw it
    if(getDrawDecorations() && getDrawTitlebar() && getTitlebar() != NULL)
    {
        getTitlebar()->draw(TheGraphics, Opacity*getOpacity());
    }

    //If I have a MenuBar then Draw it
    if(getMenuBar() != NULL)
    {
        getMenuBar()->draw(TheGraphics, Opacity*getOpacity());
    }
}
コード例 #25
0
void InternalWindow::drawUnclipped(Graphics* const TheGraphics, Real32 Opacity) const
{
    Inherited::drawUnclipped(TheGraphics, Opacity);

    //If I have an active tooltip then draw it
    if(getActiveToolTip() != NULL)
    {
        getActiveToolTip()->draw(TheGraphics, Opacity*getOpacity());
    }

    //If I have an active popupMenu then draw it
    for(UInt32 i(0) ; i<getMFActivePopupMenus()->size() ; ++i)
    {
        getActivePopupMenus(i)->draw(TheGraphics, Opacity*getOpacity());
    }
}
コード例 #26
0
ファイル: UISlider.cpp プロジェクト: 109383670/cocos2d-x
void UISlider::loadProgressBarTexture(const char *fileName, TextureResType texType)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }
    m_strProgressBarTextureFile = fileName;
    m_eProgressBarTexType = texType;
    switch (m_eProgressBarTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (m_bScale9Enabled)
            {
                dynamic_cast<CCScale9Sprite*>(m_pProgressBarRenderer)->initWithFile(fileName);
            }
            else
            {
                dynamic_cast<CCSprite*>(m_pProgressBarRenderer)->initWithFile(fileName);
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (m_bScale9Enabled)
            {
                dynamic_cast<CCScale9Sprite*>(m_pProgressBarRenderer)->initWithSpriteFrameName(fileName);
            }
            else
            {
                dynamic_cast<CCSprite*>(m_pProgressBarRenderer)->initWithSpriteFrameName(fileName);
            }
            break;
        default:
            break;
    }
    if (m_bScale9Enabled)
    {
        dynamic_cast<CCScale9Sprite*>(m_pProgressBarRenderer)->setColor(getColor());
        dynamic_cast<CCScale9Sprite*>(m_pProgressBarRenderer)->setOpacity(getOpacity());
    }
    else
    {
        dynamic_cast<CCSprite*>(m_pProgressBarRenderer)->setColor(getColor());
        dynamic_cast<CCSprite*>(m_pProgressBarRenderer)->setOpacity(getOpacity());
    }
    m_pProgressBarRenderer->setAnchorPoint(ccp(0.0f, 0.5f));
    m_ProgressBarTextureSize = m_pProgressBarRenderer->getContentSize();
    progressBarRendererScaleChangedWithSize();
}
コード例 #27
0
ファイル: UIImageView.cpp プロジェクト: studio501/BlockPuzzle
void UIImageView::loadTexture(const char *fileName, TextureResType texType)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }
    m_strTextureFile = fileName;
    m_eImageTexType = texType;
    switch (m_eImageTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (m_bScale9Enabled)
            {
                DYNAMIC_CAST_SCALE9SPRITE->initWithFile(fileName);
                DYNAMIC_CAST_SCALE9SPRITE->setColor(getColor());
                DYNAMIC_CAST_SCALE9SPRITE->setOpacity(getOpacity());
                DYNAMIC_CAST_SCALE9SPRITE->setCapInsets(m_capInsets);
            }
            else
            {
                DYNAMIC_CAST_CCSPRITE->initWithFile(fileName);
                DYNAMIC_CAST_CCSPRITE->setColor(getColor());
                DYNAMIC_CAST_CCSPRITE->setOpacity(getOpacity());
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (m_bScale9Enabled)
            {
                DYNAMIC_CAST_SCALE9SPRITE->initWithSpriteFrameName(fileName);
                DYNAMIC_CAST_SCALE9SPRITE->setColor(getColor());
                DYNAMIC_CAST_SCALE9SPRITE->setOpacity(getOpacity());
                DYNAMIC_CAST_SCALE9SPRITE->setCapInsets(m_capInsets);
            }
            else
            {
                DYNAMIC_CAST_CCSPRITE->initWithSpriteFrameName(fileName);
                DYNAMIC_CAST_CCSPRITE->setColor(getColor());
                DYNAMIC_CAST_CCSPRITE->setOpacity(getOpacity());
            }
            break;
        default:
            break;
    }
    m_imageTextureSize = m_pImageRenderer->getContentSize();
    updateAnchorPoint();
    imageTextureScaleChangedWithSize();
}
コード例 #28
0
void UISlider::setBarTexture(const char* fileName, TextureResType texType)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }
    m_strTextureFile = fileName;
    m_eBarTexType = texType;
    switch (m_eBarTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (m_bBarScale9Enable)
            {
                dynamic_cast<CCScale9Sprite*>(m_pBarNode)->initWithFile(fileName);
            }
            else
            {
                dynamic_cast<CCSprite*>(m_pBarNode)->initWithFile(fileName);
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (m_bBarScale9Enable)
            {
                dynamic_cast<CCScale9Sprite*>(m_pBarNode)->initWithSpriteFrameName(fileName);
            }
            else
            {
                dynamic_cast<CCSprite*>(m_pBarNode)->initWithSpriteFrameName(fileName);
            }
            break;
        default:
            break;
    }
    if (m_bBarScale9Enable)
    {
        dynamic_cast<CCScale9Sprite*>(m_pBarNode)->setColor(getColor());
        dynamic_cast<CCScale9Sprite*>(m_pBarNode)->setOpacity(getOpacity());
    }
    else
    {
        dynamic_cast<CCSprite*>(m_pBarNode)->setColor(getColor());
        dynamic_cast<CCSprite*>(m_pBarNode)->setOpacity(getOpacity());
    }
    
    m_fBarLength = m_pBarNode->getContentSize().width;
    setSlidBallPercent(m_nBarPercent);
}
コード例 #29
0
ファイル: txshmeshcolumn.cpp プロジェクト: SaierMe/opentoonz
void TXshMeshColumn::saveData(TOStream &os) {
  os.child("status") << getStatusWord();
  if (getOpacity() < 255) os.child("camerastand_opacity") << (int)getOpacity();

  int r0, r1;
  if (getRange(r0, r1)) {
    os.openChild("cells");
    {
      for (int r = r0; r <= r1; ++r) {
        TXshCell cell = getCell(r);
        if (cell.isEmpty()) continue;

        TFrameId fid = cell.m_frameId;
        int n = 1, inc = 0, dr = fid.getNumber();

        // If fid has no letter save more than one cell and its increment -
        // otherwise save just one cell
        if (r < r1 && fid.getLetter() == 0) {
          TXshCell cell2 = getCell(r + 1);
          TFrameId fid2  = cell2.m_frameId;

          if (cell2.m_level.getPointer() == cell.m_level.getPointer() &&
              fid2.getLetter() == 0) {
            inc = cell2.m_frameId.getNumber() - dr;
            for (++n;; ++n) {
              if (r + n > r1) break;

              cell2         = getCell(r + n);
              TFrameId fid2 = cell2.m_frameId;

              if (cell2.m_level.getPointer() != cell.m_level.getPointer() ||
                  fid2.getLetter() != 0)
                break;

              if (fid2.getNumber() != dr + n * inc) break;
            }
          }
        }

        os.child("cell") << r << n << cell.m_level.getPointer() << fid.expand()
                         << inc;
        r += n - 1;
      }
    }
    os.closeChild();
  }
}
コード例 #30
0
void UISlider::setProgressBarTexture(const char *fileName, TextureResType texType)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }
    switch (m_eBarTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (m_bBarScale9Enable)
            {
                dynamic_cast<CCScale9Sprite*>(m_pProgressBarNode)->initWithFile(fileName);
            }
            else
            {
                dynamic_cast<CCSprite*>(m_pProgressBarNode)->initWithFile(fileName);
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (m_bBarScale9Enable)
            {
                dynamic_cast<CCScale9Sprite*>(m_pProgressBarNode)->initWithSpriteFrameName(fileName);
            }
            else
            {
                dynamic_cast<CCSprite*>(m_pProgressBarNode)->initWithSpriteFrameName(fileName);
            }
            break;
        default:
            break;
    }
    if (m_bBarScale9Enable)
    {
        dynamic_cast<CCScale9Sprite*>(m_pProgressBarNode)->setColor(getColor());
        dynamic_cast<CCScale9Sprite*>(m_pProgressBarNode)->setOpacity(getOpacity());
    }
    else
    {
        dynamic_cast<CCSprite*>(m_pProgressBarNode)->setColor(getColor());
        dynamic_cast<CCSprite*>(m_pProgressBarNode)->setOpacity(getOpacity());
    }
    m_pProgressBarNode->setAnchorPoint(ccp(0.0, 0.5));
    m_pProgressBarNode->setPosition(ccp(m_pBarNode->getPosition().x - m_pBarNode->getContentSize().width / 2, m_pBarNode->getPosition().y - 1));
    m_pProgressBarNode->setContentSize(CCSizeMake(m_pBarNode->getContentSize().width, m_pBarNode->getContentSize().height));
    setProgressBarScale();
}