[gnome-todo] list-selector-grid-item: fix center "No tasks" label on HiDPI



commit 2058fb964f065e3e8214fd750b7a279951b619e1
Author: Kevin Lopez <kevin kevlopez com>
Date:   Wed Mar 1 23:17:49 2017 +0100

    list-selector-grid-item: fix center "No tasks" label on HiDPI
    
    In line 88 of src/views/gtd-list-selector-grid-item.c
    THUMBNAIL_SIZE it's multiplied by scale_factor and asigned to
    width variable.
    
    "width = THUMBNAIL_SIZE * scale_factor;"
    
    Also in line 145 of src/views/gtd-list-selector-grid-item.c
    to set width of the layaout, the width it's  another time
    multiplyied by the scale_factor.
    
    "pango_layout_set_width (layout, width * PANGO_SCALE * scale_factor)"
    
    The problem it's that, in HDIPI devices where the scale factor has the
    value of 2,the width of the pango layaout it's increased by factor
    of 2.
    
    So when the instruction
    "pango_layaout_set_aligment(layout, PANGO_ALIGN_CENTER)" it's executed,
    center the label "No tasks" in this new width, so it doesn't appears
    correctly, it's appear outside of the GTKImage widget.
    
    Also in the line 199 of the same file above described.
    The instruction:
    "if (y + font_height + 4 + margin.bottom +
        padding.bottom > THUMBNAIL_SIZE)"
    Doesn't take account of devices with scale-factor of 2, so draws "..."
    in the midle of the GTKImage and not in the bottom.
    
    To fix this, simply delete the multiply by scale_factor when we are
    setting the pango layout, and add to the if condition a product of
    THUMBNAIL_SIZE and scale_factor.
    
    This changes doesn't affects in non HIDPI devices, because the
    scale_factor have a value of 1, so the behaviour of the app is correct.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775964

 src/views/gtd-list-selector-grid-item.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/views/gtd-list-selector-grid-item.c b/src/views/gtd-list-selector-grid-item.c
index 99952a6..ab3752a 100644
--- a/src/views/gtd-list-selector-grid-item.c
+++ b/src/views/gtd-list-selector-grid-item.c
@@ -142,7 +142,7 @@ gtd_list_selector_grid_item__render_thumbnail (GtdListSelectorGridItem *item)
 
   pango_layout_set_font_description (layout, font_desc);
   pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
-  pango_layout_set_width (layout, width * PANGO_SCALE * scale_factor);
+  pango_layout_set_width (layout, width * PANGO_SCALE);
 
   /*
    * If the list exists and it's first element is a completed task,
@@ -196,7 +196,7 @@ gtd_list_selector_grid_item__render_thumbnail (GtdListSelectorGridItem *item)
            * If we reach the last visible row, it should draw a
            * "…" mark and stop drawing anything else
            */
-          if (y + font_height + 4 + margin.bottom + padding.bottom > THUMBNAIL_SIZE)
+          if (y + font_height + 4 + margin.bottom + padding.bottom > THUMBNAIL_SIZE * scale_factor)
             {
               pango_layout_set_text (layout,
                                      "…",


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