summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/ColumnsView.h
blob: 3f37463106fce3f1315fed88a637821754411a09 (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
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org>
 * Copyright (c) 2022, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Vector.h>
#include <LibGUI/AbstractView.h>

namespace GUI {

class ColumnsView : public AbstractView {
    C_OBJECT(ColumnsView)
public:
    int model_column() const { return m_model_column; }
    void set_model_column(int column) { m_model_column = column; }

    virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
    virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
    virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const&) const override;

private:
    ColumnsView();
    virtual ~ColumnsView() override = default;
    void push_column(const ModelIndex& parent_index);
    void update_column_sizes();

    int item_height() const { return 18; }
    int icon_size() const { return 16; }
    int icon_spacing() const { return 2; }
    int text_padding() const { return 2; }

    virtual void model_did_update(unsigned flags) override;
    virtual void paint_event(PaintEvent&) override;
    virtual void mousedown_event(MouseEvent& event) override;

    void move_cursor(CursorMovement, SelectionUpdate) override;

    virtual void select_all() override;
    struct Column {
        ModelIndex parent_index;
        int width;
        // TODO: per-column vertical scroll?
    };

    Vector<Column> m_columns;
    int m_model_column { 0 };
};

}