/xbmc/dialogs/GUIDialogButtonMenu.cpp

http://github.com/xbmc/xbmc · C++ · 44 lines · 28 code · 7 blank · 9 comment · 7 complexity · 7044ae4a15a9635fc4a001dd04da9438 MD5 · raw file

  1. /*
  2. * Copyright (C) 2005-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. #include "GUIDialogButtonMenu.h"
  9. #include "guilib/GUIMessage.h"
  10. #define CONTROL_BUTTON_LABEL 3100
  11. CGUIDialogButtonMenu::CGUIDialogButtonMenu(int id, const std::string &xmlFile)
  12. : CGUIDialog(id, xmlFile.c_str())
  13. {
  14. m_loadType = KEEP_IN_MEMORY;
  15. }
  16. CGUIDialogButtonMenu::~CGUIDialogButtonMenu(void) = default;
  17. bool CGUIDialogButtonMenu::OnMessage(CGUIMessage &message)
  18. {
  19. bool bRet = CGUIDialog::OnMessage(message);
  20. if (message.GetMessage() == GUI_MSG_CLICKED)
  21. {
  22. // someone has been clicked - deinit...
  23. Close();
  24. return true;
  25. }
  26. return bRet;
  27. }
  28. void CGUIDialogButtonMenu::FrameMove()
  29. {
  30. // get the active control, and put it's label into the label control
  31. const CGUIControl *pControl = GetFocusedControl();
  32. if (pControl && (pControl->GetControlType() == CGUIControl::GUICONTROL_BUTTON || pControl->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON))
  33. {
  34. SET_CONTROL_LABEL(CONTROL_BUTTON_LABEL, pControl->GetDescription());
  35. }
  36. CGUIDialog::FrameMove();
  37. }