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.

73 lines
2.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  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. #pragma once
  14. #include "../../Application/jucer_Application.h"
  15. //==============================================================================
  16. class SlidingPanelComponent : public Component
  17. {
  18. public:
  19. SlidingPanelComponent();
  20. ~SlidingPanelComponent() override;
  21. /** Adds a new tab to the panel slider. */
  22. void addTab (const String& tabName,
  23. Component* contentComponent,
  24. bool deleteComponentWhenNotNeeded,
  25. int insertIndex = -1);
  26. /** Gets rid of one of the tabs. */
  27. void removeTab (int tabIndex);
  28. /** Gets index of current tab. */
  29. int getCurrentTabIndex() const noexcept { return currentIndex; }
  30. /** Returns the number of tabs. */
  31. int getNumTabs() const noexcept { return pages.size(); }
  32. /** Animates the window to the desired tab. */
  33. void goToTab (int targetTabIndex);
  34. //==============================================================================
  35. /** @internal */
  36. void resized() override;
  37. private:
  38. struct DotButton;
  39. friend struct DotButton;
  40. struct PageInfo
  41. {
  42. ~PageInfo();
  43. Component::SafePointer<Component> content;
  44. std::unique_ptr<DotButton> dotButton;
  45. String name;
  46. bool shouldDelete;
  47. };
  48. OwnedArray<PageInfo> pages;
  49. Component pageHolder;
  50. int currentIndex, dotSize;
  51. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SlidingPanelComponent)
  52. };