aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/util/size_request_box.vala
blob: 98f1a20a8ea0c931364723252fc5b1f2585a42f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Gtk;

namespace Dino.Ui {
public class SizeRequestBox : Box {
    public SizeRequestMode size_request_mode { get; set; default = SizeRequestMode.CONSTANT_SIZE; }

    public override Gtk.SizeRequestMode get_request_mode() {
        return size_request_mode;
    }
}

public class SizeRequestBin : Widget {
    public SizeRequestMode size_request_mode { get; set; default = SizeRequestMode.CONSTANT_SIZE; }

    construct {
        this.layout_manager = new BinLayout();
    }

    public override void compute_expand_internal(out bool hexpand, out bool vexpand) {
        hexpand = false;
        vexpand = false;
        Widget child = get_first_child();
        while (child != null) {
            hexpand = hexpand || child.compute_expand(Orientation.HORIZONTAL);
            vexpand = vexpand || child.compute_expand(Orientation.VERTICAL);
            child = child.get_next_sibling();
        }
    }

    public override Gtk.SizeRequestMode get_request_mode() {
        return size_request_mode;
    }
}
}