From b95cffc1c00027f9275d395fad8d9caa78d5f640 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 23 Oct 2011 01:32:46 -0400
Subject: [PATCH] Added the concept of fullscreen panels which end draw/event
loops
---
screenlib/UIManager.cpp | 15 +++++++++++++--
screenlib/UIPanel.cpp | 8 ++++++++
screenlib/UIPanel.h | 4 ++++
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/screenlib/UIManager.cpp b/screenlib/UIManager.cpp
index 41dabe55..f831e373 100644
--- a/screenlib/UIManager.cpp
+++ b/screenlib/UIManager.cpp
@@ -86,7 +86,13 @@ void
UIManager::Draw()
{
for (unsigned i = 0; i < m_visible.length(); ++i) {
- m_visible[i]->Draw();
+ UIPanel *panel = m_visible[i];
+
+ panel->Draw();
+
+ if (panel->IsFullscreen()) {
+ break;
+ }
}
}
@@ -94,9 +100,14 @@ bool
UIManager::HandleEvent(const SDL_Event &event)
{
for (unsigned i = m_visible.length(); i--; ) {
- if (m_visible[i]->HandleEvent(event)) {
+ UIPanel *panel = m_visible[i];
+
+ if (panel->HandleEvent(event)) {
return true;
}
+ if (panel->IsFullscreen()) {
+ break;
+ }
}
return false;
}
diff --git a/screenlib/UIPanel.cpp b/screenlib/UIPanel.cpp
index ea69a07e..7d534776 100644
--- a/screenlib/UIPanel.cpp
+++ b/screenlib/UIPanel.cpp
@@ -38,6 +38,7 @@ UIPanel::UIPanel(UIManager *ui, const char *name) : UIArea()
m_rect.w = m_screen->Width();
m_rect.h = m_screen->Height();
m_shown = false;
+ m_fullscreen = true;
m_ui->AddPanel(this);
}
@@ -96,6 +97,13 @@ UIPanel::Load(const char *file)
rapidxml::xml_node<> *node = doc.first_node();
rapidxml::xml_node<> *child;
rapidxml::xml_attribute<> *attr;
+ attr = node->first_attribute("fullscreen", 0, false);
+ if (attr) {
+ const char *value = attr->value();
+ if (*value == '0' || *value == 'f' || *value == 'F') {
+ m_fullscreen = false;
+ }
+ }
if (strcmp(node->name(), "UIPanel") != 0) {
SetError("Parse error: UIPanel root element expected");
delete[] buffer;
diff --git a/screenlib/UIPanel.h b/screenlib/UIPanel.h
index 54056b85..3506494b 100644
--- a/screenlib/UIPanel.h
+++ b/screenlib/UIPanel.h
@@ -47,6 +47,9 @@ class UIPanel : public UIArea
const char *GetName() const {
return m_name;
}
+ bool IsFullscreen() const {
+ return m_fullscreen;
+ }
bool Load(const char *file);
@@ -67,6 +70,7 @@ class UIPanel : public UIArea
UIManager *m_ui;
FrameBuf *m_screen;
char *m_name;
+ bool m_fullscreen;
array<UIElement *> m_elements;
bool LoadElements(rapidxml::xml_node<> *node);