Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

801 lines
24KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. const char* const Toolbar::toolbarDragDescriptor = "_toolbarItem_";
  16. //==============================================================================
  17. class Toolbar::Spacer : public ToolbarItemComponent
  18. {
  19. public:
  20. Spacer (int itemID, float sizeToUse, bool shouldDrawBar)
  21. : ToolbarItemComponent (itemID, {}, false),
  22. fixedSize (sizeToUse),
  23. drawBar (shouldDrawBar)
  24. {
  25. setWantsKeyboardFocus (false);
  26. }
  27. bool getToolbarItemSizes (int toolbarThickness, bool /*isToolbarVertical*/,
  28. int& preferredSize, int& minSize, int& maxSize) override
  29. {
  30. if (fixedSize <= 0)
  31. {
  32. preferredSize = toolbarThickness * 2;
  33. minSize = 4;
  34. maxSize = 32768;
  35. }
  36. else
  37. {
  38. maxSize = roundToInt (toolbarThickness * fixedSize);
  39. minSize = drawBar ? maxSize : jmin (4, maxSize);
  40. preferredSize = maxSize;
  41. if (getEditingMode() == editableOnPalette)
  42. preferredSize = maxSize = toolbarThickness / (drawBar ? 3 : 2);
  43. }
  44. return true;
  45. }
  46. void paintButtonArea (Graphics&, int, int, bool, bool) override
  47. {
  48. }
  49. void contentAreaChanged (const Rectangle<int>&) override
  50. {
  51. }
  52. int getResizeOrder() const noexcept
  53. {
  54. return fixedSize <= 0 ? 0 : 1;
  55. }
  56. void paint (Graphics& g) override
  57. {
  58. auto w = getWidth();
  59. auto h = getHeight();
  60. if (drawBar)
  61. {
  62. g.setColour (findColour (Toolbar::separatorColourId, true));
  63. auto thickness = 0.2f;
  64. if (isToolbarVertical())
  65. g.fillRect (w * 0.1f, h * (0.5f - thickness * 0.5f), w * 0.8f, h * thickness);
  66. else
  67. g.fillRect (w * (0.5f - thickness * 0.5f), h * 0.1f, w * thickness, h * 0.8f);
  68. }
  69. if (getEditingMode() != normalMode && ! drawBar)
  70. {
  71. g.setColour (findColour (Toolbar::separatorColourId, true));
  72. auto indentX = jmin (2, (w - 3) / 2);
  73. auto indentY = jmin (2, (h - 3) / 2);
  74. g.drawRect (indentX, indentY, w - indentX * 2, h - indentY * 2, 1);
  75. if (fixedSize <= 0)
  76. {
  77. float x1, y1, x2, y2, x3, y3, x4, y4, hw, hl;
  78. if (isToolbarVertical())
  79. {
  80. x1 = w * 0.5f;
  81. y1 = h * 0.4f;
  82. x2 = x1;
  83. y2 = indentX * 2.0f;
  84. x3 = x1;
  85. y3 = h * 0.6f;
  86. x4 = x1;
  87. y4 = h - y2;
  88. hw = w * 0.15f;
  89. hl = w * 0.2f;
  90. }
  91. else
  92. {
  93. x1 = w * 0.4f;
  94. y1 = h * 0.5f;
  95. x2 = indentX * 2.0f;
  96. y2 = y1;
  97. x3 = w * 0.6f;
  98. y3 = y1;
  99. x4 = w - x2;
  100. y4 = y1;
  101. hw = h * 0.15f;
  102. hl = h * 0.2f;
  103. }
  104. Path p;
  105. p.addArrow ({ x1, y1, x2, y2 }, 1.5f, hw, hl);
  106. p.addArrow ({ x3, y3, x4, y4 }, 1.5f, hw, hl);
  107. g.fillPath (p);
  108. }
  109. }
  110. }
  111. private:
  112. const float fixedSize;
  113. const bool drawBar;
  114. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Spacer)
  115. };
  116. //==============================================================================
  117. class Toolbar::MissingItemsComponent : public PopupMenu::CustomComponent
  118. {
  119. public:
  120. MissingItemsComponent (Toolbar& bar, int h)
  121. : PopupMenu::CustomComponent (true),
  122. owner (&bar),
  123. height (h)
  124. {
  125. for (int i = bar.items.size(); --i >= 0;)
  126. {
  127. auto* tc = bar.items.getUnchecked(i);
  128. if (dynamic_cast<Spacer*> (tc) == nullptr && ! tc->isVisible())
  129. {
  130. oldIndexes.insert (0, i);
  131. addAndMakeVisible (tc, 0);
  132. }
  133. }
  134. layout (400);
  135. }
  136. ~MissingItemsComponent() override
  137. {
  138. if (owner != nullptr)
  139. {
  140. for (int i = 0; i < getNumChildComponents(); ++i)
  141. {
  142. if (auto* tc = dynamic_cast<ToolbarItemComponent*> (getChildComponent (i)))
  143. {
  144. tc->setVisible (false);
  145. auto index = oldIndexes.removeAndReturn (i);
  146. owner->addChildComponent (tc, index);
  147. --i;
  148. }
  149. }
  150. owner->resized();
  151. }
  152. }
  153. void layout (const int preferredWidth)
  154. {
  155. const int indent = 8;
  156. auto x = indent;
  157. auto y = indent;
  158. int maxX = 0;
  159. for (auto* c : getChildren())
  160. {
  161. if (auto* tc = dynamic_cast<ToolbarItemComponent*> (c))
  162. {
  163. int preferredSize = 1, minSize = 1, maxSize = 1;
  164. if (tc->getToolbarItemSizes (height, false, preferredSize, minSize, maxSize))
  165. {
  166. if (x + preferredSize > preferredWidth && x > indent)
  167. {
  168. x = indent;
  169. y += height;
  170. }
  171. tc->setBounds (x, y, preferredSize, height);
  172. x += preferredSize;
  173. maxX = jmax (maxX, x);
  174. }
  175. }
  176. }
  177. setSize (maxX + 8, y + height + 8);
  178. }
  179. void getIdealSize (int& idealWidth, int& idealHeight) override
  180. {
  181. idealWidth = getWidth();
  182. idealHeight = getHeight();
  183. }
  184. private:
  185. Component::SafePointer<Toolbar> owner;
  186. const int height;
  187. Array<int> oldIndexes;
  188. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MissingItemsComponent)
  189. };
  190. //==============================================================================
  191. Toolbar::Toolbar()
  192. {
  193. missingItemsButton.reset (getLookAndFeel().createToolbarMissingItemsButton (*this));
  194. addChildComponent (missingItemsButton.get());
  195. missingItemsButton->setAlwaysOnTop (true);
  196. missingItemsButton->onClick = [this] { showMissingItems(); };
  197. }
  198. Toolbar::~Toolbar()
  199. {
  200. items.clear();
  201. }
  202. void Toolbar::setVertical (const bool shouldBeVertical)
  203. {
  204. if (vertical != shouldBeVertical)
  205. {
  206. vertical = shouldBeVertical;
  207. resized();
  208. }
  209. }
  210. void Toolbar::clear()
  211. {
  212. items.clear();
  213. resized();
  214. }
  215. ToolbarItemComponent* Toolbar::createItem (ToolbarItemFactory& factory, const int itemId)
  216. {
  217. if (itemId == ToolbarItemFactory::separatorBarId) return new Spacer (itemId, 0.1f, true);
  218. if (itemId == ToolbarItemFactory::spacerId) return new Spacer (itemId, 0.5f, false);
  219. if (itemId == ToolbarItemFactory::flexibleSpacerId) return new Spacer (itemId, 0.0f, false);
  220. return factory.createItem (itemId);
  221. }
  222. void Toolbar::addItemInternal (ToolbarItemFactory& factory,
  223. const int itemId,
  224. const int insertIndex)
  225. {
  226. // An ID can't be zero - this might indicate a mistake somewhere?
  227. jassert (itemId != 0);
  228. if (auto* tc = createItem (factory, itemId))
  229. {
  230. #if JUCE_DEBUG
  231. Array<int> allowedIds;
  232. factory.getAllToolbarItemIds (allowedIds);
  233. // If your factory can create an item for a given ID, it must also return
  234. // that ID from its getAllToolbarItemIds() method!
  235. jassert (allowedIds.contains (itemId));
  236. #endif
  237. items.insert (insertIndex, tc);
  238. addAndMakeVisible (tc, insertIndex);
  239. }
  240. }
  241. void Toolbar::addItem (ToolbarItemFactory& factory, int itemId, int insertIndex)
  242. {
  243. addItemInternal (factory, itemId, insertIndex);
  244. resized();
  245. }
  246. void Toolbar::addDefaultItems (ToolbarItemFactory& factoryToUse)
  247. {
  248. Array<int> ids;
  249. factoryToUse.getDefaultItemSet (ids);
  250. clear();
  251. for (auto i : ids)
  252. addItemInternal (factoryToUse, i, -1);
  253. resized();
  254. }
  255. void Toolbar::removeToolbarItem (const int itemIndex)
  256. {
  257. items.remove (itemIndex);
  258. resized();
  259. }
  260. ToolbarItemComponent* Toolbar::removeAndReturnItem (const int itemIndex)
  261. {
  262. if (auto* tc = items.removeAndReturn (itemIndex))
  263. {
  264. removeChildComponent (tc);
  265. resized();
  266. return tc;
  267. }
  268. return nullptr;
  269. }
  270. int Toolbar::getNumItems() const noexcept
  271. {
  272. return items.size();
  273. }
  274. int Toolbar::getItemId (const int itemIndex) const noexcept
  275. {
  276. if (auto* tc = getItemComponent (itemIndex))
  277. return tc->getItemId();
  278. return 0;
  279. }
  280. ToolbarItemComponent* Toolbar::getItemComponent (const int itemIndex) const noexcept
  281. {
  282. return items[itemIndex];
  283. }
  284. ToolbarItemComponent* Toolbar::getNextActiveComponent (int index, const int delta) const
  285. {
  286. for (;;)
  287. {
  288. index += delta;
  289. if (auto* tc = getItemComponent (index))
  290. {
  291. if (tc->isActive)
  292. return tc;
  293. }
  294. else
  295. {
  296. return nullptr;
  297. }
  298. }
  299. }
  300. void Toolbar::setStyle (const ToolbarItemStyle& newStyle)
  301. {
  302. if (toolbarStyle != newStyle)
  303. {
  304. toolbarStyle = newStyle;
  305. updateAllItemPositions (false);
  306. }
  307. }
  308. String Toolbar::toString() const
  309. {
  310. String s ("TB:");
  311. for (int i = 0; i < getNumItems(); ++i)
  312. s << getItemId(i) << ' ';
  313. return s.trimEnd();
  314. }
  315. bool Toolbar::restoreFromString (ToolbarItemFactory& factoryToUse,
  316. const String& savedVersion)
  317. {
  318. if (! savedVersion.startsWith ("TB:"))
  319. return false;
  320. StringArray tokens;
  321. tokens.addTokens (savedVersion.substring (3), false);
  322. clear();
  323. for (auto& t : tokens)
  324. addItemInternal (factoryToUse, t.getIntValue(), -1);
  325. resized();
  326. return true;
  327. }
  328. void Toolbar::paint (Graphics& g)
  329. {
  330. getLookAndFeel().paintToolbarBackground (g, getWidth(), getHeight(), *this);
  331. }
  332. int Toolbar::getThickness() const noexcept
  333. {
  334. return vertical ? getWidth() : getHeight();
  335. }
  336. int Toolbar::getLength() const noexcept
  337. {
  338. return vertical ? getHeight() : getWidth();
  339. }
  340. void Toolbar::setEditingActive (const bool active)
  341. {
  342. if (isEditingActive != active)
  343. {
  344. isEditingActive = active;
  345. updateAllItemPositions (false);
  346. }
  347. }
  348. //==============================================================================
  349. void Toolbar::resized()
  350. {
  351. updateAllItemPositions (false);
  352. }
  353. void Toolbar::updateAllItemPositions (bool animate)
  354. {
  355. if (getWidth() > 0 && getHeight() > 0)
  356. {
  357. StretchableObjectResizer resizer;
  358. for (auto* tc : items)
  359. {
  360. tc->setEditingMode (isEditingActive ? ToolbarItemComponent::editableOnToolbar
  361. : ToolbarItemComponent::normalMode);
  362. tc->setStyle (toolbarStyle);
  363. auto* spacer = dynamic_cast<Spacer*> (tc);
  364. int preferredSize = 1, minSize = 1, maxSize = 1;
  365. if (tc->getToolbarItemSizes (getThickness(), isVertical(),
  366. preferredSize, minSize, maxSize))
  367. {
  368. tc->isActive = true;
  369. resizer.addItem (preferredSize, minSize, maxSize,
  370. spacer != nullptr ? spacer->getResizeOrder() : 2);
  371. }
  372. else
  373. {
  374. tc->isActive = false;
  375. tc->setVisible (false);
  376. }
  377. }
  378. resizer.resizeToFit (getLength());
  379. int totalLength = 0;
  380. for (int i = 0; i < resizer.getNumItems(); ++i)
  381. totalLength += (int) resizer.getItemSize (i);
  382. const bool itemsOffTheEnd = totalLength > getLength();
  383. auto extrasButtonSize = getThickness() / 2;
  384. missingItemsButton->setSize (extrasButtonSize, extrasButtonSize);
  385. missingItemsButton->setVisible (itemsOffTheEnd);
  386. missingItemsButton->setEnabled (! isEditingActive);
  387. if (vertical)
  388. missingItemsButton->setCentrePosition (getWidth() / 2,
  389. getHeight() - 4 - extrasButtonSize / 2);
  390. else
  391. missingItemsButton->setCentrePosition (getWidth() - 4 - extrasButtonSize / 2,
  392. getHeight() / 2);
  393. auto maxLength = itemsOffTheEnd ? (vertical ? missingItemsButton->getY()
  394. : missingItemsButton->getX()) - 4
  395. : getLength();
  396. int pos = 0, activeIndex = 0;
  397. for (auto* tc : items)
  398. {
  399. if (tc->isActive)
  400. {
  401. auto size = (int) resizer.getItemSize (activeIndex++);
  402. Rectangle<int> newBounds;
  403. if (vertical)
  404. newBounds.setBounds (0, pos, getWidth(), size);
  405. else
  406. newBounds.setBounds (pos, 0, size, getHeight());
  407. auto& animator = Desktop::getInstance().getAnimator();
  408. if (animate)
  409. {
  410. animator.animateComponent (tc, newBounds, 1.0f, 200, false, 3.0, 0.0);
  411. }
  412. else
  413. {
  414. animator.cancelAnimation (tc, false);
  415. tc->setBounds (newBounds);
  416. }
  417. pos += size;
  418. tc->setVisible (pos <= maxLength
  419. && ((! tc->isBeingDragged)
  420. || tc->getEditingMode() == ToolbarItemComponent::editableOnPalette));
  421. }
  422. }
  423. }
  424. }
  425. //==============================================================================
  426. void Toolbar::showMissingItems()
  427. {
  428. jassert (missingItemsButton->isShowing());
  429. if (missingItemsButton->isShowing())
  430. {
  431. PopupMenu m;
  432. auto comp = std::make_unique<MissingItemsComponent> (*this, getThickness());
  433. m.addCustomItem (1, std::move (comp));
  434. m.showMenuAsync (PopupMenu::Options().withTargetComponent (missingItemsButton.get()));
  435. }
  436. }
  437. //==============================================================================
  438. bool Toolbar::isInterestedInDragSource (const SourceDetails& dragSourceDetails)
  439. {
  440. return dragSourceDetails.description == toolbarDragDescriptor && isEditingActive;
  441. }
  442. void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
  443. {
  444. if (auto* tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
  445. {
  446. if (! items.contains (tc))
  447. {
  448. if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
  449. {
  450. if (auto* palette = tc->findParentComponentOfClass<ToolbarItemPalette>())
  451. palette->replaceComponent (*tc);
  452. }
  453. else
  454. {
  455. jassert (tc->getEditingMode() == ToolbarItemComponent::editableOnToolbar);
  456. }
  457. items.add (tc);
  458. addChildComponent (tc);
  459. updateAllItemPositions (true);
  460. }
  461. auto& animator = Desktop::getInstance().getAnimator();
  462. for (int i = getNumItems(); --i >= 0;)
  463. {
  464. auto currentIndex = items.indexOf (tc);
  465. auto newIndex = currentIndex;
  466. auto dragObjectLeft = vertical ? (dragSourceDetails.localPosition.getY() - tc->dragOffsetY)
  467. : (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
  468. auto dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());
  469. auto current = animator.getComponentDestination (getChildComponent (newIndex));
  470. if (auto* prev = getNextActiveComponent (newIndex, -1))
  471. {
  472. auto previousPos = animator.getComponentDestination (prev);
  473. if (std::abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX()))
  474. < std::abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight())))
  475. {
  476. newIndex = getIndexOfChildComponent (prev);
  477. }
  478. }
  479. if (auto* next = getNextActiveComponent (newIndex, 1))
  480. {
  481. auto nextPos = animator.getComponentDestination (next);
  482. if (std::abs (dragObjectLeft - (vertical ? current.getY() : current.getX()))
  483. > std::abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight())))
  484. {
  485. newIndex = getIndexOfChildComponent (next) + 1;
  486. }
  487. }
  488. if (newIndex == currentIndex)
  489. break;
  490. items.removeObject (tc, false);
  491. removeChildComponent (tc);
  492. addChildComponent (tc, newIndex);
  493. items.insert (newIndex, tc);
  494. updateAllItemPositions (true);
  495. }
  496. }
  497. }
  498. void Toolbar::itemDragExit (const SourceDetails& dragSourceDetails)
  499. {
  500. if (auto* tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
  501. {
  502. if (isParentOf (tc))
  503. {
  504. items.removeObject (tc, false);
  505. removeChildComponent (tc);
  506. updateAllItemPositions (true);
  507. }
  508. }
  509. }
  510. void Toolbar::itemDropped (const SourceDetails& dragSourceDetails)
  511. {
  512. if (auto* tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
  513. tc->setState (Button::buttonNormal);
  514. }
  515. void Toolbar::mouseDown (const MouseEvent&) {}
  516. //==============================================================================
  517. class Toolbar::CustomisationDialog : public DialogWindow
  518. {
  519. public:
  520. CustomisationDialog (ToolbarItemFactory& factory, Toolbar& bar, int optionFlags)
  521. : DialogWindow (TRANS("Add/remove items from toolbar"), Colours::white, true, true),
  522. toolbar (bar)
  523. {
  524. setContentOwned (new CustomiserPanel (factory, toolbar, optionFlags), true);
  525. setResizable (true, true);
  526. setResizeLimits (400, 300, 1500, 1000);
  527. positionNearBar();
  528. }
  529. ~CustomisationDialog() override
  530. {
  531. toolbar.setEditingActive (false);
  532. }
  533. void closeButtonPressed() override
  534. {
  535. setVisible (false);
  536. }
  537. bool canModalEventBeSentToComponent (const Component* comp) override
  538. {
  539. return toolbar.isParentOf (comp)
  540. || dynamic_cast<const ToolbarItemComponent::ItemDragAndDropOverlayComponent*> (comp) != nullptr;
  541. }
  542. void positionNearBar()
  543. {
  544. auto screenSize = toolbar.getParentMonitorArea();
  545. auto pos = toolbar.getScreenPosition();
  546. const int gap = 8;
  547. if (toolbar.isVertical())
  548. {
  549. if (pos.x > screenSize.getCentreX())
  550. pos.x -= getWidth() - gap;
  551. else
  552. pos.x += toolbar.getWidth() + gap;
  553. }
  554. else
  555. {
  556. pos.x += (toolbar.getWidth() - getWidth()) / 2;
  557. if (pos.y > screenSize.getCentreY())
  558. pos.y -= getHeight() - gap;
  559. else
  560. pos.y += toolbar.getHeight() + gap;
  561. }
  562. setTopLeftPosition (pos);
  563. }
  564. private:
  565. Toolbar& toolbar;
  566. class CustomiserPanel : public Component
  567. {
  568. public:
  569. CustomiserPanel (ToolbarItemFactory& tbf, Toolbar& bar, int optionFlags)
  570. : factory (tbf), toolbar (bar), palette (tbf, bar),
  571. instructions ({}, TRANS ("You can drag the items above and drop them onto a toolbar to add them.")
  572. + "\n\n"
  573. + TRANS ("Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")),
  574. defaultButton (TRANS ("Restore to default set of items"))
  575. {
  576. addAndMakeVisible (palette);
  577. if ((optionFlags & (Toolbar::allowIconsOnlyChoice
  578. | Toolbar::allowIconsWithTextChoice
  579. | Toolbar::allowTextOnlyChoice)) != 0)
  580. {
  581. addAndMakeVisible (styleBox);
  582. styleBox.setEditableText (false);
  583. if ((optionFlags & Toolbar::allowIconsOnlyChoice) != 0) styleBox.addItem (TRANS("Show icons only"), 1);
  584. if ((optionFlags & Toolbar::allowIconsWithTextChoice) != 0) styleBox.addItem (TRANS("Show icons and descriptions"), 2);
  585. if ((optionFlags & Toolbar::allowTextOnlyChoice) != 0) styleBox.addItem (TRANS("Show descriptions only"), 3);
  586. int selectedStyle = 0;
  587. switch (bar.getStyle())
  588. {
  589. case Toolbar::iconsOnly: selectedStyle = 1; break;
  590. case Toolbar::iconsWithText: selectedStyle = 2; break;
  591. case Toolbar::textOnly: selectedStyle = 3; break;
  592. default: break;
  593. }
  594. styleBox.setSelectedId (selectedStyle);
  595. styleBox.onChange = [this] { updateStyle(); };
  596. }
  597. if ((optionFlags & Toolbar::showResetToDefaultsButton) != 0)
  598. {
  599. addAndMakeVisible (defaultButton);
  600. defaultButton.onClick = [this] { toolbar.addDefaultItems (factory); };
  601. }
  602. addAndMakeVisible (instructions);
  603. instructions.setFont (Font (13.0f));
  604. setSize (500, 300);
  605. }
  606. void updateStyle()
  607. {
  608. switch (styleBox.getSelectedId())
  609. {
  610. case 1: toolbar.setStyle (Toolbar::iconsOnly); break;
  611. case 2: toolbar.setStyle (Toolbar::iconsWithText); break;
  612. case 3: toolbar.setStyle (Toolbar::textOnly); break;
  613. default: break;
  614. }
  615. palette.resized(); // to make it update the styles
  616. }
  617. void paint (Graphics& g) override
  618. {
  619. Colour background;
  620. if (auto* dw = findParentComponentOfClass<DialogWindow>())
  621. background = dw->getBackgroundColour();
  622. g.setColour (background.contrasting().withAlpha (0.3f));
  623. g.fillRect (palette.getX(), palette.getBottom() - 1, palette.getWidth(), 1);
  624. }
  625. void resized() override
  626. {
  627. palette.setBounds (0, 0, getWidth(), getHeight() - 120);
  628. styleBox.setBounds (10, getHeight() - 110, 200, 22);
  629. defaultButton.changeWidthToFitText (22);
  630. defaultButton.setTopLeftPosition (240, getHeight() - 110);
  631. instructions.setBounds (10, getHeight() - 80, getWidth() - 20, 80);
  632. }
  633. private:
  634. ToolbarItemFactory& factory;
  635. Toolbar& toolbar;
  636. ToolbarItemPalette palette;
  637. Label instructions;
  638. ComboBox styleBox;
  639. TextButton defaultButton;
  640. };
  641. };
  642. void Toolbar::showCustomisationDialog (ToolbarItemFactory& factory, const int optionFlags)
  643. {
  644. setEditingActive (true);
  645. (new CustomisationDialog (factory, *this, optionFlags))
  646. ->enterModalState (true, nullptr, true);
  647. }
  648. } // namespace juce