@@ -2112,19 +2112,39 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
21122112 // ----- Now the hard part, drawing (using gdi+) -------
21132113 //
21142114
2115- // First we need to figure out the tag size
2115+ // Get the TAG label settings
2116+ const Value& LabelsSettings = CurrentConfig->getActiveProfile ()[" labels" ];
21162117
2117- int TagWidth = 0 , TagHeight = 0 ;
2118+ // First we need to figure out the tag size
2119+ Gdiplus::REAL TagWidth = 0 , TagHeight = 0 ;
21182120 RectF mesureRect;
21192121 graphics.MeasureString (L" " , wcslen (L" " ), customFonts[currentFontSize], PointF (0 , 0 ), &Gdiplus::StringFormat (), &mesureRect);
2120- int blankWidth = (int )mesureRect.GetRight ();
2122+ auto blankWidth = mesureRect.GetRight ();
2123+
2124+ // default font size
2125+ mesureRect = RectF (0 , 0 , 0 , 0 );
2126+ graphics.MeasureString (L" AZERTYUIOPQSDFGHJKLMWXCVBN" , wcslen (L" AZERTYUIOPQSDFGHJKLMWXCVBN" ), customFonts[currentFontSize], PointF (0 , 0 ), &Gdiplus::StringFormat (), &mesureRect);
2127+ auto oneLineHeight = mesureRect.GetBottom ();
2128+
2129+ // bigger font size if used for 1st TAG line
2130+ string font_name = CurrentConfig->getActiveProfile ()[" font" ][" font_name" ].GetString ();
2131+ wstring wide_font_name = wstring (font_name.begin (), font_name.end ());
2132+
2133+ float fontsize = customFonts[currentFontSize]->GetSize ();
2134+ double fontSizeScaling = 1.0 ;
2135+ if (LabelsSettings[Utils::getEnumString (ColorTagType).c_str ()].HasMember (" first_line_font_factor" )) {
2136+ fontSizeScaling = LabelsSettings[Utils::getEnumString (ColorTagType).c_str ()][" first_line_font_factor" ].GetDouble ();
2137+ auto test = customFonts[currentFontSize]->GetSize ();
2138+ fontsize = round ((float )fontSizeScaling * (float )test);
2139+ }
2140+ Gdiplus::Font* firstLineFont = new Gdiplus::Font (wide_font_name.c_str (), Gdiplus::REAL (fontsize), customFonts[currentFontSize]->GetStyle (), Gdiplus::UnitPixel); ;
21212141
21222142 mesureRect = RectF (0 , 0 , 0 , 0 );
21232143 graphics.MeasureString (L" AZERTYUIOPQSDFGHJKLMWXCVBN" , wcslen (L" AZERTYUIOPQSDFGHJKLMWXCVBN" ),
2124- customFonts[currentFontSize] , PointF (0 , 0 ), &Gdiplus::StringFormat (), &mesureRect);
2125- int oneLineHeight = ( int ) mesureRect.GetBottom ();
2144+ firstLineFont , PointF (0 , 0 ), &Gdiplus::StringFormat (), &mesureRect);
2145+ auto firstLineHeight = mesureRect.GetBottom ();
21262146
2127- const Value& LabelsSettings = CurrentConfig-> getActiveProfile ()[ " labels " ];
2147+ // get label lines definitions
21282148 const Value& LabelLines = LabelsSettings[Utils::getEnumString (TagType).c_str ()][" definition" ];
21292149 vector<vector<string>> ReplacedLabelLines;
21302150
@@ -2138,9 +2158,14 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
21382158 vector<string> lineStringArray;
21392159
21402160 // Adds one line height
2141- TagHeight += oneLineHeight;
2161+ if (i == 0 ) {
2162+ TagHeight += firstLineHeight; // special case 1st line
2163+ }
2164+ else {
2165+ TagHeight += oneLineHeight;
2166+ }
21422167
2143- int TempTagWidth = 0 ;
2168+ Gdiplus::REAL TempTagWidth = 0 ;
21442169
21452170 for (unsigned int j = 0 ; j < line.Size (); j++)
21462171 {
@@ -2153,13 +2178,16 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
21532178 lineStringArray.push_back (element);
21542179
21552180 wstring wstr = wstring (element.begin (), element.end ());
2156- graphics.MeasureString (wstr.c_str (), wcslen (wstr.c_str ()),
2157- customFonts[currentFontSize], PointF (0 , 0 ), &Gdiplus::StringFormat (), &mesureRect);
2158-
2159- TempTagWidth += (int ) mesureRect.GetRight ();
2181+ if (i == 0 ) {
2182+ graphics.MeasureString (wstr.c_str (), wcslen (wstr.c_str ()), firstLineFont, PointF (0 , 0 ), &Gdiplus::StringFormat (), &mesureRect); // special case for first line
2183+ }
2184+ else {
2185+ graphics.MeasureString (wstr.c_str (), wcslen (wstr.c_str ()), customFonts[currentFontSize], PointF (0 , 0 ), &Gdiplus::StringFormat (), &mesureRect);
2186+ }
2187+ TempTagWidth += mesureRect.GetRight ();
21602188
21612189 if (j != line.Size () - 1 )
2162- TempTagWidth += ( int ) blankWidth;
2190+ TempTagWidth += blankWidth;
21632191 }
21642192
21652193 TagWidth = max (TagWidth, TempTagWidth);
@@ -2201,7 +2229,7 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
22012229
22022230 // Drawing the tag background
22032231
2204- CRect TagBackgroundRect (TagCenter.x - (TagWidth / 2 ), TagCenter.y - (TagHeight / 2 ), TagCenter.x + (TagWidth / 2 ), TagCenter.y + (TagHeight / 2 ));
2232+ CRect TagBackgroundRect (( int )( TagCenter.x - (TagWidth / 2.0 )), ( int )( TagCenter.y - (TagHeight / 2.0 )), ( int )( TagCenter.x + (TagWidth / 2.0 )), ( int )( TagCenter.y + (TagHeight / 2.0 ) ));
22052233 SolidBrush TagBackgroundBrush (TagBackgroundColor);
22062234 graphics.FillRectangle (&TagBackgroundBrush, CopyRect (TagBackgroundRect));
22072235 if (mouseWithin (TagBackgroundRect) || IsTagBeingDragged (rt.GetCallsign ()))
@@ -2212,18 +2240,18 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
22122240
22132241 // Drawing the tag text
22142242
2215- SolidBrush FontColor (ColorManager->get_corrected_color (" label" ,
2216- CurrentConfig->getConfigColor (LabelsSettings[Utils::getEnumString (ColorTagType).c_str ()][" text_color" ])));
2217- SolidBrush SquawkErrorColor (ColorManager->get_corrected_color (" label" ,
2218- CurrentConfig->getConfigColor (LabelsSettings[" squawk_error_color" ])));
2243+ SolidBrush FontColor (ColorManager->get_corrected_color (" label" , CurrentConfig->getConfigColor (LabelsSettings[Utils::getEnumString (ColorTagType).c_str ()][" text_color" ])));
2244+ SolidBrush SquawkErrorColor (ColorManager->get_corrected_color (" label" , CurrentConfig->getConfigColor (LabelsSettings[" squawk_error_color" ])));
22192245 SolidBrush RimcasTextColor (CurrentConfig->getConfigColor (CurrentConfig->getActiveProfile ()[" rimcas" ][" alert_text_color" ]));
2220- SolidBrush GroundPushColor (ColorManager->get_corrected_color (" label" ,
2221- CurrentConfig->getConfigColor (LabelsSettings[" groundstatus_colors" ][" push" ])));
2222- SolidBrush GroundTaxiColor (ColorManager->get_corrected_color (" label" ,
2223- CurrentConfig->getConfigColor (LabelsSettings[" groundstatus_colors" ][" taxi" ])));
2224- SolidBrush GroundDepaColor (ColorManager->get_corrected_color (" label" ,
2225- CurrentConfig->getConfigColor (LabelsSettings[" groundstatus_colors" ][" depa" ])));
22262246
2247+ SolidBrush GroundPushColor (TagBackgroundColor);
2248+ SolidBrush GroundTaxiColor (TagBackgroundColor);
2249+ SolidBrush GroundDepaColor (TagBackgroundColor);
2250+ if (LabelsSettings.HasMember (" groundstatus_colors" )) {
2251+ GroundPushColor.SetColor (ColorManager->get_corrected_color (" label" , CurrentConfig->getConfigColor (LabelsSettings[" groundstatus_colors" ][" push" ])));
2252+ GroundTaxiColor.SetColor (ColorManager->get_corrected_color (" label" , CurrentConfig->getConfigColor (LabelsSettings[" groundstatus_colors" ][" taxi" ])));
2253+ GroundDepaColor.SetColor (ColorManager->get_corrected_color (" label" , CurrentConfig->getConfigColor (LabelsSettings[" groundstatus_colors" ][" depa" ])));
2254+ }
22272255
22282256 // Drawing the leader line
22292257 RECT TagBackRectData = TagBackgroundRect;
@@ -2272,10 +2300,10 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
22722300 TagBackgroundRect = oldCrectSave;
22732301
22742302 // Clickable zones
2275- int heightOffset = 0 ;
2303+ Gdiplus::REAL heightOffset = 0 ;
22762304 for (auto && line : ReplacedLabelLines)
22772305 {
2278- int widthOffset = 0 ;
2306+ Gdiplus::REAL widthOffset = 0 ;
22792307 for (auto && element : line)
22802308 {
22812309 SolidBrush* color = &FontColor;
@@ -2294,27 +2322,40 @@ void CSMRRadar::OnRefresh(HDC hDC, int Phase)
22942322 color = &GroundDepaColor;
22952323
22962324 RectF mRect (0 , 0 , 0 , 0 );
2297-
22982325 wstring welement = wstring (element.begin (), element.end ());
22992326
2300- graphics.DrawString (welement.c_str (), wcslen (welement.c_str ()), customFonts[currentFontSize],
2301- PointF (Gdiplus::REAL (TagBackgroundRect.left + widthOffset), Gdiplus::REAL (TagBackgroundRect.top + heightOffset)),
2302- &Gdiplus::StringFormat (), color);
2327+ if (heightOffset == 0 ) { // first line
2328+ graphics.DrawString (welement.c_str (), wcslen (welement.c_str ()), firstLineFont,
2329+ PointF (Gdiplus::REAL (TagBackgroundRect.left ) + widthOffset, Gdiplus::REAL (TagBackgroundRect.top ) + heightOffset),
2330+ &Gdiplus::StringFormat (), color);
23032331
2332+ graphics.MeasureString (welement.c_str (), wcslen (welement.c_str ()), firstLineFont,
2333+ PointF (0 , 0 ), &Gdiplus::StringFormat (), &mRect );
2334+ }
2335+ else {
2336+ graphics.DrawString (welement.c_str (), wcslen (welement.c_str ()), customFonts[currentFontSize],
2337+ PointF (Gdiplus::REAL (TagBackgroundRect.left ) + widthOffset, Gdiplus::REAL (TagBackgroundRect.top ) + heightOffset),
2338+ &Gdiplus::StringFormat (), color);
23042339
2305- graphics.MeasureString (welement.c_str (), wcslen (welement.c_str ()), customFonts[currentFontSize],
2306- PointF (0 , 0 ), &Gdiplus::StringFormat (), &mRect );
2340+ graphics.MeasureString (welement.c_str (), wcslen (welement.c_str ()), customFonts[currentFontSize],
2341+ PointF (0 , 0 ), &Gdiplus::StringFormat (), &mRect );
2342+ }
23072343
2308- CRect ItemRect (TagBackgroundRect.left + widthOffset, TagBackgroundRect.top + heightOffset,
2309- TagBackgroundRect.left + widthOffset + ( int ) mRect .GetRight (), TagBackgroundRect.top + heightOffset + ( int ) mRect .GetBottom ());
2344+ CRect ItemRect (( int )( TagBackgroundRect.left + widthOffset), ( int )( TagBackgroundRect.top + heightOffset) ,
2345+ ( int )( TagBackgroundRect.left + widthOffset + mRect .GetRight ()), ( int )( TagBackgroundRect.top + heightOffset + mRect .GetBottom () ));
23102346
23112347 AddScreenObject (TagClickableMap[element], rt.GetCallsign (), ItemRect, true , GetBottomLine (rt.GetCallsign ()).c_str ());
23122348
2313- widthOffset += ( int ) mRect .GetRight ();
2349+ widthOffset += mRect .GetRight ();
23142350 widthOffset += blankWidth;
23152351 }
23162352
2317- heightOffset += oneLineHeight;
2353+ if (heightOffset == 0 ) {
2354+ heightOffset += firstLineHeight;
2355+ }
2356+ else {
2357+ heightOffset += oneLineHeight;
2358+ }
23182359 }
23192360
23202361
0 commit comments