diff --git a/AsuroTool/ApplicationData.h b/AsuroTool/ApplicationData.h index a21a16f..7c77f4c 100644 --- a/AsuroTool/ApplicationData.h +++ b/AsuroTool/ApplicationData.h @@ -39,6 +39,7 @@ public: class ApplicationSettings { public: + bool docked = false; bool showDisabledDevices = false; bool fitWindowHeight = true; bool minimizeToTray = true; diff --git a/AsuroTool/AsuroTool.cpp b/AsuroTool/AsuroTool.cpp index 1d346b5..359d048 100644 --- a/AsuroTool/AsuroTool.cpp +++ b/AsuroTool/AsuroTool.cpp @@ -116,7 +116,6 @@ void init(DrawData& drawData, ApplicationData& appData) nid.uVersion = NOTIFYICON_VERSION_4; Shell_NotifyIcon(NIM_SETVERSION, &nid); - // TODO: Add a different kind of hook, that gets mouse events (or other?) if (!SetWindowsHookEx(WH_CALLWNDPROC, trayIconEventHandler, instance, GetCurrentThreadId())) { std::cout << "Failed to hook tray icon events: " << std::hex << GetLastError() << std::endl; @@ -137,7 +136,7 @@ void draw(DrawData& drawData, ApplicationData& appData) ImVec2 viewportSize = ImGui::GetMainViewport()->Size; // Menu Bar - customYCursor += menuBar(appData).y; + customYCursor += menuBar(drawData, appData).y; // Playback Devices ImGui::SetNextWindowPos(ImVec2(0, customYCursor)); @@ -156,6 +155,13 @@ void draw(DrawData& drawData, ApplicationData& appData) { drawData.window_size.y = customYCursor; } + + if (appData.settings.docked) + { + int monitorX, monitorY, monitorW, monitorH; + glfwGetMonitorWorkarea(glfwGetPrimaryMonitor(), &monitorX, &monitorY, &monitorW, &monitorH); + glfwSetWindowPos(drawData.window, monitorX + monitorW - drawData.window_size.x, monitorY + monitorH - drawData.window_size.y); + } } void cleanup(DrawData& drawData, ApplicationData& appData) @@ -167,7 +173,7 @@ void cleanup(DrawData& drawData, ApplicationData& appData) bool test = Shell_NotifyIcon(NIM_DELETE, &nid); } -ImVec2 menuBar(ApplicationData& appData) +ImVec2 menuBar(DrawData& drawData, ApplicationData& appData) { ImVec2 size{}; @@ -175,6 +181,13 @@ ImVec2 menuBar(ApplicationData& appData) { if (ImGui::BeginMenu("Settings")) { + bool prevDocked = appData.settings.docked; + ImGui::Checkbox("Docked", &appData.settings.docked); + if (appData.settings.docked != prevDocked) + { + glfwSetWindowAttrib(drawData.window, GLFW_DECORATED, !appData.settings.docked); + } + ImGui::Checkbox("Show Disabled Devices", &appData.settings.showDisabledDevices); ImGui::Checkbox("Fit Window Height", &appData.settings.fitWindowHeight); ImGui::Checkbox("Minimize To Tray", &appData.settings.minimizeToTray); @@ -189,6 +202,23 @@ ImVec2 menuBar(ApplicationData& appData) } ImGui::EndMenu(); } + + if (appData.settings.docked) + { + ImVec2 availableSpace = ImGui::GetContentRegionAvail(); + ImVec2 cursorPos = ImGui::GetCursorPos(); + ImGui::SetCursorPosX(cursorPos.x + availableSpace.x - 33.); + + if (ImGui::SmallButton("-")) + { + glfwIconifyWindow(drawData.window); + } + if (ImGui::SmallButton("x")) + { + glfwSetWindowShouldClose(drawData.window, GLFW_TRUE); + } + } + size = ImGui::GetWindowSize(); ImGui::EndMainMenuBar(); } diff --git a/AsuroTool/AsuroTool.h b/AsuroTool/AsuroTool.h index 5295bf3..2a589ca 100644 --- a/AsuroTool/AsuroTool.h +++ b/AsuroTool/AsuroTool.h @@ -8,6 +8,6 @@ void init(DrawData& drawData, ApplicationData& customData); void draw(DrawData& drawData, ApplicationData& customData); void cleanup(DrawData& drawData, ApplicationData& appData); -ImVec2 menuBar(ApplicationData& appData); +ImVec2 menuBar(DrawData& drawData, ApplicationData& appData); ImVec2 audioDeviceWindow(ApplicationData& appData, std::vector& deviceList, const char* title); void drawCircle(float radius, ImU32 color);