From d0f8750de9dd426493a75f23704c236f9aadc3bc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 7 May 2013 09:15:15 +0200 Subject: [PATCH] Renderer, ...: use PixelRect::GetCenter() --- src/Gauge/ThermalAssistantRenderer.cpp | 3 +-- src/InfoBoxes/Content/Weather.cpp | 3 +-- src/MapWindow/GlueMapWindowDisplayMode.cpp | 4 +--- src/Renderer/GlassRenderer.cpp | 10 +++++----- src/Renderer/HorizonRenderer.cpp | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Gauge/ThermalAssistantRenderer.cpp b/src/Gauge/ThermalAssistantRenderer.cpp index fa2674ce4..6c4b0e77d 100644 --- a/src/Gauge/ThermalAssistantRenderer.cpp +++ b/src/Gauge/ThermalAssistantRenderer.cpp @@ -201,8 +201,7 @@ void ThermalAssistantRenderer::UpdateLayout(const PixelRect &rc) { radius = std::min(rc.right - rc.left, rc.bottom - rc.top) / 2 - padding; - mid.x = (rc.left + rc.right) / 2; - mid.y = (rc.top + rc.bottom) / 2; + mid = rc.GetCenter(); } void diff --git a/src/InfoBoxes/Content/Weather.cpp b/src/InfoBoxes/Content/Weather.cpp index 9d270fdaa..50a61eddb 100644 --- a/src/InfoBoxes/Content/Weather.cpp +++ b/src/InfoBoxes/Content/Weather.cpp @@ -213,8 +213,7 @@ InfoBoxContentWindArrow::OnCustomPaint(Canvas &canvas, const PixelRect &rc) { const auto &info = CommonInterface::Calculated(); - const RasterPoint pt((rc.left + rc.right) / 2, - (rc.top + rc.bottom) / 2); + const RasterPoint pt = rc.GetCenter(); UPixelScalar padding = Layout::FastScale(10); UPixelScalar size = std::min(rc.right - rc.left, rc.bottom - rc.top); diff --git a/src/MapWindow/GlueMapWindowDisplayMode.cpp b/src/MapWindow/GlueMapWindowDisplayMode.cpp index e6983419d..513ab04f4 100644 --- a/src/MapWindow/GlueMapWindowDisplayMode.cpp +++ b/src/MapWindow/GlueMapWindowDisplayMode.cpp @@ -273,9 +273,7 @@ GlueMapWindow::UpdateProjection() const bool circling = CommonInterface::GetUIState().display_mode == DisplayMode::CIRCLING; - RasterPoint center; - center.x = (rc.left + rc.right) / 2; - center.y = (rc.top + rc.bottom) / 2; + const RasterPoint center = rc.GetCenter(); if (circling || !IsNearSelf()) visible_projection.SetScreenOrigin(center.x, center.y); diff --git a/src/Renderer/GlassRenderer.cpp b/src/Renderer/GlassRenderer.cpp index 8fcd69168..a30f537e4 100644 --- a/src/Renderer/GlassRenderer.cpp +++ b/src/Renderer/GlassRenderer.cpp @@ -59,14 +59,14 @@ DrawGlassBackground(Canvas &canvas, const PixelRect &rc, Color color) const Color shadow = Shadow(color); - const int x = (rc.left + rc.right) / 2, y = (rc.top + rc.bottom) / 2; + const RasterPoint center = rc.GetCenter(); const int size = std::min(rc.right - rc.left, rc.bottom - rc.top) / 4; const RasterPoint vertices[] = { - { x + 1024, y - 1024 }, - { x + 1024 + size, y - 1024 + size }, - { x - 1024, y + 1024 }, - { x - 1024 + size, y + 1024 + size }, + { center.x + 1024, center.y - 1024 }, + { center.x + 1024 + size, center.y - 1024 + size }, + { center.x - 1024, center.y + 1024 }, + { center.x - 1024 + size, center.y + 1024 + size }, }; glVertexPointer(2, GL_VALUE, 0, vertices); diff --git a/src/Renderer/HorizonRenderer.cpp b/src/Renderer/HorizonRenderer.cpp index b7a94dd02..cb464f5e8 100644 --- a/src/Renderer/HorizonRenderer.cpp +++ b/src/Renderer/HorizonRenderer.cpp @@ -47,9 +47,8 @@ HorizonRenderer::Draw(Canvas &canvas, const PixelRect &rc, is the case or not. */ - RasterPoint center; - center.y = (rc.top + rc.bottom) / 2; - center.x = (rc.left + rc.right) / 2; + const RasterPoint center = rc.GetCenter(); + const int radius = std::min(rc.right - rc.left, rc.bottom - rc.top) / 2 - Layout::Scale(1); -- 2.11.4.GIT