@@ -525,22 +525,47 @@ public class Turntable.Widgets.Cover : Gtk.Widget {
525525 float ratio = cover == null ? 1f : (float ) cover. get_intrinsic_aspect_ratio ();
526526 float w = 0 ;
527527 float h = 0 ;
528+ float t_w = 0 ;
529+ float t_h = 0 ;
528530
529- if (ratio > 1 ) {
531+ if (ratio == 1 ) {
532+ w = width;
533+ h = height;
534+ if (this . turntable) {
535+ t_w = this . record_center_inner. size. width;
536+ t_h = this . record_center_inner. size. height;
537+ }
538+ } else if (ratio > 1 ) {
530539 if (fit_cover) {
531540 w = height * ratio;
532541 h = height;
542+ if (this . turntable) {
543+ t_w = this . record_center_inner. size. height * ratio;
544+ t_h = this . record_center_inner. size. height;
545+ }
533546 } else {
534547 w = width;
535548 h = width / ratio;
549+ if (this . turntable) {
550+ t_w = this . record_center_inner. size. width;
551+ t_h = this . record_center_inner. size. width / ratio;
552+ }
536553 }
537554 } else {
538555 if (fit_cover) {
539556 w = width;
540557 h = width / ratio;
558+ if (this . turntable) {
559+ t_w = this . record_center_inner. size. width;
560+ t_h = this . record_center_inner. size. width / ratio;
561+ }
541562 } else {
542563 w = height * ratio;
543564 h = height;
565+ if (this . turntable) {
566+ t_w = this . record_center_inner. size. height * ratio;
567+ t_h = this . record_center_inner. size. height;
568+ }
544569 }
545570 }
546571
@@ -727,34 +752,48 @@ public class Turntable.Widgets.Cover : Gtk.Widget {
727752 float texture_w = w;
728753 float texture_h = h;
729754 if (this . turntable) {
730- if (this . fit_cover) {
731- texture_w = width * 0.65f ;
732- texture_h = height * 0.65f ;
733- } else {
734- texture_w = texture_w * 0.65f ;
735- texture_h = texture_h * 0.65f ;
736- }
755+ texture_w = t_w;
756+ texture_h = t_h;
737757
738- snapshot . translate ( Graphene . Point () {
739- x = ( width - Math . ceilf (texture_w)) / 2f ,
740- y = Math . floorf (( height - texture_h)) / 2f
741- }) ;
758+ var center_point = Graphene . Point () {
759+ x = width / 2 - this . record_center_inner . size . width / 2 ,
760+ y = height / 2 - this . record_center_inner . size . height / 2
761+ };
742762
743763 snapshot. push_rounded_clip (
744764 Gsk . RoundedRect (). init_from_rect (
745765 Graphene . Rect () {
746- origin = Graphene . Point () {
747- x = 0 ,
748- y = 0
749- },
750- size = Graphene . Size () {
751- width = texture_w,
752- height = texture_h
753- }
766+ origin = center_point,
767+ size = this . record_center_inner. size
754768 },
755769 9999f
756770 )
757771 );
772+
773+ if (ratio == 1 ) {
774+ snapshot. translate (center_point);
775+ } else if (this . fit_cover) {
776+ float new_x = 0 ;
777+ float new_y = 0 ;
778+
779+ if (ratio < 1 ) {
780+ new_x = width / 2 - this . record_center_inner. size. width / 2 ;
781+ new_y = height / 2 - texture_h / 2 ;
782+ } else {
783+ new_y = height / 2 - this . record_center_inner. size. height / 2 ;
784+ new_x = width / 2 - texture_w / 2 ;
785+ }
786+
787+ snapshot. translate (Graphene . Point () {
788+ x = new_x,
789+ y = new_y
790+ });
791+ } else {
792+ snapshot. translate (Graphene . Point () {
793+ x = width / 2 - texture_w / 2 ,
794+ y = height / 2 - texture_h / 2
795+ });
796+ }
758797 } else if (this . style == Style . SHADOW ) {
759798 snapshot. translate (Graphene . Point () {
760799 x = 0 ,
0 commit comments