[gnome-music/wip/jfelder/playback-status-v3: 7/12] albumwidget: Dynamically align columns



commit 10127afcd41b6faedbc78e4d62ae7719da17bccd
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Sep 13 08:54:43 2018 +0200

    albumwidget: Dynamically align columns
    
    disc_listbox and _album_info vertical margins are defined in two
    separate ui files. This could lead to improper alignment if one of the
    margins is changed.
    
    Compute album_info top margin when disc_listbox is created to prevent
    this issue.

 data/ui/AlbumWidget.ui            | 7 +------
 gnomemusic/widgets/albumwidget.py | 8 ++++++++
 2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index 9dd7253d..f57634b3 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -13,13 +13,12 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
-          <object class="GtkBox" id="albumInfo">
+          <object class="GtkBox" id="_album_info">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="halign">end</property>
             <property name="margin_start">32</property>
             <property name="margin_end">32</property>
-            <property name="margin_top">64</property>
             <property name="margin_bottom">32</property>
             <property name="vexpand">True</property>
             <child>
@@ -233,10 +232,6 @@
                 <property name="hexpand">True</property>
                 <property name="shadow_type">none</property>
                 <child>
-                  <!-- TODO: The top of the coverart is the same vertical -->
-                  <!-- position as the top of the album songs, however -->
-                  <!-- since we set a top margins for the discbox -->
-                  <!-- subtract that margin here. A cleaner solution is appreciated. -->
                   <object class="DiscListBox" id="_disc_listbox">
                     <property name="can_focus">False</property>
                     <property name="margin_top">48</property>
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 55fe506c..286de2cb 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -45,6 +45,7 @@ class AlbumWidget(Gtk.EventBox):
 
     __gtype_name__ = 'AlbumWidget'
 
+    _album_info = Gtk.Template.Child()
     _artist_label = Gtk.Template.Child()
     _composer_label = Gtk.Template.Child()
     _composer_info_label = Gtk.Template.Child()
@@ -230,6 +231,13 @@ class AlbumWidget(Gtk.EventBox):
                     disc.props.show_disc_label = False
                 self._disc_listbox.add(disc)
 
+            # vertically align coverart and disc listbox
+            first_disc_box = self._disc_listbox.get_children()[0]
+            first_disc_box_margin = first_disc_box.props.margin
+            disc_box_margin = self._disc_listbox.props.margin_top
+            album_margin = disc_box_margin + first_disc_box_margin
+            self._album_info.props.margin_top = album_margin
+
             self._set_duration_label()
             self._update_model(self._player)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]