--- gigedit/trunk/src/gigedit/regionchooser.h 2007/09/10 19:56:26 1339 +++ gigedit/trunk/src/gigedit/regionchooser.h 2008/02/02 08:52:48 1658 @@ -1,5 +1,5 @@ /* -*- c++ -*- - * Copyright (C) 2006, 2007 Andreas Persson + * Copyright (C) 2006-2008 Andreas Persson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -20,6 +20,8 @@ #ifndef GIGEDIT_REGIONCHOOSER_H #define GIGEDIT_REGIONCHOOSER_H +#include + #include #include #include @@ -30,6 +32,20 @@ #include +class SortedRegions { +private: + std::vector regions; + std::vector::iterator region_iterator; + +public: + void update(gig::Instrument* instrument); + gig::Region* first(); + gig::Region* next(); + bool operator() (gig::Region* x, gig::Region* y) { + return x->KeyRange.low < y->KeyRange.low; + } +}; + class RegionChooser : public Gtk::DrawingArea { public: @@ -49,6 +65,9 @@ gig::Region* get_region() { return region; } + void on_note_on_event(int key, int velocity); + void on_note_off_event(int key, int velocity); + protected: virtual void on_realize(); virtual bool on_expose_event(GdkEventExpose* e); @@ -60,9 +79,7 @@ gig::Region* get_region(int key); Glib::RefPtr gc; - Gdk::Color blue, red, grey1; - - void draw_region(int from, int to, const Gdk::Color& color); + Gdk::Color activeKeyColor, red, grey1, white, black; sigc::signal region_selected; sigc::signal instrument_changed; @@ -75,7 +92,11 @@ gig::Instrument* instrument; gig::Region* region; + SortedRegions regions; + bool is_black_key(int key); + void draw_region(int from, int to, const Gdk::Color& color); + void draw_digit(int key); void motion_resize_region(int x, int y); void motion_move_region(int x, int y); @@ -107,7 +128,6 @@ bool is_in_resize_zone(double x, double y); int h1; - int width; Gtk::Menu* popup_menu_inside_region; Gtk::Menu* popup_menu_outside_region;