summaryrefslogtreecommitdiff
path: root/libcaribou/row-model.vala
blob: 83ba56e1dba2cb57d7def7d41138bbbbed93d54b (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
40
41
42
namespace Caribou {
    /**
     * Object representing a row in a level.
     *
     * This is used for implementing custom keyboard service.
     *
     * A keyboard object consists of {@link ColumnModel} objects.
     */
    public class RowModel : ScannableGroup, IScannableItem, IKeyboardObject {
        public bool scan_stepping { get; set; }
        public bool scan_selected { get; set; }

        Gee.ArrayList<ColumnModel> columns;

        public RowModel () {
            columns = new Gee.ArrayList<ColumnModel> ();
        }

        internal void add_column (ColumnModel column) {
            column.key_clicked.connect ((k) => { key_clicked (k); });
            column.key_pressed.connect ((k) => { key_pressed (k); });
            column.key_released.connect ((k) => { key_released (k); });

            columns.add(column);
        }

        public ColumnModel[] get_columns () {
            return (ColumnModel[]) columns.to_array ();
        }

        public override IScannableItem[] get_scan_children () {
            if (scan_grouping == ScanGrouping.ROWS)
                return (IScannableItem[]) get_keys ();
            else
                return (IScannableItem[]) columns.to_array ();
        }

        public IKeyboardObject[] get_children () {
            return (IKeyboardObject[]) get_columns ();
        }
    }
}