SliderGroup::SliderGroup (Model* model) : ResizableLayout (this) , m_model (model) , m_label (new Label) , m_slider (new CustomSlider) , m_text (new Label) { const int w = 30; m_label->setFont (14); m_label->setBorderSize (BorderSize<int> (0)); m_label->setText (m_model->getName (), dontSendNotification); m_label->setJustificationType (Justification::centred); m_label->setBounds (0, 2, w, int(ceil(m_label->getFont().getHeight()))); addToLayout (m_label, anchorTopLeft, anchorTopRight); addAndMakeVisible (m_label); const int h = 40; m_slider->setRange (0, 1); m_slider->setVelocityBasedMode (false); m_slider->setSliderStyle (Slider::RotaryVerticalDrag); m_slider->setTextBoxStyle (Slider::NoTextBox, false, 0, 0); m_slider->setRotaryParameters (float_Pi * 1.2f, float_Pi * 2.8f, false); m_slider->setBounds (0, m_label->getBounds().getBottom() + 2, w, h); m_slider->addListener (this); m_slider->setValue (m_model->getControlValue(), dontSendNotification); addToLayout (m_slider, anchorTopLeft, anchorBottomRight); addAndMakeVisible (m_slider); m_text->setFont (15); m_text->setBorderSize (BorderSize<int> (0)); m_text->setJustificationType (Justification::centredTop); m_text->setBounds (0, m_slider->getBounds().getBottom() + 0, w, int(ceil(m_text->getFont().getHeight()))); addToLayout (m_text, anchorBottomLeft, anchorBottomRight); addAndMakeVisible (m_text); updateText (); setSize (w, m_text->getBounds().getBottom()); activateLayout (); }
CpuMeter::CpuMeter (AudioDeviceManager& audioDeviceManager) : ResizableLayout (this) , m_audioDeviceManager (audioDeviceManager) , m_value (0) { setSize (80, 18); m_label = new Label; m_label->setText ("CPU", dontSendNotification); m_label->setBorderSize (BorderSize<int>(0)); m_label->setSize (m_label->getFont().getStringWidth (m_label->getText()), 18); m_label->setTopLeftPosition (0, 0); addToLayout (m_label, anchorTopLeft, anchorBottomLeft); addAndMakeVisible (m_label); activateLayout (); startTimer (100); }
void VBoxOSTypeSelectorWidget::showEvent (QShowEvent *aEvent) { activateLayout(); /* if not yet */ QIWithRetranslateUI <QWidget>::showEvent (aEvent); }
void MainContentComponent::Init(std::shared_ptr<CommandMap>& command_map, std::weak_ptr<LR_IPC_IN>&& lr_ipc_in, std::weak_ptr<LR_IPC_OUT>&& lr_ipc_out, std::shared_ptr<MIDIProcessor>& midi_processor, //-V2009 std::shared_ptr<ProfileManager>& profile_manager, std::shared_ptr<SettingsManager>& settings_manager, std::shared_ptr<MIDISender>& midi_sender) { //copy the pointers command_map_ = command_map; lr_ipc_in_ = std::move(lr_ipc_in); lr_ipc_out_ = std::move(lr_ipc_out); settings_manager_ = settings_manager; midi_processor_ = midi_processor; midi_sender_ = midi_sender; //call the function of the sub component. command_table_model_.Init(command_map); if (midi_processor) { // Add ourselves as a listener for MIDI commands midi_processor->addMIDICommandListener(this); } if (const auto ptr = lr_ipc_out_.lock()) { // Add ourselves as a listener for LR_IPC_OUT events ptr->addListener(this); } if (profile_manager) { // Add ourselves as a listener for profile changes profile_manager->addListener(this); } //Set the component size setSize(kMainWidth, kMainHeight); // Main title title_label_.setFont(juce::Font{36.f, juce::Font::bold}); title_label_.setEditable(false); title_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); title_label_.setComponentEffect(&title_shadow_); title_label_.setBounds(kMainLeft, 10, kFullWidth, 30); addToLayout(&title_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(title_label_); // Version label SetLabelSettings(version_label_); version_label_.setBounds(kMainLeft, 40, kFullWidth, 10); addToLayout(&version_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(version_label_); // Connection status connection_label_.setFont(juce::Font{12.f, juce::Font::bold}); connection_label_.setEditable(false); connection_label_.setColour(juce::Label::backgroundColourId, juce::Colours::red); connection_label_.setColour(juce::Label::textColourId, juce::Colours::black); connection_label_.setJustificationType(juce::Justification::centred); connection_label_.setBounds(200, 15, kConnectionLabelWidth, kStandardHeight); addToLayout(&connection_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(connection_label_); // Load button load_button_.addListener(this); load_button_.setBounds(kFirstButtonX, 60, kButtonWidth, kStandardHeight); addToLayout(&load_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(load_button_); // Save button save_button_.addListener(this); save_button_.setBounds(kSecondButtonX, 60, kButtonWidth, kStandardHeight); addToLayout(&save_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(save_button_); // Settings button settings_button_.addListener(this); settings_button_.setBounds(kThirdButtonX, 60, kButtonWidth, kStandardHeight); addToLayout(&settings_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(settings_button_); // Command Table command_table_.setModel(&command_table_model_); command_table_.setBounds(kMainLeft, 100, kFullWidth, kCommandTableHeight); addToLayout(&command_table_, anchorMidLeft, anchorMidRight); addAndMakeVisible(command_table_); // Profile name label SetLabelSettings(profile_name_label_); profile_name_label_.setBounds(kMainLeft, kProfileNameY, kLabelWidth, kStandardHeight); addToLayout(&profile_name_label_, anchorMidLeft, anchorMidRight); profile_name_label_.setJustificationType(juce::Justification::centred); addAndMakeVisible(profile_name_label_); // Last MIDI command command_label_.setFont(juce::Font{12.f, juce::Font::bold}); command_label_.setEditable(false); command_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); command_label_.setBounds(kCommandLabelX, kCommandLabelY, kLabelWidth, kStandardHeight); addToLayout(&command_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(command_label_); // Remove row button remove_row_button_.addListener(this); remove_row_button_.setBounds(kMainLeft, kRemoveRowY, kFullWidth, kStandardHeight); addToLayout(&remove_row_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(remove_row_button_); // Rescan MIDI button rescan_button_.addListener(this); rescan_button_.setBounds(kMainLeft, kRescanY, kFullWidth, kStandardHeight); addToLayout(&rescan_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(rescan_button_); // adding the current status label, used for counting down. current_status_.setBounds(kMainLeft, kCurrentStatusY, kFullWidth, kStandardHeight); addToLayout(¤t_status_, anchorMidLeft, anchorMidRight); current_status_.setJustificationType(juce::Justification::centred); SetLabelSettings(current_status_); addAndMakeVisible(current_status_); if (settings_manager_) { // Try to load a default.xml if the user has not set a profile directory if (settings_manager_->getProfileDirectory().isEmpty()) { juce::File default_profile = juce::File::getSpecialLocation(juce::File::currentExecutableFile).getSiblingFile("default.xml"); std::unique_ptr<juce::XmlElement> xml_element{juce::XmlDocument::parse(default_profile)}; if (xml_element) { command_table_model_.buildFromXml(xml_element.get()); command_table_.updateContent(); } } else if (profile_manager) { // otherwise use the last profile from the profile directory profile_manager->switchToProfile(0); } } // turn it on activateLayout(); }
void MainContentComponent::Init(CommandMap *commandMap, LR_IPC_IN *in, LR_IPC_OUT *out, MIDIProcessor *midiProcessor, ProfileManager *profileManager, SettingsManager *settingsManager, MIDISender *midiSender) { //copy the pointers m_commandMap = commandMap; m_lr_IPC_IN = in; m_lr_IPC_OUT = out; m_settingsManager = settingsManager; m_midiProcessor = midiProcessor; m_midiSender = midiSender; //call the function of the sub component. _commandTableModel.Init(commandMap); if (midiProcessor) { // Add ourselves as a listener for MIDI commands midiProcessor->addMIDICommandListener(this); } if (m_lr_IPC_OUT) { // Add ourselves as a listener for LR_IPC_OUT events m_lr_IPC_OUT->addListener(this); } if (profileManager) { // Add ourselves as a listener for profile changes profileManager->addListener(this); } //Set the component size setSize(MAIN_WIDTH, MAIN_HEIGHT); // Main title _titleLabel.setFont(Font(36.f, Font::bold)); _titleLabel.setEditable(false); _titleLabel.setColour(Label::textColourId, Colours::darkgrey); _titleLabel.setComponentEffect(&_titleShadow); _titleLabel.setBounds(MAIN_LEFT, 10, MAIN_WIDTH - 2 * MAIN_LEFT, 30); addToLayout(&_titleLabel, anchorMidLeft, anchorMidRight); addAndMakeVisible(_titleLabel); // Version label SetLabelSettings(_versionLabel); _versionLabel.setBounds(MAIN_LEFT, 40, MAIN_WIDTH - 2 * MAIN_LEFT, 10); addToLayout(&_versionLabel, anchorMidLeft, anchorMidRight); addAndMakeVisible(_versionLabel); // Connection status _connectionLabel.setFont(Font(12.f, Font::bold)); _connectionLabel.setEditable(false); _connectionLabel.setColour(Label::backgroundColourId, Colours::red); _connectionLabel.setColour(Label::textColourId, Colours::black); _connectionLabel.setJustificationType(Justification::centred); _connectionLabel.setBounds(200, 15, MAIN_WIDTH - MAIN_LEFT - 200, 20); addToLayout(&_connectionLabel, anchorMidLeft, anchorMidRight); addAndMakeVisible(_connectionLabel); //get the button width long buttonWidth = (MAIN_WIDTH - 2 * MAIN_LEFT - SPACEBETWEENBUTTON * 2) / 3; // Load button _loadButton.addListener(this); _loadButton.setBounds(MAIN_LEFT, 60, buttonWidth, 20); addToLayout(&_loadButton, anchorMidLeft, anchorMidRight); addAndMakeVisible(_loadButton); // Save button _saveButton.addListener(this); _saveButton.setBounds(MAIN_LEFT + buttonWidth + SPACEBETWEENBUTTON, 60, buttonWidth, 20); addToLayout(&_saveButton, anchorMidLeft, anchorMidRight); addAndMakeVisible(_saveButton); // Settings button _settingsButton.addListener(this); _settingsButton.setBounds(MAIN_LEFT + buttonWidth * 2 + SPACEBETWEENBUTTON * 2, 60, buttonWidth, 20); addToLayout(&_settingsButton, anchorMidLeft, anchorMidRight); addAndMakeVisible(_settingsButton); // Command Table _commandTable.setModel(&_commandTableModel); _commandTable.setBounds(MAIN_LEFT, 100, MAIN_WIDTH - MAIN_LEFT * 2, MAIN_HEIGHT - 210); addToLayout(&_commandTable, anchorMidLeft, anchorMidRight); addAndMakeVisible(_commandTable); long labelWidth = (MAIN_WIDTH - MAIN_LEFT * 2) / 2; // Profile name label SetLabelSettings(_profileNameLabel); _profileNameLabel.setBounds(MAIN_LEFT, MAIN_HEIGHT - 100, labelWidth, 20); addToLayout(&_profileNameLabel, anchorMidLeft, anchorMidRight); _profileNameLabel.setJustificationType(Justification::centred); addAndMakeVisible(_profileNameLabel); // Last MIDI command _commandLabel.setFont(Font(12.f, Font::bold)); _commandLabel.setEditable(false); _commandLabel.setColour(Label::textColourId, Colours::darkgrey); _commandLabel.setBounds(MAIN_LEFT + labelWidth, MAIN_HEIGHT - 100, labelWidth, 20); addToLayout(&_commandLabel, anchorMidLeft, anchorMidRight); addAndMakeVisible(_commandLabel); // Remove row button _removeRowButton.addListener(this); _removeRowButton.setBounds(MAIN_LEFT, MAIN_HEIGHT - 75, MAIN_WIDTH - MAIN_LEFT * 2, 20); addToLayout(&_removeRowButton, anchorMidLeft, anchorMidRight); addAndMakeVisible(_removeRowButton); // Rescan MIDI button _rescanButton.addListener(this); _rescanButton.setBounds(MAIN_LEFT, MAIN_HEIGHT - 50, MAIN_WIDTH - MAIN_LEFT * 2, 20); addToLayout(&_rescanButton, anchorMidLeft, anchorMidRight); addAndMakeVisible(_rescanButton); // adding the current status label, used for counting down. m_currentStatus.setBounds(MAIN_LEFT, MAIN_HEIGHT - 30, MAIN_WIDTH - MAIN_LEFT * 2, 20); addToLayout(&m_currentStatus, anchorMidLeft, anchorMidRight); m_currentStatus.setJustificationType(Justification::centred); SetLabelSettings(m_currentStatus); addAndMakeVisible(m_currentStatus); _systemTrayComponent.setIconImage(ImageCache::getFromMemory(BinaryData::MIDI2LR_png, BinaryData::MIDI2LR_pngSize)); if (m_settingsManager) { // Try to load a default.xml if the user has not set a profile directory if (m_settingsManager->getProfileDirectory().isEmpty()) { File defaultProfile = File::getSpecialLocation(File::currentExecutableFile).getSiblingFile("default.xml"); ScopedPointer<XmlElement> elem = XmlDocument::parse(defaultProfile); if (elem) { _commandTableModel.buildFromXml(elem); _commandTable.updateContent(); } } else if (profileManager) { // otherwise use the last profile from the profile directory profileManager->switchToProfile(0); } } // turn it on activateLayout(); }
MainPanel::MainPanel() : TopLevelResizableLayout (this) , m_lastTypeId (0) { setOpaque (true); const int w = 512; const int h = 512 + 102; const int gap = 4; const int x0 = 4; m_listeners.add (this); int x; int y = 4; x = x0; { ComboBox* c = new ComboBox; c->setBounds (x, y, 160, 24); addToLayout (c, anchorTopLeft); addAndMakeVisible (c); buildFamilyMenu (c); m_menuFamily = c; c->addListener (this); } x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap; { ComboBox* c = new ComboBox; c->setBounds (x, y, 120, 24); addToLayout (c, anchorTopLeft); addAndMakeVisible (c); buildFamilyMenu (c); m_menuType = c; c->addListener (this); } x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap; { ComboBox* c = new ComboBox; c->setBounds (x, y, 120, 24); c->addItem ("Amen Break", 1); c->addItem ("Sine Wave (440Hz)", 2); c->addItem ("White Noise", 3); c->addItem ("Pink Noise", 4); addToLayout (c, anchorTopLeft); addAndMakeVisible (c); m_menuAudio = c; c->addListener (this); } x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap; { CpuMeter* c = new CpuMeter (MainApp::getInstance().getAudioOutput().getAudioDeviceManager()); c->setBounds (w - 80 - gap, y, 80, 24); addToLayout (c, anchorTopRight); addAndMakeVisible (c); } y = this->getChildComponent (this->getNumChildComponents()-1)->getBounds().getBottom() + gap; x = x0; x = w - gap; const int hfc = 80; { Slider* c = new Slider; c->setBounds (x - 20, y, 20, hfc + gap + 24); c->setSliderStyle (Slider::LinearVertical); c->setTextBoxStyle (Slider::NoTextBox, true, 0, 0); c->setRange (-40, 12); c->setValue (0); addAndMakeVisible (c); addToLayout (c, anchorTopRight); c->addListener (this); m_volumeSlider = c; } x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getX() - gap; { Slider* c = new Slider; c->setBounds (x - 20, y, 20, hfc + gap + 24); c->setSliderStyle (Slider::LinearVertical); c->setTextBoxStyle (Slider::NoTextBox, true, 0, 0); c->setRange (-2, 2); c->setValue (0); addAndMakeVisible (c); addToLayout (c, anchorTopRight); c->addListener (this); m_tempoSlider = c; } x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getX() - gap; int x1 = x - x0 + gap; { FilterControls* c = new FilterControls (m_listeners); c->setBounds (x0, y, x - x0, hfc); addToLayout (c, anchorTopLeft, anchorTopRight); addAndMakeVisible (c); m_listeners.add (c); } y = this->getChildComponent (this->getNumChildComponents()-1)->getBounds().getBottom() + gap; x = x0; { ComboBox* c = new ComboBox; c->setBounds (x, y, 120, 24); c->addItem ("Direct Form I", 1); c->addItem ("Direct Form II", 2); c->addItem ("Transposed Direct Form I", 3); c->addItem ("Transposed Direct Form II", 4); c->addItem ("Lattice Form", 5); c->setItemEnabled (5, false); c->addItem ("State Variable", 6); c->setItemEnabled (6, false); c->setSelectedId (1); addToLayout (c, anchorTopLeft); addAndMakeVisible (c); m_menuStateType = c; c->addListener (this); } x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap; { ComboBox* c = new ComboBox; c->setBounds (x, y, 200, 24); c->addItem ("Parameter Smoothing", 1); c->addItem ("Pole/Zero Interpolation", 2); c->setItemEnabled (2, false); c->addItem ("Coefficient Interpolation", 3); c->setItemEnabled (3, false); c->addItem ("No Smoothing", 4); c->setSelectedId (1); addToLayout (c, anchorTopLeft); addAndMakeVisible (c); m_menuSmoothing = c; c->addListener (this); } x = this->getChildComponent (this->getNumChildComponents() - 1)->getBounds().getRight() + gap; { m_resetButton = new TextButton ("Reset"); m_resetButton->setBounds (x1 - 60, y, 60, 24); m_resetButton->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight); addToLayout (m_resetButton, anchorTopRight); addAndMakeVisible (m_resetButton); m_resetButton->addListener (this); } y = this->getChildComponent (this->getNumChildComponents()-1)->getBounds().getBottom() + gap; x = x0; const Rectangle<int> r (x, y, w - (x + gap), h - (y + gap)); createCharts (r); setSize (w, h); setMinimumSize (256, 256); activateLayout(); m_menuFamily->setSelectedId (1); m_menuAudio->setSelectedId (1); }