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.

juce_LookAndFeel_V2.cpp 126KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. namespace LookAndFeelHelpers
  22. {
  23. static Colour createBaseColour (Colour buttonColour,
  24. bool hasKeyboardFocus,
  25. bool isMouseOverButton,
  26. bool isButtonDown) noexcept
  27. {
  28. const float sat = hasKeyboardFocus ? 1.3f : 0.9f;
  29. const Colour baseColour (buttonColour.withMultipliedSaturation (sat));
  30. if (isButtonDown) return baseColour.contrasting (0.2f);
  31. if (isMouseOverButton) return baseColour.contrasting (0.1f);
  32. return baseColour;
  33. }
  34. static TextLayout layoutTooltipText (const String& text, Colour colour) noexcept
  35. {
  36. const float tooltipFontSize = 13.0f;
  37. const int maxToolTipWidth = 400;
  38. AttributedString s;
  39. s.setJustification (Justification::centred);
  40. s.append (text, Font (tooltipFontSize, Font::bold), colour);
  41. TextLayout tl;
  42. tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth);
  43. return tl;
  44. }
  45. }
  46. //==============================================================================
  47. LookAndFeel_V2::LookAndFeel_V2()
  48. {
  49. // initialise the standard set of colours..
  50. const uint32 textButtonColour = 0xffbbbbff;
  51. const uint32 textHighlightColour = 0x401111ee;
  52. const uint32 standardOutlineColour = 0xb2808080;
  53. static const uint32 standardColours[] =
  54. {
  55. TextButton::buttonColourId, textButtonColour,
  56. TextButton::buttonOnColourId, 0xff4444ff,
  57. TextButton::textColourOnId, 0xff000000,
  58. TextButton::textColourOffId, 0xff000000,
  59. ToggleButton::textColourId, 0xff000000,
  60. ToggleButton::tickColourId, 0xff000000,
  61. ToggleButton::tickDisabledColourId, 0xff808080,
  62. TextEditor::backgroundColourId, 0xffffffff,
  63. TextEditor::textColourId, 0xff000000,
  64. TextEditor::highlightColourId, textHighlightColour,
  65. TextEditor::highlightedTextColourId, 0xff000000,
  66. TextEditor::outlineColourId, 0x00000000,
  67. TextEditor::focusedOutlineColourId, textButtonColour,
  68. TextEditor::shadowColourId, 0x38000000,
  69. CaretComponent::caretColourId, 0xff000000,
  70. Label::backgroundColourId, 0x00000000,
  71. Label::textColourId, 0xff000000,
  72. Label::outlineColourId, 0x00000000,
  73. ScrollBar::backgroundColourId, 0x00000000,
  74. ScrollBar::thumbColourId, 0xffffffff,
  75. TreeView::linesColourId, 0x4c000000,
  76. TreeView::backgroundColourId, 0x00000000,
  77. TreeView::dragAndDropIndicatorColourId, 0x80ff0000,
  78. TreeView::selectedItemBackgroundColourId, 0x00000000,
  79. TreeView::oddItemsColourId, 0x00000000,
  80. TreeView::evenItemsColourId, 0x00000000,
  81. PopupMenu::backgroundColourId, 0xffffffff,
  82. PopupMenu::textColourId, 0xff000000,
  83. PopupMenu::headerTextColourId, 0xff000000,
  84. PopupMenu::highlightedTextColourId, 0xffffffff,
  85. PopupMenu::highlightedBackgroundColourId, 0x991111aa,
  86. ComboBox::buttonColourId, 0xffbbbbff,
  87. ComboBox::outlineColourId, standardOutlineColour,
  88. ComboBox::textColourId, 0xff000000,
  89. ComboBox::backgroundColourId, 0xffffffff,
  90. ComboBox::arrowColourId, 0x99000000,
  91. PropertyComponent::backgroundColourId, 0x66ffffff,
  92. PropertyComponent::labelTextColourId, 0xff000000,
  93. TextPropertyComponent::backgroundColourId, 0xffffffff,
  94. TextPropertyComponent::textColourId, 0xff000000,
  95. TextPropertyComponent::outlineColourId, standardOutlineColour,
  96. BooleanPropertyComponent::backgroundColourId, 0xffffffff,
  97. BooleanPropertyComponent::outlineColourId, standardOutlineColour,
  98. ListBox::backgroundColourId, 0xffffffff,
  99. ListBox::outlineColourId, standardOutlineColour,
  100. ListBox::textColourId, 0xff000000,
  101. Slider::backgroundColourId, 0x00000000,
  102. Slider::thumbColourId, textButtonColour,
  103. Slider::trackColourId, 0x7fffffff,
  104. Slider::rotarySliderFillColourId, 0x7f0000ff,
  105. Slider::rotarySliderOutlineColourId, 0x66000000,
  106. Slider::textBoxTextColourId, 0xff000000,
  107. Slider::textBoxBackgroundColourId, 0xffffffff,
  108. Slider::textBoxHighlightColourId, textHighlightColour,
  109. Slider::textBoxOutlineColourId, standardOutlineColour,
  110. ResizableWindow::backgroundColourId, 0xff777777,
  111. //DocumentWindow::textColourId, 0xff000000, // (this is deliberately not set)
  112. AlertWindow::backgroundColourId, 0xffededed,
  113. AlertWindow::textColourId, 0xff000000,
  114. AlertWindow::outlineColourId, 0xff666666,
  115. ProgressBar::backgroundColourId, 0xffeeeeee,
  116. ProgressBar::foregroundColourId, 0xffaaaaee,
  117. TooltipWindow::backgroundColourId, 0xffeeeebb,
  118. TooltipWindow::textColourId, 0xff000000,
  119. TooltipWindow::outlineColourId, 0x4c000000,
  120. TabbedComponent::backgroundColourId, 0x00000000,
  121. TabbedComponent::outlineColourId, 0xff777777,
  122. TabbedButtonBar::tabOutlineColourId, 0x80000000,
  123. TabbedButtonBar::frontOutlineColourId, 0x90000000,
  124. Toolbar::backgroundColourId, 0xfff6f8f9,
  125. Toolbar::separatorColourId, 0x4c000000,
  126. Toolbar::buttonMouseOverBackgroundColourId, 0x4c0000ff,
  127. Toolbar::buttonMouseDownBackgroundColourId, 0x800000ff,
  128. Toolbar::labelTextColourId, 0xff000000,
  129. Toolbar::editingModeOutlineColourId, 0xffff0000,
  130. DrawableButton::textColourId, 0xff000000,
  131. DrawableButton::textColourOnId, 0xff000000,
  132. DrawableButton::backgroundColourId, 0x00000000,
  133. DrawableButton::backgroundOnColourId, 0xaabbbbff,
  134. HyperlinkButton::textColourId, 0xcc1111ee,
  135. GroupComponent::outlineColourId, 0x66000000,
  136. GroupComponent::textColourId, 0xff000000,
  137. BubbleComponent::backgroundColourId, 0xeeeeeebb,
  138. BubbleComponent::outlineColourId, 0x77000000,
  139. TableHeaderComponent::textColourId, 0xff000000,
  140. TableHeaderComponent::backgroundColourId, 0xffe8ebf9,
  141. TableHeaderComponent::outlineColourId, 0x33000000,
  142. TableHeaderComponent::highlightColourId, 0x8899aadd,
  143. DirectoryContentsDisplayComponent::highlightColourId, textHighlightColour,
  144. DirectoryContentsDisplayComponent::textColourId, 0xff000000,
  145. 0x1000440, /*LassoComponent::lassoFillColourId*/ 0x66dddddd,
  146. 0x1000441, /*LassoComponent::lassoOutlineColourId*/ 0x99111111,
  147. 0x1005000, /*MidiKeyboardComponent::whiteNoteColourId*/ 0xffffffff,
  148. 0x1005001, /*MidiKeyboardComponent::blackNoteColourId*/ 0xff000000,
  149. 0x1005002, /*MidiKeyboardComponent::keySeparatorLineColourId*/ 0x66000000,
  150. 0x1005003, /*MidiKeyboardComponent::mouseOverKeyOverlayColourId*/ 0x80ffff00,
  151. 0x1005004, /*MidiKeyboardComponent::keyDownOverlayColourId*/ 0xffb6b600,
  152. 0x1005005, /*MidiKeyboardComponent::textLabelColourId*/ 0xff000000,
  153. 0x1005006, /*MidiKeyboardComponent::upDownButtonBackgroundColourId*/ 0xffd3d3d3,
  154. 0x1005007, /*MidiKeyboardComponent::upDownButtonArrowColourId*/ 0xff000000,
  155. 0x1005008, /*MidiKeyboardComponent::shadowColourId*/ 0x4c000000,
  156. 0x1004500, /*CodeEditorComponent::backgroundColourId*/ 0xffffffff,
  157. 0x1004502, /*CodeEditorComponent::highlightColourId*/ textHighlightColour,
  158. 0x1004503, /*CodeEditorComponent::defaultTextColourId*/ 0xff000000,
  159. 0x1004504, /*CodeEditorComponent::lineNumberBackgroundId*/ 0x44999999,
  160. 0x1004505, /*CodeEditorComponent::lineNumberTextId*/ 0x44000000,
  161. 0x1007000, /*ColourSelector::backgroundColourId*/ 0xffe5e5e5,
  162. 0x1007001, /*ColourSelector::labelTextColourId*/ 0xff000000,
  163. 0x100ad00, /*KeyMappingEditorComponent::backgroundColourId*/ 0x00000000,
  164. 0x100ad01, /*KeyMappingEditorComponent::textColourId*/ 0xff000000,
  165. FileSearchPathListComponent::backgroundColourId, 0xffffffff,
  166. FileChooserDialogBox::titleTextColourId, 0xff000000,
  167. };
  168. for (int i = 0; i < numElementsInArray (standardColours); i += 2)
  169. setColour ((int) standardColours [i], Colour ((uint32) standardColours [i + 1]));
  170. }
  171. LookAndFeel_V2::~LookAndFeel_V2() {}
  172. //==============================================================================
  173. void LookAndFeel_V2::drawButtonBackground (Graphics& g,
  174. Button& button,
  175. const Colour& backgroundColour,
  176. bool isMouseOverButton,
  177. bool isButtonDown)
  178. {
  179. const int width = button.getWidth();
  180. const int height = button.getHeight();
  181. const float outlineThickness = button.isEnabled() ? ((isButtonDown || isMouseOverButton) ? 1.2f : 0.7f) : 0.4f;
  182. const float halfThickness = outlineThickness * 0.5f;
  183. const float indentL = button.isConnectedOnLeft() ? 0.1f : halfThickness;
  184. const float indentR = button.isConnectedOnRight() ? 0.1f : halfThickness;
  185. const float indentT = button.isConnectedOnTop() ? 0.1f : halfThickness;
  186. const float indentB = button.isConnectedOnBottom() ? 0.1f : halfThickness;
  187. const Colour baseColour (LookAndFeelHelpers::createBaseColour (backgroundColour,
  188. button.hasKeyboardFocus (true),
  189. isMouseOverButton, isButtonDown)
  190. .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
  191. drawGlassLozenge (g,
  192. indentL,
  193. indentT,
  194. width - indentL - indentR,
  195. height - indentT - indentB,
  196. baseColour, outlineThickness, -1.0f,
  197. button.isConnectedOnLeft(),
  198. button.isConnectedOnRight(),
  199. button.isConnectedOnTop(),
  200. button.isConnectedOnBottom());
  201. }
  202. Font LookAndFeel_V2::getTextButtonFont (TextButton&, int buttonHeight)
  203. {
  204. return Font (jmin (15.0f, buttonHeight * 0.6f));
  205. }
  206. int LookAndFeel_V2::getTextButtonWidthToFitText (TextButton& b, int buttonHeight)
  207. {
  208. return getTextButtonFont (b, buttonHeight).getStringWidth (b.getButtonText()) + buttonHeight;
  209. }
  210. void LookAndFeel_V2::drawButtonText (Graphics& g, TextButton& button, bool /*isMouseOverButton*/, bool /*isButtonDown*/)
  211. {
  212. Font font (getTextButtonFont (button, button.getHeight()));
  213. g.setFont (font);
  214. g.setColour (button.findColour (button.getToggleState() ? TextButton::textColourOnId
  215. : TextButton::textColourOffId)
  216. .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
  217. const int yIndent = jmin (4, button.proportionOfHeight (0.3f));
  218. const int cornerSize = jmin (button.getHeight(), button.getWidth()) / 2;
  219. const int fontHeight = roundToInt (font.getHeight() * 0.6f);
  220. const int leftIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnLeft() ? 4 : 2));
  221. const int rightIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnRight() ? 4 : 2));
  222. const int textWidth = button.getWidth() - leftIndent - rightIndent;
  223. if (textWidth > 0)
  224. g.drawFittedText (button.getButtonText(),
  225. leftIndent, yIndent, textWidth, button.getHeight() - yIndent * 2,
  226. Justification::centred, 2);
  227. }
  228. void LookAndFeel_V2::drawTickBox (Graphics& g, Component& component,
  229. float x, float y, float w, float h,
  230. const bool ticked,
  231. const bool isEnabled,
  232. const bool isMouseOverButton,
  233. const bool isButtonDown)
  234. {
  235. const float boxSize = w * 0.7f;
  236. drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize,
  237. LookAndFeelHelpers::createBaseColour (component.findColour (TextButton::buttonColourId)
  238. .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f),
  239. true, isMouseOverButton, isButtonDown),
  240. isEnabled ? ((isButtonDown || isMouseOverButton) ? 1.1f : 0.5f) : 0.3f);
  241. if (ticked)
  242. {
  243. Path tick;
  244. tick.startNewSubPath (1.5f, 3.0f);
  245. tick.lineTo (3.0f, 6.0f);
  246. tick.lineTo (6.0f, 0.0f);
  247. g.setColour (component.findColour (isEnabled ? ToggleButton::tickColourId
  248. : ToggleButton::tickDisabledColourId));
  249. const AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f)
  250. .translated (x, y));
  251. g.strokePath (tick, PathStrokeType (2.5f), trans);
  252. }
  253. }
  254. void LookAndFeel_V2::drawToggleButton (Graphics& g, ToggleButton& button,
  255. bool isMouseOverButton, bool isButtonDown)
  256. {
  257. if (button.hasKeyboardFocus (true))
  258. {
  259. g.setColour (button.findColour (TextEditor::focusedOutlineColourId));
  260. g.drawRect (0, 0, button.getWidth(), button.getHeight());
  261. }
  262. float fontSize = jmin (15.0f, button.getHeight() * 0.75f);
  263. const float tickWidth = fontSize * 1.1f;
  264. drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
  265. tickWidth, tickWidth,
  266. button.getToggleState(),
  267. button.isEnabled(),
  268. isMouseOverButton,
  269. isButtonDown);
  270. g.setColour (button.findColour (ToggleButton::textColourId));
  271. g.setFont (fontSize);
  272. if (! button.isEnabled())
  273. g.setOpacity (0.5f);
  274. g.drawFittedText (button.getButtonText(),
  275. button.getLocalBounds().withTrimmedLeft (roundToInt (tickWidth) + 5)
  276. .withTrimmedRight (2),
  277. Justification::centredLeft, 10);
  278. }
  279. void LookAndFeel_V2::changeToggleButtonWidthToFitText (ToggleButton& button)
  280. {
  281. Font font (jmin (15.0f, button.getHeight() * 0.6f));
  282. const int tickWidth = jmin (24, button.getHeight());
  283. button.setSize (font.getStringWidth (button.getButtonText()) + tickWidth + 8,
  284. button.getHeight());
  285. }
  286. void LookAndFeel_V2::drawDrawableButton (Graphics& g, DrawableButton& button,
  287. bool /*isMouseOverButton*/, bool /*isButtonDown*/)
  288. {
  289. bool toggleState = button.getToggleState();
  290. g.fillAll (button.findColour (toggleState ? DrawableButton::backgroundOnColourId
  291. : DrawableButton::backgroundColourId));
  292. const int textH = (button.getStyle() == DrawableButton::ImageAboveTextLabel)
  293. ? jmin (16, button.proportionOfHeight (0.25f))
  294. : 0;
  295. if (textH > 0)
  296. {
  297. g.setFont ((float) textH);
  298. g.setColour (button.findColour (toggleState ? DrawableButton::textColourOnId
  299. : DrawableButton::textColourId)
  300. .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.4f));
  301. g.drawFittedText (button.getButtonText(),
  302. 2, button.getHeight() - textH - 1,
  303. button.getWidth() - 4, textH,
  304. Justification::centred, 1);
  305. }
  306. }
  307. //==============================================================================
  308. AlertWindow* LookAndFeel_V2::createAlertWindow (const String& title, const String& message,
  309. const String& button1, const String& button2, const String& button3,
  310. AlertWindow::AlertIconType iconType,
  311. int numButtons, Component* associatedComponent)
  312. {
  313. AlertWindow* aw = new AlertWindow (title, message, iconType, associatedComponent);
  314. if (numButtons == 1)
  315. {
  316. aw->addButton (button1, 0,
  317. KeyPress (KeyPress::escapeKey),
  318. KeyPress (KeyPress::returnKey));
  319. }
  320. else
  321. {
  322. const KeyPress button1ShortCut ((int) CharacterFunctions::toLowerCase (button1[0]), 0, 0);
  323. KeyPress button2ShortCut ((int) CharacterFunctions::toLowerCase (button2[0]), 0, 0);
  324. if (button1ShortCut == button2ShortCut)
  325. button2ShortCut = KeyPress();
  326. if (numButtons == 2)
  327. {
  328. aw->addButton (button1, 1, KeyPress (KeyPress::returnKey), button1ShortCut);
  329. aw->addButton (button2, 0, KeyPress (KeyPress::escapeKey), button2ShortCut);
  330. }
  331. else if (numButtons == 3)
  332. {
  333. aw->addButton (button1, 1, button1ShortCut);
  334. aw->addButton (button2, 2, button2ShortCut);
  335. aw->addButton (button3, 0, KeyPress (KeyPress::escapeKey));
  336. }
  337. }
  338. return aw;
  339. }
  340. void LookAndFeel_V2::drawAlertBox (Graphics& g, AlertWindow& alert,
  341. const Rectangle<int>& textArea, TextLayout& textLayout)
  342. {
  343. g.fillAll (alert.findColour (AlertWindow::backgroundColourId));
  344. int iconSpaceUsed = 0;
  345. const int iconWidth = 80;
  346. int iconSize = jmin (iconWidth + 50, alert.getHeight() + 20);
  347. if (alert.containsAnyExtraComponents() || alert.getNumButtons() > 2)
  348. iconSize = jmin (iconSize, textArea.getHeight() + 50);
  349. const Rectangle<int> iconRect (iconSize / -10, iconSize / -10,
  350. iconSize, iconSize);
  351. if (alert.getAlertType() != AlertWindow::NoIcon)
  352. {
  353. Path icon;
  354. uint32 colour;
  355. char character;
  356. if (alert.getAlertType() == AlertWindow::WarningIcon)
  357. {
  358. colour = 0x55ff5555;
  359. character = '!';
  360. icon.addTriangle (iconRect.getX() + iconRect.getWidth() * 0.5f, (float) iconRect.getY(),
  361. (float) iconRect.getRight(), (float) iconRect.getBottom(),
  362. (float) iconRect.getX(), (float) iconRect.getBottom());
  363. icon = icon.createPathWithRoundedCorners (5.0f);
  364. }
  365. else
  366. {
  367. colour = alert.getAlertType() == AlertWindow::InfoIcon ? (uint32) 0x605555ff : (uint32) 0x40b69900;
  368. character = alert.getAlertType() == AlertWindow::InfoIcon ? 'i' : '?';
  369. icon.addEllipse (iconRect.toFloat());
  370. }
  371. GlyphArrangement ga;
  372. ga.addFittedText (Font (iconRect.getHeight() * 0.9f, Font::bold),
  373. String::charToString ((juce_wchar) (uint8) character),
  374. (float) iconRect.getX(), (float) iconRect.getY(),
  375. (float) iconRect.getWidth(), (float) iconRect.getHeight(),
  376. Justification::centred, false);
  377. ga.createPath (icon);
  378. icon.setUsingNonZeroWinding (false);
  379. g.setColour (Colour (colour));
  380. g.fillPath (icon);
  381. iconSpaceUsed = iconWidth;
  382. }
  383. g.setColour (alert.findColour (AlertWindow::textColourId));
  384. textLayout.draw (g, Rectangle<int> (textArea.getX() + iconSpaceUsed,
  385. textArea.getY(),
  386. textArea.getWidth() - iconSpaceUsed,
  387. textArea.getHeight()).toFloat());
  388. g.setColour (alert.findColour (AlertWindow::outlineColourId));
  389. g.drawRect (0, 0, alert.getWidth(), alert.getHeight());
  390. }
  391. int LookAndFeel_V2::getAlertBoxWindowFlags()
  392. {
  393. return ComponentPeer::windowAppearsOnTaskbar
  394. | ComponentPeer::windowHasDropShadow;
  395. }
  396. Array<int> LookAndFeel_V2::getWidthsForTextButtons (AlertWindow&, const Array<TextButton*>& buttons)
  397. {
  398. const int n = buttons.size();
  399. Array<int> buttonWidths;
  400. const int buttonHeight = getAlertWindowButtonHeight();
  401. for (int i = 0; i < n; ++i)
  402. buttonWidths.add (getTextButtonWidthToFitText (*buttons.getReference (i), buttonHeight));
  403. return buttonWidths;
  404. }
  405. int LookAndFeel_V2::getAlertWindowButtonHeight()
  406. {
  407. return 28;
  408. }
  409. Font LookAndFeel_V2::getAlertWindowTitleFont()
  410. {
  411. Font messageFont = getAlertWindowMessageFont();
  412. return messageFont.withHeight (messageFont.getHeight() * 1.1f).boldened();
  413. }
  414. Font LookAndFeel_V2::getAlertWindowMessageFont()
  415. {
  416. return Font (15.0f);
  417. }
  418. Font LookAndFeel_V2::getAlertWindowFont()
  419. {
  420. return Font (12.0f);
  421. }
  422. //==============================================================================
  423. void LookAndFeel_V2::drawProgressBar (Graphics& g, ProgressBar& progressBar,
  424. int width, int height,
  425. double progress, const String& textToShow)
  426. {
  427. const Colour background (progressBar.findColour (ProgressBar::backgroundColourId));
  428. const Colour foreground (progressBar.findColour (ProgressBar::foregroundColourId));
  429. g.fillAll (background);
  430. if (progress >= 0.0f && progress < 1.0f)
  431. {
  432. drawGlassLozenge (g, 1.0f, 1.0f,
  433. (float) jlimit (0.0, width - 2.0, progress * (width - 2.0)),
  434. (float) (height - 2),
  435. foreground,
  436. 0.5f, 0.0f,
  437. true, true, true, true);
  438. }
  439. else
  440. {
  441. // spinning bar..
  442. g.setColour (foreground);
  443. const int stripeWidth = height * 2;
  444. const int position = (int) (Time::getMillisecondCounter() / 15) % stripeWidth;
  445. Path p;
  446. for (float x = (float) (- position); x < width + stripeWidth; x += stripeWidth)
  447. p.addQuadrilateral (x, 0.0f,
  448. x + stripeWidth * 0.5f, 0.0f,
  449. x, (float) height,
  450. x - stripeWidth * 0.5f, (float) height);
  451. Image im (Image::ARGB, width, height, true);
  452. {
  453. Graphics g2 (im);
  454. drawGlassLozenge (g2, 1.0f, 1.0f,
  455. (float) (width - 2),
  456. (float) (height - 2),
  457. foreground,
  458. 0.5f, 0.0f,
  459. true, true, true, true);
  460. }
  461. g.setTiledImageFill (im, 0, 0, 0.85f);
  462. g.fillPath (p);
  463. }
  464. if (textToShow.isNotEmpty())
  465. {
  466. g.setColour (Colour::contrasting (background, foreground));
  467. g.setFont (height * 0.6f);
  468. g.drawText (textToShow, 0, 0, width, height, Justification::centred, false);
  469. }
  470. }
  471. void LookAndFeel_V2::drawSpinningWaitAnimation (Graphics& g, const Colour& colour, int x, int y, int w, int h)
  472. {
  473. const float radius = jmin (w, h) * 0.4f;
  474. const float thickness = radius * 0.15f;
  475. Path p;
  476. p.addRoundedRectangle (radius * 0.4f, thickness * -0.5f,
  477. radius * 0.6f, thickness,
  478. thickness * 0.5f);
  479. const float cx = x + w * 0.5f;
  480. const float cy = y + h * 0.5f;
  481. const uint32 animationIndex = (Time::getMillisecondCounter() / (1000 / 10)) % 12;
  482. for (uint32 i = 0; i < 12; ++i)
  483. {
  484. const uint32 n = (i + 12 - animationIndex) % 12;
  485. g.setColour (colour.withMultipliedAlpha ((n + 1) / 12.0f));
  486. g.fillPath (p, AffineTransform::rotation (i * (float_Pi / 6.0f))
  487. .translated (cx, cy));
  488. }
  489. }
  490. bool LookAndFeel_V2::isProgressBarOpaque (ProgressBar& progressBar)
  491. {
  492. return progressBar.findColour (ProgressBar::backgroundColourId).isOpaque();
  493. }
  494. bool LookAndFeel_V2::areScrollbarButtonsVisible()
  495. {
  496. return true;
  497. }
  498. void LookAndFeel_V2::drawScrollbarButton (Graphics& g, ScrollBar& scrollbar,
  499. int width, int height, int buttonDirection,
  500. bool /*isScrollbarVertical*/,
  501. bool /*isMouseOverButton*/,
  502. bool isButtonDown)
  503. {
  504. Path p;
  505. if (buttonDirection == 0)
  506. p.addTriangle (width * 0.5f, height * 0.2f,
  507. width * 0.1f, height * 0.7f,
  508. width * 0.9f, height * 0.7f);
  509. else if (buttonDirection == 1)
  510. p.addTriangle (width * 0.8f, height * 0.5f,
  511. width * 0.3f, height * 0.1f,
  512. width * 0.3f, height * 0.9f);
  513. else if (buttonDirection == 2)
  514. p.addTriangle (width * 0.5f, height * 0.8f,
  515. width * 0.1f, height * 0.3f,
  516. width * 0.9f, height * 0.3f);
  517. else if (buttonDirection == 3)
  518. p.addTriangle (width * 0.2f, height * 0.5f,
  519. width * 0.7f, height * 0.1f,
  520. width * 0.7f, height * 0.9f);
  521. if (isButtonDown)
  522. g.setColour (scrollbar.findColour (ScrollBar::thumbColourId).contrasting (0.2f));
  523. else
  524. g.setColour (scrollbar.findColour (ScrollBar::thumbColourId));
  525. g.fillPath (p);
  526. g.setColour (Colour (0x80000000));
  527. g.strokePath (p, PathStrokeType (0.5f));
  528. }
  529. void LookAndFeel_V2::drawScrollbar (Graphics& g,
  530. ScrollBar& scrollbar,
  531. int x, int y,
  532. int width, int height,
  533. bool isScrollbarVertical,
  534. int thumbStartPosition,
  535. int thumbSize,
  536. bool /*isMouseOver*/,
  537. bool /*isMouseDown*/)
  538. {
  539. g.fillAll (scrollbar.findColour (ScrollBar::backgroundColourId));
  540. Path slotPath, thumbPath;
  541. const float slotIndent = jmin (width, height) > 15 ? 1.0f : 0.0f;
  542. const float slotIndentx2 = slotIndent * 2.0f;
  543. const float thumbIndent = slotIndent + 1.0f;
  544. const float thumbIndentx2 = thumbIndent * 2.0f;
  545. float gx1 = 0.0f, gy1 = 0.0f, gx2 = 0.0f, gy2 = 0.0f;
  546. if (isScrollbarVertical)
  547. {
  548. slotPath.addRoundedRectangle (x + slotIndent,
  549. y + slotIndent,
  550. width - slotIndentx2,
  551. height - slotIndentx2,
  552. (width - slotIndentx2) * 0.5f);
  553. if (thumbSize > 0)
  554. thumbPath.addRoundedRectangle (x + thumbIndent,
  555. thumbStartPosition + thumbIndent,
  556. width - thumbIndentx2,
  557. thumbSize - thumbIndentx2,
  558. (width - thumbIndentx2) * 0.5f);
  559. gx1 = (float) x;
  560. gx2 = x + width * 0.7f;
  561. }
  562. else
  563. {
  564. slotPath.addRoundedRectangle (x + slotIndent,
  565. y + slotIndent,
  566. width - slotIndentx2,
  567. height - slotIndentx2,
  568. (height - slotIndentx2) * 0.5f);
  569. if (thumbSize > 0)
  570. thumbPath.addRoundedRectangle (thumbStartPosition + thumbIndent,
  571. y + thumbIndent,
  572. thumbSize - thumbIndentx2,
  573. height - thumbIndentx2,
  574. (height - thumbIndentx2) * 0.5f);
  575. gy1 = (float) y;
  576. gy2 = y + height * 0.7f;
  577. }
  578. const Colour thumbColour (scrollbar.findColour (ScrollBar::thumbColourId));
  579. Colour trackColour1, trackColour2;
  580. if (scrollbar.isColourSpecified (ScrollBar::trackColourId)
  581. || isColourSpecified (ScrollBar::trackColourId))
  582. {
  583. trackColour1 = trackColour2 = scrollbar.findColour (ScrollBar::trackColourId);
  584. }
  585. else
  586. {
  587. trackColour1 = thumbColour.overlaidWith (Colour (0x44000000));
  588. trackColour2 = thumbColour.overlaidWith (Colour (0x19000000));
  589. }
  590. g.setGradientFill (ColourGradient (trackColour1, gx1, gy1,
  591. trackColour2, gx2, gy2, false));
  592. g.fillPath (slotPath);
  593. if (isScrollbarVertical)
  594. {
  595. gx1 = x + width * 0.6f;
  596. gx2 = (float) x + width;
  597. }
  598. else
  599. {
  600. gy1 = y + height * 0.6f;
  601. gy2 = (float) y + height;
  602. }
  603. g.setGradientFill (ColourGradient (Colours::transparentBlack,gx1, gy1,
  604. Colour (0x19000000), gx2, gy2, false));
  605. g.fillPath (slotPath);
  606. g.setColour (thumbColour);
  607. g.fillPath (thumbPath);
  608. g.setGradientFill (ColourGradient (Colour (0x10000000), gx1, gy1,
  609. Colours::transparentBlack, gx2, gy2, false));
  610. g.saveState();
  611. if (isScrollbarVertical)
  612. g.reduceClipRegion (x + width / 2, y, width, height);
  613. else
  614. g.reduceClipRegion (x, y + height / 2, width, height);
  615. g.fillPath (thumbPath);
  616. g.restoreState();
  617. g.setColour (Colour (0x4c000000));
  618. g.strokePath (thumbPath, PathStrokeType (0.4f));
  619. }
  620. ImageEffectFilter* LookAndFeel_V2::getScrollbarEffect()
  621. {
  622. return nullptr;
  623. }
  624. int LookAndFeel_V2::getMinimumScrollbarThumbSize (ScrollBar& scrollbar)
  625. {
  626. return jmin (scrollbar.getWidth(), scrollbar.getHeight()) * 2;
  627. }
  628. int LookAndFeel_V2::getDefaultScrollbarWidth()
  629. {
  630. return 18;
  631. }
  632. int LookAndFeel_V2::getScrollbarButtonSize (ScrollBar& scrollbar)
  633. {
  634. return 2 + (scrollbar.isVertical() ? scrollbar.getWidth()
  635. : scrollbar.getHeight());
  636. }
  637. //==============================================================================
  638. Path LookAndFeel_V2::getTickShape (const float height)
  639. {
  640. static const unsigned char tickShapeData[] =
  641. {
  642. 109,0,224,168,68,0,0,119,67,108,0,224,172,68,0,128,146,67,113,0,192,148,68,0,0,219,67,0,96,110,68,0,224,56,68,113,0,64,51,68,0,32,130,68,0,64,20,68,0,224,
  643. 162,68,108,0,128,3,68,0,128,168,68,113,0,128,221,67,0,192,175,68,0,0,207,67,0,32,179,68,113,0,0,201,67,0,224,173,68,0,0,181,67,0,224,161,68,108,0,128,168,67,
  644. 0,128,154,68,113,0,128,141,67,0,192,138,68,0,128,108,67,0,64,131,68,113,0,0,62,67,0,128,119,68,0,0,5,67,0,128,114,68,113,0,0,102,67,0,192,88,68,0,128,155,
  645. 67,0,192,88,68,113,0,0,190,67,0,192,88,68,0,128,232,67,0,224,131,68,108,0,128,246,67,0,192,139,68,113,0,64,33,68,0,128,87,68,0,0,93,68,0,224,26,68,113,0,
  646. 96,140,68,0,128,188,67,0,224,168,68,0,0,119,67,99,101
  647. };
  648. Path p;
  649. p.loadPathFromData (tickShapeData, sizeof (tickShapeData));
  650. p.scaleToFit (0, 0, height * 2.0f, height, true);
  651. return p;
  652. }
  653. Path LookAndFeel_V2::getCrossShape (const float height)
  654. {
  655. static const unsigned char crossShapeData[] =
  656. {
  657. 109,0,0,17,68,0,96,145,68,108,0,192,13,68,0,192,147,68,113,0,0,213,67,0,64,174,68,0,0,168,67,0,64,174,68,113,0,0,104,67,0,64,174,68,0,0,5,67,0,64,
  658. 153,68,113,0,0,18,67,0,64,153,68,0,0,24,67,0,64,153,68,113,0,0,135,67,0,64,153,68,0,128,207,67,0,224,130,68,108,0,0,220,67,0,0,126,68,108,0,0,204,67,
  659. 0,128,117,68,113,0,0,138,67,0,64,82,68,0,0,138,67,0,192,57,68,113,0,0,138,67,0,192,37,68,0,128,210,67,0,64,10,68,113,0,128,220,67,0,64,45,68,0,0,8,
  660. 68,0,128,78,68,108,0,192,14,68,0,0,87,68,108,0,64,20,68,0,0,80,68,113,0,192,57,68,0,0,32,68,0,128,88,68,0,0,32,68,113,0,64,112,68,0,0,32,68,0,
  661. 128,124,68,0,64,68,68,113,0,0,121,68,0,192,67,68,0,128,119,68,0,192,67,68,113,0,192,108,68,0,192,67,68,0,32,89,68,0,96,82,68,113,0,128,69,68,0,0,97,68,
  662. 0,0,56,68,0,64,115,68,108,0,64,49,68,0,128,124,68,108,0,192,55,68,0,96,129,68,113,0,0,92,68,0,224,146,68,0,192,129,68,0,224,146,68,113,0,64,110,68,0,64,
  663. 168,68,0,64,87,68,0,64,168,68,113,0,128,66,68,0,64,168,68,0,64,27,68,0,32,150,68,99,101
  664. };
  665. Path p;
  666. p.loadPathFromData (crossShapeData, sizeof (crossShapeData));
  667. p.scaleToFit (0, 0, height * 2.0f, height, true);
  668. return p;
  669. }
  670. //==============================================================================
  671. void LookAndFeel_V2::drawTreeviewPlusMinusBox (Graphics& g, const Rectangle<float>& area,
  672. Colour /*backgroundColour*/, bool isOpen, bool /*isMouseOver*/)
  673. {
  674. const int boxSize = roundToInt (jmin (16.0f, area.getWidth(), area.getHeight()) * 0.7f) | 1;
  675. const int x = ((int) area.getWidth() - boxSize) / 2 + (int) area.getX();
  676. const int y = ((int) area.getHeight() - boxSize) / 2 + (int) area.getY();
  677. Rectangle<float> boxArea ((float) x, (float) y, (float) boxSize, (float) boxSize);
  678. g.setColour (Colour (0xe5ffffff));
  679. g.fillRect (boxArea);
  680. g.setColour (Colour (0x80000000));
  681. g.drawRect (boxArea);
  682. const float size = boxSize / 2 + 1.0f;
  683. const float centre = (float) (boxSize / 2);
  684. g.fillRect (x + (boxSize - size) * 0.5f, y + centre, size, 1.0f);
  685. if (! isOpen)
  686. g.fillRect (x + centre, y + (boxSize - size) * 0.5f, 1.0f, size);
  687. }
  688. bool LookAndFeel_V2::areLinesDrawnForTreeView (TreeView&)
  689. {
  690. return true;
  691. }
  692. int LookAndFeel_V2::getTreeViewIndentSize (TreeView&)
  693. {
  694. return 24;
  695. }
  696. //==============================================================================
  697. void LookAndFeel_V2::drawBubble (Graphics& g, BubbleComponent& comp,
  698. const Point<float>& tip, const Rectangle<float>& body)
  699. {
  700. Path p;
  701. p.addBubble (body.reduced (0.5f), body.getUnion (Rectangle<float> (tip.x, tip.y, 1.0f, 1.0f)),
  702. tip, 5.0f, jmin (15.0f, body.getWidth() * 0.2f, body.getHeight() * 0.2f));
  703. g.setColour (comp.findColour (BubbleComponent::backgroundColourId));
  704. g.fillPath (p);
  705. g.setColour (comp.findColour (BubbleComponent::outlineColourId));
  706. g.strokePath (p, PathStrokeType (1.0f));
  707. }
  708. //==============================================================================
  709. Font LookAndFeel_V2::getPopupMenuFont()
  710. {
  711. return Font (17.0f);
  712. }
  713. void LookAndFeel_V2::getIdealPopupMenuItemSize (const String& text, const bool isSeparator,
  714. int standardMenuItemHeight, int& idealWidth, int& idealHeight)
  715. {
  716. if (isSeparator)
  717. {
  718. idealWidth = 50;
  719. idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight / 2 : 10;
  720. }
  721. else
  722. {
  723. Font font (getPopupMenuFont());
  724. if (standardMenuItemHeight > 0 && font.getHeight() > standardMenuItemHeight / 1.3f)
  725. font.setHeight (standardMenuItemHeight / 1.3f);
  726. idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight : roundToInt (font.getHeight() * 1.3f);
  727. idealWidth = font.getStringWidth (text) + idealHeight * 2;
  728. }
  729. }
  730. void LookAndFeel_V2::drawPopupMenuBackground (Graphics& g, int width, int height)
  731. {
  732. const Colour background (findColour (PopupMenu::backgroundColourId));
  733. g.fillAll (background);
  734. g.setColour (background.overlaidWith (Colour (0x2badd8e6)));
  735. for (int i = 0; i < height; i += 3)
  736. g.fillRect (0, i, width, 1);
  737. #if ! JUCE_MAC
  738. g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.6f));
  739. g.drawRect (0, 0, width, height);
  740. #endif
  741. }
  742. void LookAndFeel_V2::drawPopupMenuUpDownArrow (Graphics& g, int width, int height, bool isScrollUpArrow)
  743. {
  744. const Colour background (findColour (PopupMenu::backgroundColourId));
  745. g.setGradientFill (ColourGradient (background, 0.0f, height * 0.5f,
  746. background.withAlpha (0.0f),
  747. 0.0f, isScrollUpArrow ? ((float) height) : 0.0f,
  748. false));
  749. g.fillRect (1, 1, width - 2, height - 2);
  750. const float hw = width * 0.5f;
  751. const float arrowW = height * 0.3f;
  752. const float y1 = height * (isScrollUpArrow ? 0.6f : 0.3f);
  753. const float y2 = height * (isScrollUpArrow ? 0.3f : 0.6f);
  754. Path p;
  755. p.addTriangle (hw - arrowW, y1,
  756. hw + arrowW, y1,
  757. hw, y2);
  758. g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.5f));
  759. g.fillPath (p);
  760. }
  761. void LookAndFeel_V2::drawPopupMenuItem (Graphics& g, const Rectangle<int>& area,
  762. const bool isSeparator, const bool isActive,
  763. const bool isHighlighted, const bool isTicked,
  764. const bool hasSubMenu, const String& text,
  765. const String& shortcutKeyText,
  766. const Drawable* icon, const Colour* const textColourToUse)
  767. {
  768. if (isSeparator)
  769. {
  770. Rectangle<int> r (area.reduced (5, 0));
  771. r.removeFromTop (r.getHeight() / 2 - 1);
  772. g.setColour (Colour (0x33000000));
  773. g.fillRect (r.removeFromTop (1));
  774. g.setColour (Colour (0x66ffffff));
  775. g.fillRect (r.removeFromTop (1));
  776. }
  777. else
  778. {
  779. Colour textColour (findColour (PopupMenu::textColourId));
  780. if (textColourToUse != nullptr)
  781. textColour = *textColourToUse;
  782. Rectangle<int> r (area.reduced (1));
  783. if (isHighlighted)
  784. {
  785. g.setColour (findColour (PopupMenu::highlightedBackgroundColourId));
  786. g.fillRect (r);
  787. g.setColour (findColour (PopupMenu::highlightedTextColourId));
  788. }
  789. else
  790. {
  791. g.setColour (textColour);
  792. }
  793. if (! isActive)
  794. g.setOpacity (0.3f);
  795. Font font (getPopupMenuFont());
  796. const float maxFontHeight = area.getHeight() / 1.3f;
  797. if (font.getHeight() > maxFontHeight)
  798. font.setHeight (maxFontHeight);
  799. g.setFont (font);
  800. Rectangle<float> iconArea (r.removeFromLeft ((r.getHeight() * 5) / 4).reduced (3).toFloat());
  801. if (icon != nullptr)
  802. {
  803. icon->drawWithin (g, iconArea, RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
  804. }
  805. else if (isTicked)
  806. {
  807. const Path tick (getTickShape (1.0f));
  808. g.fillPath (tick, tick.getTransformToScaleToFit (iconArea, true));
  809. }
  810. if (hasSubMenu)
  811. {
  812. const float arrowH = 0.6f * getPopupMenuFont().getAscent();
  813. const float x = (float) r.removeFromRight ((int) arrowH).getX();
  814. const float halfH = (float) r.getCentreY();
  815. Path p;
  816. p.addTriangle (x, halfH - arrowH * 0.5f,
  817. x, halfH + arrowH * 0.5f,
  818. x + arrowH * 0.6f, halfH);
  819. g.fillPath (p);
  820. }
  821. r.removeFromRight (3);
  822. g.drawFittedText (text, r, Justification::centredLeft, 1);
  823. if (shortcutKeyText.isNotEmpty())
  824. {
  825. Font f2 (font);
  826. f2.setHeight (f2.getHeight() * 0.75f);
  827. f2.setHorizontalScale (0.95f);
  828. g.setFont (f2);
  829. g.drawText (shortcutKeyText, r, Justification::centredRight, true);
  830. }
  831. }
  832. }
  833. void LookAndFeel_V2::drawPopupMenuSectionHeader (Graphics& g, const Rectangle<int>& area, const String& sectionName)
  834. {
  835. g.setFont (getPopupMenuFont().boldened());
  836. g.setColour (findColour (PopupMenu::headerTextColourId));
  837. g.drawFittedText (sectionName,
  838. area.getX() + 12, area.getY(), area.getWidth() - 16, (int) (area.getHeight() * 0.8f),
  839. Justification::bottomLeft, 1);
  840. }
  841. //==============================================================================
  842. int LookAndFeel_V2::getMenuWindowFlags()
  843. {
  844. return ComponentPeer::windowHasDropShadow;
  845. }
  846. void LookAndFeel_V2::drawMenuBarBackground (Graphics& g, int width, int height, bool, MenuBarComponent& menuBar)
  847. {
  848. const Colour baseColour (LookAndFeelHelpers::createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId),
  849. false, false, false));
  850. if (menuBar.isEnabled())
  851. drawShinyButtonShape (g, -4.0f, 0.0f, width + 8.0f, (float) height,
  852. 0.0f, baseColour, 0.4f, true, true, true, true);
  853. else
  854. g.fillAll (baseColour);
  855. }
  856. Font LookAndFeel_V2::getMenuBarFont (MenuBarComponent& menuBar, int /*itemIndex*/, const String& /*itemText*/)
  857. {
  858. return Font (menuBar.getHeight() * 0.7f);
  859. }
  860. int LookAndFeel_V2::getMenuBarItemWidth (MenuBarComponent& menuBar, int itemIndex, const String& itemText)
  861. {
  862. return getMenuBarFont (menuBar, itemIndex, itemText)
  863. .getStringWidth (itemText) + menuBar.getHeight();
  864. }
  865. void LookAndFeel_V2::drawMenuBarItem (Graphics& g, int width, int height,
  866. int itemIndex, const String& itemText,
  867. bool isMouseOverItem, bool isMenuOpen,
  868. bool /*isMouseOverBar*/, MenuBarComponent& menuBar)
  869. {
  870. if (! menuBar.isEnabled())
  871. {
  872. g.setColour (menuBar.findColour (PopupMenu::textColourId)
  873. .withMultipliedAlpha (0.5f));
  874. }
  875. else if (isMenuOpen || isMouseOverItem)
  876. {
  877. g.fillAll (menuBar.findColour (PopupMenu::highlightedBackgroundColourId));
  878. g.setColour (menuBar.findColour (PopupMenu::highlightedTextColourId));
  879. }
  880. else
  881. {
  882. g.setColour (menuBar.findColour (PopupMenu::textColourId));
  883. }
  884. g.setFont (getMenuBarFont (menuBar, itemIndex, itemText));
  885. g.drawFittedText (itemText, 0, 0, width, height, Justification::centred, 1);
  886. }
  887. Component* LookAndFeel_V2::getParentComponentForMenuOptions (const PopupMenu::Options& options)
  888. {
  889. return options.getParentComponent();
  890. }
  891. void LookAndFeel_V2::preparePopupMenuWindow (Component&) {}
  892. bool LookAndFeel_V2::shouldPopupMenuScaleWithTargetComponent (const PopupMenu::Options&) { return true; }
  893. int LookAndFeel_V2::getPopupMenuBorderSize() { return 2; }
  894. //==============================================================================
  895. void LookAndFeel_V2::fillTextEditorBackground (Graphics& g, int /*width*/, int /*height*/, TextEditor& textEditor)
  896. {
  897. g.fillAll (textEditor.findColour (TextEditor::backgroundColourId));
  898. }
  899. void LookAndFeel_V2::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor)
  900. {
  901. if (textEditor.isEnabled())
  902. {
  903. if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly())
  904. {
  905. const int border = 2;
  906. g.setColour (textEditor.findColour (TextEditor::focusedOutlineColourId));
  907. g.drawRect (0, 0, width, height, border);
  908. g.setOpacity (1.0f);
  909. const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId).withMultipliedAlpha (0.75f));
  910. drawBevel (g, 0, 0, width, height + 2, border + 2, shadowColour, shadowColour);
  911. }
  912. else
  913. {
  914. g.setColour (textEditor.findColour (TextEditor::outlineColourId));
  915. g.drawRect (0, 0, width, height);
  916. g.setOpacity (1.0f);
  917. const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId));
  918. drawBevel (g, 0, 0, width, height + 2, 3, shadowColour, shadowColour);
  919. }
  920. }
  921. }
  922. CaretComponent* LookAndFeel_V2::createCaretComponent (Component* keyFocusOwner)
  923. {
  924. return new CaretComponent (keyFocusOwner);
  925. }
  926. //==============================================================================
  927. void LookAndFeel_V2::drawComboBox (Graphics& g, int width, int height, const bool isButtonDown,
  928. int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box)
  929. {
  930. g.fillAll (box.findColour (ComboBox::backgroundColourId));
  931. if (box.isEnabled() && box.hasKeyboardFocus (false))
  932. {
  933. g.setColour (box.findColour (ComboBox::buttonColourId));
  934. g.drawRect (0, 0, width, height, 2);
  935. }
  936. else
  937. {
  938. g.setColour (box.findColour (ComboBox::outlineColourId));
  939. g.drawRect (0, 0, width, height);
  940. }
  941. const float outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f;
  942. const Colour baseColour (LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId),
  943. box.hasKeyboardFocus (true),
  944. false, isButtonDown)
  945. .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f));
  946. drawGlassLozenge (g,
  947. buttonX + outlineThickness, buttonY + outlineThickness,
  948. buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f,
  949. baseColour, outlineThickness, -1.0f,
  950. true, true, true, true);
  951. if (box.isEnabled())
  952. {
  953. const float arrowX = 0.3f;
  954. const float arrowH = 0.2f;
  955. Path p;
  956. p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH),
  957. buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f,
  958. buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f);
  959. p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH),
  960. buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f,
  961. buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f);
  962. g.setColour (box.findColour (ComboBox::arrowColourId));
  963. g.fillPath (p);
  964. }
  965. }
  966. Font LookAndFeel_V2::getComboBoxFont (ComboBox& box)
  967. {
  968. return Font (jmin (15.0f, box.getHeight() * 0.85f));
  969. }
  970. Label* LookAndFeel_V2::createComboBoxTextBox (ComboBox&)
  971. {
  972. return new Label (String(), String());
  973. }
  974. void LookAndFeel_V2::positionComboBoxText (ComboBox& box, Label& label)
  975. {
  976. label.setBounds (1, 1,
  977. box.getWidth() + 3 - box.getHeight(),
  978. box.getHeight() - 2);
  979. label.setFont (getComboBoxFont (box));
  980. }
  981. //==============================================================================
  982. Font LookAndFeel_V2::getLabelFont (Label& label)
  983. {
  984. return label.getFont();
  985. }
  986. void LookAndFeel_V2::drawLabel (Graphics& g, Label& label)
  987. {
  988. g.fillAll (label.findColour (Label::backgroundColourId));
  989. if (! label.isBeingEdited())
  990. {
  991. const float alpha = label.isEnabled() ? 1.0f : 0.5f;
  992. const Font font (getLabelFont (label));
  993. g.setColour (label.findColour (Label::textColourId).withMultipliedAlpha (alpha));
  994. g.setFont (font);
  995. Rectangle<int> textArea (label.getBorderSize().subtractedFrom (label.getLocalBounds()));
  996. g.drawFittedText (label.getText(), textArea, label.getJustificationType(),
  997. jmax (1, (int) (textArea.getHeight() / font.getHeight())),
  998. label.getMinimumHorizontalScale());
  999. g.setColour (label.findColour (Label::outlineColourId).withMultipliedAlpha (alpha));
  1000. }
  1001. else if (label.isEnabled())
  1002. {
  1003. g.setColour (label.findColour (Label::outlineColourId));
  1004. }
  1005. g.drawRect (label.getLocalBounds());
  1006. }
  1007. //==============================================================================
  1008. void LookAndFeel_V2::drawLinearSliderBackground (Graphics& g, int x, int y, int width, int height,
  1009. float /*sliderPos*/,
  1010. float /*minSliderPos*/,
  1011. float /*maxSliderPos*/,
  1012. const Slider::SliderStyle /*style*/, Slider& slider)
  1013. {
  1014. const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2);
  1015. const Colour trackColour (slider.findColour (Slider::trackColourId));
  1016. const Colour gradCol1 (trackColour.overlaidWith (Colours::black.withAlpha (slider.isEnabled() ? 0.25f : 0.13f)));
  1017. const Colour gradCol2 (trackColour.overlaidWith (Colour (0x14000000)));
  1018. Path indent;
  1019. if (slider.isHorizontal())
  1020. {
  1021. const float iy = y + height * 0.5f - sliderRadius * 0.5f;
  1022. const float ih = sliderRadius;
  1023. g.setGradientFill (ColourGradient (gradCol1, 0.0f, iy,
  1024. gradCol2, 0.0f, iy + ih, false));
  1025. indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy,
  1026. width + sliderRadius, ih,
  1027. 5.0f);
  1028. }
  1029. else
  1030. {
  1031. const float ix = x + width * 0.5f - sliderRadius * 0.5f;
  1032. const float iw = sliderRadius;
  1033. g.setGradientFill (ColourGradient (gradCol1, ix, 0.0f,
  1034. gradCol2, ix + iw, 0.0f, false));
  1035. indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f,
  1036. iw, height + sliderRadius,
  1037. 5.0f);
  1038. }
  1039. g.fillPath (indent);
  1040. g.setColour (Colour (0x4c000000));
  1041. g.strokePath (indent, PathStrokeType (0.5f));
  1042. }
  1043. void LookAndFeel_V2::drawLinearSliderThumb (Graphics& g, int x, int y, int width, int height,
  1044. float sliderPos, float minSliderPos, float maxSliderPos,
  1045. const Slider::SliderStyle style, Slider& slider)
  1046. {
  1047. const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2);
  1048. Colour knobColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId),
  1049. slider.hasKeyboardFocus (false) && slider.isEnabled(),
  1050. slider.isMouseOverOrDragging() && slider.isEnabled(),
  1051. slider.isMouseButtonDown() && slider.isEnabled()));
  1052. const float outlineThickness = slider.isEnabled() ? 0.8f : 0.3f;
  1053. if (style == Slider::LinearHorizontal || style == Slider::LinearVertical)
  1054. {
  1055. float kx, ky;
  1056. if (style == Slider::LinearVertical)
  1057. {
  1058. kx = x + width * 0.5f;
  1059. ky = sliderPos;
  1060. }
  1061. else
  1062. {
  1063. kx = sliderPos;
  1064. ky = y + height * 0.5f;
  1065. }
  1066. drawGlassSphere (g,
  1067. kx - sliderRadius,
  1068. ky - sliderRadius,
  1069. sliderRadius * 2.0f,
  1070. knobColour, outlineThickness);
  1071. }
  1072. else
  1073. {
  1074. if (style == Slider::ThreeValueVertical)
  1075. {
  1076. drawGlassSphere (g, x + width * 0.5f - sliderRadius,
  1077. sliderPos - sliderRadius,
  1078. sliderRadius * 2.0f,
  1079. knobColour, outlineThickness);
  1080. }
  1081. else if (style == Slider::ThreeValueHorizontal)
  1082. {
  1083. drawGlassSphere (g,sliderPos - sliderRadius,
  1084. y + height * 0.5f - sliderRadius,
  1085. sliderRadius * 2.0f,
  1086. knobColour, outlineThickness);
  1087. }
  1088. if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical)
  1089. {
  1090. const float sr = jmin (sliderRadius, width * 0.4f);
  1091. drawGlassPointer (g, jmax (0.0f, x + width * 0.5f - sliderRadius * 2.0f),
  1092. minSliderPos - sliderRadius,
  1093. sliderRadius * 2.0f, knobColour, outlineThickness, 1);
  1094. drawGlassPointer (g, jmin (x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr,
  1095. sliderRadius * 2.0f, knobColour, outlineThickness, 3);
  1096. }
  1097. else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal)
  1098. {
  1099. const float sr = jmin (sliderRadius, height * 0.4f);
  1100. drawGlassPointer (g, minSliderPos - sr,
  1101. jmax (0.0f, y + height * 0.5f - sliderRadius * 2.0f),
  1102. sliderRadius * 2.0f, knobColour, outlineThickness, 2);
  1103. drawGlassPointer (g, maxSliderPos - sliderRadius,
  1104. jmin (y + height - sliderRadius * 2.0f, y + height * 0.5f),
  1105. sliderRadius * 2.0f, knobColour, outlineThickness, 4);
  1106. }
  1107. }
  1108. }
  1109. void LookAndFeel_V2::drawLinearSlider (Graphics& g, int x, int y, int width, int height,
  1110. float sliderPos, float minSliderPos, float maxSliderPos,
  1111. const Slider::SliderStyle style, Slider& slider)
  1112. {
  1113. g.fillAll (slider.findColour (Slider::backgroundColourId));
  1114. if (style == Slider::LinearBar || style == Slider::LinearBarVertical)
  1115. {
  1116. const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled();
  1117. Colour baseColour (LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId)
  1118. .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f),
  1119. false, isMouseOver,
  1120. isMouseOver || slider.isMouseButtonDown()));
  1121. drawShinyButtonShape (g,
  1122. (float) x,
  1123. style == Slider::LinearBarVertical ? sliderPos
  1124. : (float) y,
  1125. style == Slider::LinearBarVertical ? (float) width
  1126. : (sliderPos - x),
  1127. style == Slider::LinearBarVertical ? (height - sliderPos)
  1128. : (float) height, 0.0f,
  1129. baseColour,
  1130. slider.isEnabled() ? 0.9f : 0.3f,
  1131. true, true, true, true);
  1132. }
  1133. else
  1134. {
  1135. drawLinearSliderBackground (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
  1136. drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
  1137. }
  1138. }
  1139. int LookAndFeel_V2::getSliderThumbRadius (Slider& slider)
  1140. {
  1141. return jmin (7,
  1142. slider.getHeight() / 2,
  1143. slider.getWidth() / 2) + 2;
  1144. }
  1145. void LookAndFeel_V2::drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos,
  1146. const float rotaryStartAngle, const float rotaryEndAngle, Slider& slider)
  1147. {
  1148. const float radius = jmin (width / 2, height / 2) - 2.0f;
  1149. const float centreX = x + width * 0.5f;
  1150. const float centreY = y + height * 0.5f;
  1151. const float rx = centreX - radius;
  1152. const float ry = centreY - radius;
  1153. const float rw = radius * 2.0f;
  1154. const float angle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle);
  1155. const bool isMouseOver = slider.isMouseOverOrDragging() && slider.isEnabled();
  1156. if (radius > 12.0f)
  1157. {
  1158. if (slider.isEnabled())
  1159. g.setColour (slider.findColour (Slider::rotarySliderFillColourId).withAlpha (isMouseOver ? 1.0f : 0.7f));
  1160. else
  1161. g.setColour (Colour (0x80808080));
  1162. const float thickness = 0.7f;
  1163. {
  1164. Path filledArc;
  1165. filledArc.addPieSegment (rx, ry, rw, rw, rotaryStartAngle, angle, thickness);
  1166. g.fillPath (filledArc);
  1167. }
  1168. {
  1169. const float innerRadius = radius * 0.2f;
  1170. Path p;
  1171. p.addTriangle (-innerRadius, 0.0f,
  1172. 0.0f, -radius * thickness * 1.1f,
  1173. innerRadius, 0.0f);
  1174. p.addEllipse (-innerRadius, -innerRadius, innerRadius * 2.0f, innerRadius * 2.0f);
  1175. g.fillPath (p, AffineTransform::rotation (angle).translated (centreX, centreY));
  1176. }
  1177. if (slider.isEnabled())
  1178. g.setColour (slider.findColour (Slider::rotarySliderOutlineColourId));
  1179. else
  1180. g.setColour (Colour (0x80808080));
  1181. Path outlineArc;
  1182. outlineArc.addPieSegment (rx, ry, rw, rw, rotaryStartAngle, rotaryEndAngle, thickness);
  1183. outlineArc.closeSubPath();
  1184. g.strokePath (outlineArc, PathStrokeType (slider.isEnabled() ? (isMouseOver ? 2.0f : 1.2f) : 0.3f));
  1185. }
  1186. else
  1187. {
  1188. if (slider.isEnabled())
  1189. g.setColour (slider.findColour (Slider::rotarySliderFillColourId).withAlpha (isMouseOver ? 1.0f : 0.7f));
  1190. else
  1191. g.setColour (Colour (0x80808080));
  1192. Path p;
  1193. p.addEllipse (-0.4f * rw, -0.4f * rw, rw * 0.8f, rw * 0.8f);
  1194. PathStrokeType (rw * 0.1f).createStrokedPath (p, p);
  1195. p.addLineSegment (Line<float> (0.0f, 0.0f, 0.0f, -radius), rw * 0.2f);
  1196. g.fillPath (p, AffineTransform::rotation (angle).translated (centreX, centreY));
  1197. }
  1198. }
  1199. Button* LookAndFeel_V2::createSliderButton (Slider&, const bool isIncrement)
  1200. {
  1201. return new TextButton (isIncrement ? "+" : "-", String());
  1202. }
  1203. class LookAndFeel_V2::SliderLabelComp : public Label
  1204. {
  1205. public:
  1206. SliderLabelComp() : Label ({}, {}) {}
  1207. void mouseWheelMove (const MouseEvent&, const MouseWheelDetails&) override {}
  1208. };
  1209. Label* LookAndFeel_V2::createSliderTextBox (Slider& slider)
  1210. {
  1211. auto l = new SliderLabelComp();
  1212. l->setJustificationType (Justification::centred);
  1213. l->setKeyboardType (TextInputTarget::decimalKeyboard);
  1214. l->setColour (Label::textColourId, slider.findColour (Slider::textBoxTextColourId));
  1215. l->setColour (Label::backgroundColourId,
  1216. (slider.getSliderStyle() == Slider::LinearBar || slider.getSliderStyle() == Slider::LinearBarVertical)
  1217. ? Colours::transparentBlack
  1218. : slider.findColour (Slider::textBoxBackgroundColourId));
  1219. l->setColour (Label::outlineColourId, slider.findColour (Slider::textBoxOutlineColourId));
  1220. l->setColour (TextEditor::textColourId, slider.findColour (Slider::textBoxTextColourId));
  1221. l->setColour (TextEditor::backgroundColourId,
  1222. slider.findColour (Slider::textBoxBackgroundColourId)
  1223. .withAlpha ((slider.getSliderStyle() == Slider::LinearBar || slider.getSliderStyle() == Slider::LinearBarVertical)
  1224. ? 0.7f : 1.0f));
  1225. l->setColour (TextEditor::outlineColourId, slider.findColour (Slider::textBoxOutlineColourId));
  1226. l->setColour (TextEditor::highlightColourId, slider.findColour (Slider::textBoxHighlightColourId));
  1227. return l;
  1228. }
  1229. ImageEffectFilter* LookAndFeel_V2::getSliderEffect (Slider&)
  1230. {
  1231. return nullptr;
  1232. }
  1233. Font LookAndFeel_V2::getSliderPopupFont (Slider&)
  1234. {
  1235. return Font (15.0f, Font::bold);
  1236. }
  1237. int LookAndFeel_V2::getSliderPopupPlacement (Slider&)
  1238. {
  1239. return BubbleComponent::above
  1240. | BubbleComponent::below
  1241. | BubbleComponent::left
  1242. | BubbleComponent::right;
  1243. }
  1244. //==============================================================================
  1245. Slider::SliderLayout LookAndFeel_V2::getSliderLayout (Slider& slider)
  1246. {
  1247. // 1. compute the actually visible textBox size from the slider textBox size and some additional constraints
  1248. int minXSpace = 0;
  1249. int minYSpace = 0;
  1250. Slider::TextEntryBoxPosition textBoxPos = slider.getTextBoxPosition();
  1251. if (textBoxPos == Slider::TextBoxLeft || textBoxPos == Slider::TextBoxRight)
  1252. minXSpace = 30;
  1253. else
  1254. minYSpace = 15;
  1255. Rectangle<int> localBounds = slider.getLocalBounds();
  1256. const int textBoxWidth = jmax (0, jmin (slider.getTextBoxWidth(), localBounds.getWidth() - minXSpace));
  1257. const int textBoxHeight = jmax (0, jmin (slider.getTextBoxHeight(), localBounds.getHeight() - minYSpace));
  1258. Slider::SliderLayout layout;
  1259. // 2. set the textBox bounds
  1260. if (textBoxPos != Slider::NoTextBox)
  1261. {
  1262. if (slider.isBar())
  1263. {
  1264. layout.textBoxBounds = localBounds;
  1265. }
  1266. else
  1267. {
  1268. layout.textBoxBounds.setWidth (textBoxWidth);
  1269. layout.textBoxBounds.setHeight (textBoxHeight);
  1270. if (textBoxPos == Slider::TextBoxLeft) layout.textBoxBounds.setX (0);
  1271. else if (textBoxPos == Slider::TextBoxRight) layout.textBoxBounds.setX (localBounds.getWidth() - textBoxWidth);
  1272. else /* above or below -> centre horizontally */ layout.textBoxBounds.setX ((localBounds.getWidth() - textBoxWidth) / 2);
  1273. if (textBoxPos == Slider::TextBoxAbove) layout.textBoxBounds.setY (0);
  1274. else if (textBoxPos == Slider::TextBoxBelow) layout.textBoxBounds.setY (localBounds.getHeight() - textBoxHeight);
  1275. else /* left or right -> centre vertically */ layout.textBoxBounds.setY ((localBounds.getHeight() - textBoxHeight) / 2);
  1276. }
  1277. }
  1278. // 3. set the slider bounds
  1279. layout.sliderBounds = localBounds;
  1280. if (slider.isBar())
  1281. {
  1282. layout.sliderBounds.reduce (1, 1); // bar border
  1283. }
  1284. else
  1285. {
  1286. if (textBoxPos == Slider::TextBoxLeft) layout.sliderBounds.removeFromLeft (textBoxWidth);
  1287. else if (textBoxPos == Slider::TextBoxRight) layout.sliderBounds.removeFromRight (textBoxWidth);
  1288. else if (textBoxPos == Slider::TextBoxAbove) layout.sliderBounds.removeFromTop (textBoxHeight);
  1289. else if (textBoxPos == Slider::TextBoxBelow) layout.sliderBounds.removeFromBottom (textBoxHeight);
  1290. const int thumbIndent = getSliderThumbRadius (slider);
  1291. if (slider.isHorizontal()) layout.sliderBounds.reduce (thumbIndent, 0);
  1292. else if (slider.isVertical()) layout.sliderBounds.reduce (0, thumbIndent);
  1293. }
  1294. return layout;
  1295. }
  1296. //==============================================================================
  1297. Rectangle<int> LookAndFeel_V2::getTooltipBounds (const String& tipText, Point<int> screenPos, Rectangle<int> parentArea)
  1298. {
  1299. const TextLayout tl (LookAndFeelHelpers::layoutTooltipText (tipText, Colours::black));
  1300. const int w = (int) (tl.getWidth() + 14.0f);
  1301. const int h = (int) (tl.getHeight() + 6.0f);
  1302. return Rectangle<int> (screenPos.x > parentArea.getCentreX() ? screenPos.x - (w + 12) : screenPos.x + 24,
  1303. screenPos.y > parentArea.getCentreY() ? screenPos.y - (h + 6) : screenPos.y + 6,
  1304. w, h)
  1305. .constrainedWithin (parentArea);
  1306. }
  1307. void LookAndFeel_V2::drawTooltip (Graphics& g, const String& text, int width, int height)
  1308. {
  1309. g.fillAll (findColour (TooltipWindow::backgroundColourId));
  1310. #if ! JUCE_MAC // The mac windows already have a non-optional 1 pix outline, so don't double it here..
  1311. g.setColour (findColour (TooltipWindow::outlineColourId));
  1312. g.drawRect (0, 0, width, height, 1);
  1313. #endif
  1314. LookAndFeelHelpers::layoutTooltipText (text, findColour (TooltipWindow::textColourId))
  1315. .draw (g, Rectangle<float> ((float) width, (float) height));
  1316. }
  1317. //==============================================================================
  1318. Button* LookAndFeel_V2::createFilenameComponentBrowseButton (const String& text)
  1319. {
  1320. return new TextButton (text, TRANS("click to browse for a different file"));
  1321. }
  1322. void LookAndFeel_V2::layoutFilenameComponent (FilenameComponent& filenameComp,
  1323. ComboBox* filenameBox, Button* browseButton)
  1324. {
  1325. browseButton->setSize (80, filenameComp.getHeight());
  1326. if (auto* tb = dynamic_cast<TextButton*> (browseButton))
  1327. tb->changeWidthToFitText();
  1328. browseButton->setTopRightPosition (filenameComp.getWidth(), 0);
  1329. filenameBox->setBounds (0, 0, browseButton->getX(), filenameComp.getHeight());
  1330. }
  1331. //==============================================================================
  1332. void LookAndFeel_V2::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int>& area,
  1333. bool isMouseOver, bool /*isMouseDown*/,
  1334. ConcertinaPanel&, Component& panel)
  1335. {
  1336. g.fillAll (Colours::grey.withAlpha (isMouseOver ? 0.9f : 0.7f));
  1337. g.setColour (Colours::black.withAlpha (0.5f));
  1338. g.drawRect (area);
  1339. g.setColour (Colours::white);
  1340. g.setFont (Font (area.getHeight() * 0.7f).boldened());
  1341. g.drawFittedText (panel.getName(), 4, 0, area.getWidth() - 6, area.getHeight(), Justification::centredLeft, 1);
  1342. }
  1343. //==============================================================================
  1344. void LookAndFeel_V2::drawImageButton (Graphics& g, Image* image,
  1345. int imageX, int imageY, int imageW, int imageH,
  1346. const Colour& overlayColour,
  1347. float imageOpacity,
  1348. ImageButton& button)
  1349. {
  1350. if (! button.isEnabled())
  1351. imageOpacity *= 0.3f;
  1352. AffineTransform t = RectanglePlacement (RectanglePlacement::stretchToFit)
  1353. .getTransformToFit (image->getBounds().toFloat(),
  1354. Rectangle<int> (imageX, imageY, imageW, imageH).toFloat());
  1355. if (! overlayColour.isOpaque())
  1356. {
  1357. g.setOpacity (imageOpacity);
  1358. g.drawImageTransformed (*image, t, false);
  1359. }
  1360. if (! overlayColour.isTransparent())
  1361. {
  1362. g.setColour (overlayColour);
  1363. g.drawImageTransformed (*image, t, true);
  1364. }
  1365. }
  1366. //==============================================================================
  1367. void LookAndFeel_V2::drawCornerResizer (Graphics& g,
  1368. int w, int h,
  1369. bool /*isMouseOver*/,
  1370. bool /*isMouseDragging*/)
  1371. {
  1372. const float lineThickness = jmin (w, h) * 0.075f;
  1373. for (float i = 0.0f; i < 1.0f; i += 0.3f)
  1374. {
  1375. g.setColour (Colours::lightgrey);
  1376. g.drawLine (w * i,
  1377. h + 1.0f,
  1378. w + 1.0f,
  1379. h * i,
  1380. lineThickness);
  1381. g.setColour (Colours::darkgrey);
  1382. g.drawLine (w * i + lineThickness,
  1383. h + 1.0f,
  1384. w + 1.0f,
  1385. h * i + lineThickness,
  1386. lineThickness);
  1387. }
  1388. }
  1389. void LookAndFeel_V2::drawResizableFrame (Graphics& g, int w, int h, const BorderSize<int>& border)
  1390. {
  1391. if (! border.isEmpty())
  1392. {
  1393. const Rectangle<int> fullSize (0, 0, w, h);
  1394. const Rectangle<int> centreArea (border.subtractedFrom (fullSize));
  1395. g.saveState();
  1396. g.excludeClipRegion (centreArea);
  1397. g.setColour (Colour (0x50000000));
  1398. g.drawRect (fullSize);
  1399. g.setColour (Colour (0x19000000));
  1400. g.drawRect (centreArea.expanded (1, 1));
  1401. g.restoreState();
  1402. }
  1403. }
  1404. //==============================================================================
  1405. void LookAndFeel_V2::fillResizableWindowBackground (Graphics& g, int /*w*/, int /*h*/,
  1406. const BorderSize<int>& /*border*/, ResizableWindow& window)
  1407. {
  1408. g.fillAll (window.getBackgroundColour());
  1409. }
  1410. void LookAndFeel_V2::drawResizableWindowBorder (Graphics&, int /*w*/, int /*h*/,
  1411. const BorderSize<int>& /*border*/, ResizableWindow&)
  1412. {
  1413. }
  1414. void LookAndFeel_V2::drawDocumentWindowTitleBar (DocumentWindow& window, Graphics& g,
  1415. int w, int h, int titleSpaceX, int titleSpaceW,
  1416. const Image* icon, bool drawTitleTextOnLeft)
  1417. {
  1418. if (w * h == 0)
  1419. return;
  1420. const bool isActive = window.isActiveWindow();
  1421. g.setGradientFill (ColourGradient (window.getBackgroundColour(),
  1422. 0.0f, 0.0f,
  1423. window.getBackgroundColour().contrasting (isActive ? 0.15f : 0.05f),
  1424. 0.0f, (float) h, false));
  1425. g.fillAll();
  1426. Font font (h * 0.65f, Font::bold);
  1427. g.setFont (font);
  1428. int textW = font.getStringWidth (window.getName());
  1429. int iconW = 0;
  1430. int iconH = 0;
  1431. if (icon != nullptr)
  1432. {
  1433. iconH = (int) font.getHeight();
  1434. iconW = icon->getWidth() * iconH / icon->getHeight() + 4;
  1435. }
  1436. textW = jmin (titleSpaceW, textW + iconW);
  1437. int textX = drawTitleTextOnLeft ? titleSpaceX
  1438. : jmax (titleSpaceX, (w - textW) / 2);
  1439. if (textX + textW > titleSpaceX + titleSpaceW)
  1440. textX = titleSpaceX + titleSpaceW - textW;
  1441. if (icon != nullptr)
  1442. {
  1443. g.setOpacity (isActive ? 1.0f : 0.6f);
  1444. g.drawImageWithin (*icon, textX, (h - iconH) / 2, iconW, iconH,
  1445. RectanglePlacement::centred, false);
  1446. textX += iconW;
  1447. textW -= iconW;
  1448. }
  1449. if (window.isColourSpecified (DocumentWindow::textColourId) || isColourSpecified (DocumentWindow::textColourId))
  1450. g.setColour (window.findColour (DocumentWindow::textColourId));
  1451. else
  1452. g.setColour (window.getBackgroundColour().contrasting (isActive ? 0.7f : 0.4f));
  1453. g.drawText (window.getName(), textX, 0, textW, h, Justification::centredLeft, true);
  1454. }
  1455. //==============================================================================
  1456. class LookAndFeel_V2::GlassWindowButton : public Button
  1457. {
  1458. public:
  1459. GlassWindowButton (const String& name, Colour col,
  1460. const Path& normalShape_,
  1461. const Path& toggledShape_) noexcept
  1462. : Button (name),
  1463. colour (col),
  1464. normalShape (normalShape_),
  1465. toggledShape (toggledShape_)
  1466. {
  1467. }
  1468. //==============================================================================
  1469. void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override
  1470. {
  1471. float alpha = isMouseOverButton ? (isButtonDown ? 1.0f : 0.8f) : 0.55f;
  1472. if (! isEnabled())
  1473. alpha *= 0.5f;
  1474. float x = 0, y = 0, diam;
  1475. if (getWidth() < getHeight())
  1476. {
  1477. diam = (float) getWidth();
  1478. y = (getHeight() - getWidth()) * 0.5f;
  1479. }
  1480. else
  1481. {
  1482. diam = (float) getHeight();
  1483. y = (getWidth() - getHeight()) * 0.5f;
  1484. }
  1485. x += diam * 0.05f;
  1486. y += diam * 0.05f;
  1487. diam *= 0.9f;
  1488. g.setGradientFill (ColourGradient (Colour::greyLevel (0.9f).withAlpha (alpha), 0, y + diam,
  1489. Colour::greyLevel (0.6f).withAlpha (alpha), 0, y, false));
  1490. g.fillEllipse (x, y, diam, diam);
  1491. x += 2.0f;
  1492. y += 2.0f;
  1493. diam -= 4.0f;
  1494. LookAndFeel_V2::drawGlassSphere (g, x, y, diam, colour.withAlpha (alpha), 1.0f);
  1495. Path& p = getToggleState() ? toggledShape : normalShape;
  1496. const AffineTransform t (p.getTransformToScaleToFit (x + diam * 0.3f, y + diam * 0.3f,
  1497. diam * 0.4f, diam * 0.4f, true));
  1498. g.setColour (Colours::black.withAlpha (alpha * 0.6f));
  1499. g.fillPath (p, t);
  1500. }
  1501. private:
  1502. Colour colour;
  1503. Path normalShape, toggledShape;
  1504. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GlassWindowButton)
  1505. };
  1506. Button* LookAndFeel_V2::createDocumentWindowButton (int buttonType)
  1507. {
  1508. Path shape;
  1509. const float crossThickness = 0.25f;
  1510. if (buttonType == DocumentWindow::closeButton)
  1511. {
  1512. shape.addLineSegment (Line<float> (0.0f, 0.0f, 1.0f, 1.0f), crossThickness * 1.4f);
  1513. shape.addLineSegment (Line<float> (1.0f, 0.0f, 0.0f, 1.0f), crossThickness * 1.4f);
  1514. return new GlassWindowButton ("close", Colour (0xffdd1100), shape, shape);
  1515. }
  1516. if (buttonType == DocumentWindow::minimiseButton)
  1517. {
  1518. shape.addLineSegment (Line<float> (0.0f, 0.5f, 1.0f, 0.5f), crossThickness);
  1519. return new GlassWindowButton ("minimise", Colour (0xffaa8811), shape, shape);
  1520. }
  1521. if (buttonType == DocumentWindow::maximiseButton)
  1522. {
  1523. shape.addLineSegment (Line<float> (0.5f, 0.0f, 0.5f, 1.0f), crossThickness);
  1524. shape.addLineSegment (Line<float> (0.0f, 0.5f, 1.0f, 0.5f), crossThickness);
  1525. Path fullscreenShape;
  1526. fullscreenShape.startNewSubPath (45.0f, 100.0f);
  1527. fullscreenShape.lineTo (0.0f, 100.0f);
  1528. fullscreenShape.lineTo (0.0f, 0.0f);
  1529. fullscreenShape.lineTo (100.0f, 0.0f);
  1530. fullscreenShape.lineTo (100.0f, 45.0f);
  1531. fullscreenShape.addRectangle (45.0f, 45.0f, 100.0f, 100.0f);
  1532. PathStrokeType (30.0f).createStrokedPath (fullscreenShape, fullscreenShape);
  1533. return new GlassWindowButton ("maximise", Colour (0xff119911), shape, fullscreenShape);
  1534. }
  1535. jassertfalse;
  1536. return nullptr;
  1537. }
  1538. void LookAndFeel_V2::positionDocumentWindowButtons (DocumentWindow&,
  1539. int titleBarX, int titleBarY,
  1540. int titleBarW, int titleBarH,
  1541. Button* minimiseButton,
  1542. Button* maximiseButton,
  1543. Button* closeButton,
  1544. bool positionTitleBarButtonsOnLeft)
  1545. {
  1546. const int buttonW = titleBarH - titleBarH / 8;
  1547. int x = positionTitleBarButtonsOnLeft ? titleBarX + 4
  1548. : titleBarX + titleBarW - buttonW - buttonW / 4;
  1549. if (closeButton != nullptr)
  1550. {
  1551. closeButton->setBounds (x, titleBarY, buttonW, titleBarH);
  1552. x += positionTitleBarButtonsOnLeft ? buttonW : -(buttonW + buttonW / 4);
  1553. }
  1554. if (positionTitleBarButtonsOnLeft)
  1555. std::swap (minimiseButton, maximiseButton);
  1556. if (maximiseButton != nullptr)
  1557. {
  1558. maximiseButton->setBounds (x, titleBarY, buttonW, titleBarH);
  1559. x += positionTitleBarButtonsOnLeft ? buttonW : -buttonW;
  1560. }
  1561. if (minimiseButton != nullptr)
  1562. minimiseButton->setBounds (x, titleBarY, buttonW, titleBarH);
  1563. }
  1564. int LookAndFeel_V2::getDefaultMenuBarHeight()
  1565. {
  1566. return 24;
  1567. }
  1568. //==============================================================================
  1569. DropShadower* LookAndFeel_V2::createDropShadowerForComponent (Component*)
  1570. {
  1571. return new DropShadower (DropShadow (Colours::black.withAlpha (0.4f), 10, Point<int> (0, 2)));
  1572. }
  1573. //==============================================================================
  1574. void LookAndFeel_V2::drawStretchableLayoutResizerBar (Graphics& g, int w, int h,
  1575. bool /*isVerticalBar*/,
  1576. bool isMouseOver,
  1577. bool isMouseDragging)
  1578. {
  1579. float alpha = 0.5f;
  1580. if (isMouseOver || isMouseDragging)
  1581. {
  1582. g.fillAll (Colour (0x190000ff));
  1583. alpha = 1.0f;
  1584. }
  1585. const float cx = w * 0.5f;
  1586. const float cy = h * 0.5f;
  1587. const float cr = jmin (w, h) * 0.4f;
  1588. g.setGradientFill (ColourGradient (Colours::white.withAlpha (alpha), cx + cr * 0.1f, cy + cr,
  1589. Colours::black.withAlpha (alpha), cx, cy - cr * 4.0f,
  1590. true));
  1591. g.fillEllipse (cx - cr, cy - cr, cr * 2.0f, cr * 2.0f);
  1592. }
  1593. //==============================================================================
  1594. void LookAndFeel_V2::drawGroupComponentOutline (Graphics& g, int width, int height,
  1595. const String& text, const Justification& position,
  1596. GroupComponent& group)
  1597. {
  1598. const float textH = 15.0f;
  1599. const float indent = 3.0f;
  1600. const float textEdgeGap = 4.0f;
  1601. float cs = 5.0f;
  1602. Font f (textH);
  1603. Path p;
  1604. float x = indent;
  1605. float y = f.getAscent() - 3.0f;
  1606. float w = jmax (0.0f, width - x * 2.0f);
  1607. float h = jmax (0.0f, height - y - indent);
  1608. cs = jmin (cs, w * 0.5f, h * 0.5f);
  1609. const float cs2 = 2.0f * cs;
  1610. float textW = text.isEmpty() ? 0 : jlimit (0.0f, jmax (0.0f, w - cs2 - textEdgeGap * 2), f.getStringWidth (text) + textEdgeGap * 2.0f);
  1611. float textX = cs + textEdgeGap;
  1612. if (position.testFlags (Justification::horizontallyCentred))
  1613. textX = cs + (w - cs2 - textW) * 0.5f;
  1614. else if (position.testFlags (Justification::right))
  1615. textX = w - cs - textW - textEdgeGap;
  1616. p.startNewSubPath (x + textX + textW, y);
  1617. p.lineTo (x + w - cs, y);
  1618. p.addArc (x + w - cs2, y, cs2, cs2, 0, float_Pi * 0.5f);
  1619. p.lineTo (x + w, y + h - cs);
  1620. p.addArc (x + w - cs2, y + h - cs2, cs2, cs2, float_Pi * 0.5f, float_Pi);
  1621. p.lineTo (x + cs, y + h);
  1622. p.addArc (x, y + h - cs2, cs2, cs2, float_Pi, float_Pi * 1.5f);
  1623. p.lineTo (x, y + cs);
  1624. p.addArc (x, y, cs2, cs2, float_Pi * 1.5f, float_Pi * 2.0f);
  1625. p.lineTo (x + textX, y);
  1626. const float alpha = group.isEnabled() ? 1.0f : 0.5f;
  1627. g.setColour (group.findColour (GroupComponent::outlineColourId)
  1628. .withMultipliedAlpha (alpha));
  1629. g.strokePath (p, PathStrokeType (2.0f));
  1630. g.setColour (group.findColour (GroupComponent::textColourId)
  1631. .withMultipliedAlpha (alpha));
  1632. g.setFont (f);
  1633. g.drawText (text,
  1634. roundToInt (x + textX), 0,
  1635. roundToInt (textW),
  1636. roundToInt (textH),
  1637. Justification::centred, true);
  1638. }
  1639. //==============================================================================
  1640. int LookAndFeel_V2::getTabButtonOverlap (int tabDepth)
  1641. {
  1642. return 1 + tabDepth / 3;
  1643. }
  1644. int LookAndFeel_V2::getTabButtonSpaceAroundImage()
  1645. {
  1646. return 4;
  1647. }
  1648. int LookAndFeel_V2::getTabButtonBestWidth (TabBarButton& button, int tabDepth)
  1649. {
  1650. int width = Font (tabDepth * 0.6f).getStringWidth (button.getButtonText().trim())
  1651. + getTabButtonOverlap (tabDepth) * 2;
  1652. if (auto* extraComponent = button.getExtraComponent())
  1653. width += button.getTabbedButtonBar().isVertical() ? extraComponent->getHeight()
  1654. : extraComponent->getWidth();
  1655. return jlimit (tabDepth * 2, tabDepth * 8, width);
  1656. }
  1657. Rectangle<int> LookAndFeel_V2::getTabButtonExtraComponentBounds (const TabBarButton& button, Rectangle<int>& textArea, Component& comp)
  1658. {
  1659. Rectangle<int> extraComp;
  1660. auto orientation = button.getTabbedButtonBar().getOrientation();
  1661. if (button.getExtraComponentPlacement() == TabBarButton::beforeText)
  1662. {
  1663. switch (orientation)
  1664. {
  1665. case TabbedButtonBar::TabsAtBottom:
  1666. case TabbedButtonBar::TabsAtTop: extraComp = textArea.removeFromLeft (comp.getWidth()); break;
  1667. case TabbedButtonBar::TabsAtLeft: extraComp = textArea.removeFromBottom (comp.getHeight()); break;
  1668. case TabbedButtonBar::TabsAtRight: extraComp = textArea.removeFromTop (comp.getHeight()); break;
  1669. default: jassertfalse; break;
  1670. }
  1671. }
  1672. else
  1673. {
  1674. switch (orientation)
  1675. {
  1676. case TabbedButtonBar::TabsAtBottom:
  1677. case TabbedButtonBar::TabsAtTop: extraComp = textArea.removeFromRight (comp.getWidth()); break;
  1678. case TabbedButtonBar::TabsAtLeft: extraComp = textArea.removeFromTop (comp.getHeight()); break;
  1679. case TabbedButtonBar::TabsAtRight: extraComp = textArea.removeFromBottom (comp.getHeight()); break;
  1680. default: jassertfalse; break;
  1681. }
  1682. }
  1683. return extraComp;
  1684. }
  1685. void LookAndFeel_V2::createTabButtonShape (TabBarButton& button, Path& p, bool /*isMouseOver*/, bool /*isMouseDown*/)
  1686. {
  1687. auto activeArea = button.getActiveArea();
  1688. const float w = (float) activeArea.getWidth();
  1689. const float h = (float) activeArea.getHeight();
  1690. float length = w;
  1691. float depth = h;
  1692. if (button.getTabbedButtonBar().isVertical())
  1693. std::swap (length, depth);
  1694. const float indent = (float) getTabButtonOverlap ((int) depth);
  1695. const float overhang = 4.0f;
  1696. switch (button.getTabbedButtonBar().getOrientation())
  1697. {
  1698. case TabbedButtonBar::TabsAtLeft:
  1699. p.startNewSubPath (w, 0.0f);
  1700. p.lineTo (0.0f, indent);
  1701. p.lineTo (0.0f, h - indent);
  1702. p.lineTo (w, h);
  1703. p.lineTo (w + overhang, h + overhang);
  1704. p.lineTo (w + overhang, -overhang);
  1705. break;
  1706. case TabbedButtonBar::TabsAtRight:
  1707. p.startNewSubPath (0.0f, 0.0f);
  1708. p.lineTo (w, indent);
  1709. p.lineTo (w, h - indent);
  1710. p.lineTo (0.0f, h);
  1711. p.lineTo (-overhang, h + overhang);
  1712. p.lineTo (-overhang, -overhang);
  1713. break;
  1714. case TabbedButtonBar::TabsAtBottom:
  1715. p.startNewSubPath (0.0f, 0.0f);
  1716. p.lineTo (indent, h);
  1717. p.lineTo (w - indent, h);
  1718. p.lineTo (w, 0.0f);
  1719. p.lineTo (w + overhang, -overhang);
  1720. p.lineTo (-overhang, -overhang);
  1721. break;
  1722. default:
  1723. p.startNewSubPath (0.0f, h);
  1724. p.lineTo (indent, 0.0f);
  1725. p.lineTo (w - indent, 0.0f);
  1726. p.lineTo (w, h);
  1727. p.lineTo (w + overhang, h + overhang);
  1728. p.lineTo (-overhang, h + overhang);
  1729. break;
  1730. }
  1731. p.closeSubPath();
  1732. p = p.createPathWithRoundedCorners (3.0f);
  1733. }
  1734. void LookAndFeel_V2::fillTabButtonShape (TabBarButton& button, Graphics& g, const Path& path,
  1735. bool /*isMouseOver*/, bool /*isMouseDown*/)
  1736. {
  1737. auto tabBackground = button.getTabBackgroundColour();
  1738. const bool isFrontTab = button.isFrontTab();
  1739. g.setColour (isFrontTab ? tabBackground
  1740. : tabBackground.withMultipliedAlpha (0.9f));
  1741. g.fillPath (path);
  1742. g.setColour (button.findColour (isFrontTab ? TabbedButtonBar::frontOutlineColourId
  1743. : TabbedButtonBar::tabOutlineColourId, false)
  1744. .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
  1745. g.strokePath (path, PathStrokeType (isFrontTab ? 1.0f : 0.5f));
  1746. }
  1747. Font LookAndFeel_V2::getTabButtonFont (TabBarButton&, float height)
  1748. {
  1749. return { height * 0.6f };
  1750. }
  1751. void LookAndFeel_V2::drawTabButtonText (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown)
  1752. {
  1753. const Rectangle<float> area (button.getTextArea().toFloat());
  1754. float length = area.getWidth();
  1755. float depth = area.getHeight();
  1756. if (button.getTabbedButtonBar().isVertical())
  1757. std::swap (length, depth);
  1758. Font font (getTabButtonFont (button, depth));
  1759. font.setUnderline (button.hasKeyboardFocus (false));
  1760. AffineTransform t;
  1761. switch (button.getTabbedButtonBar().getOrientation())
  1762. {
  1763. case TabbedButtonBar::TabsAtLeft: t = t.rotated (float_Pi * -0.5f).translated (area.getX(), area.getBottom()); break;
  1764. case TabbedButtonBar::TabsAtRight: t = t.rotated (float_Pi * 0.5f).translated (area.getRight(), area.getY()); break;
  1765. case TabbedButtonBar::TabsAtTop:
  1766. case TabbedButtonBar::TabsAtBottom: t = t.translated (area.getX(), area.getY()); break;
  1767. default: jassertfalse; break;
  1768. }
  1769. Colour col;
  1770. if (button.isFrontTab() && (button.isColourSpecified (TabbedButtonBar::frontTextColourId)
  1771. || isColourSpecified (TabbedButtonBar::frontTextColourId)))
  1772. col = findColour (TabbedButtonBar::frontTextColourId);
  1773. else if (button.isColourSpecified (TabbedButtonBar::tabTextColourId)
  1774. || isColourSpecified (TabbedButtonBar::tabTextColourId))
  1775. col = findColour (TabbedButtonBar::tabTextColourId);
  1776. else
  1777. col = button.getTabBackgroundColour().contrasting();
  1778. const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f;
  1779. g.setColour (col.withMultipliedAlpha (alpha));
  1780. g.setFont (font);
  1781. g.addTransform (t);
  1782. g.drawFittedText (button.getButtonText().trim(),
  1783. 0, 0, (int) length, (int) depth,
  1784. Justification::centred,
  1785. jmax (1, ((int) depth) / 12));
  1786. }
  1787. void LookAndFeel_V2::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown)
  1788. {
  1789. Path tabShape;
  1790. createTabButtonShape (button, tabShape, isMouseOver, isMouseDown);
  1791. const Rectangle<int> activeArea (button.getActiveArea());
  1792. tabShape.applyTransform (AffineTransform::translation ((float) activeArea.getX(),
  1793. (float) activeArea.getY()));
  1794. DropShadow (Colours::black.withAlpha (0.5f), 2, Point<int> (0, 1)).drawForPath (g, tabShape);
  1795. fillTabButtonShape (button, g, tabShape, isMouseOver, isMouseDown);
  1796. drawTabButtonText (button, g, isMouseOver, isMouseDown);
  1797. }
  1798. void LookAndFeel_V2::drawTabbedButtonBarBackground (TabbedButtonBar&, Graphics&) {}
  1799. void LookAndFeel_V2::drawTabAreaBehindFrontButton (TabbedButtonBar& bar, Graphics& g, const int w, const int h)
  1800. {
  1801. const float shadowSize = 0.2f;
  1802. Rectangle<int> shadowRect, line;
  1803. ColourGradient gradient (Colours::black.withAlpha (bar.isEnabled() ? 0.25f : 0.15f), 0, 0,
  1804. Colours::transparentBlack, 0, 0, false);
  1805. switch (bar.getOrientation())
  1806. {
  1807. case TabbedButtonBar::TabsAtLeft:
  1808. gradient.point1.x = (float) w;
  1809. gradient.point2.x = w * (1.0f - shadowSize);
  1810. shadowRect.setBounds ((int) gradient.point2.x, 0, w - (int) gradient.point2.x, h);
  1811. line.setBounds (w - 1, 0, 1, h);
  1812. break;
  1813. case TabbedButtonBar::TabsAtRight:
  1814. gradient.point2.x = w * shadowSize;
  1815. shadowRect.setBounds (0, 0, (int) gradient.point2.x, h);
  1816. line.setBounds (0, 0, 1, h);
  1817. break;
  1818. case TabbedButtonBar::TabsAtTop:
  1819. gradient.point1.y = (float) h;
  1820. gradient.point2.y = h * (1.0f - shadowSize);
  1821. shadowRect.setBounds (0, (int) gradient.point2.y, w, h - (int) gradient.point2.y);
  1822. line.setBounds (0, h - 1, w, 1);
  1823. break;
  1824. case TabbedButtonBar::TabsAtBottom:
  1825. gradient.point2.y = h * shadowSize;
  1826. shadowRect.setBounds (0, 0, w, (int) gradient.point2.y);
  1827. line.setBounds (0, 0, w, 1);
  1828. break;
  1829. default: break;
  1830. }
  1831. g.setGradientFill (gradient);
  1832. g.fillRect (shadowRect.expanded (2, 2));
  1833. g.setColour (Colour (0x80000000));
  1834. g.fillRect (line);
  1835. }
  1836. Button* LookAndFeel_V2::createTabBarExtrasButton()
  1837. {
  1838. const float thickness = 7.0f;
  1839. const float indent = 22.0f;
  1840. Path p;
  1841. p.addEllipse (-10.0f, -10.0f, 120.0f, 120.0f);
  1842. DrawablePath ellipse;
  1843. ellipse.setPath (p);
  1844. ellipse.setFill (Colour (0x99ffffff));
  1845. p.clear();
  1846. p.addEllipse (0.0f, 0.0f, 100.0f, 100.0f);
  1847. p.addRectangle (indent, 50.0f - thickness, 100.0f - indent * 2.0f, thickness * 2.0f);
  1848. p.addRectangle (50.0f - thickness, indent, thickness * 2.0f, 50.0f - indent - thickness);
  1849. p.addRectangle (50.0f - thickness, 50.0f + thickness, thickness * 2.0f, 50.0f - indent - thickness);
  1850. p.setUsingNonZeroWinding (false);
  1851. DrawablePath dp;
  1852. dp.setPath (p);
  1853. dp.setFill (Colour (0x59000000));
  1854. DrawableComposite normalImage;
  1855. normalImage.addAndMakeVisible (ellipse.createCopy());
  1856. normalImage.addAndMakeVisible (dp.createCopy());
  1857. dp.setFill (Colour (0xcc000000));
  1858. DrawableComposite overImage;
  1859. overImage.addAndMakeVisible (ellipse.createCopy());
  1860. overImage.addAndMakeVisible (dp.createCopy());
  1861. DrawableButton* db = new DrawableButton ("tabs", DrawableButton::ImageFitted);
  1862. db->setImages (&normalImage, &overImage, nullptr);
  1863. return db;
  1864. }
  1865. //==============================================================================
  1866. void LookAndFeel_V2::drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header)
  1867. {
  1868. g.fillAll (Colours::white);
  1869. Rectangle<int> area (header.getLocalBounds());
  1870. area.removeFromTop (area.getHeight() / 2);
  1871. auto backgroundColour = header.findColour (TableHeaderComponent::backgroundColourId);
  1872. g.setGradientFill (ColourGradient (backgroundColour,
  1873. 0.0f, (float) area.getY(),
  1874. backgroundColour.withMultipliedSaturation (.5f),
  1875. 0.0f, (float) area.getBottom(),
  1876. false));
  1877. g.fillRect (area);
  1878. g.setColour (header.findColour (TableHeaderComponent::outlineColourId));
  1879. g.fillRect (area.removeFromBottom (1));
  1880. for (int i = header.getNumColumns (true); --i >= 0;)
  1881. g.fillRect (header.getColumnPosition (i).removeFromRight (1));
  1882. }
  1883. void LookAndFeel_V2::drawTableHeaderColumn (Graphics& g, TableHeaderComponent& header,
  1884. const String& columnName, int /*columnId*/,
  1885. int width, int height, bool isMouseOver, bool isMouseDown,
  1886. int columnFlags)
  1887. {
  1888. auto highlightColour = header.findColour (TableHeaderComponent::highlightColourId);
  1889. if (isMouseDown)
  1890. g.fillAll (highlightColour);
  1891. else if (isMouseOver)
  1892. g.fillAll (highlightColour.withMultipliedAlpha (0.625f));
  1893. Rectangle<int> area (width, height);
  1894. area.reduce (4, 0);
  1895. if ((columnFlags & (TableHeaderComponent::sortedForwards | TableHeaderComponent::sortedBackwards)) != 0)
  1896. {
  1897. Path sortArrow;
  1898. sortArrow.addTriangle (0.0f, 0.0f,
  1899. 0.5f, (columnFlags & TableHeaderComponent::sortedForwards) != 0 ? -0.8f : 0.8f,
  1900. 1.0f, 0.0f);
  1901. g.setColour (Colour (0x99000000));
  1902. g.fillPath (sortArrow, sortArrow.getTransformToScaleToFit (area.removeFromRight (height / 2).reduced (2).toFloat(), true));
  1903. }
  1904. g.setColour (header.findColour (TableHeaderComponent::textColourId));
  1905. g.setFont (Font (height * 0.5f, Font::bold));
  1906. g.drawFittedText (columnName, area, Justification::centredLeft, 1);
  1907. }
  1908. //==============================================================================
  1909. void LookAndFeel_V2::drawLasso (Graphics& g, Component& lassoComp)
  1910. {
  1911. const int outlineThickness = 1;
  1912. g.fillAll (lassoComp.findColour (0x1000440 /*lassoFillColourId*/));
  1913. g.setColour (lassoComp.findColour (0x1000441 /*lassoOutlineColourId*/));
  1914. g.drawRect (lassoComp.getLocalBounds(), outlineThickness);
  1915. }
  1916. //==============================================================================
  1917. void LookAndFeel_V2::paintToolbarBackground (Graphics& g, int w, int h, Toolbar& toolbar)
  1918. {
  1919. const Colour background (toolbar.findColour (Toolbar::backgroundColourId));
  1920. g.setGradientFill (ColourGradient (background, 0.0f, 0.0f,
  1921. background.darker (0.1f),
  1922. toolbar.isVertical() ? w - 1.0f : 0.0f,
  1923. toolbar.isVertical() ? 0.0f : h - 1.0f,
  1924. false));
  1925. g.fillAll();
  1926. }
  1927. Button* LookAndFeel_V2::createToolbarMissingItemsButton (Toolbar& /*toolbar*/)
  1928. {
  1929. return createTabBarExtrasButton();
  1930. }
  1931. void LookAndFeel_V2::paintToolbarButtonBackground (Graphics& g, int /*width*/, int /*height*/,
  1932. bool isMouseOver, bool isMouseDown,
  1933. ToolbarItemComponent& component)
  1934. {
  1935. if (isMouseDown)
  1936. g.fillAll (component.findColour (Toolbar::buttonMouseDownBackgroundColourId, true));
  1937. else if (isMouseOver)
  1938. g.fillAll (component.findColour (Toolbar::buttonMouseOverBackgroundColourId, true));
  1939. }
  1940. void LookAndFeel_V2::paintToolbarButtonLabel (Graphics& g, int x, int y, int width, int height,
  1941. const String& text, ToolbarItemComponent& component)
  1942. {
  1943. g.setColour (component.findColour (Toolbar::labelTextColourId, true)
  1944. .withAlpha (component.isEnabled() ? 1.0f : 0.25f));
  1945. const float fontHeight = jmin (14.0f, height * 0.85f);
  1946. g.setFont (fontHeight);
  1947. g.drawFittedText (text,
  1948. x, y, width, height,
  1949. Justification::centred,
  1950. jmax (1, height / (int) fontHeight));
  1951. }
  1952. //==============================================================================
  1953. void LookAndFeel_V2::drawPropertyPanelSectionHeader (Graphics& g, const String& name,
  1954. bool isOpen, int width, int height)
  1955. {
  1956. const float buttonSize = height * 0.75f;
  1957. const float buttonIndent = (height - buttonSize) * 0.5f;
  1958. drawTreeviewPlusMinusBox (g, Rectangle<float> (buttonIndent, buttonIndent, buttonSize, buttonSize), Colours::white, isOpen, false);
  1959. const int textX = (int) (buttonIndent * 2.0f + buttonSize + 2.0f);
  1960. g.setColour (Colours::black);
  1961. g.setFont (Font (height * 0.7f, Font::bold));
  1962. g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true);
  1963. }
  1964. void LookAndFeel_V2::drawPropertyComponentBackground (Graphics& g, int width, int height, PropertyComponent& component)
  1965. {
  1966. g.setColour (component.findColour (PropertyComponent::backgroundColourId));
  1967. g.fillRect (0, 0, width, height - 1);
  1968. }
  1969. void LookAndFeel_V2::drawPropertyComponentLabel (Graphics& g, int, int height, PropertyComponent& component)
  1970. {
  1971. g.setColour (component.findColour (PropertyComponent::labelTextColourId)
  1972. .withMultipliedAlpha (component.isEnabled() ? 1.0f : 0.6f));
  1973. g.setFont (jmin (height, 24) * 0.65f);
  1974. const Rectangle<int> r (getPropertyComponentContentPosition (component));
  1975. g.drawFittedText (component.getName(),
  1976. 3, r.getY(), r.getX() - 5, r.getHeight(),
  1977. Justification::centredLeft, 2);
  1978. }
  1979. Rectangle<int> LookAndFeel_V2::getPropertyComponentContentPosition (PropertyComponent& component)
  1980. {
  1981. const int textW = jmin (200, component.getWidth() / 3);
  1982. return Rectangle<int> (textW, 1, component.getWidth() - textW - 1, component.getHeight() - 3);
  1983. }
  1984. //==============================================================================
  1985. void LookAndFeel_V2::drawCallOutBoxBackground (CallOutBox& box, Graphics& g,
  1986. const Path& path, Image& cachedImage)
  1987. {
  1988. if (cachedImage.isNull())
  1989. {
  1990. cachedImage = Image (Image::ARGB, box.getWidth(), box.getHeight(), true);
  1991. Graphics g2 (cachedImage);
  1992. DropShadow (Colours::black.withAlpha (0.7f), 8, Point<int> (0, 2)).drawForPath (g2, path);
  1993. }
  1994. g.setColour (Colours::black);
  1995. g.drawImageAt (cachedImage, 0, 0);
  1996. g.setColour (Colour::greyLevel (0.23f).withAlpha (0.9f));
  1997. g.fillPath (path);
  1998. g.setColour (Colours::white.withAlpha (0.8f));
  1999. g.strokePath (path, PathStrokeType (2.0f));
  2000. }
  2001. int LookAndFeel_V2::getCallOutBoxBorderSize (const CallOutBox&)
  2002. {
  2003. return 20;
  2004. }
  2005. //==============================================================================
  2006. AttributedString LookAndFeel_V2::createFileChooserHeaderText (const String& title,
  2007. const String& instructions)
  2008. {
  2009. AttributedString s;
  2010. s.setJustification (Justification::centred);
  2011. auto colour = findColour (FileChooserDialogBox::titleTextColourId);
  2012. s.append (title + "\n\n", Font (17.0f, Font::bold), colour);
  2013. s.append (instructions, Font (14.0f), colour);
  2014. return s;
  2015. }
  2016. void LookAndFeel_V2::drawFileBrowserRow (Graphics& g, int width, int height,
  2017. const File&, const String& filename, Image* icon,
  2018. const String& fileSizeDescription,
  2019. const String& fileTimeDescription,
  2020. bool isDirectory, bool isItemSelected,
  2021. int /*itemIndex*/, DirectoryContentsDisplayComponent& dcc)
  2022. {
  2023. auto fileListComp = dynamic_cast<Component*> (&dcc);
  2024. if (isItemSelected)
  2025. g.fillAll (fileListComp != nullptr ? fileListComp->findColour (DirectoryContentsDisplayComponent::highlightColourId)
  2026. : findColour (DirectoryContentsDisplayComponent::highlightColourId));
  2027. const int x = 32;
  2028. g.setColour (Colours::black);
  2029. if (icon != nullptr && icon->isValid())
  2030. {
  2031. g.drawImageWithin (*icon, 2, 2, x - 4, height - 4,
  2032. RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
  2033. false);
  2034. }
  2035. else
  2036. {
  2037. if (auto* d = isDirectory ? getDefaultFolderImage()
  2038. : getDefaultDocumentFileImage())
  2039. d->drawWithin (g, Rectangle<float> (2.0f, 2.0f, x - 4.0f, height - 4.0f),
  2040. RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
  2041. }
  2042. g.setColour (fileListComp != nullptr ? fileListComp->findColour (DirectoryContentsDisplayComponent::textColourId)
  2043. : findColour (DirectoryContentsDisplayComponent::textColourId));
  2044. g.setFont (height * 0.7f);
  2045. if (width > 450 && ! isDirectory)
  2046. {
  2047. const int sizeX = roundToInt (width * 0.7f);
  2048. const int dateX = roundToInt (width * 0.8f);
  2049. g.drawFittedText (filename,
  2050. x, 0, sizeX - x, height,
  2051. Justification::centredLeft, 1);
  2052. g.setFont (height * 0.5f);
  2053. g.setColour (Colours::darkgrey);
  2054. if (! isDirectory)
  2055. {
  2056. g.drawFittedText (fileSizeDescription,
  2057. sizeX, 0, dateX - sizeX - 8, height,
  2058. Justification::centredRight, 1);
  2059. g.drawFittedText (fileTimeDescription,
  2060. dateX, 0, width - 8 - dateX, height,
  2061. Justification::centredRight, 1);
  2062. }
  2063. }
  2064. else
  2065. {
  2066. g.drawFittedText (filename,
  2067. x, 0, width - x, height,
  2068. Justification::centredLeft, 1);
  2069. }
  2070. }
  2071. Button* LookAndFeel_V2::createFileBrowserGoUpButton()
  2072. {
  2073. auto goUpButton = new DrawableButton ("up", DrawableButton::ImageOnButtonBackground);
  2074. Path arrowPath;
  2075. arrowPath.addArrow ({ 50.0f, 100.0f, 50.0f, 0.0f }, 40.0f, 100.0f, 50.0f);
  2076. DrawablePath arrowImage;
  2077. arrowImage.setFill (Colours::black.withAlpha (0.4f));
  2078. arrowImage.setPath (arrowPath);
  2079. goUpButton->setImages (&arrowImage);
  2080. return goUpButton;
  2081. }
  2082. void LookAndFeel_V2::layoutFileBrowserComponent (FileBrowserComponent& browserComp,
  2083. DirectoryContentsDisplayComponent* fileListComponent,
  2084. FilePreviewComponent* previewComp,
  2085. ComboBox* currentPathBox,
  2086. TextEditor* filenameBox,
  2087. Button* goUpButton)
  2088. {
  2089. const int x = 8;
  2090. auto w = browserComp.getWidth() - x - x;
  2091. if (previewComp != nullptr)
  2092. {
  2093. auto previewWidth = w / 3;
  2094. previewComp->setBounds (x + w - previewWidth, 0, previewWidth, browserComp.getHeight());
  2095. w -= previewWidth + 4;
  2096. }
  2097. int y = 4;
  2098. const int controlsHeight = 22;
  2099. const int bottomSectionHeight = controlsHeight + 8;
  2100. const int upButtonWidth = 50;
  2101. currentPathBox->setBounds (x, y, w - upButtonWidth - 6, controlsHeight);
  2102. goUpButton->setBounds (x + w - upButtonWidth, y, upButtonWidth, controlsHeight);
  2103. y += controlsHeight + 4;
  2104. if (auto listAsComp = dynamic_cast<Component*> (fileListComponent))
  2105. {
  2106. listAsComp->setBounds (x, y, w, browserComp.getHeight() - y - bottomSectionHeight);
  2107. y = listAsComp->getBottom() + 4;
  2108. }
  2109. filenameBox->setBounds (x + 50, y, w - 50, controlsHeight);
  2110. }
  2111. // Pulls a drawable out of compressed ValueTree data..
  2112. static Drawable* loadDrawableFromData (const void* data, size_t numBytes)
  2113. {
  2114. MemoryInputStream m (data, numBytes, false);
  2115. GZIPDecompressorInputStream gz (m);
  2116. ValueTree drawable (ValueTree::readFromStream (gz));
  2117. return Drawable::createFromValueTree (drawable.getChild (0), nullptr);
  2118. }
  2119. const Drawable* LookAndFeel_V2::getDefaultFolderImage()
  2120. {
  2121. if (folderImage == nullptr)
  2122. {
  2123. static const unsigned char drawableData[] =
  2124. { 120,218,197,86,77,111,27,55,16,229,182,161,237,6,61,39,233,77,63,192,38,56,195,225,215,209,105,210,2,141,13,20,201,193,109,111,178,181,178,183,145,181,130,180,110,145,127,159,199,93,73,137,87,53,218,91,109,192,160,151,179,156,55,111,222,188,229,155,247,
  2125. 231,87,231,175,47,222,170,234,155,229,244,190,86,213,115,253,102,61,253,123,122,189,168,85,51,83,213,119,250,238,221,47,231,151,175,223,169,170,250,121,221,62,172,84,245,172,60,63,209,243,118,49,171,215,170,107,87,23,245,188,83,213,145,182,167,19,91,
  2126. 254,127,223,220,222,117,37,68,82,40,143,174,219,174,107,239,135,168,147,18,37,108,85,245,237,46,207,70,33,249,175,211,238,78,85,186,28,253,76,175,73,109,186,117,251,177,190,106,102,229,241,247,58,24,103,203,15,101,245,103,219,44,187,15,221,39,0,172,142,
  2127. 245,125,211,1,196,205,116,181,125,114,164,175,31,186,78,45,219,229,31,245,186,189,106,150,179,102,121,139,100,154,240,231,167,102,177,64,72,247,105,213,23,122,187,158,206,154,122,217,169,85,57,18,1,47,53,101,107,18,135,204,167,147,192,201,216,20,114,
  2128. 244,195,62,171,234,7,125,198,100,136,216,145,149,211,9,57,103,40,249,72,219,8,167,170,87,250,140,162,199,123,226,3,34,82,202,134,131,13,172,74,170,233,162,0,177,234,166,93,180,15,235,141,170,206,180,157,204,231,150,156,159,207,39,195,50,214,88,18,150,
  2129. 245,205,124,250,104,169,212,135,158,19,144,53,20,112,172,55,237,2,132,13,199,149,130,230,115,145,112,147,147,82,61,157,32,238,178,253,11,145,213,138,10,52,138,38,103,111,99,164,211,137,139,198,35,177,35,167,212,143,15,215,205,13,160,109,163,172,225,152,
  2130. 16,232,17,149,140,103,144,158,146,90,113,217,12,6,197,167,236,3,54,5,181,101,73,54,138,90,245,165,227,120,18,252,150,77,15,242,188,228,204,81,169,139,102,249,5,68,192,145,14,244,112,1,145,29,94,137,96,235,49,136,151,58,246,32,88,192,161,88,176,76,226,
  2131. 36,247,24,176,7,232,62,16,83,42,155,201,160,30,222,65,72,98,82,76,33,198,254,197,96,124,10,150,243,8,130,48,228,36,94,124,6,4,43,38,0,142,205,99,30,4,221,13,33,230,220,71,177,65,49,142,243,150,7,1,51,20,2,5,96,96,84,225,56,217,188,3,33,46,24,228,112,
  2132. 69,69,12,68,228,108,242,99,16,165,118,208,28,51,200,98,87,42,74,62,209,24,4,206,48,22,153,125,132,220,196,56,15,234,99,216,130,0,141,38,74,162,130,48,35,163,141,94,196,245,32,94,104,7,154,132,209,40,108,162,165,232,153,165,17,4,138,201,176,135,58,49,
  2133. 165,130,122,108,114,54,28,240,64,17,89,188,79,177,116,149,10,4,246,91,30,94,104,112,96,226,144,131,144,142,98,78,177,7,128,81,242,224,140,36,249,80,208,145,196,12,202,15,16,60,161,200,69,187,169,213,86,198,123,87,224,255,199,21,94,105,134,72,40,177,245,
  2134. 14,182,32,232,54,196,231,100,111,11,189,168,201,39,177,84,102,38,139,177,168,74,210,87,174,64,20,138,160,67,111,10,4,98,196,97,60,158,118,133,25,111,173,224,171,37,97,185,119,133,221,242,63,184,194,140,71,174,240,252,145,43,72,32,147,146,147,4,104,104,
  2135. 117,134,10,18,12,107,212,40,72,148,57,6,71,69,135,222,248,16,160,168,3,169,144,55,201,69,41,147,137,134,99,50,97,8,178,85,43,217,140,201,151,192,152,10,242,190,24,11,59,183,29,25,42,115,236,98,14,229,252,32,80,66,0,162,17,136,72,6,67,5,45,242,224,10,
  2136. 193,102,71,50,6,17,129,212,18,115,105,150,80,169,45,123,222,141,76,178,70,32,55,24,90,217,132,71,73,200,57,238,204,3,136,49,144,185,55,183,190,20,137,52,246,47,113,232,158,69,35,49,145,208,129,193,56,178,77,135,230,145,113,22,140,69,74,20,146,2,120,218,
  2137. 155,135,48,32,10,89,30,156,165,204,254,222,193,160,12,19,49,6,210,59,11,70,62,4,31,15,64,196,2,157,98,33,58,1,104,32,152,50,31,128,64,148,183,197,108,209,89,107,240,41,75,36,123,16,208,108,180,44,236,250,182,227,27,20,137,118,76,60,165,137,221,92,94,
  2138. 78,215,31,235,245,230,183,242,229,30,214,251,251,195,145,94,148,15,253,170,221,52,93,211,46,7,109,171,81,208,177,94,247,119,132,47,81,186,92,22,246,7,255,254,15,7,107,141,171,197,191,156,123,162,135,187,198,227,131,113,219,80,159,1,4,239,223,231,0,0 };
  2139. folderImage = loadDrawableFromData (drawableData, sizeof (drawableData));
  2140. }
  2141. return folderImage;
  2142. }
  2143. const Drawable* LookAndFeel_V2::getDefaultDocumentFileImage()
  2144. {
  2145. if (documentImage == nullptr)
  2146. {
  2147. static const unsigned char drawableData[] =
  2148. { 120,218,213,88,77,115,219,54,16,37,147,208,246,228,214,75,155,246,164,123,29,12,176,216,197,199,49,105,218,94,156,153,78,114,72,219,155,108,75,137,26,89,212,200,116,59,233,175,239,3,105,201,164,68,50,158,166,233,76,196,11,69,60,173,128,197,123,139,183,
  2149. 124,241,234,217,155,103,207,207,126,204,242,7,171,233,213,44,203,31,23,47,54,211,191,166,231,203,89,182,184,204,242,147,226,195,165,219,252,125,150,229,249,207,155,242,102,157,229,143,210,227,199,197,101,121,113,115,53,91,85,89,85,174,207,102,243,42,
  2150. 203,143,10,125,58,209,233,251,171,197,219,119,85,250,173,97,151,30,157,151,85,85,94,53,168,147,132,50,226,179,252,225,246,143,174,179,44,63,254,101,90,189,203,242,34,5,127,84,172,77,118,93,109,202,247,179,55,139,203,244,248,97,161,179,63,202,197,170,
  2151. 122,93,125,192,196,242,227,226,106,81,205,54,217,197,116,125,251,228,168,56,191,169,170,108,85,174,126,159,109,202,55,139,213,229,98,245,182,249,97,254,240,167,197,114,137,5,86,31,214,245,111,175,203,37,254,230,162,92,150,55,155,180,148,249,237,39,203,
  2152. 94,215,127,58,10,213,245,39,203,234,249,102,249,87,47,203,63,129,204,49,227,252,73,225,149,145,104,131,245,254,116,34,202,82,164,16,153,179,236,108,177,234,7,49,41,237,130,144,167,17,144,15,42,104,239,93,12,35,32,99,68,9,187,24,125,7,244,77,23,36,164,
  2153. 40,56,226,61,12,107,229,130,215,100,105,24,227,89,17,246,211,105,55,140,49,218,43,207,100,245,72,28,195,70,17,230,201,118,8,243,164,139,233,95,88,23,52,152,162,54,104,48,217,237,105,15,111,91,107,253,131,160,118,34,239,69,128,54,232,135,101,121,61,203,
  2154. 110,169,181,147,2,253,159,82,48,180,229,247,167,74,193,41,141,188,35,93,241,116,18,148,113,214,120,207,113,47,19,109,16,51,182,153,193,5,59,2,10,90,69,114,218,135,48,2,50,198,43,171,189,152,81,144,88,108,85,136,78,246,64,54,42,163,35,69,30,3,121,82,38,
  2155. 98,81,98,70,64,70,139,34,111,163,167,49,144,13,202,138,179,58,220,23,52,180,186,54,104,48,79,109,208,96,198,219,19,31,220,187,118,10,6,65,237,100,222,139,5,109,80,191,30,236,151,162,135,147,142,30,68,105,182,58,6,22,84,43,229,124,148,116,97,145,55,231,
  2156. 139,11,76,228,16,37,14,48,205,145,77,134,34,176,55,152,182,200,57,99,93,204,144,145,253,65,97,229,132,72,104,63,62,71,21,140,54,186,41,226,59,84,19,63,130,15,222,235,224,185,59,104,27,226,68,101,153,241,227,177,248,29,20,136,26,8,252,178,183,241,219,
  2157. 131,137,160,209,107,109,92,79,124,16,211,184,104,93,77,130,110,124,2,65,172,67,201,60,157,88,163,2,91,99,92,216,198,55,78,69,75,190,150,119,84,98,200,71,150,109,124,36,204,227,52,8,33,229,223,68,167,173,167,131,248,137,212,226,141,19,233,160,154,248,
  2158. 144,142,195,140,137,185,59,104,15,247,119,40,126,23,69,81,200,242,110,254,123,20,49,94,112,110,245,199,111,241,167,87,36,252,101,138,132,149,22,22,38,65,134,29,182,139,24,230,192,31,144,184,133,130,72,44,131,210,142,111,147,216,30,76,123,30,113,206,242,
  2159. 150,196,157,65,129,130,76,180,194,61,34,225,160,5,228,233,160,118,34,137,26,202,115,212,29,108,72,134,243,223,90,114,226,199,226,119,80,6,245,152,197,122,217,146,184,53,24,140,210,30,21,59,80,79,124,182,202,71,207,218,112,159,72,80,53,140,109,68,2,191,
  2160. 227,217,210,78,36,94,137,88,231,82,157,8,176,61,0,122,191,19,137,3,255,13,39,183,228,20,193,151,144,119,166,79,36,40,253,156,138,72,11,181,19,137,14,46,176,217,27,180,135,251,219,31,255,235,61,148,165,96,72,122,118,23,229,81,52,135,24,250,163,183,216,
  2161. 211,43,17,217,151,136,253,116,137,28,53,188,127,92,188,221,76,47,23,169,59,90,167,144,141,239,197,86,104,141,189,60,157,80,84,142,140,4,31,154,241,122,105,132,41,107,13,201,39,86,120,24,82,114,206,198,6,96,27,227,172,36,232,168,201,36,219,24,113,62,163,
  2162. 154,101,233,143,166,203,102,26,141,206,174,179,252,89,161,39,243,249,197,121,186,38,233,246,146,211,53,1,123,56,194,231,122,143,103,179,217,60,204,167,19,147,110,41,93,173,219,123,72,89,248,35,173,16,220,50,179,111,60,181,24,88,103,156,235,7,78,248,14,
  2163. 4,119,78,162,93,60,112,35,109,16,124,126,12,17,71,67,24,1,165,142,1,181,215,248,56,6,66,235,193,137,167,61,22,30,5,3,27,101,71,64,169,25,112,216,2,63,22,169,110,43,18,200,140,129,208,160,88,44,220,208,125,65,67,171,107,131,6,243,212,6,13,102,188,61,241,
  2164. 225,189,107,165,96,16,212,78,230,189,88,208,6,245,235,214,237,235,150,62,167,110,155,106,170,53,133,192,117,193,20,84,78,74,174,98,39,92,156,8,112,21,46,80,106,12,209,207,225,228,16,113,59,225,126,87,60,133,25,209,34,36,2,99,242,52,197,48,30,75,244,247,
  2165. 212,238,246,182,173,221,185,78,215,127,167,221,162,163,221,250,152,217,146,196,222,145,100,223,235,105,108,28,250,149,212,74,224,86,2,213,118,110,119,204,224,144,208,38,214,131,200,14,214,223,120,189,230,53,1,193,70,133,154,131,56,223,16,229,48,188,14,
  2166. 201,205,213,121,71,233,68,89,15,124,103,37,53,26,11,118,176,127,169,88,166,158,219,178,117,173,83,108,75,95,55,68,186,193,53,246,146,206,127,6,63,53,78,58,228,204,155,224,113,74,91,232,221,195,240,105,215,34,29,138,64,128,183,8,130,233,71,173,56,54,101,
  2167. 99,75,186,111,65,58,28,229,145,82,19,152,12,99,180,81,130,131,75,234,229,220,247,53,231,154,79,205,185,185,155,199,249,172,38,85,253,204,76,68,95,92,204,207,255,221,75,178,227,14,187,224,224,97,202,172,173,219,12,167,130,133,9,54,135,245,92,176,29,134,
  2168. 165,110,139,141,18,16,223,29,188,183,65,207,144,106,144,151,143,128,224,176,168,110,140,32,62,56,110,219,195,54,235,20,68,209,216,34,232,21,6,41,234,157,39,211,201,107,160,230,66,225,56,153,9,101,21,37,237,150,204,14,115,208,22,221,54,216,230,33,116,
  2169. 14,65,14,44,19,8,236,73,71,246,182,110,125,224,75,132,195,214,247,163,36,51,252,84,76,124,37,212,100,88,62,183,179,76,67,217,218,242,244,229,116,243,126,182,185,254,21,105,126,208,220,239,94,229,30,21,203,244,202,117,93,94,47,170,69,185,106,246,60,219,
  2170. 3,29,23,155,250,109,237,29,170,72,175,109,119,129,127,235,9,92,20,85,185,254,72,220,147,162,121,235,219,13,44,144,225,63,241,244,165,51,0,0 };
  2171. documentImage = loadDrawableFromData (drawableData, sizeof (drawableData));
  2172. }
  2173. return documentImage;
  2174. }
  2175. //==============================================================================
  2176. void LookAndFeel_V2::drawLevelMeter (Graphics& g, int width, int height, float level)
  2177. {
  2178. g.setColour (Colours::white.withAlpha (0.7f));
  2179. g.fillRoundedRectangle (0.0f, 0.0f, (float) width, (float) height, 3.0f);
  2180. g.setColour (Colours::black.withAlpha (0.2f));
  2181. g.drawRoundedRectangle (1.0f, 1.0f, width - 2.0f, height - 2.0f, 3.0f, 1.0f);
  2182. const int totalBlocks = 7;
  2183. const int numBlocks = roundToInt (totalBlocks * level);
  2184. const float w = (width - 6.0f) / (float) totalBlocks;
  2185. for (int i = 0; i < totalBlocks; ++i)
  2186. {
  2187. if (i >= numBlocks)
  2188. g.setColour (Colours::lightblue.withAlpha (0.6f));
  2189. else
  2190. g.setColour (i < totalBlocks - 1 ? Colours::blue.withAlpha (0.5f)
  2191. : Colours::red);
  2192. g.fillRoundedRectangle (3.0f + i * w + w * 0.1f, 3.0f, w * 0.8f, height - 6.0f, w * 0.4f);
  2193. }
  2194. }
  2195. //==============================================================================
  2196. void LookAndFeel_V2::drawKeymapChangeButton (Graphics& g, int width, int height, Button& button, const String& keyDescription)
  2197. {
  2198. const Colour textColour (button.findColour (0x100ad01 /*KeyMappingEditorComponent::textColourId*/, true));
  2199. if (keyDescription.isNotEmpty())
  2200. {
  2201. if (button.isEnabled())
  2202. {
  2203. const float alpha = button.isDown() ? 0.3f : (button.isOver() ? 0.15f : 0.08f);
  2204. g.fillAll (textColour.withAlpha (alpha));
  2205. g.setOpacity (0.3f);
  2206. drawBevel (g, 0, 0, width, height, 2);
  2207. }
  2208. g.setColour (textColour);
  2209. g.setFont (height * 0.6f);
  2210. g.drawFittedText (keyDescription,
  2211. 3, 0, width - 6, height,
  2212. Justification::centred, 1);
  2213. }
  2214. else
  2215. {
  2216. const float thickness = 7.0f;
  2217. const float indent = 22.0f;
  2218. Path p;
  2219. p.addEllipse (0.0f, 0.0f, 100.0f, 100.0f);
  2220. p.addRectangle (indent, 50.0f - thickness, 100.0f - indent * 2.0f, thickness * 2.0f);
  2221. p.addRectangle (50.0f - thickness, indent, thickness * 2.0f, 50.0f - indent - thickness);
  2222. p.addRectangle (50.0f - thickness, 50.0f + thickness, thickness * 2.0f, 50.0f - indent - thickness);
  2223. p.setUsingNonZeroWinding (false);
  2224. g.setColour (textColour.withAlpha (button.isDown() ? 0.7f : (button.isOver() ? 0.5f : 0.3f)));
  2225. g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, width - 4.0f, height - 4.0f, true));
  2226. }
  2227. if (button.hasKeyboardFocus (false))
  2228. {
  2229. g.setColour (textColour.withAlpha (0.4f));
  2230. g.drawRect (0, 0, width, height);
  2231. }
  2232. }
  2233. //==============================================================================
  2234. void LookAndFeel_V2::drawBevel (Graphics& g, const int x, const int y, const int width, const int height,
  2235. const int bevelThickness, const Colour& topLeftColour, const Colour& bottomRightColour,
  2236. const bool useGradient, const bool sharpEdgeOnOutside)
  2237. {
  2238. if (g.clipRegionIntersects (Rectangle<int> (x, y, width, height)))
  2239. {
  2240. LowLevelGraphicsContext& context = g.getInternalContext();
  2241. context.saveState();
  2242. for (int i = bevelThickness; --i >= 0;)
  2243. {
  2244. const float op = useGradient ? (sharpEdgeOnOutside ? bevelThickness - i : i) / (float) bevelThickness
  2245. : 1.0f;
  2246. context.setFill (topLeftColour.withMultipliedAlpha (op));
  2247. context.fillRect (Rectangle<int> (x + i, y + i, width - i * 2, 1), false);
  2248. context.setFill (topLeftColour.withMultipliedAlpha (op * 0.75f));
  2249. context.fillRect (Rectangle<int> (x + i, y + i + 1, 1, height - i * 2 - 2), false);
  2250. context.setFill (bottomRightColour.withMultipliedAlpha (op));
  2251. context.fillRect (Rectangle<int> (x + i, y + height - i - 1, width - i * 2, 1), false);
  2252. context.setFill (bottomRightColour.withMultipliedAlpha (op * 0.75f));
  2253. context.fillRect (Rectangle<int> (x + width - i - 1, y + i + 1, 1, height - i * 2 - 2), false);
  2254. }
  2255. context.restoreState();
  2256. }
  2257. }
  2258. //==============================================================================
  2259. void LookAndFeel_V2::drawShinyButtonShape (Graphics& g,
  2260. float x, float y, float w, float h,
  2261. float maxCornerSize,
  2262. const Colour& baseColour,
  2263. const float strokeWidth,
  2264. const bool flatOnLeft,
  2265. const bool flatOnRight,
  2266. const bool flatOnTop,
  2267. const bool flatOnBottom) noexcept
  2268. {
  2269. if (w <= strokeWidth * 1.1f || h <= strokeWidth * 1.1f)
  2270. return;
  2271. const float cs = jmin (maxCornerSize, w * 0.5f, h * 0.5f);
  2272. Path outline;
  2273. outline.addRoundedRectangle (x, y, w, h, cs, cs,
  2274. ! (flatOnLeft || flatOnTop),
  2275. ! (flatOnRight || flatOnTop),
  2276. ! (flatOnLeft || flatOnBottom),
  2277. ! (flatOnRight || flatOnBottom));
  2278. ColourGradient cg (baseColour, 0.0f, y,
  2279. baseColour.overlaidWith (Colour (0x070000ff)), 0.0f, y + h,
  2280. false);
  2281. cg.addColour (0.5, baseColour.overlaidWith (Colour (0x33ffffff)));
  2282. cg.addColour (0.51, baseColour.overlaidWith (Colour (0x110000ff)));
  2283. g.setGradientFill (cg);
  2284. g.fillPath (outline);
  2285. g.setColour (Colour (0x80000000));
  2286. g.strokePath (outline, PathStrokeType (strokeWidth));
  2287. }
  2288. //==============================================================================
  2289. void LookAndFeel_V2::drawGlassSphere (Graphics& g, const float x, const float y,
  2290. const float diameter, const Colour& colour,
  2291. const float outlineThickness) noexcept
  2292. {
  2293. if (diameter <= outlineThickness)
  2294. return;
  2295. Path p;
  2296. p.addEllipse (x, y, diameter, diameter);
  2297. {
  2298. ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y,
  2299. Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false);
  2300. cg.addColour (0.4, Colours::white.overlaidWith (colour));
  2301. g.setGradientFill (cg);
  2302. g.fillPath (p);
  2303. }
  2304. g.setGradientFill (ColourGradient (Colours::white, 0, y + diameter * 0.06f,
  2305. Colours::transparentWhite, 0, y + diameter * 0.3f, false));
  2306. g.fillEllipse (x + diameter * 0.2f, y + diameter * 0.05f, diameter * 0.6f, diameter * 0.4f);
  2307. ColourGradient cg (Colours::transparentBlack,
  2308. x + diameter * 0.5f, y + diameter * 0.5f,
  2309. Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()),
  2310. x, y + diameter * 0.5f, true);
  2311. cg.addColour (0.7, Colours::transparentBlack);
  2312. cg.addColour (0.8, Colours::black.withAlpha (0.1f * outlineThickness));
  2313. g.setGradientFill (cg);
  2314. g.fillPath (p);
  2315. g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha()));
  2316. g.drawEllipse (x, y, diameter, diameter, outlineThickness);
  2317. }
  2318. //==============================================================================
  2319. void LookAndFeel_V2::drawGlassPointer (Graphics& g,
  2320. const float x, const float y, const float diameter,
  2321. const Colour& colour, const float outlineThickness,
  2322. const int direction) noexcept
  2323. {
  2324. if (diameter <= outlineThickness)
  2325. return;
  2326. Path p;
  2327. p.startNewSubPath (x + diameter * 0.5f, y);
  2328. p.lineTo (x + diameter, y + diameter * 0.6f);
  2329. p.lineTo (x + diameter, y + diameter);
  2330. p.lineTo (x, y + diameter);
  2331. p.lineTo (x, y + diameter * 0.6f);
  2332. p.closeSubPath();
  2333. p.applyTransform (AffineTransform::rotation (direction * (float_Pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f));
  2334. {
  2335. ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y,
  2336. Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false);
  2337. cg.addColour (0.4, Colours::white.overlaidWith (colour));
  2338. g.setGradientFill (cg);
  2339. g.fillPath (p);
  2340. }
  2341. ColourGradient cg (Colours::transparentBlack,
  2342. x + diameter * 0.5f, y + diameter * 0.5f,
  2343. Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()),
  2344. x - diameter * 0.2f, y + diameter * 0.5f, true);
  2345. cg.addColour (0.5, Colours::transparentBlack);
  2346. cg.addColour (0.7, Colours::black.withAlpha (0.07f * outlineThickness));
  2347. g.setGradientFill (cg);
  2348. g.fillPath (p);
  2349. g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha()));
  2350. g.strokePath (p, PathStrokeType (outlineThickness));
  2351. }
  2352. //==============================================================================
  2353. void LookAndFeel_V2::drawGlassLozenge (Graphics& g,
  2354. const float x, const float y, const float width, const float height,
  2355. const Colour& colour, const float outlineThickness, const float cornerSize,
  2356. const bool flatOnLeft,
  2357. const bool flatOnRight,
  2358. const bool flatOnTop,
  2359. const bool flatOnBottom) noexcept
  2360. {
  2361. if (width <= outlineThickness || height <= outlineThickness)
  2362. return;
  2363. const int intX = (int) x;
  2364. const int intY = (int) y;
  2365. const int intW = (int) width;
  2366. const int intH = (int) height;
  2367. const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize;
  2368. const float edgeBlurRadius = height * 0.75f + (height - cs * 2.0f);
  2369. const int intEdge = (int) edgeBlurRadius;
  2370. Path outline;
  2371. outline.addRoundedRectangle (x, y, width, height, cs, cs,
  2372. ! (flatOnLeft || flatOnTop),
  2373. ! (flatOnRight || flatOnTop),
  2374. ! (flatOnLeft || flatOnBottom),
  2375. ! (flatOnRight || flatOnBottom));
  2376. {
  2377. ColourGradient cg (colour.darker (0.2f), 0, y,
  2378. colour.darker (0.2f), 0, y + height, false);
  2379. cg.addColour (0.03, colour.withMultipliedAlpha (0.3f));
  2380. cg.addColour (0.4, colour);
  2381. cg.addColour (0.97, colour.withMultipliedAlpha (0.3f));
  2382. g.setGradientFill (cg);
  2383. g.fillPath (outline);
  2384. }
  2385. ColourGradient cg (Colours::transparentBlack, x + edgeBlurRadius, y + height * 0.5f,
  2386. colour.darker (0.2f), x, y + height * 0.5f, true);
  2387. cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.5f) / edgeBlurRadius), Colours::transparentBlack);
  2388. cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.25f) / edgeBlurRadius), colour.darker (0.2f).withMultipliedAlpha (0.3f));
  2389. if (! (flatOnLeft || flatOnTop || flatOnBottom))
  2390. {
  2391. g.saveState();
  2392. g.setGradientFill (cg);
  2393. g.reduceClipRegion (intX, intY, intEdge, intH);
  2394. g.fillPath (outline);
  2395. g.restoreState();
  2396. }
  2397. if (! (flatOnRight || flatOnTop || flatOnBottom))
  2398. {
  2399. cg.point1.setX (x + width - edgeBlurRadius);
  2400. cg.point2.setX (x + width);
  2401. g.saveState();
  2402. g.setGradientFill (cg);
  2403. g.reduceClipRegion (intX + intW - intEdge, intY, 2 + intEdge, intH);
  2404. g.fillPath (outline);
  2405. g.restoreState();
  2406. }
  2407. {
  2408. const float leftIndent = flatOnTop || flatOnLeft ? 0.0f : cs * 0.4f;
  2409. const float rightIndent = flatOnTop || flatOnRight ? 0.0f : cs * 0.4f;
  2410. Path highlight;
  2411. highlight.addRoundedRectangle (x + leftIndent,
  2412. y + cs * 0.1f,
  2413. width - (leftIndent + rightIndent),
  2414. height * 0.4f,
  2415. cs * 0.4f,
  2416. cs * 0.4f,
  2417. ! (flatOnLeft || flatOnTop),
  2418. ! (flatOnRight || flatOnTop),
  2419. ! (flatOnLeft || flatOnBottom),
  2420. ! (flatOnRight || flatOnBottom));
  2421. g.setGradientFill (ColourGradient (colour.brighter (10.0f), 0, y + height * 0.06f,
  2422. Colours::transparentWhite, 0, y + height * 0.4f, false));
  2423. g.fillPath (highlight);
  2424. }
  2425. g.setColour (colour.darker().withMultipliedAlpha (1.5f));
  2426. g.strokePath (outline, PathStrokeType (outlineThickness));
  2427. }
  2428. } // namespace juce