mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-14 11:52:29 +00:00
Fix side-by-side alignment in the case of a single image
This commit is contained in:
parent
2b8f2e1175
commit
c0c44a9563
|
@ -237,10 +237,16 @@ class Gitg.DiffImageSideBySide : Gtk.DrawingArea
|
||||||
ctx.render_background(cr, alloc.x, alloc.y, alloc.width, alloc.height);
|
ctx.render_background(cr, alloc.x, alloc.y, alloc.width, alloc.height);
|
||||||
|
|
||||||
double max_height = double.max(sizing.old_size.image_height, sizing.new_size.image_height);
|
double max_height = double.max(sizing.old_size.image_height, sizing.new_size.image_height);
|
||||||
|
double spread_factor = 0.5;
|
||||||
|
|
||||||
|
if (old_surface != null && new_surface != null)
|
||||||
|
{
|
||||||
|
spread_factor = 2.0 / 3.0;
|
||||||
|
}
|
||||||
|
|
||||||
if (old_surface != null)
|
if (old_surface != null)
|
||||||
{
|
{
|
||||||
var x = (sizing.old_size.width - sizing.old_size.image_width) * 2 / 3;
|
var x = (sizing.old_size.width - sizing.old_size.image_width) * spread_factor;
|
||||||
var y = (max_height - sizing.old_size.image_height) / 2;
|
var y = (max_height - sizing.old_size.image_height) / 2;
|
||||||
|
|
||||||
cr.set_source_surface(old_surface, x, y);
|
cr.set_source_surface(old_surface, x, y);
|
||||||
|
@ -258,7 +264,7 @@ class Gitg.DiffImageSideBySide : Gtk.DrawingArea
|
||||||
|
|
||||||
if (new_surface != null)
|
if (new_surface != null)
|
||||||
{
|
{
|
||||||
var x = (sizing.new_size.width - sizing.new_size.image_width) * 1 / 3;
|
var x = (sizing.new_size.width - sizing.new_size.image_width) * (1.0 - spread_factor);
|
||||||
var y = (max_height - sizing.new_size.image_height) / 2;
|
var y = (max_height - sizing.new_size.image_height) / 2;
|
||||||
|
|
||||||
if (cache.old_pixbuf != null)
|
if (cache.old_pixbuf != null)
|
||||||
|
|
Loading…
Reference in a new issue