zkv1000 / Nasal / MFD.pages.nas /
0353c3b 7 years ago
1 contributor
41 lines | 1.826kb
displayClass.MFD = {
    NRST: {
        'NEAREST VOR' : func {
            # just a POC
            print('here there will be a page for searching nearest VORs');
        },
    },
};

displayClass.setMFDPages = func {
    foreach (var g; me.device.data['page selection']) {
        var obj_s = size(g.objects);
        # build specific geometry per page, depending of number of sub-pages
        g.geometry = {x: 720, y: 758 - ((obj_s + 3) * 24), w: 300, l: obj_s + 1, sep: 1};
        # complete the hash with reccurrent elements type and callback
        var firstEntry = 1;
        foreach (var o; g.objects) {
            if (contains(me.MFD, g.name) and contains(me.MFD[g.name], o.text)) {
                o.type = firstEntry ? 'selected' : 'editable';
                o.type ~= '|end-of-line';
                o.callback = me.device.buttons.MFD_page_wrapper;
                firstEntry = ! firstEntry;
            }
            else
                o.type = 'normal|end-of-line';
        }
    }
    # build the available groups line, at the bottom
    forindex (var g; me.device.data['page selection']) {
        append(me.device.data['page selection'][g].objects, {type: 'separator'});
        for (var i = 0; i < g; i+=1)
            append(me.device.data['page selection'][g].objects,
                {text: me.device.data['page selection'][i].name, type: 'normal'});
        append(me.device.data['page selection'][g].objects,
            {text: me.device.data['page selection'][i].name, type: 'highlighted'});
        for (var i = g+1; i < size(me.device.data['page selection']); i+=1)
            append(me.device.data['page selection'][g].objects,
                {text: me.device.data['page selection'][i].name, type: 'normal'});
    }
    me.device.knobs.FmsOuter = me.device.knobs.MFD_select_page_group;
};