void RecipeListViewController::initEditBottomView() { m_EditBottomView = CAView::createWithLayout(m_bottomViewLayout[0]); this->getView()->addSubview(m_EditBottomView); CAView* horizontallineview = CAView::createWithLayout(DLayout(DHorizontalLayout_L_R(1, 1), DVerticalLayout_T_H(1, 1)), CAColor_gray); m_EditBottomView->addSubview(horizontallineview); selectAllButton = CAButton::createWithLayout(DLayout(DHorizontalLayout_L_W(0, AppWidth/2 - 2), DVerticalLayoutFill), CAButtonTypeCustom); selectAllButton->setTitleFontSize(FONT3); selectAllButton->setTitleForState(CAControlState::CAControlStateAll, "全选"); selectAllButton->addTarget(this, CAControl_selector(RecipeListViewController::onClickSelectAllButton), CAControlEvents::CAControlEventTouchUpInSide); m_EditBottomView->addSubview(selectAllButton); CAView* verticalLineView = CAView::createWithLayout(DLayout(DHorizontalLayout_L_W(AppWidth/2, 1), DVerticalLayout_T_B(5, 5)), CAColor_gray); m_EditBottomView->addSubview(verticalLineView); CAButton *rightButton = CAButton::createWithLayout(DLayout(DHorizontalLayout_R_W(0, AppWidth/2 - 2), DVerticalLayoutFill), CAButtonTypeCustom); rightButton->setTitleFontSize(FONT3); rightButton->setTitleForState(CAControlState::CAControlStateAll, "删除"); rightButton->addTarget(this, CAControl_selector(RecipeListViewController::onClickDeleteButton), CAControlEvents::CAControlEventTouchUpInSide); m_EditBottomView->addSubview(rightButton); }
void SliderTest::viewDidLoad() { if (SliderNum == 0) { CAView* view1 = CAView::createWithLayout(DLayoutFill); view1->setColor(CAColor_gray); sliderValue1 = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(100, 100), DVerticalLayout_T_H(300, 50))); sliderValue1->setColor(ccc4(51,204,255,255)); sliderValue1->setText("0"); sliderValue1->setFontSize(30); sliderValue1->setTextAlignment(CATextAlignmentCenter); sliderValue1->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); view1->addSubview(sliderValue1); CASlider* slider1 = CASlider::createWithLayout(DLayout(DHorizontalLayout_L_R(120, 120), DVerticalLayout_T_H(500, 56))); slider1->addTarget(this, CAControl_selector(SliderTest::sliderValueChange)); slider1->setTag(100); view1->addSubview(slider1); this->getView()->addSubview(view1); } else { CAView* view2 = CAView::createWithLayout(DLayoutFill); view2->setColor(CAColor_gray); sliderValue2 = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(100, 100), DVerticalLayout_T_H(300, 50))); sliderValue2->setColor(ccc4(51, 204, 255, 255)); sliderValue2->setText("0"); sliderValue2->setFontSize(30); sliderValue2->setTextAlignment(CATextAlignmentCenter); sliderValue2->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); view2->addSubview(sliderValue2); CASlider* slider2 = CASlider::createWithLayout(DLayout(DHorizontalLayout_L_R(120, 120), DVerticalLayout_T_H(500, 56))); slider2->setTag(101); slider2->setMaxTrackTintImage(CAImage::create("source_material/ex1.png")); slider2->setMinTrackTintImage(CAImage::create("source_material/ex3.png")); slider2->setThumbTintImage(CAImage::create("source_material/btn_square_highlighted.png")); slider2->addTarget(this, CAControl_selector(SliderTest::sliderValueChange)); view2->addSubview(slider2); this->getView()->addSubview(view2); } }
CACollectionViewCell* CDUIShowAutoCollectionView::collectionCellAtIndex(CAAutoCollectionView *collectionView, const DSize& cellSize, unsigned int section, unsigned int item) { CACollectionViewCell* p_Cell = collectionView->dequeueReusableCellWithIdentifier("CrossApp"); if (p_Cell == NULL) { p_Cell = CACollectionViewCell::create("CrossApp"); p_Cell->setAllowsSelected(false); CAView* itemImage = CAView::createWithLayout(DLayout(DLayoutFill)); itemImage->setTag(99); p_Cell->addSubview(itemImage); CALabel* itemText = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(0,0), DVerticalLayout_B_H(5,80))); itemText->setTag(100); itemText->setFontSize(24); itemText->setTextAlignment(CATextAlignmentCenter); itemText->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); p_Cell->addSubview(itemText); CAImageView* icon = CAImageView::createWithLayout(DLayout(DHorizontalLayout_L_R(30,30),DVerticalLayout_T_H(20, 123))); icon->setImageViewScaleType(CAImageViewScaleTypeFitImageInside); icon->setTag(101); icon->setScale(0.6f); p_Cell->addSubview(icon); } CAView* itemImageView = p_Cell->getSubviewByTag(99); itemImageView->setColor(ccc4(244, 243, 243, 255)); CALabel* itemText = (CALabel*)p_Cell->getSubviewByTag(100); itemText->setText(m_vTitle.at(item)); itemText->setColor(ccc4(34, 151, 254, 255)); CAImageView* icon = (CAImageView*)p_Cell->getSubviewByTag(101); icon->setImage(CAImage::create(iconTag[item])); return p_Cell; }
CAView* RecipeListViewController::tableViewSectionViewForHeaderInSection(CATableView* table, const DSize& viewSize, unsigned int section) { std::string head = m_strSectionTitle; CAView* view = CAView::createWithColor(SectionTitleColor); DSize _size = viewSize; CALabel* header = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(0,0), DVerticalLayoutFill)); header->setText(head); header->setFontSize(30); header->setColor(CAColor_white); header->setTextAlignment(CATextAlignmentCenter); header->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter); view->addSubview(header); return view; }
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(); }
void CDShowNewsImage::initNewsImageView(newsImage _image) { m_image = _image; CAVector<CAView* > viewList; for (int i=0; i<m_image.m_imageUrl.size(); i++) { CommonUrlImageView* temImage = CommonUrlImageView::createWithLayout(DLayoutFill); temImage->setImageViewScaleType(CAImageViewScaleTypeFitImageInside); temImage->setImage(CAImage::create("HelloWorld.png")); temImage->setUrl(m_image.m_imageUrl[i]); CAScrollView* p_ScrollView = CAScrollView::createWithLayout(DLayoutFill); p_ScrollView->setMinimumZoomScale(1.0f); p_ScrollView->setMaximumZoomScale(2.5f); p_ScrollView->setMultitouchGesture(CAScrollView::MultitouchGesture::Zoom); p_ScrollView->setBackgroundColor(CAColor_clear); p_ScrollView->setShowsScrollIndicators(false); p_ScrollView->setBounceVertical(false); p_ScrollView->setScrollViewDelegate(this); p_ScrollView->addSubview(temImage); viewList.pushBack(p_ScrollView); } p_PageView = CAPageView::createWithLayout(DLayoutFill, CAPageView::Horizontal); p_PageView->setViews(viewList); p_PageView->setPageViewDelegate(this); p_PageView->setBackgroundColor(CAColor_black); p_PageView->setPageViewDelegate(this); p_PageView->setSpacing(40); this->getView()->addSubview(p_PageView); p_bg = CAView::createWithColor(ccc4(0,0,0,200)); p_bg->setLayout(DLayout(DHorizontalLayoutFill, DVerticalLayout_B_C(0, 0.85))); this->getView()->addSubview(p_bg); p_title = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(10, 80), DVerticalLayout_T_H(10, 50))); p_title->setText(m_image.m_title); p_title->setColor(CAColor_white); p_title->setFontSize(34); p_title->setBold(true); p_bg->addSubview(p_title); char temp[10]; sprintf(temp, "1/%lu",m_image.m_imageUrl.size()); p_index = CALabel::createWithLayout(DLayout(DHorizontalLayout_R_W(0, 70), DVerticalLayout_T_H(10, 50))); p_index->setText(temp); p_index->setColor(CAColor_white); p_index->setFontSize(30); p_index->setBold(true); p_bg->addSubview(p_index); p_des = CALabel::createWithLayout(DLayout(DHorizontalLayout_L_R(10, 20), DVerticalLayoutFill)); p_des->setText(m_image.m_imageDesc[4]); p_des->setColor(ccc4(200, 200, 200, 255)); p_des->setFontSize(26); CAScrollView* ps = CAScrollView::createWithLayout(DLayout(DHorizontalLayoutFill, DVerticalLayout_T_H(70, 200))); ps->setBackgroundColor(CAColor_clear); ps->setShowsVerticalScrollIndicator(false); ps->setShowsHorizontalScrollIndicator(false); ps->setBounceHorizontal(false); ps->addSubview(p_des); p_bg->addSubview(ps); }