[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / music / dialogs / GUIDialogMusicOSD.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.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 "GUIDialogMusicOSD.h"
22 #include "guilib/GUIWindowManager.h"
23 #include "input/MouseStat.h"
24 #include "GUIUserMessages.h"
25 #include "settings/Settings.h"
26 #include "settings/GUISettings.h"
27 #include "addons/GUIWindowAddonBrowser.h"
28
29 #define CONTROL_VIS_BUTTON       500
30 #define CONTROL_LOCK_BUTTON      501
31
32 CGUIDialogMusicOSD::CGUIDialogMusicOSD(void)
33     : CGUIDialog(WINDOW_DIALOG_MUSIC_OSD, "MusicOSD.xml")
34 {
35   m_loadType = KEEP_IN_MEMORY;
36 }
37
38 CGUIDialogMusicOSD::~CGUIDialogMusicOSD(void)
39 {
40 }
41
42 bool CGUIDialogMusicOSD::OnMessage(CGUIMessage &message)
43 {
44   switch (message.GetMessage())
45   {
46   case GUI_MSG_CLICKED:
47     {
48       unsigned int iControl = message.GetSenderId();
49       if (iControl == CONTROL_VIS_BUTTON)
50       {
51         CStdString addonID;
52         if (CGUIWindowAddonBrowser::SelectAddonID(ADDON::ADDON_VIZ, addonID, true) == 1)
53         {
54           g_guiSettings.SetString("musicplayer.visualisation", addonID);
55           g_settings.Save();
56           g_windowManager.SendMessage(GUI_MSG_VISUALISATION_RELOAD, 0, 0);
57         }
58       }
59       else if (iControl == CONTROL_LOCK_BUTTON)
60       {
61         CGUIMessage msg(GUI_MSG_VISUALISATION_ACTION, 0, 0, ACTION_VIS_PRESET_LOCK);
62         g_windowManager.SendMessage(msg);
63       }
64       return true;
65     }
66     break;
67   }
68   return CGUIDialog::OnMessage(message);
69 }
70
71 bool CGUIDialogMusicOSD::OnAction(const CAction &action)
72 {
73   switch (action.GetID())
74   {
75   case ACTION_SHOW_OSD:
76     Close();
77     return true;
78
79   default:
80     break;
81   }
82
83   return CGUIDialog::OnAction(action);
84 }
85
86 void CGUIDialogMusicOSD::FrameMove()
87 {
88   if (m_autoClosing)
89   {
90     // check for movement of mouse or a submenu open
91     if (g_Mouse.IsActive() || g_windowManager.IsWindowActive(WINDOW_DIALOG_VIS_SETTINGS)
92                            || g_windowManager.IsWindowActive(WINDOW_DIALOG_VIS_PRESET_LIST))
93       SetAutoClose(100); // enough for 10fps
94   }
95   CGUIDialog::FrameMove();
96 }