本文整理汇总了C++中CAImageView::addSubview方法的典型用法代码示例。如果您正苦于以下问题:C++ CAImageView::addSubview方法的具体用法?C++ CAImageView::addSubview怎么用?C++ CAImageView::addSubview使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAImageView
的用法示例。
在下文中一共展示了CAImageView::addSubview方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toast
void UtilManager::toast(string text, string image, bool isSmall) {
CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG);
CCSize winSize = CAApplication::getApplication()->getWinSize();
CAImageView *back = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.55, _px(120), _px(120)));
}
else {
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.4, _px(120), _px(120)));
}
back->setTag(TOAST_VIEW_TAG);
back->setImage(CAImage::create("image/scape_storage.png"));
//back->setColor(ccc4(31, 31, 31, 200));//40
CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),
_dip(back->getBounds().size.height*0.8), 100, 100));
//title->setText(UTF8ToGBK::transferToGbk(text));
//title->setFontName(getChineseFont());
title->setColor(CAColor_white);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setFontSize(_px(22));
back->addSubview(title);
CAImageView *icon = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 90 / 1.5, 68 / 1.5));
}
else {
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 72 / 1.5, 72 / 1.5));
}
//CAImageView *icon = CAImageView::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),_dip(back->getBounds().size.height*0.4), 105/1.5, 95/1.5));
icon->setImage(CAImage::create(image));
back->addSubview(icon);
CAApplication::getApplication()->getRootWindow()->addSubview(back);
//CCLog("%s", get_date_now().c_str());
icon->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME / 2.0)));
back->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME)));
scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME);
}
示例2: initWithSize
void FSBooklibraryCell::initWithSize(CADipSize& cellSize)
{
CADipSize _size = cellSize;
// itemImage = CAImageView::createWithFrame(CADipRect(0, 0, _size.width, _size.height));
// itemImage->setTag(99);
// this->addSubview(itemImage);
// CADipSize itemSize = itemImage->getBounds().size;
// CALabel* itemText = CALabel::createWithCenter(CADipRect(_size.width*0.5, _size.height*0.5, 150, 40));
// itemText->setTag(100);
// itemText->setFontSize(_px(29));
// itemText->setTextAlignment(CATextAlignmentCenter);
// itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
// itemImage->addSubview(itemText);
CAImageView* itemImage = CAImageView::createWithFrame(CADipRect(0, 0, _size.width, _size.height*4/5));
itemImage->setTag(99);
this->addSubview(itemImage);
CADipSize itemSize = itemImage->getBounds().size;
CALabel* itemText = CALabel::createWithCenter(CADipRect(itemSize.width*0.5, itemSize.height+20, 150, 40));
itemText->setTag(100);
itemText->setFontSize(_px(29));
itemText->setTextAlignment(CATextAlignmentCenter);
itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
itemImage->addSubview(itemText);
// this->setControlCanSelected(false);
}
示例3: buildCtrlViews
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;
//.........这里部分代码省略.........
示例4: buildCtrlViews
void CAVideoPlayerControlView::buildCtrlViews()
{
m_glView = CAVideoPlayerView::createWithLayout(DLayoutFill);
this->addSubview(m_glView);
// Bottom Panel Back
CAImageView* bottomPanel = CAImageView::createWithLayout(DLayout(DHorizontalLayoutFill, DVerticalLayout_B_H(0, 188)));
bottomPanel->setImage(CAImage::create("source_material/vdo_panel_bottom_bg.png"));
m_glView->addSubview(bottomPanel);
// Slider
CAImage* barImage = CAImage::create("source_material/vdo_progress_bar.png");
m_playSlider = CASlider::createWithLayout(DLayout(DHorizontalLayout_L_R(32, 32), DVerticalLayout_T_H(25, 56)));
m_playSlider->setThumbTintImage(barImage);
m_playSlider->addTargetForTouchUpSide(this, CAControl_selector(CAVideoPlayerControlView::onSlideChanged));
bottomPanel->addSubview(m_playSlider);
// Play Pause Button
CAImage* backImage = CAImage::create("source_material/vdo_pause.png");
CAImage* backImage_h = CAImage::create("source_material/vdo_pause_down.png");
m_playButton = CAButton::createWithLayout(DLayout(DHorizontalLayout_L_W(32, 56), DVerticalLayout_T_H(96, 56)), 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);
// play time
m_playTimeLabel = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_W(120, 200), DVerticalLayout_T_H(96, 56)));
m_playTimeLabel->setFontSize(32);
m_playTimeLabel->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
m_playTimeLabel->setColor(ccc4(255, 255, 255, 255));
m_playTimeLabel->setText("00:00 / 00:00");
bottomPanel->addSubview(m_playTimeLabel);
/*
// 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 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();
}