Ejemplo n.º 1
0
UIFileTreeCell::UIFileTreeCell(const Rect &rect, const String &cellIdentifier)
:	UIListCell(rect, cellIdentifier)
{
	FTFont * fnt = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf");
	fnt->SetColor(0, 0, 0, 1);
	fnt->SetSize(14);
	SetStateFont(STATE_NORMAL, fnt);
	SafeRelease(fnt);
	
	
	//Rect iconSize = Rect(0, 0, rect.dy, rect.dy);
	//icon = new UIControl(rect);
	//text = new UIStaticText(rect);
	
	
	// icon = UIControl(, <#bool rectInAbsoluteCoordinates#>)
	// 
	//GetStateBackground(STATE_NORMAL)->SetDrawType(UIControlBackground::DRAW_FILL);
	//GetStateBackground(STATE_NORMAL)->SetColor(Color(0.0, 0.0, 0.0, 1.0f));
	//SetStateText(UIControl::STATE_NORMAL, L"Mega test!");

}
Ejemplo n.º 2
0
	void UIButton::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
	{
		UIControl::LoadFromYamlNode(node, loader);
		
		//int32 stateArray[] = {STATE_NORMAL, STATE_PRESSED_INSIDE, STATE_PRESSED_OUTSIDE, STATE_DISABLED, STATE_SELECTED, STATE_HOVER};
		//String statePostfix[] = {"Normal", "PressedInside", "PressedOutside", "Disabled", "Selected", "Hover"};
	
		for (int k = 0; k < STATE_COUNT; ++k)
		{
			YamlNode * stateSpriteNode = node->Get(Format("stateSprite%s", statePostfix[k].c_str()));
			if (stateSpriteNode)
			{
				YamlNode * spriteNode = stateSpriteNode->Get(0);
				YamlNode * frameNode = stateSpriteNode->Get(1);
				YamlNode * backgroundModificationNode = NULL;
				if(stateSpriteNode->GetCount() > 2)
				{
					backgroundModificationNode = stateSpriteNode->Get(2);
				}
				
				int32 frame = 0;
				if (frameNode)frame = frameNode->AsInt();
				if (spriteNode)
				{
					SetStateSprite(stateArray[k], spriteNode->AsString(), frame);
				}
				if (backgroundModificationNode)
				{
					stateBacks[k]->SetModification(backgroundModificationNode->AsInt());
				}
			}
            
            YamlNode * stateDrawTypeNode = node->Get(Format("stateDrawType%s", statePostfix[k].c_str()));
			if (stateDrawTypeNode)
			{
				UIControlBackground::eDrawType type = (UIControlBackground::eDrawType)loader->GetDrawTypeFromNode(stateDrawTypeNode);
                SetStateDrawType(stateArray[k],type);
                
                YamlNode * leftRightStretchCapNode = node->Get(Format("leftRightStretchCap%s", statePostfix[k].c_str()));
                YamlNode * topBottomStretchCapNode = node->Get(Format("topBottomStretchCap%s", statePostfix[k].c_str()));

                if(leftRightStretchCapNode)
                {
                    float32 leftStretchCap = leftRightStretchCapNode->AsFloat();
                    GetActualBackground(stateArray[k])->SetLeftRightStretchCap(leftStretchCap);
                }
                
                if(topBottomStretchCapNode)
                {
                    float32 topStretchCap = topBottomStretchCapNode->AsFloat();
                    GetActualBackground(stateArray[k])->SetTopBottomStretchCap(topStretchCap);
                }
			}
			else
			{
                SetStateDrawType(stateArray[k],UIControlBackground::DRAW_ALIGNED);
			}
            
            YamlNode * stateAlignNode = node->Get(Format("stateAlign%s", statePostfix[k].c_str()));
			if (stateAlignNode)
			{
				int32 align = loader->GetAlignFromYamlNode(stateAlignNode);
                SetStateAlign(stateArray[k],align);
			}

			YamlNode * stateFontNode = node->Get(Format("stateFont%s", statePostfix[k].c_str()));
			if (stateFontNode)
			{
				Font * font = loader->GetFontByName(stateFontNode->AsString());
				if (font)SetStateFont(stateArray[k], font);
			}
			
			YamlNode * stateTextNode = node->Get(Format("stateText%s", statePostfix[k].c_str()));
			if (stateTextNode)
			{
				SetStateText(stateArray[k], LocalizedString(stateTextNode->AsWString()));
			}
			
			YamlNode * stateTextColorNode = node->Get(Format("stateTextcolor%s", statePostfix[k].c_str()));
			if (stateTextColorNode)
			{
				Vector4 c = stateTextColorNode->AsVector4();
				SetStateFontColor(stateArray[k], Color(c.x, c.y, c.z, c.w));
			}
			
			YamlNode * stateShadowColorNode = node->Get(Format("stateShadowcolor%s", statePostfix[k].c_str()));
			if (stateShadowColorNode)
			{
				Vector4 c = stateShadowColorNode->AsVector4();
				SetStateShadowColor(stateArray[k], Color(c.x, c.y, c.z, c.w));
			}			
			
			YamlNode * stateShadowOffsetNode = node->Get(Format("stateShadowoffset%s", statePostfix[k].c_str()));
			if (stateShadowOffsetNode)
			{
				SetStateShadowOffset(stateArray[k], stateShadowOffsetNode->AsVector2());
			}
			
			YamlNode * colorInheritNode = node->Get(Format("stateColorInherit%s", statePostfix[k].c_str()));
			if(colorInheritNode)
			{
				UIControlBackground::eColorInheritType type = (UIControlBackground::eColorInheritType)loader->GetColorInheritTypeFromNode(colorInheritNode);
				GetActualBackground(stateArray[k])->SetColorInheritType(type);
			}
			
			YamlNode * colorNode = node->Get(Format("stateColor%s", statePostfix[k].c_str()));
			if(colorNode)
			{
				Color color = loader->GetColorFromYamlNode(colorNode);
				GetActualBackground(stateArray[k])->SetColor(color);
			}
		}
	}
