Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: digital clock not centered #343

Merged
merged 1 commit into from
Nov 16, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected void onDraw(Canvas canvas)
while((rect_date.width() > (view_width - 2 * padding)) && (date_text_size_factor > 0))
{
// Progressively lower the size of the date text size
date_text_size_factor -= 0.01 ;
date_text_size_factor -= 0.01f ;
textClock.setTextSize(time_text_size * date_text_size_factor) ;
textClock.getTextBounds(date_text, 0, date_text.length(), rect_date) ;
}
Expand All @@ -265,7 +265,7 @@ protected void onDraw(Canvas canvas)
// Draw the time text
textClock.setFakeBoldText(false) ;
textClock.setTextSize(time_text_size) ;
canvas.drawText(time_text, offset_x, offset_y, textClock) ;
canvas.drawText(time_text, offset_x - rect_time.left, offset_y, textClock) ;
rect_time.offset(Math.round(offset_x), Math.round(offset_y)) ;

// Define the horizontal offset of the date text
Expand All @@ -276,7 +276,7 @@ protected void onDraw(Canvas canvas)
// Draw the date text
textClock.setFakeBoldText(true) ;
textClock.setTextSize(time_text_size * date_text_size_factor) ;
canvas.drawText(date_text, offset_x, offset_y + 0.5f * padding + rect_date.height(), textClock) ;
canvas.drawText(date_text, offset_x - rect_date.left, offset_y + 0.5f * padding + rect_date.height(), textClock) ;
rect_date.offset(Math.round(offset_x), Math.round(offset_y + 0.5f * padding + rect_date.height())) ;
}
else if(clock_format.startsWith("date"))
Expand All @@ -294,7 +294,7 @@ else if(clock_format.startsWith("date"))
while((rect_date.width() > (view_width - 2 * padding)) && (date_text_size_factor > 0))
{
// Progressively lower the size of the date text size
date_text_size_factor -= 0.01 ;
date_text_size_factor -= 0.01f ;
textClock.setTextSize(time_text_size * date_text_size_factor) ;
textClock.getTextBounds(date_text, 0, date_text.length(), rect_date) ;
}
Expand All @@ -312,7 +312,7 @@ else if(clock_format.startsWith("date"))
// Draw the date text
textClock.setFakeBoldText(true) ;
textClock.setTextSize(time_text_size * date_text_size_factor) ;
canvas.drawText(date_text, offset_x, offset_y, textClock) ;
canvas.drawText(date_text, offset_x - rect_date.left, offset_y, textClock) ;
rect_date.offset(Math.round(offset_x), Math.round(offset_y)) ;
}
else
Expand Down Expand Up @@ -342,7 +342,7 @@ else if(clock_format.startsWith("date"))
else offset_x = view_width / 2f - rect_time.width() / 2f ;

// Draw the time text
canvas.drawText(time_text, offset_x, offset_y, textClock) ;
canvas.drawText(time_text, offset_x - rect_time.left, offset_y, textClock) ;
rect_time.offset(Math.round(offset_x), Math.round(offset_y)) ;
}
}
Expand Down