Center text vertically in input and result boxes
This commit is contained in:
parent
cc590001d7
commit
d67ea79994
2 changed files with 15 additions and 4 deletions
|
@ -72,7 +72,7 @@ impl<'a> Painter<'a> {
|
|||
ctx.fill().unwrap();
|
||||
|
||||
// draw text
|
||||
ctx.move_to(x + 0.2, y+0.8);
|
||||
ctx.move_to(x + 0.2, y);
|
||||
ctx.theme_text(&input, false, &[], &self.theme);
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,9 @@ impl<'a> Painter<'a> {
|
|||
ctx.fill().unwrap();
|
||||
|
||||
// draw text
|
||||
ctx.move_to (x+0.2, y+0.8);
|
||||
ctx.move_to (x+0.2, y);
|
||||
ctx.theme_text(&source, selected, &[], &self.theme);
|
||||
ctx.move_to (x+3.5, y+0.8);
|
||||
ctx.move_to (x+3.5, y);
|
||||
ctx.theme_text(&result, selected, indices, &self.theme);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,10 +125,21 @@ impl ThemedContextExt for cairo::Context {
|
|||
font.set_size(theme.font.1*pango::SCALE);
|
||||
layout.set_font_description(Some(&font));
|
||||
|
||||
layout.set_spacing(0);
|
||||
|
||||
layout.set_text(text);
|
||||
|
||||
let (_width,height) = layout.size();
|
||||
self.rel_move_to(0.0, -(height as f64)/(pango::SCALE as f64));
|
||||
let device_height = (height as f64)/(pango::SCALE as f64);
|
||||
|
||||
self.save().unwrap();
|
||||
self.scale(30.0,30.0);
|
||||
let cairo_user_height = self.device_to_user_point(device_height);
|
||||
let offset = (1.0 - cairo_user_height) / 2.0;
|
||||
self.rel_move_to(0.0, offset);
|
||||
self.restore().unwrap();
|
||||
|
||||
pangocairo::update_layout(self, &layout);
|
||||
pangocairo::show_layout(self, &layout);
|
||||
self.restore().unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue