Skip to content
Snippets Groups Projects
Commit 429acd3d authored by Per Lindgren's avatar Per Lindgren
Browse files

position as label

parent 775e39ed
No related branches found
No related tags found
No related merge requests found
...@@ -15,14 +15,21 @@ Test2AudioProcessorEditor::Test2AudioProcessorEditor(Test2AudioProcessor &p) ...@@ -15,14 +15,21 @@ Test2AudioProcessorEditor::Test2AudioProcessorEditor(Test2AudioProcessor &p)
{ {
// Make sure that before the constructor has finished, you've set the // Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be. // editor's size to whatever you need it to be.
addAndMakeVisible(positionLabel);
// m_flogger = std::unique_ptr<juce::FileLogger>(juce::FileLogger::createDateStampedLogger("foo", "mylog", ".txt", "Welcome to plugin")); 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); setResizable(true, true);
setResizeLimits(400, 300, 1024, 1024);
setSize(400, 300); setSize(400, 300);
} }
Test2AudioProcessorEditor::~Test2AudioProcessorEditor() Test2AudioProcessorEditor::~Test2AudioProcessorEditor()
{ {
stopTimer();
} }
//============================================================================== //==============================================================================
...@@ -33,10 +40,9 @@ void Test2AudioProcessorEditor::paint(juce::Graphics &g) ...@@ -33,10 +40,9 @@ void Test2AudioProcessorEditor::paint(juce::Graphics &g)
g.setColour(juce::Colours::white); g.setColour(juce::Colours::white);
g.setFont(15.0f); g.setFont(15.0f);
g.drawFittedText("Hello Per 10 !", getLocalBounds(), juce::Justification::centred, 1); g.drawFittedText("1) Position : " + std::to_string(processor.position), getLocalBounds(), juce::Justification::centred, 1);
g.drawFittedText("Hello Per 10 !", getLocalBounds(), juce::Justification::centred, 1); // if (processor.m_flogger)
if (processor.m_flogger) // processor.m_flogger->logMessage("paint called");
processor.m_flogger->logMessage("paint called");
} }
void Test2AudioProcessorEditor::resized() void Test2AudioProcessorEditor::resized()
...@@ -45,6 +51,7 @@ void Test2AudioProcessorEditor::resized() ...@@ -45,6 +51,7 @@ void Test2AudioProcessorEditor::resized()
// subcomponents in your editor.. // subcomponents in your editor..
auto bounds = getLocalBounds(); auto bounds = getLocalBounds();
positionLabel.setBounds(bounds.removeFromBottom(30).withSizeKeepingCentre(50, 24));
if (processor.m_flogger) if (processor.m_flogger)
processor.m_flogger->logMessage(bounds.toString()); processor.m_flogger->logMessage(bounds.toString());
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
//============================================================================== //==============================================================================
/** /**
*/ */
class Test2AudioProcessorEditor : public juce::AudioProcessorEditor class Test2AudioProcessorEditor : public juce::AudioProcessorEditor, private juce::Timer
{ {
public: public:
Test2AudioProcessorEditor(Test2AudioProcessor &); Test2AudioProcessorEditor(Test2AudioProcessor &);
...@@ -28,8 +28,19 @@ private: ...@@ -28,8 +28,19 @@ private:
// This reference is provided as a quick way for your editor to // This reference is provided as a quick way for your editor to
// access the processor object that created it. // access the processor object that created it.
Test2AudioProcessor &processor; Test2AudioProcessor &processor;
// is this the way
std::unique_ptr<juce::FileLogger> m_flogger; 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) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Test2AudioProcessorEditor)
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment