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.

114 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - 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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-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. class CompileEngineChildProcess;
  26. //==============================================================================
  27. class HeaderComponent : public Component,
  28. private ValueTree::Listener,
  29. private ChangeListener,
  30. private Value::Listener,
  31. private Timer
  32. {
  33. public:
  34. HeaderComponent (ProjectContentComponent* projectContentComponent);
  35. ~HeaderComponent() override;
  36. //==============================================================================
  37. void resized() override;
  38. void paint (Graphics&) override;
  39. //==============================================================================
  40. void setCurrentProject (Project*);
  41. void updateExporters();
  42. std::unique_ptr<ProjectExporter> getSelectedExporter() const;
  43. bool canCurrentExporterLaunchProject() const;
  44. void sidebarTabsWidthChanged (int newWidth);
  45. void liveBuildEnablementChanged (bool isEnabled);
  46. private:
  47. //==============================================================================
  48. void changeListenerCallback (ChangeBroadcaster* source) override;
  49. void valueChanged (Value&) override;
  50. void timerCallback() override;
  51. //==============================================================================
  52. void valueTreeChildAdded (ValueTree& parentTree, ValueTree&) override { updateIfNeeded (parentTree); }
  53. void valueTreeChildRemoved (ValueTree& parentTree, ValueTree&, int) override { updateIfNeeded (parentTree); }
  54. void valueTreeChildOrderChanged (ValueTree& parentTree, int, int) override { updateIfNeeded (parentTree); }
  55. void updateIfNeeded (ValueTree tree)
  56. {
  57. if (tree == exportersTree)
  58. updateExporters();
  59. }
  60. //==============================================================================
  61. void initialiseButtons();
  62. void updateName();
  63. void updateExporterButton();
  64. //==============================================================================
  65. void buildPing();
  66. void buildFinished (bool);
  67. void setRunAppButtonState (bool);
  68. //==============================================================================
  69. int tabsWidth = 200;
  70. bool isBuilding = false;
  71. ProjectContentComponent* projectContentComponent = nullptr;
  72. Project* project = nullptr;
  73. ValueTree exportersTree;
  74. Value projectNameValue;
  75. ComboBox exporterBox;
  76. Label configLabel { "Config Label", "Selected exporter" }, projectNameLabel;
  77. ImageComponent juceIcon;
  78. UserAvatarComponent userAvatar { true };
  79. IconButton projectSettingsButton { "Project Settings", getIcons().settings },
  80. saveAndOpenInIDEButton { "Save and Open in IDE", Image() },
  81. runAppButton { "Run Application", getIcons().play };
  82. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  83. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HeaderComponent)
  84. };