56 if (ImGuiID child_id = ImGui::GetID((
void*)(intptr_t)9);
57 ImGui::BeginChild(child_id, ImVec2(0, 170),
false)) {
58 const int NUM_LINES = 5;
59 const int LINE_THICKNESS = 2;
60 const int LINE_SPACING = 40;
63 ImDrawList* draw_list = ImGui::GetWindowDrawList();
67 ImVec2(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y);
68 ImVec2 canvas_p1 = ImVec2(canvas_p0.x + ImGui::GetContentRegionAvail().x,
69 canvas_p0.y + ImGui::GetContentRegionAvail().y);
70 draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(32, 32, 32, 255));
71 for (
int i = 0; i < NUM_LINES; i++) {
72 auto line_start = ImVec2(canvas_p0.x, canvas_p0.y + i * LINE_SPACING);
73 auto line_end = ImVec2(canvas_p1.x + ImGui::GetContentRegionAvail().x,
74 canvas_p0.y + i * LINE_SPACING);
75 draw_list->AddLine(line_start, line_end, IM_COL32(200, 200, 200, 255),
80 const int NUM_LEDGER_LINES = 3;
81 for (
int i = -NUM_LEDGER_LINES; i <= NUM_LINES + NUM_LEDGER_LINES; i++) {
82 if (i % 2 == 0)
continue;
83 auto line_start = ImVec2(canvas_p0.x, canvas_p0.y + i * LINE_SPACING / 2);
84 auto line_end = ImVec2(canvas_p1.x + ImGui::GetContentRegionAvail().x,
85 canvas_p0.y + i * LINE_SPACING / 2);
86 draw_list->AddLine(line_start, line_end, IM_COL32(150, 150, 150, 255),
95 float key_width = ImGui::GetContentRegionAvail().x / NUM_KEYS;
96 float white_key_height = ImGui::GetContentRegionAvail().y * 0.8f;
97 float black_key_height = ImGui::GetContentRegionAvail().y * 0.5f;
98 ImGui::Text(
"Piano Roll");
100 ImDrawList* draw_list = ImGui::GetWindowDrawList();
104 ImVec2(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y);
105 ImVec2 canvas_p1 = ImVec2(canvas_p0.x + ImGui::GetContentRegionAvail().x,
106 canvas_p0.y + ImGui::GetContentRegionAvail().y);
107 draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(200, 200, 200, 255));
109 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4.f, 0.f));
110 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.f);
111 for (
int i = 0; i < NUM_KEYS; i++) {
113 ImVec2 key_pos = ImVec2(i * key_width, 0.0f);
117 if (i % 12 == 1 || i % 12 == 3 || i % 12 == 6 || i % 12 == 8 ||
120 key_size = ImVec2(key_width * 0.6f, black_key_height);
121 key_color = ImVec4(0, 0, 0, 255);
122 text_color = ImVec4(255, 255, 255, 255);
125 key_size = ImVec2(key_width, white_key_height);
126 key_color = ImVec4(255, 255, 255, 255);
127 text_color = ImVec4(0, 0, 0, 255);
131 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.f, 0.f));
132 ImGui::PushStyleColor(ImGuiCol_Button, key_color);
133 ImGui::PushStyleColor(ImGuiCol_Text, text_color);
134 if (ImGui::Button(kSongNotes[i].data(), key_size)) {
137 ImGui::PopStyleColor();
138 ImGui::PopStyleColor();
139 ImGui::PopStyleVar();
141 ImVec2 button_pos = ImGui::GetItemRectMin();
142 ImVec2 button_size = ImGui::GetItemRectSize();
145 dest.x = button_pos.x + button_size.x;
146 dest.y = button_pos.y + button_size.y;
147 ImGui::GetWindowDrawList()->AddRectFilled(button_pos, dest,
148 IM_COL32(200, 200, 255, 200));
153 ImGui::PopStyleVar();
154 ImGui::PopStyleVar();
170 static bool is_playing =
false;
171 static int selected_option = 0;
172 static int current_volume = 0;
173 static bool has_loaded_song =
false;
174 const int MAX_VOLUME = 100;
176 if (is_playing && !has_loaded_song) {
177 has_loaded_song =
true;
180 gui::ItemLabel(
"Select a song to edit: ", gui::ItemLabelFlags::Left);
181 ImGui::Combo(
"#songs_in_game", &selected_option, kGameSongs, 30);
185 ImGui::TableSetupColumn(
"#play");
186 ImGui::TableSetupColumn(
"#rewind");
187 ImGui::TableSetupColumn(
"#fastforward");
188 ImGui::TableSetupColumn(
"#volume");
189 ImGui::TableSetupColumn(
"#debug");
191 ImGui::TableSetupColumn(
"#slider");
193 ImGui::TableNextColumn();
196 has_loaded_song =
false;
198 is_playing = !is_playing;
201 ImGui::TableNextColumn();
206 ImGui::TableNextColumn();
211 ImGui::TableNextColumn();
219 ImGui::TableNextColumn();
220 ImGui::SliderInt(
"Volume", ¤t_volume, 0, 100);
224 const int SONG_DURATION = 120;
225 static int current_time = 0;
229 ImGui::Text(
"%d:%02d", current_time / 60, current_time % 60);
232 ImGui::ProgressBar((
float)current_time / SONG_DURATION);