diff --git a/CMakeLists.txt b/CMakeLists.txt index 34e5d28..659828c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,5 +53,5 @@ target_include_directories(${APP} PUBLIC external/) target_include_directories(${APP} PRIVATE include/) - add_custom_command(TARGET ${APP} POST_BUILD +add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/bin" "$") diff --git a/include/MainWindow.hxx b/include/MainWindow.hxx index b5844ce..21e366c 100644 --- a/include/MainWindow.hxx +++ b/include/MainWindow.hxx @@ -45,11 +45,14 @@ namespace BrokenBytes::DualSense4Windows::UI { LRESULT CALLBACK ProcessEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) override; private: + std::unique_ptr _picker; std::vector _devices; std::vector _info; HWND _tabView; HWND _listView; std::map _tabs; + + void ShowColorPicker(); HWND CreateTabControl(); HWND CreateListViewControl(); diff --git a/src/ColorPicker.cxx b/src/ColorPicker.cxx index b8957e8..341e7b4 100644 --- a/src/ColorPicker.cxx +++ b/src/ColorPicker.cxx @@ -152,8 +152,12 @@ namespace BrokenBytes::DualSense4Windows::UI { dwPos[1] = SendMessage(_gH, TBM_GETPOS, 0, 0); dwPos[2] = SendMessage(_bH, TBM_GETPOS, 0, 0); SetColor(dwPos[0], dwPos[1], dwPos[2]); - RedrawWindow(Handle(), nullptr, nullptr, RDW_INVALIDATE); - UpdateWindow(Handle()); + RedrawWindow( + Handle(), + nullptr, + nullptr, + RDW_INVALIDATE + ); break; default: return DefWindowProcA(Handle(), uMsg, wParam, lParam); diff --git a/src/MainWindow.cxx b/src/MainWindow.cxx index 3788f2a..d082296 100644 --- a/src/MainWindow.cxx +++ b/src/MainWindow.cxx @@ -40,10 +40,6 @@ namespace BrokenBytes::DualSense4Windows::UI { void MainWindow::Show() { Window::Show(); - auto color = new ColorPicker(Color { 120, 120, 120}); - color->ColorChanged.connect([this](Color c) { - ColorChanged(0, c); - }); } void MainWindow::Hide() { @@ -94,6 +90,7 @@ namespace BrokenBytes::DualSense4Windows::UI { PAINTSTRUCT ps; HDC hdc; + // TODO: Should move to switch if(uMsg == WM_DESTROY) { PostQuitMessage(0); } @@ -105,10 +102,31 @@ namespace BrokenBytes::DualSense4Windows::UI { if (uMsg == WM_PAINT) { } + + if(uMsg == WM_NOTIFY) { + switch (reinterpret_cast(lParam)->code) { + case LVN_ITEMACTIVATE: + ShowColorPicker(); + break; + } + } return DefWindowProc(Handle(), uMsg, wParam, lParam); } + void MainWindow::ShowColorPicker() { + if(_picker != nullptr) { + _picker->Show(); + return; + } + + _picker = std::make_unique(Color{ 120, 120, 120 }); + _picker->ColorChanged.connect([this](Color c) { + ColorChanged(0, c); + }); + _picker->Show(); + } + HWND MainWindow::CreateTabControl() { RECT rcClient; INITCOMMONCONTROLSEX icex; @@ -149,7 +167,6 @@ namespace BrokenBytes::DualSense4Windows::UI { } HWND MainWindow::CreateListViewControl() { - RECT r; GetWindowRect(_tabView, &r);