示例#1
0
UIListCell *MainScreen::CellAtIndex(UIList *list, int32 index)
{
    UIListCell *c = list->GetReusableCell("UI info cell"); //try to get cell from the reusable cells store
    if(!c)
    {
        c = new UIListCell(Rect(0.0f, 0.0f, 2*buttonW, cellH), "UI info cell");
    }
    
    c->RemoveAllControls();
    
    WideString keyStr = (selectedControl ? selectedControl->GetSpecificInfoKeyText(index) : L"");
    WideString valueStr = (selectedControl ? selectedControl->GetSpecificInfoValueText(index) : L"");
    
    FTFont* font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf");
    font->SetSize(20.0f);
    font->SetColor(0.8f, 0.8f, 0.8f, 1.0f);
    
    c->SetStateFont(UIControl::STATE_NORMAL, font);
    
    UIStaticText* cellKeyText = new UIStaticText(Rect(0.0f, 0.0f, buttonW, cellH));
    cellKeyText->SetFont(font);
    cellKeyText->SetText(keyStr);
    c->AddControl(cellKeyText);
    
    UIStaticText* cellValueText = new UIStaticText(Rect(buttonW, 0.0f, buttonW, cellH));
    cellValueText->SetFont(font);
    cellValueText->SetText(valueStr);
    c->AddControl(cellValueText);
    
    SafeRelease(font);
    
    return c;//returns cell
}
UIStaticText * PropertyPanel::AddHeader(const WideString & string, float32 fontSize)
{
    FTFont * font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf");
    font->SetSize(fontSize);
    font->SetColor(Color(0.2f, 0.2f, 0.2f, 1.0f));

    UIStaticText * text = new UIStaticText(Rect(10, 0, GetRect().dx - 20, 20));
    text->SetAlign(ALIGN_LEFT | ALIGN_VCENTER);
    text->SetFont(font);
    text->SetText(string);
    SafeRelease(font);
    AddPropertyControl(text);
    text->Release();
    return text;
}
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!");

}
示例#4
0
void MainScreen::LoadResources()
{
    Vector2 screenSize(GetScreenWidth(), GetScreenHeight());
    
    cellH = GetScreenHeight() / 25;
    buttonW = GetScreenWidth() / 10;
    
    
    float32 infoAreaWidth = screenSize.x - 960.0f;

    Vector2 previewSize(screenSize.x - infoAreaWidth, screenSize.y - cellH);
    //Vector2 previewScale(previewSize.x/screenSize.x, previewSize.y/screenSize.y);
    
    preview = new PreviewControl(Rect(0.0f, cellH, previewSize.x, previewSize.y));
    //preview->SetScaledRect(Rect(0.0f, cellH, previewSize.x*0.9f, previewSize.y*0.9f));
    //preview->SetDebugDraw(true);
    
    AddControl(preview);
    
    FTFont* font = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf");
    font->SetSize(20.0f);
    font->SetColor(0.8f, 0.8f, 0.8f, 1.0f);
    
    chooseProject = new UIButton(Rect(0.0f, 0.0f, buttonW, cellH));
    chooseProject->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    chooseProject->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    chooseProject->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    chooseProject->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5, 0.5, 0.5, 0.5));
    chooseProject->SetStateFont(UIControl::STATE_NORMAL, font);
    chooseProject->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Project"));
	chooseProject->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    AddControl(chooseProject);
    
	loadUI = new UIButton(Rect(2*buttonW, 0, buttonW, cellH));
    loadUI->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    loadUI->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    loadUI->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    loadUI->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f));
    loadUI->SetStateFont(UIControl::STATE_NORMAL, font);
    loadUI->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Load"));
	loadUI->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    AddControl(loadUI);
    loadUI->SetVisible(false);
    
    saveUI = new UIButton(Rect(buttonW*3, 0, buttonW, cellH));
    saveUI->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    saveUI->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    saveUI->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    saveUI->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f));
    saveUI->SetStateFont(UIControl::STATE_NORMAL, font);
    saveUI->SetStateText(UIControl::STATE_NORMAL, LocalizedString("Save"));
	saveUI->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    //TODO: add saveUI when uiviewer becomes editor
    //AddControl(saveUI);
    
    selectHoverModeButton = new UIButton(Rect(buttonW*4, 0, 2*buttonW, cellH));
    
    selectHoverModeButton->SetStateDrawType(UIControl::STATE_NORMAL, UIControlBackground::DRAW_FILL);
    selectHoverModeButton->GetStateBackground(UIControl::STATE_NORMAL)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    selectHoverModeButton->SetStateFont(UIControl::STATE_NORMAL, font);
    selectHoverModeButton->SetStateText(UIControl::STATE_NORMAL, LocalizedString("selection.mode.click"));
    
    selectHoverModeButton->SetStateDrawType(UIControl::STATE_PRESSED_INSIDE, UIControlBackground::DRAW_FILL);
    selectHoverModeButton->GetStateBackground(UIControl::STATE_PRESSED_INSIDE)->SetColor(Color(0.5f, 0.5f, 0.5f, 0.5f));
    
    selectHoverModeButton->SetStateDrawType(UIControl::STATE_SELECTED, UIControlBackground::DRAW_FILL);
    selectHoverModeButton->GetStateBackground(UIControl::STATE_SELECTED)->SetColor(Color(0.0f, 0.0f, 0.0f, 0.5f));
    selectHoverModeButton->SetStateFont(UIControl::STATE_SELECTED, font);
    selectHoverModeButton->SetStateText(UIControl::STATE_SELECTED, LocalizedString("selection.mode.hover"));
    
	selectHoverModeButton->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &MainScreen::OnButtonPressed));
    AddControl(selectHoverModeButton);
    selectHoverModeButton->SetVisible(false);
    
    for (int32 i = 0; i < InfoControl::INFO_TYPES_COUNT; ++i) 
    {
        keyTexts[i] = new UIStaticText(Rect(screenSize.x - infoAreaWidth, cellH*(2*i+1), infoAreaWidth, cellH));
        keyTexts[i]->SetFont(font);
        keyTexts[i]->SetText(keyNames[i]);
        AddControl(keyTexts[i]);
        
        valueTexts[i] = new UIStaticText(Rect(screenSize.x - infoAreaWidth, cellH*(2*i+2), infoAreaWidth, cellH));
        valueTexts[i]->SetFont(font);
        AddControl(valueTexts[i]);
    }
    
    additionalInfoList = new UIList(Rect(screenSize.x - infoAreaWidth, cellH*(2*InfoControl::INFO_TYPES_COUNT+2), infoAreaWidth, screenSize.y - cellH*(2*InfoControl::INFO_TYPES_COUNT+2) ), UIList::ORIENTATION_VERTICAL);
    additionalInfoList->SetDelegate(this);
    AddControl(additionalInfoList);
    
    fsDlg = new UIFileSystemDialog("~res:/Fonts/MyriadPro-Regular.otf");
    fsDlg->SetDelegate(this);
    Vector<String> filter;
    filter.push_back(".yaml");
    filter.push_back(".YAML");
    fsDlg->SetExtensionFilter(filter);
    fsDlg->SetTitle(LocalizedString("Dlg.Load"));
    fsDlg->SetCurrentDir(FileSystem::Instance()->SystemPathForFrameworkPath("~res:/")); 

    fsDlgProject = new UIFileSystemDialog("~res:/Fonts/MyriadPro-Regular.otf"); //default = GetCurrentWorkingDirectory 
    fsDlgProject->SetDelegate(this);
    fsDlgProject->SetOperationType(UIFileSystemDialog::OPERATION_CHOOSE_DIR);
    fsDlgProject->SetTitle(LocalizedString("Dlg.ChoosePrj"));
    
    KeyedArchive* archive = new KeyedArchive();
	if(archive->Load("~doc:/uiviewer.archive"))
    {
        if(archive->IsKeyExists("projectPath"))
        {
            projectPath = archive->GetString("projectPath");
            //TODO: different path formats on different OS
            OnLoadProject();
            fsDlgProject->SetCurrentDir(projectPath);
        }
    }
    SafeRelease(archive);

    
    SafeRelease(font);
}