/* Copyright 2019 flyinghead This file is part of reicast. reicast is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. reicast is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with reicast. If not, see . */ #include "gui_util.h" #include #include #include #include #include "types.h" #include "stdclass.h" #include "oslib/directory.h" #include "imgui/imgui.h" #include "imgui/imgui_internal.h" #include "hw/maple/maple_devs.h" static std::string select_current_directory; static std::vector subfolders; static std::vector folderFiles; bool subfolders_read; #ifdef _WIN32 static const std::string separators = "/\\"; static const std::string native_separator = "\\"; #else static const std::string separators = "/"; static const std::string native_separator = "/"; #endif #define PSEUDO_ROOT ":" extern int insetLeft, insetRight, insetTop, insetBottom; void error_popup(); void select_file_popup(const char *prompt, StringCallback callback, bool selectFile, const std::string& selectExtension) { if (select_current_directory.empty()) { #if defined(__ANDROID__) const char *home = nowide::getenv("REICAST_HOME"); if (home != NULL) { const char *pcolon = strchr(home, ':'); if (pcolon != NULL) select_current_directory = std::string(home, pcolon - home); else select_current_directory = home; } #elif defined(__unix__) || defined(__APPLE__) const char *home = nowide::getenv("HOME"); if (home != NULL) select_current_directory = home; #elif defined(_WIN32) if (nowide::getenv("HOMEPATH") != NULL) { const char *home_drive = nowide::getenv("HOMEDRIVE"); if (home_drive != NULL) select_current_directory = home_drive; select_current_directory += nowide::getenv("HOMEPATH"); } #elif defined(__SWITCH__) select_current_directory = "/"; #endif if (select_current_directory.empty()) { select_current_directory = get_writable_config_path(""); if (select_current_directory.empty()) select_current_directory = "."; } } fullScreenWindow(true); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0); if (ImGui::BeginPopup(prompt, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize )) { std::string path = select_current_directory; std::string::size_type last_sep = path.find_last_of(separators); if (last_sep == path.size() - 1) path.pop_back(); static std::string error_message; if (!subfolders_read) { subfolders.clear(); folderFiles.clear(); error_message.clear(); #ifdef _WIN32 if (select_current_directory == PSEUDO_ROOT) { error_message = "Drives"; // List all the drives u32 drives = GetLogicalDrives(); for (int i = 0; i < 32; i++) if ((drives & (1 << i)) != 0) subfolders.push_back(std::string(1, (char)('A' + i)) + ":\\"); #ifdef TARGET_UWP // Add the home directory to the list of drives as it's not accessible from the root std::string home; const char *home_drive = nowide::getenv("HOMEDRIVE"); if (home_drive != NULL) home = home_drive; home += nowide::getenv("HOMEPATH"); subfolders.push_back(home); #endif } else #elif __ANDROID__ if (select_current_directory == PSEUDO_ROOT) { error_message = "Storage Locations"; const char *home = nowide::getenv("REICAST_HOME"); while (home != NULL) { const char *pcolon = strchr(home, ':'); if (pcolon != NULL) { subfolders.push_back(std::string(home, pcolon - home)); home = pcolon + 1; } else { subfolders.push_back(home); home = NULL; } } } else #endif { DIR *dir = flycast::opendir(select_current_directory.c_str()); if (dir == NULL) { error_message = "Cannot read " + select_current_directory; subfolders.emplace_back(".."); } else { bool dotdot_seen = false; while (true) { struct dirent *entry = flycast::readdir(dir); if (entry == NULL) break; std::string name(entry->d_name); #ifdef __APPLE__ extern std::string os_PrecomposedString(std::string string); name = os_PrecomposedString(name); #endif if (name == ".") continue; std::string child_path = path + "/" + name; bool is_dir = false; #ifndef _WIN32 if (entry->d_type == DT_DIR) is_dir = true; if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) { struct stat st; if (flycast::stat(child_path.c_str(), &st) != 0) continue; if (S_ISDIR(st.st_mode)) is_dir = true; } #else // _WIN32 nowide::wstackstring wname; if (wname.convert(child_path.c_str())) { DWORD attr = GetFileAttributesW(wname.c_str()); if (attr != INVALID_FILE_ATTRIBUTES) { if (attr & FILE_ATTRIBUTE_HIDDEN) continue; if (attr & FILE_ATTRIBUTE_DIRECTORY) is_dir = true; } } #endif if (is_dir) { if (flycast::access(child_path.c_str(), R_OK) == 0) { if (name == "..") dotdot_seen = true; subfolders.push_back(name); } } else { std::string extension = get_file_extension(name); if (selectFile) { if (extension == selectExtension) folderFiles.push_back(name); } else if (extension == "zip" || extension == "7z" || extension == "chd" || extension == "gdi" || extension == "cdi" || extension == "cue" || (!config::HideLegacyNaomiRoms && (extension == "bin" || extension == "lst" || extension == "dat"))) folderFiles.push_back(name); } } flycast::closedir(dir); #if defined(_WIN32) || defined(__ANDROID__) || defined(__SWITCH__) if (!dotdot_seen) subfolders.emplace_back(".."); #else (void)dotdot_seen; #endif } } std::stable_sort(subfolders.begin(), subfolders.end()); std::stable_sort(folderFiles.begin(), folderFiles.end()); subfolders_read = true; } ImGui::Text("%s", error_message.empty() ? select_current_directory.c_str() : error_message.c_str()); ImGui::BeginChild(ImGui::GetID("dir_list"), ImVec2(0, - 30 * settings.display.uiScale - ImGui::GetStyle().ItemSpacing.y), true, ImGuiWindowFlags_DragScrolling); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ScaledVec2(8, 20)); for (const auto& name : subfolders) { std::string child_path; if (name == "..") { std::string::size_type last_sep = path.find_last_of(separators); if (last_sep == std::string::npos) { if (path.empty()) // Root folder continue; #ifdef _WIN32 if (path.size() == 2 && path[1] == ':') child_path = PSEUDO_ROOT; else #endif if (path == ".") child_path = ".."; else if (path == "..") child_path = ".." + native_separator + ".."; else child_path = "."; } else if (last_sep == 0) child_path = native_separator; else if (path.size() >= 2 && path.substr(path.size() - 2) == "..") child_path = path + native_separator + ".."; else { child_path = path.substr(0, last_sep); #ifdef _WIN32 if (child_path.size() == 2 && child_path[1] == ':') // C: -> C:/ child_path += native_separator; #endif } #ifdef __ANDROID__ if (access(child_path.c_str(), R_OK) != 0) child_path = PSEUDO_ROOT; #endif } else { #if defined(_WIN32) || defined(__ANDROID__) if (path == PSEUDO_ROOT) child_path = name; else #endif child_path = path + native_separator + name; } if (ImGui::Selectable(name == ".." ? ".. Up to Parent Directory" : name.c_str())) { subfolders_read = false; select_current_directory = child_path; } } ImGui::PushStyleColor(ImGuiCol_Text, { 1, 1, 1, selectFile ? 1.f : 0.3f }); for (const auto& name : folderFiles) { if (selectFile) { if (ImGui::Selectable(name.c_str())) { subfolders_read = false; if (callback(false, select_current_directory + native_separator + name)) ImGui::CloseCurrentPopup(); } } else { ImGui::Text("%s", name.c_str()); } } ImGui::PopStyleColor(); scrollWhenDraggingOnVoid(); windowDragScroll(); ImGui::PopStyleVar(); ImGui::EndChild(); if (!selectFile) { if (ImGui::Button("Select Current Directory", ScaledVec2(0, 30))) { if (callback(false, select_current_directory)) { subfolders_read = false; ImGui::CloseCurrentPopup(); } } ImGui::SameLine(); } if (ImGui::Button("Cancel", ScaledVec2(0, 30))) { subfolders_read = false; callback(true, ""); ImGui::CloseCurrentPopup(); } error_popup(); ImGui::EndPopup(); } ImGui::PopStyleVar(); } // See https://github.com/ocornut/imgui/issues/3379 void scrollWhenDraggingOnVoid(ImGuiMouseButton mouse_button) { ImGuiContext& g = *ImGui::GetCurrentContext(); ImGuiWindow* window = g.CurrentWindow; while (window != nullptr && (window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_DragScrolling) && window->ScrollMax.x == 0.0f && window->ScrollMax.y == 0.0f) window = window->ParentWindow; if (window == nullptr || !(window->Flags & ImGuiWindowFlags_DragScrolling)) return; bool hovered = false; bool held = false; ImGuiButtonFlags button_flags = (mouse_button == ImGuiMouseButton_Left) ? ImGuiButtonFlags_MouseButtonLeft : (mouse_button == ImGuiMouseButton_Right) ? ImGuiButtonFlags_MouseButtonRight : ImGuiButtonFlags_MouseButtonMiddle; if (g.HoveredId == 0) // If nothing hovered so far in the frame (not same as IsAnyItemHovered()!) ImGui::ButtonBehavior(window->Rect(), window->GetID("##scrolldraggingoverlay"), &hovered, &held, button_flags); const ImVec2& delta = ImGui::GetIO().MouseDelta; if (held && delta != ImVec2()) { window->DragScrolling = true; window->ScrollSpeed = delta; } } static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges) { for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2) { out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]); base_codepoint += accumulative_offsets[n]; } out_ranges[0] = 0; } const ImWchar* GetGlyphRangesChineseSimplifiedOfficial() { // Store all official characters for Simplified Chinese. // Sourced from https://en.wikipedia.org/wiki/Table_of_General_Standard_Chinese_Characters // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) static const short accumulative_offsets_from_0x4E00[] = { 0,1,2,4,1,1,1,1,2,1,1,1,1,2,1,1,1,2,1,1,1,1,1,1,4,2,1,2,3,1,2,3,2,2,4,1,1,1,2,1,4,1,2,3,1,2,1,1,1,1,1,2,1,1,2,2,1,3,1,1,1,1,1,5,3,7,1,2,5,6, 8,2,1,2,1,1,1,1,2,1,1,1,1,3,2,1,4,2,1,2,1,1,1,1,1,2,1,1,1,4,1,2,1,2,1,1,5,1,1,1,1,1,1,1,1,2,1,1,2,1,3,2,1,1,1,1,1,1,4,1,1,2,2,1,1,3,2,1,1, 4,2,1,2,1,1,4,2,2,2,7,1,1,1,2,1,1,1,1,6,1,1,1,1,3,1,1,2,1,1,1,1,1,3,1,2,2,1,2,2,2,2,2,2,1,1,3,2,3,7,1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,3,1, 1,4,3,3,1,3,1,2,2,2,1,1,1,1,1,2,1,1,1,4,1,2,2,2,2,3,3,1,3,2,3,3,2,1,1,1,1,1,2,2,1,5,1,4,6,4,1,1,5,3,1,1,1,1,6,1,1,1,2,1,1,1,2,2,3,2,1,1,1, 2,1,1,2,2,2,1,2,2,4,14,1,2,3,1,1,1,3,1,1,2,2,1,2,4,1,1,1,1,1,2,1,1,6,6,1,1,2,3,2,4,1,4,2,1,4,2,5,2,5,4,7,1,3,2,4,1,4,3,1,1,3,2,3,1,4,5,3, 14,2,2,1,1,3,6,8,1,12,7,1,5,2,4,12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1,1,1,1, 1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,1,5,1,1,2,2,4,1,1,1,2,6,1,2,3,2,5,9,1,4,5,2,2,10,2,2,6,5,7,3,1,5,7,4,12,3,4,1,4,1,5,1,1,1,1, 1,1,1,1,2,2,2,2,3,296,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,315,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,10,1,1,2,5,1,3,6,1,1,3,7, 2,7,18,1,2,2,1,6,3,2,4,1,1,2,3,4,3,1,1,2,1,1,1,3,2,2,1,5,10,2,1,2,13,2,1,2,2,1,4,2,7,2,7,2,1,3,2,6,2,2,2,1,3,6,2,7,1,46,1,1,1,1,1,1,1,1,1, 1,1,1,1,13,1,1,4,1,2,43,1,1 }; static ImWchar base_ranges[] = // not zero-terminated { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x2000, 0x206F, // General Punctuation 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions 0xFF00, 0xFFEF // Half-width characters }; static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; if (!full_ranges[0]) { memcpy(full_ranges, base_ranges, sizeof(base_ranges)); UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); } return &full_ranges[0]; } const ImWchar* GetGlyphRangesChineseTraditionalOfficial() { // Store all official characters for Traditional Chinese. // Sourced from https://https://en.wikipedia.org/wiki/List_of_Graphemes_of_Commonly-Used_Chinese_Characters // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) static const short accumulative_offsets_from_0x4E00[] = { 0,1,2,5,1,1,1,2,3,1,3,1,1,2,1,5,1,3,4,5,2,5,6,1,2,8,2,6,2,1,1,3,1,3,2,1,4,1,1,10,10,11,4,4,2,3,1,2,3,1,2,1,4,2,3,1,2,3,1,1,2,3,1,1,1,12,6,1, 2,1,2,1,3,1,2,7,1,1,1,1,1,5,1,4,1,1,11,2,1,3,5,1,1,2,2,8,1,3,2,1,1,4,4,22,1,4,2,2,2,2,1,6,3,1,1,5,1,1,1,1,3,1,2,2,2,1,1,1,2,3,6,3,3,1,3,2,6, 4,4,3,2,3,2,2,7,5,2,17,1,6,1,9,3,1,1,6,4,1,1,1,6,1,2,3,1,1,1,1,13,1,4,5,2,4,2,6,3,2,1,1,2,2,1,2,2,2,1,1,5,2,2,2,1,2,1,1,1,2,9,6,7,4,2,3,2,1, 6,5,2,9,15,1,1,1,6,3,5,8,4,5,2,1,9,10,1,5,1,2,2,4,3,7,10,2,4,1,4,9,2,2,7,3,4,4,2,5,2,2,4,1,7,2,2,4,7,2,9,8,5,5,4,1,2,1,1,1,1,1,1,2,1,1,4,1,2, 1,2,5,6,3,2,1,1,2,1,1,1,3,4,1,1,1,4,4,9,1,3,4,1,3,11,2,2,1,7,4,6,1,6,9,5,1,1,15,1,3,1,15,1,2,3,2,1,1,3,3,1,2,3,1,1,2,4,3,1,5,6,7,4,1,1,1,3,2, 6,1,1,2,1,6,2,4,3,1,1,1,1,6,2,5,1,1,12,1,5,3,2,1,2,6,2,4,4,1,1,4,4,10,4,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,2,1,2,1,1,1,5,8,1,4,1,2,1,6,1,3,1,2,1,11,1,2,7,3,4,3,5,1,3,1,1,1,2,2,1,1,8,1,3,2,1,2,4,1,5,2,5,3,4,1,2, 2,5,4,2,1,2,4,1,1,2,2,3,6,2,9,3,8,6,1,4,1,4,2,4,10,4,5,1,2,2,1,1,4,2,1,4,7,2,6,9,6,2,2,9,8,3,3,7,20,2,3,5,1,7,9,17,6,2,1,5,4,2,1,1,2,1,2,4, 4,1,1,1,4,1,9,3,9,3,7,1,1,2,11,6,1,1,1,9,3,3,9,4,4,1,1,55,7,2,2,3,4,2,8,23,4,3,5,2,1,3,2,3,2,8,1,1,5,2,4,1,2,4,2,1,5,3,3,3,7,13,8,1,1,6,12, 1,10,2,56,3,12,3,4,1,1,3,2,1,13,15,1,1,3,4,2,2,2,3,11,4,14,2,13,8,3,18,5,7,7,2,3,2,16,2,3,1,4,3,3,5,62,7,1,7,1,4,19,3,1,1,4,14,7,1,1,12,8,3, 7,13,8,3,2,1,9,11,5,1,2,1,10,5,4,2,21,8,26,26,3,27,1,30,21,16,6,18,8,4,10,3,22,2,1,32,1,109,4,10,1,2,16,3,12,6,8,3,2,19,4,18,12,3,1,9,2,6, 23,38,5,14,17,4,14,20,1,32,4,87,4,3,1,2,12,7,1,4,6,2,6,4,1,10,7,1,1,1,5,10,1,1,2,3,4,3,1,1,1,2,8,7,5,3,16,1,6,5,2,4,7,12,8,7,3,12,1,7,13,2, 2,3,4,2,6,5,22,3,4,8, }; static ImWchar base_ranges[] = // not zero-terminated { 0x0020, 0x00FF, // Basic Latin + Latin Supplement 0x2000, 0x206F, // General Punctuation 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana 0x31F0, 0x31FF, // Katakana Phonetic Extensions 0xFF00, 0xFFEF // Half-width characters }; static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; if (!full_ranges[0]) { memcpy(full_ranges, base_ranges, sizeof(base_ranges)); UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); } return &full_ranges[0]; } // Helper to display a little (?) mark which shows a tooltip when hovered. void ShowHelpMarker(const char* desc) { ImGui::TextDisabled("(?)"); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); ImGui::PushTextWrapPos(ImGui::GetFontSize() * 25.0f); ImGui::TextUnformatted(desc); ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } } template bool OptionCheckbox(const char *name, config::Option& option, const char *help) { bool b = option; if (option.isReadOnly()) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } bool pressed = ImGui::Checkbox(name, &b); if (option.isReadOnly()) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } if (pressed) option.set(b); if (help != nullptr) { ImGui::SameLine(); ShowHelpMarker(help); } return pressed; } template bool OptionCheckbox(const char *name, config::Option& option, const char *help); template bool OptionCheckbox(const char *name, config::Option& option, const char *help); bool OptionSlider(const char *name, config::Option& option, int min, int max, const char *help) { int v = option; if (option.isReadOnly()) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } bool valueChanged = ImGui::SliderInt(name, &v, min, max); if (option.isReadOnly()) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } else if (valueChanged) option.set(v); if (help != nullptr) { ImGui::SameLine(); ShowHelpMarker(help); } return valueChanged; } bool OptionArrowButtons(const char *name, config::Option& option, int min, int max, const char *help) { const float innerSpacing = ImGui::GetStyle().ItemInnerSpacing.x; ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.f, 0.5f)); // Left ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_FrameBg]); float width = ImGui::CalcItemWidth() - innerSpacing * 2.0f - ImGui::GetFrameHeight() * 2.0f; std::string id = "##" + std::string(name); ImGui::ButtonEx((std::to_string((int)option) + id).c_str(), ImVec2(width, 0), ImGuiButtonFlags_Disabled); ImGui::PopStyleColor(); ImGui::PopStyleVar(); ImGui::SameLine(0.0f, innerSpacing); ImGui::PushButtonRepeat(true); bool valueChanged = false; if (option.isReadOnly()) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } if (ImGui::ArrowButton((id + "left").c_str(), ImGuiDir_Left)) { option.set(std::max(min, option - 1)); valueChanged = true; } ImGui::SameLine(0.0f, innerSpacing); if (ImGui::ArrowButton((id + "right").c_str(), ImGuiDir_Right)) { option.set(std::min(max, option + 1)); valueChanged = true; } if (option.isReadOnly()) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } ImGui::PopButtonRepeat(); ImGui::SameLine(0.0f, innerSpacing); ImGui::Text("%s", name); if (help != nullptr) { ImGui::SameLine(); ShowHelpMarker(help); } return valueChanged; } template bool OptionRadioButton(const char *name, config::Option& option, T value, const char *help) { int v = (int)option; if (option.isReadOnly()) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } bool pressed = ImGui::RadioButton(name, &v, (int)value); if (option.isReadOnly()) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } if (pressed) option.set((T)v); if (help != nullptr) { ImGui::SameLine(); ShowHelpMarker(help); } return pressed; } template bool OptionRadioButton(const char *name, config::Option& option, bool value, const char *help); template bool OptionRadioButton(const char *name, config::Option& option, int value, const char *help); void OptionComboBox(const char *name, config::Option& option, const char *values[], int count, const char *help) { if (option.isReadOnly()) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } if (ImGui::BeginCombo(name, values[option], ImGuiComboFlags_None)) { for (int i = 0; i < count; i++) { bool is_selected = option == i; if (ImGui::Selectable(values[i], &is_selected)) option = i; if (is_selected) ImGui::SetItemDefaultFocus(); } ImGui::EndCombo(); } if (option.isReadOnly()) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } if (help != nullptr) { ImGui::SameLine(); ShowHelpMarker(help); } } void fullScreenWindow(bool modal) { if (!modal) { ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0); if (insetLeft > 0) { ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(insetLeft, ImGui::GetIO().DisplaySize.y)); ImGui::Begin("##insetLeft", NULL, ImGuiWindowFlags_NoDecoration); ImGui::End(); } if (insetRight > 0) { ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x - insetRight, 0)); ImGui::SetNextWindowSize(ImVec2(insetRight, ImGui::GetIO().DisplaySize.y)); ImGui::Begin("##insetRight", NULL, ImGuiWindowFlags_NoDecoration); ImGui::End(); } if (insetTop > 0) { ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, insetTop)); ImGui::Begin("##insetTop", NULL, ImGuiWindowFlags_NoDecoration); ImGui::End(); } if (insetBottom > 0) { ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - insetBottom)); ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, insetBottom)); ImGui::Begin("##insetBottom", NULL, ImGuiWindowFlags_NoDecoration); ImGui::End(); } ImGui::PopStyleVar(2); } ImGui::SetNextWindowPos(ImVec2(insetLeft, insetTop)); ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x - insetLeft - insetRight, ImGui::GetIO().DisplaySize.y - insetTop - insetBottom)); } static void computeScrollSpeed(float &v) { constexpr float friction = 3.f; if (std::abs(v) > friction) { float sign = (v > 0.f) - (v < 0.f); v -= friction * sign; } else { v = 0.f; } } void windowDragScroll() { ImGuiWindow *window = ImGui::GetCurrentWindow(); if (window->DragScrolling) { if (!ImGui::GetIO().MouseDown[ImGuiMouseButton_Left]) { computeScrollSpeed(window->ScrollSpeed.x); computeScrollSpeed(window->ScrollSpeed.y); if (window->ScrollSpeed == ImVec2()) { window->DragScrolling = false; // FIXME we should really move the mouse off-screen after a touch up and this wouldn't be necessary // the only problem is tool tips gui_set_mouse_position(-1, -1); } } else { ImVec2 delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Left); if (delta != ImVec2()) ImGui::ResetMouseDragDelta(); window->ScrollSpeed = delta; } if (window->DragScrolling) { ImGui::SetScrollX(window, window->Scroll.x - window->ScrollSpeed.x); ImGui::SetScrollY(window, window->Scroll.y - window->ScrollSpeed.y); } } }