Place cover at vertical center
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
aebae5ef4c
commit
74b96c7ae9
2 changed files with 18 additions and 1 deletions
|
@ -138,7 +138,9 @@ public class MediaPlayer.Player : Gtk.Box {
|
|||
// Start background generator
|
||||
run_color_thred (pixbuff.scale_simple (64, 64, Gdk.InterpType.BILINEAR));
|
||||
|
||||
return Utils.round_pixbuff (pixbuff, (110.0 - 10.0) /* pixel-size - padding :TODO: REMOVE WHEN PHOSH MOVES TO GTK4 */ / 10 / 100);
|
||||
// TODO: REMOVE WHEN PHOSH MOVES TO GTK4
|
||||
pixbuff = Utils.round_pixbuff (pixbuff, (110.0 - 10.0 /* pixel-size - padding */) / 10 / 100);
|
||||
return Utils.rect_pixbuff (pixbuff);
|
||||
}
|
||||
|
||||
public void bind_to_player (Gtk.Box player) {
|
||||
|
|
|
@ -65,6 +65,21 @@ namespace Utils {
|
|||
return Gdk.pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||
}
|
||||
|
||||
public Gdk.Pixbuf rect_pixbuff (Gdk.Pixbuf source) {
|
||||
// That's a hack for GTK3. TODO: Remove when phosh will be moved to gtk4
|
||||
var width = source.width;
|
||||
var height = source.height;
|
||||
if (width == height)
|
||||
return source;
|
||||
var max_dim = int.max (width, height);
|
||||
|
||||
var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, max_dim, max_dim);
|
||||
var cr = new Cairo.Context (surface);
|
||||
Gdk.cairo_set_source_pixbuf (cr, source, 0, (width - height) / 2);
|
||||
cr.paint ();
|
||||
return Gdk.pixbuf_get_from_surface (surface, 0, 0, max_dim, max_dim);
|
||||
}
|
||||
|
||||
public double deg (double deg) {
|
||||
return Math.PI / 180.0 * deg;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue