Skip to content

Commit 6568611

Browse files
committed
Format code base
1 parent 8352844 commit 6568611

19 files changed

+1903
-1921
lines changed

src/config.cpp

+12-18
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* License: GNU General Public License version 2.0
77
*/
88

9-
#include <algorithm>
10-
#include <map>
11-
#include <string>
12-
#include <sstream>
139
#include "config.h"
1410
#include "resource.h"
1511
#include "translation.h"
12+
#include <algorithm>
13+
#include <map>
14+
#include <sstream>
15+
#include <string>
1616

1717
using namespace std;
1818

@@ -21,7 +21,7 @@ namespace settings {
2121
#define BoolSetting(name, displayName, default) bool name = default;
2222
#include "settings.h"
2323
#undef BoolSetting
24-
}
24+
} // namespace settings
2525

2626
void loadConfig() {
2727
// GetExtState returns an empty string (not NULL) if the key doesn't exist.
@@ -42,9 +42,7 @@ void config_onOk(HWND dialog) {
4242
#undef BoolSetting
4343
}
4444

45-
INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam,
46-
LPARAM lParam
47-
) {
45+
INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam) {
4846
switch (msg) {
4947
case WM_COMMAND:
5048
if (LOWORD(wParam) == IDOK) {
@@ -64,13 +62,11 @@ INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam,
6462
}
6563

6664
void cmdConfig(Command* command) {
67-
HWND dialog = CreateDialog(pluginHInstance, MAKEINTRESOURCE(ID_CONFIG_DLG),
68-
GetForegroundWindow(), config_dialogProc);
65+
HWND dialog = CreateDialog(pluginHInstance, MAKEINTRESOURCE(ID_CONFIG_DLG), GetForegroundWindow(), config_dialogProc);
6966
translateDialog(dialog);
7067
int id = ID_CONFIG_DLG;
7168
#define BoolSetting(name, displayName, default) \
72-
CheckDlgButton(dialog, ++id, \
73-
settings::name ? BST_CHECKED : BST_UNCHECKED);
69+
CheckDlgButton(dialog, ++id, settings::name ? BST_CHECKED : BST_UNCHECKED);
7470
#include "settings.h"
7571
#undef BoolSetting
7672
ShowWindow(dialog, SW_SHOWNORMAL);
@@ -85,6 +81,7 @@ struct ToggleCommand {
8581
string settingName;
8682
string settingDisp;
8783
};
84+
8885
map<int, ToggleCommand> toggleCommands;
8986

9087
bool handleSettingCommand(int command) {
@@ -95,11 +92,9 @@ bool handleSettingCommand(int command) {
9592
isHandlingCommand = true;
9693
ToggleCommand& tc = it->second;
9794
*tc.setting = !*tc.setting;
98-
SetExtState(CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0",
99-
true);
95+
SetExtState(CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0", true);
10096
ostringstream s;
101-
s << (*tc.setting ? translate("enabled") : translate("disabled")) <<
102-
" " << tc.settingDisp;
97+
s << (*tc.setting ? translate("enabled") : translate("disabled")) << " " << tc.settingDisp;
10398
outputMessage(s);
10499
isHandlingCommand = false;
105100
return true;
@@ -126,8 +121,7 @@ void registerSettingCommands() {
126121
gaccel.accel.cmd = cmd; \
127122
tc.settingDisp = translate(displayName); \
128123
/* Strip the '&' character indicating the access key. */ \
129-
tc.settingDisp.erase(remove(tc.settingDisp.begin(), tc.settingDisp.end(), \
130-
'&'), tc.settingDisp.end()); \
124+
tc.settingDisp.erase(remove(tc.settingDisp.begin(), tc.settingDisp.end(), '&'), tc.settingDisp.end()); \
131125
s.str(""); \
132126
s << translate("OSARA: Toggle") << " " << tc.settingDisp; \
133127
tc.desc = s.str(); \

src/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace settings {
1616
#define BoolSetting(name, displayName, default) extern bool name;
1717
#include "settings.h"
1818
#undef BoolSetting
19-
}
19+
} // namespace settings
2020

2121
const char CONFIG_SECTION[] = "osara";
2222

src/controlSurface.cpp

+20-25
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
* License: GNU General Public License version 2.0
66
*/
77

8-
#include <string>
9-
#include <sstream>
10-
#include <iomanip>
11-
#include <map>
12-
#include <WDL/db2val.h>
13-
#include <cstdint>
14-
#include "osara.h"
158
#include "config.h"
16-
#include "paramsUi.h"
179
#include "midiEditorCommands.h"
10+
#include "osara.h"
11+
#include "paramsUi.h"
1812
#include "translation.h"
13+
#include <cstdint>
14+
#include <iomanip>
15+
#include <map>
16+
#include <sstream>
17+
#include <string>
18+
#include <WDL/db2val.h>
1919

2020
using namespace std;
2121

@@ -36,10 +36,9 @@ const uint8_t TC_ARMED = 1 << 4;
3636
const uint8_t TC_UNARMED = 1 << 5;
3737

3838
// Make it easier to manipulate these cached states.
39-
template<uint8_t enableFlag, uint8_t disableFlag>
40-
class TrackCacheState {
39+
template<uint8_t enableFlag, uint8_t disableFlag> class TrackCacheState {
4140
public:
42-
TrackCacheState(uint8_t& value): value(value) {}
41+
TrackCacheState(uint8_t& value) : value(value) {}
4342

4443
// Check if a supplied new state has changed from the cached state.
4544
bool hasChanged(bool isEnabled) {
@@ -66,7 +65,7 @@ class TrackCacheState {
6665

6766
/*** A control surface to obtain certain info that can only be retrieved that way.
6867
*/
69-
class Surface: public IReaperControlSurface {
68+
class Surface : public IReaperControlSurface {
7069
public:
7170
virtual const char* GetTypeString() override {
7271
return "OSARA";
@@ -146,8 +145,7 @@ class Surface: public IReaperControlSurface {
146145
return;
147146
}
148147
auto cache = this->cachedTrackState<TC_MUTED, TC_UNMUTED>(track);
149-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
150-
cache.hasChanged(mute)) {
148+
if (!isParamsDialogOpen && !this->wasCausedByCommand() && cache.hasChanged(mute)) {
151149
ostringstream s;
152150
this->reportTrackIfDifferent(track, s);
153151
s << (mute ? translate("muted") : translate("unmuted"));
@@ -166,8 +164,7 @@ class Surface: public IReaperControlSurface {
166164
return;
167165
}
168166
auto cache = this->cachedTrackState<TC_SOLOED, TC_UNSOLOED>(track);
169-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
170-
cache.hasChanged(solo)) {
167+
if (!isParamsDialogOpen && !this->wasCausedByCommand() && cache.hasChanged(solo)) {
171168
ostringstream s;
172169
this->reportTrackIfDifferent(track, s);
173170
s << (solo ? translate("soloed") : translate("unsoloed"));
@@ -181,8 +178,7 @@ class Surface: public IReaperControlSurface {
181178
return;
182179
}
183180
auto cache = this->cachedTrackState<TC_ARMED, TC_UNARMED>(track);
184-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
185-
cache.hasChanged(arm)) {
181+
if (!isParamsDialogOpen && !this->wasCausedByCommand() && cache.hasChanged(arm)) {
186182
ostringstream s;
187183
this->reportTrackIfDifferent(track, s);
188184
s << (arm ? translate("armed") : translate("unarmed"));
@@ -217,14 +213,14 @@ class Surface: public IReaperControlSurface {
217213
virtual int Extended(int call, void* parm1, void* parm2, void* parm3) override {
218214
if (call == CSURF_EXT_SETFXPARAM) {
219215
if (!this->shouldHandleParamChange()) {
220-
return 0; // Unsupported.
216+
return 0; // Unsupported.
221217
}
222218
auto track = (MediaTrack*)parm1;
223219
int fx = *(int*)parm2 >> 16;
224220
// Don't report parameter changes where they might already be reported by
225221
// the UI.
226222
if (isParamsDialogOpen || TrackFX_GetChainVisible(track) == fx) {
227-
return 0; // Unsupported.
223+
return 0; // Unsupported.
228224
}
229225
int param = *(int*)parm2 & 0xFFFF;
230226
double normVal = *(double*)parm3;
@@ -243,16 +239,15 @@ class Surface: public IReaperControlSurface {
243239
s << chunk << " ";
244240
}
245241
this->lastParam = param;
246-
TrackFX_FormatParamValueNormalized(track, fx, param, normVal, chunk,
247-
sizeof(chunk));
242+
TrackFX_FormatParamValueNormalized(track, fx, param, normVal, chunk, sizeof(chunk));
248243
if (chunk[0]) {
249244
s << chunk;
250245
} else {
251246
s << normVal;
252247
}
253248
outputMessage(s);
254249
}
255-
return 0; // Unsupported.
250+
return 0; // Unsupported.
256251
}
257252

258253
private:
@@ -276,14 +271,14 @@ class Surface: public IReaperControlSurface {
276271
// Only handle param changes if the last change was 100ms or more ago.
277272
return now - prevChangeTime >= 100;
278273
}
274+
279275
DWORD lastParamChangeTime = 0;
280276

281277
bool reportTrackIfDifferent(MediaTrack* track, ostringstream& output) {
282278
bool different = track != this->lastChangedTrack;
283279
if (different) {
284280
this->lastChangedTrack = track;
285-
int trackNum = (int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER",
286-
nullptr);
281+
int trackNum = (int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER", nullptr);
287282
if (trackNum <= 0) {
288283
output << translate("master");
289284
} else {

0 commit comments

Comments
 (0)