53 if (ImGuiID child_id = ImGui::GetID((
void*)(intptr_t)9);
54 ImGui::BeginChild(child_id, ImVec2(0, 170),
false)) {
55 const int NUM_LINES = 5;
56 const int LINE_THICKNESS = 2;
57 const int LINE_SPACING = 40;
60 ImDrawList* draw_list = ImGui::GetWindowDrawList();
64 ImVec2(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y);
65 ImVec2 canvas_p1 = ImVec2(canvas_p0.x + ImGui::GetContentRegionAvail().x,
66 canvas_p0.y + ImGui::GetContentRegionAvail().y);
67 draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(32, 32, 32, 255));
68 for (
int i = 0; i < NUM_LINES; i++) {
69 auto line_start = ImVec2(canvas_p0.x, canvas_p0.y + i * LINE_SPACING);
70 auto line_end = ImVec2(canvas_p1.x + ImGui::GetContentRegionAvail().x,
71 canvas_p0.y + i * LINE_SPACING);
72 draw_list->AddLine(line_start, line_end, IM_COL32(200, 200, 200, 255),
77 const int NUM_LEDGER_LINES = 3;
78 for (
int i = -NUM_LEDGER_LINES; i <= NUM_LINES + NUM_LEDGER_LINES; i++) {
79 if (i % 2 == 0)
continue;
80 auto line_start = ImVec2(canvas_p0.x, canvas_p0.y + i * LINE_SPACING / 2);
81 auto line_end = ImVec2(canvas_p1.x + ImGui::GetContentRegionAvail().x,
82 canvas_p0.y + i * LINE_SPACING / 2);
83 draw_list->AddLine(line_start, line_end, IM_COL32(150, 150, 150, 255),
92 float key_width = ImGui::GetContentRegionAvail().x / NUM_KEYS;
93 float white_key_height = ImGui::GetContentRegionAvail().y * 0.8f;
94 float black_key_height = ImGui::GetContentRegionAvail().y * 0.5f;
95 ImGui::Text(
"Piano Roll");
97 ImDrawList* draw_list = ImGui::GetWindowDrawList();
101 ImVec2(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y);
102 ImVec2 canvas_p1 = ImVec2(canvas_p0.x + ImGui::GetContentRegionAvail().x,
103 canvas_p0.y + ImGui::GetContentRegionAvail().y);
104 draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(200, 200, 200, 255));
106 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4.f, 0.f));
107 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.f);
108 for (
int i = 0; i < NUM_KEYS; i++) {
110 ImVec2 key_pos = ImVec2(i * key_width, 0.0f);
114 if (i % 12 == 1 || i % 12 == 3 || i % 12 == 6 || i % 12 == 8 ||
117 key_size = ImVec2(key_width * 0.6f, black_key_height);
118 key_color = ImVec4(0, 0, 0, 255);
119 text_color = ImVec4(255, 255, 255, 255);
122 key_size = ImVec2(key_width, white_key_height);
123 key_color = ImVec4(255, 255, 255, 255);
124 text_color = ImVec4(0, 0, 0, 255);
128 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.f, 0.f));
129 ImGui::PushStyleColor(ImGuiCol_Button, key_color);
130 ImGui::PushStyleColor(ImGuiCol_Text, text_color);
131 if (ImGui::Button(kSongNotes[i].data(), key_size)) {
134 ImGui::PopStyleColor();
135 ImGui::PopStyleColor();
136 ImGui::PopStyleVar();
138 ImVec2 button_pos = ImGui::GetItemRectMin();
139 ImVec2 button_size = ImGui::GetItemRectSize();
142 dest.x = button_pos.x + button_size.x;
143 dest.y = button_pos.y + button_size.y;
144 ImGui::GetWindowDrawList()->AddRectFilled(button_pos, dest,
145 IM_COL32(200, 200, 255, 200));
150 ImGui::PopStyleVar();
151 ImGui::PopStyleVar();
167 static bool is_playing =
false;
168 static int selected_option = 0;
169 static int current_volume = 0;
170 static bool has_loaded_song =
false;
171 const int MAX_VOLUME = 100;
173 if (is_playing && !has_loaded_song) {
174 has_loaded_song =
true;
177 gui::ItemLabel(
"Select a song to edit: ", gui::ItemLabelFlags::Left);
178 ImGui::Combo(
"#songs_in_game", &selected_option, kGameSongs, 30);
182 ImGui::TableSetupColumn(
"#play");
183 ImGui::TableSetupColumn(
"#rewind");
184 ImGui::TableSetupColumn(
"#fastforward");
185 ImGui::TableSetupColumn(
"#volume");
186 ImGui::TableSetupColumn(
"#debug");
188 ImGui::TableSetupColumn(
"#slider");
190 ImGui::TableNextColumn();
193 has_loaded_song =
false;
195 is_playing = !is_playing;
204 ImGui::TableNextColumn();
205 ImGui::SliderInt(
"Volume", ¤t_volume, 0, 100);
209 const int SONG_DURATION = 120;
210 static int current_time = 0;
214 ImGui::Text(
"%d:%02d", current_time / 60, current_time % 60);
217 ImGui::ProgressBar((
float)current_time / SONG_DURATION);