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.

86 lines
3.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. //==============================================================================
  19. /**
  20. Controls the order in which focus moves between components.
  21. The default algorithm used by this class to work out the order of traversal
  22. is as follows:
  23. - if two components both have an explicit focus order specified, then the
  24. one with the lowest number comes first (see the Component::setExplicitFocusOrder()
  25. method).
  26. - any component with an explicit focus order greater than 0 comes before ones
  27. that don't have an order specified.
  28. - any unspecified components are traversed in a left-to-right, then top-to-bottom
  29. order.
  30. If you need traversal in a more customised way, you can create a subclass
  31. of KeyboardFocusTraverser that uses your own algorithm, and use
  32. Component::createFocusTraverser() to create it.
  33. @see Component::setExplicitFocusOrder, Component::createFocusTraverser
  34. */
  35. class JUCE_API KeyboardFocusTraverser
  36. {
  37. public:
  38. KeyboardFocusTraverser();
  39. /** Destructor. */
  40. virtual ~KeyboardFocusTraverser();
  41. /** Returns the component that should be given focus after the specified one
  42. when moving "forwards".
  43. The default implementation will return the next component which is to the
  44. right of or below this one.
  45. This may return nullptr if there's no suitable candidate.
  46. */
  47. virtual Component* getNextComponent (Component* current);
  48. /** Returns the component that should be given focus after the specified one
  49. when moving "backwards".
  50. The default implementation will return the next component which is to the
  51. left of or above this one.
  52. This may return nullptr if there's no suitable candidate.
  53. */
  54. virtual Component* getPreviousComponent (Component* current);
  55. /** Returns the component that should receive focus be default within the given
  56. parent component.
  57. The default implementation will just return the foremost child component that
  58. wants focus.
  59. This may return nullptr if there's no suitable candidate.
  60. */
  61. virtual Component* getDefaultComponent (Component* parentComponent);
  62. };