Skip to content

Commit 3e50e18

Browse files
committed
Format code base
1 parent c9b9b5e commit 3e50e18

20 files changed

+2158
-2165
lines changed

src/config.cpp

+9-15
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace settings {
2222
#define BoolSetting(name, sectionId, displayName, default) bool name = default;
2323
#include "settings.h"
2424
#undef BoolSetting
25-
}
25+
} // namespace settings
2626

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

46-
INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam,
47-
LPARAM lParam
48-
) {
46+
INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam) {
4947
switch (msg) {
5048
case WM_COMMAND:
5149
if (LOWORD(wParam) == IDOK) {
@@ -65,13 +63,11 @@ INT_PTR CALLBACK config_dialogProc(HWND dialog, UINT msg, WPARAM wParam,
6563
}
6664

6765
void cmdConfig(Command* command) {
68-
HWND dialog = CreateDialog(pluginHInstance, MAKEINTRESOURCE(ID_CONFIG_DLG),
69-
GetForegroundWindow(), config_dialogProc);
66+
HWND dialog = CreateDialog(pluginHInstance, MAKEINTRESOURCE(ID_CONFIG_DLG), GetForegroundWindow(), config_dialogProc);
7067
translateDialog(dialog);
7168
int id = ID_CONFIG_DLG;
7269
#define BoolSetting(name, sectionId, displayName, default) \
73-
CheckDlgButton(dialog, ++id, \
74-
settings::name ? BST_CHECKED : BST_UNCHECKED);
70+
CheckDlgButton(dialog, ++id, settings::name ? BST_CHECKED : BST_UNCHECKED);
7571
#include "settings.h"
7672
#undef BoolSetting
7773
ShowWindow(dialog, SW_SHOWNORMAL);
@@ -86,6 +82,7 @@ struct ToggleCommand {
8682
string settingName;
8783
string settingDisp;
8884
};
85+
8986
map<int, ToggleCommand> toggleCommands;
9087

9188
bool handleSettingCommand(int command) {
@@ -96,11 +93,9 @@ bool handleSettingCommand(int command) {
9693
isHandlingCommand = true;
9794
ToggleCommand& tc = it->second;
9895
*tc.setting = !*tc.setting;
99-
SetExtState(CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0",
100-
true);
96+
SetExtState(CONFIG_SECTION, tc.settingName.c_str(), *tc.setting ? "1" : "0", true);
10197
ostringstream s;
102-
s << (*tc.setting ? translate("enabled") : translate("disabled")) <<
103-
" " << tc.settingDisp;
98+
s << (*tc.setting ? translate("enabled") : translate("disabled")) << " " << tc.settingDisp;
10499
outputMessage(s);
105100
isHandlingCommand = false;
106101
return true;
@@ -123,8 +118,7 @@ void registerSettingCommands() {
123118
string idStr = s.str(); \
124119
tc.settingDisp = translate_ctxt("OSARA Configuration", displayName); \
125120
/* Strip the '&' character indicating the access key. */ \
126-
tc.settingDisp.erase(remove(tc.settingDisp.begin(), tc.settingDisp.end(), \
127-
'&'), tc.settingDisp.end()); \
121+
tc.settingDisp.erase(remove(tc.settingDisp.begin(), tc.settingDisp.end(), '&'), tc.settingDisp.end()); \
128122
s.str(""); \
129123
s << translate("OSARA: Toggle") << " " << tc.settingDisp; \
130124
tc.desc = s.str(); \
@@ -136,7 +130,7 @@ void registerSettingCommands() {
136130
gaccel.accel.cmd = cmd; \
137131
gaccel.desc = tc.desc.c_str(); \
138132
plugin_register("gaccel", &gaccel); \
139-
} else { \
133+
} else { \
140134
custom_action_register_t action; \
141135
action.uniqueSectionId = sectionId; \
142136
action.idStr = idStr.c_str(); \

src/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace settings {
1616
#define BoolSetting(name, sectionId, 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

+17-23
Original file line numberDiff line numberDiff line change
@@ -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"));
@@ -196,11 +192,10 @@ class Surface: public IReaperControlSurface {
196192

197193
virtual void SetSurfaceSelected(MediaTrack* track, bool selected) override {
198194
if (!selected || !settings::reportSurfaceChanges ||
199-
// REAPER calls this a *lot*, even if the track was already selected; e.g.
200-
// for mute, arm, solo, etc. Ignore this if we were already told about
201-
// this track being selected.
202-
track == lastSelectedTrack
203-
) {
195+
// REAPER calls this a *lot*, even if the track was already selected; e.g.
196+
// for mute, arm, solo, etc. Ignore this if we were already told about
197+
// this track being selected.
198+
track == lastSelectedTrack) {
204199
return;
205200
}
206201
// Cache the track even if we're handling a command because that command
@@ -243,8 +238,7 @@ class Surface: public IReaperControlSurface {
243238
s << chunk << " ";
244239
}
245240
this->lastParam = param;
246-
TrackFX_FormatParamValueNormalized(track, fx, param, normVal, chunk,
247-
sizeof(chunk));
241+
TrackFX_FormatParamValueNormalized(track, fx, param, normVal, chunk, sizeof(chunk));
248242
if (chunk[0]) {
249243
s << chunk;
250244
} else {
@@ -267,10 +261,10 @@ class Surface: public IReaperControlSurface {
267261
private:
268262
bool wasCausedByCommand() {
269263
return isHandlingCommand ||
270-
// Sometimes, REAPER updates control surfaces after a command rather than
271-
// during. If the last command OSARA handled was <= 50 ms ago, we assume
272-
// this update was caused by that command.
273-
GetTickCount() - lastCommandTime <= 50;
264+
// Sometimes, REAPER updates control surfaces after a command rather than
265+
// during. If the last command OSARA handled was <= 50 ms ago, we assume
266+
// this update was caused by that command.
267+
GetTickCount() - lastCommandTime <= 50;
274268
}
275269

276270
// Used for parameters we don't cache such as volume, pan and FX parameters.
@@ -285,14 +279,14 @@ class Surface: public IReaperControlSurface {
285279
// Only handle param changes if the last change was 100ms or more ago.
286280
return now - prevChangeTime >= 100;
287281
}
282+
288283
DWORD lastParamChangeTime = 0;
289284

290285
bool reportTrackIfDifferent(MediaTrack* track, ostringstream& output) {
291286
bool different = track != this->lastChangedTrack;
292287
if (different) {
293288
this->lastChangedTrack = track;
294-
int trackNum = (int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER",
295-
nullptr);
289+
int trackNum = (int)(size_t)GetSetMediaTrackInfo(track, "IP_TRACKNUMBER", nullptr);
296290
if (trackNum <= 0) {
297291
output << translate("master");
298292
} else {

0 commit comments

Comments
 (0)