showModalDialog


#1

Using Juce latest tip
I think I found a bug when you try to call the DialogWindow::showModalDialog function using a DrawableImage as the content component. The DialogWindow appears to be sized correctly, it’s just not placing its content component in the right spot. The image’s upper left corner is set to the very upper left corner of the DialogWindow, rather than just below the title bar like it should be.

Using the same basic code the showModalDialog() function uses I was able to get it working how I wanted to by just adding a line to make it resize…

[code]
DrawableImage *drawableImg = new DrawableImage();
drawableImg->setImage(img);

DialogWindow *window = new TempDialogWindow(String(L"window"), Colours::white, true);
window->setContentComponent(drawableImg, true, true);
window->centreAroundComponent(NULL, window->getWidth(), window->getHeight());
window->setSize(drawableImg->getWidth(), drawableImg->getHeight() + window->getTitleBarHeight()); // Line that makes things work
window->runModalLoop();
delete window;[/code]


#2

Seems to work ok for me. Can you show me an example of some code that doesn’t work?


#3

This produces the problem for me…

[code]File topLevelDir = File::getCurrentWorkingDirectory().getParentDirectory().getParentDirectory();
Image inputSchematicImg = ImageCache::getFromFile(topLevelDir.getChildFile(String(“images\InputCardSchematic.png”)));
DrawableImage *drawableImg = new DrawableImage();
drawableImg->setImage(inputSchematicImg);

DialogWindow::showModalDialog(String(“Input Card Schematic”), drawableImg, NULL, Colours::white, true);[/code]


#4

ah… you can’t treat a DrawableImage like a normal component. With drawables, you’re only supposed to position them using their custom positioning methods, not with the normal setBounds() calls, so if you pass one as a content component, it won’t be handled correctly. There’s nothing wrong with the dialog window, it’s just not designed to know what to do with a Drawable.