Ejemplo n.º 1
0
Archivo: iff.cpp Proyecto: Scraft/avpmp
	Chunk * Composite::GetProperty(ChildNode const * pNode, ID idProp) const
	{
		// search backward for ID
		
		ChildNode * pFindNode = GetPrevChild(pNode, idProp);
		
		if (pFindNode) return pFindNode->GetChunk();
		
		// if not found, search parent backwards, for "PROP ...." then get that
		// and if not in the parent, search its parent similarly
		// provided all these parents are of type LIST ....
		
		for (Composite const * pThis = this; pThis->m_pParent && pThis->m_pParent->m_idCk == ID("LIST"); pThis = pThis->m_pParent)
		{
			if (pThis->m_pNode)
			{
				for (ChildNode * pFindProp = pThis->m_pParent->GetPrevChild(pThis->m_pNode,"PROP"); pFindProp; pFindProp = pThis->m_pParent->GetPrevChild(pFindProp,"PROP"))
				{
					Composite * pProp = static_cast<Composite *>(pFindProp->GetChunk());
					if (pProp->m_idData == m_idData)
					{
						ChildNode * pFindNode = pProp->GetLastChild(idProp);
						
						if (pFindNode) return pFindNode->GetChunk();
					}
				}
				
			}
		}
		
		return NULL;
	}
Ejemplo n.º 2
0
void LoadExecuter::execute(SceneData &data, Commands c, command_params &p)
{
    Model3D *pointer = loader.read_model(p.load_params.file_name);
    Composite *composite = new Composite();
    composite->add_object(std::shared_ptr<SceneObj>(pointer));
    data.add_composite(std::shared_ptr<Composite>(composite), p.load_params.center);
}
Ejemplo n.º 3
0
/** Currently not used. Need to check whether all data should be copied or just pointers. 
 Current code only copies the pointers **/
