GTreeView.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <LibGUI/GAbstractView.h>
  3. class GTreeView : public GAbstractView {
  4. C_OBJECT(GTreeView)
  5. public:
  6. virtual ~GTreeView() override;
  7. virtual void scroll_into_view(const GModelIndex&, Orientation);
  8. protected:
  9. explicit GTreeView(GWidget*);
  10. virtual void paint_event(GPaintEvent&) override;
  11. virtual void mousedown_event(GMouseEvent&) override;
  12. virtual void doubleclick_event(GMouseEvent&) override;
  13. virtual void keydown_event(GKeyEvent&) override;
  14. virtual void did_update_selection() override;
  15. virtual void did_update_model() override;
  16. virtual void context_menu_event(GContextMenuEvent&) override;
  17. private:
  18. GModelIndex index_at_content_position(const Point&, bool& is_toggle) const;
  19. int item_height() const { return 16; }
  20. int max_item_width() const { return frame_inner_rect().width(); }
  21. int indent_width_in_pixels() const { return 16; }
  22. int icon_size() const { return 16; }
  23. int icon_spacing() const { return 2; }
  24. int toggle_size() const { return 9; }
  25. int text_padding() const { return 2; }
  26. void update_content_size();
  27. void toggle_index(const GModelIndex&);
  28. template<typename Callback>
  29. void traverse_in_paint_order(Callback) const;
  30. struct MetadataForIndex;
  31. MetadataForIndex& ensure_metadata_for_index(const GModelIndex&) const;
  32. mutable HashMap<void*, NonnullOwnPtr<MetadataForIndex>> m_view_metadata;
  33. RefPtr<GraphicsBitmap> m_expand_bitmap;
  34. RefPtr<GraphicsBitmap> m_collapse_bitmap;
  35. };