void FormatsTest::LoadResources() { GetBackground()->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); int32 columnCount = 6; int32 rowCount = (FORMAT_COUNT-1) / columnCount; if(0 != FORMAT_COUNT % columnCount) { ++rowCount; } float32 size = Min(GetSize().x / columnCount, GetSize().y / rowCount); Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(20); for(int32 i = FORMAT_RGBA8888; i < FORMAT_COUNT; ++i) { int32 y = (i-1) / columnCount; int32 x = (i-1) % columnCount; String formatName = Texture::GetPixelFormatString((PixelFormat)i); UIControl *c = new UIControl(Rect(x*size, y*size, size - 2, size - 2)); c->SetSprite(Format("~res:/TestData/FormatTest/%s/number_0", formatName.c_str()), 0); c->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); UIStaticText *text = new UIStaticText(Rect(0, c->GetSize().y - 30, c->GetSize().x, 30)); text->SetText(StringToWString(formatName)); text->SetFont(font); text->SetTextColor(Color(1.0f, 1.0f, 1.0f, 1.0f)); c->AddControl(text); AddControl(c); SafeRelease(text); SafeRelease(c); } SafeRelease(font); }
void HierarchyTreeControlNode::AddControlToParent() { if (!parent) return; DVASSERT(uiObject); HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(parent); if (screenNode) { screenNode->GetScreen()->AddControl(this->uiObject); } else { //HierarchyTreeControlNode* controlNode = GetControlNode(); HierarchyTreeControlNode* controlNode = dynamic_cast<HierarchyTreeControlNode*>(parent); if (controlNode) { UIControl* control = controlNode->GetUIObject(); if (control) control->AddControl(this->uiObject); } } }
void StaticTextScreen::LoadResources() { Font::SetDPI(160); Font *fnt; fnt = FTFont::Create(FilePath("~res:/Fonts/yikes.ttf")); // fnt = GraphicsFont::Create("~res:/Fonts/korinna.def", "~res:/Gfx/Fonts2/korinna"); fnt->SetSize(7.5f); // fnt->SetSize(12); // fnt->SetVerticalSpacing(-1); // fnt->SetColor(.82f, .81f, 0.73f, 1.0f); float32 sizeX = 50; float32 sizeY = 80; UIControl *tc = new UIControl(Rect(0, 0, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); UIStaticText *tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); // tx->SetMultiline(true); // tx->SetAlign(ALIGN_LEFT|ALIGN_TOP); tx->SetText(L"Management"); // tx->SetText(L"This text is aligned by the Left and Top borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, 0, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HCENTER|ALIGN_TOP); // tx->SetText(L"abab."); tx->SetText(L"This text is aligned byyyi the Center and Top borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(size.x - sizeX, 0, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_RIGHT|ALIGN_TOP); // tx->SetText(L"apap."); tx->SetText(L"This text is aligned by the Right and Top borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(0, (size.y - sizeY)/2, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_LEFT|ALIGN_VCENTER); // tx->SetText(L"apap."); tx->SetText(L"This text is aligned by the Left and Center borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, (size.y - sizeY)/2, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HCENTER|ALIGN_VCENTER); // tx->SetText(L"abpbs"); tx->SetText(L"This text is aligned by the Center and Center borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(size.x - sizeX, (size.y - sizeY)/2, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_RIGHT|ALIGN_VCENTER); // tx->SetText(L"aaaa."); tx->SetText(L"This text is aligned by the Right and Center borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(0, size.y - sizeY, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_LEFT|ALIGN_BOTTOM); tx->SetText(L"This text is aligned by the Left and Bottom borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, size.y - sizeY, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HCENTER|ALIGN_BOTTOM); tx->SetText(L"This text is aligned by the Center and Bottom borders."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect(size.x - sizeX, size.y - sizeY, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_RIGHT|ALIGN_BOTTOM); tx->SetText(L"No desc elems.uj"); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); tc = new UIControl(Rect((size.x - sizeX)/2, (size.y - sizeY)/2 - 70, sizeX, sizeY)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); //tc->GetBackground()->color = Color(0,0,0.4f,1.0f); tx = new UIStaticText(Rect(0, 0, sizeX, sizeY)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HJUSTIFY|ALIGN_TOP); tx->SetText(L"This text is Justify and it's looks little better than the others. aja. AVA."); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); //fnt->SetColor(1.0f, 0.3f, 0.3f, 1.0f); fnt->SetVerticalSpacing(5); tc = new UIControl(Rect(100, 100, 600, 400)); tc->SetSpriteDrawType(UIControlBackground::DRAW_FILL); tc->GetBackground()->color = Color(0.5f,0.5,0.5f,1.0f); tx = new UIStaticText(Rect(10, 10, 400, 200)); tx->SetFont(fnt); tx->SetMultiline(true); tx->SetAlign(ALIGN_HJUSTIFY|ALIGN_TOP); tx->SetText(L"Test test shadow, shadow test ABCDEFGHJIKLMNOPQRSTUVWXYZ\nTest test shadow, shadow test ABCDEFGHJIKLMNOPQRSTUVWXYZ\nTest test shadow, shadow test ABCDEFGHJIKLMNOPQRSTUVWXYZ"); tx->SetTextColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); tx->SetShadowColor(Color(0.0f, 0.0f, 0.0f, 0.25f)); tx->SetShadowOffset(Vector2(2.0f, 2.0f)); tc->AddControl(tx); AddControl(tc); SafeRelease(tc); SafeRelease(tx); SafeRelease(fnt); }
void UIScrollViewTest::LoadResources() { Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(14); font->SetColor(Color::White()); UIYamlLoader::Load( this, "~res:/UI/Test/ScrollScreen.yaml" ); scrollView = DynamicTypeCheck<UIScrollView *>( FindByName( "Scrollview" ) ); UIControl* innerControl = FindByName("UIControl1"); if (innerControl) { innerControl->SetSprite("~res:/Gfx/UI/HorizontalScroll", 0); innerControl->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); } UIControl *control = FindByName("HorizontalScrollbar"); if( control ) { UIScrollBar *horizontalScrollbar = DynamicTypeCheck<UIScrollBar *>( control ); horizontalScrollbar->GetSlider()->SetSprite("~res:/Gfx/UI/HorizontalScroll", 0); horizontalScrollbar->GetSlider()->GetBackground()->SetDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL); horizontalScrollbar->GetSlider()->GetBackground()->SetLeftRightStretchCap(10); horizontalScrollbar->SetOrientation( UIScrollBar::ORIENTATION_HORIZONTAL ); horizontalScrollbar->SetDelegate(scrollView); } control = FindByName("VerticalScrollbar"); if( control ) { UIScrollBar *verticalScrollbar = DynamicTypeCheck<UIScrollBar *>( control ); verticalScrollbar->GetSlider()->SetSprite("~res:/Gfx/UI/VerticalScroll", 0); verticalScrollbar->GetSlider()->GetBackground()->SetDrawType(UIControlBackground::DRAW_STRETCH_VERTICAL); verticalScrollbar->GetSlider()->GetBackground()->SetTopBottomStretchCap(10); verticalScrollbar->SetOrientation( UIScrollBar::ORIENTATION_VERTICAL ); verticalScrollbar->SetDelegate(scrollView); } UIControl *testControl4 = new UIControl(Rect(1200, 1400, 250, 250)); testControl4->SetDebugDraw(true); testControl4->GetBackground()->SetColor(Color(0.3333, 0.3333, 0.5555, 1.0000)); testControl4->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testControl4->SetName("CONTROL_4"); testControl4->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); scrollView->AddControlToContainer(testControl4); UIControl *testControlChild = new UIControl(Rect(100, 100, 150, 150)); testControlChild->SetDebugDraw(true); testControlChild->GetBackground()->SetColor(Color(0.3333, 0.3333, 0.5555, 1.0000)); testControlChild->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testControlChild->SetName("CONTROL_3"); testControlChild->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); UIControl *testControl = new UIControl(Rect(50, 0, 150, 150)); testControl->SetDebugDraw(true); testControl->GetBackground()->SetColor(Color(0.3333, 0.6667, 0.4980, 1.0000)); testControl->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testControl->SetName("CONTROL_2"); testControl->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); testControl->AddControl(testControlChild); UIButton *testButton = new UIButton(Rect(10, 50, 250, 100)); testButton->SetDebugDraw(true); testButton->SetStateFont(STATE_NORMAL, font); testButton->SetStateText(STATE_NORMAL, L"First button"); testButton->GetBackground()->SetColor(Color(0.6667, 0.6667, 0.4980, 1.0000)); testButton->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); testButton->SetName("CONTROL_1"); testButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); testButton->AddControl(testControl); scrollView->AddControlToContainer(testButton); testMessageText = new UIStaticText(Rect(10, 10, 300, 30)); testMessageText->SetFont(font); testMessageText->SetTextColor(Color(0.0, 1.0, 0.0, 1.0)); testMessageText->GetBackground()->SetColor(Color(0.5, 0.0, 0.25, 1.0)); testMessageText->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); AddControl(testMessageText); finishTestBtn = new UIButton(Rect(10, 310, 300, 30)); finishTestBtn->SetStateFont(0xFF, font); finishTestBtn->SetStateFontColor(0xFF, Color(1.0, 0.0, 0.0, 0.75)); finishTestBtn->SetStateText(0xFF, L"Finish test"); finishTestBtn->SetDebugDraw(true); finishTestBtn->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UIScrollViewTest::ButtonPressed)); AddControl(finishTestBtn); }