Composite * Composite::copy(){
    Composite * copy = new Composite();
    
    printf("Composite::copy 1\n");
    std::map<CompositeBranchContainer *,CompositeBranchContainer *> new_to_old_map;
    std::map<CompositeBranchContainer *,CompositeBranchContainer *> old_to_new_map;
    
    printf("Composite::copy  creating new branches\n");
    for (CompositeBranchContainer * branch : get_branches()){
        CompositeBranchContainer * branch_copy = new CompositeBranchContainer(branch);
        new_to_old_map[branch_copy] = branch;
        old_to_new_map[branch] = branch_copy;
        copy->add_branch(branch_copy);
    }
    //for (CompositeBranchContainer * new_branch : branches){
    // Create parent/child pointers
    printf("Composite::copy connecting branches\n");
    int count = 0;
    for (std::map<CompositeBranchContainer *,CompositeBranchContainer *>::iterator it = new_to_old_map.begin(); it != new_to_old_map.end(); ++it){
        CompositeBranchContainer * new_branch = it->first;
        CompositeBranchContainer * orig_branch = it->second;
        //CompositeBranchContainer * orig_branch = new_to_old_map[new_branch];
        CompositeBranchContainer * orig_parent = orig_branch->get_parent();
        
        count++;
        //printf("Branch connecting %d; orig_parent %p\n",count,orig_parent);
        
        if (orig_parent){
            CompositeBranchContainer * new_parent = old_to_new_map[orig_parent];
            // Make child->parent connection
            new_branch->set_parent(new_parent);

            // Copy parent-side decision points
            if (new_parent->get_decision_point2()){
                // When the copied decision point already exists
                new_branch->set_decision_point1(new_parent->get_decision_point2());
            }else{
                DecisionPoint * dp_copy = new DecisionPoint(orig_branch->get_decision_point1());
                new_branch->set_decision_point1(dp_copy);
                decision_points.push_back(dp_copy);
            }
        }else{
            // No parent, so this branch must be the root
            printf("setting root\n");
            copy->set_root(new_branch);
        }
        // Copy child-side decision point (if it isn't a certain terminal branch)
        if (orig_branch->get_decision_point2()){
            //printf("copying dp2 %p\n",orig_branch->get_decision_point2());
            DecisionPoint * dp_copy = new DecisionPoint(orig_branch->get_decision_point2());
            new_branch->set_decision_point2(dp_copy);
            decision_points.push_back(dp_copy);
        }
    }
    printf("Done making copy\n");
    
    return copy;
}
Ejemplo n.º 4
0
int main()
{
	Leaf *mouse = new Leaf(10);
	Leaf *mouse2 = new Leaf(20);
	Composite *bag = new Composite();
	bag->Add(mouse);
	bag->Add(mouse2);
	cout << bag->GetSize() << endl;
	return 0;
}
Ejemplo n.º 5
0
///Composite 组合模式通过和 Decorator 模式有着类似的结构图,但是 Composite 模式旨在构造 类,而 Decorator 模式重在不生成子类即可给对象添加职责。Decorator 模式重在修饰,而 Composite 模式重在表示
void CompositeTest() {
    Leaf* l = new Leaf();
    l->Operation();
    
    Composite* com = new Composite();
    com->Add(l);
    com->Operation();
    
    NS_Composite::Component* ll = com->GetChild(0);
    ll->Operation();
}
bool PoissonBlendEx::init(Composite& rootNode) {

    ImageRGBA srcImg, tarImg;
    ReadImageFromFile(getFullPath("images/sfmarket.png"), srcImg);
    ReadImageFromFile(getFullPath("images/sfsunset.png"), tarImg);

    ConvertImage(srcImg, src);
    ConvertImage(tarImg, tar);

    ImageGlyphPtr srcGlyph = createImageGlyph(srcImg, false);
    ImageGlyphPtr tarGlyph = createImageGlyph(tarImg, false);
    ImageGlyphPtr resultGlyph = createImageGlyph(tarImg, false);

    GlyphRegionPtr srcRegion = MakeGlyphRegion(srcGlyph,
                               CoordPercent(0.05f, 0.0f), CoordPercent(0.4f, 0.3f),
                               AspectRule::FixedWidth, COLOR_NONE, COLOR_NONE,
                               Color(200, 200, 200, 255), UnitPX(1.0f));

    GlyphRegionPtr tarRegion = MakeGlyphRegion(tarGlyph,
                               CoordPercent(0.55f, 0.0f), CoordPercent(0.4f, 0.3f),
                               AspectRule::FixedWidth, COLOR_NONE, COLOR_NONE,
                               Color(200, 200, 200, 255), UnitPX(1.0f));

    TextLabelPtr textLabel = TextLabelPtr(
                                 new TextLabel("Solving Poisson Blend ...",
                                         CoordPercent(0.1f, 0.35f), CoordPercent(0.8f, 0.5f)));
    textLabel->fontSize = UnitPX(20.0f);
    textLabel->fontType = FontType::Bold;
    textLabel->fontStyle = FontStyle::Outline;

    GlyphRegionPtr resultRegion = MakeGlyphRegion(resultGlyph,
                                  CoordPercent(0.1f, 0.35f), CoordPercent(0.8f, 0.5f),
                                  AspectRule::FixedWidth, COLOR_NONE, COLOR_NONE,
                                  Color(200, 200, 200, 255), UnitPX(1.0f));

    rootNode.add(srcRegion);
    rootNode.add(tarRegion);
    rootNode.add(resultRegion);
    rootNode.add(textLabel);
    workerTask = WorkerTaskPtr(new Worker([=] {
        PoissonBlend(src, tar, 32, 6);
        ImageRGBA out;
        ConvertImage(tar,out);
        getContext()->addDeferredTask([=]() {
            resultGlyph->set(out,getContext().get());
            textLabel->setLabel("Finished!");
        });
    }));
    workerTask->execute(isForcedClose());
    return true;
}
Ejemplo n.º 7
0
int main()
{
    Leaf *pLeaf1 = new Leaf();
    Leaf *pLeaf2 = new Leaf();
    Composite *pComposite = new Composite;
    pComposite->Add(pLeaf1);
    pComposite->Add(pLeaf2);
    pComposite->Operation();
    cout << "pComposite->GetChild(2)->Operation():" << endl;
    pComposite->GetChild(2)->Operation();
    delete pComposite;
    cin.get();
    return 0;
}
void AlloyContext::update(Composite& rootNode) {
	endTime = std::chrono::steady_clock::now();
	double updateElapsed = std::chrono::duration<double>(
			endTime - lastUpdateTime).count();
	double animateElapsed = std::chrono::duration<double>(
			endTime - lastAnimateTime).count();
	double cursorElapsed = std::chrono::duration<double>(
			endTime - lastCursorTime).count();
	if (deferredTasks.size() > 0) {
		executeDeferredTasks();
		cursorLocator.reset(screenSize);
		rootNode.updateCursor(&cursorLocator);
		dirtyCursorLocator = false;
		mouseOverRegion = locate(cursorPosition);
		dirtyCursor = false;
		dirtyLayout = true;
	}
	if (updateElapsed > UPDATE_LOCATOR_INTERVAL_SEC) {
		if (dirtyCursorLocator) {
			cursorLocator.reset(screenSize);
			rootNode.updateCursor(&cursorLocator);
			dirtyCursorLocator = false;
			mouseOverRegion = locate(cursorPosition);
			dirtyCursor = false;
		}
		lastUpdateTime = endTime;
	}
	if (cursorElapsed >= UPDATE_CURSOR_INTERVAL_SEC) { //Dont try to animate faster than 60 fps.
		if (dirtyCursor && !dirtyCursorLocator) {
			mouseOverRegion = locate(cursorPosition);
			dirtyCursor = false;
		}
		dirtyUI = true;
		lastCursorTime = endTime;
	}
	if (animateElapsed >= ANIMATE_INTERVAL_SEC) { //Dont try to animate faster than 60 fps.
		lastAnimateTime = endTime;
		if (animator.step(animateElapsed)) {
			dirtyLayout = true;
			dirtyUI = true;
		}
	}
	if (dirtyLayout) {
		rootNode.pack(this);
		animator.firePostEvents();
		dirtyCursorLocator = true;
		dirtyLayout = false;
	}

}
Ejemplo n.º 9
0
/*!
 * \brief TextEditPrintMenuVisitor::indent
 * \param item
 * \return
 */
