Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ILS_Window_Plugin/ILS_Window_Plugin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<ItemGroup>
<ClCompile Include="IWCdeMenuBtn.cpp" />
<ClCompile Include="IWCdeWindow.cpp" />
<ClCompile Include="IWSettings.cpp" />
<ClCompile Include="IWX11IconifyBtn.cpp" />
<ClCompile Include="IWCdeIconifyBtn.cpp" />
<ClCompile Include="IWX11MenuBtn.cpp" />
Expand All @@ -129,11 +130,13 @@
<ClCompile Include="IWCdeTitleBar.cpp" />
<ClCompile Include="IWVisualization.cpp" />
<ClCompile Include="IWX11TitleBar.cpp" />
<ClCompile Include="IWX11TitleBarBtnBase.cpp" />
<ClCompile Include="IWX11Window.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="IWWindowManager.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="ILS_Window_Plugin.def" />
Expand All @@ -145,6 +148,8 @@
<ClInclude Include="framework.h" />
<ClInclude Include="IWCdeMenuBtn.h" />
<ClInclude Include="IWCdeWindow.h" />
<ClInclude Include="IWContextMenu.h" />
<ClInclude Include="IWSettings.h" />
<ClInclude Include="IWX11IconifyBtn.h" />
<ClInclude Include="IWCdeIconifyBtn.h" />
<ClInclude Include="IWX11MenuBtn.h" />
Expand All @@ -158,12 +163,14 @@
<ClInclude Include="IWCdeTitleBar.h" />
<ClInclude Include="IWVisualization.h" />
<ClInclude Include="IWX11TitleBar.h" />
<ClInclude Include="IWX11TitleBarBtnBase.h" />
<ClInclude Include="IWX11Window.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="RenderUtils.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="IWUtils.h" />
<ClInclude Include="IWWindowManager.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ILS_Window_Plugin.rc" />
Expand Down
6 changes: 6 additions & 0 deletions ILS_Window_Plugin/ILS_Window_Plugin.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<ClCompile Include="IWX11Window.cpp">
<Filter>Source Files\Theme\X11</Filter>
</ClCompile>
<ClCompile Include="IWContextMenu.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="ILS_Window_Plugin.def">
Expand Down Expand Up @@ -163,6 +166,9 @@
<ClInclude Include="IWX11Window.h">
<Filter>Header Files\Theme\X11</Filter>
</ClInclude>
<ClInclude Include="IWContextMenu.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ILS_Window_Plugin.rc">
Expand Down
4 changes: 2 additions & 2 deletions ILS_Window_Plugin/IWCdeIconifyBtn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ void IWCdeIconifyBtn::DrawSymbol(CDC* pdc, CRect rect)
icon.top = buttonFrame.top + buttonFrame.Width() * 0.4;
icon.bottom = buttonFrame.bottom - buttonFrame.Width() * 0.4;

Draw3dRect(pdc, buttonFrame, 1, lightColor, darkColor);
Draw3dRect(pdc, icon, 1, lightColor, darkColor);
DrawThick3dRect(pdc, buttonFrame, 1, lightColor, darkColor);
DrawThick3dRect(pdc, icon, 1, lightColor, darkColor);
}
4 changes: 2 additions & 2 deletions ILS_Window_Plugin/IWCdeMenuBtn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ void IWCdeMenuBtn::DrawSymbol(CDC* pdc, CRect rect)
barIcon.top = rect.top + rect.Height() / 2 - 2;
barIcon.bottom = barIcon.top + 4;

Draw3dRect(pdc, rect, 1, lightColor, darkColor);
Draw3dRect(pdc, barIcon, 1, lightColor, darkColor);
DrawThick3dRect(pdc, rect, 1, lightColor, darkColor);
DrawThick3dRect(pdc, barIcon, 1, lightColor, darkColor);
}
6 changes: 3 additions & 3 deletions ILS_Window_Plugin/IWCdeTitleBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IWCdeTitleBar::IWCdeTitleBar(COLORREF backgroundColor, COLORREF textColor, COLOR

this->iconifyButton = new IWCdeIconifyBtn(backgroundColor, lightColor, darkColor);
this->menuButton = new IWCdeMenuBtn(backgroundColor, lightColor, darkColor);
this->resizeButton = new IWX11ResizeBtn(backgroundColor);
this->resizeButton = new IWX11ResizeBtn(backgroundColor, textColor);
}

