From 34db6e54840bd6ab19c067cf46caaa6adc335069 Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Sun, 15 Jun 2025 01:30:31 +0100 Subject: [PATCH 01/17] Added Colour Palette Dropdown --- resource/UKControllerPlugin.rc | 4 ++++ resource/resource.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/resource/UKControllerPlugin.rc b/resource/UKControllerPlugin.rc index dc9898b2c..d5ce82a3f 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 | CBS_SORT | 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..8645f6311 100644 --- a/resource/resource.h +++ b/resource/resource.h @@ -207,6 +207,7 @@ #define IDC_API_KEY_STATIC 1144 #define IDC_ 1145 #define IDC_RELEASE_CHAT_MESSAGE 1145 +#define IDC_COLOUR_PALETTE 1146 // Next default values for new objects // @@ -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 From 184a0651ed6c5ca3a1e17025819ccc6f82f77c69 Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Sun, 15 Jun 2025 01:34:00 +0100 Subject: [PATCH 02/17] Add Settings Handler for Colour Palette --- .../euroscope/GeneralSettingsDialog.cpp | 37 +++++++++++++++++++ src/plugin/euroscope/GeneralSettingsDialog.h | 10 +++++ .../euroscope/GeneralSettingsEntries.cpp | 6 +++ src/plugin/euroscope/GeneralSettingsEntries.h | 4 ++ 4 files changed, 57 insertions(+) diff --git a/src/plugin/euroscope/GeneralSettingsDialog.cpp b/src/plugin/euroscope/GeneralSettingsDialog.cpp index 44e8ed0ad..8f287af4e 100644 --- a/src/plugin/euroscope/GeneralSettingsDialog.cpp +++ b/src/plugin/euroscope/GeneralSettingsDialog.cpp @@ -91,6 +91,31 @@ namespace UKControllerPlugin { } } + // Colour Palette + auto selectedColourPalette = this->userSettings.GetStringEntry( + GeneralSettingsEntries::colourPaletteSettingsKey, DEFAULT_COLOUR_PALETTE); + + if (this->colourPaletteMap.count(selectedColourPalette) == 0) { + selectedColourPalette = DEFAULT_COLOUR_PALETTE; + } + + for (const auto& palette : this->colourPaletteMap) { + const auto paletteName = palette.second.c_str(); + int insertIndex = SendDlgItemMessage( + hwnd, IDC_COLOUR_PALETTE, CB_INSERTSTRING, NULL, reinterpret_cast(paletteName)); + + SendDlgItemMessage( + hwnd, + IDC_COLOUR_PALETTE, + CB_SETITEMDATA, + insertIndex, + reinterpret_cast(palette.first.c_str())); + + if (palette.first == selectedColourPalette) { + SendDlgItemMessage(hwnd, IDC_COLOUR_PALETTE, CB_SETCURSEL, insertIndex, NULL); + } + } + return TRUE; } @@ -152,6 +177,18 @@ namespace UKControllerPlugin { SendDlgItemMessage(hwnd, IDC_RELEASE_CHANNEL, CB_GETITEMDATA, selectedReleaseChannelIndex, 0)); this->settings.UpdateSetting("release_channel", selectedChannel); + + // Colour Palette + const auto selectedColourPaletteIndex = SendDlgItemMessage(hwnd, IDC_COLOUR_PALETTE, CB_GETCURSEL, 0, 0); + + const std::string selectedColourPalette = reinterpret_cast( + SendDlgItemMessage(hwnd, IDC_COLOUR_PALETTE, CB_GETITEMDATA, selectedColourPaletteIndex, 0)); + + this->userSettings.Save( + GeneralSettingsEntries::colourPaletteSettingsKey, + GeneralSettingsEntries::colourPaletteSettingsDescription, + selectedColourPalette); + this->userSettingsHandlers.UserSettingsUpdateEvent(this->userSettings); } diff --git a/src/plugin/euroscope/GeneralSettingsDialog.h b/src/plugin/euroscope/GeneralSettingsDialog.h index aa8cc84ab..aceaea9b1 100644 --- a/src/plugin/euroscope/GeneralSettingsDialog.h +++ b/src/plugin/euroscope/GeneralSettingsDialog.h @@ -38,8 +38,18 @@ namespace UKControllerPlugin::Euroscope { {"beta", L"Beta"}, }; + const std::map colourPaletteMap{ + {"default", L"Default"}, + {"node", L"NODE"}, + {"nerc", L"NERC"}, + {"nova", L"NOVA"}, + {"itec", L"iTEC"}, + }; + const std::string DEFAULT_RELEASE_CHANNEL = "stable"; + const std::string DEFAULT_COLOUR_PALETTE = "default"; + // A place where user settings are retrieved and stored UKControllerPlugin::Euroscope::UserSetting& userSettings; diff --git a/src/plugin/euroscope/GeneralSettingsEntries.cpp b/src/plugin/euroscope/GeneralSettingsEntries.cpp index c3be22922..bf97339e5 100644 --- a/src/plugin/euroscope/GeneralSettingsEntries.cpp +++ b/src/plugin/euroscope/GeneralSettingsEntries.cpp @@ -36,5 +36,11 @@ namespace UKControllerPlugin { const std::string GeneralSettingsEntries::initialHeadingToggleSettingsKey = "autoAssignInitialHeadings"; const std::string GeneralSettingsEntries::initialHeadingToggleSettingsDescription = "Automatically assign initial headings"; + + // Colour Palette + const std::string GeneralSettingsEntries::colourPaletteSettingsKey = "colourPalette"; + const std::string GeneralSettingsEntries::colourPaletteSettingsDescription = + "UKCP Colour Palette"; + } // namespace Euroscope } // namespace UKControllerPlugin diff --git a/src/plugin/euroscope/GeneralSettingsEntries.h b/src/plugin/euroscope/GeneralSettingsEntries.h index 3b44d6d91..6270f6dc7 100644 --- a/src/plugin/euroscope/GeneralSettingsEntries.h +++ b/src/plugin/euroscope/GeneralSettingsEntries.h @@ -35,6 +35,10 @@ namespace UKControllerPlugin { // Initial Headings static const std::string initialHeadingToggleSettingsKey; static const std::string initialHeadingToggleSettingsDescription; + + // Colour Palette + static const std::string colourPaletteSettingsKey; + static const std::string colourPaletteSettingsDescription; } GeneralSettingsEntries; } // namespace Euroscope } // namespace UKControllerPlugin From b7c8c5d426d67ce186dfe1708e270ecd7f841a53 Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Sun, 15 Jun 2025 19:32:46 +0100 Subject: [PATCH 03/17] Add General Definitions and Foundations --- src/plugin/CMakeLists.txt | 4 + .../graphics/ColourPaletteConfiguration.cpp | 86 +++++++++++++++++++ .../graphics/ColourPaletteConfiguration.h | 37 ++++++++ .../graphics/ColourPaletteDefinitions.cpp | 58 +++++++++++++ .../graphics/ColourPaletteDefinitions.h | 64 ++++++++++++++ 5 files changed, 249 insertions(+) create mode 100644 src/plugin/graphics/ColourPaletteConfiguration.cpp create mode 100644 src/plugin/graphics/ColourPaletteConfiguration.h create mode 100644 src/plugin/graphics/ColourPaletteDefinitions.cpp create mode 100644 src/plugin/graphics/ColourPaletteDefinitions.h diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index dd818321f..8ad451612 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -300,6 +300,10 @@ set(src__geometry source_group("src\\geometry" FILES ${src__geometry}) set(src__graphics + "graphics/ColourPaletteDefinitions.cpp" + "graphics/ColourPaletteDefinitions.h" + "graphics/ColourPaletteConfiguration.cpp" + "graphics/ColourPaletteConfiguration.h" "graphics/GdiGraphicsInterface.h" "graphics/GdiGraphicsWrapper.cpp" "graphics/GdiGraphicsWrapper.h" diff --git a/src/plugin/graphics/ColourPaletteConfiguration.cpp b/src/plugin/graphics/ColourPaletteConfiguration.cpp new file mode 100644 index 000000000..3c879e261 --- /dev/null +++ b/src/plugin/graphics/ColourPaletteConfiguration.cpp @@ -0,0 +1,86 @@ +#include "ColourPaletteDefinitions.h" +#include "GdiGraphicsInterface.h" +#include "ColourPaletteConfiguration.h" +#include "euroscope/GeneralSettingsEntries.h" +#include "euroscope/UserSetting.h" + +using UKControllerPlugin::Graphics::ColourPaletteDefinitions; +using UKControllerPlugin::Euroscope::GeneralSettingsEntries; +using UKControllerPlugin::Euroscope::UserSetting; + +namespace UKControllerPlugin { + namespace Graphics { + /* + Set the colour palette definitions based on the selected palette name. + */ + ColourPaletteConfiguration SetColourPalette(UserSetting& userSetting) { + ColourPaletteConfiguration palette; + std::string selectedPaletteName = userSetting.GetStringEntry("colour_palette", DEFAULT_COLOUR_PALETTE); + + if (selectedPaletteName == "node") { + palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NodeBackground); + palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NodeBorder); + palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NodeHeaders); + palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedHeaders); + palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NodeDefaultText); + palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedText); + palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeMainAircraftText); + palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedAircraftText); + palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerGreen); + palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerYellow); + palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerRed); + } else if (selectedPaletteName == "nerc") { + palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NercBackground); + palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NercBorder); + palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NercHeaders); + palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NercHighlightedHeaders); + palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NercDefaultText); + palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NercHighlightedText); + palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NercMainAircraftText); + palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NercHighlightedAircraftText); + palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NercTimerGreen); + palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NercTimerYellow); + palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NercTimerRed); + } else if (selectedPaletteName == "nova") { + palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NovaBackground); + palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NovaBorder); + palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NovaHeaders); + palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NovaHighlightedHeaders); + palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NovaDefaultText); + palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NovaHighlightedText); + palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NovaMainAircraftText); + palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NovaHighlightedAircraftText); + palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NovaTimerGreen); + palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NovaTimerYellow); + palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NovaTimerRed); + } else if (selectedPaletteName == "itec") { + palette.Background = Gdiplus::Color(ColourPaletteDefinitions::ItecBackground); + palette.Border = Gdiplus::Color(ColourPaletteDefinitions::ItecBorder); + palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::ItecHeaders); + palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::ItecHighlightedHeaders); + palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::ItecDefaultText); + palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::ItecHighlightedText); + palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::ItecMainAircraftText); + palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::ItecHighlightedAircraftText); + palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::ItecTimerGreen); + palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::ItecTimerYellow); + palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::ItecTimerRed); + } + else { + // Default to the default palette WIP + palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NodeBackground); + palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NodeBorder); + palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NodeHeaders); + palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedHeaders); + palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NodeDefaultText); + palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedText); + palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeMainAircraftText); + palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedAircraftText); + palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerGreen); + palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerYellow); + palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerRed); + } + return palette; + } + } +} \ No newline at end of file diff --git a/src/plugin/graphics/ColourPaletteConfiguration.h b/src/plugin/graphics/ColourPaletteConfiguration.h new file mode 100644 index 000000000..79a851dfa --- /dev/null +++ b/src/plugin/graphics/ColourPaletteConfiguration.h @@ -0,0 +1,37 @@ +#pragma once +#include "GdiGraphicsInterface.h" +#include "euroscope/UserSetting.h" + +using UKControllerPlugin::Euroscope::UserSetting; + +namespace UKControllerPlugin { + namespace Graphics { + + // Global definitions for the current colour palette. + struct ColourPaletteConfiguration { + Gdiplus::Color Background; + Gdiplus::Color Border; + Gdiplus::Color Headers; + Gdiplus::Color HighlightedHeaders; + Gdiplus::Color DefaultText; + Gdiplus::Color HighlightedText; + Gdiplus::Color MainAircraftText; + Gdiplus::Color HighlightedAircraftText; + Gdiplus::Color TimerGreen; + Gdiplus::Color TimerYellow; + Gdiplus::Color TimerRed; + }; + + const std::map colourPaletteMap{ + {"default", L"Default"}, + {"node", L"NODE"}, + {"nerc", L"NERC"}, + {"nova", L"NOVA"}, + {"itec", L"iTEC"}, + }; + + const std::string DEFAULT_COLOUR_PALETTE = "default"; + + std::string GetSelectedColourPalette(UserSetting& userSetting); + } +} \ No newline at end of file diff --git a/src/plugin/graphics/ColourPaletteDefinitions.cpp b/src/plugin/graphics/ColourPaletteDefinitions.cpp new file mode 100644 index 000000000..c275b6215 --- /dev/null +++ b/src/plugin/graphics/ColourPaletteDefinitions.cpp @@ -0,0 +1,58 @@ +#include "ColourPaletteDefinitions.h" + +namespace UKControllerPlugin { + namespace Graphics { + + // NODE + const Gdiplus::Color ColourPaletteDefinitions::NodeBackground = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::NodeBorder = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NodeHeaders = Gdiplus::Color(160, 111, 112); // #a06f70 + const Gdiplus::Color ColourPaletteDefinitions::NodeHighlightedHeaders = Gdiplus::Color(255, 100, 50); // #ff6432 + const Gdiplus::Color ColourPaletteDefinitions::NodeDefaultText = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NodeHighlightedText = Gdiplus::Color(232, 163, 0); // #e8a300 + const Gdiplus::Color ColourPaletteDefinitions::NodeMainAircraftText = Gdiplus::Color(104, 221, 69); // #68dd45 + const Gdiplus::Color ColourPaletteDefinitions::NodeHighlightedAircraftText = Gdiplus::Color(232, 163, 0); // #e8a300 + const Gdiplus::Color ColourPaletteDefinitions::NodeTimerGreen = Gdiplus::Color(104, 221, 69); // #68dd45 + const Gdiplus::Color ColourPaletteDefinitions::NodeTimerYellow = Gdiplus::Color(232, 163, 0); // #e8a300 + const Gdiplus::Color ColourPaletteDefinitions::NodeTimerRed = Gdiplus::Color(255, 100, 50); // #ff6432 + + // NERC + const Gdiplus::Color ColourPaletteDefinitions::NercBackground = Gdiplus::Color(150, 150, 150); // #969696 + const Gdiplus::Color ColourPaletteDefinitions::NercBorder = Gdiplus::Color(83, 83, 83); // #535353 + const Gdiplus::Color ColourPaletteDefinitions::NercHeaders = Gdiplus::Color(135, 135, 135); // #878787 + const Gdiplus::Color ColourPaletteDefinitions::NercHighlightedHeaders = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NercDefaultText = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::NercHighlightedText = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NercMainAircraftText = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::NercHighlightedAircraftText = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NercTimerGreen = Gdiplus::Color(180, 255, 125); // #B4FF7D + const Gdiplus::Color ColourPaletteDefinitions::NercTimerYellow = Gdiplus::Color(255, 216, 0); // #FFD800 + const Gdiplus::Color ColourPaletteDefinitions::NercTimerRed = Gdiplus::Color(192, 0, 0); // #C00000 + + // NOVA + const Gdiplus::Color ColourPaletteDefinitions::NovaBackground = Gdiplus::Color(180, 180, 180); // #B4B4B4 + const Gdiplus::Color ColourPaletteDefinitions::NovaBorder = Gdiplus::Color(83, 83, 83); // #535353 + const Gdiplus::Color ColourPaletteDefinitions::NovaHeaders = Gdiplus::Color(0, 140, 200); // #008CC8 + const Gdiplus::Color ColourPaletteDefinitions::NovaHighlightedHeaders = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NovaDefaultText = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::NovaHighlightedText = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NovaMainAircraftText = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::NovaHighlightedAircraftText = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NovaTimerGreen = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::NovaTimerYellow = Gdiplus::Color(255, 216, 0); // #FFD800 + const Gdiplus::Color ColourPaletteDefinitions::NovaTimerRed = Gdiplus::Color(192, 0, 0); // #C00000 + + // iTEC + const Gdiplus::Color ColourPaletteDefinitions::ItecBackground = Gdiplus::Color(195, 195, 185); // #C3C3B9 + const Gdiplus::Color ColourPaletteDefinitions::ItecBorder = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::ItecHeaders = Gdiplus::Color(214, 216, 150); // #D6D896 + const Gdiplus::Color ColourPaletteDefinitions::ItecHighlightedHeaders = Gdiplus::Color(255, 255, 255); // #ffffff + const Gdiplus::Color ColourPaletteDefinitions::ItecDefaultText = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::ItecHighlightedText = Gdiplus::Color(0, 0, 255); // #0000FF + const Gdiplus::Color ColourPaletteDefinitions::ItecMainAircraftText = Gdiplus::Color(0, 0, 0); // #000000 + const Gdiplus::Color ColourPaletteDefinitions::ItecHighlightedAircraftText = Gdiplus::Color(0, 0, 255); // #0000FF + const Gdiplus::Color ColourPaletteDefinitions::ItecTimerGreen = Gdiplus::Color(0, 0, 255); // #0000FF + const Gdiplus::Color ColourPaletteDefinitions::ItecTimerYellow = Gdiplus::Color(130, 111, 0); // #826F00 + const Gdiplus::Color ColourPaletteDefinitions::ItecTimerRed = Gdiplus::Color(192, 0, 0); // #C00000 + } // namespace Graphics +} // namespace UKControllerPlugin \ No newline at end of file diff --git a/src/plugin/graphics/ColourPaletteDefinitions.h b/src/plugin/graphics/ColourPaletteDefinitions.h new file mode 100644 index 000000000..9e8a59314 --- /dev/null +++ b/src/plugin/graphics/ColourPaletteDefinitions.h @@ -0,0 +1,64 @@ +#pragma once +#include "GdiGraphicsInterface.h" + +namespace UKControllerPlugin { + namespace Graphics { + /* + GDIPlus Definitions for the various colour palettes. + */ + struct ColourPaletteDefinitions + { + // NODE + static const Gdiplus::Color NodeBackground; // #000000 + static const Gdiplus::Color NodeBorder; // #ffffff + static const Gdiplus::Color NodeHeaders; // #a06f70 + static const Gdiplus::Color NodeHighlightedHeaders; // #ff6432 + static const Gdiplus::Color NodeDefaultText; // #ffffff + static const Gdiplus::Color NodeHighlightedText; // #e8a300 + static const Gdiplus::Color NodeMainAircraftText; // #68dd45 + static const Gdiplus::Color NodeHighlightedAircraftText; // #e8a300 + static const Gdiplus::Color NodeTimerGreen; // #68dd45 + static const Gdiplus::Color NodeTimerYellow; // #e8a300 + static const Gdiplus::Color NodeTimerRed; // #ff6432 + + // NERC + static const Gdiplus::Color NercBackground; // #969696 + static const Gdiplus::Color NercBorder; // #535353 + static const Gdiplus::Color NercHeaders; // #878787 + static const Gdiplus::Color NercHighlightedHeaders; // #ffffff + static const Gdiplus::Color NercDefaultText; // #000000 + static const Gdiplus::Color NercHighlightedText; // #ffffff + static const Gdiplus::Color NercMainAircraftText; // #000000 + static const Gdiplus::Color NercHighlightedAircraftText; // #ffffff + static const Gdiplus::Color NercTimerGreen; // #B4FF7D + static const Gdiplus::Color NercTimerYellow; // #FFD800 + static const Gdiplus::Color NercTimerRed; // #C00000 + + // NOVA + static const Gdiplus::Color NovaBackground; // #B4B4B4 + static const Gdiplus::Color NovaBorder; // #535353 + static const Gdiplus::Color NovaHeaders; // #008CC8 + static const Gdiplus::Color NovaHighlightedHeaders; // #ffffff + static const Gdiplus::Color NovaDefaultText; // #000000 + static const Gdiplus::Color NovaHighlightedText; // #ffffff + static const Gdiplus::Color NovaMainAircraftText; // #000000 + static const Gdiplus::Color NovaHighlightedAircraftText; // #ffffff + static const Gdiplus::Color NovaTimerGreen; // #ffffff + static const Gdiplus::Color NovaTimerYellow; // #FFD800 + static const Gdiplus::Color NovaTimerRed; // #C00000 + + // iTEC + static const Gdiplus::Color ItecBackground; // #C3C3B9 + static const Gdiplus::Color ItecBorder; // #000000 + static const Gdiplus::Color ItecHeaders; // #D6D896 + static const Gdiplus::Color ItecHighlightedHeaders; // #ffffff + static const Gdiplus::Color ItecDefaultText; // #000000 + static const Gdiplus::Color ItecHighlightedText; // #0000FF + static const Gdiplus::Color ItecMainAircraftText; // #000000 + static const Gdiplus::Color ItecHighlightedAircraftText; // #0000FF + static const Gdiplus::Color ItecTimerGreen; // #0000FF + static const Gdiplus::Color ItecTimerYellow; // #826F00 + static const Gdiplus::Color ItecTimerRed; // #C00000 + }; + } // namespace Graphics +} // namespace UKControllerPlugin \ No newline at end of file From 1d9cbf668ecb9da41a7ee99847cb86e78acb51dd Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Mon, 16 Jun 2025 02:36:45 +0100 Subject: [PATCH 04/17] Configure Save/Load Settings --- src/plugin/CMakeLists.txt | 4 +- src/plugin/bootstrap/PostInit.cpp | 3 + .../euroscope/GeneralSettingsDialog.cpp | 2 + .../euroscope/LoadDefaultUserSettings.cpp | 9 + .../graphics/ColourPaletteConfiguration.cpp | 86 --------- .../graphics/ColourPaletteConfiguration.h | 37 ---- .../graphics/ColourPaletteDefinitions.cpp | 12 ++ .../graphics/ColourPaletteDefinitions.h | 14 ++ src/plugin/graphics/GlobalColours.cpp | 176 ++++++++++++++++++ src/plugin/graphics/GlobalColours.h | 34 ++++ 10 files changed, 252 insertions(+), 125 deletions(-) delete mode 100644 src/plugin/graphics/ColourPaletteConfiguration.cpp delete mode 100644 src/plugin/graphics/ColourPaletteConfiguration.h create mode 100644 src/plugin/graphics/GlobalColours.cpp create mode 100644 src/plugin/graphics/GlobalColours.h diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 8ad451612..4c01c94cd 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -302,8 +302,8 @@ source_group("src\\geometry" FILES ${src__geometry}) set(src__graphics "graphics/ColourPaletteDefinitions.cpp" "graphics/ColourPaletteDefinitions.h" - "graphics/ColourPaletteConfiguration.cpp" - "graphics/ColourPaletteConfiguration.h" + "graphics/GlobalColours.cpp" + "graphics/GlobalColours.h" "graphics/GdiGraphicsInterface.h" "graphics/GdiGraphicsWrapper.cpp" "graphics/GdiGraphicsWrapper.h" diff --git a/src/plugin/bootstrap/PostInit.cpp b/src/plugin/bootstrap/PostInit.cpp index 76358bca2..7daa21f03 100644 --- a/src/plugin/bootstrap/PostInit.cpp +++ b/src/plugin/bootstrap/PostInit.cpp @@ -8,9 +8,11 @@ #include "plugin/UKPlugin.h" #include "tag/TagItemCollection.h" #include "update/PluginVersion.h" +#include "graphics/GlobalColours.h" using UKControllerPlugin::Bootstrap::PersistenceContainer; using UKControllerPlugin::Plugin::PluginVersion; +using UKControllerPlugin::Graphics::GlobalColours; namespace UKControllerPlugin::Bootstrap { @@ -26,6 +28,7 @@ namespace UKControllerPlugin::Bootstrap { ukPlugin.PostInit(); UKControllerPlugin::Euroscope::LoadDefaultUserSettings(*container.pluginUserSettingHandler); UKControllerPlugin::Countdown::CountdownModule::LoadDefaultUserSettings(*container.pluginUserSettingHandler); + UKControllerPlugin::Graphics::GlobalColours::LoadDefaultUserSettings(*container.pluginUserSettingHandler); container.userSettingHandlers->UserSettingsUpdateEvent(*container.pluginUserSettingHandler); container.pluginSettingsProviders->Load(); diff --git a/src/plugin/euroscope/GeneralSettingsDialog.cpp b/src/plugin/euroscope/GeneralSettingsDialog.cpp index 8f287af4e..3ce002acb 100644 --- a/src/plugin/euroscope/GeneralSettingsDialog.cpp +++ b/src/plugin/euroscope/GeneralSettingsDialog.cpp @@ -4,12 +4,14 @@ #include "UserSetting.h" #include "dialog/DialogCallArgument.h" #include "setting/SettingRepository.h" +#include "graphics/GlobalColours.h" using UKControllerPlugin::Dialog::DialogCallArgument; using UKControllerPlugin::Euroscope::GeneralSettingsEntries; using UKControllerPlugin::Euroscope::UserSetting; using UKControllerPlugin::Euroscope::UserSettingAwareCollection; + namespace UKControllerPlugin { namespace Euroscope { diff --git a/src/plugin/euroscope/LoadDefaultUserSettings.cpp b/src/plugin/euroscope/LoadDefaultUserSettings.cpp index 76a149cd4..a1409fb87 100644 --- a/src/plugin/euroscope/LoadDefaultUserSettings.cpp +++ b/src/plugin/euroscope/LoadDefaultUserSettings.cpp @@ -54,6 +54,15 @@ namespace UKControllerPlugin { GeneralSettingsEntries::unknownTimeFormatBlankDescription, false); } + + // Colour Palette + if (!userSetting.HasEntry(GeneralSettingsEntries::colourPaletteSettingsKey)) { + LogInfo("Loading default value for setting " + GeneralSettingsEntries::colourPaletteSettingsKey); + userSetting.Save( + GeneralSettingsEntries::colourPaletteSettingsKey, + GeneralSettingsEntries::colourPaletteSettingsDescription, + "default"); + } } } // namespace Euroscope } // namespace UKControllerPlugin diff --git a/src/plugin/graphics/ColourPaletteConfiguration.cpp b/src/plugin/graphics/ColourPaletteConfiguration.cpp deleted file mode 100644 index 3c879e261..000000000 --- a/src/plugin/graphics/ColourPaletteConfiguration.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "ColourPaletteDefinitions.h" -#include "GdiGraphicsInterface.h" -#include "ColourPaletteConfiguration.h" -#include "euroscope/GeneralSettingsEntries.h" -#include "euroscope/UserSetting.h" - -using UKControllerPlugin::Graphics::ColourPaletteDefinitions; -using UKControllerPlugin::Euroscope::GeneralSettingsEntries; -using UKControllerPlugin::Euroscope::UserSetting; - -namespace UKControllerPlugin { - namespace Graphics { - /* - Set the colour palette definitions based on the selected palette name. - */ - ColourPaletteConfiguration SetColourPalette(UserSetting& userSetting) { - ColourPaletteConfiguration palette; - std::string selectedPaletteName = userSetting.GetStringEntry("colour_palette", DEFAULT_COLOUR_PALETTE); - - if (selectedPaletteName == "node") { - palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NodeBackground); - palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NodeBorder); - palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NodeHeaders); - palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedHeaders); - palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NodeDefaultText); - palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedText); - palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeMainAircraftText); - palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedAircraftText); - palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerGreen); - palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerYellow); - palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerRed); - } else if (selectedPaletteName == "nerc") { - palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NercBackground); - palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NercBorder); - palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NercHeaders); - palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NercHighlightedHeaders); - palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NercDefaultText); - palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NercHighlightedText); - palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NercMainAircraftText); - palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NercHighlightedAircraftText); - palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NercTimerGreen); - palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NercTimerYellow); - palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NercTimerRed); - } else if (selectedPaletteName == "nova") { - palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NovaBackground); - palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NovaBorder); - palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NovaHeaders); - palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NovaHighlightedHeaders); - palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NovaDefaultText); - palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NovaHighlightedText); - palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NovaMainAircraftText); - palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NovaHighlightedAircraftText); - palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NovaTimerGreen); - palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NovaTimerYellow); - palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NovaTimerRed); - } else if (selectedPaletteName == "itec") { - palette.Background = Gdiplus::Color(ColourPaletteDefinitions::ItecBackground); - palette.Border = Gdiplus::Color(ColourPaletteDefinitions::ItecBorder); - palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::ItecHeaders); - palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::ItecHighlightedHeaders); - palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::ItecDefaultText); - palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::ItecHighlightedText); - palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::ItecMainAircraftText); - palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::ItecHighlightedAircraftText); - palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::ItecTimerGreen); - palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::ItecTimerYellow); - palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::ItecTimerRed); - } - else { - // Default to the default palette WIP - palette.Background = Gdiplus::Color(ColourPaletteDefinitions::NodeBackground); - palette.Border = Gdiplus::Color(ColourPaletteDefinitions::NodeBorder); - palette.Headers = Gdiplus::Color(ColourPaletteDefinitions::NodeHeaders); - palette.HighlightedHeaders = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedHeaders); - palette.DefaultText = Gdiplus::Color(ColourPaletteDefinitions::NodeDefaultText); - palette.HighlightedText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedText); - palette.MainAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeMainAircraftText); - palette.HighlightedAircraftText = Gdiplus::Color(ColourPaletteDefinitions::NodeHighlightedAircraftText); - palette.TimerGreen = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerGreen); - palette.TimerYellow = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerYellow); - palette.TimerRed = Gdiplus::Color(ColourPaletteDefinitions::NodeTimerRed); - } - return palette; - } - } -} \ No newline at end of file diff --git a/src/plugin/graphics/ColourPaletteConfiguration.h b/src/plugin/graphics/ColourPaletteConfiguration.h deleted file mode 100644 index 79a851dfa..000000000 --- a/src/plugin/graphics/ColourPaletteConfiguration.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "GdiGraphicsInterface.h" -#include "euroscope/UserSetting.h" - -using UKControllerPlugin::Euroscope::UserSetting; - -namespace UKControllerPlugin { - namespace Graphics { - - // Global definitions for the current colour palette. - struct ColourPaletteConfiguration { - Gdiplus::Color Background; - Gdiplus::Color Border; - Gdiplus::Color Headers; - Gdiplus::Color HighlightedHeaders; - Gdiplus::Color DefaultText; - Gdiplus::Color HighlightedText; - Gdiplus::Color MainAircraftText; - Gdiplus::Color HighlightedAircraftText; - Gdiplus::Color TimerGreen; - Gdiplus::Color TimerYellow; - Gdiplus::Color TimerRed; - }; - - const std::map colourPaletteMap{ - {"default", L"Default"}, - {"node", L"NODE"}, - {"nerc", L"NERC"}, - {"nova", L"NOVA"}, - {"itec", L"iTEC"}, - }; - - const std::string DEFAULT_COLOUR_PALETTE = "default"; - - std::string GetSelectedColourPalette(UserSetting& userSetting); - } -} \ No newline at end of file diff --git a/src/plugin/graphics/ColourPaletteDefinitions.cpp b/src/plugin/graphics/ColourPaletteDefinitions.cpp index c275b6215..268734792 100644 --- a/src/plugin/graphics/ColourPaletteDefinitions.cpp +++ b/src/plugin/graphics/ColourPaletteDefinitions.cpp @@ -2,6 +2,18 @@ namespace UKControllerPlugin { namespace Graphics { + // DEFAULT + const Gdiplus::Color ColourPaletteDefinitions::DefaultBackground = Gdiplus::Color(58, 57, 58); // rgb(58, 57, 58) + const Gdiplus::Color ColourPaletteDefinitions::DefaultBorder = Gdiplus::Color(215, 215, 215); // rgb(215, 215, 215) + const Gdiplus::Color ColourPaletteDefinitions::DefaultHeaders = Gdiplus::Color(130, 50, 154); // rgb(130, 50, 154) + const Gdiplus::Color ColourPaletteDefinitions::DefaultHighlightedHeaders = Gdiplus::Color(255, 153, 255); // rgb(255, 153, 255) + const Gdiplus::Color ColourPaletteDefinitions::DefaultText = Gdiplus::Color(227, 227, 227); // rgb(227, 227, 227) + const Gdiplus::Color ColourPaletteDefinitions::DefaultHighlightedText = Gdiplus::Color(255, 255, 0); // rgb(255, 255, 0) + const Gdiplus::Color ColourPaletteDefinitions::DefaultMainAircraftText = Gdiplus::Color(7, 237, 7); // rgb(7, 237, 7) + const Gdiplus::Color ColourPaletteDefinitions::DefaultHighlightedAircraftText = Gdiplus::Color(246, 181, 4); // rgb(246, 181, 4) + const Gdiplus::Color ColourPaletteDefinitions::DefaultTimerGreen = Gdiplus::Color(0, 255, 0); // rgb(0, 255, 0) + const Gdiplus::Color ColourPaletteDefinitions::DefaultTimerYellow = Gdiplus::Color(255, 255, 0); // rgb(255, 255, 0) + const Gdiplus::Color ColourPaletteDefinitions::DefaultTimerRed = Gdiplus::Color(255, 0, 0); // rgb(255, 0, 0) // NODE const Gdiplus::Color ColourPaletteDefinitions::NodeBackground = Gdiplus::Color(0, 0, 0); // #000000 diff --git a/src/plugin/graphics/ColourPaletteDefinitions.h b/src/plugin/graphics/ColourPaletteDefinitions.h index 9e8a59314..2da07d035 100644 --- a/src/plugin/graphics/ColourPaletteDefinitions.h +++ b/src/plugin/graphics/ColourPaletteDefinitions.h @@ -8,6 +8,20 @@ namespace UKControllerPlugin { */ struct ColourPaletteDefinitions { + // DEFAULT + static const Gdiplus::Color DefaultBackground; + static const Gdiplus::Color DefaultBorder; + static const Gdiplus::Color DefaultHeaders; + static const Gdiplus::Color DefaultHighlightedHeaders; + static const Gdiplus::Color DefaultText; + static const Gdiplus::Color DefaultHighlightedText; + static const Gdiplus::Color DefaultMainAircraftText; + static const Gdiplus::Color DefaultHighlightedAircraftText; + static const Gdiplus::Color DefaultTimerGreen; + static const Gdiplus::Color DefaultTimerYellow; + static const Gdiplus::Color DefaultTimerRed; + + // NODE static const Gdiplus::Color NodeBackground; // #000000 static const Gdiplus::Color NodeBorder; // #ffffff diff --git a/src/plugin/graphics/GlobalColours.cpp b/src/plugin/graphics/GlobalColours.cpp new file mode 100644 index 000000000..f53ae6aa8 --- /dev/null +++ b/src/plugin/graphics/GlobalColours.cpp @@ -0,0 +1,176 @@ +#include "GlobalColours.h" +#include "ColourPaletteDefinitions.h" +#include "euroscope/UserSettingAwareCollection.h" +#include "euroscope/UserSetting.h" +#include +#include "euroscope/GeneralSettingsEntries.h" + +using UKControllerPlugin::Euroscope::UserSetting; +using UKControllerPlugin::Euroscope::UserSettingAwareCollection; +using UKControllerPlugin::Euroscope::GeneralSettingsEntries; + +namespace UKControllerPlugin::Graphics { + Gdiplus::Color Background; + Gdiplus::Color Border; + Gdiplus::Color Headers; + Gdiplus::Color HighlightedHeaders; + Gdiplus::Color DefaultText; + Gdiplus::Color HighlightedText; + Gdiplus::Color MainAircraftText; + Gdiplus::Color HighlightedAircraftText; + Gdiplus::Color TimerGreen; + Gdiplus::Color TimerYellow; + Gdiplus::Color TimerRed; + + + std::string ColorToString(const Gdiplus::Color& color) { + std::ostringstream oss; + oss << "ARGB(" + << static_cast(color.GetA()) << "," + << static_cast(color.GetR()) << "," + << static_cast(color.GetG()) << "," + << static_cast(color.GetB()) << ")"; + return oss.str(); + } + + void GlobalColours::LoadDefaultUserSettings(UserSetting& userSetting) + { + LogInfo("Loading default user settings for global colours"); + // Set default colours if not already set + if (!userSetting.HasEntry(GeneralSettingsEntries::colourPaletteSettingsKey)) { + userSetting.Save(GeneralSettingsEntries::colourPaletteSettingsKey, + GeneralSettingsEntries::colourPaletteSettingsDescription, + DEFAULT_COLOUR_PALETTE); + } + GlobalColours::SetGlobalColours(userSetting.GetStringEntry("colourPalette", "default")); + } + + void GlobalColours::SetGlobalColours(const std::string& paletteName) { + LogInfo("Setting global colours to palette: " + paletteName); + + auto logColour = [](const std::string& name, const Gdiplus::Color& color) { + LogInfo(name + " set to " + ColorToString(color)); + }; + + if (paletteName == "default") { + Background = ColourPaletteDefinitions::NodeBackground; + logColour("Background", Background); + Border = ColourPaletteDefinitions::NodeBorder; + logColour("Border", Border); + Headers = ColourPaletteDefinitions::NodeHeaders; + logColour("Headers", Headers); + HighlightedHeaders = ColourPaletteDefinitions::NodeHighlightedHeaders; + logColour("HighlightedHeaders", HighlightedHeaders); + DefaultText = ColourPaletteDefinitions::NodeDefaultText; + logColour("DefaultText", DefaultText); + HighlightedText = ColourPaletteDefinitions::NodeHighlightedText; + logColour("HighlightedText", HighlightedText); + MainAircraftText = ColourPaletteDefinitions::NodeMainAircraftText; + logColour("MainAircraftText", MainAircraftText); + HighlightedAircraftText = ColourPaletteDefinitions::NodeHighlightedAircraftText; + logColour("HighlightedAircraftText", HighlightedAircraftText); + TimerGreen = ColourPaletteDefinitions::NodeTimerGreen; + logColour("TimerGreen", TimerGreen); + TimerYellow = ColourPaletteDefinitions::NodeTimerYellow; + logColour("TimerYellow", TimerYellow); + TimerRed = ColourPaletteDefinitions::NodeTimerRed; + logColour("TimerRed", TimerRed); + } + else if (paletteName == "nerc") { + Background = ColourPaletteDefinitions::NercBackground; + logColour("Background", Background); + Border = ColourPaletteDefinitions::NercBorder; + logColour("Border", Border); + Headers = ColourPaletteDefinitions::NercHeaders; + logColour("Headers", Headers); + HighlightedHeaders = ColourPaletteDefinitions::NercHighlightedHeaders; + logColour("HighlightedHeaders", HighlightedHeaders); + DefaultText = ColourPaletteDefinitions::NercDefaultText; + logColour("DefaultText", DefaultText); + HighlightedText = ColourPaletteDefinitions::NercHighlightedText; + logColour("HighlightedText", HighlightedText); + MainAircraftText = ColourPaletteDefinitions::NercMainAircraftText; + logColour("MainAircraftText", MainAircraftText); + HighlightedAircraftText = ColourPaletteDefinitions::NercHighlightedAircraftText; + logColour("HighlightedAircraftText", HighlightedAircraftText); + TimerGreen = ColourPaletteDefinitions::NercTimerGreen; + logColour("TimerGreen", TimerGreen); + TimerYellow = ColourPaletteDefinitions::NercTimerYellow; + logColour("TimerYellow", TimerYellow); + TimerRed = ColourPaletteDefinitions::NercTimerRed; + logColour("TimerRed", TimerRed); + } + else if (paletteName == "nova") { + Background = ColourPaletteDefinitions::NovaBackground; + logColour("Background", Background); + Border = ColourPaletteDefinitions::NovaBorder; + logColour("Border", Border); + Headers = ColourPaletteDefinitions::NovaHeaders; + logColour("Headers", Headers); + HighlightedHeaders = ColourPaletteDefinitions::NovaHighlightedHeaders; + logColour("HighlightedHeaders", HighlightedHeaders); + DefaultText = ColourPaletteDefinitions::NovaDefaultText; + logColour("DefaultText", DefaultText); + HighlightedText = ColourPaletteDefinitions::NovaHighlightedText; + logColour("HighlightedText", HighlightedText); + MainAircraftText = ColourPaletteDefinitions::NovaMainAircraftText; + logColour("MainAircraftText", MainAircraftText); + HighlightedAircraftText = ColourPaletteDefinitions::NovaHighlightedAircraftText; + logColour("HighlightedAircraftText", HighlightedAircraftText); + TimerGreen = ColourPaletteDefinitions::NovaTimerGreen; + logColour("TimerGreen", TimerGreen); + TimerYellow = ColourPaletteDefinitions::NovaTimerYellow; + logColour("TimerYellow", TimerYellow); + TimerRed = ColourPaletteDefinitions::NovaTimerRed; + logColour("TimerRed", TimerRed); + } + else if (paletteName == "itec") { + Background = ColourPaletteDefinitions::ItecBackground; + logColour("Background", Background); + Border = ColourPaletteDefinitions::ItecBorder; + logColour("Border", Border); + Headers = ColourPaletteDefinitions::ItecHeaders; + logColour("Headers", Headers); + HighlightedHeaders = ColourPaletteDefinitions::ItecHighlightedHeaders; + logColour("HighlightedHeaders", HighlightedHeaders); + DefaultText = ColourPaletteDefinitions::ItecDefaultText; + logColour("DefaultText", DefaultText); + HighlightedText = ColourPaletteDefinitions::ItecHighlightedText; + logColour("HighlightedText", HighlightedText); + MainAircraftText = ColourPaletteDefinitions::ItecMainAircraftText; + logColour("MainAircraftText", MainAircraftText); + HighlightedAircraftText = ColourPaletteDefinitions::ItecHighlightedAircraftText; + logColour("HighlightedAircraftText", HighlightedAircraftText); + TimerGreen = ColourPaletteDefinitions::ItecTimerGreen; + logColour("TimerGreen", TimerGreen); + TimerYellow = ColourPaletteDefinitions::ItecTimerYellow; + logColour("TimerYellow", TimerYellow); + TimerRed = ColourPaletteDefinitions::ItecTimerRed; + logColour("TimerRed", TimerRed); + } + else { + Background = ColourPaletteDefinitions::DefaultBackground; + logColour("Background", Background); + Border = ColourPaletteDefinitions::DefaultBorder; + logColour("Border", Border); + Headers = ColourPaletteDefinitions::DefaultHeaders; + logColour("Headers", Headers); + HighlightedHeaders = ColourPaletteDefinitions::DefaultHighlightedHeaders; + logColour("HighlightedHeaders", HighlightedHeaders); + DefaultText = ColourPaletteDefinitions::DefaultText; + logColour("DefaultText", DefaultText); + HighlightedText = ColourPaletteDefinitions::DefaultHighlightedText; + logColour("HighlightedText", HighlightedText); + MainAircraftText = ColourPaletteDefinitions::DefaultMainAircraftText; + logColour("MainAircraftText", MainAircraftText); + HighlightedAircraftText = ColourPaletteDefinitions::DefaultHighlightedAircraftText; + logColour("HighlightedAircraftText", HighlightedAircraftText); + TimerGreen = ColourPaletteDefinitions::DefaultTimerGreen; + logColour("TimerGreen", TimerGreen); + TimerYellow = ColourPaletteDefinitions::DefaultTimerYellow; + logColour("TimerYellow", TimerYellow); + TimerRed = ColourPaletteDefinitions::DefaultTimerRed; + logColour("TimerRed", TimerRed); + } + } +} \ No newline at end of file diff --git a/src/plugin/graphics/GlobalColours.h b/src/plugin/graphics/GlobalColours.h new file mode 100644 index 000000000..1d9c47b16 --- /dev/null +++ b/src/plugin/graphics/GlobalColours.h @@ -0,0 +1,34 @@ +#pragma once +#include "GdiGraphicsInterface.h" + +namespace UKControllerPlugin { + namespace Euroscope { + class UserSetting; + } // namespace Euroscope +} // namespace UKControllerPlugin + +namespace UKControllerPlugin::Graphics { + + // Default colour palette name + const std::string DEFAULT_COLOUR_PALETTE = "default"; + + // Declare global colour variables + extern Gdiplus::Color Background; + extern Gdiplus::Color Border; + extern Gdiplus::Color Headers; + extern Gdiplus::Color HighlightedHeaders; + extern Gdiplus::Color DefaultText; + extern Gdiplus::Color HighlightedText; + extern Gdiplus::Color MainAircraftText; + extern Gdiplus::Color HighlightedAircraftText; + extern Gdiplus::Color TimerGreen; + extern Gdiplus::Color TimerYellow; + extern Gdiplus::Color TimerRed; + + class GlobalColours + { + public: + static void SetGlobalColours(const std::string& paletteName); + static void LoadDefaultUserSettings(UKControllerPlugin::Euroscope::UserSetting& userSetting); + }; +} \ No newline at end of file From 1115dbeb4261b6f8798d60ccd0fbea55875584de Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:38:13 +0100 Subject: [PATCH 05/17] Added: Component Colour / Dimensions Changes --- .../approach/ApproachSequencerDisplay.h | 5 ++- src/plugin/components/StandardButtons.cpp | 7 ++-- src/plugin/components/TitleBar.cpp | 7 ++-- src/plugin/countdown/CountdownModule.cpp | 4 +- src/plugin/countdown/CountdownModule.h | 1 - src/plugin/countdown/CountdownRenderer.cpp | 39 +++++++++---------- src/plugin/countdown/CountdownRenderer.h | 24 ++++++++++-- .../departure/DepartureCoordinationList.h | 9 +++-- src/plugin/hold/HoldDisplay.cpp | 14 ++++--- src/plugin/minstack/MinStackModule.cpp | 2 - src/plugin/minstack/MinStackModule.h | 4 -- src/plugin/minstack/MinStackRenderer.cpp | 29 +++++++------- src/plugin/minstack/MinStackRenderer.h | 21 ++++++++-- src/plugin/radarscreen/RadarScreenFactory.cpp | 3 -- .../regional/RegionalPressureModule.cpp | 2 - src/plugin/regional/RegionalPressureModule.h | 1 - .../regional/RegionalPressureRenderer.cpp | 29 +++++++------- .../regional/RegionalPressureRenderer.h | 21 ++++++++-- src/plugin/wake/WakeCalculatorDisplay.h | 9 +++-- 19 files changed, 131 insertions(+), 100 deletions(-) diff --git a/src/plugin/approach/ApproachSequencerDisplay.h b/src/plugin/approach/ApproachSequencerDisplay.h index 483906d49..61af7f6e4 100644 --- a/src/plugin/approach/ApproachSequencerDisplay.h +++ b/src/plugin/approach/ApproachSequencerDisplay.h @@ -1,5 +1,6 @@ #pragma once #include "radarscreen/RadarRenderableInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Components { @@ -138,8 +139,8 @@ namespace UKControllerPlugin::Approach { 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); + const Gdiplus::Color BACKGROUND_COLOUR = UKControllerPlugin::Graphics::Background; + const Gdiplus::Color TEXT_COLOUR = UKControllerPlugin::Graphics::DefaultText; std::shared_ptr backgroundBrush; std::shared_ptr textBrush; std::shared_ptr dividingPen; diff --git a/src/plugin/components/StandardButtons.cpp b/src/plugin/components/StandardButtons.cpp index 333c03409..0d0d294b0 100644 --- a/src/plugin/components/StandardButtons.cpp +++ b/src/plugin/components/StandardButtons.cpp @@ -1,5 +1,6 @@ #include "StandardButtons.h" #include "graphics/GdiGraphicsInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin::Components { @@ -13,7 +14,7 @@ namespace UKControllerPlugin::Components { Gdiplus::Point collapsePoints[3] = {Gdiplus::Point(0, -5), Gdiplus::Point(5, 5), Gdiplus::Point(-5, 5)}; // The standard button sizing - Gdiplus::REAL buttonSize(10); + Gdiplus::REAL buttonSize(15); /* * Draws a standard X-shaped close button of the specified colour. @@ -40,7 +41,7 @@ namespace UKControllerPlugin::Components { std::function CloseButton() { - return CloseButton(Gdiplus::Color(227, 227, 227)); + return CloseButton(UKControllerPlugin::Graphics::DefaultText); } /* @@ -74,7 +75,7 @@ namespace UKControllerPlugin::Components { std::function CollapseButton(std::function stateFunction) { - return CollapseButton(Gdiplus::Color(227, 227, 227), stateFunction); + return CollapseButton(UKControllerPlugin::Graphics::DefaultText, stateFunction); } void ScalePen(const std::shared_ptr& pen, Gdiplus::REAL& scaleX, Gdiplus::REAL& scaleY) diff --git a/src/plugin/components/TitleBar.cpp b/src/plugin/components/TitleBar.cpp index e8fc63aa2..b9ed8e180 100644 --- a/src/plugin/components/TitleBar.cpp +++ b/src/plugin/components/TitleBar.cpp @@ -2,6 +2,7 @@ #include "TitleBar.h" #include "euroscope/EuroscopeRadarLoopbackInterface.h" #include "graphics/GdiGraphicsInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin::Components { TitleBar::~TitleBar() = default; @@ -76,16 +77,16 @@ namespace UKControllerPlugin::Components { std::shared_ptr TitleBar::WithDefaultBackgroundBrush() { - return this->WithBackgroundBrush(std::make_shared(Gdiplus::Color(130, 50, 154))); + return this->WithBackgroundBrush(std::make_shared(UKControllerPlugin::Graphics::Headers)); } std::shared_ptr TitleBar::WithDefaultTextBrush() { - return this->WithTextBrush(std::make_shared(Gdiplus::Color(227, 227, 227))); + return this->WithTextBrush(std::make_shared(UKControllerPlugin::Graphics::DefaultText)); } std::shared_ptr TitleBar::WithDefaultBorder() { - return this->WithBorder(std::make_shared(Gdiplus::Color(255, 255, 255))); + return this->WithBorder(std::make_shared(UKControllerPlugin::Graphics::Border)); } } // namespace UKControllerPlugin::Components diff --git a/src/plugin/countdown/CountdownModule.cpp b/src/plugin/countdown/CountdownModule.cpp index 4115980bb..0b63eabdf 100644 --- a/src/plugin/countdown/CountdownModule.cpp +++ b/src/plugin/countdown/CountdownModule.cpp @@ -85,7 +85,6 @@ namespace UKControllerPlugin::Countdown { const std::shared_ptr& configManager, RadarRenderableCollection& radarRender, ConfigurableDisplayCollection& configurableDisplays, - const UKControllerPlugin::Windows::GdiplusBrushes& brushes, AsrEventHandlerCollection& userSettingHandlers) { // Create the renderer and get the ids for screen objects @@ -97,8 +96,7 @@ namespace UKControllerPlugin::Countdown { radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), - configureFunctionId, - brushes)); + configureFunctionId)); // Add to the relevant handlers radarRender.RegisterRenderer(rendererId, renderer, radarRender.beforeTags); diff --git a/src/plugin/countdown/CountdownModule.h b/src/plugin/countdown/CountdownModule.h index 6bf332614..82da92f56 100644 --- a/src/plugin/countdown/CountdownModule.h +++ b/src/plugin/countdown/CountdownModule.h @@ -40,7 +40,6 @@ namespace UKControllerPlugin::Countdown { const std::shared_ptr& configManager, UKControllerPlugin::RadarScreen::RadarRenderableCollection& radarRender, UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection& screenControls, - const UKControllerPlugin::Windows::GdiplusBrushes& brushes, UKControllerPlugin::Euroscope::AsrEventHandlerCollection& userSettingHandler); static void LoadDefaultUserSettings(UKControllerPlugin::Euroscope::UserSetting& userSetting); diff --git a/src/plugin/countdown/CountdownRenderer.cpp b/src/plugin/countdown/CountdownRenderer.cpp index df164079e..71ed41914 100644 --- a/src/plugin/countdown/CountdownRenderer.cpp +++ b/src/plugin/countdown/CountdownRenderer.cpp @@ -18,9 +18,8 @@ namespace UKControllerPlugin::Countdown { int functionsClickspotId, int timeDisplayClickspotId, int closeClickspotId, - int toogleCallbackFunctionId, - const GdiplusBrushes& brushes) - : countdownModule(countdownModule), brushes(brushes), configManager(configManager), + int toogleCallbackFunctionId) + : countdownModule(countdownModule), configManager(configManager), functionsClickspotId(functionsClickspotId), timeDisplayClickspotId(timeDisplayClickspotId), closeClickspotId(closeClickspotId), toggleCallbackFunctionId(toogleCallbackFunctionId) { @@ -164,18 +163,18 @@ namespace UKControllerPlugin::Countdown { { // Colour the text depending on how long is left, if we get 0, that means timer is up. if (secondsRemaining == 0) { - return *this->brushes.whiteBrush; + return *currentText; } if (secondsRemaining > WARNING_SECONDS) { - return *this->brushes.greenBrush; + return *currentGreenTimer; } if (secondsRemaining > CRITICAL_SECONDS) { - return *this->brushes.yellowBrush; + return *currentYellowTimer; } - return *this->brushes.redBrush; + return *currentRedTimer; } /* @@ -240,10 +239,10 @@ namespace UKControllerPlugin::Countdown { continue; } - graphics.FillRect(this->timerButtonAreas[it->timerId], *this->brushes.euroscopeBackgroundBrush); - graphics.DrawRect(this->timerButtonAreas[it->timerId], *this->brushes.blackPen); + graphics.FillRect(this->timerButtonAreas[it->timerId], *currentBackground); + graphics.DrawRect(this->timerButtonAreas[it->timerId], *currentBorder); graphics.DrawString( - std::to_wstring(it->timerDuration), this->timerButtonAreas[it->timerId], *this->brushes.whiteBrush); + std::to_wstring(it->timerDuration), this->timerButtonAreas[it->timerId], *currentText); radarScreen.RegisterScreenObject( this->functionsClickspotId, "timer" + std::to_string(it->timerId) + "Toggle", @@ -260,20 +259,20 @@ namespace UKControllerPlugin::Countdown { this->timeDisplayArea.bottom, this->timeDisplayArea.right, this->timeDisplayArea.bottom + this->rowHeight}; - graphics.FillRect(spaceToFill, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawRect(spaceToFill, *this->brushes.blackPen); + graphics.FillRect(spaceToFill, *currentBackground); + graphics.DrawRect(spaceToFill, *currentBorder); } // The close clickspot - graphics.FillRect(this->closeClickspotDisplayArea, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawRect(this->closeClickspotDisplayArea, *this->brushes.blackPen); - graphics.DrawString(L"X", this->closeClickspotDisplayArea, *this->brushes.whiteBrush); + graphics.FillRect(this->closeClickspotDisplayArea, *currentBackground); + graphics.DrawRect(this->closeClickspotDisplayArea, *currentBorder); + graphics.DrawString(L"X", this->closeClickspotDisplayArea, *currentText); radarScreen.RegisterScreenObject(this->closeClickspotId, "", this->closeClickspotDisplayArea, false); // The reset button. - graphics.FillRect(this->resetDisplayArea, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawRect(this->resetDisplayArea, *this->brushes.blackPen); - graphics.DrawString(L"R", this->resetDisplayArea, *this->brushes.whiteBrush); + graphics.FillRect(this->resetDisplayArea, *currentBackground); + graphics.DrawRect(this->resetDisplayArea, *currentBorder); + graphics.DrawString(L"R", this->resetDisplayArea, *currentText); radarScreen.RegisterScreenObject(this->functionsClickspotId, "R", this->resetDisplayArea, false); } @@ -284,8 +283,8 @@ namespace UKControllerPlugin::Countdown { CountdownRenderer::RenderTimeDisplay(GdiGraphicsInterface& graphics, EuroscopeRadarLoopbackInterface& radarScreen) { // The time display - graphics.FillRect(this->timeDisplayArea, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawRect(this->timeDisplayArea, *this->brushes.blackPen); + graphics.FillRect(this->timeDisplayArea, *currentBackground); + graphics.DrawRect(this->timeDisplayArea, *currentBorder); radarScreen.RegisterScreenObject(this->timeDisplayClickspotId, "", this->timeDisplayArea, true); // Get the seconds remaining from the Countdown class and use that to draw the time to the screen. diff --git a/src/plugin/countdown/CountdownRenderer.h b/src/plugin/countdown/CountdownRenderer.h index 37f640244..f04ded204 100644 --- a/src/plugin/countdown/CountdownRenderer.h +++ b/src/plugin/countdown/CountdownRenderer.h @@ -3,6 +3,7 @@ #include "plugin/PopupMenuItem.h" #include "radarscreen/ConfigurableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Euroscope { @@ -39,8 +40,7 @@ namespace UKControllerPlugin::Countdown { int functionsClickspotId, int timeDisplayClickspotId, int closeClickspotId, - int toogleCallbackFunctionId, - const UKControllerPlugin::Windows::GdiplusBrushes& brushes); + int toogleCallbackFunctionId); void AsrLoadedEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void AsrClosingEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void Configure(int functionId, std::string subject, RECT screenObjectArea) override; @@ -94,8 +94,24 @@ namespace UKControllerPlugin::Countdown { // The countdown module that we're rendering UKControllerPlugin::Countdown::CountdownTimer& countdownModule; - // A set of brushes to use for rendering. - const UKControllerPlugin::Windows::GdiplusBrushes& brushes; + // Colour Brushes + const std::unique_ptr currentBackground = + std::make_unique(UKControllerPlugin::Graphics::Background); + + const std::unique_ptr currentBorder = + std::make_unique(UKControllerPlugin::Graphics::Border); + + const std::unique_ptr currentText = + std::make_unique(UKControllerPlugin::Graphics::DefaultText); + + const std::unique_ptr currentGreenTimer = + std::make_unique(UKControllerPlugin::Graphics::TimerGreen); + + const std::unique_ptr currentYellowTimer = + std::make_unique(UKControllerPlugin::Graphics::TimerYellow); + + const std::unique_ptr currentRedTimer = + std::make_unique(UKControllerPlugin::Graphics::TimerRed); // Handles the timer configurations const UKControllerPlugin::Countdown::TimerConfigurationManager& configManager; diff --git a/src/plugin/departure/DepartureCoordinationList.h b/src/plugin/departure/DepartureCoordinationList.h index 9bcdebf14..93aaebad8 100644 --- a/src/plugin/departure/DepartureCoordinationList.h +++ b/src/plugin/departure/DepartureCoordinationList.h @@ -1,6 +1,7 @@ #pragma once #include "euroscope/AsrEventHandlerInterface.h" #include "radarscreen/RadarRenderableInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Controller { @@ -87,9 +88,9 @@ namespace UKControllerPlugin::Departure { const Gdiplus::Rect destColumnHeader{395, 5, 40, 25}; // Some colours - const Gdiplus::Color OFF_WHITE_COLOUR = Gdiplus::Color(255, 255, 255); - const Gdiplus::Color TITLE_BAR_BASE_COLOUR = Gdiplus::Color(130, 50, 154); - const Gdiplus::Color TITLE_BAR_FLASH_COLOUR = Gdiplus::Color(179, 3, 0); + const Gdiplus::Color OFF_WHITE_COLOUR = UKControllerPlugin::Graphics::DefaultText; + const Gdiplus::Color TITLE_BAR_BASE_COLOUR = UKControllerPlugin::Graphics::Headers; + const Gdiplus::Color TITLE_BAR_FLASH_COLOUR = UKControllerPlugin::Graphics::HighlightedHeaders; // Brushes const Gdiplus::SolidBrush textBrush; @@ -104,7 +105,7 @@ namespace UKControllerPlugin::Departure { bool contentCollapsed; // Height of title bar - const int titleBarHeight = 20; + const int titleBarHeight = 15; // Width of title bar const int titleBarWidth = 435; diff --git a/src/plugin/hold/HoldDisplay.cpp b/src/plugin/hold/HoldDisplay.cpp index 088900a47..011207f8c 100644 --- a/src/plugin/hold/HoldDisplay.cpp +++ b/src/plugin/hold/HoldDisplay.cpp @@ -17,6 +17,7 @@ #include "geometry/Measurement.h" #include "geometry/MeasurementUnit.h" #include "graphics/GdiGraphicsInterface.h" +#include "graphics/GlobalColours.h" #include "list/PopupListInterface.h" #include "navaids/Navaid.h" @@ -28,6 +29,7 @@ using UKControllerPlugin::Euroscope::EuroscopeRadarLoopbackInterface; using UKControllerPlugin::Euroscope::UserSetting; using UKControllerPlugin::Hold::HoldManager; using UKControllerPlugin::Windows::GdiGraphicsInterface; +using UKControllerPlugin::Graphics::GlobalColours; namespace UKControllerPlugin { namespace Hold { @@ -41,12 +43,12 @@ namespace UKControllerPlugin { : navaid(navaid), publishedHolds(publishedHoldCollection.GetForFix(navaid.identifier)), holdManager(holdManager), plugin(plugin), dialogManager(dialogManager), publishedHoldCollection(publishedHoldCollection), addAircraftSelector(addAircraftSelector), - titleBarTextBrush(Gdiplus::Color(227, 227, 227)), titleBarBrush(Gdiplus::Color(130, 50, 154)), - dataBrush(Gdiplus::Color(7, 237, 7)), clearedLevelBrush(Gdiplus::Color(246, 181, 4)), - blockedLevelBrush(Gdiplus::Color(123, 125, 123)), borderPen(Gdiplus::Color(215, 215, 215), 1.5f), - sameLevelBoxPen(Gdiplus::Color(7, 237, 7), 1.5f), verticalSpeedAscentPen(Gdiplus::Color(7, 237, 7), 2.5f), - verticalSpeedDescentPen(Gdiplus::Color(7, 237, 7), 2.5f), exitButtonBrush(Gdiplus::Color(0, 0, 0)), - backgroundBrush(Gdiplus::Color(58, 57, 58)), fontFamily(L"EuroScope"), + titleBarTextBrush(UKControllerPlugin::Graphics::DefaultText), titleBarBrush(UKControllerPlugin::Graphics::Headers), + dataBrush(Gdiplus::Color(7, 237, 7)), clearedLevelBrush(UKControllerPlugin::Graphics::HighlightedText), + blockedLevelBrush(Gdiplus::Color(123, 125, 123)), borderPen(UKControllerPlugin::Graphics::Border, 1.5f), + sameLevelBoxPen(Gdiplus::Color(7, 237, 7), 1.5f), verticalSpeedAscentPen(UKControllerPlugin::Graphics::DefaultText, 2.5f), + verticalSpeedDescentPen(UKControllerPlugin::Graphics::DefaultText, 2.5f), exitButtonBrush(Gdiplus::Color(0, 0, 0)), + backgroundBrush(UKControllerPlugin::Graphics::Background), fontFamily(L"EuroScope"), font(&fontFamily, 12, Gdiplus::FontStyleBold, Gdiplus::UnitPixel), plusFont(&fontFamily, 18, Gdiplus::FontStyleRegular, Gdiplus::UnitPixel), stringFormat(Gdiplus::StringFormatFlags::StringFormatFlagsNoClip), dataStartHeight(0), diff --git a/src/plugin/minstack/MinStackModule.cpp b/src/plugin/minstack/MinStackModule.cpp index 490190a8e..69bf38276 100644 --- a/src/plugin/minstack/MinStackModule.cpp +++ b/src/plugin/minstack/MinStackModule.cpp @@ -70,7 +70,6 @@ namespace UKControllerPlugin::MinStack { MinStackManager& minStackManager, RadarRenderableCollection& radarRender, ConfigurableDisplayCollection& configurableDisplays, - const GdiplusBrushes& brushes, AsrEventHandlerCollection& userSettingHandlers, const DialogManager& dialogManager) { @@ -83,7 +82,6 @@ namespace UKControllerPlugin::MinStack { radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), configureFunctionId, - brushes, dialogManager)); // Add to the handlers. diff --git a/src/plugin/minstack/MinStackModule.h b/src/plugin/minstack/MinStackModule.h index 4974204e4..156b4535e 100644 --- a/src/plugin/minstack/MinStackModule.h +++ b/src/plugin/minstack/MinStackModule.h @@ -20,9 +20,6 @@ namespace UKControllerPlugin { namespace MinStack { class MinStackManager; } // namespace MinStack - namespace Windows { - struct GdiplusBrushes; - } // namespace Windows namespace Curl { class CurlInterface; } // namespace Curl @@ -52,7 +49,6 @@ namespace UKControllerPlugin { UKControllerPlugin::MinStack::MinStackManager& minStackManager, UKControllerPlugin::RadarScreen::RadarRenderableCollection& radarRender, UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection& configurableDisplays, - const UKControllerPlugin::Windows::GdiplusBrushes& brushes, UKControllerPlugin::Euroscope::AsrEventHandlerCollection& userSettingHandlers, const UKControllerPlugin::Dialog::DialogManager& dialogManager); }; diff --git a/src/plugin/minstack/MinStackRenderer.cpp b/src/plugin/minstack/MinStackRenderer.cpp index 5ee93898e..ef717fa6c 100644 --- a/src/plugin/minstack/MinStackRenderer.cpp +++ b/src/plugin/minstack/MinStackRenderer.cpp @@ -25,9 +25,8 @@ namespace UKControllerPlugin::MinStack { int menuBarClickspotId, int mslClickspotId, int toggleCallbackFunctionId, - const GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager) - : brushes(brushes), minStackModule(minStackModule), dialogManager(dialogManager), + : minStackModule(minStackModule), dialogManager(dialogManager), hideClickspotId(closeClickspotId), menuBarClickspotId(menuBarClickspotId), mslClickspotId(mslClickspotId), toggleCallbackFunctionId(toggleCallbackFunctionId) { @@ -212,17 +211,17 @@ namespace UKControllerPlugin::MinStack { const MinStackLevel& mslData = this->minStackModule.GetMinStackLevel(minStack.key); // Draw the TMA title and rectangles - graphics.FillRect(tma, *this->brushes.greyBrush); - graphics.DrawRect(tma, *this->brushes.blackPen); + graphics.FillRect(tma, *currentBackground); + graphics.DrawRect(tma, *currentBorder); graphics.DrawString( HelperFunctions::ConvertToWideString(MinStackManager::GetNameFromKey(minStack.key)), tma, - mslData.IsAcknowledged() ? *this->brushes.whiteBrush : *this->brushes.yellowBrush); + mslData.IsAcknowledged() ? *currentAcknowledge : *currentText); // Draw the MSL itself and associated rectangles - graphics.FillRect(msl, *this->brushes.greyBrush); - graphics.DrawRect(msl, *this->brushes.blackPen); + graphics.FillRect(msl, *currentBackground); + graphics.DrawRect(msl, *currentBorder); std::string mslString = mslData == this->minStackModule.InvalidMsl() ? "-" : std::to_string(mslData.msl).substr(0, 2); @@ -230,7 +229,7 @@ namespace UKControllerPlugin::MinStack { graphics.DrawString( HelperFunctions::ConvertToWideString(mslString), msl, - mslData.IsAcknowledged() ? *this->brushes.whiteBrush : *this->brushes.yellowBrush); + mslData.IsAcknowledged() ? *currentAcknowledge : *currentText); // Add the clickable area. radarScreen.RegisterScreenObject( @@ -259,7 +258,7 @@ namespace UKControllerPlugin::MinStack { this->topBarArea.top, this->leftColumnWidth + this->hideClickspotWidth, 1 + ((numMinStacks) * this->rowHeight)}; - graphics.DrawRect(area, *this->brushes.blackPen); + graphics.DrawRect(area, *currentBorder); } /* @@ -268,15 +267,15 @@ namespace UKControllerPlugin::MinStack { void MinStackRenderer::RenderTopBar(GdiGraphicsInterface& graphics, EuroscopeRadarLoopbackInterface& radarScreen) { // The title bar - the draggable bit - graphics.DrawRect(this->topBarRender, *this->brushes.blackPen); - graphics.FillRect(this->topBarRender, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawString(L"MSL", this->topBarRender, *this->brushes.whiteBrush); + graphics.DrawRect(this->topBarRender, *currentBorder); + graphics.FillRect(this->topBarRender, *currentHeaders); + graphics.DrawString(L"MSL", this->topBarRender, *currentText); radarScreen.RegisterScreenObject(this->menuBarClickspotId, "", this->topBarArea, true); // The toggle button - no draggable - graphics.DrawRect(this->hideSpotRender, *this->brushes.blackPen); - graphics.FillRect(this->hideSpotRender, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawString(L"X", this->hideSpotRender, *this->brushes.whiteBrush); + graphics.DrawRect(this->hideSpotRender, *currentBorder); + graphics.FillRect(this->hideSpotRender, *currentHeaders); + graphics.DrawString(L"X", this->hideSpotRender, *currentText); radarScreen.RegisterScreenObject(this->hideClickspotId, "", this->hideClickspotArea, false); } diff --git a/src/plugin/minstack/MinStackRenderer.h b/src/plugin/minstack/MinStackRenderer.h index 55fe06779..3361d059f 100644 --- a/src/plugin/minstack/MinStackRenderer.h +++ b/src/plugin/minstack/MinStackRenderer.h @@ -5,6 +5,7 @@ #include "plugin/PopupMenuItem.h" #include "radarscreen/ConfigurableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Euroscope { @@ -37,7 +38,6 @@ namespace UKControllerPlugin::MinStack { int menuBarClickspotId, int mslClickspotId, int toggleCallbackFunctionId, - const UKControllerPlugin::Windows::GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager); void AsrLoadedEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void AsrClosingEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; @@ -108,8 +108,21 @@ namespace UKControllerPlugin::MinStack { // The rectangle to render for the hide clickspot Gdiplus::Rect hideSpotRender; - // Brushes - const UKControllerPlugin::Windows::GdiplusBrushes& brushes; + // Colour Brushes + const std::unique_ptr currentBackground = + std::make_unique(UKControllerPlugin::Graphics::Background); + + const std::unique_ptr currentHeaders = + std::make_unique(UKControllerPlugin::Graphics::Headers); + + const std::unique_ptr currentBorder = + std::make_unique(UKControllerPlugin::Graphics::Border); + + const std::unique_ptr currentText = + std::make_unique(UKControllerPlugin::Graphics::DefaultText); + + const std::unique_ptr currentAcknowledge = + std::make_unique(UKControllerPlugin::Graphics::HighlightedAircraftText); // The configuration for the renderer UKControllerPlugin::MinStack::MinStackRendererConfiguration config; @@ -133,7 +146,7 @@ namespace UKControllerPlugin::MinStack { const int leftColumnWidth = 75; // Width of the right column - const int rowHeight = 20; + const int rowHeight = 15; // Width of the hide clickspot const int hideClickspotWidth = 25; diff --git a/src/plugin/radarscreen/RadarScreenFactory.cpp b/src/plugin/radarscreen/RadarScreenFactory.cpp index 743f675c4..1e06f1b00 100644 --- a/src/plugin/radarscreen/RadarScreenFactory.cpp +++ b/src/plugin/radarscreen/RadarScreenFactory.cpp @@ -83,7 +83,6 @@ namespace UKControllerPlugin::RadarScreen { *persistence.minStack, renderers, configurableDisplays, - *persistence.brushes, userSettingHandlers, *persistence.dialogManager); @@ -92,7 +91,6 @@ namespace UKControllerPlugin::RadarScreen { *persistence.regionalPressureManager, renderers, configurableDisplays, - *persistence.brushes, userSettingHandlers, *persistence.dialogManager); @@ -102,7 +100,6 @@ namespace UKControllerPlugin::RadarScreen { persistence.timerConfigurationManager, renderers, configurableDisplays, - *persistence.brushes, userSettingHandlers); Hold::BootstrapRadarScreen( diff --git a/src/plugin/regional/RegionalPressureModule.cpp b/src/plugin/regional/RegionalPressureModule.cpp index 34383a8cf..b5c56e433 100644 --- a/src/plugin/regional/RegionalPressureModule.cpp +++ b/src/plugin/regional/RegionalPressureModule.cpp @@ -73,7 +73,6 @@ namespace UKControllerPlugin { RegionalPressureManager& regionalPressureManager, RadarRenderableCollection& radarRender, ConfigurableDisplayCollection& configurableDisplays, - const GdiplusBrushes& brushes, AsrEventHandlerCollection& userSettingHandlers, const DialogManager& dialogManager) { @@ -86,7 +85,6 @@ namespace UKControllerPlugin { radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), configureFunctionId, - brushes, dialogManager)); // Add to the handlers. diff --git a/src/plugin/regional/RegionalPressureModule.h b/src/plugin/regional/RegionalPressureModule.h index 8918cd1c4..06b401bf4 100644 --- a/src/plugin/regional/RegionalPressureModule.h +++ b/src/plugin/regional/RegionalPressureModule.h @@ -54,7 +54,6 @@ namespace UKControllerPlugin { UKControllerPlugin::Regional::RegionalPressureManager& regionalPressureManager, UKControllerPlugin::RadarScreen::RadarRenderableCollection& radarRender, UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection& configurableDisplays, - const UKControllerPlugin::Windows::GdiplusBrushes& brushes, UKControllerPlugin::Euroscope::AsrEventHandlerCollection& userSettingHandlers, const UKControllerPlugin::Dialog::DialogManager& dialogManager); }; diff --git a/src/plugin/regional/RegionalPressureRenderer.cpp b/src/plugin/regional/RegionalPressureRenderer.cpp index dab9beb5f..0082f1a34 100644 --- a/src/plugin/regional/RegionalPressureRenderer.cpp +++ b/src/plugin/regional/RegionalPressureRenderer.cpp @@ -22,9 +22,8 @@ namespace UKControllerPlugin::Regional { int menuBarClickspotId, int rpsClickspotId, int toggleCallbackFunctionId, - const GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager) - : brushes(brushes), manager(manager), dialogManager(dialogManager), hideClickspotId(closeClickspotId), + : manager(manager), dialogManager(dialogManager), hideClickspotId(closeClickspotId), menuBarClickspotId(menuBarClickspotId), rpsClickspotId(rpsClickspotId), toggleCallbackFunctionId(toggleCallbackFunctionId) { @@ -211,17 +210,17 @@ namespace UKControllerPlugin::Regional { const RegionalPressure& pressureData = this->manager.GetRegionalPressure(it->key); // Draw the TMA title and rectangles - graphics.FillRect(asr, *this->brushes.greyBrush); - graphics.DrawRect(asr, *this->brushes.blackPen); + graphics.FillRect(asr, *currentBackground); + graphics.DrawRect(asr, *currentBorder); graphics.DrawString( HelperFunctions::ConvertToWideString(this->manager.GetNameFromKey(it->key)), asr, - pressureData.IsAcknowledged() ? *this->brushes.whiteBrush : *this->brushes.yellowBrush); + pressureData.IsAcknowledged() ? *currentAcknowledge : *currentText); // Draw the RPS itself and associated rectangles - graphics.FillRect(rps, *this->brushes.greyBrush); - graphics.DrawRect(rps, *this->brushes.blackPen); + graphics.FillRect(rps, *currentBackground); + graphics.DrawRect(rps, *currentBorder); std::string rpsString; if (pressureData == this->manager.invalidPressure) { @@ -235,7 +234,7 @@ namespace UKControllerPlugin::Regional { graphics.DrawString( HelperFunctions::ConvertToWideString(rpsString), rps, - pressureData.IsAcknowledged() ? *this->brushes.whiteBrush : *this->brushes.yellowBrush); + pressureData.IsAcknowledged() ? *currentAcknowledge : *currentText); // Add the clickable area. radarScreen.RegisterScreenObject( @@ -261,7 +260,7 @@ namespace UKControllerPlugin::Regional { this->topBarArea.top, LEFT_COLUMN_WIDTH + HIDE_CLICKSPOT_WIDTH, 1 + ((numRegionalPressures)*ROW_HEIGHT)}; - graphics.DrawRect(area, *this->brushes.blackPen); + graphics.DrawRect(area, *currentBorder); } /* @@ -271,15 +270,15 @@ namespace UKControllerPlugin::Regional { RegionalPressureRenderer::RenderTopBar(GdiGraphicsInterface& graphics, EuroscopeRadarLoopbackInterface& radarScreen) { // The title bar - the draggable bit - graphics.DrawRect(this->topBarRender, *this->brushes.blackPen); - graphics.FillRect(this->topBarRender, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawString(L"ASR", this->topBarRender, *this->brushes.whiteBrush); + graphics.DrawRect(this->topBarRender, *currentBorder); + graphics.FillRect(this->topBarRender, *currentHeaders); + graphics.DrawString(L"ASR", this->topBarRender, *currentText); radarScreen.RegisterScreenObject(this->menuBarClickspotId, "", this->topBarArea, true); // The toggle button - no draggable - graphics.DrawRect(this->hideSpotRender, *this->brushes.blackPen); - graphics.FillRect(this->hideSpotRender, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawString(L"X", this->hideSpotRender, *this->brushes.whiteBrush); + graphics.DrawRect(this->hideSpotRender, *currentBorder); + graphics.FillRect(this->hideSpotRender, *currentHeaders); + graphics.DrawString(L"X", this->hideSpotRender, *currentText); radarScreen.RegisterScreenObject(this->hideClickspotId, "", this->hideClickspotArea, false); } diff --git a/src/plugin/regional/RegionalPressureRenderer.h b/src/plugin/regional/RegionalPressureRenderer.h index f80510b27..bbb774f5e 100644 --- a/src/plugin/regional/RegionalPressureRenderer.h +++ b/src/plugin/regional/RegionalPressureRenderer.h @@ -5,6 +5,7 @@ #include "plugin/PopupMenuItem.h" #include "radarscreen/ConfigurableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Euroscope { @@ -35,7 +36,6 @@ namespace UKControllerPlugin::Regional { int menuBarClickspotId, int rpsClickspotId, int toggleCallbackFunctionId, - const UKControllerPlugin::Windows::GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager); void AsrLoadedEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void AsrClosingEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; @@ -88,8 +88,21 @@ namespace UKControllerPlugin::Regional { // The rectangle to render for the hide clickspot Gdiplus::Rect hideSpotRender; - // Brushes - const UKControllerPlugin::Windows::GdiplusBrushes& brushes; + // Colour Brushes + const std::unique_ptr currentBackground = + std::make_unique(UKControllerPlugin::Graphics::Background); + + const std::unique_ptr currentHeaders = + std::make_unique(UKControllerPlugin::Graphics::Headers); + + const std::unique_ptr currentBorder = + std::make_unique(UKControllerPlugin::Graphics::Border); + + const std::unique_ptr currentText = + std::make_unique(UKControllerPlugin::Graphics::DefaultText); + + const std::unique_ptr currentAcknowledge = + std::make_unique(UKControllerPlugin::Graphics::HighlightedAircraftText); // The configuration for the renderer UKControllerPlugin::Regional::RegionalPressureRendererConfiguration config; @@ -141,7 +154,7 @@ namespace UKControllerPlugin::Regional { inline static const int DEFAULT_POSITION = 100; inline static const int LEFT_COLUMN_WIDTH = 100; - inline static const int ROW_HEIGHT = 20; + inline static const int ROW_HEIGHT = 15; inline static const int HIDE_CLICKSPOT_WIDTH = 50; inline static const int APPEND_ZERO_LIMIT = 1000; }; diff --git a/src/plugin/wake/WakeCalculatorDisplay.h b/src/plugin/wake/WakeCalculatorDisplay.h index 210df9e24..9f5b426ca 100644 --- a/src/plugin/wake/WakeCalculatorDisplay.h +++ b/src/plugin/wake/WakeCalculatorDisplay.h @@ -2,6 +2,7 @@ #include "euroscope/AsrEventHandlerInterface.h" #include "radarscreen/MenuToggleableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" +#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Components { @@ -75,7 +76,7 @@ namespace UKControllerPlugin::Wake { POINT windowPosition = DEFAULT_WINDOW_POSITION; inline static const int WINDOW_WIDTH = 350; - inline static const int TITLE_BAR_HEIGHT = 20; + inline static const int TITLE_BAR_HEIGHT = 15; inline static const int CONTENT_HEIGHT = 150; inline static const int TEXT_INSET = 5; @@ -96,9 +97,9 @@ namespace UKControllerPlugin::Wake { std::shared_ptr titleBar; // Pens and brushes - const Gdiplus::Color BACKGROUND_COLOUR = Gdiplus::Color(64, 64, 64); - const Gdiplus::Color TEXT_COLOUR = Gdiplus::Color(225, 225, 225); - const Gdiplus::Color RESULT_COLOUR = Gdiplus::Color(55, 249, 1); + const Gdiplus::Color BACKGROUND_COLOUR = UKControllerPlugin::Graphics::Background; + const Gdiplus::Color TEXT_COLOUR = UKControllerPlugin::Graphics::DefaultText; + const Gdiplus::Color RESULT_COLOUR = UKControllerPlugin::Graphics::HighlightedText; std::shared_ptr backgroundBrush; std::shared_ptr textBrush; std::shared_ptr resultBrush; From 4af6c911bcdbe714b6be494f6f9295231e376ed9 Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:41:05 +0100 Subject: [PATCH 06/17] Fix: Approach Seq. Title Bar Height --- src/plugin/approach/ApproachSequencerDisplay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin/approach/ApproachSequencerDisplay.h b/src/plugin/approach/ApproachSequencerDisplay.h index 61af7f6e4..a3d7bf6db 100644 --- a/src/plugin/approach/ApproachSequencerDisplay.h +++ b/src/plugin/approach/ApproachSequencerDisplay.h @@ -68,7 +68,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 From 42cf69a3ffa1fac74d26772277ba435d69425e6d Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Mon, 30 Jun 2025 11:37:24 +0100 Subject: [PATCH 07/17] Implement Persistent Colours --- src/plugin/CMakeLists.txt | 4 +- .../approach/ApproachBootstrapProvider.cpp | 4 + .../approach/ApproachBootstrapProvider.h | 6 + .../approach/ApproachSequencerDisplay.cpp | 66 +++---- .../approach/ApproachSequencerDisplay.h | 13 +- src/plugin/bootstrap/InitialisePlugin.cpp | 7 +- src/plugin/bootstrap/PostInit.cpp | 3 - .../components/CollapsibleWindowTitleBar.cpp | 8 + .../components/CollapsibleWindowTitleBar.h | 1 + src/plugin/components/StandardButtons.cpp | 5 +- src/plugin/components/TitleBar.cpp | 21 ++- src/plugin/components/TitleBar.h | 7 + src/plugin/countdown/CountdownModule.cpp | 4 +- src/plugin/countdown/CountdownModule.h | 1 + src/plugin/countdown/CountdownRenderer.cpp | 43 +++-- src/plugin/countdown/CountdownRenderer.h | 24 +-- .../departure/DepartureCoordinationList.cpp | 45 ++--- .../departure/DepartureCoordinationList.h | 17 +- src/plugin/departure/DepartureModule.cpp | 1 + .../GeneralSettingsConfigurationBootstrap.cpp | 8 +- .../GeneralSettingsConfigurationBootstrap.h | 5 +- .../euroscope/GeneralSettingsDialog.cpp | 14 +- src/plugin/euroscope/GeneralSettingsDialog.h | 8 +- .../graphics/ColourPaletteDefinitions.cpp | 1 + src/plugin/graphics/GdiplusBrushes.h | 40 ++-- src/plugin/graphics/GlobalColours.cpp | 176 ------------------ src/plugin/graphics/GlobalColours.h | 34 ---- src/plugin/graphics/ThemingModule.cpp | 94 ++++++++++ src/plugin/graphics/ThemingModule.h | 24 +++ src/plugin/hold/HoldDisplay.cpp | 105 +++++------ src/plugin/hold/HoldDisplay.h | 22 ++- src/plugin/hold/HoldDisplayFactory.cpp | 8 +- src/plugin/hold/HoldDisplayFactory.h | 12 +- src/plugin/hold/HoldModule.cpp | 6 +- src/plugin/hold/HoldModule.h | 4 + src/plugin/minstack/MinStackModule.cpp | 2 + src/plugin/minstack/MinStackModule.h | 4 + src/plugin/minstack/MinStackRenderer.cpp | 29 +-- src/plugin/minstack/MinStackRenderer.h | 19 +- src/plugin/radarscreen/RadarScreenFactory.cpp | 9 +- src/plugin/radarscreen/ScreenControls.cpp | 4 +- .../regional/RegionalPressureModule.cpp | 2 + src/plugin/regional/RegionalPressureModule.h | 1 + .../regional/RegionalPressureRenderer.cpp | 29 +-- .../regional/RegionalPressureRenderer.h | 19 +- src/plugin/wake/WakeCalculatorDisplay.h | 14 +- src/plugin/wake/WakeModule.cpp | 6 +- src/plugin/wake/WakeModule.h | 6 +- 48 files changed, 483 insertions(+), 502 deletions(-) delete mode 100644 src/plugin/graphics/GlobalColours.cpp delete mode 100644 src/plugin/graphics/GlobalColours.h create mode 100644 src/plugin/graphics/ThemingModule.cpp create mode 100644 src/plugin/graphics/ThemingModule.h diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 4c01c94cd..65271a930 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -302,8 +302,8 @@ source_group("src\\geometry" FILES ${src__geometry}) set(src__graphics "graphics/ColourPaletteDefinitions.cpp" "graphics/ColourPaletteDefinitions.h" - "graphics/GlobalColours.cpp" - "graphics/GlobalColours.h" + "graphics/ThemingModule.cpp" + "graphics/ThemingModule.h" "graphics/GdiGraphicsInterface.h" "graphics/GdiGraphicsWrapper.cpp" "graphics/GdiGraphicsWrapper.h" diff --git a/src/plugin/approach/ApproachBootstrapProvider.cpp b/src/plugin/approach/ApproachBootstrapProvider.cpp index ac4bdadbc..8899ed76c 100644 --- a/src/plugin/approach/ApproachBootstrapProvider.cpp +++ b/src/plugin/approach/ApproachBootstrapProvider.cpp @@ -26,6 +26,9 @@ #include "radarscreen/RadarRenderableCollection.h" #include "tag/TagItemCollection.h" #include "timedevent/TimedEventCollection.h" +#include "graphics/GdiplusBrushes.h" + +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin::Approach { @@ -92,6 +95,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..f5e0d60b6 100644 --- a/src/plugin/approach/ApproachBootstrapProvider.h +++ b/src/plugin/approach/ApproachBootstrapProvider.h @@ -1,6 +1,12 @@ #pragma once #include "bootstrap/BootstrapProviderInterface.h" +namespace UKControllerPlugin { + namespace Windows { + struct GdiplusBrushes; + } // namespace 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..aaa649aef 100644 --- a/src/plugin/approach/ApproachSequencerDisplay.cpp +++ b/src/plugin/approach/ApproachSequencerDisplay.cpp @@ -17,10 +17,12 @@ #include "helper/HelperFunctions.h" #include "list/PopupListInterface.h" #include "number/NumberFormat.h" +#include "graphics/GdiplusBrushes.h" using UKControllerPlugin::Components::CollapsibleWindowTitleBar; using UKControllerPlugin::Number::To1Dp; using UKControllerPlugin::Number::To1DpWide; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin::Approach { @@ -35,13 +37,14 @@ 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( + brushes(brushes), screenObjectId(screenObjectId), titleBar(CollapsibleWindowTitleBar::Create( L"Approach Sequencer", titleBarArea, [this]() -> bool { return this->displayOptions->ContentCollapsed(); }, @@ -53,10 +56,7 @@ namespace UKControllerPlugin::Approach { 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)) + this->airfieldSeparationTextArea, screenObjectId, AIRFIELD_SEPARATION_CLICKSPOT, false)) { } @@ -76,12 +76,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 +173,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( L"Airfield:", airfieldStaticArea, - *textBrush, + Gdiplus::SolidBrush(this->brushes.text), Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); @@ -181,7 +181,7 @@ namespace UKControllerPlugin::Approach { HelperFunctions::ConvertToWideString( displayOptions->Airfield().empty() ? "--" : displayOptions->Airfield()), airfieldTextArea, - *textBrush, + Gdiplus::SolidBrush(this->brushes.text), Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); this->airfieldClickspot->Apply(graphics, radarScreen); @@ -189,23 +189,23 @@ namespace UKControllerPlugin::Approach { void ApproachSequencerDisplay::RenderDivider(Windows::GdiGraphicsInterface& graphics) { - graphics.DrawLine(*dividingPen, dividerLeft, dividerRight); + graphics.DrawLine(Gdiplus::Pen(this->brushes.text), 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, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Callsign", callsignHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Target", targetHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Actual", actualHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Actions", actionsHeader, Gdiplus::SolidBrush(this->brushes.text)); } void ApproachSequencerDisplay::RenderAddButton( Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen) { - graphics.DrawRect(addButton, *dividingPen); - graphics.DrawString(L"Add Aircraft", addButton, *textBrush); + graphics.DrawRect(addButton, Gdiplus::Pen(this->brushes.text)); + graphics.DrawString(L"Add Aircraft", addButton, Gdiplus::SolidBrush(this->brushes.text)); addClickspot->Apply(graphics, radarScreen); } @@ -248,15 +248,15 @@ namespace UKControllerPlugin::Approach { int sequenceNumber = 1; while (aircraftToProcess != nullptr) { - graphics.DrawString(std::to_wstring(sequenceNumber), numberRect, *textBrush); + graphics.DrawString(std::to_wstring(sequenceNumber), numberRect, Gdiplus::SolidBrush(this->brushes.text)); graphics.DrawString( - HelperFunctions::ConvertToWideString(aircraftToProcess->Callsign()), callsignRect, *textBrush); + HelperFunctions::ConvertToWideString(aircraftToProcess->Callsign()), callsignRect, Gdiplus::SolidBrush(this->brushes.text)); // The target distance / wake if (aircraftToProcess->Mode() == ApproachSequencingMode::WakeTurbulence) { - graphics.DrawString(L"Wake", targetRect, *textBrush); + graphics.DrawString(L"Wake", targetRect, Gdiplus::SolidBrush(this->brushes.text)); } else { - graphics.DrawString(To1DpWide(aircraftToProcess->ExpectedDistance()), targetRect, *textBrush); + graphics.DrawString(To1DpWide(aircraftToProcess->ExpectedDistance()), targetRect, Gdiplus::SolidBrush(this->brushes.text)); } Components::ClickableArea::Create( targetRect, screenObjectId, "approachTarget" + aircraftToProcess->Callsign(), false) @@ -264,30 +264,30 @@ namespace UKControllerPlugin::Approach { double requiredSpacing = spacingCalculator.Calculate(displayOptions->Airfield(), *aircraftToProcess); if (requiredSpacing == spacingCalculator.NoSpacing()) { - graphics.DrawString(L"--", actualRect, *textBrush); + graphics.DrawString(L"--", actualRect, Gdiplus::SolidBrush(this->brushes.text)); } else { - graphics.DrawString(To1DpWide(requiredSpacing), actualRect, *textBrush); + graphics.DrawString(To1DpWide(requiredSpacing), actualRect, Gdiplus::SolidBrush(this->brushes.text)); } 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 +297,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, Gdiplus::SolidBrush(this->brushes.text)); 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 +332,7 @@ namespace UKControllerPlugin::Approach { TITLE_BAR_HEIGHT, WINDOW_WIDTH, static_cast(callsignHeader.GetBottom() + INSETS + (numberOfCallsigns * callsignHeader.Height))}; - graphics.FillRect(contentArea, *backgroundBrush); + graphics.FillRect(contentArea, Gdiplus::SolidBrush(this->brushes.background)); } void ApproachSequencerDisplay::RenderAirfieldTarget( @@ -341,7 +341,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( L"Target:", airfieldTargetStatic, - *textBrush, + Gdiplus::SolidBrush(this->brushes.text), Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); @@ -356,7 +356,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( targetString, airfieldTargetTextArea, - *textBrush, + Gdiplus::SolidBrush(this->brushes.text), Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); this->airfieldTargetClickspot->Apply(graphics, radarScreen); @@ -368,7 +368,7 @@ namespace UKControllerPlugin::Approach { graphics.DrawString( L"Separation:", airfieldSeparationStatic, - *textBrush, + Gdiplus::SolidBrush(this->brushes.text), Graphics::StringFormatManager::Instance().GetLeftAlign(), Graphics::FontManager::Instance().GetDefault()); @@ -377,7 +377,7 @@ namespace UKControllerPlugin::Approach { ? L"--" : To1DpWide(options.Get(displayOptions->Airfield()).minimumSeparationRequirement), airfieldSeparationTextArea, - *textBrush, + Gdiplus::SolidBrush(this->brushes.text), 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 a3d7bf6db..541b2bc3a 100644 --- a/src/plugin/approach/ApproachSequencerDisplay.h +++ b/src/plugin/approach/ApproachSequencerDisplay.h @@ -1,6 +1,5 @@ #pragma once #include "radarscreen/RadarRenderableInterface.h" -#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Components { @@ -13,6 +12,9 @@ namespace UKControllerPlugin { namespace List { class PopupListInterface; } // namespace List + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin::Approach { @@ -38,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( @@ -106,6 +109,9 @@ namespace UKControllerPlugin::Approach { // The plugin Euroscope::EuroscopePluginLoopbackInterface& plugin; + + // Pens and brushes + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; // The screen object id int screenObjectId; @@ -139,10 +145,5 @@ namespace UKControllerPlugin::Approach { std::shared_ptr airfieldTargetClickspot; std::shared_ptr airfieldSeparationClickspot; - const Gdiplus::Color BACKGROUND_COLOUR = UKControllerPlugin::Graphics::Background; - const Gdiplus::Color TEXT_COLOUR = UKControllerPlugin::Graphics::DefaultText; - 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..14ca5f912 100644 --- a/src/plugin/bootstrap/InitialisePlugin.cpp +++ b/src/plugin/bootstrap/InitialisePlugin.cpp @@ -65,6 +65,7 @@ #include "task/TaskRunnerInterface.h" #include "update/PluginVersion.h" #include "wake/WakeModule.h" +#include "graphics/ThemingModule.h" using UKControllerPlugin::Bootstrap::CollectionBootstrap; using UKControllerPlugin::Bootstrap::EventHandlerCollectionBootstrap; @@ -93,6 +94,7 @@ using UKControllerPlugin::Plugin::PluginVersion; using UKControllerPlugin::Prenote::PrenoteModule; using UKControllerPlugin::Regional::RegionalPressureModule; using UKControllerPlugin::Squawk::SquawkModule; +using UKControllerPlugin::Graphics::ThemingModule; namespace UKControllerPlugin { /* @@ -240,13 +242,16 @@ namespace UKControllerPlugin { LoginModule::BootstrapPlugin(*this->container); SectorFile::BootstrapPlugin(*this->container); + ThemingModule::BootstrapPlugin(*this->container, *this->container->pluginUserSettingHandler); + // 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/bootstrap/PostInit.cpp b/src/plugin/bootstrap/PostInit.cpp index 7daa21f03..76358bca2 100644 --- a/src/plugin/bootstrap/PostInit.cpp +++ b/src/plugin/bootstrap/PostInit.cpp @@ -8,11 +8,9 @@ #include "plugin/UKPlugin.h" #include "tag/TagItemCollection.h" #include "update/PluginVersion.h" -#include "graphics/GlobalColours.h" using UKControllerPlugin::Bootstrap::PersistenceContainer; using UKControllerPlugin::Plugin::PluginVersion; -using UKControllerPlugin::Graphics::GlobalColours; namespace UKControllerPlugin::Bootstrap { @@ -28,7 +26,6 @@ namespace UKControllerPlugin::Bootstrap { ukPlugin.PostInit(); UKControllerPlugin::Euroscope::LoadDefaultUserSettings(*container.pluginUserSettingHandler); UKControllerPlugin::Countdown::CountdownModule::LoadDefaultUserSettings(*container.pluginUserSettingHandler); - UKControllerPlugin::Graphics::GlobalColours::LoadDefaultUserSettings(*container.pluginUserSettingHandler); container.userSettingHandlers->UserSettingsUpdateEvent(*container.pluginUserSettingHandler); container.pluginSettingsProviders->Load(); diff --git a/src/plugin/components/CollapsibleWindowTitleBar.cpp b/src/plugin/components/CollapsibleWindowTitleBar.cpp index 80fa1cf65..09703deca 100644 --- a/src/plugin/components/CollapsibleWindowTitleBar.cpp +++ b/src/plugin/components/CollapsibleWindowTitleBar.cpp @@ -38,4 +38,12 @@ 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& brushes) const + { + TitleBar::DrawTheme(graphics, radarScreen, brushes); + 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..8d7ddf3fb 100644 --- a/src/plugin/components/CollapsibleWindowTitleBar.h +++ b/src/plugin/components/CollapsibleWindowTitleBar.h @@ -15,6 +15,7 @@ namespace UKControllerPlugin::Components { Create(std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId); void Draw(Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen) const override; + void DrawTheme(Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, const Windows::GdiplusBrushes& brushes) const override; protected: CollapsibleWindowTitleBar( diff --git a/src/plugin/components/StandardButtons.cpp b/src/plugin/components/StandardButtons.cpp index 0d0d294b0..4e9f7dab5 100644 --- a/src/plugin/components/StandardButtons.cpp +++ b/src/plugin/components/StandardButtons.cpp @@ -1,6 +1,5 @@ #include "StandardButtons.h" #include "graphics/GdiGraphicsInterface.h" -#include "graphics/GlobalColours.h" namespace UKControllerPlugin::Components { @@ -41,7 +40,7 @@ namespace UKControllerPlugin::Components { std::function CloseButton() { - return CloseButton(UKControllerPlugin::Graphics::DefaultText); + return CloseButton(Gdiplus::Color(227, 227, 227)); } /* @@ -75,7 +74,7 @@ namespace UKControllerPlugin::Components { std::function CollapseButton(std::function stateFunction) { - return CollapseButton(UKControllerPlugin::Graphics::DefaultText, stateFunction); + return CollapseButton(Gdiplus::Color(227, 227, 227), stateFunction); } void ScalePen(const std::shared_ptr& pen, Gdiplus::REAL& scaleX, Gdiplus::REAL& scaleY) diff --git a/src/plugin/components/TitleBar.cpp b/src/plugin/components/TitleBar.cpp index b9ed8e180..5d078a37e 100644 --- a/src/plugin/components/TitleBar.cpp +++ b/src/plugin/components/TitleBar.cpp @@ -2,7 +2,7 @@ #include "TitleBar.h" #include "euroscope/EuroscopeRadarLoopbackInterface.h" #include "graphics/GdiGraphicsInterface.h" -#include "graphics/GlobalColours.h" +#include "graphics/GdiplusBrushes.h" namespace UKControllerPlugin::Components { TitleBar::~TitleBar() = default; @@ -71,22 +71,35 @@ namespace UKControllerPlugin::Components { } } + void TitleBar::DrawTheme( + Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, const Windows::GdiplusBrushes& brushes) const + { + // Use theme brushes instead of instance brushes + graphics.FillRect(this->area, Gdiplus::SolidBrush(brushes.header)); + graphics.DrawString(this->title, this->area, Gdiplus::SolidBrush(brushes.text)); + graphics.DrawRect(this->area, Gdiplus::Pen(brushes.border)); + + if (this->clickableArea != nullptr) { + this->clickableArea->Apply(graphics, radarScreen); + } + } + TitleBar::TitleBar(std::wstring title, Gdiplus::Rect area) : title(std::move(title)), area(area) { } std::shared_ptr TitleBar::WithDefaultBackgroundBrush() { - return this->WithBackgroundBrush(std::make_shared(UKControllerPlugin::Graphics::Headers)); + return this->WithBackgroundBrush(std::make_shared(Gdiplus::Color(130, 50, 154))); } std::shared_ptr TitleBar::WithDefaultTextBrush() { - return this->WithTextBrush(std::make_shared(UKControllerPlugin::Graphics::DefaultText)); + return this->WithTextBrush(std::make_shared(Gdiplus::Color(227, 227, 227))); } std::shared_ptr TitleBar::WithDefaultBorder() { - return this->WithBorder(std::make_shared(UKControllerPlugin::Graphics::Border)); + return this->WithBorder(std::make_shared(Gdiplus::Color(255, 255, 255))); } } // namespace UKControllerPlugin::Components diff --git a/src/plugin/components/TitleBar.h b/src/plugin/components/TitleBar.h index dce1bc30e..f155ad364 100644 --- a/src/plugin/components/TitleBar.h +++ b/src/plugin/components/TitleBar.h @@ -1,4 +1,9 @@ #pragma once +#include +#include +#include +#include +#include namespace UKControllerPlugin { namespace Euroscope { @@ -6,6 +11,7 @@ namespace UKControllerPlugin { } // namespace Euroscope namespace Windows { class GdiGraphicsInterface; + struct GdiplusBrushes; } // namespace Windows } // namespace UKControllerPlugin @@ -30,6 +36,7 @@ namespace UKControllerPlugin::Components { std::shared_ptr WithTitle(std::wstring title); virtual void Draw(Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen) const; + virtual void DrawTheme(Windows::GdiGraphicsInterface& graphics, Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, const Windows::GdiplusBrushes& brushes) const; protected: TitleBar(std::wstring title, Gdiplus::Rect area); diff --git a/src/plugin/countdown/CountdownModule.cpp b/src/plugin/countdown/CountdownModule.cpp index 0b63eabdf..4115980bb 100644 --- a/src/plugin/countdown/CountdownModule.cpp +++ b/src/plugin/countdown/CountdownModule.cpp @@ -85,6 +85,7 @@ namespace UKControllerPlugin::Countdown { const std::shared_ptr& configManager, RadarRenderableCollection& radarRender, ConfigurableDisplayCollection& configurableDisplays, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, AsrEventHandlerCollection& userSettingHandlers) { // Create the renderer and get the ids for screen objects @@ -96,7 +97,8 @@ namespace UKControllerPlugin::Countdown { radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), - configureFunctionId)); + configureFunctionId, + brushes)); // Add to the relevant handlers radarRender.RegisterRenderer(rendererId, renderer, radarRender.beforeTags); diff --git a/src/plugin/countdown/CountdownModule.h b/src/plugin/countdown/CountdownModule.h index 82da92f56..6bf332614 100644 --- a/src/plugin/countdown/CountdownModule.h +++ b/src/plugin/countdown/CountdownModule.h @@ -40,6 +40,7 @@ namespace UKControllerPlugin::Countdown { const std::shared_ptr& configManager, UKControllerPlugin::RadarScreen::RadarRenderableCollection& radarRender, UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection& screenControls, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, UKControllerPlugin::Euroscope::AsrEventHandlerCollection& userSettingHandler); static void LoadDefaultUserSettings(UKControllerPlugin::Euroscope::UserSetting& userSetting); diff --git a/src/plugin/countdown/CountdownRenderer.cpp b/src/plugin/countdown/CountdownRenderer.cpp index 71ed41914..44c96b582 100644 --- a/src/plugin/countdown/CountdownRenderer.cpp +++ b/src/plugin/countdown/CountdownRenderer.cpp @@ -18,8 +18,9 @@ namespace UKControllerPlugin::Countdown { int functionsClickspotId, int timeDisplayClickspotId, int closeClickspotId, - int toogleCallbackFunctionId) - : countdownModule(countdownModule), configManager(configManager), + int toogleCallbackFunctionId, + const GdiplusBrushes& brushes) + : countdownModule(countdownModule), brushes(brushes), configManager(configManager), functionsClickspotId(functionsClickspotId), timeDisplayClickspotId(timeDisplayClickspotId), closeClickspotId(closeClickspotId), toggleCallbackFunctionId(toogleCallbackFunctionId) { @@ -163,18 +164,22 @@ namespace UKControllerPlugin::Countdown { { // Colour the text depending on how long is left, if we get 0, that means timer is up. if (secondsRemaining == 0) { - return *currentText; + static Gdiplus::SolidBrush textBrush(this->brushes.text); + return textBrush; } if (secondsRemaining > WARNING_SECONDS) { - return *currentGreenTimer; + static Gdiplus::SolidBrush timerGreen(this->brushes.timerGreen); + return timerGreen; } if (secondsRemaining > CRITICAL_SECONDS) { - return *currentYellowTimer; + static Gdiplus::SolidBrush timerYellow(this->brushes.timerYellow); + return timerYellow; } - return *currentRedTimer; + static Gdiplus::SolidBrush timerRed(this->brushes.timerRed); + return timerRed; } /* @@ -239,10 +244,10 @@ namespace UKControllerPlugin::Countdown { continue; } - graphics.FillRect(this->timerButtonAreas[it->timerId], *currentBackground); - graphics.DrawRect(this->timerButtonAreas[it->timerId], *currentBorder); + graphics.FillRect(this->timerButtonAreas[it->timerId], Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(this->timerButtonAreas[it->timerId], Gdiplus::Pen(this->brushes.border)); graphics.DrawString( - std::to_wstring(it->timerDuration), this->timerButtonAreas[it->timerId], *currentText); + std::to_wstring(it->timerDuration), this->timerButtonAreas[it->timerId], Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( this->functionsClickspotId, "timer" + std::to_string(it->timerId) + "Toggle", @@ -259,20 +264,20 @@ namespace UKControllerPlugin::Countdown { this->timeDisplayArea.bottom, this->timeDisplayArea.right, this->timeDisplayArea.bottom + this->rowHeight}; - graphics.FillRect(spaceToFill, *currentBackground); - graphics.DrawRect(spaceToFill, *currentBorder); + graphics.FillRect(spaceToFill, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(spaceToFill, Gdiplus::Pen(this->brushes.border)); } // The close clickspot - graphics.FillRect(this->closeClickspotDisplayArea, *currentBackground); - graphics.DrawRect(this->closeClickspotDisplayArea, *currentBorder); - graphics.DrawString(L"X", this->closeClickspotDisplayArea, *currentText); + graphics.FillRect(this->closeClickspotDisplayArea, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(this->closeClickspotDisplayArea, Gdiplus::Pen(this->brushes.border)); + graphics.DrawString(L"X", this->closeClickspotDisplayArea, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject(this->closeClickspotId, "", this->closeClickspotDisplayArea, false); // The reset button. - graphics.FillRect(this->resetDisplayArea, *currentBackground); - graphics.DrawRect(this->resetDisplayArea, *currentBorder); - graphics.DrawString(L"R", this->resetDisplayArea, *currentText); + graphics.FillRect(this->resetDisplayArea, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(this->resetDisplayArea, Gdiplus::Pen(this->brushes.border)); + graphics.DrawString(L"R", this->resetDisplayArea, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject(this->functionsClickspotId, "R", this->resetDisplayArea, false); } @@ -283,8 +288,8 @@ namespace UKControllerPlugin::Countdown { CountdownRenderer::RenderTimeDisplay(GdiGraphicsInterface& graphics, EuroscopeRadarLoopbackInterface& radarScreen) { // The time display - graphics.FillRect(this->timeDisplayArea, *currentBackground); - graphics.DrawRect(this->timeDisplayArea, *currentBorder); + graphics.FillRect(this->timeDisplayArea, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(this->timeDisplayArea, Gdiplus::Pen(this->brushes.border)); radarScreen.RegisterScreenObject(this->timeDisplayClickspotId, "", this->timeDisplayArea, true); // Get the seconds remaining from the Countdown class and use that to draw the time to the screen. diff --git a/src/plugin/countdown/CountdownRenderer.h b/src/plugin/countdown/CountdownRenderer.h index f04ded204..37f640244 100644 --- a/src/plugin/countdown/CountdownRenderer.h +++ b/src/plugin/countdown/CountdownRenderer.h @@ -3,7 +3,6 @@ #include "plugin/PopupMenuItem.h" #include "radarscreen/ConfigurableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" -#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Euroscope { @@ -40,7 +39,8 @@ namespace UKControllerPlugin::Countdown { int functionsClickspotId, int timeDisplayClickspotId, int closeClickspotId, - int toogleCallbackFunctionId); + int toogleCallbackFunctionId, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes); void AsrLoadedEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void AsrClosingEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void Configure(int functionId, std::string subject, RECT screenObjectArea) override; @@ -94,24 +94,8 @@ namespace UKControllerPlugin::Countdown { // The countdown module that we're rendering UKControllerPlugin::Countdown::CountdownTimer& countdownModule; - // Colour Brushes - const std::unique_ptr currentBackground = - std::make_unique(UKControllerPlugin::Graphics::Background); - - const std::unique_ptr currentBorder = - std::make_unique(UKControllerPlugin::Graphics::Border); - - const std::unique_ptr currentText = - std::make_unique(UKControllerPlugin::Graphics::DefaultText); - - const std::unique_ptr currentGreenTimer = - std::make_unique(UKControllerPlugin::Graphics::TimerGreen); - - const std::unique_ptr currentYellowTimer = - std::make_unique(UKControllerPlugin::Graphics::TimerYellow); - - const std::unique_ptr currentRedTimer = - std::make_unique(UKControllerPlugin::Graphics::TimerRed); + // A set of brushes to use for rendering. + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; // Handles the timer configurations const UKControllerPlugin::Countdown::TimerConfigurationManager& configManager; diff --git a/src/plugin/departure/DepartureCoordinationList.cpp b/src/plugin/departure/DepartureCoordinationList.cpp index 8c7bb539c..59e58b885 100644 --- a/src/plugin/departure/DepartureCoordinationList.cpp +++ b/src/plugin/departure/DepartureCoordinationList.cpp @@ -19,6 +19,9 @@ #include "releases/DepartureReleaseEventHandler.h" #include "releases/DepartureReleaseRequest.h" #include "tag/TagData.h" +#include "graphics/GdiplusBrushes.h" + +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin::Departure { @@ -28,21 +31,22 @@ namespace UKControllerPlugin::Departure { Euroscope::EuroscopePluginLoopbackInterface& plugin, const Controller::ControllerPositionCollection& controllers, const Controller::ActiveCallsignCollection& activeCallsigns, + const GdiplusBrushes& brushes, const int screenObjectId) - : controllers(controllers), handler(handler), prenotes(prenotes), plugin(plugin), - activeCallsigns(activeCallsigns), textBrush(OFF_WHITE_COLOUR), screenObjectId(screenObjectId), visible(false), + : controllers(controllers), handler(handler), prenotes(prenotes), brushes(brushes), plugin(plugin), + activeCallsigns(activeCallsigns), screenObjectId(screenObjectId), visible(false), contentCollapsed(false) { this->brushSwitcher = Components::BrushSwitcher::Create( - std::make_shared(TITLE_BAR_BASE_COLOUR), std::chrono::seconds(2)) - ->AdditionalBrush(std::make_shared(TITLE_BAR_FLASH_COLOUR)); + std::make_shared(this->brushes.header), std::chrono::seconds(2)) + ->AdditionalBrush(std::make_shared(this->brushes.highlightedHeader)); this->titleBar = Components::TitleBar::Create( L"Departure Coordination Requests", {0, 0, this->titleBarWidth, this->titleBarHeight}) ->WithDrag(this->screenObjectId) - ->WithBorder(std::make_shared(OFF_WHITE_COLOUR)) - ->WithBackgroundBrush(std::make_shared(TITLE_BAR_BASE_COLOUR)) - ->WithTextBrush(std::make_shared(OFF_WHITE_COLOUR)); + ->WithBorder(std::make_shared(this->brushes.border)) + ->WithBackgroundBrush(std::make_shared(this->brushes.header)) + ->WithTextBrush(std::make_shared(this->brushes.text)); this->closeButton = Components::Button::Create( closeButtonOffset, this->screenObjectId, "closeButton", Components::CloseButton()); @@ -119,14 +123,13 @@ namespace UKControllerPlugin::Departure { if (this->contentCollapsed) { return; } - // Draw column headers - graphics.DrawString(L"Type", this->typeColumnHeader, this->textBrush); - graphics.DrawString(L"Callsign", this->callsignColumnHeader, this->textBrush); - graphics.DrawString(L"Controller", this->controllerColumnHeader, this->textBrush); - graphics.DrawString(L"Dept", this->airportColumnHeader, this->textBrush); - graphics.DrawString(L"SID", this->sidColumnHeader, this->textBrush); - graphics.DrawString(L"Dest", this->destColumnHeader, this->textBrush); + graphics.DrawString(L"Type", this->typeColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Callsign", this->callsignColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Controller", this->controllerColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Dept", this->airportColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"SID", this->sidColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); + graphics.DrawString(L"Dest", this->destColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); // Draw each aircraft that we care about Gdiplus::Rect typeColumn = this->typeColumnHeader; @@ -178,7 +181,7 @@ namespace UKControllerPlugin::Departure { // Type column const std::string itemType = listItem.index() == 0 ? "Rls" : "Pre"; - graphics.DrawString(HelperFunctions::ConvertToWideString(itemType), typeColumn, this->textBrush); + graphics.DrawString(HelperFunctions::ConvertToWideString(itemType), typeColumn, Gdiplus::SolidBrush(this->brushes.text)); // Callsign column const std::string callsign = @@ -186,7 +189,7 @@ namespace UKControllerPlugin::Departure { ? std::get>(listItem)->Callsign() : std::get>(listItem)->GetCallsign(); graphics.DrawString( - HelperFunctions::ConvertToWideString(callsign), callsignColumn, this->textBrush); + HelperFunctions::ConvertToWideString(callsign), callsignColumn, Gdiplus::SolidBrush(this->brushes.text)); std::shared_ptr callsignClickspot = Components::ClickableArea::Create( callsignColumn, this->screenObjectId, itemType + "." + callsign, false); callsignClickspot->Apply(graphics, radarScreen); @@ -199,7 +202,7 @@ namespace UKControllerPlugin::Departure { : std::get>(listItem)->GetSendingControllerId(); const std::wstring controller = HelperFunctions::ConvertToWideString( this->controllers.FetchPositionById(controllerId)->GetCallsign()); - graphics.DrawString(controller, controllerColumn, this->textBrush); + graphics.DrawString(controller, controllerColumn, Gdiplus::SolidBrush(this->brushes.text)); auto fp = this->plugin.GetFlightplanForCallsign(callsign); if (!fp) { @@ -208,19 +211,19 @@ namespace UKControllerPlugin::Departure { // Remaining FP-driven columns graphics.DrawString( - HelperFunctions::ConvertToWideString(fp->GetOrigin()), airportColumn, this->textBrush); + HelperFunctions::ConvertToWideString(fp->GetOrigin()), airportColumn, Gdiplus::SolidBrush(this->brushes.text)); graphics.DrawString( - HelperFunctions::ConvertToWideString(fp->GetSidName()), sidColumn, this->textBrush); + HelperFunctions::ConvertToWideString(fp->GetSidName()), sidColumn, Gdiplus::SolidBrush(this->brushes.text)); graphics.DrawString( - HelperFunctions::ConvertToWideString(fp->GetDestination()), destColumn, this->textBrush); + HelperFunctions::ConvertToWideString(fp->GetDestination()), destColumn, Gdiplus::SolidBrush(this->brushes.text)); } while (nextRelease != decisions.cend() || nextPrenote != prenoteMessages.cend()); }); // Translate to window position graphics.Translated(this->position.X, this->position.Y, [this, &graphics, &radarScreen] { - this->titleBar->Draw(graphics, radarScreen); + this->titleBar->DrawTheme(graphics, radarScreen, brushes); this->closeButton->Draw(graphics, radarScreen); this->collapseButton->Draw(graphics, radarScreen); }); diff --git a/src/plugin/departure/DepartureCoordinationList.h b/src/plugin/departure/DepartureCoordinationList.h index 93aaebad8..880283b06 100644 --- a/src/plugin/departure/DepartureCoordinationList.h +++ b/src/plugin/departure/DepartureCoordinationList.h @@ -1,7 +1,6 @@ #pragma once #include "euroscope/AsrEventHandlerInterface.h" #include "radarscreen/RadarRenderableInterface.h" -#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Controller { @@ -24,6 +23,10 @@ namespace UKControllerPlugin { class DepartureReleaseRequest; class DepartureReleaseEventHandler; } // namespace Releases + namespace Windows { + class GdiGraphicsInterface; + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin::Departure { @@ -42,6 +45,7 @@ namespace UKControllerPlugin::Departure { Euroscope::EuroscopePluginLoopbackInterface& plugin, const Controller::ControllerPositionCollection& controllers, const Controller::ActiveCallsignCollection& activeCallsigns, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, int screenObjectId); void LeftClick( Euroscope::EuroscopeRadarLoopbackInterface& radarScreen, @@ -73,6 +77,9 @@ namespace UKControllerPlugin::Departure { // Contains all the prenote messages Prenote::PrenoteMessageCollection& prenotes; + // Pens and brushes + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; + // Provides interface with the plugin Euroscope::EuroscopePluginLoopbackInterface& plugin; @@ -87,14 +94,6 @@ namespace UKControllerPlugin::Departure { const Gdiplus::Rect sidColumnHeader{320, 5, 65, 25}; const Gdiplus::Rect destColumnHeader{395, 5, 40, 25}; - // Some colours - const Gdiplus::Color OFF_WHITE_COLOUR = UKControllerPlugin::Graphics::DefaultText; - const Gdiplus::Color TITLE_BAR_BASE_COLOUR = UKControllerPlugin::Graphics::Headers; - const Gdiplus::Color TITLE_BAR_FLASH_COLOUR = UKControllerPlugin::Graphics::HighlightedHeaders; - - // Brushes - const Gdiplus::SolidBrush textBrush; - // Clickspot identifier const int screenObjectId; diff --git a/src/plugin/departure/DepartureModule.cpp b/src/plugin/departure/DepartureModule.cpp index 6feb396bb..b6c1b2b85 100644 --- a/src/plugin/departure/DepartureModule.cpp +++ b/src/plugin/departure/DepartureModule.cpp @@ -49,6 +49,7 @@ namespace UKControllerPlugin::Departure { *container.plugin, *container.controllerPositions, *container.activeCallsigns, + *container.brushes, renderables.ReserveScreenObjectIdentifier(coordinationListRendererId)); renderables.RegisterRenderer(coordinationListRendererId, coordinationList, renderables.afterLists); diff --git a/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.cpp b/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.cpp index 38bd476b0..96e37c672 100644 --- a/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.cpp +++ b/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.cpp @@ -11,6 +11,7 @@ #include "setting/SettingRepository.h" #include "setting/JsonFileSettingProvider.h" #include "update/BootstrapReleaseChannelSettings.h" +#include "graphics/GdiplusBrushes.h" using UKControllerPlugin::Command::CommandHandlerCollection; using UKControllerPlugin::Dialog::DialogData; @@ -24,6 +25,7 @@ using UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection; using UKControllerPlugin::Setting::JsonFileSettingProvider; using UKControllerPlugin::Windows::WinApiInterface; using UKControllerPluginUtils::Update::BootstrapReleaseChannelSettings; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin { namespace Euroscope { @@ -33,11 +35,12 @@ namespace UKControllerPlugin { UserSetting& userSettings, UserSettingAwareCollection& userSettingsHandlers, Setting::SettingRepository& settings, - WinApiInterface& windows) + WinApiInterface& windows, + Windows::GdiplusBrushes& brushes) { BootstrapReleaseChannelSettings(settings, windows); std::shared_ptr dialog = - std::make_shared(userSettings, userSettingsHandlers, settings); + std::make_shared(userSettings, userSettingsHandlers, settings, brushes); dialogManager.AddDialog( {IDD_GENERAL_SETTINGS, "General Settings", @@ -49,6 +52,7 @@ namespace UKControllerPlugin { void GeneralSettingsConfigurationBootstrap::BootstrapRadarScreen( FunctionCallEventHandler& functionHandler, ConfigurableDisplayCollection& configurableDisplays, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, CommandHandlerCollection& commandHandlers, const DialogManager& dialogManager) { diff --git a/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.h b/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.h index 17b800ef0..d1aa1585a 100644 --- a/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.h +++ b/src/plugin/euroscope/GeneralSettingsConfigurationBootstrap.h @@ -22,6 +22,7 @@ namespace UKControllerPlugin { } // namespace Setting namespace Windows { class WinApiInterface; + struct GdiplusBrushes; } // namespace Windows } // namespace UKControllerPlugin @@ -39,11 +40,13 @@ namespace UKControllerPlugin { UKControllerPlugin::Euroscope::UserSetting& userSettings, UKControllerPlugin::Euroscope::UserSettingAwareCollection& userSettingsHandlers, Setting::SettingRepository& settings, - Windows::WinApiInterface& windows); + Windows::WinApiInterface& windows, + Windows::GdiplusBrushes& brushes); static void BootstrapRadarScreen( UKControllerPlugin::Plugin::FunctionCallEventHandler& functionCalls, UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection& configurableDisplays, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, UKControllerPlugin::Command::CommandHandlerCollection& commandHandlers, const UKControllerPlugin::Dialog::DialogManager& dialogManager); }; diff --git a/src/plugin/euroscope/GeneralSettingsDialog.cpp b/src/plugin/euroscope/GeneralSettingsDialog.cpp index 3ce002acb..c567cd184 100644 --- a/src/plugin/euroscope/GeneralSettingsDialog.cpp +++ b/src/plugin/euroscope/GeneralSettingsDialog.cpp @@ -4,12 +4,15 @@ #include "UserSetting.h" #include "dialog/DialogCallArgument.h" #include "setting/SettingRepository.h" -#include "graphics/GlobalColours.h" +#include "graphics/ThemingModule.h" +#include "graphics/GdiplusBrushes.h" using UKControllerPlugin::Dialog::DialogCallArgument; using UKControllerPlugin::Euroscope::GeneralSettingsEntries; using UKControllerPlugin::Euroscope::UserSetting; using UKControllerPlugin::Euroscope::UserSettingAwareCollection; +using UKControllerPlugin::Graphics::ThemingModule; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin { @@ -18,13 +21,14 @@ namespace UKControllerPlugin { GeneralSettingsDialog::GeneralSettingsDialog( UserSetting& userSettings, const UserSettingAwareCollection& userSettingsHandlers, - Setting::SettingRepository& settings) - : userSettings(userSettings), userSettingsHandlers(userSettingsHandlers), settings(settings) + Setting::SettingRepository& settings, + GdiplusBrushes& brushes) + : userSettings(userSettings), brushes(brushes), userSettingsHandlers(userSettingsHandlers), settings(settings) { } GeneralSettingsDialog::GeneralSettingsDialog(const GeneralSettingsDialog& newObject) - : userSettings(newObject.userSettings), userSettingsHandlers(newObject.userSettingsHandlers), + : userSettings(newObject.userSettings), brushes(newObject.brushes), userSettingsHandlers(newObject.userSettingsHandlers), settings(newObject.settings) { } @@ -190,6 +194,8 @@ namespace UKControllerPlugin { GeneralSettingsEntries::colourPaletteSettingsKey, GeneralSettingsEntries::colourPaletteSettingsDescription, selectedColourPalette); + + ThemingModule::ApplyTheme(selectedColourPalette, this->brushes); this->userSettingsHandlers.UserSettingsUpdateEvent(this->userSettings); } diff --git a/src/plugin/euroscope/GeneralSettingsDialog.h b/src/plugin/euroscope/GeneralSettingsDialog.h index aceaea9b1..190353030 100644 --- a/src/plugin/euroscope/GeneralSettingsDialog.h +++ b/src/plugin/euroscope/GeneralSettingsDialog.h @@ -8,6 +8,9 @@ namespace UKControllerPlugin { namespace Setting { class SettingRepository; } // namespace Setting + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin::Euroscope { @@ -21,7 +24,8 @@ namespace UKControllerPlugin::Euroscope { GeneralSettingsDialog( UKControllerPlugin::Euroscope::UserSetting& userSettings, const UKControllerPlugin::Euroscope::UserSettingAwareCollection& userSettingsHandlers, - Setting::SettingRepository& settings); + Setting::SettingRepository& settings, + UKControllerPlugin::Windows::GdiplusBrushes& brushes); GeneralSettingsDialog(const GeneralSettingsDialog& newObject); static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); @@ -53,6 +57,8 @@ namespace UKControllerPlugin::Euroscope { // A place where user settings are retrieved and stored UKControllerPlugin::Euroscope::UserSetting& userSettings; + UKControllerPlugin::Windows::GdiplusBrushes& brushes; + // A set of handlers that want to know when user settings get updated const UKControllerPlugin::Euroscope::UserSettingAwareCollection& userSettingsHandlers; diff --git a/src/plugin/graphics/ColourPaletteDefinitions.cpp b/src/plugin/graphics/ColourPaletteDefinitions.cpp index 268734792..23644d1e4 100644 --- a/src/plugin/graphics/ColourPaletteDefinitions.cpp +++ b/src/plugin/graphics/ColourPaletteDefinitions.cpp @@ -14,6 +14,7 @@ namespace UKControllerPlugin { const Gdiplus::Color ColourPaletteDefinitions::DefaultTimerGreen = Gdiplus::Color(0, 255, 0); // rgb(0, 255, 0) const Gdiplus::Color ColourPaletteDefinitions::DefaultTimerYellow = Gdiplus::Color(255, 255, 0); // rgb(255, 255, 0) const Gdiplus::Color ColourPaletteDefinitions::DefaultTimerRed = Gdiplus::Color(255, 0, 0); // rgb(255, 0, 0) + //rgb(123, 125, 123) // NODE const Gdiplus::Color ColourPaletteDefinitions::NodeBackground = Gdiplus::Color(0, 0, 0); // #000000 diff --git a/src/plugin/graphics/GdiplusBrushes.h b/src/plugin/graphics/GdiplusBrushes.h index 9c57482a1..f665eda1a 100644 --- a/src/plugin/graphics/GdiplusBrushes.h +++ b/src/plugin/graphics/GdiplusBrushes.h @@ -3,25 +3,29 @@ namespace UKControllerPlugin { namespace Windows { - typedef struct GdiplusBrushes + struct GdiplusBrushes { - const std::unique_ptr whiteBrush = - std::make_unique(Gdiplus::Color(255, 255, 255, 255)); - const std::unique_ptr yellowBrush = - std::make_unique(Gdiplus::Color(255, 255, 255, 0)); - const std::unique_ptr euroscopeBackgroundBrush = - std::make_unique(Gdiplus::Color(255, 11, 65, 54)); - const std::unique_ptr blackBrush = - std::make_unique(Gdiplus::Color(255, 0, 0, 0)); - const std::unique_ptr blackPen = - std::make_unique(Gdiplus::Color(255, 0, 0, 0)); - const std::unique_ptr greyBrush = - std::make_unique(Gdiplus::Color(255, 125, 125, 125)); - const std::unique_ptr redBrush = - std::make_unique(Gdiplus::Color(255, 255, 0, 0)); - const std::unique_ptr greenBrush = - std::make_unique(Gdiplus::Color(255, 0, 255, 0)); - } GdiplusBrushes; + Gdiplus::Color white; + Gdiplus::Color yellow; + Gdiplus::Color euroscopeBackground; + Gdiplus::Color black; + Gdiplus::Color grey; + Gdiplus::Color red; + Gdiplus::Color green; + + // Add themed colors + Gdiplus::Color background; + Gdiplus::Color header; + Gdiplus::Color highlightedHeader; + Gdiplus::Color acknowledge; + Gdiplus::Color border; + Gdiplus::Color text; + Gdiplus::Color mainAircraftText; + Gdiplus::Color highlightedAircraftText; + Gdiplus::Color timerGreen; + Gdiplus::Color timerYellow; + Gdiplus::Color timerRed; + }; } // namespace Windows } // namespace UKControllerPlugin diff --git a/src/plugin/graphics/GlobalColours.cpp b/src/plugin/graphics/GlobalColours.cpp deleted file mode 100644 index f53ae6aa8..000000000 --- a/src/plugin/graphics/GlobalColours.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "GlobalColours.h" -#include "ColourPaletteDefinitions.h" -#include "euroscope/UserSettingAwareCollection.h" -#include "euroscope/UserSetting.h" -#include -#include "euroscope/GeneralSettingsEntries.h" - -using UKControllerPlugin::Euroscope::UserSetting; -using UKControllerPlugin::Euroscope::UserSettingAwareCollection; -using UKControllerPlugin::Euroscope::GeneralSettingsEntries; - -namespace UKControllerPlugin::Graphics { - Gdiplus::Color Background; - Gdiplus::Color Border; - Gdiplus::Color Headers; - Gdiplus::Color HighlightedHeaders; - Gdiplus::Color DefaultText; - Gdiplus::Color HighlightedText; - Gdiplus::Color MainAircraftText; - Gdiplus::Color HighlightedAircraftText; - Gdiplus::Color TimerGreen; - Gdiplus::Color TimerYellow; - Gdiplus::Color TimerRed; - - - std::string ColorToString(const Gdiplus::Color& color) { - std::ostringstream oss; - oss << "ARGB(" - << static_cast(color.GetA()) << "," - << static_cast(color.GetR()) << "," - << static_cast(color.GetG()) << "," - << static_cast(color.GetB()) << ")"; - return oss.str(); - } - - void GlobalColours::LoadDefaultUserSettings(UserSetting& userSetting) - { - LogInfo("Loading default user settings for global colours"); - // Set default colours if not already set - if (!userSetting.HasEntry(GeneralSettingsEntries::colourPaletteSettingsKey)) { - userSetting.Save(GeneralSettingsEntries::colourPaletteSettingsKey, - GeneralSettingsEntries::colourPaletteSettingsDescription, - DEFAULT_COLOUR_PALETTE); - } - GlobalColours::SetGlobalColours(userSetting.GetStringEntry("colourPalette", "default")); - } - - void GlobalColours::SetGlobalColours(const std::string& paletteName) { - LogInfo("Setting global colours to palette: " + paletteName); - - auto logColour = [](const std::string& name, const Gdiplus::Color& color) { - LogInfo(name + " set to " + ColorToString(color)); - }; - - if (paletteName == "default") { - Background = ColourPaletteDefinitions::NodeBackground; - logColour("Background", Background); - Border = ColourPaletteDefinitions::NodeBorder; - logColour("Border", Border); - Headers = ColourPaletteDefinitions::NodeHeaders; - logColour("Headers", Headers); - HighlightedHeaders = ColourPaletteDefinitions::NodeHighlightedHeaders; - logColour("HighlightedHeaders", HighlightedHeaders); - DefaultText = ColourPaletteDefinitions::NodeDefaultText; - logColour("DefaultText", DefaultText); - HighlightedText = ColourPaletteDefinitions::NodeHighlightedText; - logColour("HighlightedText", HighlightedText); - MainAircraftText = ColourPaletteDefinitions::NodeMainAircraftText; - logColour("MainAircraftText", MainAircraftText); - HighlightedAircraftText = ColourPaletteDefinitions::NodeHighlightedAircraftText; - logColour("HighlightedAircraftText", HighlightedAircraftText); - TimerGreen = ColourPaletteDefinitions::NodeTimerGreen; - logColour("TimerGreen", TimerGreen); - TimerYellow = ColourPaletteDefinitions::NodeTimerYellow; - logColour("TimerYellow", TimerYellow); - TimerRed = ColourPaletteDefinitions::NodeTimerRed; - logColour("TimerRed", TimerRed); - } - else if (paletteName == "nerc") { - Background = ColourPaletteDefinitions::NercBackground; - logColour("Background", Background); - Border = ColourPaletteDefinitions::NercBorder; - logColour("Border", Border); - Headers = ColourPaletteDefinitions::NercHeaders; - logColour("Headers", Headers); - HighlightedHeaders = ColourPaletteDefinitions::NercHighlightedHeaders; - logColour("HighlightedHeaders", HighlightedHeaders); - DefaultText = ColourPaletteDefinitions::NercDefaultText; - logColour("DefaultText", DefaultText); - HighlightedText = ColourPaletteDefinitions::NercHighlightedText; - logColour("HighlightedText", HighlightedText); - MainAircraftText = ColourPaletteDefinitions::NercMainAircraftText; - logColour("MainAircraftText", MainAircraftText); - HighlightedAircraftText = ColourPaletteDefinitions::NercHighlightedAircraftText; - logColour("HighlightedAircraftText", HighlightedAircraftText); - TimerGreen = ColourPaletteDefinitions::NercTimerGreen; - logColour("TimerGreen", TimerGreen); - TimerYellow = ColourPaletteDefinitions::NercTimerYellow; - logColour("TimerYellow", TimerYellow); - TimerRed = ColourPaletteDefinitions::NercTimerRed; - logColour("TimerRed", TimerRed); - } - else if (paletteName == "nova") { - Background = ColourPaletteDefinitions::NovaBackground; - logColour("Background", Background); - Border = ColourPaletteDefinitions::NovaBorder; - logColour("Border", Border); - Headers = ColourPaletteDefinitions::NovaHeaders; - logColour("Headers", Headers); - HighlightedHeaders = ColourPaletteDefinitions::NovaHighlightedHeaders; - logColour("HighlightedHeaders", HighlightedHeaders); - DefaultText = ColourPaletteDefinitions::NovaDefaultText; - logColour("DefaultText", DefaultText); - HighlightedText = ColourPaletteDefinitions::NovaHighlightedText; - logColour("HighlightedText", HighlightedText); - MainAircraftText = ColourPaletteDefinitions::NovaMainAircraftText; - logColour("MainAircraftText", MainAircraftText); - HighlightedAircraftText = ColourPaletteDefinitions::NovaHighlightedAircraftText; - logColour("HighlightedAircraftText", HighlightedAircraftText); - TimerGreen = ColourPaletteDefinitions::NovaTimerGreen; - logColour("TimerGreen", TimerGreen); - TimerYellow = ColourPaletteDefinitions::NovaTimerYellow; - logColour("TimerYellow", TimerYellow); - TimerRed = ColourPaletteDefinitions::NovaTimerRed; - logColour("TimerRed", TimerRed); - } - else if (paletteName == "itec") { - Background = ColourPaletteDefinitions::ItecBackground; - logColour("Background", Background); - Border = ColourPaletteDefinitions::ItecBorder; - logColour("Border", Border); - Headers = ColourPaletteDefinitions::ItecHeaders; - logColour("Headers", Headers); - HighlightedHeaders = ColourPaletteDefinitions::ItecHighlightedHeaders; - logColour("HighlightedHeaders", HighlightedHeaders); - DefaultText = ColourPaletteDefinitions::ItecDefaultText; - logColour("DefaultText", DefaultText); - HighlightedText = ColourPaletteDefinitions::ItecHighlightedText; - logColour("HighlightedText", HighlightedText); - MainAircraftText = ColourPaletteDefinitions::ItecMainAircraftText; - logColour("MainAircraftText", MainAircraftText); - HighlightedAircraftText = ColourPaletteDefinitions::ItecHighlightedAircraftText; - logColour("HighlightedAircraftText", HighlightedAircraftText); - TimerGreen = ColourPaletteDefinitions::ItecTimerGreen; - logColour("TimerGreen", TimerGreen); - TimerYellow = ColourPaletteDefinitions::ItecTimerYellow; - logColour("TimerYellow", TimerYellow); - TimerRed = ColourPaletteDefinitions::ItecTimerRed; - logColour("TimerRed", TimerRed); - } - else { - Background = ColourPaletteDefinitions::DefaultBackground; - logColour("Background", Background); - Border = ColourPaletteDefinitions::DefaultBorder; - logColour("Border", Border); - Headers = ColourPaletteDefinitions::DefaultHeaders; - logColour("Headers", Headers); - HighlightedHeaders = ColourPaletteDefinitions::DefaultHighlightedHeaders; - logColour("HighlightedHeaders", HighlightedHeaders); - DefaultText = ColourPaletteDefinitions::DefaultText; - logColour("DefaultText", DefaultText); - HighlightedText = ColourPaletteDefinitions::DefaultHighlightedText; - logColour("HighlightedText", HighlightedText); - MainAircraftText = ColourPaletteDefinitions::DefaultMainAircraftText; - logColour("MainAircraftText", MainAircraftText); - HighlightedAircraftText = ColourPaletteDefinitions::DefaultHighlightedAircraftText; - logColour("HighlightedAircraftText", HighlightedAircraftText); - TimerGreen = ColourPaletteDefinitions::DefaultTimerGreen; - logColour("TimerGreen", TimerGreen); - TimerYellow = ColourPaletteDefinitions::DefaultTimerYellow; - logColour("TimerYellow", TimerYellow); - TimerRed = ColourPaletteDefinitions::DefaultTimerRed; - logColour("TimerRed", TimerRed); - } - } -} \ No newline at end of file diff --git a/src/plugin/graphics/GlobalColours.h b/src/plugin/graphics/GlobalColours.h deleted file mode 100644 index 1d9c47b16..000000000 --- a/src/plugin/graphics/GlobalColours.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "GdiGraphicsInterface.h" - -namespace UKControllerPlugin { - namespace Euroscope { - class UserSetting; - } // namespace Euroscope -} // namespace UKControllerPlugin - -namespace UKControllerPlugin::Graphics { - - // Default colour palette name - const std::string DEFAULT_COLOUR_PALETTE = "default"; - - // Declare global colour variables - extern Gdiplus::Color Background; - extern Gdiplus::Color Border; - extern Gdiplus::Color Headers; - extern Gdiplus::Color HighlightedHeaders; - extern Gdiplus::Color DefaultText; - extern Gdiplus::Color HighlightedText; - extern Gdiplus::Color MainAircraftText; - extern Gdiplus::Color HighlightedAircraftText; - extern Gdiplus::Color TimerGreen; - extern Gdiplus::Color TimerYellow; - extern Gdiplus::Color TimerRed; - - class GlobalColours - { - public: - static void SetGlobalColours(const std::string& paletteName); - static void LoadDefaultUserSettings(UKControllerPlugin::Euroscope::UserSetting& userSetting); - }; -} \ No newline at end of file diff --git a/src/plugin/graphics/ThemingModule.cpp b/src/plugin/graphics/ThemingModule.cpp new file mode 100644 index 000000000..eb37c383d --- /dev/null +++ b/src/plugin/graphics/ThemingModule.cpp @@ -0,0 +1,94 @@ +#include "ThemingModule.h" +#include "ColourPaletteDefinitions.h" +#include "bootstrap/PersistenceContainer.h" +#include "euroscope/UserSetting.h" +#include "GdiplusBrushes.h" + +using UKControllerPlugin::Euroscope::UserSetting; +using UKControllerPlugin::Windows::GdiplusBrushes; +using UKControllerPlugin::Bootstrap::PersistenceContainer; + +namespace UKControllerPlugin::Graphics { + void ThemingModule::BootstrapPlugin(PersistenceContainer& pc, UserSetting& userSetting) + { + std::string palette = userSetting.GetStringEntry("colourPalette", "default"); + ApplyTheme(palette, *pc.brushes); + } + + void ThemingModule::ApplyTheme(const std::string& paletteName, UKControllerPlugin::Windows::GdiplusBrushes& brushes) + { + if (paletteName == "node") { + brushes.background = ColourPaletteDefinitions::NodeBackground; + brushes.header = ColourPaletteDefinitions::NodeHeaders; + brushes.highlightedHeader = ColourPaletteDefinitions::NodeHighlightedHeaders; + brushes.acknowledge = ColourPaletteDefinitions::NodeHighlightedText; + brushes.border = ColourPaletteDefinitions::NodeBorder; + brushes.text = ColourPaletteDefinitions::NodeDefaultText; + brushes.mainAircraftText = ColourPaletteDefinitions::NodeMainAircraftText; + brushes.highlightedAircraftText = ColourPaletteDefinitions::NodeHighlightedAircraftText; + brushes.timerGreen = ColourPaletteDefinitions::NodeTimerGreen; + brushes.timerYellow = ColourPaletteDefinitions::NodeTimerYellow; + brushes.timerRed = ColourPaletteDefinitions::NodeTimerRed; + } + else if (paletteName == "nerc") { + brushes.background = ColourPaletteDefinitions::NercBackground; + brushes.header = ColourPaletteDefinitions::NercHeaders; + brushes.highlightedHeader = ColourPaletteDefinitions::NercHighlightedHeaders; + brushes.acknowledge = ColourPaletteDefinitions::NercHighlightedText; + brushes.border = ColourPaletteDefinitions::NercBorder; + brushes.text = ColourPaletteDefinitions::NercDefaultText; + brushes.mainAircraftText = ColourPaletteDefinitions::NercMainAircraftText; + brushes.highlightedAircraftText = ColourPaletteDefinitions::NercHighlightedAircraftText; + brushes.timerGreen = ColourPaletteDefinitions::NercTimerGreen; + brushes.timerYellow = ColourPaletteDefinitions::NercTimerYellow; + brushes.timerRed = ColourPaletteDefinitions::NercTimerRed; + } + else if (paletteName == "nova") { + brushes.background = ColourPaletteDefinitions::NovaBackground; + brushes.header = ColourPaletteDefinitions::NovaHeaders; + brushes.highlightedHeader = ColourPaletteDefinitions::NovaHighlightedHeaders; + brushes.acknowledge = ColourPaletteDefinitions::NovaHighlightedText; + brushes.border = ColourPaletteDefinitions::NovaBorder; + brushes.text = ColourPaletteDefinitions::NovaDefaultText; + brushes.mainAircraftText = ColourPaletteDefinitions::NovaMainAircraftText; + brushes.highlightedAircraftText = ColourPaletteDefinitions::NovaHighlightedAircraftText; + brushes.timerGreen = ColourPaletteDefinitions::NovaTimerGreen; + brushes.timerYellow = ColourPaletteDefinitions::NovaTimerYellow; + brushes.timerRed = ColourPaletteDefinitions::NovaTimerRed; + } + else if (paletteName == "itec") { + brushes.background = ColourPaletteDefinitions::ItecBackground; + brushes.header = ColourPaletteDefinitions::ItecHeaders; + brushes.highlightedHeader = ColourPaletteDefinitions::ItecHighlightedHeaders; + brushes.acknowledge = ColourPaletteDefinitions::ItecHighlightedText; + brushes.border = ColourPaletteDefinitions::ItecBorder; + brushes.text = ColourPaletteDefinitions::ItecDefaultText; + brushes.mainAircraftText = ColourPaletteDefinitions::ItecMainAircraftText; + brushes.highlightedAircraftText = ColourPaletteDefinitions::ItecHighlightedAircraftText; + brushes.timerGreen = ColourPaletteDefinitions::ItecTimerGreen; + brushes.timerYellow = ColourPaletteDefinitions::ItecTimerYellow; + brushes.timerRed = ColourPaletteDefinitions::ItecTimerRed; + } + else { + brushes.background = ColourPaletteDefinitions::DefaultBackground; + brushes.header = ColourPaletteDefinitions::DefaultHeaders; + brushes.highlightedHeader = ColourPaletteDefinitions::DefaultHighlightedHeaders; + brushes.acknowledge = ColourPaletteDefinitions::DefaultHighlightedText; + brushes.border = ColourPaletteDefinitions::DefaultBorder; + brushes.text = ColourPaletteDefinitions::DefaultText; + brushes.mainAircraftText = ColourPaletteDefinitions::DefaultMainAircraftText; + brushes.highlightedAircraftText = ColourPaletteDefinitions::DefaultHighlightedAircraftText; + brushes.timerGreen = ColourPaletteDefinitions::DefaultTimerGreen; + brushes.timerYellow = ColourPaletteDefinitions::DefaultTimerYellow; + brushes.timerRed = ColourPaletteDefinitions::DefaultTimerRed; + } + // Set static/constant brushes + brushes.white = Gdiplus::Color(255, 255, 255, 255); + brushes.yellow = Gdiplus::Color(255, 255, 255, 0); + brushes.euroscopeBackground = Gdiplus::Color(255, 11, 65, 54); + brushes.black = Gdiplus::Color(255, 0, 0, 0); + brushes.grey = Gdiplus::Color(255, 125, 125, 125); + brushes.red = Gdiplus::Color(255, 255, 0, 0); + brushes.green = Gdiplus::Color(255, 0, 255, 0); + } +} \ No newline at end of file diff --git a/src/plugin/graphics/ThemingModule.h b/src/plugin/graphics/ThemingModule.h new file mode 100644 index 000000000..afacb1ab2 --- /dev/null +++ b/src/plugin/graphics/ThemingModule.h @@ -0,0 +1,24 @@ +#pragma once + +namespace UKControllerPlugin { + namespace Euroscope { + class UserSetting; + } // namespace Euroscope + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows + namespace Bootstrap { + struct PersistenceContainer; + } // namespace Bootstrap +} // namespace UKControllerPlugin + +namespace UKControllerPlugin::Graphics { + + class ThemingModule + { + public: + static void BootstrapPlugin(Bootstrap::PersistenceContainer& pc, Euroscope::UserSetting& userSetting); + static void ApplyTheme(const std::string& paletteName, Windows::GdiplusBrushes& brushes); + }; + +} \ No newline at end of file diff --git a/src/plugin/hold/HoldDisplay.cpp b/src/plugin/hold/HoldDisplay.cpp index 011207f8c..c89ccae5f 100644 --- a/src/plugin/hold/HoldDisplay.cpp +++ b/src/plugin/hold/HoldDisplay.cpp @@ -17,9 +17,9 @@ #include "geometry/Measurement.h" #include "geometry/MeasurementUnit.h" #include "graphics/GdiGraphicsInterface.h" -#include "graphics/GlobalColours.h" #include "list/PopupListInterface.h" #include "navaids/Navaid.h" +#include "graphics/GdiplusBrushes.h" using UKControllerPlugin::Dialog::DialogManager; using UKControllerPlugin::Euroscope::EuroScopeCFlightPlanInterface; @@ -29,7 +29,7 @@ using UKControllerPlugin::Euroscope::EuroscopeRadarLoopbackInterface; using UKControllerPlugin::Euroscope::UserSetting; using UKControllerPlugin::Hold::HoldManager; using UKControllerPlugin::Windows::GdiGraphicsInterface; -using UKControllerPlugin::Graphics::GlobalColours; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin { namespace Hold { @@ -39,16 +39,13 @@ namespace UKControllerPlugin { const Navaids::Navaid& navaid, const PublishedHoldCollection& publishedHoldCollection, const DialogManager& dialogManager, + const GdiplusBrushes& brushes, std::shared_ptr addAircraftSelector) : navaid(navaid), publishedHolds(publishedHoldCollection.GetForFix(navaid.identifier)), holdManager(holdManager), plugin(plugin), dialogManager(dialogManager), - publishedHoldCollection(publishedHoldCollection), addAircraftSelector(addAircraftSelector), - titleBarTextBrush(UKControllerPlugin::Graphics::DefaultText), titleBarBrush(UKControllerPlugin::Graphics::Headers), - dataBrush(Gdiplus::Color(7, 237, 7)), clearedLevelBrush(UKControllerPlugin::Graphics::HighlightedText), - blockedLevelBrush(Gdiplus::Color(123, 125, 123)), borderPen(UKControllerPlugin::Graphics::Border, 1.5f), - sameLevelBoxPen(Gdiplus::Color(7, 237, 7), 1.5f), verticalSpeedAscentPen(UKControllerPlugin::Graphics::DefaultText, 2.5f), - verticalSpeedDescentPen(UKControllerPlugin::Graphics::DefaultText, 2.5f), exitButtonBrush(Gdiplus::Color(0, 0, 0)), - backgroundBrush(UKControllerPlugin::Graphics::Background), fontFamily(L"EuroScope"), + publishedHoldCollection(publishedHoldCollection), addAircraftSelector(addAircraftSelector), + verticalSpeedAscentPen(Gdiplus::Color(7, 237, 7), 2.5f), verticalSpeedDescentPen(Gdiplus::Color(7, 237, 7), 2.5f), + brushes(brushes), fontFamily(L"EuroScope"), font(&fontFamily, 12, Gdiplus::FontStyleBold, Gdiplus::UnitPixel), plusFont(&fontFamily, 18, Gdiplus::FontStyleRegular, Gdiplus::UnitPixel), stringFormat(Gdiplus::StringFormatFlags::StringFormatFlagsNoClip), dataStartHeight(0), @@ -680,7 +677,7 @@ namespace UKControllerPlugin { path.AddLine(rect.X, rect.Y + rect.Height - (radius * 2), rect.X, rect.Y + radius); path.AddArc(rect.X, rect.Y, radius * 2, radius * 2, 180, 90); path.CloseFigure(); - graphics.DrawPath(path, this->borderPen); + graphics.DrawPath(path, Gdiplus::Pen(this->brushes.border, 1.5f)); } /* @@ -695,8 +692,8 @@ namespace UKControllerPlugin { Gdiplus::Rect borderRect = { this->windowPos.x, this->windowPos.y, this->windowWidth, this->informationDisplayWindowHeight}; - graphics.FillRect(borderRect, this->backgroundBrush); - graphics.DrawRect(borderRect, this->borderPen); + graphics.FillRect(borderRect, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(borderRect, Gdiplus::Pen(this->brushes.border, 1.5f)); // Render the title bar this->RenderTitleBar(graphics, radarScreen, screenObjectId); @@ -706,7 +703,7 @@ namespace UKControllerPlugin { // Render a message if no published holds if (this->publishedHolds.empty()) { - graphics.DrawString(std::wstring(L"No published holds found."), dataRect, this->dataBrush); + graphics.DrawString(std::wstring(L"No published holds found."), dataRect, Gdiplus::SolidBrush(this->brushes.text)); return; } @@ -716,8 +713,8 @@ namespace UKControllerPlugin { Gdiplus::Rect buttonRect = {this->windowPos.x + 5, this->titleArea.GetBottom() + 5, 20, 20}; // Left - graphics.DrawRect(buttonRect, this->sameLevelBoxPen); - graphics.DrawString(L"<", buttonRect, this->dataBrush); + graphics.DrawRect(buttonRect, Gdiplus::Pen(this->brushes.text)); + graphics.DrawString(L"<", buttonRect, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/prevhold", @@ -726,8 +723,8 @@ namespace UKControllerPlugin { // Right buttonRect.X = this->titleArea.GetRight() - 25; - graphics.DrawRect(buttonRect, this->sameLevelBoxPen); - graphics.DrawString(L">", buttonRect, this->dataBrush); + graphics.DrawRect(buttonRect, Gdiplus::Pen(this->brushes.text)); + graphics.DrawString(L">", buttonRect, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/nexthold", @@ -741,38 +738,38 @@ namespace UKControllerPlugin { L"Hold " + std::to_wstring(this->selectedPublishedHoldIndex + 1) + L" of " + std::to_wstring(this->publishedHolds.size()), buttonRect, - this->dataBrush); + Gdiplus::SolidBrush(this->brushes.text)); // Render the data - graphics.DrawString(ConvertToTchar(hold->description), dataRect, this->dataBrush); + graphics.DrawString(ConvertToTchar(hold->description), dataRect, Gdiplus::SolidBrush(this->brushes.text)); dataRect.Y = dataRect.Y + this->lineHeight + 5; graphics.DrawString( - std::wstring(L"Fix: ") + ConvertToTchar(this->navaid.identifier), dataRect, this->dataBrush); + std::wstring(L"Fix: ") + ConvertToTchar(this->navaid.identifier), dataRect, Gdiplus::SolidBrush(this->brushes.text)); dataRect.Y = dataRect.Y + this->lineHeight + 5; - graphics.DrawString(std::wstring(L"Inbound: ") + ConvertToTchar(hold->inbound), dataRect, this->dataBrush); + graphics.DrawString(std::wstring(L"Inbound: ") + ConvertToTchar(hold->inbound), dataRect, Gdiplus::SolidBrush(this->brushes.text)); dataRect.Y = dataRect.Y + this->lineHeight + 5; graphics.DrawString( - std::wstring(L"Turn: ") + ConvertToTchar(hold->turnDirection), dataRect, this->dataBrush); + std::wstring(L"Turn: ") + ConvertToTchar(hold->turnDirection), dataRect, Gdiplus::SolidBrush(this->brushes.text)); dataRect.Y = dataRect.Y + this->lineHeight + 5; - graphics.DrawString(std::wstring(L"Maximum: ") + ConvertToTchar(hold->maximum), dataRect, this->dataBrush); + graphics.DrawString(std::wstring(L"Maximum: ") + ConvertToTchar(hold->maximum), dataRect, Gdiplus::SolidBrush(this->brushes.text)); dataRect.Y = dataRect.Y + this->lineHeight + 5; - graphics.DrawString(std::wstring(L"Minimum: ") + ConvertToTchar(hold->minimum), dataRect, this->dataBrush); + graphics.DrawString(std::wstring(L"Minimum: ") + ConvertToTchar(hold->minimum), dataRect, Gdiplus::SolidBrush(this->brushes.text)); dataRect.Y = dataRect.Y + this->lineHeight + 5; if (*hold->outboundLeg->unit == Geometry::MeasurementUnitType::None) { - graphics.DrawString(std::wstring(L"Outbound Leg: --"), dataRect, this->dataBrush); + graphics.DrawString(std::wstring(L"Outbound Leg: --"), dataRect, Gdiplus::SolidBrush(this->brushes.text)); } else { graphics.DrawString( std::wstring(L"Outbound Leg: ") + FormatOutboundLegValue(hold->outboundLeg->value) + L" " + ConvertToTchar(hold->outboundLeg->unit->description), dataRect, - this->dataBrush); + Gdiplus::SolidBrush(this->brushes.text)); } } @@ -786,33 +783,33 @@ namespace UKControllerPlugin { { // Title bar radarScreen.RegisterScreenObject(screenObjectId, this->navaid.identifier, this->titleRect, true); - graphics.FillRect(this->titleArea, this->titleBarBrush); - graphics.DrawRect(this->titleArea, this->borderPen); + graphics.FillRect(this->titleArea, Gdiplus::SolidBrush(this->brushes.header)); + graphics.DrawRect(this->titleArea, Gdiplus::Pen(this->brushes.border)); std::wstring holdName = ConvertToTchar(this->navaid.identifier); - graphics.DrawString(ConvertToTchar(this->navaid.identifier), this->titleArea, this->titleBarTextBrush); + graphics.DrawString(ConvertToTchar(this->navaid.identifier), this->titleArea, Gdiplus::SolidBrush(this->brushes.text)); graphics.DrawLine( - this->borderPen, + Gdiplus::Pen(this->brushes.border), Gdiplus::Point{this->titleArea.X, this->titleArea.Y + this->titleArea.Height}, Gdiplus::Point{this->titleArea.X + this->titleArea.Width, this->titleArea.Y + this->titleArea.Height}); // Minimise Button - graphics.FillRect(this->minimiseButtonArea, this->backgroundBrush); - graphics.DrawRect(this->minimiseButtonArea, this->borderPen); + graphics.FillRect(this->minimiseButtonArea, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(this->minimiseButtonArea, Gdiplus::Pen(this->brushes.border)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/minimise", this->minimiseClickRect, false); // Information button - graphics.FillRect(this->informationButtonArea, this->backgroundBrush); - graphics.DrawRect(this->informationButtonArea, this->borderPen); - graphics.DrawString(L"i", this->informationButtonArea, this->titleBarTextBrush); + graphics.FillRect(this->informationButtonArea, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(this->informationButtonArea, Gdiplus::Pen(this->brushes.border)); + graphics.DrawString(L"i", this->informationButtonArea, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/information", this->informationClickRect, false); // Options button - graphics.FillRect(this->optionsButtonArea, this->backgroundBrush); - graphics.DrawRect(this->optionsButtonArea, this->borderPen); - graphics.DrawString(L"o", this->optionsButtonArea, this->titleBarTextBrush); + graphics.FillRect(this->optionsButtonArea, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(this->optionsButtonArea, Gdiplus::Pen(this->brushes.border)); + graphics.DrawString(L"o", this->optionsButtonArea, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/options", this->optionsClickRect, false); } @@ -823,26 +820,26 @@ namespace UKControllerPlugin { const int screenObjectId) const { this->DrawRoundRectangle(graphics, minusButtonRect, 5); - graphics.DrawString(L"-", minusButtonRect, this->titleBarTextBrush); + graphics.DrawString(L"-", minusButtonRect, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/minus", this->minusButtonClickRect, false); this->DrawRoundRectangle(graphics, plusButtonRect, 5); - graphics.DrawString(L"+", plusButtonRect, this->titleBarTextBrush); + graphics.DrawString(L"+", plusButtonRect, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/plus", this->plusButtonClickRect, false); this->DrawRoundRectangle(graphics, addButtonRect, 5); - graphics.DrawString(L"ADD", addButtonRect, this->titleBarTextBrush); + graphics.DrawString(L"ADD", addButtonRect, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/add", this->addButtonClickRect, false); this->DrawRoundRectangle(graphics, allButtonRect, 5); - graphics.DrawString(L"ALL", allButtonRect, this->titleBarTextBrush); + graphics.DrawString(L"ALL", allButtonRect, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/allLevels", this->allButtonClickRect, false); - graphics.DrawLine(this->borderPen, this->underButtonLineLeft, this->underButtonLineRight); + graphics.DrawLine(Gdiplus::Pen(this->brushes.border), this->underButtonLineLeft, this->underButtonLineRight); } /* @@ -859,7 +856,7 @@ namespace UKControllerPlugin { // Render the background Gdiplus::Rect backgroundRect = this->GetHoldViewBackgroundRender(holdingAircraft); - graphics.FillRect(backgroundRect, this->backgroundBrush); + graphics.FillRect(backgroundRect, Gdiplus::SolidBrush(this->brushes.background)); // Render the title bar this->RenderTitleBar(graphics, radarScreen, screenObjectId); @@ -916,11 +913,11 @@ namespace UKControllerPlugin { // Render the restrictions if (levelRestricted) { - graphics.FillRect(holdRow, this->blockedLevelBrush); + graphics.FillRect(holdRow, Gdiplus::SolidBrush(this->brushes.border)); } // Render the numbers - graphics.DrawString(GetLevelDisplayString(level), numbersDisplay, this->titleBarTextBrush); + graphics.DrawString(GetLevelDisplayString(level), numbersDisplay, Gdiplus::SolidBrush(this->brushes.text)); // Increase the lines holdRow.Y = holdRow.Y + this->lineHeight; @@ -947,12 +944,12 @@ namespace UKControllerPlugin { ++it) { // Render the restrictions if (levelRestricted) { - graphics.FillRect(holdRow, this->blockedLevelBrush); + graphics.FillRect(holdRow, Gdiplus::SolidBrush(this->brushes.border)); } // Render the numbers if (aircraftIndex == 0) { - graphics.DrawString(GetLevelDisplayString(level), numbersDisplay, this->titleBarTextBrush); + graphics.DrawString(GetLevelDisplayString(level), numbersDisplay, Gdiplus::SolidBrush(this->brushes.text)); } rt = this->plugin.GetRadarTargetForCallsign((*it)->GetCallsign()); @@ -965,7 +962,7 @@ namespace UKControllerPlugin { // Callsign std::wstring callsign = ConvertToTchar((*it)->GetCallsign()); - graphics.DrawString(callsign, callsignDisplay, this->dataBrush); + graphics.DrawString(callsign, callsignDisplay, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/callsign/" + fp->GetCallsign(), @@ -977,7 +974,7 @@ namespace UKControllerPlugin { // Reported level graphics.DrawString( - GetLevelDisplayString(rt->GetFlightLevel()), actualLevelDisplay, this->dataBrush); + GetLevelDisplayString(rt->GetFlightLevel()), actualLevelDisplay, Gdiplus::SolidBrush(this->brushes.text)); if (GetVerticalSpeedDirection(rt->GetVerticalSpeed()) == 1) { graphics.DrawLine( this->verticalSpeedAscentPen, @@ -995,7 +992,7 @@ namespace UKControllerPlugin { fp->GetClearedAltitude() == 0 ? L"---" : GetLevelDisplayString(fp->GetClearedAltitude()), clearedLevelDisplay, - this->clearedLevelBrush); + Gdiplus::SolidBrush(this->brushes.highlightedAircraftText)); radarScreen.RegisterScreenObject( screenObjectId, this->navaid.identifier + "/cleared/" + fp->GetCallsign(), @@ -1010,7 +1007,7 @@ namespace UKControllerPlugin { auto holdProximity = (*it)->GetProximityHold(navaid.identifier); if (holdProximity != nullptr && holdProximity->HasEntered()) { std::wstring timeString = GetTimeInHoldDisplayString(holdProximity->EnteredAt()); - graphics.DrawString(timeString, timeInHoldDisplay, this->dataBrush); + graphics.DrawString(timeString, timeInHoldDisplay, Gdiplus::SolidBrush(this->brushes.text)); } } } @@ -1035,7 +1032,7 @@ namespace UKControllerPlugin { holdRow.Y - (static_cast(aircraftAtLevel.size()) * this->lineHeight), holdRow.Width - 20, (static_cast(aircraftAtLevel.size()) * this->lineHeight)}; - graphics.DrawRect(boundingBox, this->sameLevelBoxPen); + graphics.DrawRect(boundingBox, Gdiplus::Pen(this->brushes.text)); } } } @@ -1047,7 +1044,7 @@ namespace UKControllerPlugin { this->windowPos.y, this->windowPos.x + this->windowWidth, holdRow.Y + this->lineHeight}, - this->borderPen); + Gdiplus::Pen(this->brushes.border)); } void HoldDisplay::PaintWindow( diff --git a/src/plugin/hold/HoldDisplay.h b/src/plugin/hold/HoldDisplay.h index 8fab1d317..0769ff6f6 100644 --- a/src/plugin/hold/HoldDisplay.h +++ b/src/plugin/hold/HoldDisplay.h @@ -21,6 +21,7 @@ namespace UKControllerPlugin { } // namespace Navaids namespace Windows { class GdiGraphicsInterface; + struct GdiplusBrushes; } // namespace Windows } // namespace UKControllerPlugin @@ -42,6 +43,7 @@ namespace UKControllerPlugin { const Navaids::Navaid& navaid, const PublishedHoldCollection& publishedHoldCollection, const Dialog::DialogManager& dialogManager, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, std::shared_ptr addAircraftSelector); void ButtonClicked(std::string button); void ButtonRightClicked(const std::string& button); @@ -171,17 +173,19 @@ namespace UKControllerPlugin { std::shared_ptr addAircraftSelector; // Brushes - const Gdiplus::SolidBrush titleBarTextBrush; - const Gdiplus::SolidBrush titleBarBrush; - const Gdiplus::SolidBrush dataBrush; - const Gdiplus::SolidBrush clearedLevelBrush; - const Gdiplus::SolidBrush blockedLevelBrush; - const Gdiplus::Pen borderPen; - const Gdiplus::Pen sameLevelBoxPen; + // const Gdiplus::SolidBrush titleBarTextBrush; + // const Gdiplus::SolidBrush titleBarBrush; + // const Gdiplus::SolidBrush dataBrush; + // const Gdiplus::SolidBrush clearedLevelBrush; + // const Gdiplus::SolidBrush blockedLevelBrush; + // const Gdiplus::Pen borderPen; + // const Gdiplus::Pen sameLevelBoxPen; Gdiplus::Pen verticalSpeedAscentPen; Gdiplus::Pen verticalSpeedDescentPen; - const Gdiplus::SolidBrush exitButtonBrush; - const Gdiplus::SolidBrush backgroundBrush; + // const Gdiplus::SolidBrush exitButtonBrush; + // const Gdiplus::SolidBrush backgroundBrush; + + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; // Fonts const Gdiplus::FontFamily fontFamily; diff --git a/src/plugin/hold/HoldDisplayFactory.cpp b/src/plugin/hold/HoldDisplayFactory.cpp index ad3c42f9f..747a8514a 100644 --- a/src/plugin/hold/HoldDisplayFactory.cpp +++ b/src/plugin/hold/HoldDisplayFactory.cpp @@ -9,12 +9,14 @@ #include "dialog/DialogManager.h" #include "euroscope/EuroscopePluginLoopbackInterface.h" #include "navaids/NavaidCollection.h" +#include "graphics/GdiplusBrushes.h" using UKControllerPlugin::Dialog::DialogManager; using UKControllerPlugin::Euroscope::EuroscopePluginLoopbackInterface; using UKControllerPlugin::Hold::HoldManager; using UKControllerPlugin::Navaids::Navaid; using UKControllerPlugin::Navaids::NavaidCollection; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin { namespace Hold { @@ -25,9 +27,10 @@ namespace UKControllerPlugin { const NavaidCollection& navaids, const PublishedHoldCollection& holds, const DialogManager& dialogManager, - const Aircraft::CallsignSelectionListFactory& addAircraftListFactory) + const Aircraft::CallsignSelectionListFactory& addAircraftListFactory, + const GdiplusBrushes& brushes) : plugin(plugin), holdManager(holdManager), navaids(navaids), holds(holds), dialogManager(dialogManager), - addAircraftListFactory(addAircraftListFactory) + addAircraftListFactory(addAircraftListFactory), brushes(brushes) { } @@ -48,6 +51,7 @@ namespace UKControllerPlugin { navaidData, holds, dialogManager, + brushes, addAircraftListFactory.Create( std::make_shared(navaidData, holdManager, plugin), "Add to hold " + navaidData.identifier)); diff --git a/src/plugin/hold/HoldDisplayFactory.h b/src/plugin/hold/HoldDisplayFactory.h index a1807d035..eaafbcc66 100644 --- a/src/plugin/hold/HoldDisplayFactory.h +++ b/src/plugin/hold/HoldDisplayFactory.h @@ -13,6 +13,9 @@ namespace UKControllerPlugin { namespace Navaids { class NavaidCollection; } // namespace Navaids + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin { @@ -26,14 +29,14 @@ namespace UKControllerPlugin { */ class HoldDisplayFactory { - public: - HoldDisplayFactory( + public: HoldDisplayFactory( UKControllerPlugin::Euroscope::EuroscopePluginLoopbackInterface& plugin, UKControllerPlugin::Hold::HoldManager& holdManager, const UKControllerPlugin::Navaids::NavaidCollection& navaids, const UKControllerPlugin::Hold::PublishedHoldCollection& holds, const UKControllerPlugin::Dialog::DialogManager& dialogManager, - const Aircraft::CallsignSelectionListFactory& addAircraftListFactory); + const Aircraft::CallsignSelectionListFactory& addAircraftListFactory, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes); [[nodiscard]] auto Create(std::string navaid) const -> std::unique_ptr; @@ -55,6 +58,9 @@ namespace UKControllerPlugin { // For creating the callsign selection lists const Aircraft::CallsignSelectionListFactory& addAircraftListFactory; + + // Brushes + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; }; } // namespace Hold } // namespace UKControllerPlugin diff --git a/src/plugin/hold/HoldModule.cpp b/src/plugin/hold/HoldModule.cpp index 15968ce58..677ee6eed 100644 --- a/src/plugin/hold/HoldModule.cpp +++ b/src/plugin/hold/HoldModule.cpp @@ -35,6 +35,7 @@ #include "tag/TagFunction.h" #include "timedevent/TimedEventCollection.h" #include "windows/WinApiInterface.h" +#include "graphics/GdiplusBrushes.h" using UKControllerPlugin::Api::ApiException; using UKControllerPlugin::Api::ApiInterface; @@ -57,6 +58,7 @@ using UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection; using UKControllerPlugin::RadarScreen::RadarRenderableCollection; using UKControllerPlugin::Tag::TagFunction; using UKControllerPlugin::Windows::WinApiInterface; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin::Hold { @@ -138,7 +140,8 @@ namespace UKControllerPlugin::Hold { *container.navaids, *container.publishedHolds, *container.dialogManager, - *container.callsignSelectionListFactory); + *container.callsignSelectionListFactory, + *container.brushes); // Command to assign holds container.commandHandlers->RegisterHandler( @@ -190,6 +193,7 @@ namespace UKControllerPlugin::Hold { RadarRenderableCollection& radarRenderables, AsrEventHandlerCollection& asrEvents, CommandHandlerCollection& commandHandlers, + const GdiplusBrushes& brushes, const PersistenceContainer& container) { // Display manager diff --git a/src/plugin/hold/HoldModule.h b/src/plugin/hold/HoldModule.h index 86c2acd46..07cc8eb54 100644 --- a/src/plugin/hold/HoldModule.h +++ b/src/plugin/hold/HoldModule.h @@ -26,6 +26,9 @@ namespace UKControllerPlugin { namespace Command { class CommandHandlerCollection; } // namespace Command + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin::Hold { @@ -42,6 +45,7 @@ namespace UKControllerPlugin::Hold { UKControllerPlugin::RadarScreen::RadarRenderableCollection& radarRenderables, UKControllerPlugin::Euroscope::AsrEventHandlerCollection& asrEvents, UKControllerPlugin::Command::CommandHandlerCollection& commandHandlers, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, const UKControllerPlugin::Bootstrap::PersistenceContainer& container); [[nodiscard]] auto GetDependencyKey() -> std::string; diff --git a/src/plugin/minstack/MinStackModule.cpp b/src/plugin/minstack/MinStackModule.cpp index 69bf38276..490190a8e 100644 --- a/src/plugin/minstack/MinStackModule.cpp +++ b/src/plugin/minstack/MinStackModule.cpp @@ -70,6 +70,7 @@ namespace UKControllerPlugin::MinStack { MinStackManager& minStackManager, RadarRenderableCollection& radarRender, ConfigurableDisplayCollection& configurableDisplays, + const GdiplusBrushes& brushes, AsrEventHandlerCollection& userSettingHandlers, const DialogManager& dialogManager) { @@ -82,6 +83,7 @@ namespace UKControllerPlugin::MinStack { radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), configureFunctionId, + brushes, dialogManager)); // Add to the handlers. diff --git a/src/plugin/minstack/MinStackModule.h b/src/plugin/minstack/MinStackModule.h index 156b4535e..4974204e4 100644 --- a/src/plugin/minstack/MinStackModule.h +++ b/src/plugin/minstack/MinStackModule.h @@ -20,6 +20,9 @@ namespace UKControllerPlugin { namespace MinStack { class MinStackManager; } // namespace MinStack + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows namespace Curl { class CurlInterface; } // namespace Curl @@ -49,6 +52,7 @@ namespace UKControllerPlugin { UKControllerPlugin::MinStack::MinStackManager& minStackManager, UKControllerPlugin::RadarScreen::RadarRenderableCollection& radarRender, UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection& configurableDisplays, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, UKControllerPlugin::Euroscope::AsrEventHandlerCollection& userSettingHandlers, const UKControllerPlugin::Dialog::DialogManager& dialogManager); }; diff --git a/src/plugin/minstack/MinStackRenderer.cpp b/src/plugin/minstack/MinStackRenderer.cpp index ef717fa6c..70e141630 100644 --- a/src/plugin/minstack/MinStackRenderer.cpp +++ b/src/plugin/minstack/MinStackRenderer.cpp @@ -25,8 +25,9 @@ namespace UKControllerPlugin::MinStack { int menuBarClickspotId, int mslClickspotId, int toggleCallbackFunctionId, + const GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager) - : minStackModule(minStackModule), dialogManager(dialogManager), + : brushes(brushes), minStackModule(minStackModule), dialogManager(dialogManager), hideClickspotId(closeClickspotId), menuBarClickspotId(menuBarClickspotId), mslClickspotId(mslClickspotId), toggleCallbackFunctionId(toggleCallbackFunctionId) { @@ -211,17 +212,17 @@ namespace UKControllerPlugin::MinStack { const MinStackLevel& mslData = this->minStackModule.GetMinStackLevel(minStack.key); // Draw the TMA title and rectangles - graphics.FillRect(tma, *currentBackground); - graphics.DrawRect(tma, *currentBorder); + graphics.FillRect(tma, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(tma, Gdiplus::Pen(this->brushes.border)); graphics.DrawString( HelperFunctions::ConvertToWideString(MinStackManager::GetNameFromKey(minStack.key)), tma, - mslData.IsAcknowledged() ? *currentAcknowledge : *currentText); + mslData.IsAcknowledged() ? Gdiplus::SolidBrush(this->brushes.acknowledge) : Gdiplus::SolidBrush(this->brushes.text)); // Draw the MSL itself and associated rectangles - graphics.FillRect(msl, *currentBackground); - graphics.DrawRect(msl, *currentBorder); + graphics.FillRect(msl, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(msl, Gdiplus::Pen(this->brushes.border)); std::string mslString = mslData == this->minStackModule.InvalidMsl() ? "-" : std::to_string(mslData.msl).substr(0, 2); @@ -229,7 +230,7 @@ namespace UKControllerPlugin::MinStack { graphics.DrawString( HelperFunctions::ConvertToWideString(mslString), msl, - mslData.IsAcknowledged() ? *currentAcknowledge : *currentText); + mslData.IsAcknowledged() ? Gdiplus::SolidBrush(this->brushes.acknowledge) : Gdiplus::SolidBrush(this->brushes.text)); // Add the clickable area. radarScreen.RegisterScreenObject( @@ -258,7 +259,7 @@ namespace UKControllerPlugin::MinStack { this->topBarArea.top, this->leftColumnWidth + this->hideClickspotWidth, 1 + ((numMinStacks) * this->rowHeight)}; - graphics.DrawRect(area, *currentBorder); + graphics.DrawRect(area, Gdiplus::Pen(this->brushes.border)); } /* @@ -267,15 +268,15 @@ namespace UKControllerPlugin::MinStack { void MinStackRenderer::RenderTopBar(GdiGraphicsInterface& graphics, EuroscopeRadarLoopbackInterface& radarScreen) { // The title bar - the draggable bit - graphics.DrawRect(this->topBarRender, *currentBorder); - graphics.FillRect(this->topBarRender, *currentHeaders); - graphics.DrawString(L"MSL", this->topBarRender, *currentText); + graphics.DrawRect(this->topBarRender, Gdiplus::Pen(this->brushes.border)); + graphics.FillRect(this->topBarRender, Gdiplus::SolidBrush(this->brushes.header)); + graphics.DrawString(L"MSL", this->topBarRender, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject(this->menuBarClickspotId, "", this->topBarArea, true); // The toggle button - no draggable - graphics.DrawRect(this->hideSpotRender, *currentBorder); - graphics.FillRect(this->hideSpotRender, *currentHeaders); - graphics.DrawString(L"X", this->hideSpotRender, *currentText); + graphics.DrawRect(this->hideSpotRender, Gdiplus::Pen(this->brushes.border)); + graphics.FillRect(this->hideSpotRender, Gdiplus::SolidBrush(this->brushes.header)); + graphics.DrawString(L"X", this->hideSpotRender, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject(this->hideClickspotId, "", this->hideClickspotArea, false); } diff --git a/src/plugin/minstack/MinStackRenderer.h b/src/plugin/minstack/MinStackRenderer.h index 3361d059f..7b02db923 100644 --- a/src/plugin/minstack/MinStackRenderer.h +++ b/src/plugin/minstack/MinStackRenderer.h @@ -5,7 +5,6 @@ #include "plugin/PopupMenuItem.h" #include "radarscreen/ConfigurableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" -#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Euroscope { @@ -38,6 +37,7 @@ namespace UKControllerPlugin::MinStack { int menuBarClickspotId, int mslClickspotId, int toggleCallbackFunctionId, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager); void AsrLoadedEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void AsrClosingEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; @@ -108,21 +108,8 @@ namespace UKControllerPlugin::MinStack { // The rectangle to render for the hide clickspot Gdiplus::Rect hideSpotRender; - // Colour Brushes - const std::unique_ptr currentBackground = - std::make_unique(UKControllerPlugin::Graphics::Background); - - const std::unique_ptr currentHeaders = - std::make_unique(UKControllerPlugin::Graphics::Headers); - - const std::unique_ptr currentBorder = - std::make_unique(UKControllerPlugin::Graphics::Border); - - const std::unique_ptr currentText = - std::make_unique(UKControllerPlugin::Graphics::DefaultText); - - const std::unique_ptr currentAcknowledge = - std::make_unique(UKControllerPlugin::Graphics::HighlightedAircraftText); + // Brushes + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; // The configuration for the renderer UKControllerPlugin::MinStack::MinStackRendererConfiguration config; diff --git a/src/plugin/radarscreen/RadarScreenFactory.cpp b/src/plugin/radarscreen/RadarScreenFactory.cpp index 1e06f1b00..27d9b34cc 100644 --- a/src/plugin/radarscreen/RadarScreenFactory.cpp +++ b/src/plugin/radarscreen/RadarScreenFactory.cpp @@ -66,7 +66,7 @@ namespace UKControllerPlugin::RadarScreen { SectorFile::BootstrapRadarScreen(persistence, userSettingHandlers); GeneralSettingsConfigurationBootstrap::BootstrapRadarScreen( - *persistence.pluginFunctionHandlers, configurableDisplays, commandHandlers, *persistence.dialogManager); + *persistence.pluginFunctionHandlers, configurableDisplays, *persistence.brushes, commandHandlers, *persistence.dialogManager); HistoryTrailModule::BootstrapRadarScreen( *persistence.pluginFunctionHandlers, @@ -83,6 +83,7 @@ namespace UKControllerPlugin::RadarScreen { *persistence.minStack, renderers, configurableDisplays, + *persistence.brushes, userSettingHandlers, *persistence.dialogManager); @@ -91,6 +92,7 @@ namespace UKControllerPlugin::RadarScreen { *persistence.regionalPressureManager, renderers, configurableDisplays, + *persistence.brushes, userSettingHandlers, *persistence.dialogManager); @@ -100,10 +102,11 @@ namespace UKControllerPlugin::RadarScreen { persistence.timerConfigurationManager, renderers, configurableDisplays, + *persistence.brushes, userSettingHandlers); Hold::BootstrapRadarScreen( - configurableDisplays, renderers, userSettingHandlers, commandHandlers, this->persistence); + configurableDisplays, renderers, userSettingHandlers, commandHandlers, *persistence.brushes, this->persistence); Srd::BootstrapRadarScreen(configurableDisplays); Notifications::BootstrapRadarScreen(this->persistence, configurableDisplays); @@ -111,7 +114,7 @@ namespace UKControllerPlugin::RadarScreen { PrenoteModule::BootstrapRadarScreen(this->persistence, renderers); Departure::BootstrapRadarScreen(this->persistence, renderers, configurableDisplays, userSettingHandlers); MissedApproach::BootstrapRadarScreen(this->persistence, renderers, configurableDisplays, userSettingHandlers); - Wake::BootstrapRadarScreen(this->persistence, renderers, userSettingHandlers, displayFactory); + Wake::BootstrapRadarScreen(this->persistence, renderers, userSettingHandlers, displayFactory, *persistence.brushes); this->persistence.bootstrapProviders->BootstrapRadarScreen( this->persistence, renderers, configurableDisplays, userSettingHandlers, displayFactory); diff --git a/src/plugin/radarscreen/ScreenControls.cpp b/src/plugin/radarscreen/ScreenControls.cpp index d418d39ee..3edd86855 100644 --- a/src/plugin/radarscreen/ScreenControls.cpp +++ b/src/plugin/radarscreen/ScreenControls.cpp @@ -80,8 +80,8 @@ namespace UKControllerPlugin::RadarScreen { RECT radarArea = radarScreen.GetRadarViewport(); Gdiplus::Rect renderArea = { radarArea.right - controlWidth, radarArea.bottom - controlHeight, controlWidth, controlHeight}; - graphics.FillRect(renderArea, *this->brushes.euroscopeBackgroundBrush); - graphics.DrawString(L"OP", renderArea, *this->brushes.greenBrush); + graphics.FillRect(renderArea, Gdiplus::SolidBrush(this->brushes.euroscopeBackground)); + graphics.DrawString(L"OP", renderArea, Gdiplus::SolidBrush(this->brushes.green)); radarScreen.RegisterScreenObject( toggleboxIdEuroscope, "", diff --git a/src/plugin/regional/RegionalPressureModule.cpp b/src/plugin/regional/RegionalPressureModule.cpp index b5c56e433..34383a8cf 100644 --- a/src/plugin/regional/RegionalPressureModule.cpp +++ b/src/plugin/regional/RegionalPressureModule.cpp @@ -73,6 +73,7 @@ namespace UKControllerPlugin { RegionalPressureManager& regionalPressureManager, RadarRenderableCollection& radarRender, ConfigurableDisplayCollection& configurableDisplays, + const GdiplusBrushes& brushes, AsrEventHandlerCollection& userSettingHandlers, const DialogManager& dialogManager) { @@ -85,6 +86,7 @@ namespace UKControllerPlugin { radarRender.ReserveScreenObjectIdentifier(rendererId), radarRender.ReserveScreenObjectIdentifier(rendererId), configureFunctionId, + brushes, dialogManager)); // Add to the handlers. diff --git a/src/plugin/regional/RegionalPressureModule.h b/src/plugin/regional/RegionalPressureModule.h index 06b401bf4..8918cd1c4 100644 --- a/src/plugin/regional/RegionalPressureModule.h +++ b/src/plugin/regional/RegionalPressureModule.h @@ -54,6 +54,7 @@ namespace UKControllerPlugin { UKControllerPlugin::Regional::RegionalPressureManager& regionalPressureManager, UKControllerPlugin::RadarScreen::RadarRenderableCollection& radarRender, UKControllerPlugin::RadarScreen::ConfigurableDisplayCollection& configurableDisplays, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, UKControllerPlugin::Euroscope::AsrEventHandlerCollection& userSettingHandlers, const UKControllerPlugin::Dialog::DialogManager& dialogManager); }; diff --git a/src/plugin/regional/RegionalPressureRenderer.cpp b/src/plugin/regional/RegionalPressureRenderer.cpp index 0082f1a34..2e20db62b 100644 --- a/src/plugin/regional/RegionalPressureRenderer.cpp +++ b/src/plugin/regional/RegionalPressureRenderer.cpp @@ -22,8 +22,9 @@ namespace UKControllerPlugin::Regional { int menuBarClickspotId, int rpsClickspotId, int toggleCallbackFunctionId, + const GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager) - : manager(manager), dialogManager(dialogManager), hideClickspotId(closeClickspotId), + : brushes(brushes), manager(manager), dialogManager(dialogManager), hideClickspotId(closeClickspotId), menuBarClickspotId(menuBarClickspotId), rpsClickspotId(rpsClickspotId), toggleCallbackFunctionId(toggleCallbackFunctionId) { @@ -210,17 +211,17 @@ namespace UKControllerPlugin::Regional { const RegionalPressure& pressureData = this->manager.GetRegionalPressure(it->key); // Draw the TMA title and rectangles - graphics.FillRect(asr, *currentBackground); - graphics.DrawRect(asr, *currentBorder); + graphics.FillRect(asr, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(asr, Gdiplus::Pen(this->brushes.border)); graphics.DrawString( HelperFunctions::ConvertToWideString(this->manager.GetNameFromKey(it->key)), asr, - pressureData.IsAcknowledged() ? *currentAcknowledge : *currentText); + pressureData.IsAcknowledged() ? Gdiplus::SolidBrush(this->brushes.acknowledge) : Gdiplus::SolidBrush(this->brushes.text)); // Draw the RPS itself and associated rectangles - graphics.FillRect(rps, *currentBackground); - graphics.DrawRect(rps, *currentBorder); + graphics.FillRect(rps, Gdiplus::SolidBrush(this->brushes.background)); + graphics.DrawRect(rps, Gdiplus::Pen(this->brushes.border)); std::string rpsString; if (pressureData == this->manager.invalidPressure) { @@ -234,7 +235,7 @@ namespace UKControllerPlugin::Regional { graphics.DrawString( HelperFunctions::ConvertToWideString(rpsString), rps, - pressureData.IsAcknowledged() ? *currentAcknowledge : *currentText); + pressureData.IsAcknowledged() ? Gdiplus::SolidBrush(this->brushes.acknowledge) : Gdiplus::SolidBrush(this->brushes.text)); // Add the clickable area. radarScreen.RegisterScreenObject( @@ -260,7 +261,7 @@ namespace UKControllerPlugin::Regional { this->topBarArea.top, LEFT_COLUMN_WIDTH + HIDE_CLICKSPOT_WIDTH, 1 + ((numRegionalPressures)*ROW_HEIGHT)}; - graphics.DrawRect(area, *currentBorder); + graphics.DrawRect(area, Gdiplus::Pen(this->brushes.border)); } /* @@ -270,15 +271,15 @@ namespace UKControllerPlugin::Regional { RegionalPressureRenderer::RenderTopBar(GdiGraphicsInterface& graphics, EuroscopeRadarLoopbackInterface& radarScreen) { // The title bar - the draggable bit - graphics.DrawRect(this->topBarRender, *currentBorder); - graphics.FillRect(this->topBarRender, *currentHeaders); - graphics.DrawString(L"ASR", this->topBarRender, *currentText); + graphics.DrawRect(this->topBarRender, Gdiplus::Pen(this->brushes.border)); + graphics.FillRect(this->topBarRender, Gdiplus::SolidBrush(this->brushes.header)); + graphics.DrawString(L"ASR", this->topBarRender, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject(this->menuBarClickspotId, "", this->topBarArea, true); // The toggle button - no draggable - graphics.DrawRect(this->hideSpotRender, *currentBorder); - graphics.FillRect(this->hideSpotRender, *currentHeaders); - graphics.DrawString(L"X", this->hideSpotRender, *currentText); + graphics.DrawRect(this->hideSpotRender, Gdiplus::Pen(this->brushes.border)); + graphics.FillRect(this->hideSpotRender, Gdiplus::SolidBrush(this->brushes.header)); + graphics.DrawString(L"X", this->hideSpotRender, Gdiplus::SolidBrush(this->brushes.text)); radarScreen.RegisterScreenObject(this->hideClickspotId, "", this->hideClickspotArea, false); } diff --git a/src/plugin/regional/RegionalPressureRenderer.h b/src/plugin/regional/RegionalPressureRenderer.h index bbb774f5e..88c80af53 100644 --- a/src/plugin/regional/RegionalPressureRenderer.h +++ b/src/plugin/regional/RegionalPressureRenderer.h @@ -5,7 +5,6 @@ #include "plugin/PopupMenuItem.h" #include "radarscreen/ConfigurableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" -#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Euroscope { @@ -36,6 +35,7 @@ namespace UKControllerPlugin::Regional { int menuBarClickspotId, int rpsClickspotId, int toggleCallbackFunctionId, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, const UKControllerPlugin::Dialog::DialogManager& dialogManager); void AsrLoadedEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; void AsrClosingEvent(UKControllerPlugin::Euroscope::UserSetting& userSetting) override; @@ -88,21 +88,8 @@ namespace UKControllerPlugin::Regional { // The rectangle to render for the hide clickspot Gdiplus::Rect hideSpotRender; - // Colour Brushes - const std::unique_ptr currentBackground = - std::make_unique(UKControllerPlugin::Graphics::Background); - - const std::unique_ptr currentHeaders = - std::make_unique(UKControllerPlugin::Graphics::Headers); - - const std::unique_ptr currentBorder = - std::make_unique(UKControllerPlugin::Graphics::Border); - - const std::unique_ptr currentText = - std::make_unique(UKControllerPlugin::Graphics::DefaultText); - - const std::unique_ptr currentAcknowledge = - std::make_unique(UKControllerPlugin::Graphics::HighlightedAircraftText); + // Brushes + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; // The configuration for the renderer UKControllerPlugin::Regional::RegionalPressureRendererConfiguration config; diff --git a/src/plugin/wake/WakeCalculatorDisplay.h b/src/plugin/wake/WakeCalculatorDisplay.h index 9f5b426ca..b4c8dc5ea 100644 --- a/src/plugin/wake/WakeCalculatorDisplay.h +++ b/src/plugin/wake/WakeCalculatorDisplay.h @@ -2,7 +2,6 @@ #include "euroscope/AsrEventHandlerInterface.h" #include "radarscreen/MenuToggleableDisplayInterface.h" #include "radarscreen/RadarRenderableInterface.h" -#include "graphics/GlobalColours.h" namespace UKControllerPlugin { namespace Components { @@ -15,6 +14,10 @@ namespace UKControllerPlugin { namespace Euroscope { class EuroscopePluginLoopbackInterface; } // namespace Euroscope + namespace Windows { + class GdiGraphicsInterface; + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin::Wake { @@ -33,6 +36,7 @@ namespace UKControllerPlugin::Wake { std::shared_ptr followCallsignSelector, std::shared_ptr wakeSchemeSelector, Euroscope::EuroscopePluginLoopbackInterface& plugin, + const UKControllerPlugin::Windows::GdiplusBrushes& brushes, int screenObjectId); [[nodiscard]] auto IsVisible() const -> bool override; [[nodiscard]] auto IsCollapsed() const -> bool; @@ -97,13 +101,7 @@ namespace UKControllerPlugin::Wake { std::shared_ptr titleBar; // Pens and brushes - const Gdiplus::Color BACKGROUND_COLOUR = UKControllerPlugin::Graphics::Background; - const Gdiplus::Color TEXT_COLOUR = UKControllerPlugin::Graphics::DefaultText; - const Gdiplus::Color RESULT_COLOUR = UKControllerPlugin::Graphics::HighlightedText; - std::shared_ptr backgroundBrush; - std::shared_ptr textBrush; - std::shared_ptr resultBrush; - std::shared_ptr dividingLinePen; + const UKControllerPlugin::Windows::GdiplusBrushes& brushes; // Drawing rects Gdiplus::Rect contentArea; diff --git a/src/plugin/wake/WakeModule.cpp b/src/plugin/wake/WakeModule.cpp index 3a4856305..96f5e2190 100644 --- a/src/plugin/wake/WakeModule.cpp +++ b/src/plugin/wake/WakeModule.cpp @@ -22,10 +22,12 @@ #include "radarscreen/MenuToggleableDisplayFactory.h" #include "radarscreen/RadarRenderableCollection.h" #include "tag/TagItemCollection.h" +#include "graphics/GdiplusBrushes.h" using UKControllerPlugin::Bootstrap::PersistenceContainer; using UKControllerPlugin::Dependency::DependencyLoaderInterface; using UKControllerPlugin::Wake::WakeCategoryEventHandler; +using UKControllerPlugin::Windows::GdiplusBrushes; namespace UKControllerPlugin::Wake { @@ -74,7 +76,8 @@ namespace UKControllerPlugin::Wake { const Bootstrap::PersistenceContainer& container, RadarScreen::RadarRenderableCollection& renderables, Euroscope::AsrEventHandlerCollection& asrHandlers, - const RadarScreen::MenuToggleableDisplayFactory& toggleableDisplayFactory) + const RadarScreen::MenuToggleableDisplayFactory& toggleableDisplayFactory, + const GdiplusBrushes& brushes) { auto options = std::make_shared(); options->Scheme("UK"); @@ -99,6 +102,7 @@ namespace UKControllerPlugin::Wake { std::make_shared(options, *container.wakeSchemes, *container.aircraftTypeMapper), "Wake Calculator Scheme"), *container.plugin, + *container.brushes, renderables.ReserveScreenObjectIdentifier(rendererId)); renderables.RegisterRenderer(rendererId, renderer, RadarScreen::RadarRenderableCollection::afterLists); diff --git a/src/plugin/wake/WakeModule.h b/src/plugin/wake/WakeModule.h index c07020672..8f79048a7 100644 --- a/src/plugin/wake/WakeModule.h +++ b/src/plugin/wake/WakeModule.h @@ -14,6 +14,9 @@ namespace UKControllerPlugin { class MenuToggleableDisplayFactory; class RadarRenderableCollection; } // namespace RadarScreen + namespace Windows { + struct GdiplusBrushes; + } // namespace Windows } // namespace UKControllerPlugin namespace UKControllerPlugin::Wake { @@ -26,5 +29,6 @@ namespace UKControllerPlugin::Wake { const UKControllerPlugin::Bootstrap::PersistenceContainer& container, RadarScreen::RadarRenderableCollection& renderables, Euroscope::AsrEventHandlerCollection& asrHandlers, - const RadarScreen::MenuToggleableDisplayFactory& toggleableDisplayFactory); + const RadarScreen::MenuToggleableDisplayFactory& toggleableDisplayFactory, + const Windows::GdiplusBrushes& brushes); } // namespace UKControllerPlugin::Wake From aeaeb648bee7daab13f3c11f27e45419eb7c1e00 Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Thu, 7 Aug 2025 00:36:07 +0100 Subject: [PATCH 08/17] (WIP) Add Background to Departure Requests Initial work on this (WIP) --- src/plugin/departure/DepartureCoordinationList.cpp | 13 +++++++++++++ src/plugin/departure/DepartureCoordinationList.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/plugin/departure/DepartureCoordinationList.cpp b/src/plugin/departure/DepartureCoordinationList.cpp index 59e58b885..53657af0a 100644 --- a/src/plugin/departure/DepartureCoordinationList.cpp +++ b/src/plugin/departure/DepartureCoordinationList.cpp @@ -123,6 +123,19 @@ namespace UKControllerPlugin::Departure { if (this->contentCollapsed) { return; } + + // Calculate dynamic height based on number of items + const int totalItems = static_cast(decisions.size() + prenoteMessages.size()); + const int headerHeight = 30; // Height for column headers + const int minHeight = 50; // Minimum height even when no items + const int calculatedHeight = headerHeight + (totalItems * lineHeight); + const int dynamicHeight = calculatedHeight > minHeight ? calculatedHeight : minHeight; + + // Update content area with dynamic height + this->contentArea = {0, 0, 435, dynamicHeight}; + + graphics.FillRect(this->contentArea, Gdiplus::SolidBrush(this->brushes.background)); + // Draw column headers graphics.DrawString(L"Type", this->typeColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); graphics.DrawString(L"Callsign", this->callsignColumnHeader, Gdiplus::SolidBrush(this->brushes.text)); diff --git a/src/plugin/departure/DepartureCoordinationList.h b/src/plugin/departure/DepartureCoordinationList.h index 880283b06..2dd3b64dc 100644 --- a/src/plugin/departure/DepartureCoordinationList.h +++ b/src/plugin/departure/DepartureCoordinationList.h @@ -87,6 +87,7 @@ namespace UKControllerPlugin::Departure { const Controller::ActiveCallsignCollection& activeCallsigns; // Drawing RECTs + Gdiplus::Rect contentArea{0, 0, 435, 400}; const Gdiplus::Rect typeColumnHeader{5, 5, 40, 25}; const Gdiplus::Rect callsignColumnHeader{50, 5, 100, 25}; const Gdiplus::Rect controllerColumnHeader{160, 5, 100, 25}; From fe5d14403c0e7c871eedf668d48ab34abb201f1a Mon Sep 17 00:00:00 2001 From: William Hinshaw <61280994+Hinshee@users.noreply.github.com> Date: Mon, 20 Oct 2025 20:58:24 +0100 Subject: [PATCH 09/17] Added: Standard Menu Buttons match selected theme --- .../approach/ApproachSequencerDisplay.cpp | 3 +- .../components/CollapsibleWindowTitleBar.cpp | 12 ++-- .../components/CollapsibleWindowTitleBar.h | 7 ++- src/plugin/components/StandardButtons.cpp | 60 ++++++++++++++++--- src/plugin/components/StandardButtons.h | 9 ++- .../departure/DepartureCoordinationList.cpp | 4 +- .../graphics/ColourPaletteDefinitions.cpp | 1 - 7 files changed, 74 insertions(+), 22 deletions(-) diff --git a/src/plugin/approach/ApproachSequencerDisplay.cpp b/src/plugin/approach/ApproachSequencerDisplay.cpp index aaa649aef..c3c3f0a13 100644 --- a/src/plugin/approach/ApproachSequencerDisplay.cpp +++ b/src/plugin/approach/ApproachSequencerDisplay.cpp @@ -48,7 +48,8 @@ namespace UKControllerPlugin::Approach { L"Approach Sequencer", titleBarArea, [this]() -> bool { return this->displayOptions->ContentCollapsed(); }, - screenObjectId)), + screenObjectId, + brushes)), airfieldClickspot(Components::ClickableArea::Create( this->airfieldTextArea, screenObjectId, AIRFIELD_SELECTOR_CLICKSPOT, false)), addClickspot( diff --git a/src/plugin/components/CollapsibleWindowTitleBar.cpp b/src/plugin/components/CollapsibleWindowTitleBar.cpp index 09703deca..72d2e5b25 100644 --- a/src/plugin/components/CollapsibleWindowTitleBar.cpp +++ b/src/plugin/components/CollapsibleWindowTitleBar.cpp @@ -5,27 +5,27 @@ namespace UKControllerPlugin::Components { CollapsibleWindowTitleBar::CollapsibleWindowTitleBar( - std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId) - : TitleBar(title, area) + std::wstring title, Gdiplus::Rect area, 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) + std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId, const Windows::GdiplusBrushes& brushes) { auto titlebar = std::shared_ptr( - new CollapsibleWindowTitleBar(title, area, collapseState, screenObjectId)); + new CollapsibleWindowTitleBar(title, area, collapseState, screenObjectId, brushes)); titlebar->WithDefaultBorder()->WithDefaultTextBrush()->WithDefaultBackgroundBrush()->WithDrag(screenObjectId); return titlebar; diff --git a/src/plugin/components/CollapsibleWindowTitleBar.h b/src/plugin/components/CollapsibleWindowTitleBar.h index 8d7ddf3fb..2ee65ba63 100644 --- a/src/plugin/components/CollapsibleWindowTitleBar.h +++ b/src/plugin/components/CollapsibleWindowTitleBar.h @@ -12,16 +12,19 @@ namespace UKControllerPlugin::Components { { public: static std::shared_ptr - Create(std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId); + Create(std::wstring title, Gdiplus::Rect area, 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& brushes) const override; protected: CollapsibleWindowTitleBar( - std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId); + std::wstring title, Gdiplus::Rect area, std::function collapseState, int screenObjectId, const Windows::GdiplusBrushes& brushes); private: + // The brushes for theming + const Windows::GdiplusBrushes& brushes; + // The close button std::shared_ptr