QString TextEditPrintMenuVisitor::indent(Composite *item) const
{
    QString rIndentString;

    QString lIndentStep("    ");
    Composite *lMenuItem = item->parent();
    while (lMenuItem)
    {
        lMenuItem = lMenuItem->parent();
        rIndentString.append(lIndentStep);
    }

    return rIndentString;
}
/*!
 * \brief ConsolePrintMenuVisitor::indent
 * \param item
 * \return
 */
std::string ConsolePrintMenuVisitor::indent(Composite *item) const
{
    std::string rIndentString;

    std::string lIndentStep = "    ";
    Composite *lMenuItem = item->parent();
    while (lMenuItem)
    {
        lMenuItem = lMenuItem->parent();
        rIndentString.append(lIndentStep);
    }

    return rIndentString;
}
Ejemplo n.º 11
0
int main()
{
    Leaf * pLeaf1 = new Leaf();
    Leaf * pLeaf2 = new Leaf();

    Composite * pComposite = new Composite;
    pComposite->Add(pLeaf1);
    pComposite->Add(pLeaf2);
    pComposite->Operation();
    pComposite->GetChild(2)->Operation();

    delete pComposite;

    return 0;
}
Ejemplo n.º 12
0
bool MeshParticleEx::init(Composite& rootNode) {
	box3f renderBBox = box3f(float3(-0.5f, -0.5f, -0.5f),float3(1.0f, 1.0f, 1.0f));

	mesh.load(getFullPath("models/monkey.obj"));

	mesh.updateVertexNormals();
	int N = (int)mesh.vertexLocations.size();
	mesh.vertexColors.resize(N);
	box3f box = mesh.getBoundingBox();
	for (int n = 0; n < N; n++) {
		float3 pt = mesh.vertexLocations[n];
		pt = (pt - box.position) / box.dimensions;
		mesh.vertexColors[n] = HSVAtoRGBAf(HSVA(pt.x, 0.7f, 0.8f, 1.0f));
	}
	//Make region on screen to render 3d view
	renderRegion=MakeRegion("Render View",CoordPerPX(0.5f,0.5f,-256,-256),CoordPX(512,512),COLOR_NONE,COLOR_WHITE,UnitPX(1.0f));
	//Initialize depth buffer to store the render
	depthFrameBuffer.initialize(512, 512);
	//Set up camera
	camera.setNearFarPlanes(0.1f, 3.0f);
	camera.setZoom(1.0f);
	camera.setCameraType(CameraType::Perspective);
	camera.setDirty(true);
	//Map object geometry into unit bounding box for draw.
	camera.setPose(MakeTransform(mesh.getBoundingBox(), renderBBox));
	//Add listener to respond to mouse manipulations
	addListener(&camera);
	//Add render component to root node so it is relatively positioned.
	rootNode.add(renderRegion);
	return true;
}
bool MeshWireframeEx::init(Composite& rootNode) {
	box3f renderBBox = box3f(float3(-0.5f, -0.5f, -0.5f),
			float3(1.0f, 1.0f, 1.0f));
	mesh.load(getFullPath("models/monkey.obj"));
	Subdivide(mesh,SubDivisionScheme::CatmullClark);
	mesh.updateVertexNormals();
	//Make region on screen to render 3d view
	renderRegion = MakeRegion("Render View", CoordPerPX(0.5f, 0.5f, -256, -256),
			CoordPX(512, 512), COLOR_NONE, COLOR_WHITE, UnitPX(1.0f));
	//Initialize depth buffer to store the render
	depthFrameBuffer.initialize(512, 512);
	wireframeFrameBuffer.initialize(512, 512);
	//Set up camera
	camera.setNearFarPlanes(-2.0f, 2.0f);
	camera.setZoom(0.75f);
	camera.setCameraType(CameraType::Orthographic);
	//Map object geometry into unit bounding box for draw.
	camera.setPose(MakeTransform(mesh.getBoundingBox(), renderBBox));
	//Add listener to respond to mouse manipulations
	addListener(&camera);
	//Add render component to root node so it is relatively positioned.
	rootNode.add(renderRegion);
	setOnResize([=](const int2& dims) {
		camera.setDirty(true);
	});
	wireframeShader.setFaceColor(Color(0.1f,0.1f,1.0f,0.5f));
	wireframeShader.setEdgeColor(Color(1.0f,0.8f,0.1f,1.0f));
	wireframeShader.setLineWidth(1.5f);
	return true;
}
Ejemplo n.º 14
0
void CompositeDlg::SetTime(TimeValue t) 
	{
	Interval valid;	
	theTex->Update(ip->GetTime(), valid);
	LoadDialog(FALSE);
	InvalidateRect(hPanel,NULL,0);	
	}
