diff --git a/src/libprojectM/CMakeLists.txt b/src/libprojectM/CMakeLists.txt index 9b553c248..6105a4eb8 100644 --- a/src/libprojectM/CMakeLists.txt +++ b/src/libprojectM/CMakeLists.txt @@ -1,7 +1,6 @@ add_compile_definitions( DATADIR_PATH="${PROJECTM_DATADIR_PATH}" GL_SILENCE_DEPRECATION - USE_TEXT_MENU ) if(CMAKE_SYSTEM_NAME STREQUAL "Windows") diff --git a/src/libprojectM/KeyHandler.cpp b/src/libprojectM/KeyHandler.cpp index 81dadb1c9..5166bba02 100755 --- a/src/libprojectM/KeyHandler.cpp +++ b/src/libprojectM/KeyHandler.cpp @@ -68,175 +68,37 @@ void ProjectM::DefaultKeyHandler(projectMEvent event, projectMKeycode keycode) { switch (keycode) { - case PROJECTM_K_HOME: - if (m_renderer->showmenu) { - if (!TextInputActive()) { - SelectPreset(0); // jump to top of presets. - } - else { - m_renderer->m_activePresetID = 1; // jump to top of search results. - SelectPresetByName(m_renderer->m_presetList[0].name, true); - } - } - break; - case PROJECTM_K_END: - if (m_renderer->showmenu) { - if (!TextInputActive()) { - SelectPreset(m_presetLoader->size() - 1); // jump to bottom of presets. - } - else { - m_renderer->m_activePresetID = m_renderer->m_presetList.size(); // jump to top of search results. - SelectPresetByName(m_renderer->m_presetList[m_renderer->m_activePresetID - 1].name, true); - } - } - break; - case PROJECTM_K_PAGEUP: - if (TextInputActive()) break; // don't handle this key if search menu is up. - if (m_renderer->showmenu) { - int upPreset = m_presetPos->lastIndex() - (m_renderer->textMenuPageSize / 2.0f); // jump up by page size / 2 - if (upPreset < 0) // handle lower boundary - upPreset = m_presetLoader->size() - 1; - SelectPreset(upPreset); // jump up menu half a page. - } - break; - case PROJECTM_K_PAGEDOWN: - if (TextInputActive()) break; // don't handle this key if search menu is up. - if (m_renderer->showmenu) { - int downPreset = m_presetPos->lastIndex() + (m_renderer->textMenuPageSize / 2.0f); // jump down by page size / 2 - if (static_cast(downPreset) >= (m_presetLoader->size() - 1)) // handle upper boundary - downPreset = 0; - SelectPreset(downPreset); // jump down menu half a page. - } - break; + case PROJECTM_K_UP: - if (m_renderer->showmenu) { - SelectPrevious(true); - } - else { - m_beatDetect->beatSensitivity += 0.01; - if (m_beatDetect->beatSensitivity > 5.0) - m_beatDetect->beatSensitivity = 5.0; - m_renderer->setToastMessage("Beat Sensitivity: " + round_float(m_beatDetect->beatSensitivity)); - } + m_beatDetect->beatSensitivity += 0.01; + if (m_beatDetect->beatSensitivity > 5.0) + { + m_beatDetect->beatSensitivity = 5.0; + } break; case PROJECTM_K_DOWN: - if (m_renderer->showmenu) { - SelectNext(true); - } - else { - m_beatDetect->beatSensitivity -= 0.01; - if (m_beatDetect->beatSensitivity < 0) - m_beatDetect->beatSensitivity = 0; - m_renderer->setToastMessage("Beat Sensitivity: " + round_float(m_beatDetect->beatSensitivity)); - } - break; - case PROJECTM_K_h: - if (TextInputActive(true)) break; // disable when searching. - m_renderer->showhelp = !m_renderer->showhelp; - m_renderer->showstats = false; - m_renderer->showmenu = false; - break; - case PROJECTM_K_F1: - if (TextInputActive(true)) break; // disable when searching. - m_renderer->showhelp = !m_renderer->showhelp; - m_renderer->showstats = false; - m_renderer->showmenu = false; + m_beatDetect->beatSensitivity -= 0.01; + if (m_beatDetect->beatSensitivity < 0) + { + m_beatDetect->beatSensitivity = 0; + } break; case PROJECTM_K_y: - if (TextInputActive(true)) break; // disable when searching. this->SetShuffleEnabled(!this->ShuffleEnabled()); - if (this->ShuffleEnabled()) { - m_renderer->setToastMessage("Shuffle Enabled"); - } - else { - m_renderer->setToastMessage("Shuffle Disabled"); - } - break; - case PROJECTM_K_F5: - if (TextInputActive(true)) break; // disable when searching. - m_renderer->showfps = !m_renderer->showfps; - // Initialize counters and reset frame count. - m_renderer->lastTimeFPS = duration_cast(system_clock::now().time_since_epoch()); - m_renderer->currentTimeFPS = duration_cast(system_clock::now().time_since_epoch()); - m_renderer->totalframes = 0; - // Hide preset name from screen and replace it with FPS counter. - if (m_renderer->showfps) - { - m_renderer->showpreset = false; - } - break; - case PROJECTM_K_F4: - if (TextInputActive(true)) break; // disable when searching. - m_renderer->showstats = !m_renderer->showstats; - if (m_renderer->showstats) { - m_renderer->showhelp = false; - m_renderer->showmenu = false; - } - break; - case PROJECTM_K_F3: { - if (TextInputActive(true)) break; // disable when searching. - m_renderer->showpreset = !m_renderer->showpreset; - // Hide FPS from screen and replace it with preset name. - if (m_renderer->showpreset) - { - m_renderer->showsearch = false; - m_renderer->showfps = false; - } - break; - } - case PROJECTM_K_F2: - m_renderer->showtitle = !m_renderer->showtitle; - break; - - case PROJECTM_K_ESCAPE: { - m_renderer->showsearch = false; // hide input menu - SetShuffleEnabled(m_renderer->shuffletrack); // restore shuffle - m_renderer->showmenu = false; // hide input - break; - } - case PROJECTM_K_f: - break; case PROJECTM_K_a: m_renderer->correction = !m_renderer->correction; break; - case PROJECTM_K_b: - break; - case PROJECTM_K_H: - case PROJECTM_K_m: - if (TextInputActive(true)) break; // disable when searching. - m_renderer->showmenu = !m_renderer->showmenu; - if (m_renderer->showmenu) { - m_renderer->showfps = false; - m_renderer->showhelp = false; - m_renderer->showstats = false; - PopulatePresetMenu(); - } - break; - case PROJECTM_K_M: - if (TextInputActive(true)) break; // disable when searching. - m_renderer->showmenu = !m_renderer->showmenu; - if (m_renderer->showmenu) - { - m_renderer->showhelp = false; - m_renderer->showstats = false; - PopulatePresetMenu(); - } - break; case PROJECTM_K_n: - if (TextInputActive(true)) break; // disable when searching. SelectNext(true); break; case PROJECTM_K_N: - if (TextInputActive(true)) break; // disable when searching. SelectNext(false); break; case PROJECTM_K_r: - if (TextInputActive(true)) break; // disable when searching. SelectRandom(true); break; case PROJECTM_K_R: - if (TextInputActive(true)) break; // disable when searching. SelectRandom(false); break; case PROJECTM_K_p: @@ -247,7 +109,6 @@ void ProjectM::DefaultKeyHandler(projectMEvent event, projectMKeycode keycode) { SelectPrevious(false); break; case PROJECTM_K_l: - if (TextInputActive(true)) break; // disable when searching. SetPresetLocked(!PresetLocked()); break; case PROJECTM_K_i: @@ -255,33 +116,6 @@ void ProjectM::DefaultKeyHandler(projectMEvent event, projectMKeycode keycode) { case PROJECTM_K_d: // d stands for write DEBUG output. m_renderer->writeNextFrameToFile = true; break; - case PROJECTM_K_RETURN: - m_renderer->toggleSearchText(); - if (m_renderer->showsearch) { - m_renderer->shuffletrack = this->ShuffleEnabled(); // track previous shuffle state. - SetShuffleEnabled(false); // disable shuffle - m_renderer->showhelp = false; - m_renderer->showstats = false; - m_renderer->showtitle = false; - m_renderer->showpreset = false; - m_renderer->showmenu = true; - PopulatePresetMenu(); - } else { - SetShuffleEnabled(m_renderer->shuffletrack); // restore shuffle - m_renderer->showmenu = false; - } - break; - case PROJECTM_K_0: -// nWaveMode=0; - break; - case PROJECTM_K_6: -// nWaveMode=6; - break; - case PROJECTM_K_7: -// nWaveMode=7; - break; - case PROJECTM_K_t: - break; case PROJECTM_K_EQUALS: case PROJECTM_K_PLUS: diff --git a/src/libprojectM/ProjectM.cpp b/src/libprojectM/ProjectM.cpp index 1cfc5700b..e3bc48f3c 100644 --- a/src/libprojectM/ProjectM.cpp +++ b/src/libprojectM/ProjectM.cpp @@ -434,23 +434,6 @@ void ProjectM::ResetOpenGL(size_t width, size_t height) m_renderer->reset(width, height); } -/** Sets the title to display */ -auto ProjectM::Title() const -> std::string -{ - return m_renderer->title; -} - -/** Sets the title to display */ -void ProjectM::SetTitle(const std::string& title) -{ - if (title != m_renderer->title) - { - m_renderer->title = title; - m_renderer->drawtitle = 1; - } -} - - auto ProjectM::InitializePresetTools() -> void { /* Set the seed to the current time in seconds */ @@ -472,9 +455,6 @@ auto ProjectM::InitializePresetTools() -> void // Load idle preset m_activePreset = m_presetLoader->loadPreset("idle://Geiss & Sperl - Feedback (projectM idle HDR mix).milk"); m_renderer->setPresetName("Geiss & Sperl - Feedback (projectM idle HDR mix)"); - - PopulatePresetMenu(); - m_renderer->SetPipeline(m_activePreset->pipeline()); ResetEngine(); @@ -536,8 +516,6 @@ void ProjectM::SelectPreset(unsigned int index, bool hardCut) return; } - PopulatePresetMenu(); - *m_presetPos = m_presetChooser->begin(index); if (!StartPresetTransition(hardCut)) { @@ -545,73 +523,6 @@ void ProjectM::SelectPreset(unsigned int index, bool hardCut) } } -// populatePresetMenu is called when a preset is loaded. -void ProjectM::PopulatePresetMenu() -{ - if (m_renderer->showmenu) - { // only track a preset list buffer if the preset menu is up. - m_renderer->m_presetList.clear(); // clear preset list buffer from renderer. - - if (TextInputActive()) - { - // if a searchTerm is active, we will populate the preset menu with search terms instead of the page we are on. - int h = 0; - std::string presetName = m_renderer->presetName(); - int presetIndex = SearchIndex(presetName); - for (unsigned int i = 0; i < PlaylistSize(); i++) - { // loop over all presets - if (CaseInsensitiveSubstringFind(PresetName(i), m_renderer->searchText()) != std::string::npos) - { // if term matches - if (h < m_renderer->textMenuPageSize) // limit to just one page, pagination is not needed. - { - h++; - m_renderer->m_presetList.push_back( - {h, PresetName(i), ""}); // populate the renders preset list. - if (h == presetIndex) - { - m_renderer->m_activePresetID = h; - } - } - } - } - } - else - { - // normal preset menu, based on pagination. - m_renderer->m_activePresetID = m_presetPos->lastIndex(); // tell renderer about the active preset ID (so it can be highlighted) - int page_start = 0; - if (m_presetPos->lastIndex() != m_presetLoader->size()) - { - page_start = m_renderer->m_activePresetID; // if it's not the idle preset, then set it to the true value - } - if (page_start < m_renderer->textMenuPageSize) - { - page_start = 0; // if we are on page 1, start at the first preset. - } - if (page_start % m_renderer->textMenuPageSize == 0) - { - // if it's a perfect division of the page size, we are good. - } - else - { - page_start = page_start - (page_start % - m_renderer->textMenuPageSize); // if not, find closest divisable number for page start - } - int page_end = page_start + m_renderer->textMenuPageSize; // page end is page start + page size - if (page_end > m_presetLoader->size()) - { - page_end = m_presetLoader->size(); - } - while (page_start < page_end) - { - m_renderer->m_presetList.push_back( - {page_start, PresetName(page_start), ""}); // populate the renders preset list. - page_start++; - } - } - } -} - bool ProjectM::StartPresetTransition(bool hardCut) { std::unique_ptr new_preset = SwitchToCurrentPreset(); @@ -619,7 +530,7 @@ bool ProjectM::StartPresetTransition(bool hardCut) { PresetSwitchFailedEvent(hardCut, **m_presetPos, "fake error"); m_errorLoadingCurrentPreset = true; - PopulatePresetMenu(); + return false; } @@ -638,8 +549,6 @@ bool ProjectM::StartPresetTransition(bool hardCut) PresetSwitchedEvent(hardCut, **m_presetPos); m_errorLoadingCurrentPreset = false; - PopulatePresetMenu(); - return true; } @@ -689,24 +598,8 @@ void ProjectM::SelectPrevious(const bool hardCut) return; } - if (TextInputActive() && m_renderer->m_presetList.size() >= 1) - { - // if search menu is up, previous is based on search terms. - if (m_renderer->m_activePresetID <= 1) - { - // loop to bottom of page is at top - m_renderer->m_activePresetID = m_renderer->m_presetList.size(); - SelectPresetByName(m_renderer->m_presetList[m_renderer->m_activePresetID - 1].name, true); - } - else - { - // otherwise move back - m_renderer->m_activePresetID--; - SelectPresetByName(m_renderer->m_presetList[m_renderer->m_activePresetID - 1].name, true); - } - } - else if (Settings().shuffleEnabled && m_presetHistory.size() >= 1 && - static_cast(m_presetHistory.back()) != m_presetLoader->size() && !m_renderer->showmenu) + if (Settings().shuffleEnabled && m_presetHistory.size() >= 1 && + static_cast(m_presetHistory.back()) != m_presetLoader->size()) { // if randomly browsing presets, "previous" should return to last random preset not the index--. Avoid returning to size() because that's the idle:// preset. m_presetFuture.push_back(m_presetPos->lastIndex()); SelectPreset(m_presetHistory.back()); @@ -732,24 +625,8 @@ void ProjectM::SelectNext(const bool hardCut) return; } - if (TextInputActive() && m_renderer->m_presetList.size() >= 1) // if search is active and there are search results - { - // if search menu is down, next is based on search terms. - if (static_cast(m_renderer->m_activePresetID) >= m_renderer->m_presetList.size()) - { - // loop to top of page is at bottom - m_renderer->m_activePresetID = 1; - SelectPresetByName(m_renderer->m_presetList[0].name, true); - } - else - { - // otherwise move forward - m_renderer->m_activePresetID++; - SelectPresetByName(m_renderer->m_presetList[m_renderer->m_activePresetID - 1].name, true); - } - } - else if (Settings().shuffleEnabled && m_presetFuture.size() >= 1 && - static_cast(m_presetFuture.front()) != m_presetLoader->size() && !m_renderer->showmenu) + if (Settings().shuffleEnabled && m_presetFuture.size() >= 1 && + static_cast(m_presetFuture.front()) != m_presetLoader->size()) { // if shuffling and we have future presets already stashed then let's go forward rather than truely move randomly. m_presetHistory.push_back(m_presetPos->lastIndex()); SelectPreset(m_presetFuture.back()); @@ -810,27 +687,6 @@ auto ProjectM::SwitchToCurrentPreset() -> std::unique_ptr void ProjectM::SetPresetLocked(bool locked) { m_renderer->noSwitch = locked; - if (PresetLocked()) - { - m_renderer->setToastMessage("Preset Locked"); - } - else - { - m_renderer->setToastMessage("Unlocked"); - } -} - -// check if search menu is up and you have search terms (2 chars). nomin means you don't care about search terms. -auto ProjectM::TextInputActive(bool noMinimumCharacters) const -> bool -{ - if (m_renderer->showsearch && (m_renderer->searchText().length() >= 2 || noMinimumCharacters)) - { - return true; - } - else - { - return false; - } } auto ProjectM::PresetLocked() const -> bool @@ -1068,15 +924,6 @@ void ProjectM::SetMeshSize(size_t meshResolutionX, size_t meshResolutionY) RecreateRenderer(); } -// toggleSearchText -void ProjectM::ToggleSearchText() -{ - if (m_renderer) - { - m_renderer->toggleSearchText(); - } -} - auto ProjectM::Pcm() -> class Pcm& { return m_pcm; @@ -1116,67 +963,6 @@ void ProjectM::SelectPresetByName(std::string presetName, bool hardCut) SelectPreset(index); } -auto ProjectM::SearchText() const -> std::string -{ - return m_renderer->getSearchText(); -} - -// update search text based on new keystroke -void ProjectM::SetSearchText(const std::string& searchKey) -{ - if (m_renderer) - { - m_renderer->setSearchText(searchKey); - } - PopulatePresetMenu(); - if (m_renderer->m_presetList.size() >= 1) - { - std::string topPreset = m_renderer->m_presetList.front().name; - m_renderer->m_activePresetID = 1; - SelectPresetByName(topPreset); - } -} - -// update search text based on new backspace -void ProjectM::DeleteSearchText() -{ - if (m_renderer) - { - m_renderer->deleteSearchText(); - } - PopulatePresetMenu(); - if (m_renderer->m_presetList.size() >= 1) - { - m_renderer->m_activePresetID = 1; - std::string topPreset = m_renderer->m_presetList.front().name; - SelectPresetByName(topPreset); - } -} - -// reset search text -void ProjectM::ResetSearchText() -{ - if (m_renderer) - { - m_renderer->resetSearchText(); - } - PopulatePresetMenu(); - if (m_renderer->m_presetList.size() >= 1) - { - m_renderer->m_activePresetID = 1; - std::string topPreset = m_renderer->m_presetList.front().name; - SelectPresetByName(topPreset); - } -} - -void ProjectM::SetToastMessage(const std::string& toastMessage) -{ - if (m_renderer) - { - m_renderer->setToastMessage(toastMessage); - } -} - auto ProjectM::Settings() const -> const class ProjectM::Settings& { return m_settings; @@ -1215,14 +1001,6 @@ void ProjectM::TouchDestroyAll() } } -void ProjectM::SetHelpText(const std::string& helpText) -{ - if (m_renderer) - { - m_renderer->setHelpText(helpText); - } -} - void ProjectM::RecreateRenderer() { m_renderer = std::make_unique(m_settings.windowWidth, m_settings.windowHeight, diff --git a/src/libprojectM/ProjectM.hpp b/src/libprojectM/ProjectM.hpp index bc61e4807..e138bf090 100644 --- a/src/libprojectM/ProjectM.hpp +++ b/src/libprojectM/ProjectM.hpp @@ -115,10 +115,6 @@ public: void ResetTextures(); - auto Title() const -> std::string; - - void SetTitle(const std::string& title); - void RenderFrame(); auto InitRenderToTexture() -> unsigned; @@ -175,12 +171,6 @@ public: void TouchDestroyAll(); - void SetHelpText(const std::string& helpText); - - void ToggleSearchText(); // turn search text input on / off - - void SetToastMessage(const std::string& toastMessage); - auto Settings() const -> const class Settings&; /// Writes a Settings configuration to the specified file @@ -193,9 +183,6 @@ public: /// Plays a preset immediately void SelectPreset(unsigned int index, bool hardCut = true); - /// Populates a page full of presets for the renderer to use. - void PopulatePresetMenu(); - /// Removes a preset from the play list. If it is playing then it will continue as normal until next switch void RemovePreset(unsigned int index); @@ -208,26 +195,11 @@ public: /// Returns true if the active preset is locked auto PresetLocked() const -> bool; - /// Returns true if the text based search menu is up. - auto TextInputActive(bool noMinimumCharacters = false) const -> bool; - auto PresetIndex(const std::string& presetFilename) const -> unsigned int; /// Plays a preset immediately when given preset name void SelectPresetByName(std::string presetName, bool hardCut = true); - // search based on keystroke - auto SearchText() const -> std::string; - - // search based on keystroke - void SetSearchText(const std::string& searchKey); - - // delete part of search term (backspace) - void DeleteSearchText(); - - // reset search term (blank) - void ResetSearchText(); - /// Returns index of currently active preset. In the case where the active /// preset was removed from the playlist, this function will return the element /// before active preset (thus the next in order preset is invariant with respect diff --git a/src/libprojectM/ProjectMCWrapper.cpp b/src/libprojectM/ProjectMCWrapper.cpp index aef2adde7..1aaa7d55a 100644 --- a/src/libprojectM/ProjectMCWrapper.cpp +++ b/src/libprojectM/ProjectMCWrapper.cpp @@ -203,18 +203,6 @@ void projectm_reset_textures(projectm_handle instance) projectMInstance->ResetTextures(); } -const char* projectm_get_title(projectm_handle instance) -{ - auto projectMInstance = handle_to_instance(instance); - return projectm_alloc_string_from_std_string(projectMInstance->Title()); -} - -void projectm_set_title(projectm_handle instance, const char* title) -{ - auto projectMInstance = handle_to_instance(instance); - projectMInstance->SetTitle(title); -} - void projectm_render_frame(projectm_handle instance) { auto projectMInstance = handle_to_instance(instance); @@ -390,28 +378,6 @@ void projectm_touch_destroy_all(projectm_handle instance) projectMInstance->TouchDestroyAll(); } -void projectm_set_help_text(projectm_handle instance, const char* help_text) -{ - if (!help_text) - { - return; - } - - auto projectMInstance = handle_to_instance(instance); - projectMInstance->SetHelpText(help_text); -} - -void projectm_set_toast_message(projectm_handle instance, const char* toast_message) -{ - if (!toast_message) - { - return; - } - - auto projectMInstance = handle_to_instance(instance); - projectMInstance->SetToastMessage(toast_message); -} - projectm_settings* projectm_get_settings(projectm_handle instance) { auto projectMInstance = handle_to_instance(instance); @@ -479,12 +445,6 @@ void projectm_select_preset(projectm_handle instance, unsigned int index, bool h projectMInstance->SelectPreset(index, hard_cut); } -void projectm_populate_preset_menu(projectm_handle instance) -{ - auto projectMInstance = handle_to_instance(instance); - projectMInstance->PopulatePresetMenu(); -} - void projectm_remove_preset(projectm_handle instance, unsigned int index) { auto projectMInstance = handle_to_instance(instance); @@ -509,12 +469,6 @@ bool projectm_is_preset_locked(projectm_handle instance) return projectMInstance->PresetLocked(); } -bool projectm_is_text_input_active(projectm_handle instance, bool no_minimum_length) -{ - auto projectMInstance = handle_to_instance(instance); - return projectMInstance->TextInputActive(no_minimum_length); -} - unsigned int projectm_get_preset_index(projectm_handle instance, const char* preset_name) { if (!preset_name) @@ -537,35 +491,6 @@ void projectm_select_preset_by_name(projectm_handle instance, const char* preset return projectMInstance->SelectPresetByName(preset_name, hard_cut); } -const char* projectm_get_search_text(projectm_handle instance) -{ - auto projectMInstance = handle_to_instance(instance); - return projectm_alloc_string_from_std_string(projectMInstance->SearchText()); -} - -void projectm_set_search_text(projectm_handle instance, const char* search_text) -{ - if (!search_text) - { - return; - } - - auto projectMInstance = handle_to_instance(instance); - return projectMInstance->SetSearchText(search_text); -} - -void projectm_delete_search_text(projectm_handle instance) -{ - auto projectMInstance = handle_to_instance(instance); - return projectMInstance->DeleteSearchText(); -} - -void projectm_reset_search_text(projectm_handle instance) -{ - auto projectMInstance = handle_to_instance(instance); - return projectMInstance->ResetSearchText(); -} - bool projectm_get_selected_preset_index(projectm_handle instance, unsigned int* index) { if (!index) diff --git a/src/libprojectM/Renderer/CMakeLists.txt b/src/libprojectM/Renderer/CMakeLists.txt index f489e677e..9b009a1c9 100644 --- a/src/libprojectM/Renderer/CMakeLists.txt +++ b/src/libprojectM/Renderer/CMakeLists.txt @@ -10,8 +10,6 @@ add_library(Renderer OBJECT DarkenCenter.hpp Filters.cpp Filters.hpp - MenuText.cpp - MenuText.h MilkdropNoise.cpp MilkdropNoise.hpp MilkdropWaveform.cpp diff --git a/src/libprojectM/Renderer/MenuText.cpp b/src/libprojectM/Renderer/MenuText.cpp deleted file mode 100644 index 713c8fcc3..000000000 --- a/src/libprojectM/Renderer/MenuText.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "Common.hpp" -#ifdef USE_TEXT_MENU - -#include "MenuText.h" - -#define GLT_IMPLEMENTATION -#include "gltext.h" - -MenuText::MenuText(int viewportWidth) - : _viewportWidth(viewportWidth) -{ - gltInit(); - _glTextInstance = gltCreateText(); -} - -MenuText::~MenuText() -{ - if (_glTextInstance) - { - gltDeleteText(_glTextInstance); - _glTextInstance = nullptr; - } -} - -void MenuText::SetViewportWidth(int viewportWidth) -{ - _viewportWidth = viewportWidth; -} - -void MenuText::CleanUp() -{ - gltTerminate(); -} - -void MenuText::DrawBegin() const -{ - // Begin text drawing (this for instance calls glUseProgram) - gltBeginDraw(); -} - -void MenuText::DrawEnd() const -{ - // Finish drawing text - will unbind font texture & shaders. - gltEndDraw(); -} - -void MenuText::Draw(std::string textLine, - GLfloat x, - GLfloat y, - GLfloat scale, - HorizontalAlignment horizontalAlignment, - VerticalAlignment verticalAlignment, - float r, - float b, - float g, - float a, - bool highlightable, - const std::string& highlightText) const -{ - if (!gltInitialized || !_glTextInstance) - { - return; - } - - int gltHorizontalAlignment = static_cast(horizontalAlignment); - int gltVerticalAlignment = static_cast(verticalAlignment); - - gltSetText(_glTextInstance, textLine.c_str()); - GLfloat textWidth = gltGetTextWidth(_glTextInstance, scale); - - auto windowWidth = static_cast(_viewportWidth); - if (gltHorizontalAlignment == GLT_LEFT) - { - // if left aligned factor in X offset - windowWidth -= x; - } - - // if our window is greater than the text width, there is no overflow so let's display it normally. - if (windowWidth < textWidth) - { - // if the text is greater than the window width, we have a problem. - while (textWidth > windowWidth) - { - textLine.pop_back(); - gltSetText(_glTextInstance, textLine.c_str()); - - gltDrawText2DAligned(_glTextInstance, x, y, scale, gltHorizontalAlignment, gltVerticalAlignment); - textWidth = gltGetTextWidth(_glTextInstance, scale); - } - - // if it's not multi-line then append a ... - if (textLine.find('\n') != std::string::npos) - { - textLine.pop_back(); - textLine.pop_back(); - textLine.pop_back(); - textLine += "..."; - } - } - - // redraw without transparency - if (highlightable && highlightText.length() > 1) - { - HighlightNeedle(textLine, highlightText, x, y, scale, gltHorizontalAlignment, gltVerticalAlignment, r, g, b, a); - } - else - { - gltColor(r, g, b, a); - gltSetText(_glTextInstance, textLine.c_str()); - gltDrawText2DAligned(_glTextInstance, x, y, scale, gltHorizontalAlignment, gltVerticalAlignment); - } -} - -void MenuText::HighlightNeedle(const std::string& textLine, - const std::string& highlightText, - GLfloat x, - GLfloat y, - GLfloat scale, - int horizontalAlignment = GLT_LEFT, - int verticalAlignment = GLT_TOP, - float r = 1.0f, - float b = 1.0f, - float g = 1.0f, - float a = 1.0f) const -{ - - size_t pos = CaseInsensitiveSubstringFind(textLine, highlightText); - - gltColor(r, g, b, a); - - if (pos == std::string::npos) - { - // Search term not found (e.g. cropped due to window size), render whole line. - gltSetText(_glTextInstance, textLine.c_str()); - gltDrawText2DAligned(_glTextInstance, x, y, scale, horizontalAlignment, verticalAlignment); - - return; - } - - // Draw everything normal, up to search term. - gltSetText(_glTextInstance, textLine.substr(0, pos).c_str()); - gltDrawText2DAligned(_glTextInstance, x, y, scale, horizontalAlignment, verticalAlignment); - - // Crop original text from "textLine" to retain casing. - std::string originalHighlightText = textLine.substr(pos, highlightText.length()); - - // highlight search term - GLfloat textWidth = gltGetTextWidth(_glTextInstance, scale); - GLfloat offset = x + textWidth; - gltColor(1.0f, 0.0f, 1.0f, a); - gltSetText(_glTextInstance, originalHighlightText.c_str()); - gltDrawText2DAligned(_glTextInstance, offset, y, scale, horizontalAlignment, verticalAlignment); - - // draw rest of name, normally - textWidth = gltGetTextWidth(_glTextInstance, scale); - offset = offset + textWidth; - gltColor(r, g, b, a); - gltSetText(_glTextInstance, textLine.substr(pos + originalHighlightText.length(), textLine.length()).c_str()); - gltDrawText2DAligned(_glTextInstance, offset, y, scale, horizontalAlignment, verticalAlignment); -} - -#endif diff --git a/src/libprojectM/Renderer/MenuText.h b/src/libprojectM/Renderer/MenuText.h deleted file mode 100644 index 54e2f08d0..000000000 --- a/src/libprojectM/Renderer/MenuText.h +++ /dev/null @@ -1,152 +0,0 @@ -#pragma once - -#ifdef USE_TEXT_MENU - -#include "projectM-opengl.h" - -#include - -struct GLTtext; - -/** - * @brief Menu text renderer - * - *

Uses the single-header glText library to render the menu overlay and toast messages.

- * - *

For proper cleanup, the CleanUp() method should be called once before shutdown or when resetting - * the OpenGL renderer. It will destroy the texture atlas and shaders. It just calls gltTerminate(). - * The gltInit() function is called each time an instance of MenuText is created, assuring that everything - * is properly initialized. This is only done once on start or after calling CleanUp().

- */ -class MenuText -{ -public: - /** - * Constants for horizontal text alignment. - */ - enum class HorizontalAlignment - { - Left = 0, //!< Render text aligned to the left - Center = 1, //!< Render text aligned to the center - Right = 2 //!< Render text aligned to the right - }; - - /** - * Constants for vertical text alignment. - */ - enum class VerticalAlignment - { - Top = 0, //!< Render text aligned to the top - Center = 1, //!< Render text aligned to the center - Bottom = 2//!< Render text aligned to the bottom - }; - - MenuText() = delete; - - /** - * Constructor. - * @param viewportWidth Sets the maximum viewport width. - */ - explicit MenuText(int viewportWidth); - virtual ~MenuText(); - - /** - * @brief Sets the maximum viewport width. - * @param viewportWidth - */ - void SetViewportWidth(int viewportWidth); - - /** - * @brief Destroy the internal glText objects, e.g. shaders and the font texture. - * - * Only call this on shutdown or when resetting the OpenGL renderer and after all instances of MenuText - * were destroyed. The next instance of MenuText will reinitialize glText. - */ - static void CleanUp(); - - /** - * @brief Binds text drawing shaders and textures. - * - * Always needs to be called before the initial call to Draw(). - */ - void DrawBegin() const; - - /** - * @brief Unbinds text drawing shaders and textures. - * - * Should be called after the last call to Draw(). - */ - void DrawEnd() const; - - /** - * @brief Renders a line or block of text. - * - *

Text is cut off if wider than the viewport. Note this can cull more text than intended if - * it consists of multiple lines, e.g. after a long line, no more text is rendered.

- * - *

Before calling Draw(), BeginDraw() must be called to set up the required OpenGL states. Draw() - * can then be called any number of times. If text rendering is done, DrawEnd() should be called.

- * - * @param textLine The text that should be rendered. - * @param x X offset of the text. - * @param y Y offset of the text. - * @param scale Font size. - * @param horizontalAlignment Horizontal text alignment inside the viewport. - * @param verticalAlignment Vertical text alignment inside the viewport. - * @param r Red color value, 0.0 to 1.0. - * @param b Blue color value, 0.0 to 1.0. - * @param g Green color value, 0.0 to 1.0. - * @param a Alpha value, 0.0 (transparent) to 1.0 (opaque). - * @param highlightable If true, highlightText will be searched in textLine and highlighted in magenta in the output. - * @param highlightText Text to be seaqrched and highlighted, case-insensitive. - */ - void Draw(std::string textLine, - GLfloat x, - GLfloat y, - GLfloat scale, - HorizontalAlignment horizontalAlignment = HorizontalAlignment::Left, - VerticalAlignment verticalAlignment = VerticalAlignment::Top, - float r = 1.0f, - float b = 1.0f, - float g = 1.0f, - float a = 1.0f, - bool highlightable = false, - const std::string& highlightText = "") const; - -protected: - - /** - * @brief Searches for highlightText in textLine and renders the search text in a different color. - * - * If the text is not found, the line will be rendered normally. The highlighted text is rendered in magenta - * with the same alpha value as the normal text. - * - * @param textLine The text that should be rendered. - * @param highlightText The text that should be highlighted. - * @param x X offset of the text. - * @param y Y offset of the text. - * @param scale Font size. - * @param horizontalAlignment Horizontal text alignment inside the viewport. - * @param verticalAlignment Vertical text alignment inside the viewport. - * @param r Red color value, 0.0 to 1.0. Only used for the non-highlighted part of the text. - * @param b Blue color value, 0.0 to 1.0. Only used for the non-highlighted part of the text. - * @param g Green color value, 0.0 to 1.0. Only used for the non-highlighted part of the text. - * @param a Alpha value, 0.0 (transparent) to 1.0 (opaque). - */ - void HighlightNeedle(const std::string& textLine, - const std::string& highlightText, - GLfloat x, - GLfloat y, - GLfloat scale, - int horizontalAlignment, - int verticalAlignment, - float r, - float b, - float g, - float a) const; - - int _viewportWidth{ 0 }; //!< The viewport width in pixels that can be used. - GLTtext* _glTextInstance{ nullptr }; //!< The glText instance pointer. -}; - -#endif \ No newline at end of file diff --git a/src/libprojectM/Renderer/Renderer.cpp b/src/libprojectM/Renderer/Renderer.cpp index ccc16711a..f57a0b422 100644 --- a/src/libprojectM/Renderer/Renderer.cpp +++ b/src/libprojectM/Renderer/Renderer.cpp @@ -28,22 +28,7 @@ Renderer::Renderer(int width, int height, int gx, int gy, , m_viewportWidth(width) , m_viewportHeight(height) , m_textureSearchPaths(textureSearchPaths) - , m_menuText(width) { - // This is the default help menu for applications that have not defined any custom menu. - const char* defaultHelpMenu = "\n" - "F1: This help menu""\n" - "F3: Show preset name""\n" - "F5: Show FPS""\n" - "L: Lock/Unlock Preset""\n" - "R: Random preset""\n" - "N/P: [N]ext+ or [P]revious-reset""\n" - "M/Return: Preset Menu (Arrow Up/Down & Page Up/Down to Navigate)""\n" - "Arrow Up/Down: Increase or Decrease Beat Sensitivity""\n" - "CTRL-F: Fullscreen"; - - this->setHelpText(defaultHelpMenu); - int size = (m_perPixelMesh.height - 1) * m_perPixelMesh.width * 4 * 2; m_perPointMeshBuffer = static_cast(wipemalloc(size * sizeof(float))); @@ -177,22 +162,6 @@ void Renderer::SetupPass1(const Pipeline& pipeline, const PipelineContext& pipel { totalframes++; - /* - If FPS is displayed (by pressing F5 or by config): - - check if 250 milliseconds has passed (1/4 of a second) - - multiply the total rendered frames (totalframes) by the fraction of a second that passed to get the approximate frames per second count. - - reset the totalframes and timer (lastTime) so we don't trigger for another 250 milliseconds. - */ - if (this->showfps) - { - this->currentTimeFPS = nowMilliseconds(); - if (timeCheck(this->currentTimeFPS, this->lastTimeFPS, (double)250)) { - this->realfps = totalframes * (1000 / 250); - setFPS(realfps); - totalframes = 0; - this->lastTimeFPS = nowMilliseconds(); - } - } glViewport(0, 0, m_textureSizeX, m_textureSizeY); m_renderContext.mat_ortho = glm::ortho(0.0f, 1.0f, 0.0f, 1.0f, -40.0f, 40.0f); @@ -242,8 +211,6 @@ void Renderer::RenderTouch(const Pipeline& pipeline, const PipelineContext& pipe void Renderer::FinishPass1() { - draw_title_to_texture(); - m_textureManager->updateMainTexture(); if(writeNextFrameToFile) { debugWriteMainTextureToFile(); @@ -276,29 +243,6 @@ void Renderer::Pass2(const Pipeline& pipeline, const PipelineContext& pipelineCo { CompositeOutput(pipeline, pipelineContext); } - - - // When console refreshes, there is a chance the preset has been changed by the user - // TODO: - draw_title_to_screen(false); - if (this->showhelp == true) - draw_help(); - if (this->showtitle == true) - draw_title(); - if (this->showfps == true) - draw_fps(); - // this->realfps - if (this->showsearch == true) - draw_search(); - if (this->showmenu == true) - draw_menu(); - if (this->showpreset == true) - draw_preset(); - if (this->showstats == true) - draw_stats(); - // We should always draw toasts last so they are on top of other text (lp/menu). - if (this->m_showToast == true) - draw_toast(); } void Renderer::RenderFrame(const Pipeline& pipeline, @@ -436,10 +380,6 @@ Renderer::~Renderer() glDeleteVertexArrays(1, &m_vaoCompositeOutput); glDeleteTextures(1, &textureRenderToTexture); - -#ifdef USE_TEXT_MENU - MenuText::CleanUp(); -#endif } void Renderer::reset(int w, int h) @@ -483,24 +423,6 @@ void Renderer::reset(int w, int h) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClear(GL_COLOR_BUFFER_BIT); - -#ifdef USE_TEXT_MENU - m_menuText.SetViewportWidth(w); - - // When the renderer resets, do a check to find out what the maximum number of lines we could display are. - int r_textMenuPageSize = 0; - int yOffset = m_textMenuYOffset; - while (true) { // infinite loop, only satisifed when we have found the max lines of text on the screen. - if (yOffset < m_viewportHeight - m_textMenuLineHeight) { // if yOffset could be displayed on the screen (vh), then we have room for the next line. - r_textMenuPageSize++; - yOffset = yOffset + m_textMenuLineHeight; - } - else { // if we reached the end of the screen, set textMenuPageSize and move on. - textMenuPageSize = r_textMenuPageSize; - break; - } - } -#endif } GLuint Renderer::initRenderToTexture() @@ -520,17 +442,6 @@ GLuint Renderer::initRenderToTexture() return textureRenderToTexture; } -void Renderer::draw_title_to_texture() -{ -#ifdef USE_TEXT_MENU - if (this->drawtitle > 100) - { - draw_title_to_screen(true); - this->drawtitle = 0; - } -#endif /** USE_TEXT_MENU */ -} - float title_y; bool Renderer::timeCheck(const milliseconds currentTime, const milliseconds lastTime, const double difference) { @@ -638,43 +549,6 @@ void Renderer::touchDestroyAll() m_waveformList.clear(); } -// turn search menu on / off -void Renderer::toggleSearchText() { - this->showsearch = !this->showsearch; - if (this->showsearch) - { - this->showfps = false; - this->showtitle = false; - } -} - -std::string Renderer::getSearchText() const -{ - return m_searchText; -} - -// search based on new key input -void Renderer::setSearchText(const std::string& theValue) -{ - m_searchText = m_searchText + theValue; -} - -// reset search text backspace (reset) -void Renderer::resetSearchText() -{ - m_searchText = ""; -} - -// search text backspace (delete a key) -void Renderer::deleteSearchText() -{ - if (m_searchText.length() >= 1) { - m_searchText = m_searchText.substr(0, m_searchText.size() - 1); - } -} - - - void Renderer::debugWriteMainTextureToFile() const { GLuint fbo; auto mainTexture = m_textureManager->getMainTexture(); @@ -717,165 +591,6 @@ void Renderer::UpdateContext(PipelineContext& context) context.aspecty = m_fInvAspectY; } -void Renderer::setToastMessage(const std::string& theValue) -{ - // Initialize counters - m_lastTimeToast = nowMilliseconds(); - m_currentTimeToast = nowMilliseconds(); - m_toastMessage = theValue; - m_showToast = true; -} - -// TODO: -void Renderer::draw_title_to_screen(bool flip) -{ -#ifdef USE_TEXT_MENU - if (this->drawtitle > 0) - { - } -#endif /** USE_TEXT_MENU */ -} - -// render search text menu -void Renderer::draw_search() -{ -#ifdef USE_TEXT_MENU - std::string search = "Search: "; - search = search + searchText(); - - m_menuText.DrawBegin(); - m_menuText.Draw(search, 30, 20, 2.5); - m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ -} - -void Renderer::draw_title() -{ -#ifdef USE_TEXT_MENU - // TODO: investigate possible banner text for GUI - // m_menuText.DrawBegin(); - // drawText(title_font, this->title.c_str(), 10, 20, 2.5); - // m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ -} - -void Renderer::draw_menu() -{ -#ifdef USE_TEXT_MENU - int menu_xOffset = 30; // x axis static point. - int menu_yOffset = 60; // y axis start point. - float windowHeight = m_viewportHeight; - float alpha = 1.0; - if (this->showsearch) // if search input is up, slightly dim preset menu - alpha = 0.82f; - m_menuText.DrawBegin(); - for (auto& it : m_presetList) { // loop over preset buffer - if (menu_yOffset < windowHeight - m_textMenuLineHeight) { // if we are not at the bottom of the screen, display preset name. - if (it.id == m_activePresetID) { // if this is the active preset, add some color. - m_menuText.Draw(it.name, menu_xOffset, menu_yOffset , 1.5, - MenuText::HorizontalAlignment::Left, - MenuText::VerticalAlignment::Top, - 1.0, 0.1, 0.1, 1.0, true, m_searchText); - } - else { - m_menuText.Draw(it.name, menu_xOffset, menu_yOffset , 1.5, - MenuText::HorizontalAlignment::Left, - MenuText::VerticalAlignment::Top, - 1.0, 1.0, 1.0, alpha, true, m_searchText); - } - } - menu_yOffset = menu_yOffset + m_textMenuLineHeight; // increase line y offset so we can track if we reached the bottom of the screen. - } - m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ -} - -void Renderer::draw_preset() -{ -#ifdef USE_TEXT_MENU - m_menuText.DrawBegin(); - m_menuText.Draw(this->presetName(), 30, 20, 2.5); - m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ -} - -void Renderer::draw_help() -{ -#ifdef USE_TEXT_MENU - // TODO: match winamp/milkdrop bindings - m_menuText.DrawBegin(); - m_menuText.Draw(this->helpText(), 30, 20, 2.5); - m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ -} - -// fake rounding - substr is good enough. -std::string Renderer::float_stats(float stat) -{ - std::string num_text = std::to_string(stat); - std::string rounded = num_text.substr(0, num_text.find(".")+4); - return rounded; -} - -// TODO -void Renderer::draw_stats() -{ -#ifdef USE_TEXT_MENU - std::string stats = "\n"; - std::string warpShader = (!m_currentPipeline->warpShader.programSource.empty()) ? "ON" : "OFF"; - std::string compShader = (!m_currentPipeline->compositeShader.programSource.empty()) ? "ON" : "OFF"; - - stats += "Render:""\n"; - stats += "Resolution: " + std::to_string(m_viewportWidth) + "x" + std::to_string(m_viewportHeight) + "\n"; - stats += "Mesh X: " + std::to_string(m_perPixelMesh.width) + "\n"; - stats += "Mesh Y: " + std::to_string(m_perPixelMesh.height) + "\n"; - stats += "Time: " + std::to_string(m_renderContext.time) + "\n"; - - stats += "\n"; - stats += "Beat Detect:""\n"; - stats += "Sensitivity: " + float_stats(m_beatDetect->beatSensitivity) + "\n"; - stats += "Bass: " + float_stats(m_beatDetect->bass) + "\n"; - stats += "Mid Range: " + float_stats(m_beatDetect->mid) + "\n"; - stats += "Treble: " + float_stats(m_beatDetect->treb) + "\n"; - stats += "Volume: " + float_stats(m_beatDetect->vol) + "\n"; - - stats += "\n"; - stats += "Preset:""\n"; - stats += "Warp Shader: " + warpShader + "\n"; - stats += "Composite Shader: " + compShader + "\n"; - m_menuText.DrawBegin(); - m_menuText.Draw(stats, 30, 20, 2.5); - m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ -} - -// TODO -void Renderer::draw_fps() -{ -#ifdef USE_TEXT_MENU - m_menuText.DrawBegin(); - m_menuText.Draw(this->fps(), 30, 20, 2.5); - m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ -} - -void Renderer::draw_toast() -{ -#ifdef USE_TEXT_MENU - m_menuText.DrawBegin(); - m_menuText.Draw(this->toastMessage(), (m_viewportWidth /2), (m_viewportHeight /2), 2.5, - MenuText::HorizontalAlignment::Center, MenuText::VerticalAlignment::Center); - m_menuText.DrawEnd(); -#endif /** USE_TEXT_MENU */ - - this->m_currentTimeToast = nowMilliseconds(); - if (timeCheck(this->m_currentTimeToast,this->m_lastTimeToast,(double)(TOAST_TIME*1000))) { - this->m_currentTimeToast = nowMilliseconds(); - this->m_lastTimeToast = nowMilliseconds(); - this->m_showToast = false; - } -} - void Renderer::CompositeOutput(const Pipeline& pipeline, const PipelineContext& pipelineContext) { glActiveTexture(GL_TEXTURE0); diff --git a/src/libprojectM/Renderer/Renderer.hpp b/src/libprojectM/Renderer/Renderer.hpp index d6eb5a097..e6fd83f71 100644 --- a/src/libprojectM/Renderer/Renderer.hpp +++ b/src/libprojectM/Renderer/Renderer.hpp @@ -8,9 +8,6 @@ #include "ShaderEngine.hpp" #include "Transformation.hpp" #include "projectM-opengl.h" -#ifdef USE_TEXT_MENU -#include "MenuText.h" -#endif /** USE_TEXT_MENU */ #include #include @@ -23,9 +20,6 @@ using namespace std::chrono; -#define TOAST_TIME 2 -#define TOUCH_TIME 5 - // for final composite grid: #define FCGSX 32 // final composite gridsize - # verts - should be EVEN. #define FCGSY 24 // final composite gridsize - # verts - should be EVEN. @@ -80,14 +74,6 @@ public: return m_presetName; } - void setHelpText(const std::string& theValue) { - m_helpText = theValue; - } - - std::string helpText() const { - return m_helpText; - } - void setFPS(const int &theValue) { m_fps = std::to_string(theValue); } @@ -100,39 +86,17 @@ public: return duration_cast(system_clock::now().time_since_epoch());; } - void toggleSearchText(); - void toggleInput(); void touch(float x, float y, int pressure, int type); void touchDrag(float x, float y, int pressure); void touchDestroy(float x, float y); void touchDestroyAll(); bool touchedWaveform(float x, float y, std::size_t i); - void setToastMessage(const std::string& theValue); - std::string getSearchText() const; - void setSearchText(const std::string& theValue); - void resetSearchText(); - void deleteSearchText(); /// Writes the contents of current mainTexture in TextureManager to a bmp file void debugWriteMainTextureToFile() const; - std::string toastMessage() const { - return m_toastMessage; - } - - std::string searchText() const { - return m_searchText; - } void UpdateContext(PipelineContext& context); - bool showfps{ false }; - bool showtitle{ false }; - bool showpreset{ false }; - bool showhelp{ false }; - bool showsearch{ false }; - bool showmenu{ false }; - bool showstats{ false }; - bool shuffletrack{ false }; bool correction{ true }; @@ -150,9 +114,6 @@ public: int m_activePresetID{ 0 }; std::vector m_presetList; - int drawtitle{ 0 }; - int textMenuPageSize{ 10 }; - private: void SetupPass1(const Pipeline& pipeline, const PipelineContext& pipelineContext); void Interpolation(const Pipeline& pipeline, const PipelineContext& pipelineContext); @@ -163,21 +124,6 @@ private: void CompositeShaderOutput(const Pipeline& pipeline, const PipelineContext& pipelineContext); void CompositeOutput(const Pipeline& pipeline, const PipelineContext& pipelineContext); - void rescale_per_pixel_matrices(); - - void draw_toast(); - void draw_fps(); - void draw_stats(); - void draw_help(); - void draw_menu(); - void draw_preset(); - void draw_search(); - void draw_title(); - void draw_title_to_screen(bool flip); - void draw_title_to_texture(); - - std::string float_stats(float stat); - int nearestPower2(int value); GLuint textureRenderToTexture{0}; @@ -195,8 +141,6 @@ private: std::string m_presetName; std::string m_fps; - std::string m_toastMessage; - std::string m_searchText; float* m_perPointMeshBuffer{nullptr}; @@ -229,10 +173,6 @@ private: GLuint m_vboCompositeShaderOutput{0}; GLuint m_vaoCompositeShaderOutput{0}; -#ifdef USE_TEXT_MENU - MenuText m_menuText; -#endif /** USE_TEXT_MENU */ - composite_shader_vertex m_compositeVertices[FCGSX * FCGSY]; int m_compositeIndices[(FCGSX - 2) * (FCGSY - 2) * 6]; @@ -243,21 +183,11 @@ private: double m_touchB{0.0};///!< Blue double m_touchA{0.0};///!< Alpha - bool m_showToast{false}; - - milliseconds m_lastTimeToast{nowMilliseconds()}; - milliseconds m_currentTimeToast{nowMilliseconds()}; - - std::string m_helpText; - std::vector m_waveformList; int m_textureSizeX{0}; int m_textureSizeY{0}; - int m_textMenuLineHeight{25}; - const int m_textMenuYOffset{60}; - float m_fAspectX{1.0}; float m_fAspectY{1.0}; float m_fInvAspectX{1.0}; diff --git a/src/libprojectM/projectM.h b/src/libprojectM/projectM.h index b81aeb20c..379d24714 100644 --- a/src/libprojectM/projectM.h +++ b/src/libprojectM/projectM.h @@ -305,18 +305,6 @@ PROJECTM_EXPORT void projectm_set_preset_rating_changed_event_callback(projectm_ projectm_preset_rating_changed_event callback, void* user_data); -/** - * @brief Reset the projectM OpenGL renderer. - * - *

Required if anything invalidates the state of the current OpenGL context projectM is rendering to.

- * - *

For resize events, it is sufficient to call projectm_set_window_size()

- * - * @param instance The projectM instance handle. - */ -PROJECTM_EXPORT void projectm_reset_gl(projectm_handle instance); - - /** * @brief Reloads all textures. * @@ -326,20 +314,6 @@ PROJECTM_EXPORT void projectm_reset_gl(projectm_handle instance); */ PROJECTM_EXPORT void projectm_reset_textures(projectm_handle instance); -/** - * @brief Returns the current title text. - * @param instance The projectM instance handle. - * @return The currently set title text. - */ -PROJECTM_EXPORT const char* projectm_get_title(projectm_handle instance); - -/** - * @brief Sets the current title text and displays it. - * @param instance The projectM instance handle. - * @param title The title text to display. - */ -PROJECTM_EXPORT void projectm_set_title(projectm_handle instance, const char* title); - /** * @brief Renders a single frame. * @@ -619,30 +593,6 @@ PROJECTM_EXPORT void projectm_touch_destroy(projectm_handle instance, float x, f */ PROJECTM_EXPORT void projectm_touch_destroy_all(projectm_handle instance); -/** - * @brief Sets the help menu text. - * - * The help menu will be toggled if the key mapped to PROJECTM_K_F1 is pressed. - * - * @param instance The projectM instance handle. - * @param help_text The help text to be displayed. - */ -PROJECTM_EXPORT void projectm_set_help_text(projectm_handle instance, const char* help_text); - -/** - * @brief Displays a short message in the center of the rendering area for a few seconds. - * - *

Useful to display song titles and changed audio settings. Used internally by projectM to display setting - * changes like preset lock.

- * - *

Only one toast message is shown at a time. If this method is called while another message is shown, it - * will be replaced immediately.

- * - * @param instance The projectM instance handle. - * @param toast_message The message to display. - */ -PROJECTM_EXPORT void projectm_set_toast_message(projectm_handle instance, const char* toast_message); - /** * @brief Returns a structure with the current projectM settings. * @param instance The projectM instance handle. @@ -676,12 +626,6 @@ PROJECTM_EXPORT void projectm_select_preset_position(projectm_handle instance, u */ PROJECTM_EXPORT void projectm_select_preset(projectm_handle instance, unsigned int index, bool hard_cut); -/** - * @brief Populates the on-screen preset menu. - * @param instance The projectM instance handle. - */ -PROJECTM_EXPORT void projectm_populate_preset_menu(projectm_handle instance); - /** * @brief Removes a preset from the playlist. * @param instance The projectM instance handle. @@ -713,15 +657,6 @@ PROJECTM_EXPORT void projectm_lock_preset(projectm_handle instance, bool lock); */ PROJECTM_EXPORT bool projectm_is_preset_locked(projectm_handle instance); -/** - * @brief Returns whether the search text input mode is active or not. - * @param instance The projectM instance handle. - * @param no_minimum_length If set to true, will return true if at least one character has been typed, otherwise - * a minimum length of three characters is required. - * @return True if text input mode is active, false otherwise. - */ -PROJECTM_EXPORT bool projectm_is_text_input_active(projectm_handle instance, bool no_minimum_length); - /** * @brief Returns the playlist index for the given preset name. * @@ -741,38 +676,6 @@ PROJECTM_EXPORT unsigned int projectm_get_preset_index(projectm_handle instance, */ PROJECTM_EXPORT void projectm_select_preset_by_name(projectm_handle instance, const char* preset_name, bool hard_cut); -/** - * @brief Returns the current preset search text. - * @param instance The projectM instance handle. - * @return The current search text used to search for presets in the playlist. - */ -PROJECTM_EXPORT const char* projectm_get_search_text(projectm_handle instance); - -/** - * @brief Sets the current preset search text. - * @param instance The projectM instance handle. - * @param search_text The search text used to search for presets in the current playlist. - */ -PROJECTM_EXPORT void projectm_set_search_text(projectm_handle instance, const char* search_text); - -/** - * @brief Deletes one character from the preset search text. - * - * This is equivalent to pressing DEL in a text box. - * - * @param instance The projectM instance handle. - */ -PROJECTM_EXPORT void projectm_delete_search_text(projectm_handle instance); - -/** - * @brief Deletes the whole search text. - * - * This will effectively leave preset search mode. - * - * @param instance The projectM instance handle. - */ -PROJECTM_EXPORT void projectm_reset_search_text(projectm_handle instance); - /** * @brief Returns the currently selected preset index. * @param instance The projectM instance handle. diff --git a/src/sdl-test-ui/audioCapture.cpp b/src/sdl-test-ui/audioCapture.cpp index 03b06e78d..b5e69bb5b 100644 --- a/src/sdl-test-ui/audioCapture.cpp +++ b/src/sdl-test-ui/audioCapture.cpp @@ -32,7 +32,6 @@ int projectMSDL::initAudioInput() { SDL_Log("Opened audio capture device index=%i devId=%i: %s", selectedAudioDevice, audioDeviceID, deviceName); std::string deviceToast = deviceName; // Example: Microphone rear deviceToast += " selected"; - projectm_set_toast_message(_projectM, deviceToast.c_str()); #ifdef DEBUG SDL_Log("Samples: %i, frequency: %i, channels: %i, format: %i", have.samples, have.freq, have.channels, have.format); #endif @@ -129,7 +128,6 @@ int projectMSDL::openAudioInput() { if(!initAudioInput() && NumAudioDevices == 0) { // the default device doesn't work, and there's no other device to try SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "No audio capture devices found"); - projectm_set_toast_message(_projectM, "No audio capture devices found: using simulated audio"); fakeAudio = true; return 0; } diff --git a/src/sdl-test-ui/pmSDL.cpp b/src/sdl-test-ui/pmSDL.cpp index eaca05041..79d701ebf 100644 --- a/src/sdl-test-ui/pmSDL.cpp +++ b/src/sdl-test-ui/pmSDL.cpp @@ -58,11 +58,6 @@ projectMSDL::~projectMSDL() _projectM = nullptr; } -void projectMSDL::setHelpText(const std::string& helpText) -{ - projectm_set_help_text(_projectM, helpText.c_str()); -} - /* Stretch projectM across multiple monitors */ void projectMSDL::stretchMonitors() { @@ -194,25 +189,6 @@ void projectMSDL::keyHandler(SDL_Event* sdl_evt) return; } break; - case SDLK_BACKSPACE: - projectm_delete_search_text(_projectM); - break; - case SDLK_SLASH: - break; - case SDLK_BACKSLASH: - break; - case SDLK_RETURN: - if (!projectm_is_text_input_active(_projectM, false)) - { - SDL_StartTextInput(); - } - break; - case SDLK_ESCAPE: - if (projectm_is_text_input_active(_projectM, false)) - { - SDL_StopTextInput(); - } - break; case SDLK_i: if (sdl_mod & KMOD_LGUI || sdl_mod & KMOD_RGUI || sdl_mod & KMOD_LCTRL) { @@ -278,10 +254,7 @@ void projectMSDL::keyHandler(SDL_Event* sdl_evt) case SDLK_SPACE: - if (!projectm_is_text_input_active(_projectM, true)) - { - projectm_lock_preset(_projectM, !projectm_is_preset_locked(_projectM)); - } + projectm_lock_preset(_projectM, !projectm_is_preset_locked(_projectM)); break; case SDLK_F1: break; @@ -424,13 +397,6 @@ void projectMSDL::pollEvent() case SDL_MOUSEBUTTONUP: mouseDown = false; break; - case SDL_TEXTINPUT: - if (projectm_is_text_input_active(_projectM, true)) - { - projectm_set_search_text(_projectM, evt.text.text); - projectm_populate_preset_menu(_projectM); - } - break; case SDL_QUIT: done = true; break; diff --git a/src/sdl-test-ui/pmSDL.hpp b/src/sdl-test-ui/pmSDL.hpp index c119de43d..125d88e37 100644 --- a/src/sdl-test-ui/pmSDL.hpp +++ b/src/sdl-test-ui/pmSDL.hpp @@ -119,7 +119,6 @@ public: void touchDrag(float x, float y, int pressure); void touchDestroy(float x, float y); void touchDestroyAll(); - void setHelpText(const std::string& theValue); void renderFrame(); void pollEvent(); bool keymod = false; diff --git a/src/sdl-test-ui/setup.cpp b/src/sdl-test-ui/setup.cpp index 74a0fce1f..ecc274509 100644 --- a/src/sdl-test-ui/setup.cpp +++ b/src/sdl-test-ui/setup.cpp @@ -235,12 +235,8 @@ projectMSDL *setupSDLApp() { settings->shuffle_enabled = 1; settings->soft_cut_ratings_enabled = 1; // ??? // get path to our app, use CWD or resource dir for presets/fonts/etc - settings->preset_url = projectm_alloc_string(presetURL.length() + 1); - strncpy(settings->preset_url, presetURL.c_str(), presetURL.length()); - settings->menu_font_url = projectm_alloc_string(menuFontURL.length() + 1); - strncpy(settings->menu_font_url, menuFontURL.c_str(), menuFontURL.length()); - settings->title_font_url = projectm_alloc_string(titleFontURL.length() + 1); - strncpy(settings->title_font_url, titleFontURL.c_str(), titleFontURL.length()); + settings->preset_path = projectm_alloc_string(presetURL.length() + 1); + strncpy(settings->preset_path, presetURL.c_str(), presetURL.length()); // init with settings app = new projectMSDL(glCtx, settings, 0); } @@ -264,28 +260,6 @@ projectMSDL *setupSDLApp() { modKey = "CMD"; #endif - std::string sdlHelpMenu = "\n" - "F1: This help menu""\n" - "F3: Show preset name""\n" - "F4: Show details and statistics""\n" - "F5: Show FPS""\n" - "L or SPACE: Lock/Unlock Preset""\n" - "R: Random preset""\n" - "N: Next preset""\n" - "P: Previous preset""\n" - "UP: Increase Beat Sensitivity""\n" - "DOWN: Decrease Beat Sensitivity""\n" -#ifdef PROJECTM_TOUCH_ENABLED - "Left Click: Drop Random Waveform on Screen""\n" - "Right Click: Remove Random Waveform""\n" + - modKey + "+Right Click: Remove All Random Waveforms""\n" -#endif - + modKey + "+I: Audio Input (listen to next device)""\n" + - modKey + "+M: Change Monitor""\n" + - modKey + "+S: Stretch Monitors""\n" + - modKey + "+F: Fullscreen""\n" + - modKey + "+Q: Quit"; - app->setHelpText(sdlHelpMenu.c_str()); app->init(win); #if STEREOSCOPIC_SBS