aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/util/size_request_box.vala
blob: f479e14e06770087d198765a5ff76e18b5ead3c1 (plain)
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
35
36
37
38
39
using Gtk;

namespace Dino.Ui {
public class SizeRequestBox : Box {
    construct {
        check_widget_leak(this);
    }

    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();
        check_widget_leak(this);
    }

    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;
    }
}
}