mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 01:32:14 -05:00
LibGUI: Move index_at_event_position() up to GAbstractView
It's now an abstract (pure virtual) public method in GAbstractView that individual widgets have to implement. This will allow us to move more selection-related logic into GAbstractView in order to share it between implementations.
This commit is contained in:
parent
ff66101f9e
commit
91d3fc54be
Notes:
sideshowbarker
2024-07-19 09:53:13 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/91d3fc54be8 Pull-request: https://github.com/SerenityOS/serenity/pull/1115
6 changed files with 16 additions and 5 deletions
|
@ -396,6 +396,13 @@ GModelIndex GAbstractColumnView::index_at_event_position(const Point& position,
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GModelIndex GAbstractColumnView::index_at_event_position(const Point& position) const
|
||||||
|
{
|
||||||
|
bool is_toggle;
|
||||||
|
auto index = index_at_event_position(position, is_toggle);
|
||||||
|
return is_toggle ? GModelIndex() : index;
|
||||||
|
}
|
||||||
|
|
||||||
int GAbstractColumnView::item_count() const
|
int GAbstractColumnView::item_count() const
|
||||||
{
|
{
|
||||||
if (!model())
|
if (!model())
|
||||||
|
|
|
@ -68,6 +68,9 @@ public:
|
||||||
|
|
||||||
void scroll_into_view(const GModelIndex&, Orientation);
|
void scroll_into_view(const GModelIndex&, Orientation);
|
||||||
|
|
||||||
|
virtual GModelIndex index_at_event_position(const Point&, bool& is_toggle) const;
|
||||||
|
virtual GModelIndex index_at_event_position(const Point&) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~GAbstractColumnView() override;
|
virtual ~GAbstractColumnView() override;
|
||||||
explicit GAbstractColumnView(GWidget* parent);
|
explicit GAbstractColumnView(GWidget* parent);
|
||||||
|
@ -81,7 +84,6 @@ protected:
|
||||||
virtual void leave_event(CEvent&) override;
|
virtual void leave_event(CEvent&) override;
|
||||||
virtual void context_menu_event(GContextMenuEvent&) override;
|
virtual void context_menu_event(GContextMenuEvent&) override;
|
||||||
|
|
||||||
virtual GModelIndex index_at_event_position(const Point&, bool& is_toggle) const;
|
|
||||||
virtual void toggle_index(const GModelIndex&) {}
|
virtual void toggle_index(const GModelIndex&) {}
|
||||||
|
|
||||||
void paint_headers(GPainter&);
|
void paint_headers(GPainter&);
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
virtual void did_update_selection();
|
virtual void did_update_selection();
|
||||||
|
|
||||||
virtual Rect content_rect(const GModelIndex&) const { return {}; }
|
virtual Rect content_rect(const GModelIndex&) const { return {}; }
|
||||||
|
virtual GModelIndex index_at_event_position(const Point&) const = 0;
|
||||||
void begin_editing(const GModelIndex&);
|
void begin_editing(const GModelIndex&);
|
||||||
void stop_editing();
|
void stop_editing();
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,11 @@ public:
|
||||||
int model_column() const { return m_model_column; }
|
int model_column() const { return m_model_column; }
|
||||||
void set_model_column(int column) { m_model_column = column; }
|
void set_model_column(int column) { m_model_column = column; }
|
||||||
|
|
||||||
|
virtual GModelIndex index_at_event_position(const Point&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GColumnsView(GWidget* parent = nullptr);
|
GColumnsView(GWidget* parent = nullptr);
|
||||||
virtual ~GColumnsView();
|
virtual ~GColumnsView();
|
||||||
|
|
||||||
GModelIndex index_at_event_position(const Point&) const;
|
|
||||||
void push_column(GModelIndex& parent_index);
|
void push_column(GModelIndex& parent_index);
|
||||||
void update_column_sizes();
|
void update_column_sizes();
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
int model_column() const { return m_model_column; }
|
int model_column() const { return m_model_column; }
|
||||||
void set_model_column(int column) { m_model_column = column; }
|
void set_model_column(int column) { m_model_column = column; }
|
||||||
|
|
||||||
|
virtual GModelIndex index_at_event_position(const Point&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit GItemView(GWidget* parent);
|
explicit GItemView(GWidget* parent);
|
||||||
|
|
||||||
|
@ -64,7 +66,6 @@ private:
|
||||||
|
|
||||||
int item_count() const;
|
int item_count() const;
|
||||||
Rect item_rect(int item_index) const;
|
Rect item_rect(int item_index) const;
|
||||||
GModelIndex index_at_event_position(const Point&) const;
|
|
||||||
Vector<int> items_intersecting_rect(const Rect&) const;
|
Vector<int> items_intersecting_rect(const Rect&) const;
|
||||||
void update_content_size();
|
void update_content_size();
|
||||||
void get_item_rects(int item_index, const Font&, const GVariant& item_text, Rect& item_rect, Rect& icon_rect, Rect& text_rect) const;
|
void get_item_rects(int item_index, const Font&, const GVariant& item_text, Rect& item_rect, Rect& icon_rect, Rect& text_rect) const;
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
Point adjusted_position(const Point&) const;
|
Point adjusted_position(const Point&) const;
|
||||||
|
|
||||||
GModelIndex index_at_event_position(const Point&) const;
|
virtual GModelIndex index_at_event_position(const Point&) const override;
|
||||||
virtual Rect content_rect(const GModelIndex&) const override;
|
virtual Rect content_rect(const GModelIndex&) const override;
|
||||||
|
|
||||||
int model_column() const { return m_model_column; }
|
int model_column() const { return m_model_column; }
|
||||||
|
|
Loading…
Reference in a new issue