Page *CascadesCookbookApp::createRecipePage()
{
    Page *recipeListPage = new Page();

    // Create the main app Container and set a DockLayout which is used to align children
    Container *recipeListContainer = new Container();
    DockLayout *recipeListLayout = new DockLayout();
    recipeListContainer->setLayout(recipeListLayout);

    // A nine-sliced book image is used as background of the cookbook.
    ImageView *backgroundImage = ImageView::create("asset:///images/Book_background.amd");
    backgroundImage->setVerticalAlignment(VerticalAlignment::Fill);
    backgroundImage->setHorizontalAlignment(HorizontalAlignment::Fill);

    // Create and set up a Container for the list
    Container *cookbookContainer = new Container();
    cookbookContainer->setTopPadding(15.0f);
    cookbookContainer->setBottomPadding(15.0f);
    cookbookContainer->setLayout(new DockLayout());
    cookbookContainer->setHorizontalAlignment(HorizontalAlignment::Fill);

    // Set up and create the ListView for the recipe list
    mRecipeListView = createRecipeListView();
    mRecipeListView->setHorizontalAlignment(HorizontalAlignment::Fill);

    // Add the controls
    cookbookContainer->add(mRecipeListView);

    recipeListContainer->add(backgroundImage);
    recipeListContainer->add(cookbookContainer);

    recipeListPage->setContent(recipeListContainer);

    return recipeListPage;
}
Ejemplo n.º 2
0
bool UIImageViewTest_Scale9::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getContentSize();
        
        Text* alert = Text::create("ImageView scale9 render", "fonts/Marker Felt.ttf", 26);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f,
                                 widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));
        
        _uiLayer->addChild(alert);        
        
        // Create the imageview
        ImageView* imageView = ImageView::create("cocosui/buttonHighlighted.png");
        imageView->setScale9Enabled(true);
        imageView->setContentSize(Size(200, 115));
        imageView->setPosition(Vec2(widgetSize.width / 2.0f - 100,
                                     widgetSize.height / 2.0f));
        
        _uiLayer->addChild(imageView);

        auto imageCopy = imageView->clone();
        imageCopy->setPosition(Vec2(widgetSize.width / 2.0f + 100,
                                    widgetSize.height / 2.0f));
        _uiLayer->addChild(imageCopy);
        
        return true;
    }
    return false;
}
Ejemplo n.º 3
0
Handle<Value> ImageView::isSolid(const Arguments& args)
{
    HandleScope scope;
    ImageView* im = node::ObjectWrap::Unwrap<ImageView>(args.This());

    if (args.Length() == 0) {
        return isSolidSync(args);
    }
    // ensure callback is a function
    Local<Value> callback = args[args.Length()-1];
    if (!args[args.Length()-1]->IsFunction())
        return ThrowException(Exception::TypeError(
                                  String::New("last argument must be a callback function")));

    is_solid_image_view_baton_t *closure = new is_solid_image_view_baton_t();
    closure->request.data = closure;
    closure->im = im;
    closure->result = true;
    closure->pixel = 0;
    closure->error = false;
    closure->cb = Persistent<Function>::New(Handle<Function>::Cast(callback));
    uv_queue_work(uv_default_loop(), &closure->request, EIO_IsSolid, (uv_after_work_cb)EIO_AfterIsSolid);
    im->Ref();
    return Undefined();
}
Handle<Value> ImageView::getPixel(const Arguments& args)
{
    HandleScope scope;

    unsigned x(0);
    unsigned y(0);

    if (args.Length() >= 2) {
        if (!args[0]->IsNumber())
            return ThrowException(Exception::TypeError(
                                      String::New("first arg, 'x' must be an integer")));
        if (!args[1]->IsNumber())
            return ThrowException(Exception::TypeError(
                                      String::New("second arg, 'y' must be an integer")));
        x = args[0]->IntegerValue();
        y = args[1]->IntegerValue();
    } else {
        return ThrowException(Exception::TypeError(
                                  String::New("must supply x,y to query pixel color")));
    }

    ImageView* im = ObjectWrap::Unwrap<ImageView>(args.This());
    image_view_ptr view = im->get();
    if (x < view->width() && y < view->height())
    {
        mapnik::image_view<mapnik::image_data_32>::pixel_type const * row = view->getRow(y);
        mapnik::image_view<mapnik::image_data_32>::pixel_type const pixel = row[x];
        unsigned r = pixel & 0xff;
        unsigned g = (pixel >> 8) & 0xff;
        unsigned b = (pixel >> 16) & 0xff;
        unsigned a = (pixel >> 24) & 0xff;
        return Color::New(mapnik::color(r,g,b,a));
    }
Ejemplo n.º 5
0
bool UIImageViewTest::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getContentSize();
        
        Text* alert = Text::create("ImageView", "fonts/Marker Felt.ttf", 30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f,
                                 widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f));
        
        _uiLayer->addChild(alert);        
        
        // Create the imageview
        ImageView* imageView = ImageView::create("cocosui/ccicon.png");
        imageView->setPosition(Vec2(widgetSize.width / 2.0f,
                                     widgetSize.height / 2.0f));
        
        _uiLayer->addChild(imageView);
        
      
        
        return true;
    }
    return false;
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  ImageView w;
  w.show();
  a.exec();
}
Ejemplo n.º 7
0
bool UIPageViewTest::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getSize();
        
        // Add a label in which the dragpanel events will be displayed
        _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
        _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
        _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
                                              widgetSize.height / 2.0f +
                                              _displayValueLabel->getContentSize().height * 1.5));
        _uiLayer->addChild(_displayValueLabel);
        
        // Add the black background
        Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
        _uiLayer->addChild(alert);
        
        Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
        
        Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
        
        // Create the page view
        PageView* pageView = PageView::create();
        pageView->setSize(Size(240.0f, 130.0f));
        Size backgroundSize = background->getContentSize();
        pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
                                  (backgroundSize.width - pageView->getSize().width) / 2.0f,
                                  (widgetSize.height - backgroundSize.height) / 2.0f +
                                  (backgroundSize.height - pageView->getSize().height) / 2.0f));
        
        for (int i = 0; i < 3; ++i)
        {
            Layout* layout = Layout::create();
            layout->setSize(Size(240.0f, 130.0f));
            
            ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
            imageView->setScale9Enabled(true);
            imageView->setSize(Size(240, 130));
            imageView->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
            layout->addChild(imageView);
            
            Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
            label->setColor(Color3B(192, 192, 192));
            label->setPosition(Vec2(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
            layout->addChild(label);
            
            pageView->addPage(layout);
        }
        pageView->addEventListener(CC_CALLBACK_2(UIPageViewTest::pageViewEvent, this));
        
        _uiLayer->addChild(pageView);
        
        return true;
    }
    return false;
}
Ejemplo n.º 8
0
  ImagePyramid<T>
  gaussian_pyramid(const ImageView<T>& image,
                   const ImagePyramidParams& params = ImagePyramidParams())
  {
    using Scalar = typename ImagePyramid<T>::scalar_type;

    // Resize the image with the appropriate factor.
    auto resize_factor = pow(2.f, -params.first_octave_index());
    auto I = enlarge(image, resize_factor);

    // Deduce the new camera sigma with respect to the dilated image.
    auto camera_sigma = Scalar(params.scale_camera())*resize_factor;

    // Blur the image so that its new sigma is equal to the initial sigma.
    auto init_sigma = Scalar(params.scale_initial());
    if (camera_sigma < init_sigma)
    {
      Scalar sigma = sqrt(init_sigma*init_sigma - camera_sigma*camera_sigma);
      I = gaussian(I, sigma);
    }

    // Deduce the maximum number of octaves.
    auto l = std::min(image.width(), image.height());
    auto b = params.image_padding_size();
    // l/2^k > 2b
    // 2^k < l/(2b)
    // k < log(l/(2b))/log(2)
    auto num_octaves = static_cast<int>(log(l/(2.f*b))/log(2.f));

    // Shorten names.
    auto k = Scalar(params.scale_geometric_factor());
    auto num_scales = params.num_scales_per_octave();
    auto downscale_index = int( floor( log(Scalar(2))/log(k)) );

    // Create the image pyramid
    auto G = ImagePyramid<T>{};
    G.reset(num_octaves, num_scales, init_sigma, k);

    for (auto o = 0; o < num_octaves; ++o)
    {
      // Compute the octave scaling factor
      G.octave_scaling_factor(o) =
        (o == 0) ? 1.f/resize_factor : G.octave_scaling_factor(o-1)*2;

      // Compute the gaussians in octave \f$o\f$
      Scalar sigma_s_1 = init_sigma;
      G(0, o) = o == 0 ? I : downscale(G(downscale_index, o - 1), 2);

      for (auto s = 1; s < num_scales; ++s)
      {
        auto sigma = sqrt(k*k*sigma_s_1*sigma_s_1 - sigma_s_1*sigma_s_1);
        G(s,o) = gaussian(G(s-1,o), sigma);
        sigma_s_1 *= k;
      }
    }

    // Done!
    return G;
  }
