From d5e2aa9389a3a9df72c33bd521260c74d6bb3a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 1 Mar 2009 13:58:05 +0000 Subject: [PATCH] Patch by Oliver Coursiere: Center the TV window on start. Fixes ticket #3041. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29363 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/tv/MainWin.cpp | 24 ++++++++++++++++++++++++ src/apps/tv/MainWin.h | 5 +++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/apps/tv/MainWin.cpp b/src/apps/tv/MainWin.cpp index 95cbba738a..6ae2d5eb0e 100644 --- a/src/apps/tv/MainWin.cpp +++ b/src/apps/tv/MainWin.cpp @@ -132,6 +132,8 @@ MainWin::MainWin(BRect frame_rect) SetChannelMenuMarker(); VideoFormatChange(fSourceWidth, fSourceHeight, fWidthScale, fHeightScale); + + CenterWindow(); } @@ -1175,3 +1177,25 @@ MainWin::MessageReceived(BMessage *msg) } } } + + +void +MainWin::CenterWindow() +{ + BScreen screen(this); + if (!screen.IsValid()) + return; + + BRect frame = screen.Frame(); + BRect windowFrame = Frame(); + + float left = floor((frame.Width() - windowFrame.Width()) / 2); + float top = floor((frame.Height() - windowFrame.Height()) / 2); + + if (left < 20) + left = 20; + if (top < 20) + top = 20; + + MoveTo(left, top); +} diff --git a/src/apps/tv/MainWin.h b/src/apps/tv/MainWin.h index c676b89418..d9ea486784 100644 --- a/src/apps/tv/MainWin.h +++ b/src/apps/tv/MainWin.h @@ -61,7 +61,7 @@ public: void SetInterfaceMenuMarker(); void SetChannelMenuMarker(); - + void VideoFormatChange(int width, int height, float width_scale, float height_scale); void UpdateWindowTitle(); @@ -75,7 +75,8 @@ public: void ToggleNoBorder(); void ToggleNoMenu(); void ToggleNoBorderNoMenu(); - + void CenterWindow(); + void ShowContextMenu(const BPoint &screen_point); BMenuBar * fMenuBar;