Skip to content
Snippets Groups Projects
Commit f7df2c71 authored by Septen's avatar Septen
Browse files

PluginGenerator: polishing and minor fixes.

* Changed the order of plugin types at the enum definition.
* Changed some plugin definition names to be more user friendly and to
  be consistent with OE GUI.
* Removed "DataThread" plugin type from the "Plugin type" comboBox at
  the plugin creation page. Now to create DataThread plugin user
  should select "Processor" plugin type, then "Source" processor type
  and click "Use separate thread" button
* Removed possibility to create "Utility" processors plugins since we
  don't want to let users create such types of plugins.
* Removed possibility to generate editor and content component files
  for non-processor plugins since this feature was redundant.
* Removed "Plugin" page from "Config" for non-processor plugins since
  they have no built-in parameters.
* Added missing LookAndFeel related files to stage.
* Refactoring.
parent 47f05ca7
Branches
Tags
No related merge requests found
......@@ -311,6 +311,7 @@ private:
updatePropertyList();
project.addChangeListener (this);
// Open Ephys
addChildComponent (&m_parametersEditorComponent);
static const Colour COLOUR_PRIMARY (Colours::black.withAlpha (0.87f));
......@@ -324,18 +325,20 @@ private:
projectSettingsButton->setColour (TextButton::buttonOnColourId, Colour (0x0));
projectSettingsButton->setColour (TextButton::textColourOffId, COLOUR_PRIMARY);
projectSettingsButton->setColour (TextButton::textColourOnId, COLOUR_ACCENT);
m_buttonGroupManager.addButton (projectSettingsButton);
TextButton* pluginSettingsButton = new TextButton ("Plugin", "Switch to plugin settings tab");
pluginSettingsButton->setComponentID (PLUGIN_SETTINGS_BUTTON_ID);
pluginSettingsButton->setClickingTogglesState (true);
pluginSettingsButton->setColour (TextButton::buttonColourId, Colour (0x0));
pluginSettingsButton->setColour (TextButton::buttonOnColourId, Colour (0x0));
pluginSettingsButton->setColour (TextButton::textColourOffId, COLOUR_PRIMARY);
pluginSettingsButton->setColour (TextButton::textColourOnId, COLOUR_ACCENT);
if (p.isProcessorPlugin())
{
TextButton* pluginSettingsButton = new TextButton ("Plugin", "Switch to plugin settings tab");
pluginSettingsButton->setComponentID (PLUGIN_SETTINGS_BUTTON_ID);
pluginSettingsButton->setClickingTogglesState (true);
pluginSettingsButton->setColour (TextButton::buttonColourId, Colour (0x0));
pluginSettingsButton->setColour (TextButton::buttonOnColourId, Colour (0x0));
pluginSettingsButton->setColour (TextButton::textColourOffId, COLOUR_PRIMARY);
pluginSettingsButton->setColour (TextButton::textColourOnId, COLOUR_ACCENT);
m_buttonGroupManager.addButton (pluginSettingsButton);
}
// Open Ephys
m_buttonGroupManager.addButton (projectSettingsButton);
m_buttonGroupManager.addButton (pluginSettingsButton);
m_buttonGroupManager.setRadioButtonMode (true);
m_buttonGroupManager.setButtonListener (this);
m_buttonGroupManager.setButtonsLookAndFeel (m_materialButtonLookAndFeel);
......
......@@ -37,8 +37,8 @@ PluginTemplatesPageComponent::PluginTemplatesPageComponent()
, m_lookAndFeelsComboBox (new ComboBox ("LookAndFeel selector"))
, m_pluginTypeLabel (new Label (String::empty, TRANS("Plugin type") + ":"))
, m_processorTypeLabel (new Label (String::empty, TRANS("Processor type") + ":"))
, m_shouldUseVisualizerEditorButton (new ToggleButton ("Visualizer editor"))
, m_shouldUseDataThreadButton (new ToggleButton ("Data thread source"))
, m_shouldUseVisualizerEditorButton (new ToggleButton ("Use visualizer"))
, m_shouldUseDataThreadButton (new ToggleButton ("Use separate thread"))
, m_genericEditorTemplatesManager (new TiledButtonGroupManager)
, m_visualizerEditorTemplatesManager (new TiledButtonGroupManager)
, m_tabsButtonManager (new LinearButtonGroupManager)
......@@ -48,8 +48,8 @@ PluginTemplatesPageComponent::PluginTemplatesPageComponent()
{
TRANS("Processor"),
TRANS("Record engine"),
TRANS("Data thread"),
TRANS("File source")
//TRANS("Data thread"),
};
m_pluginTypeComboBox->addItemList (StringArray (pluginTypeOptions,
......@@ -70,7 +70,7 @@ PluginTemplatesPageComponent::PluginTemplatesPageComponent()
TRANS("Sink"),
//TRANS("Splitter"),
//TRANS("Merger"),
TRANS("Utility"),
//TRANS("Utility"),
};
m_processorTypeComboBox->addItemList (StringArray (processorTypeOptions,
......@@ -100,17 +100,20 @@ PluginTemplatesPageComponent::PluginTemplatesPageComponent()
static const Colour TAB_BUTTON_COLOUR_PRIMARY (Colours::black.withAlpha (0.87f));
static const Colour TAB_BUTTON_COLOUR_ACCENT (Colour::fromRGB (3, 169, 244));
TextButton* genericEditorTabButton = new TextButton ("Main editor templates",
TextButton* genericEditorTabButton = new TextButton ("Editor templates",
"Choose template for main plugin editor");
genericEditorTabButton->setComponentID (GENERIC_EDITOR_TEMPLATES_TAB_BUTTON_ID);
genericEditorTabButton->setClickingTogglesState (true);
genericEditorTabButton->setToggleState (true, dontSendNotification);
genericEditorTabButton->setColour (TextButton::buttonColourId, Colour (0x0));
genericEditorTabButton->setColour (TextButton::buttonOnColourId, Colour (0x0));
genericEditorTabButton->setColour (TextButton::textColourOffId, TAB_BUTTON_COLOUR_PRIMARY);
genericEditorTabButton->setColour (TextButton::textColourOnId, TAB_BUTTON_COLOUR_ACCENT);
TextButton* visualizerEditorTabButton = new TextButton ("Visualizer editor templates",
TextButton* visualizerEditorTabButton = new TextButton ("Visualizer templates",
"Choose template for visualizer editor");
visualizerEditorTabButton->setComponentID (VISUALIZER_EDITOR_TEMPLATES_TAB_BUTTON_ID);
visualizerEditorTabButton->setClickingTogglesState (true);
visualizerEditorTabButton->setColour (TextButton::buttonColourId, Colour (0x0));
visualizerEditorTabButton->setColour (TextButton::buttonOnColourId, Colour (0x0));
visualizerEditorTabButton->setColour (TextButton::textColourOffId, TAB_BUTTON_COLOUR_PRIMARY);
......@@ -153,9 +156,12 @@ PluginTemplatesPageComponent::PluginTemplatesPageComponent()
void PluginTemplatesPageComponent::paint (Graphics& g)
{
const auto managerBorderBounds = m_genericEditorTemplatesManager->getBounds().expanded (10, 30).translated (0, 20);
g.setColour (Colours::orange);
g.drawRoundedRectangle (managerBorderBounds.toFloat(), 5.f, 2.f);
if (isProcessorPlugin())
{
const auto managerBorderBounds = m_genericEditorTemplatesManager->getBounds().expanded (10, 30).translated (0, 20);
g.setColour (Colours::orange);
g.drawRoundedRectangle (managerBorderBounds.toFloat(), 5.f, 2.f);
}
}
......@@ -177,8 +183,9 @@ void PluginTemplatesPageComponent::resized()
m_processorTypeComboBox->setBounds (configComponentsBounds.removeFromLeft (processorComboBoxWidth));
configComponentsBounds.removeFromLeft (20);
if (m_shouldUseDataThreadButton->isVisible())
m_shouldUseDataThreadButton->setBounds (configComponentsBounds.removeFromLeft (160));
m_shouldUseVisualizerEditorButton->setBounds (configComponentsBounds);
m_shouldUseDataThreadButton->setBounds (configComponentsBounds);
localBounds.removeFromTop (10);
// ========================================================================
......@@ -213,6 +220,10 @@ void PluginTemplatesPageComponent::buttonClicked (Button* buttonThatWasClicked)
// Uncomment if we want to disable "VisualizerEditor templates" tab when no need to use visualizer editor
//setVisualizerTemplatesAvailable (m_shouldUseVisualizerEditor->getToggleState());
}
else if (buttonThatWasClicked == m_shouldUseDataThreadButton)
{
updateComponentsVisibility();
}
else if (auto selectedTemplateComponent = dynamic_cast<EditorTemplateComponent*> (buttonThatWasClicked))
{
// The page with templates for generic editor is active
......@@ -227,23 +238,10 @@ void PluginTemplatesPageComponent::buttonClicked (Button* buttonThatWasClicked)
void PluginTemplatesPageComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
{
if (comboBoxThatHasChanged == m_pluginTypeComboBox)
{
const int selectedPluginType = Plugin::PluginType (m_pluginTypeComboBox->getSelectedItemIndex() + 1);
const bool isProcessorPlugin = selectedPluginType == (int)Plugin::PLUGIN_TYPE_PROCESSOR;
const bool isDataThreadPlugin = selectedPluginType == (int)Plugin::PLUGIN_TYPE_DATA_THREAD;
// These components should be visible only if the Processor plugin type was selected
m_processorTypeComboBox->setVisible (isProcessorPlugin);
m_shouldUseVisualizerEditorButton->setVisible (isProcessorPlugin);
// These components should be visible only if the File Source plugin type was selected
m_shouldUseDataThreadButton->setVisible (isDataThreadPlugin);
resized();
}
else if (comboBoxThatHasChanged == m_processorTypeComboBox)
if (comboBoxThatHasChanged == m_pluginTypeComboBox
|| comboBoxThatHasChanged == m_processorTypeComboBox)
{
updateComponentsVisibility();
}
else if (comboBoxThatHasChanged == m_lookAndFeelsComboBox)
{
......@@ -263,6 +261,33 @@ void PluginTemplatesPageComponent::comboBoxChanged (ComboBox* comboBoxThatHasCha
}
void PluginTemplatesPageComponent::updateComponentsVisibility()
{
const int selectedPluginType = getSelectedPluginType();
const bool isProcessorPlugin = selectedPluginType == (int)Plugin::PLUGIN_TYPE_PROCESSOR;
const bool isDataThreadPlugin = selectedPluginType == (int)Plugin::PLUGIN_TYPE_DATA_THREAD;
const int selectedProcessorType = getSelectedProcessorType();
const bool isSourcePlugin = selectedProcessorType == (int)Plugin::PROCESSOR_TYPE_SOURCE;
// These components should be visible only if the Processor plugin type was selected
m_processorTypeComboBox->setVisible (isProcessorPlugin || isDataThreadPlugin);
m_shouldUseVisualizerEditorButton->setVisible (isProcessorPlugin);
m_lookAndFeelsComboBox->setVisible (isProcessorPlugin);
m_tabsButtonManager->setVisible (isProcessorPlugin);
const bool isGenericTemplatesActive = m_tabsButtonManager->getButtonAt (0)->getToggleState();
m_genericEditorTemplatesManager->setVisible (isProcessorPlugin && isGenericTemplatesActive);
m_visualizerEditorTemplatesManager->setVisible (isProcessorPlugin && ! isGenericTemplatesActive);
// These components should be visible only if the File Source plugin type was selected
m_shouldUseDataThreadButton->setVisible (isDataThreadPlugin || isSourcePlugin);
resized();
repaint();
}
void PluginTemplatesPageComponent::setButtonListenerForCreateProjectButton (Button::Listener* buttonListener)
{
m_createProjectButton->addListener (buttonListener);
......@@ -327,26 +352,28 @@ void PluginTemplatesPageComponent::setVisualizerTemplatesAvailable (bool areAvai
bool PluginTemplatesPageComponent::isProcessorSourcePlugin() const noexcept
{
const int selectedPluginType = m_pluginTypeComboBox->getSelectedItemIndex() + 1;
const int selectedPluginType = m_pluginTypeComboBox->getSelectedItemIndex() + 1;
const int selectedProcessorType = m_processorTypeComboBox->getSelectedItemIndex() + 1;
// If selected plugin type is FileSource type and "Use thread type" is not selected
// We should treat it the same if when "Processor" with "Source" type was just selected.
const bool isImplicitSourcePlugin = (selectedPluginType == (int)Plugin::PLUGIN_TYPE_DATA_THREAD)
&& (! m_shouldUseDataThreadButton->getToggleState());
const bool isSourcePlugin = (selectedPluginType == (int)Plugin::PLUGIN_TYPE_PROCESSOR)
&& (selectedProcessorType == (int)Plugin::PROCESSOR_TYPE_SOURCE);
const int selectedProcessorType = m_processorTypeComboBox->getSelectedItemIndex() + 1;
// Appropriate types were selected
const bool isExplicitSourcePlugin = (selectedPluginType == (int)Plugin::PLUGIN_TYPE_PROCESSOR)
&& (selectedProcessorType == (int)Plugin::PROCESSOR_TYPE_SOURCE);
return isSourcePlugin;
}
return isImplicitSourcePlugin || isExplicitSourcePlugin;
bool PluginTemplatesPageComponent::isProcessorPlugin() const noexcept
{
return getSelectedPluginType() == (int)Plugin::PLUGIN_TYPE_PROCESSOR;
}
Plugin::PluginType PluginTemplatesPageComponent::getSelectedPluginType() const noexcept
{
if (isProcessorSourcePlugin())
return Plugin::PLUGIN_TYPE_PROCESSOR;
// If selected plugin type is Processor type and "Use thread type" is selected
// Then it means, that we should create DataThread plugin.
if (isProcessorSourcePlugin() && m_shouldUseDataThreadButton->getToggleState())
return Plugin::PLUGIN_TYPE_DATA_THREAD;
return Plugin::PluginType (m_pluginTypeComboBox->getSelectedItemIndex() + 1);
}
......@@ -354,11 +381,6 @@ Plugin::PluginType PluginTemplatesPageComponent::getSelectedPluginType() const n
Plugin::PluginProcessorType PluginTemplatesPageComponent::getSelectedProcessorType() const noexcept
{
// If selected plugin type is FileSource type and "Use thread type" is not selected
// We should treat it the same if when "Processor" with "Source" type was just selected.
if (isProcessorSourcePlugin())
return Plugin::PROCESSOR_TYPE_SOURCE;
if (getSelectedPluginType() != Plugin::PLUGIN_TYPE_PROCESSOR)
return Plugin::PROCESSOR_TYPE_INVALID;
......@@ -376,7 +398,7 @@ bool PluginTemplatesPageComponent::shouldUseVisualizerEditor() const noexcept
bool PluginTemplatesPageComponent::shouldUseDataThreadSource() const noexcept
{
return m_shouldUseDataThreadButton->isVisible() && m_shouldUseDataThreadButton->getToggleState();
return isProcessorSourcePlugin() && m_shouldUseDataThreadButton->getToggleState();
}
......
......@@ -71,7 +71,10 @@ public:
private:
bool isProcessorSourcePlugin() const noexcept;
bool isProcessorSourcePlugin() const noexcept;
bool isProcessorPlugin() const noexcept;
void updateComponentsVisibility();
void fillGenericEditorTemplates();
void fillVisualizerEditorTemplates();
......
......@@ -66,7 +66,7 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
DBG (String ("GUI Template name: ") + m_guiTemplateName);
if (m_shouldUseVisualizerEditor)
DBG (String ("GUI Visualizer Canvas template name: ") + m_guiVisualizerTemplateName);
DBG (String ("GUI Visualizer template name: ") + m_guiVisualizerTemplateName);
m_contentLookAndFeelClassName = configPage->getSelectedLookAndFeelClassName();
m_shouldChangeContentLookAndFeel = (m_contentLookAndFeelClassName != "DEFAULT");
......@@ -118,8 +118,8 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
generatePluginLibFile (project, sourceGroup, pluginProcessorName, pluginFriendlyName);
generatePluginProcessorFiles (project, sourceGroup, pluginProcessorName, pluginEditorName, pluginFriendlyName);
// No need to generate content component files for FileSource
if (m_pluginType == Plugin::PLUGIN_TYPE_FILE_SOURCE)
// No need to generate content component files for any plugins except Processors.
if (m_pluginType != Plugin::PLUGIN_TYPE_PROCESSOR)
return true;
generatePluginEditorFiles (project, sourceGroup, pluginProcessorName, pluginEditorName, pluginFriendlyName, pluginContentComponentName);
......@@ -127,7 +127,7 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
if (m_shouldUseVisualizerEditor)
{
const String visualizerCanvasName = pluginProcessorName + "Canvas";
const String visualizerCanvasName = pluginProcessorName + "Visualizer";
const String visualizerCanvasContentComponentName = visualizerCanvasName + "ContentComponent";
generatePluginVisualizerEditorCanvasFiles (project, sourceGroup,
pluginProcessorName, visualizerCanvasName,
......@@ -158,9 +158,9 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
String pluginLibCppFileContent = project.getFileTemplate ("openEphys_OpenEphysLibTemplate_cpp")
.replace ("PROCESSORCLASSNAME", pluginProcessorName, false)
.replace ("PLUGINLIBRARYNAME", "Temporary " + pluginFriendlyName + " library", false) // TODO <Kirill A>: set library name variable
.replace ("PLUGINLIBRARYNAME", pluginFriendlyName + " plugin library", false) // TODO <Kirill A>: set library name variable
.replace ("PLUGINLIBRARYVERSION", "1", false) // TODO <Kirill A>: set library version variable
.replace ("PLUGINGUINAME", "Temporary " + pluginFriendlyName, false) // TODO <Kirill A>: set library gui name variable
.replace ("PLUGINGUINAME", pluginFriendlyName, false) // TODO <Kirill A>: set library gui name variable
.replace ("LIBPLUGINTYPE", libPluginType, false)
.replace ("LIBPLUGININFOTYPE", libPluginInfoType, false)
.replace ("LIBPLUGINCREATEFUNCTION", libCreateFunctionName, false)
......@@ -218,13 +218,13 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
String processorHeaders = CodeHelpers::createIncludeStatement (newProcessorHFile, newProcessorCppFile) + newLine;
if (m_pluginType != PLUGIN_TYPE_FILE_SOURCE)
if (m_pluginType == PLUGIN_TYPE_PROCESSOR)
processorHeaders += CodeHelpers::createIncludeStatement (newEditorHFile, newProcessorCppFile);
String processorCppFileContent = project.getFileTemplate (processorFileTemplateName + "_cpp")
.replace ("PROCESSORHEADERS", processorHeaders, false)
.replace ("PROCESSORCLASSNAME", processorName, false)
.replace ("PLUGINGUINAME", pluginFriendlyName, false) // TODO <Kirill A>: set better gui name variable
.replace ("PLUGINGUINAME", pluginFriendlyName, false)
.replace ("EDITORCLASSNAME", editorName, false)
.replace ("PROCESSORTYPE", processorType, false);
......@@ -288,9 +288,9 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
if (m_shouldUseVisualizerEditor)
{
const String canvasClassName = processorName + "Canvas";
const String visualizerCanvasClassName = processorName + "Visualizer";
editorCppFileContent = editorCppFileContent
.replace ("EDITORCANVASCLASSNAME", canvasClassName, false)
.replace ("EDITORCANVASCLASSNAME", visualizerCanvasClassName, false)
.replace ("GenericEditor", "VisualizerEditor", false);
}
......
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../UI/LookAndFeel/CustomLookAndFeel.h"
#include "../../UI/LookAndFeel/MaterialButtonLookAndFeel.h"
#include "../../UI/LookAndFeel/MaterialSliderLookAndFeel.h"
#include "../../UI/LookAndFeel/SquareLookAndFeel.h"
#include "../../UI/LookAndFeel/FlatRoundLookAndFeel.h"
......@@ -63,8 +63,8 @@ enum PluginType
{
PLUGIN_TYPE_PROCESSOR = 1
, PLUGIN_TYPE_RECORD_ENGINE
, PLUGIN_TYPE_DATA_THREAD
, PLUGIN_TYPE_FILE_SOURCE
, PLUGIN_TYPE_DATA_THREAD
, NOT_A_PLUGIN_TYPE = -1
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment