/[svn]/gigedit/trunk/src/gigedit/regionchooser.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/regionchooser.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1657 by schoenebeck, Wed Jan 30 02:20:48 2008 UTC revision 1658 by persson, Sat Feb 2 08:52:48 2008 UTC
# Line 161  bool RegionChooser::on_expose_event(GdkE Line 161  bool RegionChooser::on_expose_event(GdkE
161      Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc();      Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc();
162      Glib::RefPtr<const Gdk::GC> white = get_style()->get_white_gc();      Glib::RefPtr<const Gdk::GC> white = get_style()->get_white_gc();
163    
     Glib::RefPtr<Pango::Context> context = get_pango_context();  
     Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context);  
   
164      window->draw_rectangle(black, false, 0, h1, w, h - 1);      window->draw_rectangle(black, false, 0, h1, w, h - 1);
165      gc->set_foreground(grey1);      gc->set_foreground(grey1);
166      int x1 = int(w * 20.5 / 128.0 + 0.5);      int x1 = int(w * 20.5 / 128.0 + 0.5);
# Line 173  bool RegionChooser::on_expose_event(GdkE Line 170  bool RegionChooser::on_expose_event(GdkE
170      window->draw_rectangle(white, true, x1 + 1, h1 + 1, x2 - x1 - 1, h - 2);      window->draw_rectangle(white, true, x1 + 1, h1 + 1, x2 - x1 - 1, h - 2);
171      window->draw_rectangle(gc, true, x2 + 1, h1 + 1,      window->draw_rectangle(gc, true, x2 + 1, h1 + 1,
172                             w - x2 - 1, h - 2);                             w - x2 - 1, h - 2);
     int octave = -1;  
173      for (int i = 0 ; i < 128 ; i++) {      for (int i = 0 ; i < 128 ; i++) {
174          int note = (i + 3) % 12;          int note = (i + 3) % 12;
175          int x = int(w * i / 128.0 + 0.5);          int x = int(w * i / 128.0 + 0.5);
# Line 187  bool RegionChooser::on_expose_event(GdkE Line 183  bool RegionChooser::on_expose_event(GdkE
183          } else if (note == 3 || note == 8) {          } else if (note == 3 || note == 8) {
184              window->draw_line(black, x, h1 + 1, x, h1 + h);              window->draw_line(black, x, h1 + 1, x, h1 + h);
185          }          }
186          if (note == 3) {          if (note == 3) draw_digit(i);
             char buf[30];  
             sprintf(buf, "<span size=\"8000\">%d</span>", octave);  
             layout->set_markup(buf);  
             Pango::Rectangle rectangle = layout->get_logical_extents();  
             double text_w = double(rectangle.get_width()) / Pango::SCALE;  
             double text_h = double(rectangle.get_height()) / Pango::SCALE;  
             double x2 = w * (i + 0.75) / 128.0;  
             window->draw_layout(black, int(x2 - text_w / 2 + 1),  
                                 int(h1 + h - text_h + 0.5), layout);  
             octave++;  
         }  
187      }      }
188    
189      if (instrument) {      if (instrument) {
# Line 248  bool RegionChooser::is_black_key(int key Line 233  bool RegionChooser::is_black_key(int key
233      return note == 1 || note == 4 || note == 6 || note == 9 || note == 11;      return note == 1 || note == 4 || note == 6 || note == 9 || note == 11;
234  }  }
235    
236    void RegionChooser::draw_digit(int key) {
237        const int h = 40;
238        const int w = get_width() - 1;
239        Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(get_pango_context());
240        char buf[30];
241        sprintf(buf, "<span size=\"8000\">%d</span>", key / 12 - 1);
242        layout->set_markup(buf);
243        Pango::Rectangle rectangle = layout->get_logical_extents();
244        double text_w = double(rectangle.get_width()) / Pango::SCALE;
245        double text_h = double(rectangle.get_height()) / Pango::SCALE;
246        double x = w * (key + 0.75) / 128.0;
247        get_window()->draw_layout(get_style()->get_black_gc(), int(x - text_w / 2 + 1),
248                                  int(h1 + h - text_h + 0.5), layout);
249    }
250    
251  void RegionChooser::draw_region(int from, int to, const Gdk::Color& color)  void RegionChooser::draw_region(int from, int to, const Gdk::Color& color)
252  {  {
253      const int h = 40;      const int h = 40;
254      const int w = get_width();      const int w = get_width() - 1;
255      const int bh = int(h * 0.55);      const int bh = int(h * 0.55);
256    
257      Glib::RefPtr<Gdk::Window> window = get_window();      Glib::RefPtr<Gdk::Window> window = get_window();
# Line 262  void RegionChooser::draw_region(int from Line 262  void RegionChooser::draw_region(int from
262          int x = int(w * i / 128.0 + 0.5) + 1;          int x = int(w * i / 128.0 + 0.5) + 1;
263          int x2 = int(w * (i + 1.5) / 128.0 + 0.5);          int x2 = int(w * (i + 1.5) / 128.0 + 0.5);
264          int x3 = int(w * (i + 1) / 128.0 + 0.5);          int x3 = int(w * (i + 1) / 128.0 + 0.5);
265          int x4 = int(w * (i - 0.5) / 128 + 0.5) + 1;          int x4 = int(w * (i - 0.5) / 128.0 + 0.5);
266          int w1 = x3 - x;          int w1 = x3 - x;
267          switch (note) {          switch (note) {
268          case 0: case 5: case 10:          case 0: case 5: case 10:
269              window->draw_rectangle(gc, true, x - 1, h1 + 1, w1, bh);              window->draw_rectangle(gc, true, x, h1 + 1, w1, bh);
270              window->draw_rectangle(gc, true, x4, h1 + bh + 1, x2 - x4 - 1, h - bh - 2);              window->draw_rectangle(gc, true, x4 + 1, h1 + bh + 1, x2 - x4 - 1, h - bh - 2);
271              break;              break;
272          case 2: case 7:          case 2: case 7:
273              window->draw_rectangle(gc, true, x, h1 + 1, w1, bh);              window->draw_rectangle(gc, true, x, h1 + 1, w1, bh);
274              window->draw_rectangle(gc, true, x4 - 1, h1 + bh + 1, x3 - x4 + 1, h - bh - 2);              window->draw_rectangle(gc, true, x4 + 1, h1 + bh + 1, x3 - x4 - 1, h - bh - 2);
275              break;              break;
276          case 3: case 8:          case 3: case 8:
277              window->draw_rectangle(gc, true, x, h1 + 1, w1, bh);              window->draw_rectangle(gc, true, x, h1 + 1, w1, bh);
278              window->draw_rectangle(gc, true, x, h1 + bh + 1, x2 - x, h - bh - 2);              window->draw_rectangle(gc, true, x, h1 + bh + 1, x2 - x, h - bh - 2);
279                if (note == 3) draw_digit(i);
280              break;              break;
281          default:          default:
282              window->draw_rectangle(gc, true, x, h1 + 1, w1 - 1, bh - 1);              window->draw_rectangle(gc, true, x, h1 + 1, w1, bh - 1);
283              break;              break;
284          }          }
285      }      }

Legend:
Removed from v.1657  
changed lines
  Added in v.1658

  ViewVC Help
Powered by ViewVC