Skip to content

Commit a22c2d3

Browse files
committed
Tag beautifying
1 parent 88a8fe1 commit a22c2d3

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

vSMR/SMRRadar.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#include "stdafx.h"
2-
#include <d2d1.h>
2+
//#include <d2d1.h>
33
#include "Resource.h"
44
#include "SMRRadar.hpp"
55

6-
#pragma comment(lib, "d2d1.lib")
7-
6+
//#pragma comment(lib, "d2d1.lib")
87

98
ULONG_PTR m_gdiplusToken;
109
CPoint mouseLocation(0, 0);
@@ -2557,8 +2556,7 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
25572556
// Get the TAG label settings
25582557
const Value& LabelsSettings = CurrentConfig->getActiveProfile()["labels"];
25592558

2560-
// First we need to figure out the tag size
2561-
Gdiplus::REAL TagWidth = 0, TagHeight = 0;
2559+
// First we need to figure out the tag size
25622560
RectF mesureRect;
25632561
graphics->MeasureString(L" ", wcslen(L" "), customFont, PointF(0, 0), stformat, &mesureRect);
25642562
auto blankWidth = mesureRect.GetRight();
@@ -2596,22 +2594,29 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
25962594

25972595
if (!LabelLines.IsArray())
25982596
return;
2597+
25992598

2599+
REAL TagWidth = 0, TagHeight = 0;
2600+
REAL TAG_PADDING_LEFT = (REAL)currentFontSize / 4.0;
2601+
REAL TAG_PADDING_RIGHT = TAG_PADDING_LEFT;
2602+
REAL TAG_PADDING_TOP = TAG_PADDING_LEFT*0.5;
2603+
REAL TAG_PADDING_BOTTOM = TAG_PADDING_LEFT*0.5;
2604+
26002605
for (unsigned int i = 0; i < LabelLines.Size(); i++) {
26012606

26022607
const Value& line = LabelLines[i];
26032608
vector<TagItem> lineTagItemArray;
26042609

26052610
// Adds one line height
26062611
if (i == 0) {
2612+
TagHeight += TAG_PADDING_TOP;
26072613
TagHeight += firstLineHeight; // special case 1st line
26082614
}
26092615
else {
26102616
TagHeight += oneLineHeight;
26112617
}
26122618

2613-
Gdiplus::REAL lineWidth = 0;
2614-
2619+
Gdiplus::REAL lineWidth = TAG_PADDING_LEFT;
26152620
for (unsigned int j = 0; j < line.Size(); j++) {
26162621
mesureRect = RectF(0, 0, 0, 0);
26172622
CBString tagKey = line[j].GetString();
@@ -2635,11 +2640,12 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
26352640
//lineWidth += blankWidth;
26362641
}
26372642
}
2638-
2643+
lineWidth += TAG_PADDING_RIGHT;
26392644
TagWidth = max(TagWidth, lineWidth);
26402645

26412646
ReplacedLabelLines.push_back(lineTagItemArray);
26422647
}
2648+
TagHeight += TAG_PADDING_BOTTOM;
26432649

26442650
Color definedBackgroundColor = CurrentConfig->getConfigColor(LabelsSettings[getEnumString(ColorTagType)]["background_color"]);
26452651
if (ColorTagType == TagTypes::Departure) {
@@ -2768,10 +2774,10 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
27682774
TagBackgroundRect = oldCrectSave;
27692775

27702776
// Draw tag text and clickable zones
2771-
Gdiplus::REAL heightOffset = 0;
2777+
Gdiplus::REAL heightOffset = TAG_PADDING_TOP;
27722778
for (auto&& line : ReplacedLabelLines) {
27732779

2774-
Gdiplus::REAL widthOffset = 0;
2780+
Gdiplus::REAL widthOffset = TAG_PADDING_LEFT;
27752781
for (auto&& tagItem : line) {
27762782
SolidBrush* color = &FontColor;
27772783
if (TagMap["sqerror"].value.length() > 0 && tagItem.value == TagMap["sqerror"].value)
@@ -2795,7 +2801,9 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
27952801
widthOffset -= blankWidth; // We don't want a space between the callsign and the comm type if it's there
27962802
}
27972803

2798-
if (heightOffset == 0) { // first line
2804+
if (heightOffset == TAG_PADDING_TOP) { // first line
2805+
heightOffset;
2806+
27992807
graphics->DrawString(welement.c_str(), wcslen(welement.c_str()), firstLineFont,
28002808
PointF(Gdiplus::REAL(TagBackgroundRect.left) + widthOffset, Gdiplus::REAL(TagBackgroundRect.top) + heightOffset),
28012809
stformat, color);
@@ -2817,17 +2825,18 @@ void CSMRRadar::DrawTags(Graphics* graphics, CInsetWindow* insetWindow)
28172825

28182826
AddScreenObject(tagItem.function, rt.GetCallsign(), ItemRect, true, GetBottomLine(rt.GetCallsign()));
28192827

2820-
widthOffset += mRect.GetRight();
2821-
//widthOffset += blankWidth;
2828+
widthOffset += mRect.GetRight();
28222829
}
28232830

2824-
if (heightOffset == 0) {
2831+
if (heightOffset == TAG_PADDING_TOP) {
28252832
heightOffset += firstLineHeight;
28262833
}
28272834
else {
28282835
heightOffset += oneLineHeight;
28292836
}
2837+
widthOffset += TAG_PADDING_RIGHT;
28302838
}
2839+
heightOffset += TAG_PADDING_BOTTOM;
28312840
}
28322841
}
28332842
}

0 commit comments

Comments
 (0)