void FileChooserDialogBox::centreWithDefaultSize (Component* componentToCentreAround) { Component* const previewComp = content->chooserComponent.getPreviewComponent(); centreAroundComponent (componentToCentreAround, previewComp != nullptr ? 400 + previewComp->getWidth() : 600, 500); }
PrefsPanel::PrefsPanel() : DialogWindow ("Jucer Preferences", Colour::greyLevel (0.92f), true) { PrefsTabComp* const p = new PrefsTabComp(); p->setSize (456, 510); setContentOwned (p, true); if (! restoreWindowStateFromString (prefsWindowPos)) centreAroundComponent (0, getWidth(), getHeight()); setResizable (true, true); setResizeLimits (400, 400, 1000, 800); }
DefaultDialogWindow (LaunchOptions& options) : DialogWindow (options.dialogTitle, options.dialogBackgroundColour, options.escapeKeyTriggersCloseButton, true) { setUsingNativeTitleBar (options.useNativeTitleBar); setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows()); if (options.content.willDeleteObject()) setContentOwned (options.content.release(), true); else setContentNonOwned (options.content.release(), true); centreAroundComponent (options.componentToCentreAround, getWidth(), getHeight()); setResizable (options.resizable, options.useBottomRightCornerResizer); }
TempDialogWindow (const String& title, Component* contentComponent_, Component* componentToCentreAround, const Colour& colour, const bool escapeKeyTriggersCloseButton_, const bool shouldBeResizable, const bool useBottomRightCornerResizer) : DialogWindow (title, colour, escapeKeyTriggersCloseButton_, true) { if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level setContentNonOwned (contentComponent_, true); centreAroundComponent (componentToCentreAround, getWidth(), getHeight()); setResizable (shouldBeResizable, useBottomRightCornerResizer); }
DefaultDialogWindow (LaunchOptions& options) : DialogWindow (options.dialogTitle, options.dialogBackgroundColour, options.escapeKeyTriggersCloseButton, true) { setUsingNativeTitleBar (options.useNativeTitleBar); if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level if (options.content.willDeleteObject()) setContentOwned (options.content.release(), true); else setContentNonOwned (options.content.release(), true); centreAroundComponent (options.componentToCentreAround, getWidth(), getHeight()); setResizable (options.resizable, options.useBottomRightCornerResizer); }
ShredderPluginEditor::ShredderPluginEditor(ShredderPlugin *_shredderPlugin, ShredderSlot *_shredderSlot) : DocumentWindow (String::empty, Colours::aliceblue, DocumentWindow::closeButton, true), shredderPlugin(_shredderPlugin), shredderSlot(_shredderSlot), shredderMidiSlot(0) { if (shredderPlugin->getLastPos().isEmpty()) { setContentComponent (shredderPlugin->getEditor(), true, true); centreAroundComponent (shredderSlot, getWidth(), getHeight()); } else { setBounds (shredderPlugin->getLastPos()); setContentComponent (shredderPlugin->getEditor(), true, false); } setName (shredderPlugin->getName()); setVisible (true); }
void AlertWindow::updateLayout (const bool onlyIncreaseSize) { const int titleH = 24; const int iconWidth = 80; const Font font (getLookAndFeel().getAlertWindowMessageFont()); const int wid = jmax (font.getStringWidth (text), font.getStringWidth (getName())); const int sw = (int) std::sqrt (font.getHeight() * wid); int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f)); const int edgeGap = 10; const int labelHeight = 18; int iconSpace = 0; AttributedString attributedText; attributedText.append (getName(), font.withHeight (font.getHeight() * 1.1f).boldened()); if (text.isNotEmpty()) attributedText.append ("\n\n" + text, font); attributedText.setColour (findColour (textColourId)); if (alertIconType == NoIcon) { attributedText.setJustification (Justification::centredTop); textLayout.createLayoutWithBalancedLineLengths (attributedText, (float) w); } else { attributedText.setJustification (Justification::topLeft); textLayout.createLayoutWithBalancedLineLengths (attributedText, (float) w); iconSpace = iconWidth; } w = jmax (350, (int) textLayout.getWidth() + iconSpace + edgeGap * 4); w = jmin (w, (int) (getParentWidth() * 0.7f)); const int textLayoutH = (int) textLayout.getHeight(); const int textBottom = 16 + titleH + textLayoutH; int h = textBottom; int buttonW = 40; int i; for (i = 0; i < buttons.size(); ++i) buttonW += 16 + buttons.getUnchecked(i)->getWidth(); w = jmax (buttonW, w); h += (textBoxes.size() + comboBoxes.size() + progressBars.size()) * 50; if (buttons.size() > 0) h += 20 + buttons.getUnchecked(0)->getHeight(); for (i = customComps.size(); --i >= 0;) { Component* c = customComps.getUnchecked(i); w = jmax (w, (c->getWidth() * 100) / 80); h += 10 + c->getHeight(); if (c->getName().isNotEmpty()) h += labelHeight; } for (i = textBlocks.size(); --i >= 0;) { const AlertTextComp* const ac = static_cast <const AlertTextComp*> (textBlocks.getUnchecked(i)); w = jmax (w, ac->getPreferredWidth()); } w = jmin (w, (int) (getParentWidth() * 0.7f)); for (i = textBlocks.size(); --i >= 0;) { AlertTextComp* const ac = static_cast <AlertTextComp*> (textBlocks.getUnchecked(i)); ac->updateLayout ((int) (w * 0.8f)); h += ac->getHeight() + 10; } h = jmin (getParentHeight() - 50, h); if (onlyIncreaseSize) { w = jmax (w, getWidth()); h = jmax (h, getHeight()); } if (! isVisible()) { centreAroundComponent (associatedComponent, w, h); } else { const int cx = getX() + getWidth() / 2; const int cy = getY() + getHeight() / 2; setBounds (cx - w / 2, cy - h / 2, w, h); } textArea.setBounds (edgeGap, edgeGap, w - (edgeGap * 2), h - edgeGap); const int spacer = 16; int totalWidth = -spacer; for (i = buttons.size(); --i >= 0;) totalWidth += buttons.getUnchecked(i)->getWidth() + spacer; int x = (w - totalWidth) / 2; int y = (int) (getHeight() * 0.95f); for (i = 0; i < buttons.size(); ++i) { TextButton* const c = buttons.getUnchecked(i); int ny = proportionOfHeight (0.95f) - c->getHeight(); c->setTopLeftPosition (x, ny); if (ny < y) y = ny; x += c->getWidth() + spacer; c->toFront (false); } y = textBottom; for (i = 0; i < allComps.size(); ++i) { Component* const c = allComps.getUnchecked(i); h = 22; const int comboIndex = comboBoxes.indexOf (dynamic_cast <ComboBox*> (c)); if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty()) y += labelHeight; const int tbIndex = textBoxes.indexOf (dynamic_cast <TextEditor*> (c)); if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty()) y += labelHeight; if (customComps.contains (c)) { if (c->getName().isNotEmpty()) y += labelHeight; c->setTopLeftPosition (proportionOfWidth (0.1f), y); h = c->getHeight(); } else if (textBlocks.contains (c)) { c->setTopLeftPosition ((getWidth() - c->getWidth()) / 2, y); h = c->getHeight(); } else { c->setBounds (proportionOfWidth (0.1f), y, proportionOfWidth (0.8f), h); } y += h + 10; } setWantsKeyboardFocus (getNumChildComponents() == 0); }
void FileChooserDialogBox::centreWithDefaultSize (Component* componentToCentreAround) { centreAroundComponent (componentToCentreAround, getDefaultWidth(), 500); }
/// Create dialog window for selecting a new GUI skin. /// /// @param editorWindow pointer to the plug-in GUI /// /// @param currentSkinFile file pointing to the currently used skin /// /// ### Exit values /// /// | %Value | %Result | /// | :----: | --------------------------------- | /// | 0 | window has been closed "by force" | /// | 1 | user has selected a skin | /// GenericWindowSkin::GenericWindowSkin(Component *editorWindow, const File ¤tSkinFile) : DocumentWindow("Select skin", Colours::white, 0, true) { // dialog window dimentsions int windowWidth = 150; int windowHeight = 0; // empty windows are boring, so let's prepare a space for some // window components setContentOwned(&contentComponent, false); // locate skin directory and fill list box model File fileSkinDirectory = currentSkinFile.getParentDirectory(); listBoxModel.fill(fileSkinDirectory); // set model for list box listBox.setModel(&listBoxModel); // calculate and set list box dimensions int listBoxWidth = windowWidth - 20; int listBoxHeight = listBoxModel.getNumRows() * listBox.getRowHeight() + 2; listBox.setBounds(10, 10, listBoxWidth, listBoxHeight); // set look of list box listBox.setColour(ListBox::outlineColourId, Colours::grey); listBox.setOutlineThickness(1); // disable multiple selections listBox.setMultipleSelectionEnabled(false); // select current skin in list box currentSkinName = currentSkinFile.getFileNameWithoutExtension(); int rowNumber = listBoxModel.getRow(currentSkinName); listBox.selectRow(rowNumber); // display list box contentComponent.addAndMakeVisible(listBox); // calculate dialog window height from height of list box windowHeight = listBoxHeight + 50; // create and position an "select" button buttonSelect.setButtonText("Select"); buttonSelect.setBounds(10, windowHeight - 30, 60, 20); buttonSelect.setColour(TextButton::buttonColourId, Colours::red); buttonSelect.setColour(TextButton::buttonOnColourId, Colours::red); // add "skin" window as button listener and display the button buttonSelect.addListener(this); contentComponent.addAndMakeVisible(buttonSelect); // create and position an "default" button buttonDefault.setButtonText("Default"); buttonDefault.setBounds(windowWidth - 70, windowHeight - 30, 60, 20); buttonDefault.setColour(TextButton::buttonColourId, Colours::yellow); buttonDefault.setColour(TextButton::buttonOnColourId, Colours::yellow); // add "skin" window as button listener and display the button buttonDefault.addListener(this); contentComponent.addAndMakeVisible(buttonDefault); // set window dimensions setSize(windowWidth, windowHeight + getTitleBarHeight()); // keep dialog window on top setAlwaysOnTop(true); // center window on editor centreAroundComponent(editorWindow, getWidth(), getHeight()); // this window does not have any transparent areas (increases // performance on redrawing) setOpaque(true); // finally, display window setVisible(true); }