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.

102 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. #include "../../Application/jucer_Headers.h"
  20. #include "../../Utility/UI/jucer_IconButton.h"
  21. #include "jucer_UserAvatarComponent.h"
  22. class Project;
  23. class ProjectContentComponent;
  24. class ProjectExporter;
  25. //==============================================================================
  26. class HeaderComponent final : public Component,
  27. private ValueTree::Listener,
  28. private ChangeListener,
  29. private Value::Listener,
  30. private Timer
  31. {
  32. public:
  33. HeaderComponent (ProjectContentComponent* projectContentComponent);
  34. //==============================================================================
  35. void resized() override;
  36. void paint (Graphics&) override;
  37. //==============================================================================
  38. void setCurrentProject (Project*);
  39. void updateExporters();
  40. std::unique_ptr<ProjectExporter> getSelectedExporter() const;
  41. bool canCurrentExporterLaunchProject() const;
  42. void sidebarTabsWidthChanged (int newWidth);
  43. private:
  44. //==============================================================================
  45. void changeListenerCallback (ChangeBroadcaster* source) override;
  46. void valueChanged (Value&) override;
  47. void timerCallback() override;
  48. //==============================================================================
  49. void valueTreeChildAdded (ValueTree& parentTree, ValueTree&) override { updateIfNeeded (parentTree); }
  50. void valueTreeChildRemoved (ValueTree& parentTree, ValueTree&, int) override { updateIfNeeded (parentTree); }
  51. void valueTreeChildOrderChanged (ValueTree& parentTree, int, int) override { updateIfNeeded (parentTree); }
  52. void updateIfNeeded (ValueTree tree)
  53. {
  54. if (tree == exportersTree)
  55. updateExporters();
  56. }
  57. //==============================================================================
  58. void initialiseButtons();
  59. void updateName();
  60. void updateExporterButton();
  61. //==============================================================================
  62. int tabsWidth = 200;
  63. ProjectContentComponent* projectContentComponent = nullptr;
  64. Project* project = nullptr;
  65. ValueTree exportersTree;
  66. Value projectNameValue;
  67. ComboBox exporterBox;
  68. Label configLabel { "Config Label", "Selected exporter" }, projectNameLabel;
  69. ImageComponent juceIcon;
  70. UserAvatarComponent userAvatar { true };
  71. IconButton projectSettingsButton { "Project Settings", getIcons().settings },
  72. saveAndOpenInIDEButton { "Save and Open in IDE", Image() };
  73. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HeaderComponent)
  74. };