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.

203 lines
7.6KB

  1. /* Copyright 2013-2019 Matt Tytel
  2. *
  3. * vital is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * vital is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with vital. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include "JuceHeader.h"
  18. #include "header_section.h"
  19. #include "effects_interface.h"
  20. #include "memory.h"
  21. #include "modulation_matrix.h"
  22. #include "open_gl_background.h"
  23. #include "shaders.h"
  24. #include "synth_section.h"
  25. #include "wavetable_creator.h"
  26. class AboutSection;
  27. class BankExporter;
  28. class BendSection;
  29. class DeleteSection;
  30. class ExpiredSection;
  31. class ExtraModSection;
  32. class HeaderSection;
  33. class KeyboardInterface;
  34. class MasterControlsInterface;
  35. class ModulationInterface;
  36. class ModulationManager;
  37. class PortamentoSection;
  38. class PresetBrowser;
  39. class SaveSection;
  40. class SynthesisInterface;
  41. struct SynthGuiData;
  42. class SynthSlider;
  43. class WavetableEditSection;
  44. class VoiceSection;
  45. class FullInterface : public SynthSection, public HeaderSection::Listener,
  46. public EffectsInterface::Listener, public ModulationMatrix::Listener,
  47. public OpenGLRenderer, DragAndDropContainer {
  48. public:
  49. static constexpr double kMinOpenGlVersion = 1.4;
  50. FullInterface(SynthGuiData* synth_gui_data);
  51. FullInterface();
  52. virtual ~FullInterface();
  53. void setOscilloscopeMemory(const vital::poly_float* memory);
  54. void setAudioMemory(const vital::StereoMemory* memory);
  55. void createModulationSliders(const vital::output_map& mono_modulations,
  56. const vital::output_map& poly_modulations);
  57. virtual void paintBackground(Graphics& g) override;
  58. void copySkinValues(const Skin& skin);
  59. void reloadSkin(const Skin& skin);
  60. void repaintChildBackground(SynthSection* child);
  61. void repaintSynthesisSection();
  62. void repaintOpenGlBackground(OpenGlComponent* component);
  63. void redoBackground();
  64. void checkShouldReposition(bool resize = true);
  65. void parentHierarchyChanged() override {
  66. SynthSection::parentHierarchyChanged();
  67. checkShouldReposition();
  68. }
  69. virtual void resized() override;
  70. void animate(bool animate) override;
  71. void reset() override;
  72. void setAllValues(vital::control_map& controls) override;
  73. void setWavetableNames();
  74. void newOpenGLContextCreated() override;
  75. void renderOpenGL() override;
  76. void openGLContextClosing() override;
  77. void showAboutSection() override;
  78. void deleteRequested(File preset) override;
  79. void tabSelected(int index) override;
  80. void clearTemporaryTab(int current_tab) override;
  81. void setPresetBrowserVisibility(bool visible, int current_tab) override;
  82. void setBankExporterVisibility(bool visible, int current_tab) override;
  83. void bankImported() override;
  84. void effectsMoved() override;
  85. void modulationsScrolled() override;
  86. void setFocus();
  87. void notifyChange();
  88. void notifyFresh();
  89. void externalPresetLoaded(const File& preset);
  90. void showFullScreenSection(SynthSection* full_screen);
  91. void showWavetableEditSection(int index);
  92. std::string getLastBrowsedWavetable(int index);
  93. std::string getWavetableName(int index);
  94. void hideWavetableEditSection();
  95. void loadWavetableFile(int index, const File& wavetable);
  96. void loadWavetable(int index, json& wavetable_data);
  97. void loadDefaultWavetable(int index);
  98. void resynthesizeToWavetable(int index);
  99. void saveWavetable(int index);
  100. void saveLfo(const json& data);
  101. json getWavetableJson(int index);
  102. bool loadAudioAsWavetable(int index, const String& name, InputStream* audio_stream,
  103. WavetableCreator::AudioFileLoadStyle style);
  104. void popupBrowser(SynthSection* owner, Rectangle<int> bounds, std::vector<File> directories,
  105. String extensions, std::string passthrough_name, std::string additional_folders_name);
  106. void popupBrowserUpdate(SynthSection* owner);
  107. void popupSelector(Component* source, Point<int> position, const PopupItems& options,
  108. std::function<void(int)> callback, std::function<void()> cancel);
  109. void dualPopupSelector(Component* source, Point<int> position, int width,
  110. const PopupItems& options, std::function<void(int)> callback);
  111. void popupDisplay(Component* source, const std::string& text,
  112. BubbleComponent::BubblePlacement placement, bool primary);
  113. void hideDisplay(bool primary);
  114. void modulationChanged();
  115. void modulationValueChanged(int index);
  116. void openSaveDialog() { save_section_->setIsPreset(true); save_section_->setVisible(true); }
  117. void enableRedoBackground(bool enable) {
  118. enable_redo_background_ = enable;
  119. if (enable)
  120. resized();
  121. }
  122. float getResizingScale() const { return width_ * 1.0f / resized_width_; }
  123. float getPixelScaling() const override { return display_scale_; }
  124. int getPixelMultiple() const override { return pixel_multiple_; }
  125. void toggleOscillatorZoom(int index);
  126. void toggleFilter1Zoom();
  127. void toggleFilter2Zoom();
  128. private:
  129. bool wavetableEditorsInitialized() {
  130. for (int i = 0; i < vital::kNumOscillators; ++i) {
  131. if (wavetable_edits_[i] == nullptr)
  132. return false;
  133. }
  134. return true;
  135. }
  136. std::map<std::string, SynthSlider*> slider_lookup_;
  137. std::map<std::string, Button*> button_lookup_;
  138. std::unique_ptr<ModulationManager> modulation_manager_;
  139. std::unique_ptr<ModulationMatrix> modulation_matrix_;
  140. std::unique_ptr<AboutSection> about_section_;
  141. std::unique_ptr<Component> standalone_settings_section_;
  142. std::unique_ptr<HeaderSection> header_;
  143. std::unique_ptr<SynthesisInterface> synthesis_interface_;
  144. std::unique_ptr<MasterControlsInterface> master_controls_interface_;
  145. std::unique_ptr<ModulationInterface> modulation_interface_;
  146. std::unique_ptr<ExtraModSection> extra_mod_section_;
  147. std::unique_ptr<EffectsInterface> effects_interface_;
  148. std::unique_ptr<WavetableEditSection> wavetable_edits_[vital::kNumOscillators];
  149. std::unique_ptr<KeyboardInterface> keyboard_interface_;
  150. std::unique_ptr<BendSection> bend_section_;
  151. std::unique_ptr<PortamentoSection> portamento_section_;
  152. std::unique_ptr<VoiceSection> voice_section_;
  153. std::unique_ptr<PresetBrowser> preset_browser_;
  154. std::unique_ptr<PopupBrowser> popup_browser_;
  155. std::unique_ptr<SinglePopupSelector> popup_selector_;
  156. std::unique_ptr<DualPopupSelector> dual_popup_selector_;
  157. std::unique_ptr<PopupDisplay> popup_display_1_;
  158. std::unique_ptr<PopupDisplay> popup_display_2_;
  159. std::unique_ptr<BankExporter> bank_exporter_;
  160. std::unique_ptr<SaveSection> save_section_;
  161. std::unique_ptr<DeleteSection> delete_section_;
  162. SynthSection* full_screen_section_;
  163. int width_;
  164. int resized_width_;
  165. float last_render_scale_;
  166. float display_scale_;
  167. int pixel_multiple_;
  168. bool setting_all_values_;
  169. bool unsupported_;
  170. bool animate_;
  171. bool enable_redo_background_;
  172. CriticalSection open_gl_critical_section_;
  173. OpenGLContext open_gl_context_;
  174. std::unique_ptr<Shaders> shaders_;
  175. OpenGlWrapper open_gl_;
  176. Image background_image_;
  177. OpenGlBackground background_;
  178. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FullInterface)
  179. };