diff --git a/.clang-format b/.clang-format index 6458773b9..faaca4630 100644 --- a/.clang-format +++ b/.clang-format @@ -105,7 +105,9 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left ReflowComments: true -SortIncludes: false +SortIncludes: + Enabled: true + IgnoreCase: true SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 000000000..61476c7f2 --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1 @@ +resource/resource.h \ No newline at end of file diff --git a/resource/UKControllerPlugin.rc b/resource/UKControllerPlugin.rc index dc9898b2c..19b7956ad 100644 --- a/resource/UKControllerPlugin.rc +++ b/resource/UKControllerPlugin.rc @@ -122,6 +122,8 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,25,118,10 CONTROL "Notify Departure Release Activity In Chat Area",IDC_RELEASE_CHAT_MESSAGE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,34,152,10 + COMBOBOX IDC_COLOUR_PALETTE,178,16,48,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Colour Palette",IDC_STATIC,230,18,43,8 END IDD_TIMER_CONFIGURATION DIALOGEX 0, 0, 179, 158 @@ -391,6 +393,8 @@ BEGIN RIGHTMARGIN, 302 TOPMARGIN, 7 BOTTOMMARGIN, 169 + HORZGUIDE, 16 + HORZGUIDE, 22 END IDD_TIMER_CONFIGURATION, DIALOG diff --git a/resource/resource.h b/resource/resource.h index a151d55ec..9eb83c667 100644 --- a/resource/resource.h +++ b/resource/resource.h @@ -37,6 +37,7 @@ #define IDC_TRAIL_TYPE 1004 #define IDC_TRAIL_LENGTH 1005 #define IDC_TRAIL_COLOUR 1009 +#define IDC_COLOUR_PALETTE 1146 #define IDC_SPIN_LENGTH 1010 #define IDC_DOT_SIZE 1012 #define GS_DIALOG_PRENOTE_TITLE 1012 @@ -214,7 +215,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 147 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1146 +#define _APS_NEXT_CONTROL_VALUE 1147 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index dd818321f..baf02eb68 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -304,6 +304,9 @@ set(src__graphics "graphics/GdiGraphicsWrapper.cpp" "graphics/GdiGraphicsWrapper.h" "graphics/GdiplusBrushes.h" + "graphics/GdiplusBrushes.cpp" + "graphics/Theme.h" + "graphics/Theme.cpp" graphics/FontManager.cpp graphics/FontManager.h graphics/StringFormatManager.cpp graphics/StringFormatManager.h) source_group("src\\graphics" FILES ${src__graphics}) diff --git a/src/plugin/approach/ApproachBootstrapProvider.cpp b/src/plugin/approach/ApproachBootstrapProvider.cpp index ac4bdadbc..f1204cc82 100644 --- a/src/plugin/approach/ApproachBootstrapProvider.cpp +++ b/src/plugin/approach/ApproachBootstrapProvider.cpp @@ -1,7 +1,8 @@ +#include "ApproachBootstrapProvider.h" +#include "aircraft/CallsignSelectionListFactory.h" #include "AircraftSelectionProvider.h" #include "AirfieldMinimumSeparationSelectorList.h" #include "AirfieldTargetSelectorList.h" -#include "ApproachBootstrapProvider.h" #include "ApproachFlightplanEventHandler.h" #include "ApproachModuleFactory.h" #include "ApproachSequencerDisplay.h" @@ -9,30 +10,33 @@ #include "ApproachSequencerDisplayOptions.h" #include "ApproachSequencerOptionsLoader.h" #include "ApproachSpacingRingRenderer.h" -#include "GlideslopeDeviationEstimator.h" -#include "GlideslopeDeviationTagItem.h" -#include "RemoveLandedAircraft.h" -#include "SequencerAirfieldSelector.h" -#include "TargetSelectorList.h" -#include "ToggleApproachSequencerDisplay.h" -#include "aircraft/CallsignSelectionListFactory.h" #include "bootstrap/ModuleFactories.h" #include "bootstrap/PersistenceContainer.h" #include "euroscope/AsrEventHandlerCollection.h" #include "euroscope/PluginSettingsProviderCollection.h" #include "flightplan/FlightPlanEventHandlerCollection.h" +#include "GlideslopeDeviationEstimator.h" +#include "GlideslopeDeviationTagItem.h" +#include "graphics/GdiplusBrushes.h" #include "list/PopupListFactory.h" #include "radarscreen/MenuToggleableDisplayFactory.h" #include "radarscreen/RadarRenderableCollection.h" +#include "RemoveLandedAircraft.h" +#include "SequencerAirfieldSelector.h" #include "tag/TagItemCollection.h" +#include "TargetSelectorList.h" #include "timedevent/TimedEventCollection.h" +#include "ToggleApproachSequencerDisplay.h" + +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin::Approach { void ApproachBootstrapProvider::BootstrapPlugin(Bootstrap::PersistenceContainer& container) { - container.pluginSettingsProviders->AddProvider(std::make_shared( - container.moduleFactories->Approach().SequencerOptions(), *container.airfields)); + container.pluginSettingsProviders->AddProvider( + std::make_shared( + container.moduleFactories->Approach().SequencerOptions(), *container.airfields)); container.timedHandler->RegisterEvent( std::make_shared( @@ -92,6 +96,7 @@ namespace UKControllerPlugin::Approach { container.moduleFactories->Approach().SequencerOptions(), displayOptions), "Toggle sequencer airfield separation selector"), *container.plugin, + *container.brushes, sequencerScreenObjectId), RadarScreen::RadarRenderableCollection::beforeTags); diff --git a/src/plugin/approach/ApproachBootstrapProvider.h b/src/plugin/approach/ApproachBootstrapProvider.h index bbb8c1a68..c4a61a327 100644 --- a/src/plugin/approach/ApproachBootstrapProvider.h +++ b/src/plugin/approach/ApproachBootstrapProvider.h @@ -1,6 +1,10 @@ #pragma once #include "bootstrap/BootstrapProviderInterface.h" +namespace UKControllerPlugin::Windows { + struct GdiplusBrushes; +} // namespace UKControllerPlugin::Windows + namespace UKControllerPlugin::Approach { class ApproachBootstrapProvider : public Bootstrap::BootstrapProviderInterface { diff --git a/src/plugin/approach/ApproachSequencerDisplay.cpp b/src/plugin/approach/ApproachSequencerDisplay.cpp index 4fd25a124..4d182a311 100644 --- a/src/plugin/approach/ApproachSequencerDisplay.cpp +++ b/src/plugin/approach/ApproachSequencerDisplay.cpp @@ -1,8 +1,8 @@ +#include "ApproachSequencerDisplay.h" #include "AirfieldApproachOptions.h" #include "ApproachSequence.h" #include "ApproachSequencedAircraft.h" #include "ApproachSequencer.h" -#include "ApproachSequencerDisplay.h" #include "ApproachSequencerDisplayOptions.h" #include "ApproachSequencerOptions.h" #include "ApproachSpacingCalculator.h" @@ -13,6 +13,7 @@ #include "euroscope/EuroscopePluginLoopbackInterface.h" #include "graphics/FontManager.h" #include "graphics/GdiGraphicsInterface.h" +#include "graphics/GdiplusBrushes.h" #include "graphics/StringFormatManager.h" #include "helper/HelperFunctions.h" #include "list/PopupListInterface.h" @@ -21,6 +22,7 @@ using UKControllerPlugin::Components::CollapsibleWindowTitleBar; using UKControllerPlugin::Number::To1Dp; using UKControllerPlugin::Number::To1DpWide; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin::Approach { @@ -35,28 +37,31 @@ namespace UKControllerPlugin::Approach { std::shared_ptr airfieldTargetSelector, std::shared_ptr airfieldSeparationSelector, Euroscope::EuroscopePluginLoopbackInterface& plugin, + const GdiplusBrushes& brushes, int screenObjectId) : sequencer(sequencer), spacingCalculator(spacingCalculator), options(options), displayOptions(std::move(displayOptions)), airfieldSelector(std::move(airfieldSelector)), callsignSelector(std::move(callsignSelector)), targetSelector(std::move(targetSelector)), airfieldTargetSelector(std::move(airfieldTargetSelector)), - airfieldSeparationSelector(std::move(airfieldSeparationSelector)), plugin(plugin), - screenObjectId(screenObjectId), titleBar(CollapsibleWindowTitleBar::Create( - L"Approach Sequencer", - titleBarArea, - [this]() -> bool { return this->displayOptions->ContentCollapsed(); }, - screenObjectId)), - airfieldClickspot(Components::ClickableArea::Create( - this->airfieldTextArea, screenObjectId, AIRFIELD_SELECTOR_CLICKSPOT, false)), + airfieldSeparationSelector(std::move(airfieldSeparationSelector)), plugin(plugin), brushes(brushes), + screenObjectId(screenObjectId), titleBar( + CollapsibleWindowTitleBar::Create( + L"Approach Sequencer", + titleBarArea, + [this]() -> bool { return this->displayOptions->ContentCollapsed(); }, + screenObjectId, + brushes)), + airfieldClickspot( + Components::ClickableArea::Create( + this->airfieldTextArea, screenObjectId, AIRFIELD_SELECTOR_CLICKSPOT, false)), addClickspot( Components::ClickableArea::Create(this->addButton, screenObjectId, ADD_AIRCRAFT_CLICKSPOT, false)), - airfieldTargetClickspot(Components::ClickableArea::Create( - this->airfieldTargetTextArea, screenObjectId, AIRFIELD_TARGET_CLICKSPOT, false)), - airfieldSeparationClickspot(Components::ClickableArea::Create( - this->airfieldSeparationTextArea, screenObjectId, AIRFIELD_SEPARATION_CLICKSPOT, false)), - backgroundBrush(std::make_shared(BACKGROUND_COLOUR)), - textBrush(std::make_shared(TEXT_COLOUR)), - dividingPen(std::make_shared(TEXT_COLOUR)) + airfieldTargetClickspot( + Components::ClickableArea::Create( + this->airfieldTargetTextArea, screenObjectId, AIRFIELD_TARGET_CLICKSPOT, false)), + airfieldSeparationClickspot( + Components::ClickableArea::Create( + this->airfieldSeparationTextArea, screenObjectId, AIRFIELD_SEPARATION_CLICKSPOT, false)) { } @@ -76,12 +81,12 @@ namespace UKControllerPlugin::Approach { graphics.Translated( displayOptions->Position().x, displayOptions->Position().y, [this, &graphics, &radarScreen]() { if (this->displayOptions->ContentCollapsed()) { - this->titleBar->Draw(graphics, radarScreen); + this->titleBar->DrawTheme(graphics, radarScreen, brushes); return; } this->RenderBackground(graphics); - this->titleBar->Draw(graphics, radarScreen); + this->titleBar->DrawTheme(graphics, radarScreen, brushes); this->RenderAirfield(graphics, radarScreen); this->RenderAddButton(graphics, radarScreen); this->RenderAirfieldTarget(graphics, radarScreen); @@ -173,7 +178,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( L"Airfield:", airfieldStaticArea, - *textBrush, + *this->brushes.textBrush, Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); @@ -181,7 +186,7 @@ namespace UKControllerPlugin::Approach { HelperFunctions::ConvertToWideString( displayOptions->Airfield().empty() ? "--" : displayOptions->Airfield()), airfieldTextArea, - *textBrush, + *this->brushes.textBrush, Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); this->airfieldClickspot->Apply(graphics, radarScreen); @@ -189,23 +194,23 @@ namespace UKControllerPlugin::Approach { void ApproachSequencerDisplay::RenderDivider(Windows::GdiGraphicsInterface& graphics) { - graphics.DrawLine(*dividingPen, dividerLeft, dividerRight); + graphics.DrawLine(*this->brushes.textPen, dividerLeft, dividerRight); } void ApproachSequencerDisplay::RenderHeaders(Windows::GdiGraphicsInterface& graphics) { - graphics.DrawString(L"#", numberHeader, *textBrush); - graphics.DrawString(L"Callsign", callsignHeader, *textBrush); - graphics.DrawString(L"Target", targetHeader, *textBrush); - graphics.DrawString(L"Actual", actualHeader, *textBrush); - graphics.DrawString(L"Actions", actionsHeader, *textBrush); + graphics.DrawString(L"#", numberHeader, *this->brushes.textBrush); + graphics.DrawString(L"Callsign", callsignHeader, *this->brushes.textBrush); + graphics.DrawString(L"Target", targetHeader, *this->brushes.textBrush); + graphics.DrawString(L"Actual", actualHeader, *this->brushes.textBrush); + graphics.DrawString(L"Actions", actionsHeader, *this->brushes.textBrush); } void ApproachSequencerDisplay::RenderAddButton( Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen) { - graphics.DrawRect(addButton, *dividingPen); - graphics.DrawString(L"Add Aircraft", addButton, *textBrush); + graphics.DrawRect(addButton, *this->brushes.textPen); + graphics.DrawString(L"Add Aircraft", addButton, *this->brushes.textBrush); addClickspot->Apply(graphics, radarScreen); } @@ -248,15 +253,18 @@ namespace UKControllerPlugin::Approach { int sequenceNumber = 1; while (aircraftToProcess != nullptr) { - graphics.DrawString(std::to_wstring(sequenceNumber), numberRect, *textBrush); + graphics.DrawString(std::to_wstring(sequenceNumber), numberRect, *this->brushes.textBrush); graphics.DrawString( - HelperFunctions::ConvertToWideString(aircraftToProcess->Callsign()), callsignRect, *textBrush); + HelperFunctions::ConvertToWideString(aircraftToProcess->Callsign()), + callsignRect, + *this->brushes.textBrush); // The target distance / wake if (aircraftToProcess->Mode() == ApproachSequencingMode::WakeTurbulence) { - graphics.DrawString(L"Wake", targetRect, *textBrush); + graphics.DrawString(L"Wake", targetRect, *this->brushes.textBrush); } else { - graphics.DrawString(To1DpWide(aircraftToProcess->ExpectedDistance()), targetRect, *textBrush); + graphics.DrawString( + To1DpWide(aircraftToProcess->ExpectedDistance()), targetRect, *this->brushes.textBrush); } Components::ClickableArea::Create( targetRect, screenObjectId, "approachTarget" + aircraftToProcess->Callsign(), false) @@ -264,30 +272,30 @@ namespace UKControllerPlugin::Approach { double requiredSpacing = spacingCalculator.Calculate(displayOptions->Airfield(), *aircraftToProcess); if (requiredSpacing == spacingCalculator.NoSpacing()) { - graphics.DrawString(L"--", actualRect, *textBrush); + graphics.DrawString(L"--", actualRect, *this->brushes.textBrush); } else { - graphics.DrawString(To1DpWide(requiredSpacing), actualRect, *textBrush); + graphics.DrawString(To1DpWide(requiredSpacing), actualRect, *this->brushes.textBrush); } auto upButton = Components::Button::Create( upButtonRect, screenObjectId, "moveUp" + aircraftToProcess->Callsign(), - Components::UpArrow(TEXT_COLOUR)); + Components::UpArrow(this->brushes.text)); upButton->Draw(graphics, radarScreen); auto downButton = Components::Button::Create( downButtonRect, screenObjectId, "moveDown" + aircraftToProcess->Callsign(), - Components::DownArrow(TEXT_COLOUR)); + Components::DownArrow(this->brushes.text)); downButton->Draw(graphics, radarScreen); auto deleteButton = Components::Button::Create( deleteButtonRect, screenObjectId, "deleteButton" + aircraftToProcess->Callsign(), - Components::DeleteButton(TEXT_COLOUR)); + Components::DeleteButton(this->brushes.text)); deleteButton->Draw(graphics, radarScreen); auto toggleButton = Components::Button::Create( @@ -297,13 +305,13 @@ namespace UKControllerPlugin::Approach { [&aircraftToProcess, &radarScreen, this]( Windows::GdiGraphicsInterface& graphics, const Gdiplus::Rect& area) { Gdiplus::Rect drawArea = {0, 0, area.Width, area.Height}; - graphics.FillCircle(drawArea, *textBrush); + graphics.FillCircle(drawArea, *this->brushes.textBrush); if (!aircraftToProcess->ShouldDraw()) { Components::Button::Create( drawArea, screenObjectId, "toggleDraw" + aircraftToProcess->Callsign(), - Components::DeleteButton(BACKGROUND_COLOUR)) + Components::DeleteButton(this->brushes.background)) ->Draw(graphics, radarScreen); } }); @@ -332,7 +340,7 @@ namespace UKControllerPlugin::Approach { TITLE_BAR_HEIGHT, WINDOW_WIDTH, static_cast(callsignHeader.GetBottom() + INSETS + (numberOfCallsigns * callsignHeader.Height))}; - graphics.FillRect(contentArea, *backgroundBrush); + graphics.FillRect(contentArea, *this->brushes.backgroundBrush); } void ApproachSequencerDisplay::RenderAirfieldTarget( @@ -341,7 +349,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( L"Target:", airfieldTargetStatic, - *textBrush, + *this->brushes.textBrush, Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); @@ -356,7 +364,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( targetString, airfieldTargetTextArea, - *textBrush, + *this->brushes.textBrush, Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); this->airfieldTargetClickspot->Apply(graphics, radarScreen); @@ -368,7 +376,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( L"Separation:", airfieldSeparationStatic, - *textBrush, + *this->brushes.textBrush, Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); @@ -377,7 +385,7 @@ namespace UKControllerPlugin::Approach { ? L"--" : To1DpWide(options.Get(displayOptions->Airfield()).minimumSeparationRequirement), airfieldSeparationTextArea, - *textBrush, + *this->brushes.textBrush, Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); this->airfieldSeparationClickspot->Apply(graphics, radarScreen); diff --git a/src/plugin/approach/ApproachSequencerDisplay.h b/src/plugin/approach/ApproachSequencerDisplay.h index 483906d49..30a641274 100644 --- a/src/plugin/approach/ApproachSequencerDisplay.h +++ b/src/plugin/approach/ApproachSequencerDisplay.h @@ -12,6 +12,9 @@ namespace UKControllerPlugin { namespace List { class PopupListInterface; } // namespace List + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin::Approach { @@ -37,6 +40,7 @@ namespace UKControllerPlugin::Approach { std::shared_ptr airfieldTargetSelector, std::shared_ptr airfieldSeparationSelector, Euroscope::EuroscopePluginLoopbackInterface& plugin, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, int screenObjectId); [[nodiscard]] auto IsVisible() const -> bool override; void LeftClick( @@ -67,7 +71,7 @@ namespace UKControllerPlugin::Approach { // Dimensions inline static const int WINDOW_WIDTH = 435; - inline static const int TITLE_BAR_HEIGHT = 20; + inline static const int TITLE_BAR_HEIGHT = 15; inline static const int INSETS = 5; // Clickspot @@ -106,6 +110,9 @@ namespace UKControllerPlugin::Approach { // The plugin Euroscope::EuroscopePluginLoopbackInterface& plugin; + // Pens and brushes + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; + // The screen object id int screenObjectId; @@ -137,11 +144,5 @@ namespace UKControllerPlugin::Approach { std::shared_ptr addClickspot; std::shared_ptr airfieldTargetClickspot; std::shared_ptr airfieldSeparationClickspot; - - const Gdiplus::Color BACKGROUND_COLOUR = Gdiplus::Color(64, 64, 64); - const Gdiplus::Color TEXT_COLOUR = Gdiplus::Color(225, 225, 225); - std::shared_ptr backgroundBrush; - std::shared_ptr textBrush; - std::shared_ptr dividingPen; }; } // namespace UKControllerPlugin::Approach diff --git a/src/plugin/bootstrap/InitialisePlugin.cpp b/src/plugin/bootstrap/InitialisePlugin.cpp index c03462c08..8a6e44d51 100644 --- a/src/plugin/bootstrap/InitialisePlugin.cpp +++ b/src/plugin/bootstrap/InitialisePlugin.cpp @@ -1,17 +1,17 @@ +#include "bootstrap/InitialisePlugin.h" #include "aircraft/AircraftModule.h" #include "aircraft/CallsignSelectionListFactoryBootstrap.h" #include "airfield/AirfieldModule.h" #include "api/ApiFactory.h" #include "api/ApiRequestFactory.h" #include "api/BootstrapApi.h" -#include "api/FirstTimeApiConfigLoader.h" #include "api/FirstTimeApiAuthorisationChecker.h" +#include "api/FirstTimeApiConfigLoader.h" #include "bootstrap/BootstrapProviderCollection.h" #include "bootstrap/CollectionBootstrap.h" #include "bootstrap/EventHandlerCollectionBootstrap.h" #include "bootstrap/ExternalsBootstrap.h" #include "bootstrap/HelperBootstrap.h" -#include "bootstrap/InitialisePlugin.h" #include "bootstrap/ModuleBootstrap.h" #include "bootstrap/PostInit.h" #include "controller/ControllerBootstrap.h" @@ -22,11 +22,14 @@ #include "dependency/UpdateDependencies.h" #include "euroscope/GeneralSettingsConfigurationBootstrap.h" #include "euroscope/PluginUserSettingBootstrap.h" +#include "euroscope/UserSetting.h" #include "eventhandler/EventBusBootstrap.h" #include "filestatus/FileStatusModule.h" #include "flightinformationservice/FlightInformationServiceModule.h" #include "flightplan/FlightplanStorageBootstrap.h" #include "flightrule/FlightRuleModule.h" +#include "graphics/GdiplusBrushes.h" +#include "graphics/Theme.h" #include "handoff/HandoffModule.h" #include "historytrail/HistoryTrailModule.h" #include "hold/HoldModule.h" @@ -83,6 +86,7 @@ using UKControllerPlugin::Duplicate::DuplicatePlugin; using UKControllerPlugin::Euroscope::GeneralSettingsConfigurationBootstrap; using UKControllerPlugin::Euroscope::PluginUserSettingBootstrap; using UKControllerPlugin::Flightplan::FlightplanStorageBootstrap; +using UKControllerPlugin::Graphics::ThemeFromKey; using UKControllerPlugin::HistoryTrail::HistoryTrailModule; using UKControllerPlugin::InitialAltitude::InitialAltitudeModule; using UKControllerPlugin::Log::LoggerBootstrap; @@ -240,13 +244,21 @@ namespace UKControllerPlugin { LoginModule::BootstrapPlugin(*this->container); SectorFile::BootstrapPlugin(*this->container); + // Apply the saved colour palette theme + { + auto& userSettings = *this->container->pluginUserSettingHandler; + std::string palette = userSettings.GetStringEntry("colourPalette", "default"); + this->container->brushes->LoadTheme(ThemeFromKey(palette)); + } + // General settings config bootstrap GeneralSettingsConfigurationBootstrap::BootstrapPlugin( *this->container->dialogManager, *this->container->pluginUserSettingHandler, *this->container->userSettingHandlers, *this->container->settingsRepository, - *this->container->windows); + *this->container->windows, + *this->container->brushes); // Bootstrap the modules Metar::BootstrapPlugin(*this->container); diff --git a/src/plugin/components/CollapsibleWindowTitleBar.cpp b/src/plugin/components/CollapsibleWindowTitleBar.cpp index 80fa1cf65..56858de54 100644 --- a/src/plugin/components/CollapsibleWindowTitleBar.cpp +++ b/src/plugin/components/CollapsibleWindowTitleBar.cpp @@ -1,32 +1,44 @@ -#include "Button.h" #include "CollapsibleWindowTitleBar.h" +#include "Button.h" +#include "graphics/GdiplusBrushes.h" #include "StandardButtons.h" namespace UKControllerPlugin::Components { CollapsibleWindowTitleBar::CollapsibleWindowTitleBar( - std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId) - : TitleBar(title, area) + const std::wstring& title, + Gdiplus::Rect area, + const std::function& collapseState, + int screenObjectId, + const Windows::GdiplusBrushes& brushes) + : TitleBar(title, area), brushes(brushes) { this->closeButton = Button::Create( {area.GetRight() - 20, area.GetTop() + 5, 10, 10}, screenObjectId, "closeButton", - Components::CloseButton()); + Components::CloseButton(this->brushes)); this->collapseButton = Button::Create( {area.GetRight() - 35, area.GetTop() + 5, 10, 10}, screenObjectId, "collapseButton", - Components::CollapseButton(collapseState)); + Components::CollapseButton(this->brushes, collapseState)); } std::shared_ptr CollapsibleWindowTitleBar::Create( - std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId) + const std::wstring& title, + Gdiplus::Rect area, + const std::function& collapseState, + int screenObjectId, + const Windows::GdiplusBrushes& brushes) { - auto titlebar = std::shared_ptr( - new CollapsibleWindowTitleBar(title, area, collapseState, screenObjectId)); - titlebar->WithDefaultBorder()->WithDefaultTextBrush()->WithDefaultBackgroundBrush()->WithDrag(screenObjectId); + auto titlebar = + std::make_shared(title, area, collapseState, screenObjectId, brushes); + titlebar->WithBackgroundBrush(brushes.headerBrush) + ->WithTextBrush(brushes.textBrush) + ->WithBorder(brushes.borderPen) + ->WithDrag(screenObjectId); return titlebar; } @@ -38,4 +50,14 @@ namespace UKControllerPlugin::Components { this->closeButton->Draw(graphics, radarScreen); this->collapseButton->Draw(graphics, radarScreen); } + + void CollapsibleWindowTitleBar::DrawTheme( + Windows::GdiGraphicsInterface& graphics, + Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, + const Windows::GdiplusBrushes& themeBrushes) const + { + TitleBar::DrawTheme(graphics, radarScreen, themeBrushes); + this->closeButton->Draw(graphics, radarScreen); + this->collapseButton->Draw(graphics, radarScreen); + } } // namespace UKControllerPlugin::Components diff --git a/src/plugin/components/CollapsibleWindowTitleBar.h b/src/plugin/components/CollapsibleWindowTitleBar.h index 603e28789..89ef81897 100644 --- a/src/plugin/components/CollapsibleWindowTitleBar.h +++ b/src/plugin/components/CollapsibleWindowTitleBar.h @@ -11,16 +11,30 @@ namespace UKControllerPlugin::Components { class CollapsibleWindowTitleBar : public TitleBar { public: - static std::shared_ptr - Create(std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId); + static std::shared_ptr Create( + const std::wstring& title, + Gdiplus::Rect area, + const std::function& collapseState, + int screenObjectId, + const Windows::GdiplusBrushes& brushes); void Draw(Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen) const override; + void DrawTheme( + Windows::GdiGraphicsInterface& graphics, + Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, + const Windows::GdiplusBrushes& themeBrushes) const override; - protected: CollapsibleWindowTitleBar( - std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId); + const std::wstring& title, + Gdiplus::Rect area, + const std::function& collapseState, + int screenObjectId, + const Windows::GdiplusBrushes& brushes); private: + // The brushes for theming + const Windows::GdiplusBrushes& brushes; + // The close button std::shared_ptr