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.

95 lines
3.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. #pragma once
  14. #include "../../Application/jucer_Headers.h"
  15. #include "../../Utility/UI/jucer_IconButton.h"
  16. #include "jucer_UserAvatarComponent.h"
  17. class Project;
  18. class ProjectContentComponent;
  19. class ProjectExporter;
  20. //==============================================================================
  21. class HeaderComponent : public Component,
  22. private ValueTree::Listener,
  23. private ChangeListener,
  24. private Value::Listener,
  25. private Timer
  26. {
  27. public:
  28. HeaderComponent (ProjectContentComponent* projectContentComponent);
  29. //==============================================================================
  30. void resized() override;
  31. void paint (Graphics&) override;
  32. //==============================================================================
  33. void setCurrentProject (Project*);
  34. void updateExporters();
  35. std::unique_ptr<ProjectExporter> getSelectedExporter() const;
  36. bool canCurrentExporterLaunchProject() const;
  37. void sidebarTabsWidthChanged (int newWidth);
  38. private:
  39. //==============================================================================
  40. void changeListenerCallback (ChangeBroadcaster* source) override;
  41. void valueChanged (Value&) override;
  42. void timerCallback() override;
  43. //==============================================================================
  44. void valueTreeChildAdded (ValueTree& parentTree, ValueTree&) override { updateIfNeeded (parentTree); }
  45. void valueTreeChildRemoved (ValueTree& parentTree, ValueTree&, int) override { updateIfNeeded (parentTree); }
  46. void valueTreeChildOrderChanged (ValueTree& parentTree, int, int) override { updateIfNeeded (parentTree); }
  47. void updateIfNeeded (ValueTree tree)
  48. {
  49. if (tree == exportersTree)
  50. updateExporters();
  51. }
  52. //==============================================================================
  53. void initialiseButtons();
  54. void updateName();
  55. void updateExporterButton();
  56. //==============================================================================
  57. int tabsWidth = 200;
  58. ProjectContentComponent* projectContentComponent = nullptr;
  59. Project* project = nullptr;
  60. ValueTree exportersTree;
  61. Value projectNameValue;
  62. ComboBox exporterBox;
  63. Label configLabel { "Config Label", "Selected exporter" }, projectNameLabel;
  64. ImageComponent juceIcon;
  65. UserAvatarComponent userAvatar { true };
  66. IconButton projectSettingsButton { "Project Settings", getIcons().settings },
  67. saveAndOpenInIDEButton { "Save and Open in IDE", Image() };
  68. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HeaderComponent)
  69. };