Ejemplo n.º 15
0
	void CityObject::finish( AppearanceManager& appearanceManager, const ParserParams& params ) 
	{
		Appearance* myappearance = appearanceManager.getAppearance( getId() );

        std::vector< Geometry* >::const_iterator itGeom = _geometries.begin();
        for ( ; itGeom != _geometries.end(); ++itGeom ) {
            if ( !( (*itGeom)->getComposite() ) ) {
                (*itGeom)->finish( appearanceManager, myappearance ? myappearance : 0, params );
            } else {
                Composite* geomComposite = (*itGeom)->getComposite();
                myappearance = appearanceManager.getAppearance( geomComposite->getId() );
                (*itGeom)->finish( appearanceManager, myappearance ? myappearance : 0, params );
            }
        }

        std::vector< ImplicitGeometry* >::const_iterator itImplGeom = _implicitGeometries.begin();
        for( ; itImplGeom != _implicitGeometries.end(); ++itImplGeom) {
            for(std::vector< Geometry* >::const_iterator it = (*itImplGeom)->_geometries.begin(); it != (*itImplGeom)->_geometries.end(); ++it) {
                if ( !( (*it)->getComposite() ) ) {
                    (*it)->finish( appearanceManager, myappearance ? myappearance : 0, params );
                } else {
                    Composite* geomComposite = (*it)->getComposite();
                    myappearance = appearanceManager.getAppearance( geomComposite->getId() );
                    (*it)->finish( appearanceManager, myappearance ? myappearance : 0, params );
                }
            }
        }

        bool finish = false;
        while ( !finish && params.optimize )
        {
            finish = true;
            int len = _geometries.size();
            for ( int i = 0; finish && i < len - 2; i++ )
            {
                for ( int j = i+1; finish && j < len - 1; j++ )
                {
                    if ( !_geometries[i]->merge( _geometries[j] ) ) continue;
                    delete _geometries[j];
                    _geometries.erase( _geometries.begin() + j );
                    finish = false;
                }
            }
        }
	}
