void DataGraph::FillCell(UIHierarchyCell *cell, void *node) { //Temporary fix for loading of UI Interface to avoid reloading of texrures to different formates. // 1. Reset default format before loading of UI // 2. Restore default format after loading of UI from stored settings. Texture::SetDefaultGPU(GPU_UNKNOWN); DataNode *n = (DataNode *)node; UIStaticText *text = (UIStaticText *)cell->FindByName("_Text_"); text->SetText(StringToWString(n->GetName())); UIControl *icon = cell->FindByName("_Icon_"); icon->SetSprite("~res:/Gfx/UI/SceneNode/datanode", 0); UIControl *marker = cell->FindByName("_Marker_"); marker->SetVisible(false); if(n == workingNode) { cell->SetSelected(true, false); } else { cell->SetSelected(false, false); } Texture::SetDefaultGPU(EditorSettings::Instance()->GetTextureViewGPU()); }
void ControlsFactory::CustomizeButtonExpandable(UIButton *btn) { UIControl *expandable = new UIControl(Rect(btn->GetSize().dx - btn->GetSize().dy, 0, btn->GetSize().dy, btn->GetSize().dy)); expandable->SetInputEnabled(false); expandable->SetSprite("~res:/Gfx/UI/arrowdown", 0); btn->AddControl(expandable); SafeRelease(expandable); }
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 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); }
UIListCell *MaterialEditor::CellAtIndex(UIList *forList, int32 index) { UIListCell *c = forList->GetReusableCell("Material name cell"); if (!c) { c = new UIListCell(Rect(0, 0, forList->GetRect().dx, 20), "Material name cell"); float32 boxSize = 16; float32 y = (CellHeight(forList, index) - boxSize) / 2; float32 x = forList->GetRect().dx - boxSize; //Temporary fix for loading of UI Interface to avoid reloading of texrures to different formates. // 1. Reset default format before loading of UI // 2. Restore default format after loading of UI from stored settings. Texture::SetDefaultFileFormat(NOT_FILE); Rect r = Rect(x, y, boxSize, boxSize); UIControl *sceneFlagBox = new UIControl(r); sceneFlagBox->SetName("flagBox"); sceneFlagBox->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); sceneFlagBox->SetSprite("~res:/Gfx/UI/marker", 1); sceneFlagBox->SetInputEnabled(false); c->AddControl(sceneFlagBox); SafeRelease(sceneFlagBox); Texture::SetDefaultFileFormat((ImageFileFormat)EditorSettings::Instance()->GetTextureViewFileFormat()); } Material *mat = GetMaterial(index); bool found = false; if(EDM_ALL == displayMode) { for (int32 i = 0; i < (int32)workingNodeMaterials.size(); ++i) { if(workingNodeMaterials[i] == mat) { found = true; break; } } } else { found = true; } ControlsFactory::CustomizeListCell(c, StringToWString(mat->GetName()), false); UIControl *sceneFlagBox = c->FindByName("flagBox"); sceneFlagBox->SetVisible(found, false); if (index == selectedMaterial) { c->SetSelected(true, false); lastSelection = c; } else { c->SetSelected(false, false); } return c; }