diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 220bce3d09c215ee2ba5f4cc717d7b0f315ac8d8..03bae6e4abfd7e18765d9c5e6de66a6642d89505 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -15,14 +15,21 @@ Test2AudioProcessorEditor::Test2AudioProcessorEditor(Test2AudioProcessor &p) { // Make sure that before the constructor has finished, you've set the // editor's size to whatever you need it to be. - - // m_flogger = std::unique_ptr<juce::FileLogger>(juce::FileLogger::createDateStampedLogger("foo", "mylog", ".txt", "Welcome to plugin")); + addAndMakeVisible(positionLabel); + positionLabel.setText("Text input:", juce::dontSendNotification); + // positionLabel.attachToComponent(&inputText, true); + positionLabel.setColour(juce::Label::textColourId, juce::Colours::orange); + positionLabel.setJustificationType(juce::Justification::right); + startTimerHz(60); setResizable(true, true); + setResizeLimits(400, 300, 1024, 1024); + setSize(400, 300); } Test2AudioProcessorEditor::~Test2AudioProcessorEditor() { + stopTimer(); } //============================================================================== @@ -33,10 +40,9 @@ void Test2AudioProcessorEditor::paint(juce::Graphics &g) g.setColour(juce::Colours::white); g.setFont(15.0f); - g.drawFittedText("Hello Per 10 !", getLocalBounds(), juce::Justification::centred, 1); - g.drawFittedText("Hello Per 10 !", getLocalBounds(), juce::Justification::centred, 1); - if (processor.m_flogger) - processor.m_flogger->logMessage("paint called"); + g.drawFittedText("1) Position : " + std::to_string(processor.position), getLocalBounds(), juce::Justification::centred, 1); + // if (processor.m_flogger) + // processor.m_flogger->logMessage("paint called"); } void Test2AudioProcessorEditor::resized() @@ -45,6 +51,7 @@ void Test2AudioProcessorEditor::resized() // subcomponents in your editor.. auto bounds = getLocalBounds(); + positionLabel.setBounds(bounds.removeFromBottom(30).withSizeKeepingCentre(50, 24)); if (processor.m_flogger) processor.m_flogger->logMessage(bounds.toString()); diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index ce210d13ae91ea167f544d1ab0c6424091363f30..271c020321e93922cf90736a005bd889bfffa553 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -14,7 +14,7 @@ //============================================================================== /** */ -class Test2AudioProcessorEditor : public juce::AudioProcessorEditor +class Test2AudioProcessorEditor : public juce::AudioProcessorEditor, private juce::Timer { public: Test2AudioProcessorEditor(Test2AudioProcessor &); @@ -28,8 +28,19 @@ private: // This reference is provided as a quick way for your editor to // access the processor object that created it. Test2AudioProcessor &processor; - - std::unique_ptr<juce::FileLogger> m_flogger; - + // is this the way + juce::Label positionLabel; // = juce::Label("Position", "Position : 0"); + // or something like + //juce::Label positionLabel = {"Position"}; + + // should it be here or in the cpp file + // do we even need a cpp file, seems easier to do everything in the + // class declaration as we do not need to repeat the type name for each + // member function. + void timerCallback() override + { + positionLabel.setText("Pos : " + std::to_string(processor.position), juce::dontSendNotification); + repaint(); + } JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Test2AudioProcessorEditor) };