bool UIImageViewTest::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getSize();
        
        Text* alert = Text::create();
        alert->setText("ImageView");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
        _uiLayer->addChild(alert);        
        
        // Create the imageview
        ImageView* imageView = ImageView::create();
        imageView->loadTexture("cocosgui/ccicon.png");
        imageView->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
        
//        imageView->setOpacity(64);
        _uiLayer->addChild(imageView);
        
        /*
        NodeRGBA* root = NodeRGBA::create();
        root->setCascadeOpacityEnabled(true);
        NodeRGBA* render = Sprite::create();
        static_cast<Sprite*>(render)->setTexture("cocosgui/ccicon.png");
        root->addChild(render);
//        root->setOpacity(64);
        root->setPosition(Point(200, 180));
        _uiLayer->addChild(root);
         */
        
        /*
        NodeRGBA* nodergba = NodeRGBA::create();
        Sprite* child = Sprite::create();
        child->setTexture("cocosgui/ccicon.png");
        nodergba->addChild(child);
        nodergba->setPosition(Point(120, 80));
        nodergba->setOpacity(64);
        _uiLayer->addChild(nodergba);
         */
        
        /*
        Sprite* sprite = Sprite::create();
        sprite->setTexture("cocosgui/ccicon.png");
        sprite->setPosition(Point(200, 180));
//        sprite->setOpacity(64);
        _uiLayer->addChild(sprite);
         */
        
