Debian Codegraph @

src/gui/songInfo.cpp

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "gui.h"
21 #include "imgui.h"
22 #include "misc/cpp/imgui_stdlib.h"
23 #include "intConst.h"
24
25 void FurnaceGUI::drawSongInfo(bool asChild) {
26 if (nextWindow==GUI_WINDOW_SONG_INFO) {
27 songInfoOpen=true;
28 ImGui::SetNextWindowFocus();
29 nextWindow=GUI_WINDOW_NOTHING;
30 }
31 if (!songInfoOpen && !asChild) return;
32 bool began=asChild?ImGui::BeginChild("Song Info##Song Information"):ImGui::Begin("Song Info##Song Information",&songInfoOpen,globalWinFlags,_("Song Info##Song Information"));
33 if (began) {
34 if (ImGui::BeginTable("NameAuthor",2,ImGuiTableFlags_SizingStretchProp)) {
35 ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0);
36 ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0);
37 ImGui::TableNextRow();
38 ImGui::TableNextColumn();
39 ImGui::AlignTextToFramePadding();
40 ImGui::Text(_("Name"));
41 ImGui::TableNextColumn();
42 float avail=ImGui::GetContentRegionAvail().x;
43 ImGui::SetNextItemWidth(avail);
44 if (ImGui::InputText("##Name",&e->song.name,ImGuiInputTextFlags_UndoRedo)) { MARK_MODIFIED
45 updateWindowTitle();
46 }
47 ImGui::TableNextRow();
48 ImGui::TableNextColumn();
49 ImGui::AlignTextToFramePadding();
50 ImGui::Text(_("Author"));
51 ImGui::TableNextColumn();
52 ImGui::SetNextItemWidth(avail);
53 if (ImGui::InputText("##Author",&e->song.author,ImGuiInputTextFlags_UndoRedo)) {
54 MARK_MODIFIED;
55 }
56
57 ImGui::TableNextRow();
58 ImGui::TableNextColumn();
59 ImGui::AlignTextToFramePadding();
60 ImGui::Text(_("Album"));
61 ImGui::TableNextColumn();
62 ImGui::SetNextItemWidth(avail);
63 if (ImGui::InputText("##Category",&e->song.category,ImGuiInputTextFlags_UndoRedo)) {
64 MARK_MODIFIED;
65 }
66 ImGui::TableNextRow();
67 ImGui::TableNextColumn();
68 ImGui::AlignTextToFramePadding();
69 ImGui::Text(_("System"));
70 ImGui::TableNextColumn();
71 ImGui::SetNextItemWidth(MAX(16.0f*dpiScale,avail-autoButtonSize-ImGui::GetStyle().ItemSpacing.x));
72 if (ImGui::InputText("##SystemName",&e->song.systemName,ImGuiInputTextFlags_UndoRedo)) {
73 MARK_MODIFIED;
74 updateWindowTitle();
75 e->song.autoSystem=false;
76 }
77 ImGui::SameLine();
78 pushToggleColors(e->song.autoSystem);
79 if (ImGui::Button(_("Auto"))) {
80 e->song.autoSystem=!e->song.autoSystem;
81 if (e->song.autoSystem) {
82 autoDetectSystem();
83 updateWindowTitle();
84 }
85 MARK_MODIFIED;
86 }
87 popToggleColors();
88 autoButtonSize=ImGui::GetItemRectSize().x;
89
90 ImGui::EndTable();
91 }
92
93 if (ImGui::BeginTable("OtherProps",2,ImGuiTableFlags_SizingStretchProp)) {
94 ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0);
95 ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0);
96
97 ImGui::TableNextRow();
98 ImGui::TableNextColumn();
99 ImGui::AlignTextToFramePadding();
100 ImGui::Text(_("Tuning (A-4)"));
101 ImGui::TableNextColumn();
102 float tune=e->song.tuning;
103 float avail=ImGui::GetContentRegionAvail().x;
104 ImGui::SetNextItemWidth(avail);
105 if (ImGui::InputFloat("##Tuning",&tune,1.0f,10.0f,"%g")) { MARK_MODIFIED
106 if (tune<220.0f) tune=220.0f;
107 if (tune>880.0f) tune=880.0f;
108 e->song.tuning=tune;
109 }
110 ImGui::EndTable();
111 }
112 }
113 if (!asChild && ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_SONG_INFO;
114 if (asChild) {
115 ImGui::EndChild();
116 } else {
117 ImGui::End();
118 }
119 }