[gnome-music/wip/jfelder/albumwidget-full-scrollarea: 2/4] albumwidget: Simplify margin handling
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/albumwidget-full-scrollarea: 2/4] albumwidget: Simplify margin handling
- Date: Wed, 9 Jan 2019 08:05:49 +0000 (UTC)
commit 369021fc9f8a2a47b43f0c5fb30e0ecad14da439
Author: Jean Felder <jfelder src gnome org>
Date: Tue Jan 8 20:49:01 2019 +0100
albumwidget: Simplify margin handling
Move top an bottom margins to the main box. Update disc box's margin
at init time to align it with the album info box.
data/ui/AlbumWidget.ui | 16 +++++-----------
gnomemusic/widgets/albumwidget.py | 15 +++++++++------
2 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index 9909ac74..b53160db 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -16,18 +16,19 @@
<property name="vexpand">True</property>
<property name="hscrollbar_policy">never</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="_main_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_start">32</property>
+ <property name="margin_end">32</property>
+ <property name="margin_top">64</property>
+ <property name="margin_bottom">64</property>
<child>
<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="valign">start</property>
<property name="vexpand">True</property>
<signal name="size-allocate" handler="_on_album_info_size_changed" swapped="no"/>
@@ -227,15 +228,8 @@
</packing>
</child>
<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>
- <property name="margin_bottom">64</property>
- <property name="margin_end">32</property>
<property name="halign">start</property>
<property name="orientation">vertical</property>
<property name="selection_mode_allowed">True</property>
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 1a0f66ab..3e6f1ea3 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -51,6 +51,7 @@ class AlbumWidget(Gtk.EventBox):
_composer_info_label = Gtk.Template.Child()
_cover_stack = Gtk.Template.Child()
_disc_listbox = Gtk.Template.Child()
+ _main_box = Gtk.Template.Child()
_released_info_label = Gtk.Template.Child()
_running_info_label = Gtk.Template.Child()
_scrolled_window = Gtk.Template.Child()
@@ -74,7 +75,6 @@ class AlbumWidget(Gtk.EventBox):
super().__init__()
self._songs = []
- self._initial_margin_top = self._album_info.props.margin_top
self._album_info_height = 0
self._cover_stack.props.size = Art.Size.LARGE
@@ -150,7 +150,7 @@ class AlbumWidget(Gtk.EventBox):
self._set_composer_label(album)
- self._album_info.props.margin_top = self._initial_margin_top
+ self._album_info.props.margin_top = 0
self._player.connect('song-changed', self._update_model)
@@ -238,6 +238,10 @@ class AlbumWidget(Gtk.EventBox):
disc.props.show_disc_label = False
self._disc_listbox.add(disc)
+ # update first dic box margin to align it with album_info
+ first_disc_box = self._disc_listbox.get_children()[0]
+ first_disc_box.props.margin_top = self._album_info.props.margin_top
+
self._set_duration_label()
self._update_model(self._player)
@@ -292,8 +296,7 @@ class AlbumWidget(Gtk.EventBox):
@log
def _on_scroll_value_changed(self, adjustment):
- self._album_info.props.margin_top = (adjustment.props.value
- + self._initial_margin_top)
+ self._album_info.props.margin_top = adjustment.props.value
@Gtk.Template.Callback()
@log
@@ -301,6 +304,6 @@ class AlbumWidget(Gtk.EventBox):
if allocation.height != self._album_info_height:
self._album_info_height = allocation.height
min_height = (allocation.height
- + self._initial_margin_top
- + self._album_info.props.margin_bottom)
+ + self._main_box.props.margin_top
+ + self._main_box.props.margin_bottom)
self._scrolled_window.props.min_content_height = min_height
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]