/[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 2246 by persson, Fri Aug 19 10:55:41 2011 UTC revision 2663 by schoenebeck, Wed Jul 2 23:53:21 2014 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2011 Andreas Persson   * Copyright (C) 2006-2014 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 20  Line 20 
20  #include "regionchooser.h"  #include "regionchooser.h"
21    
22  #include <algorithm>  #include <algorithm>
 #include <sstream>  
23    
24  #include <cairomm/context.h>  #include <cairomm/context.h>
25  #include <gdkmm/general.h>  #include <gdkmm/general.h>
# Line 31  Line 30 
30    
31  #include "global.h"  #include "global.h"
32    
33  #define REGION_BLOCK_HEIGHT             20  #define REGION_BLOCK_HEIGHT             30
34  #define KEYBOARD_HEIGHT                 40  #define KEYBOARD_HEIGHT                 40
35    
36  void SortedRegions::update(gig::Instrument* instrument) {  void SortedRegions::update(gig::Instrument* instrument) {
# Line 155  RegionChooser::RegionChooser() : Line 154  RegionChooser::RegionChooser() :
154      keyboard_key_released_signal.connect(      keyboard_key_released_signal.connect(
155          sigc::mem_fun(*this, &RegionChooser::on_note_off_event)          sigc::mem_fun(*this, &RegionChooser::on_note_off_event)
156      );      );
157        set_tooltip_text(_("Right click here for adding new region. Use mouse pointer for moving (dragging) or resizing existing regions (by pointing at region's boundary). Right click on an existing region for more actions."));
158  }  }
159    
160  RegionChooser::~RegionChooser()  RegionChooser::~RegionChooser()
161  {  {
162  }  }
163    
 template<class T> inline std::string ToString(T o) {  
     std::stringstream ss;  
     ss << o;  
     return ss.str();  
 }  
   
164  void RegionChooser::invalidate_key(int key) {  void RegionChooser::invalidate_key(int key) {
165      const int h = KEYBOARD_HEIGHT;      const int h = KEYBOARD_HEIGHT;
166      const int w = get_width() - 1;      const int w = get_width() - 1;
# Line 219  bool RegionChooser::on_draw(const Cairo: Line 213  bool RegionChooser::on_draw(const Cairo:
213      Gdk::Cairo::set_source_rgba(cr, bg);      Gdk::Cairo::set_source_rgba(cr, bg);
214      cr->paint();      cr->paint();
215    
     const int w = get_width() - 1;  
   
216      if (clipy2 > h1) {      if (clipy2 > h1) {
217          draw_keyboard(cr, clipx1, clipx2);          draw_keyboard(cr, clipx1, clipx2);
218      }      }
# Line 338  void RegionChooser::draw_regions(const C Line 330  void RegionChooser::draw_regions(const C
330          cr->line_to(x + 0.5, h1 - 1);          cr->line_to(x + 0.5, h1 - 1);
331          cr->stroke();          cr->stroke();
332      }      }
333    
334        // if there is no region yet, show the user some hint text that he may
335        // right click on this area to create a new region
336        if (!regions.first()) {
337            Glib::RefPtr<Pango::Context> context = get_pango_context();
338            Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context);
339            layout->set_alignment(Pango::ALIGN_CENTER);
340            layout->set_text(Glib::ustring("*** ") + _("Right click here to create a region.") + " ***");
341            layout->set_width(get_width() * Pango::SCALE);
342            //layout->set_height(get_height() * Pango::SCALE);
343            layout->set_spacing(10);
344            Gdk::Cairo::set_source_rgba(cr, red);        
345            // get the text dimensions
346            Pango::Rectangle rect = layout->get_logical_extents();
347            int text_width, text_height;
348            layout->get_pixel_size(text_width, text_height);
349            cr->move_to(0, (REGION_BLOCK_HEIGHT - text_height) / 2);
350    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 16) || GTKMM_MAJOR_VERSION < 2
351            pango_cairo_show_layout(cr->cobj(), layout->gobj());
352    #else
353            layout->show_in_cairo_context(cr);
354    #endif
355        }
356  }  }
357    
358  bool RegionChooser::is_black_key(int key) {  bool RegionChooser::is_black_key(int key) {
# Line 523  bool RegionChooser::on_button_press_even Line 538  bool RegionChooser::on_button_press_even
538          }          }
539      }      }
540    
541        // left mouse button double click
542        if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
543            if (event->y < REGION_BLOCK_HEIGHT) {
544                // show dimension manager dialog for this region
545                manage_dimensions();
546            }
547        }
548    
549      if (event->y >= REGION_BLOCK_HEIGHT) return true;      if (event->y >= REGION_BLOCK_HEIGHT) return true;
550      if (event->type == GDK_BUTTON_PRESS && event->button == 3) {      if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
551          gig::Region* r = get_region(k);          gig::Region* r = get_region(k);

Legend:
Removed from v.2246  
changed lines
  Added in v.2663

  ViewVC Help
Powered by ViewVC