Ejemplo n.º 16
0
int main() {
	Leaf* leaf1 = new Leaf();
	Leaf* leaf2 = new Leaf();

	Composite* composite = new Composite();
	composite->add( leaf1 );
	composite->add( leaf2 );
	Composite* composite2 = new Composite();
	composite2->add( new Leaf() );
	composite2->add( new Leaf() );
	composite2->add( new Leaf() );
	composite2->add( new Leaf() );
	composite->add( composite2 );

	composite->operation();


}
Ejemplo n.º 17
0
void dummy () {
	Composite* aComposite = new Composite;
	Leaf* aLeaf = new Leaf;

	Component* aComponent;
	Composite* test;

	aComponent = aComposite;
	if (test = aComponent->GetComposite()) {
		test->Add(new Leaf);
	}

	aComponent = aLeaf;

	if (test = aComponent->GetComposite()) {
		test->Add(new Leaf); // will not add leaf
	}
}
void test_incomplete()
{
    Composite c;
    c.add( new ConcreteComposite1 );
    c.add( new ConcreteComposite2 ); 
    BOOST_CHECK_EQUAL( c.size(), 3u );
    c.add( new_clone( c ) ); // add c to itself
    BOOST_CHECK_EQUAL( c.size(), 6u );
    c.add( c );              // add c to itself
    BOOST_CHECK_EQUAL( c.size(), 12u );
    c.foo();     
}
Ejemplo n.º 19
0
void CompositeDlg::LoadDialog(BOOL draw) 
	{	
	if (theTex) {		
		theTex->ClampOffset();
		
		SetScrollRange(hScroll,SB_CTL,0,theTex->subTex.Count()-NDLG,FALSE);
		SetScrollPos(hScroll,SB_CTL,theTex->offset,TRUE);
		EnableWindow(hScroll,theTex->NumSubTexmaps()>NDLG);

		if (theTex->subTex.Count()>NDLG) {
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_UP),theTex->offset>0);
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_PAGEUP),theTex->offset>0);
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_DOWN),theTex->offset+NDLG<theTex->subTex.Count());
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_PAGEDOWN),theTex->offset+NDLG<theTex->subTex.Count());
		} else {
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_UP),FALSE);
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_PAGEUP),FALSE);
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_DOWN),FALSE);
			EnableWindow(GetDlgItem(hPanel,IDC_COMP_PAGEDOWN),FALSE);
			}

		Interval valid;
		theTex->Update(ip->GetTime(),valid);		
		UpdateSubTexNames();
		TSTR buf;
		buf.printf(_T("%d"),theTex->subTex.Count());
		SetDlgItemText(hPanel,IDC_COMP_NUMMAPS,buf);
		for (int i=0; i<min(theTex->subTex.Count(),NDLG); i++) {
			ShowWindow(GetDlgItem(hPanel,mapIDs[i]),SW_SHOW);
			ShowWindow(GetDlgItem(hPanel,labelIDs[i]),SW_SHOW);
			ShowWindow(GetDlgItem(hPanel,mapOnIDs[i]),SW_SHOW);
//			SetCheckBox(hPanel, mapOnIDs[i], theTex->mapOn[i+theTex->offset]);
			}
		for (; i<NDLG; i++) {
			ShowWindow(GetDlgItem(hPanel,mapIDs[i]),SW_HIDE);
			ShowWindow(GetDlgItem(hPanel,labelIDs[i]),SW_HIDE);
			ShowWindow(GetDlgItem(hPanel,mapOnIDs[i]),SW_HIDE);
			}
		}
	}
Ejemplo n.º 20
0
void CompositeDlg::SetNumMaps()
	{
	int res = DialogBoxParam(
		hInstance,
		MAKEINTRESOURCE(IDD_COMP_SETNUM),
		hPanel,
		NumMapsDlgProc,
		(LPARAM)theTex->subTex.Count());
	if (res>=0) {
		theTex->SetNumMaps(res);
		LoadDialog(TRUE);
		}
	}
Ejemplo n.º 21
0
RefTargetHandle Composite::Clone(RemapDir &remap) 
	{
	Composite *mnew = new Composite();
	*((MtlBase*)mnew) = *((MtlBase*)this);  // copy superclass stuff	
	mnew->ivalid.SetEmpty();	
	mnew->subTex.SetCount(subTex.Count());
	mnew->ReplaceReference(0,remap.CloneRef(pblock));

	mnew->offset = offset;
	mnew->mapOn.SetCount(subTex.Count()); //DS 3/8/99  this seems necessary due to the param block 2 changes.

	for (int i = 0; i<subTex.Count(); i++) {
		mnew->subTex[i] = NULL;
		if (subTex[i]) {
			mnew->ReplaceReference(i+1,remap.CloneRef(subTex[i]));
		//	GetCOREInterface()->AssignNewName(mnew->subTex[i]);
			}
//		mnew->mapOn[i] = mapOn[i];
		}
	BaseClone(this, mnew, remap);
	return (RefTargetHandle)mnew;
	}
