2020-01-18 11:38:21 +03:00
|
|
|
/*
|
2020-01-24 16:45:29 +03:00
|
|
|
* Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org>
|
2020-01-18 11:38:21 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2020-01-10 19:07:08 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Vector.h>
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/AbstractView.h>
|
2020-01-10 19:07:08 +03:00
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class ColumnsView : public AbstractView {
|
|
|
|
C_OBJECT(ColumnsView)
|
2020-01-10 19:07:08 +03:00
|
|
|
public:
|
|
|
|
int model_column() const { return m_model_column; }
|
|
|
|
void set_model_column(int column) { m_model_column = column; }
|
|
|
|
|
2020-06-10 11:57:59 +03:00
|
|
|
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
|
2020-09-24 12:50:47 +03:00
|
|
|
virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
|
2021-07-10 18:11:04 +03:00
|
|
|
virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const&) const override;
|
2020-01-22 18:13:01 +03:00
|
|
|
|
2020-01-10 19:07:08 +03:00
|
|
|
private:
|
2020-02-23 14:07:13 +03:00
|
|
|
ColumnsView();
|
|
|
|
virtual ~ColumnsView() override;
|
2020-09-01 17:26:32 +03:00
|
|
|
void push_column(const ModelIndex& parent_index);
|
2020-01-10 19:07:08 +03:00
|
|
|
void update_column_sizes();
|
|
|
|
|
2021-03-04 07:39:56 +03:00
|
|
|
int item_height() const { return 18; }
|
2020-01-10 19:07:08 +03:00
|
|
|
int icon_size() const { return 16; }
|
|
|
|
int icon_spacing() const { return 2; }
|
|
|
|
int text_padding() const { return 2; }
|
|
|
|
|
2020-11-26 10:40:14 +03:00
|
|
|
virtual void model_did_update(unsigned flags) override;
|
2020-02-02 17:07:41 +03:00
|
|
|
virtual void paint_event(PaintEvent&) override;
|
|
|
|
virtual void mousedown_event(MouseEvent& event) override;
|
2020-01-10 19:07:08 +03:00
|
|
|
|
2020-09-01 17:26:32 +03:00
|
|
|
void move_cursor(CursorMovement, SelectionUpdate) override;
|
|
|
|
|
2020-02-25 18:03:15 +03:00
|
|
|
virtual void select_all() override;
|
2020-01-10 19:07:08 +03:00
|
|
|
struct Column {
|
2020-02-02 17:07:41 +03:00
|
|
|
ModelIndex parent_index;
|
2020-01-10 19:07:08 +03:00
|
|
|
int width;
|
|
|
|
// TODO: per-column vertical scroll?
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Column> m_columns;
|
2020-01-21 23:05:34 +03:00
|
|
|
int m_model_column { 0 };
|
2020-01-10 19:07:08 +03:00
|
|
|
};
|
2020-02-02 17:07:41 +03:00
|
|
|
|
|
|
|
}
|