[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / music / windows / GUIWindowVisualisation.cpp
blobfa17c60d623159bbbcf41c55c5a8befc57dbbef8
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "GUIWindowVisualisation.h"
11 #include "GUIInfoManager.h"
12 #include "GUIUserMessages.h"
13 #include "ServiceBroker.h"
14 #include "application/ApplicationComponents.h"
15 #include "application/ApplicationPlayer.h"
16 #include "guilib/GUIComponent.h"
17 #include "guilib/GUIDialog.h"
18 #include "guilib/GUIWindowManager.h"
19 #include "input/actions/Action.h"
20 #include "input/actions/ActionIDs.h"
21 #include "input/mouse/MouseEvent.h"
22 #include "settings/AdvancedSettings.h"
23 #include "settings/Settings.h"
24 #include "settings/SettingsComponent.h"
26 using namespace KODI;
27 using namespace MUSIC_INFO;
29 #define START_FADE_LENGTH 2.0f // 2 seconds on startup
31 #define CONTROL_VIS 2
33 CGUIWindowVisualisation::CGUIWindowVisualisation(void)
34 : CGUIWindow(WINDOW_VISUALISATION, "MusicVisualisation.xml")
36 m_bShowPreset = false;
37 m_loadType = KEEP_IN_MEMORY;
40 bool CGUIWindowVisualisation::OnAction(const CAction &action)
42 bool passToVis = false;
43 switch (action.GetID())
45 case ACTION_VIS_PRESET_NEXT:
46 case ACTION_VIS_PRESET_PREV:
47 case ACTION_VIS_PRESET_RANDOM:
48 case ACTION_VIS_RATE_PRESET_PLUS:
49 case ACTION_VIS_RATE_PRESET_MINUS:
50 passToVis = true;
51 break;
53 case ACTION_SHOW_INFO:
55 m_initTimer.Stop();
56 CServiceBroker::GetSettingsComponent()->GetSettings()->SetBool(CSettings::SETTING_MYMUSIC_SONGTHUMBINVIS,
57 CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().ToggleShowInfo());
58 return true;
60 break;
62 case ACTION_SHOW_OSD:
63 CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_DIALOG_MUSIC_OSD);
64 return true;
66 case ACTION_SHOW_GUI:
67 // save the settings
68 CServiceBroker::GetSettingsComponent()->GetSettings()->Save();
69 CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow();
70 return true;
71 break;
73 case ACTION_VIS_PRESET_LOCK:
74 { // show the locked icon + fall through so that the vis handles the locking
75 if (!m_bShowPreset)
77 m_lockedTimer.StartZero();
79 passToVis = true;
81 break;
82 case ACTION_VIS_PRESET_SHOW:
84 if (!m_lockedTimer.IsRunning() || m_bShowPreset)
85 m_bShowPreset = !m_bShowPreset;
86 return true;
88 break;
90 case ACTION_DECREASE_RATING:
91 case ACTION_INCREASE_RATING:
93 // actual action is taken care of in CApplication::OnAction()
94 m_initTimer.StartZero();
95 CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().SetShowInfo(true);
97 break;
98 //! @todo These should be mapped to its own function - at the moment it's overriding
99 //! the global action of fastforward/rewind and OSD.
100 /* case KEY_BUTTON_Y:
101 g_application.m_CdgParser.Pause();
102 return true;
103 break;
105 case ACTION_ANALOG_FORWARD:
106 // calculate the speed based on the amount the button is held down
107 if (action.GetAmount())
109 float AVDelay = g_application.m_CdgParser.GetAVDelay();
110 g_application.m_CdgParser.SetAVDelay(AVDelay - action.GetAmount() / 4.0f);
111 return true;
113 break;*/
116 if (passToVis)
118 CGUIControl *control = GetControl(CONTROL_VIS);
119 if (control)
120 return control->OnAction(action);
123 return CGUIWindow::OnAction(action);
126 bool CGUIWindowVisualisation::OnMessage(CGUIMessage& message)
128 switch ( message.GetMessage() )
130 case GUI_MSG_GET_VISUALISATION:
131 case GUI_MSG_VISUALISATION_RELOAD:
132 case GUI_MSG_PLAYBACK_STARTED:
134 CGUIControl *control = GetControl(CONTROL_VIS);
135 if (control)
136 return control->OnMessage(message);
138 break;
139 case GUI_MSG_VISUALISATION_ACTION:
141 CAction action(message.GetParam1());
142 return OnAction(action);
144 case GUI_MSG_WINDOW_DEINIT:
146 if (IsActive()) // save any changed settings from the OSD
147 CServiceBroker::GetSettingsComponent()->GetSettings()->Save();
149 // close all active modal dialogs
150 CServiceBroker::GetGUI()->GetWindowManager().CloseInternalModalDialogs(true);
152 break;
153 case GUI_MSG_WINDOW_INIT:
155 // check whether we've come back here from a window during which time we've actually
156 // stopped playing music
157 const auto& components = CServiceBroker::GetAppComponents();
158 const auto appPlayer = components.GetComponent<CApplicationPlayer>();
159 if (message.GetParam1() == WINDOW_INVALID && !appPlayer->IsPlayingAudio())
160 { // why are we here if nothing is playing???
161 CServiceBroker::GetGUI()->GetWindowManager().PreviousWindow();
162 return true;
165 // hide or show the preset button(s)
166 CGUIInfoManager& infoMgr = CServiceBroker::GetGUI()->GetInfoManager();
167 infoMgr.GetInfoProviders().GetPlayerInfoProvider().SetShowInfo(true); // always show the info initially.
168 CGUIWindow::OnMessage(message);
169 if (infoMgr.GetCurrentSongTag())
170 m_tag = *infoMgr.GetCurrentSongTag();
172 if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MYMUSIC_SONGTHUMBINVIS))
173 { // always on
174 m_initTimer.Stop();
176 else
178 // start display init timer (fade out after 3 secs...)
179 m_initTimer.StartZero();
181 return true;
184 return CGUIWindow::OnMessage(message);
187 EVENT_RESULT CGUIWindowVisualisation::OnMouseEvent(const CPoint& point,
188 const MOUSE::CMouseEvent& event)
190 if (event.m_id == ACTION_MOUSE_RIGHT_CLICK)
191 { // no control found to absorb this click - go back to GUI
192 OnAction(CAction(ACTION_SHOW_GUI));
193 return EVENT_RESULT_HANDLED;
195 if (event.m_id == ACTION_GESTURE_NOTIFY)
196 return EVENT_RESULT_UNHANDLED;
197 if (event.m_id != ACTION_MOUSE_MOVE || event.m_offsetX || event.m_offsetY)
198 { // some other mouse action has occurred - bring up the OSD
199 CGUIDialog *pOSD = CServiceBroker::GetGUI()->GetWindowManager().GetDialog(WINDOW_DIALOG_MUSIC_OSD);
200 if (pOSD)
202 pOSD->SetAutoClose(3000);
203 pOSD->Open();
205 return EVENT_RESULT_HANDLED;
207 return EVENT_RESULT_UNHANDLED;
210 void CGUIWindowVisualisation::FrameMove()
212 CGUIInfoManager& infoMgr = CServiceBroker::GetGUI()->GetInfoManager();
214 // check for a tag change
215 const CMusicInfoTag* tag = infoMgr.GetCurrentSongTag();
216 if (tag && *tag != m_tag)
217 { // need to fade in then out again
218 m_tag = *tag;
219 // fade in
220 m_initTimer.StartZero();
221 infoMgr.GetInfoProviders().GetPlayerInfoProvider().SetShowInfo(true);
223 if (m_initTimer.IsRunning() && m_initTimer.GetElapsedSeconds() > (float)CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_songInfoDuration)
225 m_initTimer.Stop();
226 if (!CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MYMUSIC_SONGTHUMBINVIS))
227 { // reached end of fade in, fade out again
228 infoMgr.GetInfoProviders().GetPlayerInfoProvider().SetShowInfo(false);
231 // show or hide the locked texture
232 if (m_lockedTimer.IsRunning() && m_lockedTimer.GetElapsedSeconds() > START_FADE_LENGTH)
234 m_lockedTimer.Stop();
236 CGUIWindow::FrameMove();