UIHierarchyCell * GraphBase::CellForNode(UIHierarchy *forHierarchy, void *node) { UIHierarchyCell *c= forHierarchy->GetReusableCell("Graph cell"); //try to get cell from the reusable cells store if(!c) { //if cell of requested type isn't find in the store create new cell int32 leftSideWidth = EditorSettings::Instance()->GetLeftPanelWidth(); c = new UIHierarchyCell(Rect(0, 0, leftSideWidth, ControlsFactory::CELL_HEIGHT), "Graph cell"); UIControl *icon = new UIControl(Rect(0, 0, ControlsFactory::CELL_HEIGHT, ControlsFactory::CELL_HEIGHT)); icon->SetName("_Icon_"); icon->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); c->text->AddControl(icon); UIControl *marker = new UIControl(Rect(0, 0, ControlsFactory::CELL_HEIGHT, ControlsFactory::CELL_HEIGHT)); marker->SetName("_Marker_"); marker->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_PROPORTIONAL); c->text->AddControl(marker); UIStaticText *text = new UIStaticText(Rect(ControlsFactory::CELL_HEIGHT, 0, leftSideWidth - ControlsFactory::CELL_HEIGHT, ControlsFactory::CELL_HEIGHT)); Font *font = ControlsFactory::GetFont12(); text->SetFont(font); text->SetAlign(ALIGN_LEFT|ALIGN_VCENTER); text->SetName("_Text_"); text->SetTextColor(ControlsFactory::GetColorDark()); c->text->AddControl(text); } FillCell(c, node); ControlsFactory::CustomizeExpandButton(c->openButton); ControlsFactory::CustomizeSceneGraphCell(c); return c; }
void ControlsFactory::AddBorder(DAVA::UIControl *c) { Rect fullRect = c->GetRect(); Color lineColor(1.f, 1.f, 1.f, 0.5f); UIControl *leftLine = c->FindByName("LeftLine", false); if(!leftLine) { leftLine = ControlsFactory::CreateLine(Rect(0, 1, 1, fullRect.dy - 2), lineColor); leftLine->SetName("LeftLine"); c->AddControl(leftLine); SafeRelease(leftLine); } UIControl *rightLine = c->FindByName("RightLine", false); if(!rightLine) { rightLine = ControlsFactory::CreateLine(Rect(fullRect.dx - 1, 1, 1, fullRect.dy - 2), lineColor); rightLine->SetName("RightLine"); c->AddControl(rightLine); SafeRelease(rightLine); } UIControl *topLine = c->FindByName("TopLine", false); if(!topLine) { topLine = ControlsFactory::CreateLine(Rect(0, 0, fullRect.dx, 1), lineColor); topLine->SetName("TopLine"); c->AddControl(topLine); SafeRelease(topLine); } UIControl *bottomtLine = c->FindByName("BottomLine", false); if(!bottomtLine) { bottomtLine = ControlsFactory::CreateLine(Rect(0, fullRect.dy-1, fullRect.dx, 1), lineColor); bottomtLine->SetName("BottomLine"); c->AddControl(bottomtLine); SafeRelease(bottomtLine); } }
void UIAggregatorMetadata::InitializeControl(const String& controlName, const Vector2& position) { int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { UIControl* control = this->treeNodeParams[i].GetUIControl(); control->SetName(controlName); control->SetPosition(position); control->GetBackground()->SetDrawType(UIControlBackground::DRAW_ALIGNED); } }
// Initialize the control(s) attached. void BaseMetadata::InitializeControl(const String& controlName, const Vector2& position) { int paramsCount = this->GetParamsCount(); for (BaseMetadataParams::METADATAPARAMID i = 0; i < paramsCount; i ++) { UIControl* control = this->treeNodeParams[i].GetUIControl(); control->SetName(controlName); control->SetSize(INITIAL_CONTROL_SIZE); control->SetPosition(position); control->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); } }
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; }