//        imageView->setLocalZOrder(20);
        
        return true;
    }
    return false;
}
Ejemplo n.º 10
0
	void intiData(){
		people = loadPUBModel("resources/456.BINARY",m_pd3dDevice,m_pImmediateContext);

		
		// Initialize the world matrix
		m_World = XMMatrixIdentity();

		// Initialize the view matrix
		XMVECTOR Eye = XMVectorSet( 0, 1.1, -2.0, 0.0f );
		XMVECTOR At = XMVectorSet( 0.0f, 1.1, 0.0f, 0.0f );
		XMVECTOR Up = XMVectorSet( 0.0f, 1.0f, 0.0f, 0.0f );
		m_View = XMMatrixLookAtLH( Eye, At, Up );

		// Initialize the projection matrix
		m_Projection = XMMatrixPerspectiveFovLH( XM_PIDIV4, getWindowWidth() / (FLOAT)getWindowHeight(), 0.01f, 1000.0f );
		m_Projection = XMMatrixOrthographicLH(4,4*getWindowHeight()/(FLOAT)getWindowWidth(),0,100);
		
		bone_shader =new ShaderProgram(m_pd3dDevice);
		bone_shader->setLayout(CUSTOM_LAYOUT_PUB,CUSTOM_LAYOUT_PUB_NUM);
		bone_shader->requestConstantBuffer(192,0);
		bone_shader->requestConstantBuffer(sizeof(XMMATRIX)*BONE_MAX_NUM,1);
		bone_shader->loadShader(L"FX/boneAnime.fx");
		people->useShader(bone_shader);


		Sampler* samp=new Sampler(m_pd3dDevice);
		samp->createSampleState(D3D11_FILTER_MIN_MAG_MIP_LINEAR,D3D11_TEXTURE_ADDRESS_WRAP,-1);
		samp->useSamplerAt(m_pImmediateContext,0);

	//	MyLuaManager::getInstance()->registerFun(ConsleGlue);






		/***********************************************************************/
		
		view_shader= new ShaderProgram(m_pd3dDevice);
		view_shader->setLayout(CUSTOM_LAYOUT_PU,CUSTOM_LAYOUT_PU_NUM);
		view_shader->requestConstantBuffer(192,0);
		view_shader->loadShader(L"FX/Tutorial04.fx");
		quard=new ImageView(m_pd3dDevice);
		quard->setBorder(getWindowWidth(),getWindowHeight());
		quard->setSize(200,150);
		quard->setShader(view_shader);


		backTarget=RenderTarget::generateRenderTarget(m_pd3dDevice,getWindowWidth(),getWindowHeight());
		quard->setTexture(*backTarget->getShaderResource());
		/**********************************************************************/
		setDrawMode(Triangle);
		/*********************************************************************/
		controller=new ObjectController(m_pd3dDevice);
		controller->addObject(quard);
	}
Ejemplo n.º 11
0
//设置单个模版的数据显示
void Gate::setItemData(Widget*item,PGateItem gateItem)
{
    Text*desTxt=static_cast<Text*>(item->getChildByName("desTxt"));
    Label* desLabel = static_cast<Label*>(desTxt->getVirtualRenderer());
    desLabel->enableOutline(Color4B::BLACK,1);
    //此处需要判断是否有倒计时,没有倒计时就隐藏此文本,否则具体显示倒计时(策划说以后会有个事件表,从里面读取时间)
    
    ImageView* items = static_cast<ImageView*>(item);
    items->loadTexture("Level Select_Book_A"+Value(this->currentType).asString()+".png");
}
Ejemplo n.º 12
0
ImageView* ImageView::create()
{
    ImageView* widget = new ImageView();
    if (widget && widget->init())
    {
        widget->autorelease();
        return widget;
    }
    CC_SAFE_DELETE(widget);
    return NULL;
}
Ejemplo n.º 13
0
/**
 * App::onImageLoaded(QString url, bool success, QString response)
 *
 * Handle the result of a loading image request.
 *
 * Basing on the result, we will update UI accordingly.
 *
 * --url, the url of the previous url
 * --success, the flag to indicate if the request was successful.
 * --response, this will carry some error information if the operation was not successful.
 *
 */
