void CALabel::updateImage() { CAImage *tex = new CAImage(); float fontHeight = getFontHeight(m_nfontName.c_str(), m_nfontSize); unsigned int linenumber = (int)this->getBounds().size.height/fontHeight; CCSize size = CCSizeZero; if ((m_nNumberOfLine <= linenumber && m_nNumberOfLine != 0)) { size = CCSizeMake(this->getBounds().size.width, fontHeight*m_nNumberOfLine); } else { size = this->getBounds().size; } tex->initWithString(m_nText.c_str(), m_nfontName.c_str(), m_nfontSize* CC_CONTENT_SCALE_FACTOR(), size, m_nTextAlignment, m_nVerticalTextAlignmet); m_cLabelSize = tex->getContentSize(); CCRect rect = CCRectZero; rect.size.width = this->getBounds().size.width; rect.size.height = tex->getContentSize().height; float width = MIN(this->getBounds().size.width,tex->getContentSize().width); rect.size.width = width; this->setImage(tex); switch (m_nVerticalTextAlignmet) { case CAVerticalTextAlignmentTop: pTextHeight =0; break; case CAVerticalTextAlignmentCenter: pTextHeight =(this->getBounds().size.height-rect.size.height)/2; break; case CAVerticalTextAlignmentBottom: pTextHeight =this->getBounds().size.height - rect.size.height; break; default: break; } this->setImageRect(rect); tex->release(); return ; }
bool CALabel::updateImage() { if (m_bRunning == false) { return false; } CAImage *tex = new CAImage(); if (!tex) { return false; } caFontDefinition fontDef = setFontDefiniton(true); CAImage *at = new CAImage(); at->initWithString("9m", fontDef.m_fontName.c_str(), fontDef.m_fontSize, CCSizeZero, fontDef.m_alignment, fontDef.m_vertAlignment); float fontHeight = at->getContentSize().height+1; at->release(); unsigned int linenumber = (int)this->getBounds().size.height/fontHeight; if (m_nNumberOfLine <= linenumber && m_nNumberOfLine != 0) { tex->initWithString(m_nText.c_str(), fontDef.m_fontName.c_str(), fontDef.m_fontSize, CCSizeZero, fontDef.m_alignment, fontDef.m_vertAlignment); } else { if (this->getBounds().size.width == 0 && this->getBounds().size.height == 0) { tex->initWithString(m_nText.c_str(), fontDef.m_fontName.c_str(), fontDef.m_fontSize, CCSizeZero, fontDef.m_alignment, fontDef.m_vertAlignment); } else { tex->initWithString(m_nText.c_str(), fontDef.m_fontName.c_str(), fontDef.m_fontSize, this->getBounds().size, fontDef.m_alignment, fontDef.m_vertAlignment); } } CCRect rect = CCRectZero; rect.size = tex->getContentSize(); m_cLabelSize = tex->getContentSize(); m_pTextImage->setImage(tex); m_pTextImage->setImageRect(rect); m_pTextImage->setColor(ccc3(m_nTextcolor.r, m_nTextcolor.g, m_nTextcolor.b)); m_pTextImage->setOpacity(m_nTextcolor.a); m_pTextImage->CAView::setFrameOrigin(CCPoint(0, (this->getBounds().size.height - rect.size.height)/2)); tex->release(); return true; }
void CATextField::updateImage() { float fontHeight = CAImage::getFontHeight("Arial", m_fFontSize); CCSize size = CCSizeZero; size = CCSizeMake(0, fontHeight); std::string text = ""; if (spaceHolderIsOn) { text = m_sPlaceHolder; this->setColor(m_cSpaceHolderColor); } else { text = m_sText; this->setColor(m_cTextColor); } CAImage* image = CAImage::createWithString(text.c_str(), "Arial", m_fFontSize * CC_CONTENT_SCALE_FACTOR(), size, m_aTextAlignment, CAVerticalTextAlignmentCenter); CCRect rect = CCRectZero; float imageWidth = 0; if (image != NULL) { rect.size.height = image->getContentSize().height; m_rLabelRect.size = image->getContentSize(); imageWidth = image->getContentSize().width; } if (spaceHolderIsOn) { m_rLabelRect = CCRectZero; } float width = MIN(labelWidth, imageWidth); rect.size.width = width; this->setImage(image); pTextHeight = (this->getBounds().size.height-rect.size.height)/2; rect.origin.x = m_fString_left_offX; this->setImageRect(rect); return ; }
void CANavigationBar::showTitle() { CCRect rect; rect.origin = this->getBounds().size/2; rect.size.height = this->getBounds().size.height; rect.size.width = this->getBounds().size.width - rect.size.height * 4; if (m_pTitle) { this->removeSubview(m_pTitle); m_pTitle = NULL; } CAImage* image = m_pItems.back()->getTitleViewImage(); if (image) { float height = MIN(image->getContentSize().height, rect.size.height * 0.75f); float width = height * image->getContentSize().width / image->getContentSize().height; width = MIN(rect.size.width, width); rect.size = CCSize(width, height); m_pTitle = CAImageView::createWithImage(image); m_pTitle->setCenter(rect); this->addSubview(m_pTitle); } else { int fontSize = this->getBounds().size.height * 0.35f / CROSSAPP_ADPTATION_RATIO; CALabel* title = CALabel::createWithCenter(rect); title->setTextAlignment(CATextAlignmentCenter); title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); title->setNumberOfLine(1); title->setColor(CAColor_white); title->setFontSize(fontSize); this->addSubview(title); m_pTitle = title; } if (!m_pItems.empty()) { std::string str = m_pItems.back()->getTitle(); ((CALabel*)m_pTitle)->setText(str.c_str()); } }
void CATextView::updateImage() { std::string text; if (m_szText.empty()) { text = m_sPlaceHolder; } else { text = m_szText; } m_cFontColor = m_szText.empty() ? m_cPlaceHolderColor : m_cTextColor; float width = this->getBounds().size.width; width -= m_iHoriMargins * 2; CAImage* image = g_AFTFontCache.initWithString(text.c_str(), m_szFontName.c_str(), m_iFontSize, width, 0, CATextAlignmentLeft, CAVerticalTextAlignmentTop, m_bWordWrap, m_iLineSpacing, false, false, false, &m_vLinesTextView); if (m_szText.empty()) { m_vLinesTextView.clear(); } m_pImageView->setColor(m_cFontColor); m_pImageView->setImage(image); CCRect rect = CCRectZero; if (image) { rect.size = image->getContentSize(); } m_pImageView->setImageRect(rect); m_pContainerView->setViewSize(CCSizeMake(rect.size.width, rect.size.height)); rect.origin = CCPointMake(m_iHoriMargins, 0); m_pImageView->setFrame(rect); calcCursorPosition(); }
float CATextField::getStringLength(const std::string &var) { float length = 0; CAImage *image = CAImage::createWithString(var.c_str(), "", m_fFontSize, CCSizeZero, CATextAlignmentLeft, CAVerticalTextAlignmentCenter); length = image->getContentSize().width; return length; }
NS_CC_BEGIN static unsigned int getFontHeight(const char *fontName, int fontSize) { unsigned int result=0; CAImage *image = new CAImage(); image->initWithString("9m", fontName, fontSize, CCSizeZero, CATextAlignmentLeft, CAVerticalTextAlignmentTop); CAImage *image1 = new CAImage(); image1->initWithString("9\nm", fontName, fontSize, CCSizeZero, CATextAlignmentLeft, CAVerticalTextAlignmentTop); result = image1->getContentSize().height-image->getContentSize().height; image->release(); image1->release(); return result; }
void CATextField::initMarkSprite() { int pixels[1][1]; pixels[0][0] = 0; CAImage *image = new CAImage(); image->initWithData(pixels, kCAImagePixelFormat_RGB888, 1, 1, CCSizeMake(m_fFontSize / 10.0f, m_fFontSize)); m_pMark = CAImageView::createWithImage(image); m_pMark->setVisible(false); CCSize contentsize =this->getBounds().size; m_pMark->setFrame(CCRect(0, 0, image->getContentSize().width, m_fFontSize)); this->addSubview(m_pMark); m_pCursorAction = CCRepeatForever::create((CCActionInterval *) CCSequence::create(CCFadeOut::create(0.5f), CCFadeIn::create(0.5f), NULL)); m_pMark->runAction(m_pCursorAction); }
int CATextView::getStringLength(const std::string &var) { #if (CC_TARGET_PLATFORM != CC_PLATFORM_LINUX) return g_AFTFontCache.getStringWidth(m_szFontName.c_str(), m_iFontSize, var); #else CAImage *image = CAImage::createWithString(var.c_str(), "", m_iFontSize, CCSizeZero, CATextAlignmentLeft, CAVerticalTextAlignmentCenter); if (image != NULL) { return image->getContentSize().width; } return 0; #endif }
void CAGifView::setGif(CAGif* gif) { CC_SAFE_RETAIN(gif); CC_SAFE_DELETE(m_pGif); m_pGif = gif; if (m_pGif) { CAImage* image = m_pGif->getImage(); this->setImage(image); CCRect rect = CCRectZero; rect.size = image->getContentSize(); this->setImageRect(rect); if(m_pGif->getGifImageCounts()>1) { m_nGifcount = m_pGif->getGifImageCounts(); CAScheduler::schedule(schedule_selector(CAGifView::updateGif), this, 0); } this->setGifBounds(this->getBounds().size); } }
bool CAIndicator::initWithFrame(const CCRect& rect, CAIndicatorType type) { if (!CAView::init()) { return false; } this->setFrame(rect); m_eType = type; CAImage* image = CAImage::create("indicator.png"); CCRect r; r.origin = ccpSub(ccpMult(image->getContentSize(), 0.5f), CCPoint(0.5f, 0.5f)); r.size = CCSize(1.0f, 1.0f); m_pIndicator = CCScale9Sprite::createWithImage(r, image); this->addSubview(m_pIndicator); return true; }
void updateImage() { float width = this->getBounds().size.width; CAImage* image = g_AFTFontCache.initWithString(m_szText.c_str(), m_pCATextView->getTextColor(), m_szFontName.c_str(), m_pCATextView->getTextFontSize(), width, 0, CATextAlignmentLeft, CAVerticalTextAlignmentTop, true, 0, false, false, false, false, &m_vLinesTextView); if (m_szText.empty()) { m_vLinesTextView.clear(); } m_pImageView->setColor(CAColor_white); m_pImageView->setImage(image); DRect rect = DRectZero; if (image) { rect.size = image->getContentSize(); } m_pImageView->setImageRect(rect); m_pContainerView->setViewSize(rect.size); m_pImageView->setFrame(rect); calcCursorPosition(); m_pCurPosition = m_pCursorMark->getCenterOrigin(); }
void CAGifView::updateGif(float delta) { CC_RETURN_IF(!m_pGif); float ldelta = (uint32_t)(delta * 1000) * m_fTimes; m_fDurTime += ldelta; if(m_fDurTime > m_pGif->getImageDuration()) { m_pGif->nextGifImageIndex(); CAImage* image = m_pGif->getImage(); this->setImage(image); if (image) { CCRect rect = CCRectZero; rect.size = image->getContentSize(); this->setImageRect(rect); } m_fDurTime = 0; } if (!m_bIsRepeatForever && m_pGif->getGifImageIndex() >= m_pGif->getGifImageCounts() - 1) { CAScheduler::unschedule(schedule_selector(CAGifView::updateGif), this); } }
void updateImage() { const std::string& sPlaceHolder = m_pTextFieldX->getPlaceHolderText(); CAColor4B cFontColor; std::string text; if (m_sText.empty()) { text = sPlaceHolder; cFontColor = m_pTextFieldX->getPlaceHolderColor(); } else { text = m_sText; cFontColor = m_pTextFieldX->getTextColor(); } if (m_pTextFieldX->isSecureTextEntry()) { std::string password; for (std::string::size_type i = 0; i < m_sText.length(); i++) { password.append("*"); } if (password.empty()) { text = sPlaceHolder; } else { text = password; } } int fontSize = m_pTextFieldX->getFontSize(); m_iFontHeight = CAImage::getFontHeight(m_szFontName.c_str(), fontSize); DSize size = DSize(0, m_iFontHeight); CAImage* image = CAImage::createWithString(text.c_str(), cFontColor, m_szFontName.c_str(), fontSize, size, CATextAlignmentLeft, CAVerticalTextAlignmentCenter, true); DRect rect = DRectZero; if (sPlaceHolder.length() == 0) { this->setImage(image); this->setImageRect(rect); } CC_RETURN_IF(image == NULL); rect.size.height = image->getContentSize().height; rect.size.width = MIN(m_iLabelWidth, image->getContentSize().width); if (text.empty()) { m_cImageSize = DSizeZero; } else { m_cImageSize = image->getContentSize(); } this->setImage(image); rect.origin.x = -m_iString_o_length; this->setImageRect(rect); }
void CATextField::updateImage() { std::string text = ""; if (m_sText.empty()) { text = m_sPlaceHolder; this->setColor(m_cSpaceHolderColor); } else { text = m_sText; this->setColor(m_cTextColor); } std::string password(""); if (m_nInputType == KEY_BOARD_INPUT_PASSWORD) { for (std::string::size_type i = 0; i<m_sText.length(); i++) { password.append("*"); } if (m_sText.empty()) { text = m_sPlaceHolder; } else { text = password; } } float dt = 1.0f; #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) dt = 1.2f; #endif CCSize size = CCSizeMake(0, m_iFontHeight*dt); CAImage* image = CAImage::createWithString(text.c_str(), m_nfontName.c_str(), m_iFontSize, size, CATextAlignmentLeft, CAVerticalTextAlignmentCenter, true); CCRect rect = CCRectZero; if (m_sPlaceHolder.length() == 0) { this->setImage(image); this->setImageRect(rect); } if (image == NULL ) return; rect.size.height = image->getContentSize().height; rect.size.width = MIN(m_iLabelWidth, image->getContentSize().width); if (text.empty()) { m_cImageSize = CCSizeZero; } else { m_cImageSize = image->getContentSize(); } this->setImage(image); rect.origin.x = -m_iString_left_offX; this->setImageRect(rect); }
void CALabel::updateImage() { float fontHeight = CAImage::getFontHeight(m_nfontName.c_str(), m_nfontSize); unsigned int linenumber = 0; if (this->getBounds().size.height == 0) { linenumber = m_nNumberOfLine; } else { linenumber = (int)this->getBounds().size.height / fontHeight; } CCSize size = CCSizeZero; if ((m_nNumberOfLine <= linenumber && m_nNumberOfLine != 0)) { size = CCSizeMake(this->getBounds().size.width, fontHeight*m_nNumberOfLine); } else { size = this->getBounds().size; size.height = linenumber *fontHeight; } CAImage* image = CAImage::createWithString(m_nText.c_str(), m_nfontName.c_str(), m_nfontSize, size, m_nTextAlignment, m_nVerticalTextAlignmet); CC_RETURN_IF(image == NULL); m_cLabelSize = image->getContentSize(); CCRect rect = CCRectZero; rect.size.width = this->getBounds().size.width; rect.size.height = image->getContentSize().height; float width = MIN(this->getBounds().size.width,image->getContentSize().width); rect.size.width = width; this->setImage(image); switch (m_nVerticalTextAlignmet) { case CAVerticalTextAlignmentTop: pTextHeight =0; break; case CAVerticalTextAlignmentCenter: pTextHeight =(this->getBounds().size.height-rect.size.height)/2; break; case CAVerticalTextAlignmentBottom: pTextHeight =this->getBounds().size.height - rect.size.height; break; default: break; } this->setImageRect(rect); }
void CALabel::updateImage() { int fontHeight = CAImage::getFontHeight(m_nfontName.c_str(), m_nfontSize); int defaultLineSpace = fontHeight / 4; unsigned int linenumber = (int)this->getBounds().size.height / fontHeight; DSize size = DSizeZero; if (m_bFitFlag) { float width = CAImage::getStringWidth(m_nfontName.c_str(), m_nfontSize, m_nText); if (width > m_obContentSize.width) { if (m_nNumberOfLine > 1) { size = DSize(this->getBounds().size.width, (defaultLineSpace + m_iLineSpacing + fontHeight) * m_nNumberOfLine); } else if (m_nNumberOfLine == 1) { size = DSize(width, fontHeight); } else { size.width = this->getBounds().size.width; size.height = CAImage::getStringHeight(m_nfontName.c_str(), m_nfontSize, m_nText, size.width, m_iLineSpacing, m_bWordWrap); } } else { size.height = fontHeight; size.width = width; } } else { if (linenumber == 0) { size = this->getBounds().size; } else { if (m_nNumberOfLine > 0) { size = DSize(this->getBounds().size.width, (defaultLineSpace + m_iLineSpacing + fontHeight) * MIN(m_nNumberOfLine, linenumber)); } else { size = DSize(this->getBounds().size.width, (defaultLineSpace + m_iLineSpacing + fontHeight) * linenumber); } } } CAImage* image = CAImage::createWithString(m_nText.c_str(), m_cFontColor, m_nfontName.c_str(), m_nfontSize, size, m_nTextAlignment, m_nVerticalTextAlignmet, m_bWordWrap, m_iLineSpacing, m_bBold, m_bItalics, m_bUnderLine); this->setImage(image); CC_RETURN_IF(image == NULL); m_cLabelSize = size; DRect rect = DRectZero; rect.size.width = this->getBounds().size.width; rect.size.height = size.height; float width = m_bFitFlag ? image->getContentSize().width : MIN(this->getBounds().size.width, image->getContentSize().width); rect.size.width = width; switch (m_nVerticalTextAlignmet) { case CAVerticalTextAlignmentTop: pTextHeight = 0; break; case CAVerticalTextAlignmentCenter: pTextHeight = (this->getBounds().size.height - rect.size.height) / 2; break; case CAVerticalTextAlignmentBottom: pTextHeight = this->getBounds().size.height - rect.size.height; break; default: break; } if (m_bFitFlag) { if (!size.equals(m_obContentSize)) { if (m_bFrame) { DRect rect = this->getFrame(); rect.size = size; this->setFrame(rect); } else { DRect rect = this->getCenter(); rect.size = size; this->setCenter(rect); } } } this->setImageRect(rect); }
void CAButton::setControlState(const CAControlState& var) { CAControl::setControlState(var); CC_RETURN_IF(var == CAControlStateAll); for (int i=0; i<CAControlStateAll; i++) { this->removeSubview(m_pBackGroundView[i]); } m_eControlState = var; if (m_bControlStateLocked) { m_eControlState = CAControlStateNormal; } if (m_pBackGroundView[m_eControlState] && m_eControlState != CAControlStateNormal) { m_pBackGroundView[m_eControlState]->setFrame(this->getBounds()); this->insertSubview(m_pBackGroundView[m_eControlState], -1); } else if (m_pBackGroundView[CAControlStateNormal]) { m_pBackGroundView[CAControlStateNormal]->setFrame(this->getBounds()); this->insertSubview(m_pBackGroundView[CAControlStateNormal], -1); } if (m_eControlState == CAControlStateSelected) { m_bSelected = true; } else if(m_eControlState != CAControlStateHighlighted) { m_bSelected = false; } CAImage* image = NULL; std::string title = ""; CCRect imageViewCenter = CCRectZero; CCRect rect = CCRectZero; CCRect labelCenter = this->getBounds(); float labelSize = 0; image = m_pImage[m_eControlState]; title = m_sTitle[m_eControlState]; if (image == NULL) { image = this->isSelected() ? m_pImage[CAControlStateSelected] : m_pImage[CAControlStateNormal]; } if (strcmp(title.c_str(), "") == 0) { title = this->isSelected() ? m_sTitle[CAControlStateSelected] : m_sTitle[CAControlStateNormal]; } if (image && title.compare("") == 0) { CCSize size = this->getBounds().size; CCSize iSize = image->getContentSize(); float scaleX = size.width / iSize.width * 0.75f; float scaleY = size.height / iSize.height * 0.75f; float scale = MIN(scaleX, scaleY); scale = MIN(scale, 1.0f); iSize = ccpMult(iSize, scale); imageViewCenter.origin = size / 2; imageViewCenter.size = iSize; } else if (image == NULL && title.compare("") != 0) { labelSize = this->getBounds().size.height * 0.4f; labelCenter.origin = this->getBounds().size / 2 ; } else if (image && title.compare("") != 0) { CCSize size = this->getBounds().size; CCSize iSize = image->getContentSize(); float scaleX = size.width / iSize.width * 0.5f; float scaleY = size.height / iSize.height * 0.45f; float scale = MIN(scaleX, scaleY); scale = MIN(scale, 1.0f); iSize = ccpMult(iSize, scale); imageViewCenter.size = iSize; imageViewCenter.origin.x = size.width / 2; imageViewCenter.origin.y = size.height * 0.35f; labelSize = size.height * 0.2f; labelCenter.origin.x = size.width / 2; labelCenter.origin.y = size.height * 0.75f; } m_pImageView->setColor(m_sImageColor[m_eControlState]); m_pImageView->setCenter(imageViewCenter); if (image != m_pImageView->getImage()) { m_pImageView->setImage(image); } m_pLabel->setColor(m_sTitleColor[m_eControlState]); m_pLabel->setCenter(labelCenter); if (!title.empty()) { m_pLabel->setFontSize(labelSize); } if (strcmp(title.c_str(), m_pLabel->getText().c_str())) { m_pLabel->setText(title.c_str()); } }
void CAVideoPlayerControlView::buildCtrlViews() { m_glView = CAVideoPlayerView::createWithFrame(getFrame()); m_glView->setFrameOrigin(DPointZero); m_glView->setColor(ccc4(0, 0, 0, 0)); this->insertSubview(m_glView, 1); // Bottom Panel Back CAImageView* bottomPanel = NULL; do { DRect frame = m_glView->getFrame(); CAImage* image = CAImage::create("source_material/vdo_panel_bottom_bg.png"); float width = m_glView->getFrame().size.width; float height = image->getContentSize().height; bottomPanel = CAImageView::createWithFrame(DRect(0, frame.size.height - height, width, height)); bottomPanel->setImage(image); m_glView->addSubview(bottomPanel); } while (0); // Slider do { DRect frame = bottomPanel->getFrame(); CAImage* backImage = CAImage::create("source_material/vdo_progress_back.png"); CAImage* barImage = CAImage::create("source_material/vdo_progress_bar.png"); m_playSlider = CASlider::createWithCenter(DRect(frame.size.width / 2, frame.size.height*0.3, frame.size.width * 0.9, barImage->getContentSize().height)); m_playSlider->setMaxTrackTintImage(backImage); m_playSlider->setThumbTintImage(barImage); m_playSlider->setTrackHeight(backImage->getContentSize().height); m_playSlider->addTargetForTouchUpSide(this, CAControl_selector(CAVideoPlayerControlView::onSlideChanged)); m_playSlider->addTarget(this, CAControl_selector(CAVideoPlayerControlView::onSlideTouched)); bottomPanel->addSubview(m_playSlider); } while (0); // Play Pause Button do { DRect frame = bottomPanel->getFrame(); CAImage* backImage = CAImage::create("source_material/vdo_pause.png"); CAImage* backImage_h = CAImage::create("source_material/vdo_pause_down.png"); frame.origin.y = frame.size.height * 2 / 3; frame.origin.x = backImage->getContentSize().width; frame.size.height = backImage->getContentSize().height; frame.size.width = backImage->getContentSize().width; m_playButton = CAButton::createWithCenter(frame, CAButtonTypeCustom); m_playButton->setImageForState(CAControlStateAll, backImage); m_playButton->setImageForState(CAControlStateHighlighted, backImage_h); m_playButton->addTarget(this, CAControl_selector(CAVideoPlayerControlView::onButtonPause), CAControlEventTouchUpInSide); bottomPanel->addSubview(m_playButton); } while (0); // play time do { DRect frame = m_playButton->getFrame(); DRect newFrame = DRectZero; m_playTimeLabel = CALabel::createWithFrame(DRectZero); m_playTimeLabel->setFontSize(32); m_playTimeLabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); m_playTimeLabel->setColor(ccc4(255, 255, 255, 255)); newFrame.origin.x = frame.origin.x * 2 + frame.size.width; newFrame.origin.y = frame.origin.y; newFrame.size.width = m_playTimeLabel->getFontSize() * 20; newFrame.size.height = frame.size.height; m_playTimeLabel->setFrame(newFrame); m_playTimeLabel->setText("00:00 / 00:00"); bottomPanel->addSubview(m_playTimeLabel); } while (0); // Top Panel Back CAImageView* topPanel = NULL; do { CAImage* image = CAImage::create("source_material/vdo_panel_top_bg.png"); topPanel = CAImageView::createWithFrame(DRect(0, 0, m_glView->getFrame().size.width, image->getContentSize().height)); topPanel->setImage(image); m_glView->addSubview(topPanel); } while (0); // Back Button CAButton* buttonBack = NULL; do { DRect frame = topPanel->getFrame(); // CAImage* backImage = CAImage::create("source_material/vdo_btn_back.png"); // CAImage* backImage_h = CAImage::create("source_material/vdo_btn_back_h.png"); CAImage* backImage = CAImage::create("source_material/btn_left_blue.png"); CAImage* backImage_h = CAImage::create("source_material/btn_left_white.png"); frame.origin.y = frame.size.height / 3; frame.origin.x = frame.origin.y; frame.size.height = backImage->getContentSize().height; frame.size.width = backImage->getContentSize().width; buttonBack = CAButton::createWithCenter(frame, CAButtonTypeCustom); buttonBack->setImageForState(CAControlStateAll, backImage); buttonBack->setImageForState(CAControlStateHighlighted, backImage_h); buttonBack->addTarget(this, CAControl_selector(CAVideoPlayerControlView::onButtonBack), CAControlEventTouchUpInSide); topPanel->addSubview(buttonBack); } while (0); // Title do { DRect frame = buttonBack->getFrame(); DRect r = DRectZero; r.origin.x = buttonBack->getFrame().origin.x * 2 + buttonBack->getFrame().size.width; r.origin.y = buttonBack->getFrame().origin.y; r.size.width = m_glView->getFrame().size.width - r.origin.x; r.size.height = buttonBack->getFrame().size.height; CALabel* title = CALabel::createWithFrame(r); title->setText(m_szTitle); title->setFontSize(42); title->setColor(ccc4(255, 255, 255, 255)); title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); topPanel->addSubview(title); } while (0); updatePlayButton(); }