MacOS [sic] required changes for Rect in Push 2 code
[ardour.git] / libs / surfaces / push2 / menu.h
index 1e6e3d6d1041f5c755a8a3ed8fced0277ee7c0a8..ef4b9e2311cc6e373877d60d191f07ce3fce3c57 100644 (file)
 #ifndef __ardour_push2_menu_h__
 #define __ardour_push2_menu_h__
 
+#include <vector>
+
 namespace Cairo {
        class Context;
        class Region;
 }
 
-#include <pangomm/layout.h>
+#include <pangomm/fontdescription.h>
 
 #include "pbd/signals.h"
 
@@ -33,6 +35,7 @@ namespace Cairo {
 namespace ArdourCanvas {
        class Text;
        class Rectangle;
+       class Rect;
 }
 
 namespace ArdourSurface {
@@ -40,34 +43,57 @@ namespace ArdourSurface {
 class Push2Menu : public ArdourCanvas::Container
 {
    public:
-       Push2Menu (ArdourCanvas::Item* parent);
+       Push2Menu (ArdourCanvas::Item* parent, std::vector<std::string>);
 
        void render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const;
 
-       void fill_column (int col, std::vector<std::string>);
-       void set_active (int col, int index);
-       void step_active (int col, int dir);
-       int get_active (int col);
+       void set_wrap (bool);
+       void set_active (uint32_t index);
 
-       PBD::Signal0<void> ActiveChanged;
-       PBD::Signal0<void> Selected;
+       uint32_t active () const { return _active; }
+       uint32_t items() const { return displays.size(); }
 
-   private:
-       struct Column {
-               std::vector<std::string> text;
-               ArdourCanvas::Rectangle* active_bg;
-               ArdourCanvas::Text* lines;
-               int top;
-               int active;
-       };
+       uint32_t rows() const { return nrows; }
+       uint32_t cols() const { return ncols; }
+
+       void set_layout (int cols, int rows);
+       void set_font_description (Pango::FontDescription);
+       void set_text_color (ArdourCanvas::Color);
+       void set_active_color (ArdourCanvas::Color);
 
-       Column  columns[8];
+       bool can_scroll_left() const { return first >= nrows; }
+       bool can_scroll_right() const { return last < displays.size() - 1; }
 
-       void scroll (int col, int dir);
-       void set_text (int col, int top);
+       enum Direction { DirectionUp, DirectionDown, DirectionLeft, DirectionRight };
+       void scroll (Direction, bool page = false);
 
-       int nrows;
-       mutable double baseline;
+       PBD::Signal0<void> ActiveChanged;
+       PBD::Signal0<void> Rearranged;
+
+   private:
+       std::vector<ArdourCanvas::Text*> displays;
+       ArdourCanvas::Rectangle* active_bg;
+
+       void rearrange (uint32_t initial_display);
+
+       double   baseline;
+       int      row_start;
+       int      col_start;
+       uint32_t ncols;
+       uint32_t nrows;
+       bool     wrap;
+       uint32_t first;
+       uint32_t last;
+       uint32_t _active;
+
+       ArdourCanvas::Color text_color;
+       ArdourCanvas::Color active_color;
+       ArdourCanvas::Color contrast_color;
+       Pango::FontDescription font_description;
+
+       inline int active_row () const { return _active % nrows; }
+       inline int active_col () const { return (_active / nrows); }
+       inline int active_top () const { return active_col() * nrows; }
 };
 
 } // namespace