The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

723 lines
29KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. struct SliderHandler : public ComponentTypeHandler
  18. {
  19. SliderHandler()
  20. : ComponentTypeHandler ("Slider", "Slider", typeid (Slider), 150, 24)
  21. {
  22. registerColour (Slider::backgroundColourId, "background", "bkgcol");
  23. registerColour (Slider::thumbColourId, "thumb", "thumbcol");
  24. registerColour (Slider::trackColourId, "track", "trackcol");
  25. registerColour (Slider::rotarySliderFillColourId, "rotary fill", "rotarysliderfill");
  26. registerColour (Slider::rotarySliderOutlineColourId, "rotary outln", "rotaryslideroutline");
  27. registerColour (Slider::textBoxTextColourId, "textbox text", "textboxtext");
  28. registerColour (Slider::textBoxBackgroundColourId, "textbox bkgd", "textboxbkgd");
  29. registerColour (Slider::textBoxHighlightColourId, "textbox highlt", "textboxhighlight");
  30. registerColour (Slider::textBoxOutlineColourId, "textbox outln", "textboxoutline");
  31. }
  32. Component* createNewComponent (JucerDocument*) override
  33. {
  34. return new Slider ("new slider");
  35. }
  36. XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) override
  37. {
  38. XmlElement* e = ComponentTypeHandler::createXmlFor (comp, layout);
  39. Slider* s = dynamic_cast<Slider*> (comp);
  40. e->setAttribute ("min", s->getMinimum());
  41. e->setAttribute ("max", s->getMaximum());
  42. e->setAttribute ("int", s->getInterval());
  43. e->setAttribute ("style", sliderStyleToString (s->getSliderStyle()));
  44. e->setAttribute ("textBoxPos", textBoxPosToString (s->getTextBoxPosition()));
  45. e->setAttribute ("textBoxEditable", s->isTextBoxEditable());
  46. e->setAttribute ("textBoxWidth", s->getTextBoxWidth());
  47. e->setAttribute ("textBoxHeight", s->getTextBoxHeight());
  48. e->setAttribute ("skewFactor", s->getSkewFactor());
  49. e->setAttribute ("needsCallback", needsSliderListener (s));
  50. return e;
  51. }
  52. bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout) override
  53. {
  54. if (! ComponentTypeHandler::restoreFromXml (xml, comp, layout))
  55. return false;
  56. Slider* const s = dynamic_cast<Slider*> (comp);
  57. s->setRange (xml.getDoubleAttribute ("min", 0.0),
  58. xml.getDoubleAttribute ("max", 10.0),
  59. xml.getDoubleAttribute ("int", 0.0));
  60. s->setSliderStyle (sliderStringToStyle (xml.getStringAttribute ("style", "LinearHorizontal")));
  61. s->setTextBoxStyle (stringToTextBoxPos (xml.getStringAttribute ("textBoxPos", "TextBoxLeft")),
  62. ! xml.getBoolAttribute ("textBoxEditable", true),
  63. xml.getIntAttribute ("textBoxWidth", 80),
  64. xml.getIntAttribute ("textBoxHeight", 20));
  65. s->setSkewFactor (xml.getDoubleAttribute ("skewFactor", 1.0));
  66. setNeedsSliderListener (s, xml.getBoolAttribute ("needsCallback", true));
  67. return true;
  68. }
  69. String getCreationParameters (GeneratedCode&, Component* component) override
  70. {
  71. return quotedString (component->getName(), false);
  72. }
  73. void fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName) override
  74. {
  75. ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName);
  76. Slider* const s = dynamic_cast<Slider*> (component);
  77. String r;
  78. r << memberVariableName << "->setRange ("
  79. << s->getMinimum() << ", " << s->getMaximum() << ", " << s->getInterval()
  80. << ");\n"
  81. << memberVariableName << "->setSliderStyle (Slider::"
  82. << sliderStyleToString (s->getSliderStyle()) << ");\n"
  83. << memberVariableName << "->setTextBoxStyle (Slider::"
  84. << textBoxPosToString (s->getTextBoxPosition())
  85. << ", " << CodeHelpers::boolLiteral (! s->isTextBoxEditable())
  86. << ", " << s->getTextBoxWidth() << ", " << s->getTextBoxHeight() << ");\n"
  87. << getColourIntialisationCode (component, memberVariableName);
  88. if (needsSliderListener (component))
  89. r << memberVariableName << "->addListener (this);\n";
  90. if (s->getSkewFactor() != 1.0)
  91. r << memberVariableName << "->setSkewFactor (" << s->getSkewFactor() << ");\n";
  92. r << '\n';
  93. code.constructorCode += r;
  94. }
  95. void fillInGeneratedCode (Component* component, GeneratedCode& code) override
  96. {
  97. ComponentTypeHandler::fillInGeneratedCode (component, code);
  98. if (needsSliderListener (component))
  99. {
  100. String& callback = code.getCallbackCode ("public SliderListener",
  101. "void",
  102. "sliderValueChanged (Slider* sliderThatWasMoved)",
  103. true);
  104. if (callback.isNotEmpty())
  105. callback << "else ";
  106. const String memberVariableName (code.document->getComponentLayout()->getComponentMemberVariableName (component));
  107. const String userCodeComment ("UserSliderCode_" + memberVariableName);
  108. callback
  109. << "if (sliderThatWasMoved == " << memberVariableName
  110. << ")\n{\n //[" << userCodeComment << "] -- add your slider handling code here..\n //[/" << userCodeComment << "]\n}\n";
  111. }
  112. }
  113. void getEditableProperties (Component* component, JucerDocument& document, Array<PropertyComponent*>& props) override
  114. {
  115. ComponentTypeHandler::getEditableProperties (component, document, props);
  116. Slider* s = dynamic_cast<Slider*> (component);
  117. jassert (s != 0);
  118. props.add (new SliderRangeProperty (s, document, "minimum", 0));
  119. props.add (new SliderRangeProperty (s, document, "maximum", 1));
  120. props.add (new SliderRangeProperty (s, document, "interval", 2));
  121. props.add (new SliderTypeProperty (s, document));
  122. props.add (new SliderTextboxProperty (s, document));
  123. props.add (new SliderTextboxEditableProperty (s, document));
  124. props.add (new SliderTextboxSizeProperty (s, document, true));
  125. props.add (new SliderTextboxSizeProperty (s, document, false));
  126. props.add (new SliderSkewProperty (s, document));
  127. props.add (new SliderCallbackProperty (s, document));
  128. addColourProperties (component, document, props);
  129. }
  130. static bool needsSliderListener (Component* slider)
  131. {
  132. return slider->getProperties().getWithDefault ("generateListenerCallback", true);
  133. }
  134. static void setNeedsSliderListener (Component* slider, bool shouldDoCallback)
  135. {
  136. slider->getProperties().set ("generateListenerCallback", shouldDoCallback);
  137. }
  138. private:
  139. //==============================================================================
  140. struct SliderTypeProperty : public ComponentChoiceProperty<Slider>
  141. {
  142. SliderTypeProperty (Slider* slider, JucerDocument& doc)
  143. : ComponentChoiceProperty<Slider> ("type", slider, doc)
  144. {
  145. choices.add ("Linear Horizontal");
  146. choices.add ("Linear Vertical");
  147. choices.add ("Linear Bar");
  148. choices.add ("Rotary");
  149. choices.add ("Rotary HorizontalDrag");
  150. choices.add ("Rotary VerticalDrag");
  151. choices.add ("Rotary HorizontalVerticalDrag");
  152. choices.add ("Inc/Dec Buttons");
  153. choices.add ("Two Value Horizontal");
  154. choices.add ("Two Value Vertical");
  155. choices.add ("Three Value Horizontal");
  156. choices.add ("Three Value Vertical");
  157. }
  158. void setIndex (int newIndex) override
  159. {
  160. const Slider::SliderStyle types[] = { Slider::LinearHorizontal,
  161. Slider::LinearVertical,
  162. Slider::LinearBar,
  163. Slider::Rotary,
  164. Slider::RotaryHorizontalDrag,
  165. Slider::RotaryVerticalDrag,
  166. Slider::RotaryHorizontalVerticalDrag,
  167. Slider::IncDecButtons,
  168. Slider::TwoValueHorizontal,
  169. Slider::TwoValueVertical,
  170. Slider::ThreeValueHorizontal,
  171. Slider::ThreeValueVertical };
  172. if (newIndex >= 0 && newIndex < numElementsInArray (types))
  173. {
  174. document.perform (new SliderTypeChangeAction (component, *document.getComponentLayout(), types [newIndex]),
  175. "Change Slider style");
  176. }
  177. }
  178. int getIndex() const override
  179. {
  180. const Slider::SliderStyle types[] = { Slider::LinearHorizontal,
  181. Slider::LinearVertical,
  182. Slider::LinearBar,
  183. Slider::Rotary,
  184. Slider::RotaryHorizontalDrag,
  185. Slider::RotaryVerticalDrag,
  186. Slider::RotaryHorizontalVerticalDrag,
  187. Slider::IncDecButtons,
  188. Slider::TwoValueHorizontal,
  189. Slider::TwoValueVertical,
  190. Slider::ThreeValueHorizontal,
  191. Slider::ThreeValueVertical };
  192. for (int i = 0; i < numElementsInArray (types); ++i)
  193. if (types [i] == dynamic_cast<Slider*> (component)->getSliderStyle())
  194. return i;
  195. return -1;
  196. }
  197. private:
  198. struct SliderTypeChangeAction : public ComponentUndoableAction<Slider>
  199. {
  200. SliderTypeChangeAction (Slider* comp, ComponentLayout& l, Slider::SliderStyle newState_)
  201. : ComponentUndoableAction<Slider> (comp, l),
  202. newState (newState_)
  203. {
  204. oldState = comp->getSliderStyle();
  205. }
  206. bool perform() override
  207. {
  208. showCorrectTab();
  209. getComponent()->setSliderStyle (newState);
  210. changed();
  211. return true;
  212. }
  213. bool undo() override
  214. {
  215. showCorrectTab();
  216. getComponent()->setSliderStyle (oldState);
  217. changed();
  218. return true;
  219. }
  220. Slider::SliderStyle newState, oldState;
  221. };
  222. };
  223. //==============================================================================
  224. struct SliderTextboxProperty : public ComponentChoiceProperty<Slider>
  225. {
  226. SliderTextboxProperty (Slider* slider, JucerDocument& doc)
  227. : ComponentChoiceProperty<Slider> ("text position", slider, doc)
  228. {
  229. choices.add ("No text box");
  230. choices.add ("Text box on left");
  231. choices.add ("Text box on right");
  232. choices.add ("Text box above");
  233. choices.add ("Text box below");
  234. }
  235. void setIndex (int newIndex) override
  236. {
  237. const Slider::TextEntryBoxPosition types[] = { Slider::NoTextBox,
  238. Slider::TextBoxLeft,
  239. Slider::TextBoxRight,
  240. Slider::TextBoxAbove,
  241. Slider::TextBoxBelow };
  242. if (newIndex >= 0 && newIndex < numElementsInArray (types))
  243. {
  244. document.perform (new SliderTextBoxChangeAction (component, *document.getComponentLayout(), types [newIndex]),
  245. "Change Slider textbox");
  246. }
  247. }
  248. int getIndex() const override
  249. {
  250. const Slider::TextEntryBoxPosition types[] = { Slider::NoTextBox,
  251. Slider::TextBoxLeft,
  252. Slider::TextBoxRight,
  253. Slider::TextBoxAbove,
  254. Slider::TextBoxBelow };
  255. for (int i = 0; i < numElementsInArray (types); ++i)
  256. if (types [i] == component->getTextBoxPosition())
  257. return i;
  258. return -1;
  259. }
  260. private:
  261. struct SliderTextBoxChangeAction : public ComponentUndoableAction<Slider>
  262. {
  263. SliderTextBoxChangeAction (Slider* comp, ComponentLayout& l, Slider::TextEntryBoxPosition newState_)
  264. : ComponentUndoableAction<Slider> (comp, l),
  265. newState (newState_)
  266. {
  267. oldState = comp->getTextBoxPosition();
  268. }
  269. bool perform() override
  270. {
  271. showCorrectTab();
  272. getComponent()->setTextBoxStyle (newState,
  273. ! getComponent()->isTextBoxEditable(),
  274. getComponent()->getTextBoxWidth(),
  275. getComponent()->getTextBoxHeight());
  276. changed();
  277. return true;
  278. }
  279. bool undo() override
  280. {
  281. showCorrectTab();
  282. getComponent()->setTextBoxStyle (oldState,
  283. ! getComponent()->isTextBoxEditable(),
  284. getComponent()->getTextBoxWidth(),
  285. getComponent()->getTextBoxHeight());
  286. changed();
  287. return true;
  288. }
  289. Slider::TextEntryBoxPosition newState, oldState;
  290. };
  291. };
  292. //==============================================================================
  293. struct SliderTextboxEditableProperty : public ComponentBooleanProperty<Slider>
  294. {
  295. SliderTextboxEditableProperty (Slider* slider, JucerDocument& doc)
  296. : ComponentBooleanProperty<Slider> ("text box mode", "Editable", "Editable", slider, doc)
  297. {
  298. }
  299. void setState (bool newState) override
  300. {
  301. document.perform (new SliderEditableChangeAction (component, *document.getComponentLayout(), newState),
  302. "Change Slider editability");
  303. }
  304. bool getState() const override
  305. {
  306. return component->isTextBoxEditable();
  307. }
  308. private:
  309. struct SliderEditableChangeAction : public ComponentUndoableAction<Slider>
  310. {
  311. SliderEditableChangeAction (Slider* const comp, ComponentLayout& l, bool newState_)
  312. : ComponentUndoableAction<Slider> (comp, l),
  313. newState (newState_)
  314. {
  315. oldState = comp->isTextBoxEditable();
  316. }
  317. bool perform() override
  318. {
  319. showCorrectTab();
  320. getComponent()->setTextBoxIsEditable (newState);
  321. changed();
  322. return true;
  323. }
  324. bool undo() override
  325. {
  326. showCorrectTab();
  327. getComponent()->setTextBoxIsEditable (oldState);
  328. changed();
  329. return true;
  330. }
  331. bool newState, oldState;
  332. };
  333. };
  334. //==============================================================================
  335. struct SliderCallbackProperty : public ComponentBooleanProperty<Slider>
  336. {
  337. SliderCallbackProperty (Slider* s, JucerDocument& doc)
  338. : ComponentBooleanProperty<Slider> ("callback", "Generate SliderListener",
  339. "Generate SliderListener", s, doc)
  340. {
  341. }
  342. void setState (bool newState) override
  343. {
  344. document.perform (new SliderCallbackChangeAction (component, *document.getComponentLayout(), newState),
  345. "Change button callback");
  346. }
  347. bool getState() const override { return needsSliderListener (component); }
  348. struct SliderCallbackChangeAction : public ComponentUndoableAction<Slider>
  349. {
  350. SliderCallbackChangeAction (Slider* comp, ComponentLayout& l, bool newState_)
  351. : ComponentUndoableAction<Slider> (comp, l),
  352. newState (newState_)
  353. {
  354. oldState = needsSliderListener (comp);
  355. }
  356. bool perform() override
  357. {
  358. showCorrectTab();
  359. setNeedsSliderListener (getComponent(), newState);
  360. changed();
  361. return true;
  362. }
  363. bool undo() override
  364. {
  365. showCorrectTab();
  366. setNeedsSliderListener (getComponent(), oldState);
  367. changed();
  368. return true;
  369. }
  370. bool newState, oldState;
  371. };
  372. };
  373. //==============================================================================
  374. struct SliderTextboxSizeProperty : public ComponentTextProperty<Slider>
  375. {
  376. SliderTextboxSizeProperty (Slider* slider, JucerDocument& doc, bool isWidth_)
  377. : ComponentTextProperty<Slider> (isWidth_ ? "text box width" : "text box height",
  378. 12, false, slider, doc),
  379. isWidth (isWidth_)
  380. {
  381. }
  382. void setText (const String& newText) override
  383. {
  384. document.perform (new SliderBoxSizeChangeAction (component, *document.getComponentLayout(), isWidth, newText.getIntValue()),
  385. "Change Slider textbox size");
  386. }
  387. String getText() const override
  388. {
  389. return String (isWidth ? component->getTextBoxWidth()
  390. : component->getTextBoxHeight());
  391. }
  392. private:
  393. const bool isWidth;
  394. struct SliderBoxSizeChangeAction : public ComponentUndoableAction<Slider>
  395. {
  396. SliderBoxSizeChangeAction (Slider* const comp, ComponentLayout& l, bool isWidth_, int newSize_)
  397. : ComponentUndoableAction<Slider> (comp, l),
  398. isWidth (isWidth_),
  399. newSize (newSize_)
  400. {
  401. oldSize = isWidth ? comp->getTextBoxWidth()
  402. : comp->getTextBoxHeight();
  403. }
  404. bool perform() override
  405. {
  406. showCorrectTab();
  407. Slider& c = *getComponent();
  408. if (isWidth)
  409. c.setTextBoxStyle (c.getTextBoxPosition(),
  410. ! c.isTextBoxEditable(),
  411. newSize,
  412. c.getTextBoxHeight());
  413. else
  414. c.setTextBoxStyle (c.getTextBoxPosition(),
  415. ! c.isTextBoxEditable(),
  416. c.getTextBoxWidth(),
  417. newSize);
  418. changed();
  419. return true;
  420. }
  421. bool undo() override
  422. {
  423. showCorrectTab();
  424. Slider& c = *getComponent();
  425. if (isWidth)
  426. c.setTextBoxStyle (c.getTextBoxPosition(),
  427. ! c.isTextBoxEditable(),
  428. oldSize,
  429. c.getTextBoxHeight());
  430. else
  431. c.setTextBoxStyle (c.getTextBoxPosition(),
  432. ! c.isTextBoxEditable(),
  433. c.getTextBoxWidth(),
  434. oldSize);
  435. changed();
  436. return true;
  437. }
  438. bool isWidth;
  439. int newSize, oldSize;
  440. };
  441. };
  442. //==============================================================================
  443. struct SliderRangeProperty : public ComponentTextProperty<Slider>
  444. {
  445. SliderRangeProperty (Slider* slider, JucerDocument& doc,
  446. const String& name, int rangeParam_)
  447. : ComponentTextProperty<Slider> (name, 15, false, slider, doc),
  448. rangeParam (rangeParam_)
  449. {
  450. }
  451. void setText (const String& newText) override
  452. {
  453. double state [3];
  454. state [0] = component->getMinimum();
  455. state [1] = component->getMaximum();
  456. state [2] = component->getInterval();
  457. state [rangeParam] = newText.getDoubleValue();
  458. document.perform (new SliderRangeChangeAction (component, *document.getComponentLayout(), state),
  459. "Change Slider range");
  460. }
  461. String getText() const override
  462. {
  463. Slider* s = dynamic_cast<Slider*> (component);
  464. jassert (s != nullptr);
  465. switch (rangeParam)
  466. {
  467. case 0: return String (s->getMinimum());
  468. case 1: return String (s->getMaximum());
  469. case 2: return String (s->getInterval());
  470. default: jassertfalse; break;
  471. }
  472. return String::empty;
  473. }
  474. private:
  475. const int rangeParam;
  476. struct SliderRangeChangeAction : public ComponentUndoableAction<Slider>
  477. {
  478. SliderRangeChangeAction (Slider* comp, ComponentLayout& l, const double newState_[3])
  479. : ComponentUndoableAction<Slider> (comp, l)
  480. {
  481. newState [0] = newState_ [0];
  482. newState [1] = newState_ [1];
  483. newState [2] = newState_ [2];
  484. oldState [0] = comp->getMinimum();
  485. oldState [1] = comp->getMaximum();
  486. oldState [2] = comp->getInterval();
  487. }
  488. bool perform() override
  489. {
  490. showCorrectTab();
  491. getComponent()->setRange (newState[0], newState[1], newState[2]);
  492. changed();
  493. return true;
  494. }
  495. bool undo() override
  496. {
  497. showCorrectTab();
  498. getComponent()->setRange (oldState[0], oldState[1], oldState[2]);
  499. changed();
  500. return true;
  501. }
  502. double newState[3], oldState[3];
  503. };
  504. };
  505. //==============================================================================
  506. struct SliderSkewProperty : public ComponentTextProperty<Slider>
  507. {
  508. SliderSkewProperty (Slider* slider, JucerDocument& doc)
  509. : ComponentTextProperty<Slider> ("skew factor", 12, false, slider, doc)
  510. {
  511. }
  512. void setText (const String& newText) override
  513. {
  514. const double skew = jlimit (0.001, 1000.0, newText.getDoubleValue());
  515. document.perform (new SliderSkewChangeAction (component, *document.getComponentLayout(), skew),
  516. "Change Slider skew");
  517. }
  518. String getText() const override
  519. {
  520. Slider* s = dynamic_cast<Slider*> (component);
  521. jassert (s != 0);
  522. return String (s->getSkewFactor());
  523. }
  524. struct SliderSkewChangeAction : public ComponentUndoableAction<Slider>
  525. {
  526. SliderSkewChangeAction (Slider* comp, ComponentLayout& l, double newValue_)
  527. : ComponentUndoableAction<Slider> (comp, l)
  528. {
  529. newValue = newValue_;
  530. oldValue = comp->getSkewFactor();
  531. }
  532. bool perform() override
  533. {
  534. showCorrectTab();
  535. getComponent()->setSkewFactor (newValue);
  536. changed();
  537. return true;
  538. }
  539. bool undo() override
  540. {
  541. showCorrectTab();
  542. getComponent()->setSkewFactor (oldValue);
  543. changed();
  544. return true;
  545. }
  546. double newValue, oldValue;
  547. };
  548. };
  549. //==============================================================================
  550. static String sliderStyleToString (Slider::SliderStyle style)
  551. {
  552. switch (style)
  553. {
  554. case Slider::LinearHorizontal: return "LinearHorizontal";
  555. case Slider::LinearVertical: return "LinearVertical";
  556. case Slider::LinearBar: return "LinearBar";
  557. case Slider::Rotary: return "Rotary";
  558. case Slider::RotaryHorizontalDrag: return "RotaryHorizontalDrag";
  559. case Slider::RotaryVerticalDrag: return "RotaryVerticalDrag";
  560. case Slider::RotaryHorizontalVerticalDrag: return "RotaryHorizontalVerticalDrag";
  561. case Slider::IncDecButtons: return "IncDecButtons";
  562. case Slider::TwoValueHorizontal: return "TwoValueHorizontal";
  563. case Slider::TwoValueVertical: return "TwoValueVertical";
  564. case Slider::ThreeValueHorizontal: return "ThreeValueHorizontal";
  565. case Slider::ThreeValueVertical: return "ThreeValueVertical";
  566. default: jassertfalse; break;
  567. }
  568. return String::empty;
  569. }
  570. static Slider::SliderStyle sliderStringToStyle (const String& s)
  571. {
  572. if (s == "LinearHorizontal") return Slider::LinearHorizontal;
  573. if (s == "LinearVertical") return Slider::LinearVertical;
  574. if (s == "LinearBar") return Slider::LinearBar;
  575. if (s == "Rotary") return Slider::Rotary;
  576. if (s == "RotaryHorizontalDrag") return Slider::RotaryHorizontalDrag;
  577. if (s == "RotaryVerticalDrag") return Slider::RotaryVerticalDrag;
  578. if (s == "RotaryHorizontalVerticalDrag") return Slider::RotaryHorizontalVerticalDrag;
  579. if (s == "IncDecButtons") return Slider::IncDecButtons;
  580. if (s.startsWithIgnoreCase ("TwoValueHoriz")) return Slider::TwoValueHorizontal;
  581. if (s.startsWithIgnoreCase ("TwoValueVert")) return Slider::TwoValueVertical;
  582. if (s.startsWithIgnoreCase ("ThreeValueHoriz")) return Slider::ThreeValueHorizontal;
  583. if (s.startsWithIgnoreCase ("ThreeValueVert")) return Slider::ThreeValueVertical;
  584. jassertfalse;
  585. return Slider::LinearHorizontal;
  586. }
  587. static String textBoxPosToString (const Slider::TextEntryBoxPosition pos)
  588. {
  589. switch (pos)
  590. {
  591. case Slider::NoTextBox: return "NoTextBox";
  592. case Slider::TextBoxLeft: return "TextBoxLeft";
  593. case Slider::TextBoxRight: return "TextBoxRight";
  594. case Slider::TextBoxAbove: return "TextBoxAbove";
  595. case Slider::TextBoxBelow: return "TextBoxBelow";
  596. default: jassertfalse; break;
  597. }
  598. return String::empty;
  599. }
  600. static Slider::TextEntryBoxPosition stringToTextBoxPos (const String& s)
  601. {
  602. if (s == "NoTextBox") return Slider::NoTextBox;
  603. if (s == "TextBoxLeft") return Slider::TextBoxLeft;
  604. if (s == "TextBoxRight") return Slider::TextBoxRight;
  605. if (s == "TextBoxAbove") return Slider::TextBoxAbove;
  606. if (s == "TextBoxBelow") return Slider::TextBoxBelow;
  607. jassertfalse;
  608. return Slider::TextBoxLeft;
  609. }
  610. };