Commit eb7f6ae8 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko

ui: Add DisplayBin

This bin can offset child without changing its size. This will be used in
the next commit to ensure game never changes height when the savestates
sidebar slides out.
parent 8ad80e43
......@@ -138,6 +138,7 @@ vala_sources = [
'ui/collection-icon-view.vala',
'ui/collection-header-bar.vala',
'ui/collection-view.vala',
'ui/display-bin.vala',
'ui/display-box.vala',
'ui/display-header-bar.vala',
'ui/display-view.vala',
......
// This file is part of GNOME Games. License: GPL-3.0+.
public class Games.DisplayBin : Gtk.Bin {
private int _horizontal_offset;
public int horizontal_offset {
get { return _horizontal_offset; }
set {
_horizontal_offset = value;
queue_allocate ();
}
}
private int _vertical_offset;
public int vertical_offset {
get { return _vertical_offset; }
set {
_vertical_offset = value;
queue_allocate ();
}
}
public override void size_allocate (Gtk.Allocation allocation) {
set_allocation (allocation);
var child = get_child ();
if (child != null && child.visible) {
Gtk.Allocation child_allocation = {};
if (get_direction () == Gtk.TextDirection.RTL)
child_allocation.x = allocation.x - horizontal_offset;
else
child_allocation.x = allocation.x + horizontal_offset;
child_allocation.y = allocation.y + vertical_offset;
child_allocation.width = allocation.width;
child_allocation.height = allocation.height;
child.size_allocate (child_allocation);
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment