mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
GTableView: Add a way to customize cell painting per-column
You can now set a GTableCellPaintingDelegate per column in GTableView. For columns with a painting delegate set, the view will defer to the delegate for painting each cell in that column.
This commit is contained in:
parent
b777f740a4
commit
9789ee9b58
2 changed files with 34 additions and 13 deletions
|
@ -5,9 +5,17 @@
|
|||
#include <LibGUI/GAbstractView.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
|
||||
class GPainter;
|
||||
class GScrollBar;
|
||||
class Painter;
|
||||
|
||||
class GTableCellPaintingDelegate {
|
||||
public:
|
||||
virtual ~GTableCellPaintingDelegate() {}
|
||||
|
||||
virtual void paint(GPainter&, const Rect&, const GModel&, const GModelIndex&) = 0;
|
||||
};
|
||||
|
||||
class GTableView : public GAbstractView {
|
||||
C_OBJECT(GTableView)
|
||||
public:
|
||||
|
@ -38,6 +46,8 @@ public:
|
|||
|
||||
virtual Rect content_rect(const GModelIndex&) const override;
|
||||
|
||||
void set_cell_painting_delegate(int column, OwnPtr<GTableCellPaintingDelegate>&&);
|
||||
|
||||
private:
|
||||
virtual void did_update_model() override;
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
|
@ -67,6 +77,7 @@ private:
|
|||
bool has_initialized_width { false };
|
||||
bool visibility { true };
|
||||
RefPtr<GAction> visibility_action;
|
||||
OwnPtr<GTableCellPaintingDelegate> cell_painting_delegate;
|
||||
};
|
||||
ColumnData& column_data(int column) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue