| 1 |
/* |
| 2 |
* Copyright (C) 2017-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "dialogs/GUIDialogSlider.h" |
| 12 |
#include "dialogs/IGUIVolumeBarCallback.h" |
| 13 |
#include "guilib/ISliderCallback.h" |
| 14 |
#include "interfaces/IAnnouncer.h" |
| 15 |
|
| 16 |
#include <set> |
| 17 |
|
| 18 |
namespace KODI |
| 19 |
{ |
| 20 |
|
| 21 |
namespace GAME |
| 22 |
{ |
| 23 |
/*! |
| 24 |
* \ingroup games |
| 25 |
*/ |
| 26 |
class CDialogGameVolume : public CGUIDialogSlider, // GUI interface |
| 27 |
public ISliderCallback, // GUI callback |
| 28 |
public IGUIVolumeBarCallback, // Volume bar dialog callback |
| 29 |
public ANNOUNCEMENT::IAnnouncer // Application callback |
| 30 |
{ |
| 31 |
public: |
| 32 |
CDialogGameVolume(); |
| 33 |
~CDialogGameVolume() override = default; |
| 34 |
|
| 35 |
// implementation of CGUIControl via CGUIDialogSlider |
| 36 |
bool OnMessage(CGUIMessage& message) override; |
| 37 |
|
| 38 |
// implementation of CGUIWindow via CGUIDialogSlider |
| 39 |
void OnDeinitWindow(int nextWindowID) override; |
| 40 |
|
| 41 |
// implementation of ISliderCallback |
| 42 |
void OnSliderChange(void* data, CGUISliderControl* slider) override; |
| 43 |
|
| 44 |
// implementation of IGUIVolumeBarCallback |
| 45 |
bool IsShown() const override; |
| 46 |
|
| 47 |
// implementation of IAnnouncer |
| 48 |
void Announce(ANNOUNCEMENT::AnnouncementFlag flag, |
| 49 |
const std::string& sender, |
| 50 |
const std::string& message, |
| 51 |
const CVariant& data) override; |
| 52 |
|
| 53 |
protected: |
| 54 |
// implementation of CGUIWindow via CGUIDialogSlider |
| 55 |
void OnInitWindow() override; |
| 56 |
|
| 57 |
private: |
| 58 |
/*! |
| 59 |
* \brief Call when state change message is received |
| 60 |
*/ |
| 61 |
void OnStateChanged(); |
| 62 |
|
| 63 |
/*! |
| 64 |
* \brief Get the volume of the first callback |
| 65 |
* |
| 66 |
* \return The volume, as a fraction of maximum volume |
| 67 |
*/ |
| 68 |
float GetVolumePercent() const; |
| 69 |
|
| 70 |
/*! |
| 71 |
* \brief Get the volume bar label |
| 72 |
*/ |
| 73 |
static std::string GetLabel(); |
| 74 |
|
| 75 |
// Volume parameters |
| 76 |
const float VOLUME_MIN = 0.0f; |
| 77 |
const float VOLUME_DELTA = 10.0f; |
| 78 |
const float VOLUME_MAX = 100.0f; |
| 79 |
float m_volumePercent = 100.0f; |
| 80 |
float m_oldVolumePercent = 100.0f; |
| 81 |
}; |
| 82 |
} // namespace GAME |
| 83 |
} // namespace KODI |