forked from ambilight-4-mediaportal/AtmoWin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtmoLiveSettings.cpp
More file actions
287 lines (238 loc) · 11.4 KB
/
Copy pathAtmoLiveSettings.cpp
File metadata and controls
287 lines (238 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#include "StdAfx.h"
#include "resource.h"
#include "atmotools.h"
#include "AtmoLiveSettings.h"
CAtmoLiveSettings::CAtmoLiveSettings(HINSTANCE hInst, HWND parent, CAtmoDynData *pDynData) : CBasicDialog(hInst, IDD_EFFECT_LIVE, parent)
{
this->m_pDynData = pDynData;
m_pBackupConfig = new CAtmoConfig();
m_pBackupConfig->Assign( m_pDynData->getAtmoConfig() );
}
CAtmoLiveSettings::~CAtmoLiveSettings(void)
{
delete m_pBackupConfig;
}
void CAtmoLiveSettings::LoadDisplayList() {
CAtmoDisplays *pAtmoDisplays = this->m_pDynData->getAtmoDisplays();
HWND hwndCtrl;
hwndCtrl = getDlgItem(IDC_DISPLAYS);
ComboBox_ResetContent(hwndCtrl);
for(int i=0;i<pAtmoDisplays->getCount();i++) {
TAtmoDisplayInfo nfo = pAtmoDisplays->getDisplayInfo(i);
ComboBox_AddString(hwndCtrl, nfo.infoText);
}
ComboBox_SetCurSel(hwndCtrl, m_pDynData->getAtmoConfig()->getLiveView_DisplayNr());
}
ATMO_BOOL CAtmoLiveSettings::InitDialog(WPARAM wParam)
{
CAtmoConfig *config = m_pDynData->getAtmoConfig();
char buffer[256];
HWND hwndCtrl;
hwndCtrl = this->getDlgItem(IDC_GDI_CAPURE_RATE);
sprintf(buffer,"%d",config->getLiveView_GDI_FrameRate());
Edit_SetText(hwndCtrl, buffer);
Edit_LimitText(hwndCtrl,2);
LoadDisplayList();
hwndCtrl = getDlgItem(IDC_FILTERMODE);
ComboBox_AddString(hwndCtrl, "No Filter");
ComboBox_AddString(hwndCtrl, "Combined");
ComboBox_AddString(hwndCtrl, "Percent");
ComboBox_SetCurSel(hwndCtrl, (int)config->getLiveViewFilterMode());
hwndCtrl = getDlgItem(IDC_WIDESCREEN);
Button_SetCheck(hwndCtrl, config->getLiveView_WidescreenMode());
SetupSliderControl(IDC_EdgeWeighting,1,30,config->getLiveView_EdgeWeighting(),5);
SendMessage(getDlgItem(IDC_EdgeWeighting),TBM_SETPAGESIZE,0,2);
sprintf(buffer,"Edge weighting [%d]",config->getLiveView_EdgeWeighting());
SetStaticText(IDC_TXT_EDGEWEIGHTNING, buffer);
SetupSliderControl(IDC_BrightCorrect,50,300,config->getLiveView_BrightCorrect(),15);
SendMessage(getDlgItem(IDC_BrightCorrect),TBM_SETPAGESIZE,0,10);
sprintf(buffer,"Brightness [%d%%]",config->getLiveView_BrightCorrect());
SetStaticText(IDC_TXT_BRIGHTCORRECT, buffer);
SetupSliderControl(IDC_DarknessLimit,0,10,config->getLiveView_DarknessLimit(),1);
SendMessage(getDlgItem(IDC_DarknessLimit),TBM_SETPAGESIZE,0,1);
sprintf(buffer,"Darkness Limit [%d]",config->getLiveView_DarknessLimit());
SetStaticText(IDC_TXT_DARKNESSLIMIT, buffer);
SetupSliderControl(IDC_HueWinSize,0,5,config->getLiveView_HueWinSize(),1);
SendMessage(getDlgItem(IDC_HueWinSize),TBM_SETPAGESIZE,0,1);
sprintf(buffer,"Hue windowing [%d]",config->getLiveView_HueWinSize());
SetStaticText(IDC_TXT_HUEWINSIZE, buffer);
SetupSliderControl(IDC_SatWinSize,0,5,config->getLiveView_SatWinSize(),1);
SendMessage(getDlgItem(IDC_SatWinSize),TBM_SETPAGESIZE,0,1);
sprintf(buffer,"Sat windowing [%d]",config->getLiveView_SatWinSize());
SetStaticText(IDC_TXT_SATWINSIZE, buffer);
SetupSliderControl(IDC_Overlap,0,3,config->getLiveView_Overlap(),1);
SendMessage(getDlgItem(IDC_Overlap),TBM_SETPAGESIZE,0,1);
sprintf(buffer,"Zone overlap [%d]",config->getLiveView_Overlap());
SetStaticText(IDC_TXT_OVERLAP, buffer);
SetupSliderControl(IDC_Filter_MeanLength,300,5000,config->getLiveViewFilter_MeanLength(),0);
SendMessage(getDlgItem(IDC_Filter_MeanLength),TBM_SETPAGESIZE,0,100);
sprintf(buffer,"Filter length [%d ms]",config->getLiveViewFilter_MeanLength());
SetStaticText(IDC_TXT_Filter_MeanLength, buffer);
SetupSliderControl(IDC_Filter_MeanThreshold,1,100,config->getLiveViewFilter_MeanThreshold(),0);
SendMessage(getDlgItem(IDC_Filter_MeanThreshold),TBM_SETPAGESIZE,0,5);
sprintf(buffer,"Filter threshold [%d%%]",config->getLiveViewFilter_MeanThreshold());
SetStaticText(IDC_TXT_Filter_MeanThreshold, buffer);
SetupSliderControl(IDC_Filter_PercentNew,1,100,config->getLiveViewFilter_PercentNew(),0);
SendMessage(getDlgItem(IDC_Filter_PercentNew),TBM_SETPAGESIZE,0,5);
sprintf(buffer,"Filter smoothness [%d%%]",config->getLiveViewFilter_PercentNew());
SetStaticText(IDC_TXT_Filter_PercentNew, buffer);
return ATMO_FALSE;
}
void CAtmoLiveSettings::HandleHorzScroll(int code,int position,HWND scrollBarHandle) {
// slider handling...
char buffer[100];
int dlgItemId = GetDlgCtrlID(scrollBarHandle);
switch(dlgItemId) {
case IDC_EdgeWeighting: {
int EdgeWeighting = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Edge weighting [%d]",EdgeWeighting);
SetStaticText(IDC_TXT_EDGEWEIGHTNING, buffer);
this->m_pDynData->getAtmoConfig()->setLiveView_EdgeWeighting(EdgeWeighting);
break;
}
case IDC_BrightCorrect: {
int BrightCorrect = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Brightness [%d%%]",BrightCorrect);
SetStaticText(IDC_TXT_BRIGHTCORRECT, buffer);
this->m_pDynData->getAtmoConfig()->setLiveView_BrightCorrect(BrightCorrect);
break;
}
case IDC_DarknessLimit: {
int DarknessLimit = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Darkness Limit [%d]",DarknessLimit);
SetStaticText(IDC_TXT_DARKNESSLIMIT, buffer);
this->m_pDynData->getAtmoConfig()->setLiveView_DarknessLimit(DarknessLimit);
break;
}
case IDC_HueWinSize: {
int HueWinSize = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Hue windowing [%d]",HueWinSize);
SetStaticText(IDC_TXT_HUEWINSIZE, buffer);
this->m_pDynData->getAtmoConfig()->setLiveView_HueWinSize(HueWinSize);
break;
}
case IDC_SatWinSize: {
int SatWinSize = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Sat windowing [%d]",SatWinSize);
SetStaticText(IDC_TXT_SATWINSIZE, buffer);
this->m_pDynData->getAtmoConfig()->setLiveView_SatWinSize(SatWinSize);
break;
}
case IDC_Overlap: {
int Overlap = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Zone overlap [%d]",Overlap);
SetStaticText(IDC_TXT_OVERLAP, buffer);
this->m_pDynData->getAtmoConfig()->setLiveView_Overlap(Overlap);
break;
}
case IDC_Filter_MeanLength: {
int Filter_MeanLength = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Filter length [%d ms]",Filter_MeanLength);
SetStaticText(IDC_TXT_Filter_MeanLength, buffer);
this->m_pDynData->getAtmoConfig()->setLiveViewFilter_MeanLength(Filter_MeanLength);
break;
}
case IDC_Filter_MeanThreshold: {
int Filter_MeanThreshold = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Filter threshold [%d%%]",Filter_MeanThreshold);
SetStaticText(IDC_TXT_Filter_MeanThreshold, buffer);
this->m_pDynData->getAtmoConfig()->setLiveViewFilter_MeanThreshold(Filter_MeanThreshold);
break;
}
case IDC_Filter_PercentNew: {
int Filter_PercentNew = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
sprintf(buffer,"Filter smoothness [%d%%]",Filter_PercentNew);
SetStaticText(IDC_TXT_Filter_PercentNew, buffer);
this->m_pDynData->getAtmoConfig()->setLiveViewFilter_PercentNew(Filter_PercentNew);
break;
}
default:
return;
}
}
void CAtmoLiveSettings::HandleVertScroll(int code,int position,HWND scrollBarHandle) {
}
ATMO_BOOL CAtmoLiveSettings::UpdateLiveViewValues(ATMO_BOOL showPreview) {
HWND hwndCtrl;
CAtmoDisplays *pAtmoDisplays = this->m_pDynData->getAtmoDisplays();
CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
pAtmoDisplays->ReloadList(); // auf nummer sicher!
hwndCtrl = getDlgItem(IDC_DISPLAYS);
int i = ComboBox_GetCurSel(hwndCtrl);
if(i>=pAtmoDisplays->getCount()) {
pAtmoConfig->setLiveView_DisplayNr(0);
LoadDisplayList();
MessageBox(this->m_hDialog,"Ausgewähltes Display nicht mehr in der Liste ;-)","Fehler",MB_ICONERROR | MB_OK);
return ATMO_FALSE;
}
pAtmoConfig->setLiveView_DisplayNr(i);
if(showPreview == ATMO_TRUE) {
CAtmoConnection *pAtmoConnection = m_pDynData->getAtmoConnection();
if((pAtmoConnection!=NULL) && pAtmoConnection->isOpen()) {
CAtmoTools::SwitchEffect(m_pDynData, emLivePicture);
}
}
return ATMO_TRUE;
}
ATMO_BOOL CAtmoLiveSettings::ExecuteCommand(HWND hControl,int wmId, int wmEvent) {
switch(wmId) {
case IDOK: {
CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
if(UpdateLiveViewValues(ATMO_FALSE) == ATMO_FALSE) return 0;
EndDialog(this->m_hDialog, wmId);
break;
}
case IDCANCEL: {
// m_pBackupConfig --> wieder herstellen...
CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
pAtmoConfig->Assign(this->m_pBackupConfig);
EndDialog(this->m_hDialog, wmId);
break;
}
case IDC_WIDESCREEN: {
CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
if(Button_GetCheck(hControl) == BST_CHECKED)
pAtmoConfig->setLiveView_WidescreenMode(1);
else
pAtmoConfig->setLiveView_WidescreenMode(0);
break;
}
case IDC_FILTERMODE: {
/// CBN_SELCHANGE
if(wmEvent == CBN_SELCHANGE) {
CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
int i = ComboBox_GetCurSel(hControl);
pAtmoConfig->setLiveViewFilterMode((AtmoFilterMode)i);
}
break;
}
case IDC_DISPLAYS: {
if(wmEvent == CBN_SELCHANGE) {
CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
int i = ComboBox_GetCurSel(hControl);
if(i != pAtmoConfig->getLiveView_DisplayNr()) {
UpdateLiveViewValues( pAtmoConfig->getEffectMode() == emLivePicture );
}
}
break;
}
case IDC_GDI_CAPURE_RATE: {
if(wmEvent == EN_CHANGE) {
char buffer[20];
if(Edit_GetText(hControl,buffer,sizeof(buffer))>0) {
int value = atoi(buffer);
if((value>=1) && (value<=50)) {
CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
pAtmoConfig->setLiveView_GDI_FrameRate(value);
} else {
MessageBeep(MB_ICONEXCLAMATION);
}
}
}
break;
}
default:
return ATMO_FALSE;
}
return ATMO_TRUE;
}