Hello! Newbie here.
So, briefly I am trying to add a new component, having a lable inside, to my mainComponent class.
But no matter how much I try, when building It doesn’t appear on the main window! The sub-component gets shown when launched on its own (replacing mainComponent class with subComponent class on the main.cpp), but not when it is imported on the mainComponent.
Here is my code structure:
maincomponent.cpp:
#include "MainComponent.h"
MainComponent::MainComponent()
{
setSize (600, 400);
addAndMakeVisible (subComponent);
}
void MainComponent::paint (juce::Graphics&)
{ }
void MainComponent::resized()
{
subComponent.setBounds(100, 80, getWidth() - 110, 20);
}
subcomponent.h (Header only)
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
class subComponent : public juce::Component
{
public:
//==============================================================================
subComponent() : updateMessage("Loading...")
{
setSize (200, 200);
addAndMakeVisible(updater);
updater.setFont(juce::Font(16.0f, juce::Font::bold));
updater.setText(updateMessage, juce::dontSendNotification);
updater.setColour(juce::Label::textColourId, juce::Colours::orange);
updater.setJustificationType(juce::Justification::bottomLeft);
}
void paint (juce::Graphics& g) override {}
void resized() override
{
updater.setBounds(100, 80, getWidth() - 110, 20);
}
private:
juce::Label updater;
std::string updateMessage;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (setupper)
};
