Skip to content

Commit d977560

Browse files
committed
Format the code base
1 parent a2146c0 commit d977560

19 files changed

+3349
-1987
lines changed

src/config.cpp

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

9+
#include "config.h"
10+
911
#include <algorithm>
1012
#include <map>
11-
#include <string>
1213
#include <sstream>
13-
#include "config.h"
14+
#include <string>
15+
1416
#include "resource.h"
1517
#include "translation.h"
1618

@@ -21,7 +23,7 @@ namespace settings {
2123
#define BoolSetting(name, displayName, default) bool name = default;
2224
#include "settings.h"
2325
#undef BoolSetting
24-
}
26+
} // namespace settings
2527

2628
void loadConfig() {
2729
// GetExtState returns an empty string (not NULL) if the key doesn't exist.
@@ -42,9 +44,8 @@ void config_onOk(HWND dialog) {
4244
#undef BoolSetting
4345
}
4446

45-
INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam,
46-
LPARAM lParam
47-
) {
47+
INT_PTR CALLBACK
48+
config_dialogProc(HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam) {
4849
switch (msg) {
4950
case WM_COMMAND:
5051
if (LOWORD(wParam) == IDOK) {
@@ -64,13 +65,14 @@ INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam,
6465
}
6566

6667
void cmdConfig(Command* command) {
67-
HWND dialog = CreateDialog(pluginHInstance, MAKEINTRESOURCE(ID_CONFIG_DLG),
68-
GetForegroundWindow(), config_dialogProc);
68+
HWND dialog = CreateDialog(
69+
pluginHInstance, MAKEINTRESOURCE(ID_CONFIG_DLG), GetForegroundWindow(),
70+
config_dialogProc
71+
);
6972
translateDialog(dialog);
7073
int id = ID_CONFIG_DLG;
7174
#define BoolSetting(name, displayName, default) \
72-
CheckDlgButton(dialog, ++id, \
73-
settings::name ? BST_CHECKED : BST_UNCHECKED);
75+
CheckDlgButton(dialog, ++id, settings::name ? BST_CHECKED : BST_UNCHECKED);
7476
#include "settings.h"
7577
#undef BoolSetting
7678
ShowWindow(dialog, SW_SHOWNORMAL);
@@ -85,6 +87,7 @@ struct ToggleCommand {
8587
string settingName;
8688
string settingDisp;
8789
};
90+
8891
map<int, ToggleCommand> toggleCommands;
8992

9093
bool handleSettingCommand(int command) {
@@ -95,11 +98,12 @@ bool handleSettingCommand(int command) {
9598
isHandlingCommand = true;
9699
ToggleCommand& tc = it->second;
97100
*tc.setting = !*tc.setting;
98-
SetExtState(CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0",
99-
true);
101+
SetExtState(
102+
CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0", true
103+
);
100104
ostringstream s;
101-
s << (*tc.setting ? translate("enabled") : translate("disabled")) <<
102-
" " << tc.settingDisp;
105+
s << (*tc.setting ? translate("enabled") : translate("disabled")) << " "
106+
<< tc.settingDisp;
103107
outputMessage(s);
104108
isHandlingCommand = false;
105109
return true;
@@ -126,8 +130,10 @@ void registerSettingCommands() {
126130
gaccel.accel.cmd = cmd; \
127131
tc.settingDisp = translate(displayName); \
128132
/* Strip the '&' character indicating the access key. */ \
129-
tc.settingDisp.erase(remove(tc.settingDisp.begin(), tc.settingDisp.end(), \
130-
'&'), tc.settingDisp.end()); \
133+
tc.settingDisp.erase( \
134+
remove(tc.settingDisp.begin(), tc.settingDisp.end(), '&'), \
135+
tc.settingDisp.end() \
136+
); \
131137
s.str(""); \
132138
s << translate("OSARA: Toggle") << " " << tc.settingDisp; \
133139
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

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

8-
#include <string>
9-
#include <sstream>
10-
#include <iomanip>
11-
#include <map>
128
#include <WDL/db2val.h>
9+
1310
#include <cstdint>
14-
#include "osara.h"
11+
#include <iomanip>
12+
#include <map>
13+
#include <sstream>
14+
#include <string>
15+
1516
#include "config.h"
16-
#include "paramsUi.h"
1717
#include "midiEditorCommands.h"
18+
#include "osara.h"
19+
#include "paramsUi.h"
1820
#include "translation.h"
1921

2022
using namespace std;
@@ -39,7 +41,7 @@ const uint8_t TC_UNARMED = 1 << 5;
3941
template<uint8_t enableFlag, uint8_t disableFlag>
4042
class TrackCacheState {
4143
public:
42-
TrackCacheState(uint8_t& value): value(value) {}
44+
TrackCacheState(uint8_t& value) : value(value) {}
4345

4446
// Check if a supplied new state has changed from the cached state.
4547
bool hasChanged(bool isEnabled) {
@@ -64,9 +66,10 @@ class TrackCacheState {
6466
uint8_t& value;
6567
};
6668

67-
/*** A control surface to obtain certain info that can only be retrieved that way.
69+
/*** A control surface to obtain certain info that can only be retrieved that
70+
* way.
6871
*/
69-
class Surface: public IReaperControlSurface {
72+
class Surface : public IReaperControlSurface {
7073
public:
7174
virtual const char* GetTypeString() override {
7275
return "OSARA";
@@ -146,8 +149,7 @@ class Surface: public IReaperControlSurface {
146149
return;
147150
}
148151
auto cache = this->cachedTrackState<TC_MUTED, TC_UNMUTED>(track);
149-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
150-
cache.hasChanged(mute)) {
152+
if (!isParamsDialogOpen && !this->wasCausedByCommand() && cache.hasChanged(mute)) {
151153
ostringstream s;
152154
this->reportTrackIfDifferent(track, s);
153155
s << (mute ? translate("muted") : translate("unmuted"));
@@ -166,8 +168,7 @@ class Surface: public IReaperControlSurface {
166168
return;
167169
}
168170
auto cache = this->cachedTrackState<TC_SOLOED, TC_UNSOLOED>(track);
169-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
170-
cache.hasChanged(solo)) {
171+
if (!isParamsDialogOpen && !this->wasCausedByCommand() && cache.hasChanged(solo)) {
171172
ostringstream s;
172173
this->reportTrackIfDifferent(track, s);
173174
s << (solo ? translate("soloed") : translate("unsoloed"));
@@ -181,8 +182,7 @@ class Surface: public IReaperControlSurface {
181182
return;
182183
}
183184
auto cache = this->cachedTrackState<TC_ARMED, TC_UNARMED>(track);
184-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
185-
cache.hasChanged(arm)) {
185+
if (!isParamsDialogOpen && !this->wasCausedByCommand() && cache.hasChanged(arm)) {
186186
ostringstream s;
187187
this->reportTrackIfDifferent(track, s);
188188
s << (arm ? translate("armed") : translate("unarmed"));
@@ -214,7 +214,8 @@ class Surface: public IReaperControlSurface {
214214
postGoToTrack(0, track);
215215
}
216216

217-
virtual int Extended(int call, void* parm1, void* parm2, void* parm3) override {
217+
virtual int Extended(int call, void* parm1, void* parm2, void* parm3)
218+
override {
218219
if (call == CSURF_EXT_SETFXPARAM) {
219220
if (!this->shouldHandleParamChange()) {
220221
return 0; // Unsupported.
@@ -243,8 +244,9 @@ class Surface: public IReaperControlSurface {
243244
s << chunk << " ";
244245
}
245246
this->lastParam = param;
246-
TrackFX_FormatParamValueNormalized(track, fx, param, normVal, chunk,
247-
sizeof(chunk));
247+
TrackFX_FormatParamValueNormalized(
248+
track, fx, param, normVal, chunk, sizeof(chunk)
249+
);
248250
if (chunk[0]) {
249251
s << chunk;
250252
} else {
@@ -276,14 +278,15 @@ class Surface: public IReaperControlSurface {
276278
// Only handle param changes if the last change was 100ms or more ago.
277279
return now - prevChangeTime >= 100;
278280
}
281+
279282
DWORD lastParamChangeTime = 0;
280283

281284
bool reportTrackIfDifferent(MediaTrack* track, ostringstream& output) {
282285
bool different = track != this->lastChangedTrack;
283286
if (different) {
284287
this->lastChangedTrack = track;
285-
int trackNum = (int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER",
286-
nullptr);
288+
int trackNum =
289+
(int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER", nullptr);
287290
if (trackNum <= 0) {
288291
output << translate("master");
289292
} else {

0 commit comments

Comments
 (0)