Skip to content

Commit 4f6442a

Browse files
committed
Format code base
1 parent 4701d3f commit 4f6442a

19 files changed

+2339
-1858
lines changed

src/config.cpp

+16-14
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 config_dialogProc(
48+
HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam) {
4849
switch (msg) {
4950
case WM_COMMAND:
5051
if (LOWORD(wParam) == IDOK) {
@@ -69,8 +70,7 @@ void cmdConfig(Command* command) {
6970
translateDialog(dialog);
7071
int id = ID_CONFIG_DLG;
7172
#define BoolSetting(name, displayName, default) \
72-
CheckDlgButton(dialog, ++id, \
73-
settings::name ? BST_CHECKED : BST_UNCHECKED);
73+
CheckDlgButton(dialog, ++id, settings::name ? BST_CHECKED : BST_UNCHECKED);
7474
#include "settings.h"
7575
#undef BoolSetting
7676
ShowWindow(dialog, SW_SHOWNORMAL);
@@ -85,6 +85,7 @@ struct ToggleCommand {
8585
string settingName;
8686
string settingDisp;
8787
};
88+
8889
map<int, ToggleCommand> toggleCommands;
8990

9091
bool handleSettingCommand(int command) {
@@ -95,11 +96,11 @@ bool handleSettingCommand(int command) {
9596
isHandlingCommand = true;
9697
ToggleCommand& tc = it->second;
9798
*tc.setting = !*tc.setting;
98-
SetExtState(CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0",
99-
true);
99+
SetExtState(
100+
CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0", true);
100101
ostringstream s;
101-
s << (*tc.setting ? translate("enabled") : translate("disabled")) <<
102-
" " << tc.settingDisp;
102+
s << (*tc.setting ? translate("enabled") : translate("disabled"))
103+
<< " " << tc.settingDisp;
103104
outputMessage(s);
104105
isHandlingCommand = false;
105106
return true;
@@ -126,8 +127,9 @@ void registerSettingCommands() {
126127
gaccel.accel.cmd = cmd; \
127128
tc.settingDisp = translate(displayName); \
128129
/* Strip the '&' character indicating the access key. */ \
129-
tc.settingDisp.erase(remove(tc.settingDisp.begin(), tc.settingDisp.end(), \
130-
'&'), tc.settingDisp.end()); \
130+
tc.settingDisp.erase( \
131+
remove(tc.settingDisp.begin(), tc.settingDisp.end(), '&'), \
132+
tc.settingDisp.end()); \
131133
s.str(""); \
132134
s << translate("OSARA: Toggle") << " " << tc.settingDisp; \
133135
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

+26-22
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,8 @@ 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()
153+
&& cache.hasChanged(mute)) {
151154
ostringstream s;
152155
this->reportTrackIfDifferent(track, s);
153156
s << (mute ? translate("muted") : translate("unmuted"));
@@ -166,8 +169,8 @@ class Surface: public IReaperControlSurface {
166169
return;
167170
}
168171
auto cache = this->cachedTrackState<TC_SOLOED, TC_UNSOLOED>(track);
169-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
170-
cache.hasChanged(solo)) {
172+
if (!isParamsDialogOpen && !this->wasCausedByCommand()
173+
&& cache.hasChanged(solo)) {
171174
ostringstream s;
172175
this->reportTrackIfDifferent(track, s);
173176
s << (solo ? translate("soloed") : translate("unsoloed"));
@@ -181,8 +184,8 @@ class Surface: public IReaperControlSurface {
181184
return;
182185
}
183186
auto cache = this->cachedTrackState<TC_ARMED, TC_UNARMED>(track);
184-
if (!isParamsDialogOpen && !this->wasCausedByCommand() &&
185-
cache.hasChanged(arm)) {
187+
if (!isParamsDialogOpen && !this->wasCausedByCommand()
188+
&& cache.hasChanged(arm)) {
186189
ostringstream s;
187190
this->reportTrackIfDifferent(track, s);
188191
s << (arm ? translate("armed") : translate("unarmed"));
@@ -199,8 +202,7 @@ class Surface: public IReaperControlSurface {
199202
// REAPER calls this a *lot*, even if the track was already selected; e.g.
200203
// for mute, arm, solo, etc. Ignore this if we were already told about
201204
// this track being selected.
202-
track == lastSelectedTrack
203-
) {
205+
track == lastSelectedTrack) {
204206
return;
205207
}
206208
// Cache the track even if we're handling a command because that command
@@ -214,7 +216,8 @@ class Surface: public IReaperControlSurface {
214216
postGoToTrack(0, track);
215217
}
216218

217-
virtual int Extended(int call, void* parm1, void* parm2, void* parm3) override {
219+
virtual int Extended(
220+
int call, void* parm1, void* parm2, void* parm3) override {
218221
if (call == CSURF_EXT_SETFXPARAM) {
219222
if (!this->shouldHandleParamChange()) {
220223
return 0; // Unsupported.
@@ -243,8 +246,8 @@ class Surface: public IReaperControlSurface {
243246
s << chunk << " ";
244247
}
245248
this->lastParam = param;
246-
TrackFX_FormatParamValueNormalized(track, fx, param, normVal, chunk,
247-
sizeof(chunk));
249+
TrackFX_FormatParamValueNormalized(
250+
track, fx, param, normVal, chunk, sizeof(chunk));
248251
if (chunk[0]) {
249252
s << chunk;
250253
} else {
@@ -276,14 +279,15 @@ class Surface: public IReaperControlSurface {
276279
// Only handle param changes if the last change was 100ms or more ago.
277280
return now - prevChangeTime >= 100;
278281
}
282+
279283
DWORD lastParamChangeTime = 0;
280284

281285
bool reportTrackIfDifferent(MediaTrack* track, ostringstream& output) {
282286
bool different = track != this->lastChangedTrack;
283287
if (different) {
284288
this->lastChangedTrack = track;
285-
int trackNum = (int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER",
286-
nullptr);
289+
int trackNum =
290+
(int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER", nullptr);
287291
if (trackNum <= 0) {
288292
output << translate("master");
289293
} else {

0 commit comments

Comments
 (0)