mirror of
https://github.com/RGBCube/serenity
synced 2025-07-05 08:57:35 +00:00
LibGUI: Factor out scrolling logic from GTableView into a GScrollableWidget.
This then becomes the base class for GTableView. I'd like to share as much code as possible with GTextEditor and any other scrollable widgets.
This commit is contained in:
parent
dd5ca1940a
commit
6fbabac460
5 changed files with 168 additions and 93 deletions
|
@ -1,14 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GTableModel.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GScrollableWidget.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
||||
class GScrollBar;
|
||||
class Painter;
|
||||
|
||||
class GTableView : public GWidget {
|
||||
class GTableView : public GScrollableWidget {
|
||||
public:
|
||||
explicit GTableView(GWidget* parent);
|
||||
virtual ~GTableView() override;
|
||||
|
@ -33,27 +33,22 @@ public:
|
|||
|
||||
virtual bool accepts_focus() const override { return true; }
|
||||
|
||||
Rect visible_content_rect() const;
|
||||
void scroll_into_view(const GModelIndex&, Orientation);
|
||||
|
||||
private:
|
||||
virtual void model_notification(const GModelNotification&);
|
||||
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
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;
|
||||
Rect header_rect(int) const;
|
||||
int column_width(int) const;
|
||||
void update_content_size();
|
||||
|
||||
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