void App::onImageLoaded(QString url, bool success, QString response)
{
    //get the LoadImage object
    LoadImage* img = qobject_cast<LoadImage*>(sender());

    if (!img)
    {
        return;
    }

    connect(this, SIGNAL(finishUpdateImage()), img, SIGNAL(finishThread()));

    qDebug() << "Download complete: " << url;

    //find the url to photo index mapping
    QMap<QString, int>::iterator it = m_imageMap.find(url);
    if (it != m_imageMap.end())
    {
        //stop indicator
        ActivityIndicator* activityId = m_root->findChild<ActivityIndicator*>(QString("image%1Indicator").arg(it.value()));
        if (activityId)
        {
            activityId->stop();
            activityId->setVisible(false);
        }

        if (success)
        {
            //show the image
            ImageView* imageView = m_root->findChild<ImageView*>(QString("image%1").arg(it.value()));
            if (imageView)
            {
                QImage qm = img->getImage().rgbSwapped().scaled(768, 500, Qt::KeepAspectRatioByExpanding); //resize image to fit container
                bb::cascades::PixelBufferData pb = bb::cascades::PixelBufferData(PixelBufferData::RGBX, qm.width(), qm.height(), qm.width(), qm.bits());
                bb::cascades::Image image(pb);
                imageView->setImage(image);
                imageView->setVisible(true);
            }
        }
        else
        {
            //show the label with the error from the retrieval
            Label* imageLabel = m_root->findChild<Label*>(QString("image%1Label").arg(it.value()));
            if (imageLabel)
            {
                imageLabel->setText(response);
                imageLabel->setVisible(true);
            }
        }
        m_imageMap.erase(it);
    }
    emit finishUpdateImage();
   // no need to explicitly delete img, it has been destroyed when receiving the "finishThread" signal
}
Ejemplo n.º 14
0
ImageView* ImageView::create()
{
    ImageView* widget = new (std::nothrow) ImageView();
    if (widget && widget->init())
    {
        widget->autorelease();
        return widget;
    }
    CC_SAFE_DELETE(widget);
    return nullptr;
}
Ejemplo n.º 15
0
bool UIScrollViewTest_Both::init()
{
    if (UIScene::init())
    {
        Size widgetSize = _widget->getContentSize();;
        
        // Add a label in which the dragpanel events will be displayed
        _displayValueLabel = Text::create("Move by any direction","fonts/Marker Felt.ttf",32);
        _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
        _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
        _uiLayer->addChild(_displayValueLabel);
        
        // Add the alert
        Text* alert = Text::create("ScrollView both","fonts/Marker Felt.ttf",30);
        alert->setColor(Color3B(159, 168, 176));
        alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
        _uiLayer->addChild(alert);
        
        Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
        
        Layout* background = static_cast<Layout*>(root->getChildByName("background_Panel"));
        
        // Create the dragpanel
        ui::ScrollView* scrollView = ui::ScrollView::create();
        scrollView->setDirection(ui::ScrollView::Direction::BOTH);
        scrollView->setTouchEnabled(true);
        scrollView->setBounceEnabled(true);
        scrollView->setBackGroundImageScale9Enabled(true);
        scrollView->setBackGroundImage("cocosui/green_edit.png");
        scrollView->setContentSize(Size(210, 122.5));
		scrollView->setScrollBarWidth(4);
		scrollView->setScrollBarPositionFromCorner(Vec2(6, 6));
        Size backgroundSize = background->getContentSize();
        scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
                                    (backgroundSize.width - scrollView->getContentSize().width) / 2.0f,
                                    (widgetSize.height - backgroundSize.height) / 2.0f +
                                    (backgroundSize.height - scrollView->getContentSize().height) / 2.0f));
        ImageView* imageView = ImageView::create("Hello.png");
        scrollView->addChild(imageView);
        
        scrollView->setInnerContainerSize(imageView->getContentSize());
        Size innerSize = scrollView->getInnerContainerSize();
        imageView->setPosition(Vec2(innerSize.width / 2.0f, innerSize.height / 2.0f));
        
        _uiLayer->addChild(scrollView);

        // Jump to right bottom
        scrollView->jumpToBottomRight();

        return true;
    }
    
    return false;
}
Ejemplo n.º 16
0
    void ImageViewReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *cocoLoader, stExpCocoNode *cocoNode)
    {
        WidgetReader::setPropsFromBinary(widget, cocoLoader, cocoNode);
        
        ImageView* imageView = static_cast<ImageView*>(widget);
        this->beginSetBasicProperties(widget);
        float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
        
        stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);

        for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
            std::string key = stChildArray[i].GetName(cocoLoader);
            std::string value = stChildArray[i].GetValue(cocoLoader);

            //read all basic properties of widget
            CC_BASIC_PROPERTY_BINARY_READER
            //read all color related properties of widget
            CC_COLOR_PROPERTY_BINARY_READER
            
            else if (key == P_Scale9Enable) {
                imageView->setScale9Enabled(valueToBool(value));
            }
            else if (key == P_FileNameData){
                stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
                std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
                
                Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
                
                std::string backgroundValue = this->getResourcePath(cocoLoader, &stChildArray[i], imageFileNameType);

                imageView->loadTexture(backgroundValue, imageFileNameType);
                
            }
            else if(key == P_Scale9Width){
                imageView->setContentSize(Size(valueToFloat(value), imageView->getContentSize().height));
            }else if(key == P_Scale9Height){
                imageView->setContentSize(Size(imageView->getContentSize().width, valueToFloat(value)));
            }
            else if(key == P_CapInsetsX){
                capsx = valueToFloat(value);
            }else if(key == P_CapInsetsY){
                capsy = valueToFloat(value);
            }else if(key == P_CapInsetsWidth){
                capsWidth = valueToFloat(value);
            }else if(key == P_CapInsetsHeight){
                capsHeight = valueToFloat(value);
            }
            
        } //end of for loop
        
        if (imageView->isScale9Enabled()) {
            imageView->setCapInsets(Rect(capsx, capsy, capsWidth, capsHeight));
        }
        
        this->endSetBasicProperties(widget);

    }
