]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/list.h
Add a level of indirection to decouple list rows from items
[libs/gltk.git] / source / list.h
index 05ba852949281698a6e4d32fd21706766a42c853..ef4311e0702c73b818a19ab3abaadb07e1427abb 100644 (file)
@@ -68,6 +68,12 @@ public:
                virtual void render_special(const Part &, GL::Renderer &) const;
        };
 
+       class SimpleItem: public Item
+       {
+       private:
+               virtual void on_style_change();
+       };
+
        class MultiColumnItem: public Item
        {
        protected:
@@ -79,16 +85,13 @@ public:
        };
 
 private:
-       class BasicItem: public Item
+       class BasicItem: public SimpleItem
        {
        private:
                Label label;
 
        public:
                BasicItem(const std::string &);
-
-       private:
-               virtual void on_style_change();
        };
 
        class ItemFactory
@@ -128,8 +131,17 @@ private:
                }
        };
 
+       struct Row
+       {
+               unsigned first;
+               unsigned height;
+
+               Row(unsigned f): first(f), height(0) { }
+       };
+
 public:
        sigc::signal<void, unsigned> signal_item_selected;
+       sigc::signal<void> signal_selection_cleared;
 
 private:
        ListData *data;
@@ -137,12 +149,19 @@ private:
        DataObserver *observer;
        ItemFactory *item_factory;
        int sel_index;
-       unsigned first;
+       int focus_index;
+       unsigned first_row;
        unsigned max_scroll;
-       unsigned view_size;
+       unsigned view_rows;
+       const Part *items_part;
+       bool ignore_slider_change;
+       bool dragging;
+       int drag_start_x;
+       int drag_start_y;
 
        VSlider slider;
        std::vector<Item *> items;
+       std::vector<Row> rows;
 
 public:
        List();
@@ -181,21 +200,34 @@ public:
 
        void set_selected_index(int);
        int get_selected_index() const { return sel_index; }
-
 private:
+       void set_selected_item(Widget *);
+
+       virtual void rebuild_special(const Part &);
        virtual void render_special(const Part &, GL::Renderer &) const;
 
 public:
+       virtual bool key_press(unsigned, unsigned);
        virtual void button_press(int, int, unsigned);
+       virtual void touch_press(int, int, unsigned);
+       virtual void touch_release(int, int, unsigned);
+       virtual void touch_motion(int, int, unsigned);
+       virtual void focus_in();
+       virtual bool navigate(Navigation);
 private:
-       virtual void on_geometry_change();
        virtual void on_style_change();
 
-       void reposition_slider();
-       void item_autosize_changed();
-       void reposition_items();
+       void move_focus(Navigation, bool);
+       void set_focus_index(int);
+
+       void item_autosize_changed(Item *);
+       void reposition_items(bool);
+       unsigned last_to_first_row(unsigned) const;
+       unsigned item_index_to_row(unsigned) const;
        void check_view_range();
+       void scroll_to_focus();
        void slider_value_changed(double);
+       static void adjust_index(int &, int, int);
 };
 
 } // namespace GLtk