Skip to content

Commit 9f12cb4

Browse files
authored
Merge pull request #6 from broken-bytes/dev
Color Picker on list click
2 parents b0e3315 + c792bcb commit 9f12cb4

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ target_include_directories(${APP} PUBLIC external/)
5353
target_include_directories(${APP} PRIVATE include/)
5454

5555

56-
add_custom_command(TARGET ${APP} POST_BUILD
56+
add_custom_command(TARGET ${APP} POST_BUILD
5757
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/bin" "$<TARGET_FILE_DIR:${APP}>")

include/MainWindow.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ namespace BrokenBytes::DualSense4Windows::UI {
4545
LRESULT CALLBACK ProcessEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
4646

4747
private:
48+
std::unique_ptr<ColorPicker> _picker;
4849
std::vector<char*> _devices;
4950
std::vector<DualSenseInfo> _info;
5051
HWND _tabView;
5152
HWND _listView;
5253
std::map<std::wstring, HWND> _tabs;
54+
55+
void ShowColorPicker();
5356

5457
HWND CreateTabControl();
5558
HWND CreateListViewControl();

src/ColorPicker.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ namespace BrokenBytes::DualSense4Windows::UI {
152152
dwPos[1] = SendMessage(_gH, TBM_GETPOS, 0, 0);
153153
dwPos[2] = SendMessage(_bH, TBM_GETPOS, 0, 0);
154154
SetColor(dwPos[0], dwPos[1], dwPos[2]);
155-
RedrawWindow(Handle(), nullptr, nullptr, RDW_INVALIDATE);
156-
UpdateWindow(Handle());
155+
RedrawWindow(
156+
Handle(),
157+
nullptr,
158+
nullptr,
159+
RDW_INVALIDATE
160+
);
157161
break;
158162
default:
159163
return DefWindowProcA(Handle(), uMsg, wParam, lParam);

src/MainWindow.cxx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ namespace BrokenBytes::DualSense4Windows::UI {
4040

4141
void MainWindow::Show() {
4242
Window::Show();
43-
auto color = new ColorPicker(Color { 120, 120, 120});
44-
color->ColorChanged.connect([this](Color c) {
45-
ColorChanged(0, c);
46-
});
4743
}
4844

4945
void MainWindow::Hide() {
@@ -94,6 +90,7 @@ namespace BrokenBytes::DualSense4Windows::UI {
9490
PAINTSTRUCT ps;
9591
HDC hdc;
9692

93+
// TODO: Should move to switch
9794
if(uMsg == WM_DESTROY) {
9895
PostQuitMessage(0);
9996
}
@@ -105,10 +102,31 @@ namespace BrokenBytes::DualSense4Windows::UI {
105102
if (uMsg == WM_PAINT) {
106103

107104
}
105+
106+
if(uMsg == WM_NOTIFY) {
107+
switch (reinterpret_cast<LPNMHDR>(lParam)->code) {
108+
case LVN_ITEMACTIVATE:
109+
ShowColorPicker();
110+
break;
111+
}
112+
}
108113

109114
return DefWindowProc(Handle(), uMsg, wParam, lParam);
110115
}
111116

117+
void MainWindow::ShowColorPicker() {
118+
if(_picker != nullptr) {
119+
_picker->Show();
120+
return;
121+
}
122+
123+
_picker = std::make_unique<ColorPicker>(Color{ 120, 120, 120 });
124+
_picker->ColorChanged.connect([this](Color c) {
125+
ColorChanged(0, c);
126+
});
127+
_picker->Show();
128+
}
129+
112130
HWND MainWindow::CreateTabControl() {
113131
RECT rcClient;
114132
INITCOMMONCONTROLSEX icex;
@@ -149,7 +167,6 @@ namespace BrokenBytes::DualSense4Windows::UI {
149167
}
150168

151169
HWND MainWindow::CreateListViewControl() {
152-
153170
RECT r;
154171
GetWindowRect(_tabView, &r);
155172

0 commit comments

Comments
 (0)