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.

107 lines
3.8KB

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