void IWCdeTitleBar::PositionButtons(const CRect& rect)
Expand All @@ -34,9 +34,9 @@ void IWCdeTitleBar::PositionButtons(const CRect& rect)

void IWCdeTitleBar::DrawTitle(CDC* pdc, CRect rect, CString title)
{
Draw3dRect(pdc, titleArea, 1, lightColor, darkColor);
DrawThick3dRect(pdc, titleArea, 1, lightColor, darkColor);

auto oldFont = pdc->SelectObject(this->font);
auto oldFont = pdc->SelectObject(this->mainFont);
pdc->SetTextColor(this->textColor);
pdc->SetBkMode(TRANSPARENT);
pdc->DrawText(_T(title), -1, titleArea, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
Expand Down
59 changes: 45 additions & 14 deletions ILS_Window_Plugin/IWCdeWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ IWCdeWindow::IWCdeWindow(IWApproachDefinition selectedApproach, IWStyling stylin
, lightColor(AdjustColorBrightness(styling.windowFrameColor, 1.4))
, darkColor(AdjustColorBrightness(styling.windowFrameColor, 0.4))
{
COLORREF textColor = RGB(styling.windowFrameTextColor.r, styling.windowFrameTextColor.g, styling.windowFrameTextColor.b);
this->titleBar = new IWCdeTitleBar(windowBorderColor, textColor, lightColor, darkColor, this);
this->titleBar = new IWCdeTitleBar(windowBorderColor, styling.windowFrameTextColor, lightColor, darkColor, this);
this->extraMenuItemWidth = 20;
}

int IWCdeWindow::GetEdgeCursorPosition(CPoint point)
Expand Down Expand Up @@ -76,28 +76,28 @@ void IWCdeWindow::DrawBorder(CDC* pdc, CRect rect)
leftBorderRect.left = leftBorderRect.left + 1;
leftBorderRect.right = leftBorderRect.left + WINDOW_BORDER_THICKNESS - 1;
leftBorderRect.bottom = leftBorderRect.bottom - TITLE_BAR_HEIGHT;
Draw3dRect(pdc, leftBorderRect, border3dSteps, lightColor, darkColor);
DrawThick3dRect(pdc, leftBorderRect, border3dSteps, lightColor, darkColor);

CRect bottomBorderRect = rect;
bottomBorderRect.top = bottomBorderRect.bottom - WINDOW_BORDER_THICKNESS;
bottomBorderRect.left = bottomBorderRect.left + TITLE_BAR_HEIGHT;
bottomBorderRect.right = bottomBorderRect.right - TITLE_BAR_HEIGHT;
bottomBorderRect.bottom = bottomBorderRect.bottom - 1;
Draw3dRect(pdc, bottomBorderRect, border3dSteps, lightColor, darkColor);
DrawThick3dRect(pdc, bottomBorderRect, border3dSteps, lightColor, darkColor);

CRect rightBorderRect = rect;
rightBorderRect.top = rightBorderRect.top + TITLE_BAR_HEIGHT;
rightBorderRect.left = rightBorderRect.right - WINDOW_BORDER_THICKNESS;
rightBorderRect.right = rightBorderRect.right - 1;
rightBorderRect.bottom = rightBorderRect.bottom - TITLE_BAR_HEIGHT;
Draw3dRect(pdc, rightBorderRect, border3dSteps, lightColor, darkColor);
DrawThick3dRect(pdc, rightBorderRect, border3dSteps, lightColor, darkColor);

CRect topBorderRect = rect;
topBorderRect.top = topBorderRect.top + 1;
topBorderRect.left = topBorderRect.left + TITLE_BAR_HEIGHT;
topBorderRect.right = topBorderRect.right - TITLE_BAR_HEIGHT;
topBorderRect.bottom = topBorderRect.top + WINDOW_BORDER_THICKNESS - 1;
Draw3dRect(pdc, topBorderRect, border3dSteps, lightColor, darkColor);
DrawThick3dRect(pdc, topBorderRect, border3dSteps, lightColor, darkColor);

// Corners

Expand All @@ -106,36 +106,38 @@ void IWCdeWindow::DrawBorder(CDC* pdc, CRect rect)
topLeftCornerRect.left = topLeftCornerRect.left + 1;
topLeftCornerRect.right = topLeftCornerRect.left + TITLE_BAR_HEIGHT - 2;
topLeftCornerRect.bottom = topLeftCornerRect.top + TITLE_BAR_HEIGHT - 2;
Draw3dCorner(pdc, topLeftCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, true, true);
DrawThick3dCorner(pdc, topLeftCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, true, true);

CRect topRightCornerRect = rect;
topRightCornerRect.top = topRightCornerRect.top + 1;
topRightCornerRect.left = topRightCornerRect.right - TITLE_BAR_HEIGHT;
topRightCornerRect.right = topRightCornerRect.right - 2;
topRightCornerRect.bottom = topRightCornerRect.top + TITLE_BAR_HEIGHT - 2;
Draw3dCorner(pdc, topRightCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, true, false);
DrawThick3dCorner(pdc, topRightCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, true, false);

CRect bottomRightCornerRect = rect;
bottomRightCornerRect.top = bottomRightCornerRect.bottom - TITLE_BAR_HEIGHT;
bottomRightCornerRect.left = bottomRightCornerRect.right - TITLE_BAR_HEIGHT;
bottomRightCornerRect.right = bottomRightCornerRect.right - 2;
bottomRightCornerRect.bottom = bottomRightCornerRect.bottom - 2;
Draw3dCorner(pdc, bottomRightCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, false, false);
DrawThick3dCorner(pdc, bottomRightCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, false, false);

CRect bottomLeftCornerRect = rect;
bottomLeftCornerRect.top = bottomLeftCornerRect.bottom - TITLE_BAR_HEIGHT;
bottomLeftCornerRect.left = bottomLeftCornerRect.left + 1;
bottomLeftCornerRect.right = bottomLeftCornerRect.left + TITLE_BAR_HEIGHT - 2;
bottomLeftCornerRect.bottom = bottomLeftCornerRect.bottom - 2;
Draw3dCorner(pdc, bottomLeftCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, false, true);
DrawThick3dCorner(pdc, bottomLeftCornerRect, WINDOW_BORDER_THICKNESS, border3dSteps, lightColor, darkColor, false, true);
}

COLORREF IWCdeWindow::AdjustColorBrightness(RGB color, double factor)
COLORREF IWCdeWindow::AdjustColorBrightness(COLORREF color, double factor)
{
GetRValue(color);

// Adjust each component
int red = static_cast<int>(color.r * factor);
int green = static_cast<int>(color.g * factor);
int blue = static_cast<int>(color.b * factor);
int red = GetRValue(color) * factor;
int green = GetGValue(color) * factor;
int blue = GetBValue(color) * factor;

// Ensure the components are within the valid range
red = max(0, min(255, red));
Expand All @@ -145,3 +147,32 @@ COLORREF IWCdeWindow::AdjustColorBrightness(RGB color, double factor)
// Combine them back into a COLORREF
return RGB(red, green, blue);
}

void IWCdeWindow::DrawMenuItem(CDC* pdc, CRect bounds, CString text, bool isHovered, bool isChecked)
{
COLORREF bgColor = isHovered ? RGB(130, 130, 130) : RGB(152, 152, 152);
COLORREF textColor = RGB(255, 255, 255); // White text

std::string fullText = isChecked ? "¤ " : " ";
fullText += text;

CBrush brush(bgColor);
pdc->FillRect(&bounds, &brush);

if (isHovered) {
COLORREF darkened = AdjustColorBrightness(bgColor, 0.6);
COLORREF lightened = AdjustColorBrightness(bgColor, 1.4);
DrawThick3dRect(pdc, bounds, 2, darkened, lightened);
}

// Draw text
pdc->SetTextColor(textColor);
pdc->SetBkMode(TRANSPARENT);

CRect textArea = bounds;
textArea.left += 10;

CFont* oldFont = pdc->SelectObject(&mainFont);
pdc->DrawText(fullText.c_str(), &textArea, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
pdc->SelectObject(&oldFont);
}
4 changes: 3 additions & 1 deletion ILS_Window_Plugin/IWCdeWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ class IWCdeWindow :

private:
void DrawBorder(CDC* pdc, CRect rect) override;
COLORREF AdjustColorBrightness(RGB color, double factor);
void DrawMenuItem(CDC* pdc, CRect bounds, CString text, bool isHovered, bool isChecked) override;
virtual int GetEdgeCursorPosition(CPoint point) override;

COLORREF AdjustColorBrightness(COLORREF color, double factor);

const COLORREF lightColor;
const COLORREF darkColor;
};
33 changes: 33 additions & 0 deletions ILS_Window_Plugin/IWContextMenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "pch.h"
#include "IWContextMenu.h"

BEGIN_MESSAGE_MAP(IWContextMenu, CWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

void IWContextMenu::SubclassMenu(HWND hMenuWnd)
{
// Attach to the existing menu window
Attach(hMenuWnd);
}

void IWContextMenu::OnPaint()
{
CPaintDC dc(this); // Get device context

// Get the menu window's size
CRect rect;
GetClientRect(&rect);

// Draw the default menu first
DefWindowProc(WM_PAINT, (WPARAM)dc.m_hDC, 0);

// Draw custom border
COLORREF borderColor = RGB(255, 0, 0); // Red border
int borderWidth = 2;

CBrush borderBrush(borderColor);
dc.FrameRect(&rect, &borderBrush);

// You can also use dc.DrawEdge() for different styles
}
12 changes: 12 additions & 0 deletions ILS_Window_Plugin/IWContextMenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include <afxwin.h>

class IWContextMenu : public CWnd
{
public:
void SubclassMenu(HWND hMenuWnd);

protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
39 changes: 25 additions & 14 deletions ILS_Window_Plugin/IWDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

class IWWindow;

struct RGB {
int r, g, b;
};

struct IWTargetPosition {
int trueAltitude;
double latitude;
Expand Down Expand Up @@ -49,17 +45,22 @@ enum IWTagMode {
Callsign
};

enum IWTheme {
CDE,
X11
};

struct IWStyling {
RGB windowFrameColor;
RGB windowFrameTextColor;
RGB windowOuterFrameColor;
RGB backgroundColor;
RGB glideslopeColor;
RGB localizerColor;
RGB radarTargetColor;
RGB historyTrailColor;
RGB targetLabelColor;
RGB rangeStatusTextColor;
COLORREF windowFrameColor;
COLORREF windowFrameTextColor;
COLORREF windowOuterFrameColor;
COLORREF backgroundColor;
COLORREF glideslopeColor;
COLORREF localizerColor;
COLORREF radarTargetColor;
COLORREF historyTrailColor;
COLORREF targetLabelColor;
COLORREF rangeStatusTextColor;
unsigned int fontSize;
bool showTagByDefault;
IWTagMode defaultTagMode;
Expand All @@ -68,4 +69,14 @@ struct IWStyling {
struct IWBehaviourSettings {
bool openWindowsBasedOnActiveRunways;
std::string windowStyle;
};

struct IWConfig {
IWStyling styling;
IWBehaviourSettings behaviour;
};

struct IWActiveRunway {
std::string airport;
std::string runway;
};
Loading
Loading