UIElement* EPScene2D::GetMainScreen() { if (!window_) { EditorData* editorData_ = GetSubsystem<EditorData>(); window_ = new Window(context_); window_->SetFixedSize(200, 200); window_->SetStyleAuto(editorData_->GetDefaultStyle()); Text* hello = window_->CreateChild<Text>(); hello->SetText("hello 2d view ... "); hello->SetStyleAuto(editorData_->GetDefaultStyle()); } return window_; }
void HelloGUI::InitWindow() { // Create the Window and add it to the UI's root node window_ = new Window(context_); uiRoot_->AddChild(window_); // Set Window size and layout settings window_->SetMinSize(384, 192); window_->SetLayout(LM_VERTICAL, 6, IntRect(6, 6, 6, 6)); window_->SetAlignment(HA_CENTER, VA_CENTER); window_->SetName("Window"); // Create Window 'titlebar' container UIElement* titleBar = new UIElement(context_); titleBar->SetMinSize(0, 24); titleBar->SetVerticalAlignment(VA_TOP); titleBar->SetLayoutMode(LM_HORIZONTAL); // Create the Window title Text Text* windowTitle = new Text(context_); windowTitle->SetName("WindowTitle"); windowTitle->SetText("Hello GUI!"); // Create the Window's close button Button* buttonClose = new Button(context_); buttonClose->SetName("CloseButton"); // Add the controls to the title bar titleBar->AddChild(windowTitle); titleBar->AddChild(buttonClose); // Add the title bar to the Window window_->AddChild(titleBar); // Apply styles window_->SetStyleAuto(); windowTitle->SetStyleAuto(); buttonClose->SetStyle("CloseButton"); // Subscribe to buttonClose release (following a 'press') events SubscribeToEvent(buttonClose, E_RELEASED, HANDLER(HelloGUI, HandleClosePressed)); // Subscribe also to all UI mouse clicks just to see where we have clicked SubscribeToEvent(E_UIMOUSECLICK, HANDLER(HelloGUI, HandleControlClicked)); }