Ejemplo n.º 22
0
bool TabPaneEx::init(Composite& rootNode) {
	TabBarPtr tabBar=TabBarPtr(new TabBar("Tab Bar",CoordPX(10,10),CoordPerPX(1.0,1.0,-20.0f,-20.0f)));
	tabBar->backgroundColor=MakeColor(64,64,64);
	const int K = 15;
	for (int k = 0;k < K;k++) {
		CompositePtr tabPane = CompositePtr(new Composite(MakeString()<<"Tab "<<k, CoordPX(0, 0), CoordPercent(1.0f, 1.0f)));
		tabPane->backgroundColor = MakeColor(HSVAtoColor(HSVA(k/(float)K, 0.7f, 1.0f, 1.0f)));
		tabBar->addPane(MakeShared<TabPane>(tabPane,(k%2==0)));
	}
	rootNode.backgroundColor=MakeColor(0,0,0);
	rootNode.add(tabBar);
	return true;
}
Ejemplo n.º 23
0
void Client::main(std::string args[]) {
    //定义所有的组合对象
    Composite *root = new Composite("服装");
    Composite *c1 = new Composite("男装");
    Composite *c2 = new Composite("女装");
    //定义所有的叶子对象
    Leaf *leaf1 = new Leaf("衬衣");
    Leaf *leaf2 = new Leaf("夹克");
    Leaf *leaf3 = new Leaf("裙子");
    Leaf *leaf4 = new Leaf("套装");
    //按照树的结构来组合组合对象和叶子对象
    root->addChild(c1);
    root->addChild(c2);

    c1->addChild(leaf1);
    c1->addChild(leaf2);

    c2->addChild(leaf3);
    c2->addChild(leaf4);

    //调用根对象的输出功能来输出整棵树
    root->printStruct("");
}
Ejemplo n.º 24
0
bool TweenEx::init(Composite& rootNode) {
	TextLabelPtr label = MakeTextLabel("Hello There!", CoordPercent(0.5f, 0.9f), CoordPX(100, 30), FontType::Normal, UnitPT(16.0f),RGBA(255, 255, 255, 255), HorizontalAlignment::Center,VerticalAlignment::Bottom);
	label->setOrigin(Origin::MiddleCenter);
	std::shared_ptr<ImageGlyph> img = createImageGlyph(getFullPath("images/sfmarket.png"));
	GlyphRegionPtr imgr = MakeGlyphRegion(img, CoordPercent(0.5f, 0.45f),CoordPX(100,300), AspectRule::FixedHeight, Color(32, 64, 128, 255),Color(128, 128, 128, 128), Color(200, 200, 200, 255), UnitPX(1.0f));
	GlyphRegionPtr iconr = MakeGlyphRegion(createAwesomeGlyph(0xf1b3),CoordPX(20, 20), CoordPX(50, 50), Color(32, 64, 128, 255),Color(255, 255, 255, 255));
	imgr->setOrigin(Origin::MiddleCenter);
	addTween(imgr->foregroundColor, Color(128, 128, 128, 255),Color(128, 128, 128, 0), 3.0, SineOut());
	addTween(imgr->dimensions, CoordPX(50, 50), CoordPX(300, 300), 1.0, SineOut());
	addTween(iconr->backgroundColor, Color(255, 64, 32, 255),Color(32, 64, 255, 255), 3.0, SineIn());
	addTween(iconr->foregroundColor, Color(0, 0, 0, 255),Color(255, 255, 255, 255), 3.0, SineIn());
	addTween(iconr->position, CoordPX(100, 10), CoordPerPX(0.5f,0.0f,-25.0f, 10.0f), 3.0, ExponentialOut());
	addTween(label->position, CoordPercent(0.5f, 0.7f), CoordPercent(0.5f, 0.9f), 1.0f, ExponentialOut())->addCompleteEvent([=](Tweenable* tween) {
		addTween(label->fontSize, UnitPT(16.0f), UnitPT(36.0f), 1.0f, ExponentialIn())->addCompleteEvent(
			[=](Tweenable* object) {
			label->setLabel( "Did you like that tween?");
		});
	});
	
	rootNode.add(label);
	rootNode.add(iconr);
	rootNode.add(imgr);
	return true;
}
Ejemplo n.º 25
0
void MainWindow::CreateEmpty(void)
{
    //Populate databases with sample objects
    WorldDatabase* world = dynamic_cast<WorldDatabase*>(DataModel("World"));
    ComponentModel* components = dynamic_cast<ComponentModel*>(DataModel("Components"));
    if(world != NULL && components != NULL)
    {           
        world->NewComposite();
        Composite* newObj = world->GetLastCreated();
        //Create component. If engine component, the engine component will also be
        //created. Also, all attributes are set to a generic default value at this point.
        Component* newComponent = components->CreateComponent("Transform");
        world->AddComponentTo(newComponent,newObj);

        newComponent = components->CreateComponent("Model");
        world->AddComponentTo(newComponent,newObj);

        //Initialize will set the component's model equal to the component values
        newObj->Initialize();

        m_HandleSys.HandleNew( newObj );
        m_Ui->ObjInspector->ReceiveNew(m_HandleSys.GetHandle());
    }
}
Ejemplo n.º 26
0
bool DialogsEx::init(Composite& rootNode) {
	FileButtonPtr saveButton=FileButtonPtr(new FileButton("Save File", CoordPerPX(0.2f, 0.0f, 0.0f, 5.0f),CoordPX(40, 40), FileDialogType::SaveFile));
	FileButtonPtr openMultiButton = FileButtonPtr(new FileButton("Open Multi-File", CoordPerPX(0.2f, 0.0f, 45.0f, 5.0f), CoordPX(40, 40), FileDialogType::OpenMultiFile));
	FileSelectorPtr fileSelector=FileSelectorPtr(new FileSelector("Selector", CoordPerPX(0.5f, 0.0f,0.0f,90.0f),CoordPX(300.0f, 30.0f)));
	ColorSelectorPtr colorselect = ColorSelectorPtr(new ColorSelector("Color", CoordPerPX(0.2f, 0.0f, 90.0f, 5.0f), CoordPX(150, 40)));
	ListBoxPtr listBox = ListBoxPtr(new ListBox("List Box", CoordPX( 5.0f, 90.0f),CoordPX(300,300)));
	for (int i = 0;i < 30;i++) {
		listBox->addEntry(ListEntryPtr(new ListEntry(listBox.get(),MakeString()<<"Multi-Selection Entry ("<<i<<")",30.0f)));
	}
	listBox->update();
	listBox->setEnableMultiSelection(true);

	rootNode.add(saveButton);
	rootNode.add(openMultiButton);
	rootNode.add(fileSelector);
	rootNode.add(colorselect);
	rootNode.add(listBox);

	using extensions = std::initializer_list<std::string>;
	std::string exampleFile = getContext()->getFullPath("images" + ALY_PATH_SEPARATOR + "sfsunset.png");
	fileSelector->addFileExtensionRule("Portable Network Graphics", "png");
	fileSelector->addFileExtensionRule("XML", extensions { "raw", "xml" });
	fileSelector->addFileExtensionRule("Text", "txt");
	fileSelector->setValue(exampleFile);

	saveButton->addFileExtensionRule("Portable Network Graphics", "png");
	saveButton->addFileExtensionRule("XML", extensions { "raw", "xml" });
	saveButton->addFileExtensionRule("Text", "txt");
	saveButton->setValue(exampleFile);

	openMultiButton->addFileExtensionRule("Portable Network Graphics", "png");
	openMultiButton->addFileExtensionRule("XML", extensions { "raw", "xml" });
	openMultiButton->addFileExtensionRule("Text", "txt");
	openMultiButton->setValue(exampleFile);
	return true;
}
Ejemplo n.º 27
0
void CompositeDlg::VScroll(int code, short int cpos ) {
	switch (code) {
		case SB_LINEUP: 	theTex->offset--;		break;
		case SB_LINEDOWN:	theTex->offset++;		break;
		case SB_PAGEUP:		theTex->offset -= NDLG;	break;
		case SB_PAGEDOWN:	theTex->offset += NDLG;	break;
		
		case SB_THUMBPOSITION: 
		case SB_THUMBTRACK:
			theTex->offset = cpos;
			break;
		}
	theTex->ClampOffset();
	UpdateSubTexNames();						
	LoadDialog(ip->GetTime());
	}
