Reduce use of display.h (dp_xres, dp_yres) now that uicontext has bounds

This commit is contained in:
Henrik Rydgard committed 2014-02-10 12:44:36 +01:00
1 parent 8b6b491820
commit 4d00a9b4bc
10 files changed
+95 -69

No files matched your search

+3 -4
View File
@@ -2,13 +2,12 @@
#include "UI/ui_atlas.h"
#include "base/colorutil.h"
#include "base/display.h"
#include "base/timeutil.h"
#include "gfx_es2/draw_buffer.h"
OnScreenMessages osm;
void OnScreenMessages::Draw(DrawBuffer &draw) {
void OnScreenMessages::Draw(DrawBuffer &draw, const Bounds &bounds) {
// First, clean out old messages.
std::lock_guard<std::recursive_mutex> guard(mutex_);
@@ -34,9 +33,9 @@ restart:
// Messages that are wider than the screen are left-aligned instead of centered.
float tw, th;
draw.MeasureText(UBUNTU24, iter->text.c_str(), &tw, &th);
float x = dp_xres / 2;
float x = bounds.centerX();
int align = ALIGN_TOP | ALIGN_HCENTER;
if (tw > dp_xres) {
if (tw > bounds.w) {
align = ALIGN_TOP | ALIGN_LEFT;
x = 2;
}