GTableView: Make it possible to resize the columns with the mouse.

The GModel now merely provides an initial width for the columns. Once that
has been queried, the table view manages width from then on.
This commit is contained in:
Andreas Kling 2019-05-04 23:45:31 +02:00
parent f3aec1a0d9
commit 48e3ea9e5c
Notes: sideshowbarker 2024-07-19 14:15:07 +09:00
2 changed files with 101 additions and 22 deletions

View file

@ -40,19 +40,35 @@ private:
virtual void did_update_model() override;
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void doubleclick_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual void leave_event(CEvent&) override;
Rect content_rect(int row, int column) const;
void paint_headers(Painter&);
int item_count() const;
Rect row_rect(int item_index) const;
Rect header_rect(int) const;
Rect column_resize_grabbable_rect(int) const;
int column_width(int) const;
void update_content_size();
Vector<bool> m_column_visibility;
struct ColumnData {
int width { 0 };
bool has_initialized_width { false };
bool visibility { true };
};
ColumnData& column_data(int column) const;
mutable Vector<ColumnData> m_column_data;
int m_horizontal_padding { 5 };
bool m_headers_visible { true };
bool m_alternating_row_colors { true };
bool m_in_column_resize { false };
Point m_column_resize_origin;
int m_column_resize_original_width { 0 };
int m_resizing_column { -1 };
};