@@ -280,15 +280,11 @@ private static void DrawColumnHeader(
280280 int column ,
281281 HierarchyDefinition hdef ,
282282 double width ,
283- double screenScale
283+ double screenScale ,
284+ bool lastColumn = false
284285 )
285286 {
286- var height = hdef is { IsExpanded : true , HasChild : true }
287- ? viewModel . ColumnsHeadersHeight [ hdef . Level ]
288- : Enumerable
289- . Range ( hdef . Level , viewModel . ColumnsHeadersHeight . Length - hdef . Level )
290- . Select ( x => viewModel . ColumnsHeadersHeight [ x ] )
291- . Sum ( ) ;
287+ double height = ComputeHeaderHeight ( viewModel , hdef ) ;
292288
293289 var top = Enumerable
294290 . Range ( 0 , hdef . Level )
@@ -320,6 +316,25 @@ double screenScale
320316 currentPosition += width ;
321317 }
322318
319+ /// <summary>
320+ /// If the definition is expanded and has any child element,
321+ /// it should span on only one row, using the height of its level.
322+ /// Otherwise, it should span until the end of the headers display.
323+ /// </summary>
324+ private static double ComputeHeaderHeight (
325+ HierarchyGridViewModel viewModel ,
326+ HierarchyDefinition hdef
327+ )
328+ {
329+ var height = hdef is { IsExpanded : true , HasChild : true }
330+ ? viewModel . ColumnsHeadersHeight [ hdef . Level ]
331+ : Enumerable
332+ . Range ( hdef . Level , viewModel . ColumnsHeadersHeight . Length - hdef . Level )
333+ . Select ( x => viewModel . ColumnsHeadersHeight [ x ] )
334+ . Sum ( ) ;
335+ return height ;
336+ }
337+
323338 private static void DrawParentColumnHeader (
324339 this SKCanvas canvas ,
325340 HierarchyGridViewModel viewModel ,
@@ -613,7 +628,7 @@ private static void RenderHeaderText(
613628 double screenScale ,
614629 RenderInfo renderInfo ,
615630 string fontFamily = "" ,
616- float headerTextSize = 16f
631+ float headerFontSize = 16f
617632 )
618633 {
619634 TextDrawer . Clear ( ) ;
@@ -622,20 +637,30 @@ private static void RenderHeaderText(
622637 hdef . Content ? . ToString ( ) ?? string . Empty ,
623638 new Style
624639 {
625- FontSize = headerTextSize ,
640+ FontSize = headerFontSize ,
626641 TextColor = renderInfo . ForegroundColor ,
627642 FontWeight = 600 ,
628643 FontFamily = ! string . IsNullOrEmpty ( fontFamily ) ? fontFamily : "Sans Serif" ,
629644 }
630645 ) ;
631- TextDrawer . MaxHeight = ( float ) ( ( height - 10 ) * screenScale ) ;
632- TextDrawer . MaxWidth = ( float ) ( ( width - 24 ) * screenScale ) ;
633646
634- TextDrawer . Paint (
635- canvas ,
636- new SKPoint ( ( float ) ( ( left + 22 ) * screenScale ) , ( float ) ( ( top + 6 ) * screenScale ) ) ,
637- TextPaintOptions
638- ) ;
647+ float textVPadding = ( float ) ( height - ( headerFontSize * screenScale ) ) ;
648+ float textHPadding = 22f ;
649+
650+ TextDrawer . MaxHeight = ( float ) ( height * screenScale ) ;
651+ TextDrawer . MaxWidth = ( float ) ( ( width - textHPadding ) * screenScale ) ;
652+
653+ /* We can center elements that have no child elements,
654+ otherwise the text might be out of drawn screen */
655+ float x = hdef . HasChild
656+ ? ( float ) ( ( left + 22 ) * screenScale )
657+ : ( float ) ( ( left + ( ( width - TextDrawer . MeasuredWidth ) / 2 ) ) * screenScale ) ;
658+
659+ float y = hdef . HasChild
660+ ? ( float ) ( ( top + 6 ) * screenScale )
661+ : ( float ) ( ( top + ( textVPadding / 2 ) ) * screenScale ) ;
662+
663+ TextDrawer . Paint ( canvas , new SKPoint ( x , y ) , TextPaintOptions ) ;
639664 }
640665
641666 private static Option < SKPath > GetHeaderDecorator (
@@ -928,10 +953,10 @@ private static void RenderCellText(
928953 RenderInfo renderInfo
929954 )
930955 {
931- var fontSize = viewModel . CellFontSize ;
956+ float fontSize = viewModel . CellFontSize ;
932957
933958 float textHPadding = ( float ) ( ( 6f + theme . SelectionBorderThickness ) * screenScale ) ;
934- var textVPadding = ( float ) ( cell . Height - ( fontSize * screenScale ) ) ;
959+ float textVPadding = ( float ) ( cell . Height - ( fontSize * screenScale ) ) ;
935960
936961 var rightDecorPadding = (
937962 from rd in cell . ResultSet . RightDecor
@@ -968,8 +993,8 @@ select svg.Picture.CullRect.Width * screenScale
968993 TextDrawer . Paint (
969994 canvas ,
970995 new SKPoint (
971- ( float ) ( cell . Left * screenScale ) + ( textHPadding / 2 ) + leftDecorPadding ,
972- ( float ) ( cell . Top * screenScale ) + ( textVPadding / 2 )
996+ ( float ) ( ( cell . Left + ( textHPadding / 2 ) + leftDecorPadding ) * screenScale ) ,
997+ ( float ) ( ( cell . Top + ( textVPadding / 2 ) ) * screenScale )
973998 ) ,
974999 TextPaintOptions
9751000 ) ;
0 commit comments