Ejemplo n.º 17
0
void ShopLayer::RunActionBuySuccess(Ref * pSender)
{
	ImageView * sp = dynamic_cast<ImageView*>(rootNode->getChildByName("success_sprite"));
	sp->setVisible(true);
	sp->setScale(0.0f);
	ActionInterval * scaleto = ScaleTo::create(.1f, 1.0f);
	ActionInterval * scaleto2 = ScaleTo::create(.1f, 0.0f);
	ActionInterval * Sequence = Sequence::create(scaleto, DelayTime::create(1.5f), scaleto2,
		CallFunc::create([&]() {
		//this->removeFromParentAndCleanup(true);
	}), nullptr);
	sp->runAction(Sequence);
}
Container *AnimationRecipe::setUpAnimationEgg()
{
    Container *animationEggContainer = new Container();
    animationEggContainer->setLayout(new AbsoluteLayout());

    // The egg image
    ImageView *eggImage = ImageView::create("asset:///images/animation/egg_isolated.png");
    eggImage->setLayoutProperties(AbsoluteLayoutProperties::create().x(40));
    eggImage->setObjectName("eggImage");

    // The egg shadow put beneath the egg in Y direction
    ImageView *shadowImage = ImageView::create("asset:///images/animation/egg_isolated_shadow.png");
    shadowImage->setLayoutProperties(AbsoluteLayoutProperties::create().y(150));
    shadowImage->setObjectName("shadowImage");

    // The egg rotates around half the full height (the bottom of the egg),
    // the pivot point is in the middle of the image to start.
    eggImage->setPivotY(203 / 2);

    // The shadow rotates around half its height,
    // the pivot point is in the middle of the image to start.
    shadowImage->setPivotY(-297 / 2);

    // Add the images to the Container.
    animationEggContainer->add(shadowImage);
    animationEggContainer->add(eggImage);

    animationEggContainer->setClipContentToBounds(false);

    return animationEggContainer;
}
Container *LightningCrossfadeApp::setUpSliderContainer(Container *imageContainer)
{
    bool connectResult;
    Q_UNUSED(connectResult);

    // Create the Slider Container with the controls set to sort themselves from
    // left to right rather then top to bottom (which is the default for a StackLayout).
    Container* sliderContainer = Container::create().left(20.0f).right(20.0f);
    sliderContainer->setLayout(StackLayout::create().orientation(LayoutOrientation::LeftToRight));

    // Setting spacequota not equals to one tells this Container
    // that it should fill up the remaining part of the screen.
    sliderContainer->setLayoutProperties(StackLayoutProperties::create().spaceQuota(1));

    // This is the Slider you see at the bottom of the page when it get's a onImmediateValueChanged
    // event it changes the image with id night's opacity to that value, margins for space.
    Slider* opacitySlider = Slider::create().leftMargin(20.0f).rightMargin(20.0f).vertical(VerticalAlignment::Center);

    // Center the slider in the stack layout. We have given a positive space quota which
    // makes the slider opacity value less than the moon and sun icon images when
    // laying out on screens of different widths.
    opacitySlider->setLayoutProperties(StackLayoutProperties::create().spaceQuota(1.0f));
    opacitySlider->setHorizontalAlignment(HorizontalAlignment::Fill);

    // Add A11y description to the slider
    opacitySlider->accessibility()->setDescription(
            "Drag to change image. Night to the left - day to the right");

    // A moon and sun icon image is used to illustrate that time of day, both
    // aligned to the center in a vertical direction to line up with the slider.
    ImageView* moon = ImageView::create("asset:///images/moon.png");
    moon->setVerticalAlignment(VerticalAlignment::Center);
    ImageView* sun = ImageView::create("asset:///images/sun.png");
    sun->setVerticalAlignment(VerticalAlignment::Center);

    // The day image will be attached to a slider so we need to get the corresponding
    // object from the image Container.
    ImageView *dayImage = imageContainer->findChild<ImageView*>("dayImage");

    // Connect the Slider value directly to the opacity property of the day image view.
    connectResult = connect(opacitySlider, SIGNAL(immediateValueChanged(float)), dayImage, SLOT(setOpacity(float)));
    Q_ASSERT(connectResult);

    // Add the components to the slider container (remember that they will be stacked from left to right).
    sliderContainer->add(moon);
    sliderContainer->add(opacitySlider);
    sliderContainer->add(sun);

    return sliderContainer;
}
Ejemplo n.º 20
0
bool BackgroundInGame::init() {
    if (!UILayer::init()) return false;
    
    this->setAnchorPoint(ccp(0, 0));
    
    ImageView *bg = ImageView::create();
    bg->loadTexture("table.png");
    
    bg->setAnchorPoint(ccp(0, 0));
    
    this->addWidget(bg);
    
    return true;
}
Ejemplo n.º 21
0
bool UI_Bag_Gem_Layer::SetSingleCellInfo(const int nTagID, Game_Data::Item_Container * pInfo)
{
	/************************************************************************/
	// 设置单个Cell的信息
	// 1. 判断索引ID是否异常
	if (nTagID >= MAX_TAG_COUNT)
		return false;

	// 2. 获取该物品的Config
	Game_Data::Item_Config * pItemConfig = ITEM_CONFIG_MGR::instance()->get_item_config(pInfo->item_id);
	if (pItemConfig == NULL)
		return false;

	// 3. 读取Json文件获取包裹每一个单元格
	Widget *pLayer = dynamic_cast<Widget*>(m_pBagGemScrollView->getChildByTag(nTagID));
	if (pLayer == NULL)
		return false;

	/************************************************************************/
	// 条件满足设置物品信息
	int nTemp = 0;
	const char * szTemp;
	// 1. 设置Icon
	ImageView * pMaterialImage = dynamic_cast<ui::ImageView*>(Helper::seekWidgetByName(pLayer, "Icon_ImagerView"));
	if (pMaterialImage == NULL)
		return false;

	szTemp	= ITEM_CONFIG_MGR::instance()->get_icon_path(pItemConfig->icon);
    std::string p("icon/");
    p+=szTemp;
	nTemp	= strcmp(p.c_str(), "");
	if (nTemp <= 0)
		return false;

	pMaterialImage->loadTexture(p.c_str());
	pMaterialImage->setVisible(true);
	
	// 2. 设置物品的个数
	TextAtlas * pMateriCount = dynamic_cast<ui::TextAtlas*>(Helper::seekWidgetByName(pLayer, "Count_Text"));
	if (pMaterialImage == NULL)
		return false;

	pMateriCount->setString(CCString::createWithFormat("%d", pInfo->item_count)->getCString());
	pMateriCount->setVisible(true);

	// 3. 为每件物品注册点击事件
	pMaterialImage->setTag(nTagID);
	pMaterialImage->addTouchEventListener(CC_CALLBACK_2(UI_Bag_Gem_Layer::OnBtnClickMaterialCallBack, this));
	return true;
}
Ejemplo n.º 22
0
CustomDialogRecipe::CustomDialogRecipe(Container * parent) :
        CustomControl(parent)
{
    bool connectResult;
    Q_UNUSED(connectResult);

    Container *recipeContainer = new Container();
    recipeContainer->setLayout(new AbsoluteLayout());

    mFlame = ImageView::create("asset:///images/customdialog/flame.png");

    // Connect to the layout handler of the flame image, we need the image size
    // in order to set the pivot point for scaling correctly.
    LayoutUpdateHandler::create(mFlame).onLayoutFrameChanged(this,
            SLOT(flameLayoutFrameUpdated(QRectF)));

    // The flame animation gradually scales the flame up in Y direction and
    // finally triggers the CustomDialog.
    mRisingFlame = SequentialAnimation::create(mFlame)
            .add(ScaleTransition::create(mFlame).toY(1.2).duration(400))
            .add(ScaleTransition::create(mFlame).toY(1.1).duration(400))
            .add(ScaleTransition::create(mFlame).toY(1.4).duration(400))
            .add(ScaleTransition::create(mFlame).toY(1.3).duration(400))
            .add(ScaleTransition::create(mFlame).toY(1.6).duration(400))
            .add(ScaleTransition::create(mFlame).toY(1.5).duration(400))
            .add(ScaleTransition::create(mFlame).toY(1.9).duration(400))
            .add(ScaleTransition::create(mFlame).toY(1.7).duration(400))
            .add(ScaleTransition::create(mFlame).toY(2.0).duration(400)).parent(this);

    // Connect to the animation ended signal, when triggered the dialog will be shown.
    connectResult = connect(mRisingFlame, SIGNAL(ended()), this, SLOT(onHideAnimEnded()));
    Q_ASSERT(connectResult);

    ImageView *candle = ImageView::create("asset:///images/customdialog/background.png");
    candle->setScalingMethod(ScalingMethod::AspectFit);

    // The CustomDialog is added as an attached object since it is visible in the
    // UI from the start. Since a dialog is often used in many different places in an application,
    // it is set up as a separate component. This is to easily add it to other Pages.
    mAlarmDialog = new CustomDialogAlarm(this);
    connectResult = connect(mAlarmDialog, SIGNAL(visibleChanged(bool)), this, SLOT(onDialogVisible(bool)));
    Q_ASSERT(connectResult);

    recipeContainer->add(mFlame);
    recipeContainer->add(candle);

    setRoot(recipeContainer);

    mRisingFlame->play();
}
Ejemplo n.º 23
0
/* module functions */
static PyObject * 
open(PyObject *self, PyObject *args) 
{
    char* Name;
    const char* DocName=0;
    if (!PyArg_ParseTuple(args, "et|s","utf-8",&Name,&DocName))
        return NULL;
    std::string EncodedName = std::string(Name);
    PyMem_Free(Name);

    PY_TRY {
        QString fileName = QString::fromUtf8(EncodedName.c_str());
        QFileInfo file(fileName);

        // Load image from file into a QImage object
        QImage imageq(fileName);

        // Extract image into a general RGB format recognised by the ImageView class
        int format = IB_CF_RGB24;
        unsigned char *pPixelData = NULL;
        if (imageq.isNull() == false) {
            pPixelData = new unsigned char[3 * (unsigned long)imageq.width() * (unsigned long)imageq.height()];
            unsigned char *pPix = pPixelData;
            for (int r = 0; r < imageq.height(); r++) {
                for (int c = 0; c < imageq.width(); c++) {
                    QRgb rgb = imageq.pixel(c,r);
                    *pPix = (unsigned char)qRed(rgb);
                    *(pPix + 1) = (unsigned char)qGreen(rgb);
                    *(pPix + 2) = (unsigned char)qBlue(rgb);
                    pPix += 3;
                }
            }
        }
        else
            Py_Error(Base::BaseExceptionFreeCADError,"Could not load image");

        // Displaying the image in a view.
        // This ImageView object takes ownership of the pixel data (in 'pointImageTo') so we don't need to delete it here
        ImageView* iView = new ImageView(Gui::getMainWindow());
        iView->setWindowIcon( Gui::BitmapFactory().pixmap("colors") );
        iView->setWindowTitle(file.fileName());
        iView->resize( 400, 300 );
        Gui::getMainWindow()->addWindow( iView );
        iView->pointImageTo((void *)pPixelData, (unsigned long)imageq.width(), (unsigned long)imageq.height(), format, 0, true);

    } PY_CATCH;

    Py_Return; 
}
Ejemplo n.º 24
0
// on "init" you need to initialize your instance
bool IndexScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

	m_visibleSize = Director::getInstance()->getVisibleSize();

	ImageView* imgBg = ImageView::create("index/bg.png");
	imgBg->setPosition(Point(m_visibleSize.width / 2, m_visibleSize.height / 2));
	this->addChild(imgBg, 0, 10);

	ImageView* imgLogo = ImageView::create("index/logo.png");
	imgLogo->setPosition(Point(m_visibleSize.width / 2, m_visibleSize.height / 2 + m_visibleSize.height / 4));
	this->addChild(imgLogo, 1, 11);

	//load animation

	m_imgLeft = ImageView::create("global/blackRectLeft.png");
	m_imgLeft->setPosition(Point(m_imgLeft->getContentSize().width/2, m_visibleSize.height / 2));
	//imgLeft->setAnchorPoint(Point(0, 0.5));
	this->addChild(m_imgLeft, 4, 24);

	m_imgRight = ImageView::create("global/blackRectRight.png");
	m_imgRight->setPosition(Point(m_visibleSize.width, m_visibleSize.height / 2));
	m_imgRight->setAnchorPoint(Point(1, 0.5));
	this->addChild(m_imgRight, 4, 25);

	m_imgLoad = ImageView::create("index/load.png");
	m_imgLoad->setPosition(Point(m_visibleSize.width - m_imgLoad->getContentSize().width/1.5, m_visibleSize.height / 5));
	m_imgLoad->setOpacity(0);
	this->addChild(m_imgLoad, 4);

	FadeOut* fadeOutLeft = FadeOut::create(1.0f);
	FadeOut* fadeOutRight = FadeOut::create(1.2f);
	
	auto fadeInLoad = FadeIn::create(1.0f);
	auto fadeInLoadBack = fadeInLoad->reverse();
	m_imgLeft->runAction(Sequence::create(DelayTime::create(0.8f), fadeOutLeft, nullptr));
	m_imgRight->runAction(Sequence::create(DelayTime::create(1.0f), fadeOutRight, nullptr));
	m_imgLoad->runAction( Sequence::create(fadeInLoad, fadeInLoadBack, nullptr));

	loadBtns();

    return true;
}
Ejemplo n.º 25
0
 void shrink_box(
     ImageView const & input, TColor const & tcolor,
     size_t & x, size_t & y, size_t & w, size_t & h
 ) {
     auto d = input(y, x).c;
     while (y < h && horizontal_empty<ImageView>(tcolor, d, w)) {
         ++y;
         d += input.width() * 3;
     }
     d = input(h, x).c - input.width() * 3;
     while (h > y && horizontal_empty<ImageView>(tcolor, d, w)) {
         d -= input.width() * 3;
         --h;
     }
 }
