The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. class UIAExpandCollapseProvider : public UIAProviderBase,
  17. public ComBaseClassHelper<ComTypes::IExpandCollapseProvider>
  18. {
  19. public:
  20. using UIAProviderBase::UIAProviderBase;
  21. //==============================================================================
  22. JUCE_COMRESULT Expand() override
  23. {
  24. return invokeShowMenu();
  25. }
  26. JUCE_COMRESULT Collapse() override
  27. {
  28. return invokeShowMenu();
  29. }
  30. JUCE_COMRESULT get_ExpandCollapseState (ComTypes::ExpandCollapseState* pRetVal) override
  31. {
  32. return withCheckedComArgs (pRetVal, *this, [&]
  33. {
  34. *pRetVal = getHandler().getCurrentState().isExpanded()
  35. ? ComTypes::ExpandCollapseState_Expanded
  36. : ComTypes::ExpandCollapseState_Collapsed;
  37. return S_OK;
  38. });
  39. }
  40. private:
  41. JUCE_COMRESULT invokeShowMenu()
  42. {
  43. if (! isElementValid())
  44. return (HRESULT) UIA_E_ELEMENTNOTAVAILABLE;
  45. const auto& handler = getHandler();
  46. if (handler.getActions().invoke (AccessibilityActionType::showMenu))
  47. {
  48. sendAccessibilityAutomationEvent (handler, handler.getCurrentState().isExpanded()
  49. ? ComTypes::UIA_MenuOpenedEventId
  50. : ComTypes::UIA_MenuClosedEventId);
  51. return S_OK;
  52. }
  53. return (HRESULT) UIA_E_NOTSUPPORTED;
  54. }
  55. //==============================================================================
  56. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIAExpandCollapseProvider)
  57. };
  58. } // namespace juce