[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / settings / windows / GUIWindowTestPattern.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "GUIWindowTestPattern.h"
22 #include "settings/DisplaySettings.h"
23 #include "guilib/GUIWindowManager.h"
24 #include "guilib/Key.h"
25 #include "guilib/WindowIDs.h"
26
27 CGUIWindowTestPattern::CGUIWindowTestPattern(void)
28     : CGUIWindow(WINDOW_TEST_PATTERN, "")
29 {
30   m_pattern = 0;
31   m_bounceX = 0;
32   m_bounceY = 0;
33   m_bounceDirectionX = 0;
34   m_bounceDirectionY = 0;
35   m_blinkFrame = 0;
36   m_needsScaling = false;
37 }
38
39 CGUIWindowTestPattern::~CGUIWindowTestPattern(void)
40 {}
41
42
43 bool CGUIWindowTestPattern::OnAction(const CAction &action)
44 {
45   switch (action.GetID())
46   {
47   case ACTION_MOVE_UP:
48   case ACTION_MOVE_LEFT:
49     m_pattern = m_pattern > 0 ? m_pattern - 1 : TEST_PATTERNS_COUNT - 1;
50     SetInvalid();
51     return true;
52
53   case ACTION_MOVE_DOWN:
54   case ACTION_MOVE_RIGHT:
55     m_pattern = (m_pattern + 1) % TEST_PATTERNS_COUNT;
56     SetInvalid();
57     return true;
58   }
59   return CGUIWindow::OnAction(action); // base class to handle basic movement etc.
60 }
61
62 bool CGUIWindowTestPattern::OnMessage(CGUIMessage& message)
63 {
64   switch (message.GetMessage())
65   {
66   case GUI_MSG_WINDOW_INIT:
67     m_pattern = 0;
68     m_bounceDirectionX = 1;
69     m_bounceDirectionY = 1;
70     m_bounceX = 0;
71     m_bounceY = 0;
72     m_blinkFrame = 0;
73     break;
74
75   }
76   return CGUIWindow::OnMessage(message);
77 }
78
79 void CGUIWindowTestPattern::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
80 {
81   if (m_pattern == 0 || m_pattern == 4)
82     MarkDirtyRegion();
83   CGUIWindow::Process(currentTime, dirtyregions);
84   m_renderRegion.SetRect(0, 0, (float)g_graphicsContext.GetWidth(), (float)g_graphicsContext.GetHeight());
85 }
86
87 void CGUIWindowTestPattern::Render()
88 {
89   BeginRender();
90   const RESOLUTION_INFO info = g_graphicsContext.GetResInfo();
91
92   int top    = info.Overscan.top;
93   int bottom = info.Overscan.bottom;
94   int left   = info.Overscan.left;
95   int right  = info.Overscan.right;
96
97   switch (m_pattern)
98   {
99     case 0:
100       DrawContrastBrightnessPattern(top, left, bottom, right);
101       break;
102
103     case 1:
104       DrawVerticalLines(top, left, bottom, right);
105       break;
106
107     case 2:
108       DrawHorizontalLines(top, left, bottom, right);
109       break;
110
111     case 3:
112       DrawCheckers(top, left, bottom, right);
113       break;
114
115     case 4:
116       DrawBouncingRectangle(top, left, bottom, right);
117       break;
118   }
119
120   EndRender();
121
122   CGUIWindow::Render();
123 }
124