Example #1
0
TextureTrianglesDialog::TextureTrianglesDialog()
    :   ExtendedDialog()
{
    workingPolygonGroup = NULL;
    previewSprite = NULL;

    Rect rect = GetDialogRect();
    draggableDialog->SetRect(rect);

    rect.x = rect.y = 0;
    
    Vector<String> comboboxItems;
    comboboxItems.push_back("0");
    comboboxItems.push_back("1");
    comboboxItems.push_back("2");
    comboboxItems.push_back("3");
    
    Rect comboRect = rect;
    comboRect.dy = ControlsFactory::BUTTON_HEIGHT;
    combobox = new ComboBox(comboRect, this, comboboxItems);
    draggableDialog->AddControl(combobox);
    
    Rect previewRect = rect;
    previewRect.y = ControlsFactory::BUTTON_HEIGHT;
    previewRect.dy -= ControlsFactory::BUTTON_HEIGHT * 2;
    texturePreview = new UIControl(previewRect);
    texturePreview->SetInputEnabled(false);
    draggableDialog->AddControl(texturePreview);
    
    float32 buttonX = (rect.dx - ControlsFactory::BUTTON_WIDTH) / 2;
    float32 buttonY = rect.dy - ControlsFactory::BUTTON_HEIGHT;
    btnCancel = ControlsFactory::CreateButton(Vector2(buttonX, buttonY), LocalizedString(L"dialog.close"));
    btnCancel->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &TextureTrianglesDialog::OnClose));
    draggableDialog->AddControl(btnCancel);
}
Example #2
0
void TextureTrianglesDialog::UpdateSize()
{
    ExtendedDialog::UpdateSize();
    
    Rect rect = GetDialogRect();
    rect.x = rect.y = 0;
    
    Rect previewRect = rect;
    previewRect.y = ControlsFactory::BUTTON_HEIGHT;
    previewRect.dy -= ControlsFactory::BUTTON_HEIGHT * 2;
    texturePreview->SetRect(previewRect);

    float32 buttonX = (rect.dx - ControlsFactory::BUTTON_WIDTH) / 2;
    float32 buttonY = rect.dy - ControlsFactory::BUTTON_HEIGHT;
    btnCancel->SetPosition(Vector2(buttonX, buttonY));
}
//*************  ColorPicker  *************
ColorPicker::ColorPicker(ColorPickerDelegate *newDelegate)
    :   ExtendedDialog()
    ,   delegate(newDelegate)
{
    //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);

    
    draggableDialog->SetRect(GetDialogRect());
    
    colorMapControl = new ColorMapControl(Rect(ControlsFactory::OFFSET, ControlsFactory::OFFSET, 
                                               ControlsFactory::COLOR_MAP_SIDE, ControlsFactory::COLOR_MAP_SIDE));
    colorMapControl->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &ColorPicker::OnMapColorChanged));
    draggableDialog->AddControl(colorMapControl);
    
    Rect alphaRect(colorMapControl->GetRect());
    alphaRect.y += alphaRect.dy + ControlsFactory::OFFSET;
    alphaRect.dy = ControlsFactory::BUTTON_HEIGHT;
    alphaValue = new UISlider(alphaRect);
    alphaValue->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &ColorPicker::OnAlphaChanged));
    alphaValue->SetMinMaxValue(0.f, 1.0f);
    alphaValue->SetValue(1.0f);
    alphaValue->SetMinSprite("~res:/Gfx/LandscapeEditor/Tools/polzunok", 1);
    alphaValue->SetMinDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL);
    alphaValue->SetMinLeftRightStretchCap(5);
    alphaValue->SetMaxSprite("~res:/Gfx/LandscapeEditor/Tools/polzunok", 0);
    alphaValue->SetMaxDrawType(UIControlBackground::DRAW_STRETCH_HORIZONTAL);
    alphaValue->SetMaxLeftRightStretchCap(5);
    alphaValue->SetThumbSprite("~res:/Gfx/LandscapeEditor/Tools/polzunokCenter", 0);
    draggableDialog->AddControl(alphaValue);

    Rect selectorRect(colorMapControl->GetRect());
    selectorRect.x += selectorRect.dx + ControlsFactory::OFFSET;
    selectorRect.dx = ControlsFactory::COLOR_SELECTOR_WIDTH;
    colorSelectorControl = new ColorSelectorControl(selectorRect);
    colorSelectorControl->AddEvent(UIControl::EVENT_VALUE_CHANGED, Message(this, &ColorPicker::OnSelectorColorChanged));
    draggableDialog->AddControl(colorSelectorControl);
    
    Rect colorPreviewRect;
    colorPreviewRect.x = selectorRect.x + selectorRect.dx + ControlsFactory::OFFSET;
    colorPreviewRect.y = ControlsFactory::OFFSET;
    colorPreviewRect.dx = ControlsFactory::COLOR_PREVIEW_SIDE;
    colorPreviewRect.dy = ControlsFactory::COLOR_PREVIEW_SIDE/2;
    colorPreviewCurrent = new UIControl(colorPreviewRect);
    colorPreviewCurrent->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
    draggableDialog->AddControl(colorPreviewCurrent);

    Rect prevRect = colorPreviewCurrent->GetRect();
    prevRect.y += prevRect.dy;
    colorPreviewPrev = new UIControl(Rect(prevRect));
    colorPreviewPrev->GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL);
    draggableDialog->AddControl(colorPreviewPrev);
    
    Rect colorListRect;
    colorListRect.x = prevRect.x;
    colorListRect.y = prevRect.y + prevRect.dy + ControlsFactory::OFFSET;
    colorListRect.dx = prevRect.dx;
    colorListRect.dy = 80;
    colorList = new PropertyList(colorListRect, this);
    ControlsFactory::CusomizeTransparentControl(colorList, 0.0f);
    colorList->AddIntProperty("colorpicker.r", PropertyList::PROPERTY_IS_EDITABLE);
    colorList->AddIntProperty("colorpicker.g", PropertyList::PROPERTY_IS_EDITABLE);
    colorList->AddIntProperty("colorpicker.b", PropertyList::PROPERTY_IS_EDITABLE);
    colorList->AddIntProperty("colorpicker.a", PropertyList::PROPERTY_IS_EDITABLE);
    draggableDialog->AddControl(colorList);
    
    Rect rect = GetDialogRect();
    float32 buttonX = rect.dx /2 - ControlsFactory::BUTTON_WIDTH;
    float32 buttonY = rect.dy - ControlsFactory::BUTTON_HEIGHT;
    UIButton *btnCancel = ControlsFactory::CreateButton(Vector2(buttonX, buttonY), LocalizedString(L"dialog.cancel"));
    btnCancel->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ColorPicker::OnCancel));
    draggableDialog->AddControl(btnCancel);
    SafeRelease(btnCancel);
    
    buttonX += ControlsFactory::BUTTON_WIDTH;
    UIButton *btnOk = ControlsFactory::CreateButton(Vector2(buttonX, buttonY), LocalizedString(L"dialog.ok"));
    btnOk->AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &ColorPicker::OnOk));
    draggableDialog->AddControl(btnOk);
    SafeRelease(btnOk);
    
    SetColor(Color(1.0f, 1.0f, 1.0f, 1.0f));
    
    Texture::SetDefaultFileFormat((ImageFileFormat)EditorSettings::Instance()->GetTextureViewFileFormat());
}