6
6
#include " WakeCalculatorOptions.h"
7
7
#include " WakeIntervalFormatter.h"
8
8
#include " components/ClickableArea.h"
9
- #include " components/TitleBar .h"
9
+ #include " components/CollapsibleWindowTitleBar .h"
10
10
#include " euroscope/EuroscopePluginLoopbackInterface.h"
11
11
#include " euroscope/EuroscopeRadarLoopbackInterface.h"
12
12
#include " euroscope/UserSetting.h"
@@ -27,11 +27,11 @@ namespace UKControllerPlugin::Wake {
27
27
int screenObjectId)
28
28
: options(std::move(options)), leadCallsignSelector(std::move(leadCallsignSelector)),
29
29
followCallsignSelector (std::move(followCallsignSelector)), wakeSchemeSelector(std::move(wakeSchemeSelector)),
30
- plugin(plugin), screenObjectId(screenObjectId),
31
- titleBar(Components::TitleBar::Create( L" Wake Turbulence Calculator" , TitleBarArea())
32
- ->WithDrag( this ->screenObjectId)
33
- ->WithDefaultBackgroundBrush()
34
- ->WithDefaultTextBrush( )),
30
+ plugin(plugin), titleBar(Components::CollapsibleWindowTitleBar::Create(
31
+ L" Wake Turbulence Calculator" ,
32
+ TitleBarArea (),
33
+ [this]() -> bool { return this -> contentCollapsed ; },
34
+ screenObjectId )),
35
35
backgroundBrush(std::make_shared<Gdiplus::SolidBrush>(BACKGROUND_COLOUR)),
36
36
textBrush(std::make_shared<Gdiplus::SolidBrush>(TEXT_COLOUR)),
37
37
resultBrush(std::make_shared<Gdiplus::SolidBrush>(RESULT_COLOUR)),
@@ -86,6 +86,11 @@ namespace UKControllerPlugin::Wake {
86
86
options->FollowingAircraft (" " );
87
87
return ;
88
88
}
89
+
90
+ if (objectDescription == " collapseButton" ) {
91
+ this ->contentCollapsed = !this ->contentCollapsed ;
92
+ return ;
93
+ }
89
94
}
90
95
91
96
void WakeCalculatorDisplay::Move (RECT position, std::string objectDescription)
@@ -138,14 +143,19 @@ namespace UKControllerPlugin::Wake {
138
143
Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen)
139
144
{
140
145
graphics.Translated (windowPosition.x , windowPosition.y , [&graphics, &radarScreen, this ]() {
141
- graphics.FillRect (this ->contentArea , *backgroundBrush);
142
- this ->RenderScheme (graphics, radarScreen);
143
- this ->RenderIntermediate (graphics, radarScreen);
144
- this ->RenderMode (graphics, radarScreen);
145
- this ->RenderLead (graphics, radarScreen);
146
- this ->RenderFollowing (graphics, radarScreen);
147
- this ->RenderDividingLine (graphics);
148
- this ->RenderSeparationRequirement (graphics);
146
+ // Draw the content if not collapsed
147
+ if (!this ->contentCollapsed ) {
148
+ graphics.FillRect (this ->contentArea , *backgroundBrush);
149
+ this ->RenderScheme (graphics, radarScreen);
150
+ this ->RenderIntermediate (graphics, radarScreen);
151
+ this ->RenderMode (graphics, radarScreen);
152
+ this ->RenderLead (graphics, radarScreen);
153
+ this ->RenderFollowing (graphics, radarScreen);
154
+ this ->RenderDividingLine (graphics);
155
+ this ->RenderSeparationRequirement (graphics);
156
+ }
157
+
158
+ // Do title bar, so it's always on top.
149
159
titleBar->Draw (graphics, radarScreen);
150
160
});
151
161
}
@@ -164,13 +174,15 @@ namespace UKControllerPlugin::Wake {
164
174
0 },
165
175
" " );
166
176
this ->visible = userSetting.GetBooleanEntry (ASR_KEY_VISIBILITY, false );
177
+ this ->contentCollapsed = userSetting.GetBooleanEntry (ASR_KEY_COLLAPSED, false );
167
178
}
168
179
169
180
void WakeCalculatorDisplay::AsrClosingEvent (Euroscope::UserSetting& userSetting)
170
181
{
171
182
userSetting.Save (ASR_KEY_X_POS, ASR_DESCRIPTION_X_POS, windowPosition.x );
172
183
userSetting.Save (ASR_KEY_Y_POS, ASR_DESCRIPTION_Y_POS, windowPosition.y );
173
184
userSetting.Save (ASR_KEY_VISIBILITY, ASR_DESCRIPTION_VISIBILITY, visible);
185
+ userSetting.Save (ASR_KEY_COLLAPSED, ASR_DESCRIPTION_COLLAPSED, contentCollapsed);
174
186
}
175
187
176
188
auto WakeCalculatorDisplay::TitleBarArea () -> Gdiplus::Rect
@@ -361,4 +373,9 @@ namespace UKControllerPlugin::Wake {
361
373
{
362
374
this ->visible = !this ->visible ;
363
375
}
376
+
377
+ auto WakeCalculatorDisplay::IsCollapsed () const -> bool
378
+ {
379
+ return this ->contentCollapsed ;
380
+ }
364
381
} // namespace UKControllerPlugin::Wake
0 commit comments