summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/GTreeView.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-04 16:16:50 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-04 16:16:50 +0200
commit04b9dc2d30cfc9b383029f6a4b02e2725108b0ae (patch)
treee117a998173b767f9fd009d49c4f8573d8b85432 /Libraries/LibGUI/GTreeView.h
parent63814ffebf16291419745cd8ba29a4d2fd888563 (diff)
downloadserenity-04b9dc2d30cfc9b383029f6a4b02e2725108b0ae.zip
Libraries: Create top level directory for libraries.
Things were getting a little crowded in the project root, so this patch moves the Lib*/ directories into Libraries/.
Diffstat (limited to 'Libraries/LibGUI/GTreeView.h')
-rw-r--r--Libraries/LibGUI/GTreeView.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GTreeView.h b/Libraries/LibGUI/GTreeView.h
new file mode 100644
index 0000000000..6fe0df6e69
--- /dev/null
+++ b/Libraries/LibGUI/GTreeView.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <LibGUI/GAbstractView.h>
+
+class GTreeView : public GAbstractView {
+public:
+ explicit GTreeView(GWidget*);
+ virtual ~GTreeView() override;
+
+ virtual void scroll_into_view(const GModelIndex&, Orientation);
+ virtual const char* class_name() const override { return "GTreeView"; }
+
+protected:
+ virtual void paint_event(GPaintEvent&) override;
+ virtual void mousedown_event(GMouseEvent&) override;
+ virtual void keydown_event(GKeyEvent&) override;
+ virtual void did_update_selection() override;
+ virtual void did_update_model() override;
+
+private:
+ GModelIndex index_at_content_position(const Point&, bool& is_toggle) const;
+ int item_height() const { return 16; }
+ int max_item_width() const { return frame_inner_rect().width(); }
+ int indent_width_in_pixels() const { return 16; }
+ int icon_size() const { return 16; }
+ int icon_spacing() const { return 2; }
+ int toggle_size() const { return 9; }
+ int text_padding() const { return 2; }
+ void update_content_size();
+
+ template<typename Callback>
+ void traverse_in_paint_order(Callback) const;
+
+ struct MetadataForIndex;
+
+ MetadataForIndex& ensure_metadata_for_index(const GModelIndex&) const;
+
+ mutable HashMap<void*, OwnPtr<MetadataForIndex>> m_view_metadata;
+
+ RefPtr<GraphicsBitmap> m_expand_bitmap;
+ RefPtr<GraphicsBitmap> m_collapse_bitmap;
+};