https://github.com/libsdl-org/Maelstrom/commit/6de8ddb8cb2fdfd090a22400df7dab4884437c01
From 6de8ddb8cb2fdfd090a22400df7dab4884437c01 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 23 Nov 2012 01:38:57 -0800
Subject: [PATCH] Added always on top dialogs
---
screenlib/UIManager.cpp | 12 +++++++++---
screenlib/UIPanel.cpp | 2 ++
screenlib/UIPanel.h | 13 +++++++++++++
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/screenlib/UIManager.cpp b/screenlib/UIManager.cpp
index 203ca06e..17348929 100644
--- a/screenlib/UIManager.cpp
+++ b/screenlib/UIManager.cpp
@@ -203,9 +203,15 @@ UIManager::ShowPanel(UIPanel *panel)
}
// Make sure that fullscreen panels go behind dialogs
- if (panel->IsFullscreen()) {
- m_visible.insert(panel, 0);
- } else {
+ bool added = false;
+ for (unsigned int i = 0; i < m_visible.length(); ++i) {
+ if (panel->GetPriority() < m_visible[i]->GetPriority()) {
+ m_visible.insert(panel, i);
+ added = true;
+ break;
+ }
+ }
+ if (!added) {
m_visible.add(panel);
}
diff --git a/screenlib/UIPanel.cpp b/screenlib/UIPanel.cpp
index cf840069..8a255662 100644
--- a/screenlib/UIPanel.cpp
+++ b/screenlib/UIPanel.cpp
@@ -34,6 +34,7 @@ UIPanel::UIPanel(UIManager *ui, const char *name) :
{
m_shown = false;
m_fullscreen = true;
+ m_alwaysOnTop = false;
m_cursorVisible = true;
m_enterSound = 0;
m_leaveSound = 0;
@@ -58,6 +59,7 @@ UIPanel::Load(rapidxml::xml_node<> *node, const UITemplates *templates)
}
LoadBool(node, "fullscreen", m_fullscreen);
+ LoadBool(node, "alwaysOnTop", m_alwaysOnTop);
LoadBool(node, "cursor", m_cursorVisible);
LoadNumber(node, "enterSound", m_enterSound);
LoadNumber(node, "leaveSound", m_leaveSound);
diff --git a/screenlib/UIPanel.h b/screenlib/UIPanel.h
index 5c364376..6647fd94 100644
--- a/screenlib/UIPanel.h
+++ b/screenlib/UIPanel.h
@@ -79,9 +79,21 @@ DECLARE_TYPESAFE_CLASS(UIBaseElement)
bool IsFullscreen() const {
return m_fullscreen;
}
+ bool AlwaysOnTop() const {
+ return m_alwaysOnTop;
+ }
bool IsCursorVisible() const {
return m_cursorVisible;
}
+ int GetPriority() {
+ if (IsFullscreen()) {
+ return 1;
+ }
+ if (!AlwaysOnTop()) {
+ return 2;
+ }
+ return 3;
+ }
override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
override bool FinishLoading();
@@ -102,6 +114,7 @@ DECLARE_TYPESAFE_CLASS(UIBaseElement)
protected:
bool m_fullscreen;
+ bool m_alwaysOnTop;
bool m_cursorVisible;
int m_enterSound;
int m_leaveSound;