Opened 22 months ago

Closed 3 months ago

#18288 closed bug (fixed)

Text not vertically aligned in CalendarView

Reported by: accessays Owned by: stippi
Priority: normal Milestone: R1/beta6
Component: User Interface Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

Days in the calendar widget (seen by clicking on time in Deskbar) are not vertically aligned. This can be easily seen if a day is selected (see attached image). Same goes for date selection in "Date and time", where system datetime is modified.

Attachments (3)

d6f5bc931fe48c9f702a0d6c2b89fdd02bff9d41.png (57.9 KB ) - added by accessays 22 months ago.
Screenshot_20230302_000323.png (14.0 KB ) - added by accessays 22 months ago.
Looks a lot better on the first row
Screenshot_20230301_235738.png (14.1 KB ) - added by accessays 22 months ago.
But still offset on the bottom row

Download all attachments as: .zip

Change History (5)

comment:1 by accessays, 22 months ago

This is due to incorrect centering calculations in CalendarView. Now it is done as follows:

float offsetV = frame.Height() / 2.0 + FontHeight(owner) / 2.0 - 2.0;
...
DrawString(..., BPoint(..., frame.top + offsetV));

where FontHeight(owner) is ascent + descent + leading, and - 2.0 accounts for the extra padding (4.0) within the cell, I assume.

The correct calculation is as follows:

font_height fheight;
font.GetHeight(&fheight);
float offsetV = (frame.Height() - (fheight.ascent + fheight.descent + fheight.leading)) + fheight.ascent - 2.0;

This centers the text like you would center a bitmap (top + (bounds.height - bitmap.height)/2) and accounts for the fact that font rendering is done from the baseline (+ fheight.ascent).

This makes the result better, but does not fully fix the issue. The numbers in the cells start drifting the lower down they are. I'm guessing that's because cell borders are not taken into account, but I haven't looked at that yet.

by accessays, 22 months ago

Looks a lot better on the first row

by accessays, 22 months ago

But still offset on the bottom row

comment:2 by waddlesplash, 3 months ago

Milestone: UnscheduledR1/beta6
Resolution: fixed
Status: newclosed

Fixed in hrev58189.

Note: See TracTickets for help on using tickets.