@@ -78,12 +78,45 @@ ProcessorList::ProcessorList (Viewport* v) : viewport (v),
7878 arrowButton->setClickingTogglesState (false );
7979 arrowButton->setInterceptsMouseClicks (false , false );
8080 addAndMakeVisible (arrowButton.get ());
81+
82+ searchButton = std::make_unique<ShapeButton> (" Search" , Colours::transparentBlack, Colours::transparentBlack, Colours::transparentBlack);
83+ searchButton->setOutline (findColour (ThemeColours::controlPanelText), 1 .0f );
84+ String searchIconPath = " M15 15m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0 M18.5 18.5l2.5 2.5 M4 6h16 M4 12h4 M4 18h4" ;
85+ searchButton->setShape (Drawable::parseSVGPath (searchIconPath), true , true , false );
86+ searchButton->setClickingTogglesState (false );
87+ searchButton->onClick = [this ]
88+ {
89+ searchField->setVisible (true );
90+ searchField->grabKeyboardFocus ();
91+ };
92+ addAndMakeVisible (searchButton.get ());
93+
94+ searchField = std::make_unique<TextEditor>();
95+ searchField->setTextToShowWhenEmpty (" Search..." , Colours::grey);
96+ searchField->setPopupMenuEnabled (false );
97+ searchField->onTextChange = [this ]
98+ {
99+ searchText = searchField->getText ();
100+ repaint ();
101+ };
102+ searchField->onEscapeKey = [this ]
103+ {
104+ searchField->setText (" " );
105+ searchField->setVisible (false );
106+ };
107+ searchField->onFocusLost = [this ]
108+ {
109+ searchField->setText (" " );
110+ searchField->setVisible (false );
111+ };
112+ addChildComponent (searchField.get ());
81113}
82114
83115void ProcessorList::resized ()
84116{
85117 setBounds (0 , 0 , 195 , getTotalHeight ());
86-
118+ searchField->setBounds (0 , 0 , getWidth (), itemHeight);
119+ searchButton->setBounds (getWidth () - 45 , (itemHeight / 2 ) - 8 , 16 , 16 );
87120 arrowButton->setBounds (getWidth () - 25 , (itemHeight / 2 ) - 10 , 20 , 20 );
88121}
89122
@@ -94,6 +127,11 @@ void ProcessorList::timerCallback()
94127 repaint ();
95128}
96129
130+ void ProcessorList::lookAndFeelChanged ()
131+ {
132+ searchButton->setOutline (findColour (ThemeColours::controlPanelText), 1 .0f );
133+ }
134+
97135bool ProcessorList::isOpen ()
98136{
99137 return baseItem->isOpen ();
@@ -126,8 +164,12 @@ void ProcessorList::drawItems (Graphics& g)
126164 {
127165 for (int m = 0 ; m < baseItem->getSubItem (n)->getNumSubItems (); m++)
128166 {
129- setViewport (g, baseItem->getSubItem (n)->getSubItem (m)->hasSubItems ());
130- drawItem (g, baseItem->getSubItem (n)->getSubItem (m));
167+ ProcessorListItem* subSubItem = baseItem->getSubItem (n)->getSubItem (m);
168+ if (subSubItem->getName ().containsIgnoreCase (searchText) || searchText.isEmpty ())
169+ {
170+ setViewport (g, subSubItem->hasSubItems ());
171+ drawItem (g, subSubItem);
172+ }
131173 }
132174 }
133175 }
@@ -209,7 +251,7 @@ void ProcessorList::drawItemName (Graphics& g, ProcessorListItem* item)
209251
210252 if (! item->getName ().equalsIgnoreCase (" Processors" ))
211253 {
212- g.setColour (Colours::black.withAlpha (0 .25f ));
254+ g.setColour (Colours::black.withAlpha (0 .25f ));
213255
214256 if (item->isOpen ())
215257 {
@@ -263,11 +305,15 @@ ProcessorListItem* ProcessorList::getListItemForYPos (int y)
263305 {
264306 for (int m = 0 ; m < baseItem->getSubItem (n)->getNumSubItems (); m++)
265307 {
266- bottom += (yBuffer + subItemHeight);
267-
268- if (y < bottom)
308+ ProcessorListItem* subSubItem = baseItem->getSubItem (n)->getSubItem (m);
309+ if (subSubItem->getName ().containsIgnoreCase (searchText) || searchText.isEmpty ())
269310 {
270- return baseItem->getSubItem (n)->getSubItem (m);
311+ bottom += (yBuffer + subItemHeight);
312+
313+ if (y < bottom)
314+ {
315+ return baseItem->getSubItem (n)->getSubItem (m);
316+ }
271317 }
272318 }
273319 }
@@ -307,6 +353,7 @@ void ProcessorList::toggleState()
307353 fli->reverseOpenState ();
308354 LOGC (" Processor List - Toggling state of " , fli->getName ());
309355 arrowButton->setToggleState (fli->isOpen (), dontSendNotification);
356+ searchButton->setVisible (fli->isOpen ());
310357 AccessClass::getUIComponent ()->childComponentChanged ();
311358 repaint ();
312359}
@@ -552,7 +599,6 @@ void ProcessorList::loadStateFromXml (XmlElement* xml)
552599 colourNode->getIntAttribute (" R" ),
553600 colourNode->getIntAttribute (" G" ),
554601 colourNode->getIntAttribute (" B" )));
555-
556602 }
557603 }
558604 }
0 commit comments