Hello Everybody,
I’m new to Juce and I’m interested on this topic.
I’ve tried to reproduce what you are doing with the additional constraint that I want my overlaping window to be semi-transparent … My overlapping widget is a treecomponent. I would like to reproduce something like the CAD tree in CATIA:
It does note work and I don’t really understand why …
My application:
class JUCETestDemoApplication : public JUCEApplication
{
/* Important! NEVER embed objects directly inside your JUCEApplication class! Use
ONLY pointers to objects, which you should create during the initialise() method
(NOT in the constructor!) and delete in the shutdown() method (NOT in the
destructor!)
This is because the application object gets created before Juce has been properly
initialised, so any embedded objects would also get constructed too soon.
*/
TestDemoWindow* theTestMainWindow;
public:
//==============================================================================
JUCETestDemoApplication()
: theTestMainWindow (0)
{
// NEVER do anything in here that could involve any Juce function being called
// - leave all your startup tasks until the initialise() method.
}
~JUCETestDemoApplication()
{
// Your shutdown() method should already have done all the things necessary to
// clean up this app object, so you should never need to put anything in
// the destructor.
// Making any Juce calls in here could be very dangerous...
}
//==============================================================================
void initialise (const String& commandLine)
{
// just create the main window...
theTestMainWindow = new TestDemoWindow();
theTestMainWindow->centreWithSize (800, 600);
theTestMainWindow->setVisible (true);
theTestMainWindow->BuildContainer();
theTestMainWindow->BuildTreeComponent();
theTestMainWindow->BuildOpenGLWindow();
/* on return from this method, the app will go into its the main event
dispatch loop, and this will run until something calls
JUCEAppliction::quit().
In this case, JUCEAppliction::quit() will be called by the
demo window when the user clicks on its close button.
*/
}
void shutdown()
{
delete theTestMainWindow;
theTestMainWindow = 0;
}
//==============================================================================
const String getApplicationName()
{
return String("JUCE Test Demo");
}
const String getApplicationVersion()
{
return String("1.0");
}
bool moreThanOneInstanceAllowed()
{
return false;
}
void anotherInstanceStarted (const String& commandLine)
{
// This will get called if the user launches another copy of the app, but
// there's nothing that the demo app needs to do here.
}
private:
};
//==============================================================================
/*
This macro creates the application's main() function..
*/
START_JUCE_APPLICATION (JUCETestDemoApplication)
and the different components:
//==============================================================================
TestDemoWindow::TestDemoWindow()
: ResizableWindow ( String("JUCE Test!"), // TopLevelWindow
Colour((uint8)0x00,(uint8)0x00,(uint8)0x00,(uint8)0xff), //Colours::floralwhite,
true)
{
commandManager = new ApplicationCommandManager();
setResizable (false, false); // resizability is a property of ResizableWindow
commandManager->registerAllCommandsForTarget (JUCEApplication::getInstance());
// this lets the command manager use keypresses that arrive in our window to send
// out commands
addKeyListener (commandManager->getKeyMappings());
m_pContainer = NULL;
m_pTreeComponent = NULL;
m_pOpenGLDemo = NULL;
}
//==============================================================================
TestDemoWindow::~TestDemoWindow()
{
delete commandManager;
}
//==============================================================================
void TestDemoWindow::BuildOpenGLWindow()
{
m_pOpenGLDemo = new OpenGLDemo();
m_pOpenGLDemo->setBounds(0,0,getWidth(),getHeight()); //>setSize(getWidth(),getHeight());
m_pContainer->addAndMakeVisible(m_pOpenGLDemo);
m_pOpenGLDemo->toBack();
//m_pOpenGLDemo->setAlwaysOnTop(true);
//setContentComponent( pOpenGLDemo,
// false,
// true );
//addAndMakeVisible (new OpenGLDemo()); //createOpenGLDemo());
resized();
}
//==============================================================================
void TestDemoWindow::BuildTreeComponent()
{
m_pTreeComponent = new TreeTestComponent ();
m_pContainer->addAndMakeVisible(m_pTreeComponent);
m_pTreeComponent->addToDesktop(getDesktopWindowStyleFlags());
m_pTreeComponent->toFront(true); //setAlwaysOnTop(true);
//setContentComponent( TreeComponent,
// false,
// true );
m_pTreeComponent->resized();
}
//==============================================================================
void TestDemoWindow::BuildContainer()
{
m_pContainer = new Component();
m_pContainer->setSize(800,600);
//m_pContainer->setColour(TreeView::backgroundColourId, Colour(0xff000000));
m_pContainer->setVisible(true);
setContentComponent( m_pContainer,
false,
true );
resized();
}
//==============================================================================
Is it possible to have semi-transparent overlapping windows over OpenGL?
Did I make something wrong?
Thanks in advance for your help.
Glou