search.cpp (974B)
1 #include "search.h" 2 3 #include "defaultskin.h" 4 #include "dsp56kEmu/logging.h" 5 6 namespace jucePluginEditorLib::patchManager 7 { 8 Search::Search() 9 { 10 setColour(textColourId, juce::Colour(defaultSkin::colors::itemText)); 11 setColour(backgroundColourId, juce::Colour(defaultSkin::colors::background)); 12 setColour(outlineColourId, juce::Colour(defaultSkin::colors::textEditOutline)); 13 14 addListener(this); 15 } 16 17 void Search::textEditorTextChanged(juce::TextEditor& _textEditor) 18 { 19 setText(_textEditor.getText().toStdString()); 20 } 21 22 std::string Search::lowercase(const std::string& _s) 23 { 24 auto t = _s; 25 std::transform(t.begin(), t.end(), t.begin(), tolower); 26 return t; 27 } 28 29 void Search::onTextChanged(const std::string& _text) 30 { 31 } 32 33 void Search::paint(juce::Graphics& g) 34 { 35 TextEditor::paint(g); 36 } 37 38 void Search::setText(const std::string& _text) 39 { 40 const auto t = lowercase(_text); 41 42 if (m_text == t) 43 return; 44 45 m_text = t; 46 onTextChanged(t); 47 repaint(); 48 } 49 }