void TestCase::AddReturnButton(UIScreen* pUIScreen) { UIButton* pButton = new UIButton(pUIScreen, IMath::VEC2_ZERO, "RETURN"); Vector2 pos(0.0f, ScreenUtil::GetInstance().GetScreenHeight() - pButton->GetSize().y); pButton->SetPosition(pos); pButton->ConnectEvent(UMI_CLICKED, this, (MSG_CALLBACK)&TestCase::OnBtnReturnClicked); }
void HelloGUI::CreateDraggableFish() { ResourceCache* cache = GetSubsystem<ResourceCache>(); Graphics* graphics = GetSubsystem<Graphics>(); // Create a draggable Fish button Button* draggableFish = new Button(context_); draggableFish->SetTexture(cache->GetResource<Texture2D>("Textures/UrhoDecal.dds")); // Set texture draggableFish->SetBlendMode(BLEND_ADD); draggableFish->SetSize(128, 128); draggableFish->SetPosition((graphics->GetWidth() - draggableFish->GetWidth()) / 2, 200); draggableFish->SetName("Fish"); uiRoot_->AddChild(draggableFish); // Add a tooltip to Fish button // ToolTip* toolTip = new ToolTip(context_); // draggableFish->AddChild(toolTip); // toolTip->SetPosition(IntVector2(draggableFish->GetWidth() + 5, draggableFish->GetWidth() / 2)); // slightly offset from close button // BorderImage* textHolder = new BorderImage(context_); // toolTip->AddChild(textHolder); // textHolder->SetStyle("ToolTipBorderImage"); // //Text* toolTipText = new Text(context_); // textHolder->AddChild(toolTipText); // toolTipText->SetStyle("ToolTipText"); // toolTipText->SetText("Please drag me!"); ////////////////////////////////////////////////////////////////////////// SpriteSheet2D* playerSheet = cache->GetResource<SpriteSheet2D>("Urho2D/height_864/Razor.plist", false); UIButton::SetDefaultSkin(playerSheet, "a26.png", "a20.png", "a15.png", "a12.png"); UIButton::RegisterObject(context_); // UIButton* testButton = new UIButton(context_); testButton->SetPosition(100, 100); uiRoot_->AddChild(testButton); testButton->SetText("test"); testButton->SetToolTip("Click me......................."); // Subscribe draggableFish to Drag Events (in order to make it draggable) // See "Event list" in documentation's Main Page for reference on available Events and their eventData SubscribeToEvent(draggableFish, E_DRAGBEGIN, HANDLER(HelloGUI, HandleDragBegin)); SubscribeToEvent(draggableFish, E_DRAGMOVE, HANDLER(HelloGUI, HandleDragMove)); SubscribeToEvent(draggableFish, E_DRAGEND, HANDLER(HelloGUI, HandleDragEnd)); }
bool PorkerTestCase::Initialize(UIScreen* pUIScreen) { m_pBackGroundImagePiece = IResourceMgr::GetInstance().FindImagePiece("backgorund"); if(!m_pBackGroundImagePiece) return false; m_pTile = new Tile(m_pBackGroundImagePiece); m_pRootNode = IResourceMgr::GetInstance().CreateRootNode(); m_pRootNode->AttachObject(m_pTile); UIButton* pButtonNormal = new UIButton(pUIScreen); pButtonNormal->SetText("Normal"); pButtonNormal->ConnectEvent(UMI_CLICKED, this, (MSG_CALLBACK)&PorkerTestCase::OnNormalButtonClicked); UIButton* pButtonGray = new UIButton(pUIScreen); pButtonGray->SetText("Gray"); pButtonGray->SetPosition(0.0f, 60.0f); pButtonGray->ConnectEvent(UMI_CLICKED, this, (MSG_CALLBACK)& PorkerTestCase::OnGrayButtonClicked); return true; }