mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Improve small calendar display.
All checks were successful
Remind unit tests / tests (push) Successful in 26s
All checks were successful
Remind unit tests / tests (push) Successful in 26s
This commit is contained in:
@@ -821,7 +821,6 @@ sub draw_small_calendar
|
|||||||
$layout->set_text('88 ');
|
$layout->set_text('88 ');
|
||||||
my ($wid, $h) = $layout->get_pixel_size();
|
my ($wid, $h) = $layout->get_pixel_size();
|
||||||
$h += 1;
|
$h += 1;
|
||||||
|
|
||||||
# Month name
|
# Month name
|
||||||
$layout = Pango::Cairo::create_layout($cr);
|
$layout = Pango::Cairo::create_layout($cr);
|
||||||
$desc = Pango::FontDescription->from_string($settings->{small_cal_font} . ' ' . $font_size . 'px');
|
$desc = Pango::FontDescription->from_string($settings->{small_cal_font} . ' ' . $font_size . 'px');
|
||||||
@@ -835,6 +834,7 @@ sub draw_small_calendar
|
|||||||
|
|
||||||
$y += $h;
|
$y += $h;
|
||||||
# Day names
|
# Day names
|
||||||
|
$wid = $width / 7;
|
||||||
for (my $col=0; $col <7; $col++) {
|
for (my $col=0; $col <7; $col++) {
|
||||||
my $j;
|
my $j;
|
||||||
if ($self->{mondayfirst}) {
|
if ($self->{mondayfirst}) {
|
||||||
@@ -860,7 +860,11 @@ sub draw_small_calendar
|
|||||||
for (my $d=1; $d <= $days; $d++) {
|
for (my $d=1; $d <= $days; $d++) {
|
||||||
$desc = Pango::FontDescription->from_string($settings->{small_cal_font} . ' ' . $font_size . 'px');
|
$desc = Pango::FontDescription->from_string($settings->{small_cal_font} . ' ' . $font_size . 'px');
|
||||||
$layout->set_font_description($desc);
|
$layout->set_font_description($desc);
|
||||||
$layout->set_text($d);
|
my $dt = $d;
|
||||||
|
if (length($dt) < 2) {
|
||||||
|
$dt = ' ' . $dt;
|
||||||
|
}
|
||||||
|
$layout->set_text($dt);
|
||||||
$cr->save();
|
$cr->save();
|
||||||
$cr->move_to($x + $col*$wid, $y);
|
$cr->move_to($x + $col*$wid, $y);
|
||||||
Pango::Cairo::show_layout($cr, $layout);
|
Pango::Cairo::show_layout($cr, $layout);
|
||||||
@@ -892,20 +896,23 @@ sub calculate_small_calendar_font_size
|
|||||||
my $font_size = int($scale * 10);
|
my $font_size = int($scale * 10);
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
$desc = Pango::FontDescription->from_string($settings->{small_cal_font} . ' ' . $font_size . 'px');
|
while(1) {
|
||||||
$layout->set_font_description($desc);
|
$desc = Pango::FontDescription->from_string($settings->{small_cal_font} . ' ' . $font_size . 'px');
|
||||||
$layout->set_text('88 88 88 88 88 88 88');
|
$layout->set_font_description($desc);
|
||||||
($wid, $h) = $layout->get_pixel_size();
|
$layout->set_text('88 88 88 88 88 88 88');
|
||||||
$h += 1;
|
($wid, $h) = $layout->get_pixel_size();
|
||||||
$h *= ($rows + 2); # row for month name; row for day names
|
$h += 1;
|
||||||
|
$h *= ($rows + 2); # row for month name; row for day names
|
||||||
|
|
||||||
$scale = $width / $wid;
|
$scale = $width / $wid;
|
||||||
if (($height / $h) < $scale) {
|
if (($height / $h) < $scale) {
|
||||||
$scale = $height / $h;
|
$scale = $height / $h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scale < 1) { # Font size is too big
|
if ($scale >= 1) { # Font size is OK
|
||||||
$font_size--;
|
last;
|
||||||
|
}
|
||||||
|
$font_size -= 0.1;
|
||||||
}
|
}
|
||||||
return $font_size;
|
return $font_size;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user