Ejemplo n.º 26
0
void GameWin::onHttpLoadImageCompleted(HttpClient *sender, HttpResponse *response){
  if (!response)
    {
        return;
    }   

    // You can get original request type from: response->request->reqType
    if (0 != strlen(response->getHttpRequest()->getTag()))
    {
        log("%s completed", response->getHttpRequest()->getTag());
    }   
    int statusCode = response->getResponseCode();
    char statusString[64] = {};
    sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
   // _labelStatusCode->setString(statusString);
    log("response code: %d", statusCode);   
    if (!response->isSucceed())
    {
        log("response failed");
        log("error buffer: %s", response->getErrorBuffer());
		
        return;
	}
	if (statusCode != 200){
		log("response code failed");
		log("error buffer: %s", response->getErrorBuffer());
		//SaveReward2Local();
		return;
	}
    // dump data
    std::vector<char> *buffer = response->getResponseData();
	Image* image = new Image();
    image->initWithImageData(reinterpret_cast<unsigned char*>(&(buffer->front())), buffer->size());

	
    Texture2D* texture = new Texture2D();
    texture->initWithImage(image);
    
    if(_rootNode && _rootNode->getChildByName("ivPromotionImg")){
        ImageView* imgPromotion = dynamic_cast<ImageView*>(_rootNode->getChildByName("ivPromotionImg"));
        Sprite* sprite = (Sprite*)imgPromotion->getChildByTag(1001);
        sprite->setTexture(texture);
    }
    if(_rootNode && _rootNode->getChildByName("lblProductName")){
        Text* lblProductName=dynamic_cast<Text*>(_rootNode->getChildByName("lblProductName"));// (CCLabelTTF*)this->getChildByTag(2001);
        lblProductName->setString(m_strProductName);
    }
}
Ejemplo n.º 27
0
void
MainWindow::RemoveImage()
{
	QListWidgetItem *current = list->currentItem();
	if (current)
	{
		ImageView * view = current->data(Qt::UserRole).value<ImageView *>();
		view->close();
		list->takeItem(list->row(current));
		if (list->count() == 0)
		{
			fPreview->setEnabled(false);
			fRemove->setEnabled(false);
		}
	}
}
Ejemplo n.º 28
0
            static inline void save(OutputArchive& ar, const ImageView& val)
            {
                const cv::Mat& m = val.getImage();

                ar & make_nvp("rows", m.rows);
                ar & make_nvp("cols", m.cols);
                ar & make_nvp("channels", m.channels());
                ar & make_nvp("type", m.type());

                switch (m.type())
                {
                case CV_32F:
                {
                               auto start = m.ptr<float>(0);
                               auto end = start + m.total();
                               ar & make_nvp("data", std::vector<float>(start, end));
                               break;
                }
                case CV_8U:
                default:
                {
                           auto start = m.ptr<uint8_t>(0);
                           auto end = start + m.elemSize() * m.total();
                           ar & make_nvp("data", std::vector<uint8_t>(start, end));
                           break;
                }
                }
            }
 void updateImage()
     {
         boost::lock_guard<boost::mutex> lock(mtx);
         if(image.height() > 1){
             imageView->setImage(image);
         }
     }
Ejemplo n.º 30
0
    void ImageViewReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
    {
        WidgetReader::setPropsFromJsonDictionary(widget, options);
        
        
        
        ImageView* imageView = static_cast<ImageView*>(widget);
        
        const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_FileNameData);
        int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType);
        const std::string& imageFilePath = DICTOOL->getStringValue_json(imageFileNameDic, P_Path);

        if (!imageFilePath.empty()) {
        	std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType);
        	imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
        }
                
        
        bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, P_Scale9Enable);
        bool scale9Enable = false;
        if (scale9EnableExist)
        {
            scale9Enable = DICTOOL->getBooleanValue_json(options, P_Scale9Enable);
        }
        imageView->setScale9Enabled(scale9Enable);
        
        
        if (scale9Enable)
        {
          
            float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width,80.0f);
            float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height,80.0f);
            imageView->setContentSize(Size(swf, shf));
            
            
            float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
            float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
            float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1.0f);
            float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1.0f);
            
            imageView->setCapInsets(Rect(cx, cy, cw, ch));
            
        }
        
        
        WidgetReader::setColorPropsFromJsonDictionary(widget, options);
    }