! * \brief Enable or disables the widget background. */
| 62 | * \brief Enable or disables the widget background. |
| 63 | */ |
| 64 | void BaseWidget::EnableBackground(bool enable) |
| 65 | { |
| 66 | if (m_backgroundEntity.IsValid() == enable) |
| 67 | return; |
| 68 | |
| 69 | if (enable) |
| 70 | { |
| 71 | m_backgroundSprite = Nz::Sprite::New(); |
| 72 | m_backgroundSprite->SetColor(m_backgroundColor); |
| 73 | m_backgroundSprite->SetMaterial(Nz::Material::New((m_backgroundColor.IsOpaque()) ? "Basic2D" : "Translucent2D")); |
| 74 | |
| 75 | m_backgroundEntity = CreateEntity(); |
| 76 | m_backgroundEntity->AddComponent<GraphicsComponent>().Attach(m_backgroundSprite, -1); |
| 77 | m_backgroundEntity->AddComponent<NodeComponent>().SetParent(this); |
| 78 | |
| 79 | BaseWidget::Layout(); // Only layout background |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | m_backgroundEntity->Kill(); |
| 84 | m_backgroundSprite.Reset(); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | void BaseWidget::GrabKeyboard() |
| 89 | { |