mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:48:14 +00:00
GTableView: Add a way to hide the column headers.
There are many situations where you would want a table view without headers.
This commit is contained in:
parent
a23dddc56f
commit
a5d538b389
2 changed files with 34 additions and 17 deletions
|
@ -6,19 +6,23 @@
|
|||
#include <AK/HashMap.h>
|
||||
|
||||
class GScrollBar;
|
||||
class Painter;
|
||||
|
||||
class GTableView : public GWidget {
|
||||
public:
|
||||
explicit GTableView(GWidget* parent);
|
||||
virtual ~GTableView() override;
|
||||
|
||||
virtual int header_height() const { return 16; }
|
||||
virtual int item_height() const { return 16; }
|
||||
int header_height() const { return m_headers_visible ? 16 : 0; }
|
||||
int item_height() const { return 16; }
|
||||
|
||||
void set_model(OwnPtr<GTableModel>&&);
|
||||
GTableModel* model() { return m_model.ptr(); }
|
||||
const GTableModel* model() const { return m_model.ptr(); }
|
||||
|
||||
bool headers_visible() const { return m_headers_visible; }
|
||||
void set_headers_visible(bool headers_visible) { m_headers_visible = headers_visible; }
|
||||
|
||||
void did_update_model();
|
||||
|
||||
int content_width() const;
|
||||
|
@ -37,6 +41,7 @@ private:
|
|||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void keydown_event(GKeyEvent&) override;
|
||||
|
||||
void paint_headers(Painter&);
|
||||
void update_scrollbar_ranges();
|
||||
int item_count() const;
|
||||
Rect row_rect(int item_index) const;
|
||||
|
@ -45,6 +50,8 @@ private:
|
|||
|
||||
GScrollBar* m_vertical_scrollbar { nullptr };
|
||||
GScrollBar* m_horizontal_scrollbar { nullptr };
|
||||
GWidget* m_corner_widget { nullptr };
|
||||
OwnPtr<GTableModel> m_model;
|
||||
int m_horizontal_padding { 5 };
|
||||
bool m_headers_visible { true };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue