summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2020-09-16 16:42:04 -0400
committerGitHub <noreply@github.com>2020-09-16 16:42:04 -0400
commit6ada03fca2e5f8a55992d5c9fd35c91e2825fff7 (patch)
tree2934cc50e9deed32cf56aa6d4c6ee408b49a6e07 /Source/Core
parent097a4f4ecf8db18737ee64d4721fd46d98695302 (diff)
parent161f99b864795bf714941e981ad4032c6f50855e (diff)
Merge pull request #9075 from JosJuice/android-osd-left-margin
Android: Move OSD out of the way when menu is open
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/OnScreenDisplay.cpp20
-rw-r--r--Source/Core/VideoCommon/OnScreenDisplay.h3
2 files changed, 21 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/OnScreenDisplay.cpp b/Source/Core/VideoCommon/OnScreenDisplay.cpp
index e08bfb0970..0558ee2619 100644
--- a/Source/Core/VideoCommon/OnScreenDisplay.cpp
+++ b/Source/Core/VideoCommon/OnScreenDisplay.cpp
@@ -5,6 +5,7 @@
#include "VideoCommon/OnScreenDisplay.h"
#include <algorithm>
+#include <atomic>
#include <map>
#include <mutex>
#include <string>
@@ -24,6 +25,9 @@ constexpr float LEFT_MARGIN = 10.0f; // Pixels to the left of OSD messages.
constexpr float TOP_MARGIN = 10.0f; // Pixels above the first OSD message.
constexpr float WINDOW_PADDING = 4.0f; // Pixels between subsequent OSD messages.
+static std::atomic<int> s_obscured_pixels_left = 0;
+static std::atomic<int> s_obscured_pixels_top = 0;
+
struct Message
{
Message() = default;
@@ -97,8 +101,9 @@ void DrawMessages()
{
const bool draw_messages = Config::Get(Config::MAIN_OSD_MESSAGES);
const u32 now = Common::Timer::GetTimeMs();
- const float current_x = LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x;
- float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y;
+ const float current_x =
+ LEFT_MARGIN * ImGui::GetIO().DisplayFramebufferScale.x + s_obscured_pixels_left;
+ float current_y = TOP_MARGIN * ImGui::GetIO().DisplayFramebufferScale.y + s_obscured_pixels_top;
int index = 0;
std::lock_guard lock{s_messages_mutex};
@@ -128,4 +133,15 @@ void ClearMessages()
std::lock_guard lock{s_messages_mutex};
s_messages.clear();
}
+
+void SetObscuredPixelsLeft(int width)
+{
+ s_obscured_pixels_left = width;
+}
+
+void SetObscuredPixelsTop(int height)
+{
+ s_obscured_pixels_top = height;
+}
+
} // namespace OSD
diff --git a/Source/Core/VideoCommon/OnScreenDisplay.h b/Source/Core/VideoCommon/OnScreenDisplay.h
index 73d6bcf753..fe31c99fe6 100644
--- a/Source/Core/VideoCommon/OnScreenDisplay.h
+++ b/Source/Core/VideoCommon/OnScreenDisplay.h
@@ -44,4 +44,7 @@ void AddTypedMessage(MessageType type, std::string message, u32 ms = Duration::S
// Draw the current messages on the screen. Only call once per frame.
void DrawMessages();
void ClearMessages();
+
+void SetObscuredPixelsLeft(int width);
+void SetObscuredPixelsTop(int height);
} // namespace OSD