Ejemplo n.º 28
0
bool ExpandEx::init(Composite& rootNode) {
	ExpandBarPtr expandBar = ExpandBarPtr(
			new ExpandBar("exapander", CoordPercent(0.7f, 0.0f),
					CoordPercent(0.3f, 1.0f)));

	CompositePtr geomRegion = CompositePtr(
			new aly::Composite("Geometry", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 400.0f)));

	CompositePtr scrollRegion = CompositePtr(
			new aly::Composite("Scroll", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 200.0f)));
	scrollRegion->setScrollEnabled(true);
	scrollRegion->setOrientation(Orientation::Vertical);
	scrollRegion->add(
			MakeRegion("Region 1", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 300.0f), Color(255, 0, 0)));
	scrollRegion->add(
			MakeRegion("Region 2", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 300.0f), Color(0, 255, 0)));
	expandBar->add(geomRegion, 400, false);
	std::string exampleFile = getContext()->getFullPath(
			"models" + ALY_PATH_SEPARATOR+"monkey.ply");
	geomRegion->setOrientation(Orientation::Vertical);
	geomRegion->add(scrollRegion);
	RegionPtr apprRegion = RegionPtr(
			new aly::Region("Appearance", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 3000.0f)));
	expandBar->add(apprRegion, 400, false);
	apprRegion->backgroundColor = MakeColor(128, 64, 255);
	CompositePtr lightRegion = CompositePtr(
			new aly::Composite("Lighting", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 300.0f)));
	expandBar->add(lightRegion, 300, false);
	RegionPtr renderingRegion = RegionPtr(
			new aly::Region("Rendering", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 300.0f)));
	expandBar->add(renderingRegion, 300, true);
	RegionPtr filterRegion = RegionPtr(
			new aly::Region("Filtering", CoordPX(0, 0),
					CoordPerPX(1.0f, 0.0f, 0.0f, 300.0f)));
	expandBar->add(filterRegion, 300, false);
	rootNode.backgroundColor = MakeColor(getContext()->theme.LIGHT);
	rootNode.add(expandBar);
	return true;
}
Ejemplo n.º 29
0
Archivo: main.cpp Proyecto: Chuvi-w/cpp
int main() {
  Composite comp;
  Leaf test("test");
  test.show();
  comp.add(&test);
  Composite a;
  a.add(new Leaf("aa"));
  a.add(new Leaf("bb"));
  a.show();
  comp.add(&a);

  comp.show();

  return 0;
}
Ejemplo n.º 30
0
bool DragEx::init(Composite& rootNode) {
	int N = 25;
	srand(817213);
	std::list<TextLabelPtr> labels;
	for (int i = 0;i <N;i++) {
		TextLabelPtr label = MakeTextLabel(MakeString() << "Drag (" << i<<")", CoordPX(rand()%700, rand()%500), CoordPX(100, 100), FontType::Bold, UnitPT(16.0f), COLOR_WHITE, HorizontalAlignment::Center, VerticalAlignment::Middle);
		label->backgroundColor = MakeColor(HSVAtoColor(HSVA(i/(float)N,0.7f,0.5f,1.0f)));
		label->borderColor = MakeColor(64,64,64);
		label->borderWidth = UnitPX(1.0f);
		label->onMouseDown = [=](AlloyContext* context, const InputEvent& e) {
			if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
				//Bring component to top by setting it to be drawn last.
				dynamic_cast<Composite*>(label->parent)->putLast(label);
				label->borderColor = MakeColor(200, 200, 200);
			}
			return false;
		};
		label->onMouseUp = [=](AlloyContext* context, const InputEvent& e) {
			label->borderColor = MakeColor(64,64,64);
			return false;
		};

		labels.push_back(label);
		label->setDragEnabled(true);
		rootNode.add(label);

	}
	//Force drag elements inside draw bounds.
	setOnResize([=](const int2& dims) {
		box2px bounds(pixel2(0, 0), pixel2((float)dims.x,(float)dims.y));
		for (TextLabelPtr label : labels) {
			//Get current location, including drag offset.
			box2px box = label->getBounds();
			box.position = aly::clamp(box.position, bounds.position,bounds.position + bounds.dimensions - box.dimensions);
			label->position=CoordPX(box.position);
			//Reset drag offset now that we changed position.
			label->setDragOffset(pixel2(0, 0));
			//Repack component.
			label->pack();
		}
	});
	//getContext()->setDebug(true);
	return true;
}