/** * Furnace Tracker - multi-system chiptune tracker * Copyright (C) 2021-2022 tildearrow and contributors * * This program 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. * * This program 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 this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "gui.h" #include "../ta-log.h" #include const char* logLevels[5]={ "ERROR", "warning", "info", "debug", "trace" }; FurnaceGUIColors logColors[5]={ GUI_COLOR_LOGLEVEL_ERROR, GUI_COLOR_LOGLEVEL_WARNING, GUI_COLOR_LOGLEVEL_INFO, GUI_COLOR_LOGLEVEL_DEBUG, GUI_COLOR_LOGLEVEL_TRACE }; void FurnaceGUI::drawLog() { if (nextWindow==GUI_WINDOW_LOG) { logOpen=true; ImGui::SetNextWindowFocus(); nextWindow=GUI_WINDOW_NOTHING; } if (!logOpen) return; if (ImGui::Begin("Log Viewer",&logOpen,globalWinFlags)) { ImGui::Checkbox("Follow",&followLog); ImGui::SameLine(); ImGui::Text("Level"); ImGui::SameLine(); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); ImGui::Combo("##LogLevel",&logLevel,logLevels,5); if (ImGui::BeginTable("LogView",3,ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersInnerV)) { ImGui::PushFont(patFont); float timeChars=ImGui::CalcTextSize("00:00:00").x; float levelChars=ImGui::CalcTextSize("warning").x; ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,timeChars); ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed,levelChars); ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupScrollFreeze(0,1); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextColumn(); ImGui::TextUnformatted("time"); ImGui::TableNextColumn(); ImGui::TextUnformatted("level"); ImGui::TableNextColumn(); ImGui::TextUnformatted("message"); int pos=logPosition; for (int i=0; i