51 if (ImGuiID child_id = ImGui::GetID((
void*)(intptr_t)9);
52 ImGui::BeginChild(child_id, ImVec2(0, 170),
false)) {
53 const int NUM_LINES = 5;
54 const int LINE_THICKNESS = 2;
55 const int LINE_SPACING = 40;
58 ImDrawList* draw_list = ImGui::GetWindowDrawList();
62 ImVec2(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y);
63 ImVec2 canvas_p1 = ImVec2(canvas_p0.x + ImGui::GetContentRegionAvail().x,
64 canvas_p0.y + ImGui::GetContentRegionAvail().y);
65 draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(32, 32, 32, 255));
66 for (
int i = 0; i < NUM_LINES; i++) {
67 auto line_start = ImVec2(canvas_p0.x, canvas_p0.y + i * LINE_SPACING);
68 auto line_end = ImVec2(canvas_p1.x + ImGui::GetContentRegionAvail().x,
69 canvas_p0.y + i * LINE_SPACING);
70 draw_list->AddLine(line_start, line_end, IM_COL32(200, 200, 200, 255),
75 const int NUM_LEDGER_LINES = 3;
76 for (
int i = -NUM_LEDGER_LINES; i <= NUM_LINES + NUM_LEDGER_LINES; i++) {
77 if (i % 2 == 0)
continue;
78 auto line_start = ImVec2(canvas_p0.x, canvas_p0.y + i * LINE_SPACING / 2);
79 auto line_end = ImVec2(canvas_p1.x + ImGui::GetContentRegionAvail().x,
80 canvas_p0.y + i * LINE_SPACING / 2);
81 draw_list->AddLine(line_start, line_end, IM_COL32(150, 150, 150, 255),
90 float key_width = ImGui::GetContentRegionAvail().x / NUM_KEYS;
91 float white_key_height = ImGui::GetContentRegionAvail().y * 0.8f;
92 float black_key_height = ImGui::GetContentRegionAvail().y * 0.5f;
93 ImGui::Text(
"Piano Roll");
95 ImDrawList* draw_list = ImGui::GetWindowDrawList();
99 ImVec2(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y);
100 ImVec2 canvas_p1 = ImVec2(canvas_p0.x + ImGui::GetContentRegionAvail().x,
101 canvas_p0.y + ImGui::GetContentRegionAvail().y);
102 draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(200, 200, 200, 255));
104 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4.f, 0.f));
105 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.f);
106 for (
int i = 0; i < NUM_KEYS; i++) {
108 ImVec2 key_pos = ImVec2(i * key_width, 0.0f);
112 if (i % 12 == 1 || i % 12 == 3 || i % 12 == 6 || i % 12 == 8 ||
115 key_size = ImVec2(key_width * 0.6f, black_key_height);
116 key_color = ImVec4(0, 0, 0, 255);
117 text_color = ImVec4(255, 255, 255, 255);
120 key_size = ImVec2(key_width, white_key_height);
121 key_color = ImVec4(255, 255, 255, 255);
122 text_color = ImVec4(0, 0, 0, 255);
126 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.f, 0.f));
127 ImGui::PushStyleColor(ImGuiCol_Button, key_color);
128 ImGui::PushStyleColor(ImGuiCol_Text, text_color);
129 if (ImGui::Button(kSongNotes[i].data(), key_size)) {
132 ImGui::PopStyleColor();
133 ImGui::PopStyleColor();
134 ImGui::PopStyleVar();
136 ImVec2 button_pos = ImGui::GetItemRectMin();
137 ImVec2 button_size = ImGui::GetItemRectSize();
140 dest.x = button_pos.x + button_size.x;
141 dest.y = button_pos.y + button_size.y;
142 ImGui::GetWindowDrawList()->AddRectFilled(button_pos, dest,
143 IM_COL32(200, 200, 255, 200));
148 ImGui::PopStyleVar();
149 ImGui::PopStyleVar();
165 static bool is_playing =
false;
166 static int selected_option = 0;
167 static int current_volume = 0;
168 static bool has_loaded_song =
false;
169 const int MAX_VOLUME = 100;
171 if (is_playing && !has_loaded_song) {
172 has_loaded_song =
true;
175 gui::ItemLabel(
"Select a song to edit: ", gui::ItemLabelFlags::Left);
176 ImGui::Combo(
"#songs_in_game", &selected_option, kGameSongs, 30);
180 ImGui::TableSetupColumn(
"#play");
181 ImGui::TableSetupColumn(
"#rewind");
182 ImGui::TableSetupColumn(
"#fastforward");
183 ImGui::TableSetupColumn(
"#volume");
184 ImGui::TableSetupColumn(
"#debug");
186 ImGui::TableSetupColumn(
"#slider");
188 ImGui::TableNextColumn();
191 has_loaded_song =
false;
193 is_playing = !is_playing;
202 ImGui::TableNextColumn();
203 ImGui::SliderInt(
"Volume", ¤t_volume, 0, 100);
207 const int SONG_DURATION = 120;
208 static int current_time = 0;
212 ImGui::Text(
"%d:%02d", current_time / 60, current_time % 60);
215 ImGui::ProgressBar((
float)current_time / SONG_DURATION);