Debian Codegraph @

src/gui/channels.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 "misc/cpp/imgui_stdlib.h"
22 #include "IconsFontAwesome4.h"
23 #include <imgui.h>
24
25 void FurnaceGUI::drawChannels() {
26 if (nextWindow==GUI_WINDOW_CHANNELS) {
27 channelsOpen=true;
28 ImGui::SetNextWindowFocus();
29 nextWindow=GUI_WINDOW_NOTHING;
30 }
31 if (!channelsOpen) return;
32 if (mobileUI) {
33 patWindowPos=(portrait?ImVec2(0.0f,(mobileMenuPos*-0.65*canvasH)):ImVec2((0.16*canvasH)+0.5*canvasW*mobileMenuPos,0.0f));
34 patWindowSize=(portrait?ImVec2(canvasW,canvasH-(0.16*canvasW)):ImVec2(canvasW-(0.16*canvasH),canvasH));
35 ImGui::SetNextWindowPos(patWindowPos);
36 ImGui::SetNextWindowSize(patWindowSize);
37 } else {
38 //ImGui::SetNextWindowSizeConstraints(ImVec2(440.0f*dpiScale,400.0f*dpiScale),ImVec2(canvasW,canvasH));
39 }
40 if (ImGui::Begin("Channels",&channelsOpen,globalWinFlags,_("Channels"))) {
41 if (ImGui::BeginTable("ChannelList",5)) {
42 ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0);
43 ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed,0.0);
44 ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthFixed,0.0);
45 ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch,0.0);
46 ImGui::TableSetupColumn("c4",ImGuiTableColumnFlags_WidthFixed,48.0f*dpiScale);
47 ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
48 ImGui::TableNextColumn();
49 ImGui::Text(_("Pat"));
50 ImGui::TableNextColumn();
51 ImGui::Text(_("Osc"));
52 ImGui::TableNextColumn();
53 ImGui::Text(_("Swap"));
54 ImGui::TableNextColumn();
55 ImGui::Text(_("Name"));
56 for (int i=0; i<e->getTotalChannelCount(); i++) {
57 ImGui::PushID(i);
58 ImGui::TableNextRow();
59 ImGui::TableNextColumn();
60 if (ImGui::Checkbox("##VisiblePat",&e->curSubSong->chanShow[i])) {
61 MARK_MODIFIED;
62 }
63 if (ImGui::IsItemHovered()) {
64 ImGui::SetTooltip(_("Show in pattern"));
65 }
66 ImGui::TableNextColumn();
67 if (ImGui::Checkbox("##VisibleChanOsc",&e->curSubSong->chanShowChanOsc[i])) {
68 MARK_MODIFIED;
69 }
70 if (ImGui::IsItemHovered()) {
71 ImGui::SetTooltip(_("Show in per-channel oscilloscope"));
72 }
73 ImGui::TableNextColumn();
74 if (ImGui::Button(ICON_FA_ARROWS)) {
75 }
76 if (ImGui::BeginDragDropSource()) {
77 chanToMove=i;
78 ImGui::SetDragDropPayload("FUR_CHAN",NULL,0,ImGuiCond_Once);
79 ImGui::Button(ICON_FA_ARROWS "##ChanDrag");
80 ImGui::EndDragDropSource();
81 } else if (ImGui::IsItemHovered()) {
82 ImGui::SetTooltip(_("%s #%d\n(drag to swap channels)"),e->getSystemName(e->sysOfChan[i]),e->dispatchChanOfChan[i]);
83 }
84 if (ImGui::BeginDragDropTarget()) {
85 const ImGuiPayload* dragItem=ImGui::AcceptDragDropPayload("FUR_CHAN");
86 if (dragItem!=NULL) {
87 if (dragItem->IsDataType("FUR_CHAN")) {
88 if (chanToMove!=i && chanToMove>=0) {
89 e->swapChannelsP(chanToMove,i);
90 MARK_MODIFIED;
91 }
92 chanToMove=-1;
93 }
94 }
95 ImGui::EndDragDropTarget();
96 }
97 ImGui::TableNextColumn();
98 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
99 if (ImGui::InputTextWithHint("##ChanName",e->getChannelName(i),&e->curSubSong->chanName[i])) {
100 MARK_MODIFIED;
101 }
102 ImGui::TableNextColumn();
103 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
104 if (ImGui::InputTextWithHint("##ChanShortName",e->getChannelShortName(i),&e->curSubSong->chanShortName[i])) {
105 MARK_MODIFIED;
106 }
107 ImGui::PopID();
108 }
109 ImGui::EndTable();
110 }
111 }
112 if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_CHANNELS;
113 ImGui::End();
114 }