Ejemplo n.º 3
0
	void UIButton::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
	{
		UIControl::LoadFromYamlNode(node, loader);
		
		//int32 stateArray[] = {STATE_NORMAL, STATE_PRESSED_INSIDE, STATE_PRESSED_OUTSIDE, STATE_DISABLED, STATE_SELECTED, STATE_HOVER};
		//String statePostfix[] = {"Normal", "PressedInside", "PressedOutside", "Disabled", "Selected", "Hover"};
	
		for (int k = 0; k < STATE_COUNT; ++k)
		{
			YamlNode * stateSpriteNode = node->Get(Format("stateSprite%s", statePostfix[k].c_str()));
			if (stateSpriteNode)
			{
				YamlNode * spriteNode = stateSpriteNode->Get(0);
				YamlNode * frameNode = stateSpriteNode->Get(1);
				
				int32 frame = 0;
				if (frameNode)frame = frameNode->AsInt();
				if (spriteNode)
				{
					SetStateSprite(stateArray[k], spriteNode->AsString(), frame);
				}
			}
            
            YamlNode * stateDrawTypeNode = node->Get(Format("stateDrawType%s", statePostfix[k].c_str()));
			if (stateDrawTypeNode)
			{
				UIControlBackground::eDrawType type = (UIControlBackground::eDrawType)loader->GetDrawTypeFromNode(stateDrawTypeNode);
                SetStateDrawType(stateArray[k],type);
                
                YamlNode * leftRightStretchCapNode = node->Get(Format("leftRightStretchCap%s", statePostfix[k].c_str()));
                YamlNode * topBottomStretchCapNode = node->Get(Format("topBottomStretchCap%s", statePostfix[k].c_str()));

                if(leftRightStretchCapNode)
                {
                    float32 leftStretchCap = leftRightStretchCapNode->AsFloat();
                    GetActualBackground(stateArray[k])->SetLeftRightStretchCap(leftStretchCap);
                }
                
                if(topBottomStretchCapNode)
                {
                    float32 topStretchCap = topBottomStretchCapNode->AsFloat();
                    GetActualBackground(stateArray[k])->SetTopBottomStretchCap(topStretchCap);
                }
			}
            
            YamlNode * stateAlignNode = node->Get(Format("stateAlign%s", statePostfix[k].c_str()));
			if (stateAlignNode)
			{
				int32 align = loader->GetAlignFromYamlNode(stateAlignNode);
                SetStateAlign(stateArray[k],align);
			}

			YamlNode * stateFontNode = node->Get(Format("stateFont%s", statePostfix[k].c_str()));
			if (stateFontNode)
			{
				Font * font = loader->GetFontByName(stateFontNode->AsString());
				if (font)SetStateFont(stateArray[k], font);
			}
			
			YamlNode * stateTextNode = node->Get(Format("stateText%s", statePostfix[k].c_str()));
			if (stateTextNode)
			{
				SetStateText(stateArray[k], LocalizedString(stateTextNode->AsWString()));
			}
			
		}
		for (int k = 0; k < STATE_COUNT; ++k)
		{
			YamlNode * colorInheritNode = node->Get("colorInherit");
			UIControlBackground::eColorInheritType type = (UIControlBackground::eColorInheritType)loader->GetColorInheritTypeFromNode(colorInheritNode);
			if(colorInheritNode)
			{
				for(int32 i = 0; i < DRAW_STATE_COUNT; ++i)
				{
					if(stateBacks[i])
					{
						stateBacks[i]->SetColorInheritType(type);
					}
				}
			}
		}
	}