|
@@ -10,7 +10,16 @@ void window_resize_callback(GLFWwindow *window, int width, int height)
|
|
|
}
|
|
|
|
|
|
BaseWindow::BaseWindow(int width, int height, const char *title, Color clear_color, Audio audio_handler)
|
|
|
- : m_window_height(height), m_window_width(width), m_window_title(title), m_clear_color(clear_color), m_audio_handler(audio_handler) {}
|
|
|
+ : m_window_height(height),
|
|
|
+ m_window_width(width),
|
|
|
+ m_window_title(title),
|
|
|
+ m_clear_color(clear_color),
|
|
|
+ m_audio_handler(audio_handler) {}
|
|
|
+
|
|
|
+BaseWindow::~BaseWindow()
|
|
|
+{
|
|
|
+ glfwTerminate();
|
|
|
+}
|
|
|
|
|
|
int BaseWindow::run()
|
|
|
{
|
|
@@ -70,47 +79,53 @@ int BaseWindow::run()
|
|
|
}
|
|
|
|
|
|
static std::filesystem::path selected;
|
|
|
- if (m_audio_handler.loaded_files().size() > 0) {
|
|
|
- if(ImGui::BeginListBox("##", ImVec2(-FLT_MIN, 5 * ImGui::GetTextLineHeightWithSpacing())))
|
|
|
+ if (m_audio_handler.loaded_files().size() > 0)
|
|
|
+ {
|
|
|
+ if (ImGui::BeginListBox("##", ImVec2(-FLT_MIN, 5 * ImGui::GetTextLineHeightWithSpacing())))
|
|
|
{
|
|
|
|
|
|
- for (auto file: m_audio_handler.loaded_files()) {
|
|
|
+ for (auto file : m_audio_handler.loaded_files())
|
|
|
+ {
|
|
|
bool is_selected = selected.compare(file);
|
|
|
- if (ImGui::Selectable(file.string().c_str(), is_selected)) {
|
|
|
+ if (ImGui::Selectable(file.string().c_str(), is_selected))
|
|
|
+ {
|
|
|
selected = file;
|
|
|
m_audio_handler.select_file(file);
|
|
|
}
|
|
|
|
|
|
- if(is_selected) {
|
|
|
+ if (is_selected)
|
|
|
+ {
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
ImGui::EndListBox();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
ImGui::End();
|
|
|
fileDialog.Display();
|
|
|
- if (fileDialog.HasSelected()) {
|
|
|
+ if (fileDialog.HasSelected())
|
|
|
+ {
|
|
|
m_audio_handler.load_file(fileDialog.GetSelected());
|
|
|
m_audio_handler.select_file(fileDialog.GetSelected());
|
|
|
fileDialog.ClearSelected();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
ImGui::Begin("Player controls");
|
|
|
{
|
|
|
- if (ImGui::Button("Play")) {
|
|
|
+ if (ImGui::Button("Play"))
|
|
|
+ {
|
|
|
m_audio_handler.play();
|
|
|
}
|
|
|
- if (ImGui::Button("Stop")) {
|
|
|
+ if (ImGui::Button("Stop"))
|
|
|
+ {
|
|
|
m_audio_handler.stop();
|
|
|
}
|
|
|
}
|
|
|
ImGui::End();
|
|
|
|
|
|
- if (m_audio_handler.decoder().is_finished) {
|
|
|
+ if (m_audio_handler.decoder().is_finished)
|
|
|
+ {
|
|
|
m_audio_handler.next_music();
|
|
|
}
|
|
|
|