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

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

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

revision 2169 by persson, Sun Mar 6 07:51:04 2011 UTC revision 3131 by schoenebeck, Thu Apr 27 17:28:01 2017 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006-2011 Andreas Persson   * Copyright (C) 2006-2017 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 22  Line 22 
22    
23  #include <vector>  #include <vector>
24    
25    #include <gtkmm/box.h>
26  #include <gtkmm/drawingarea.h>  #include <gtkmm/drawingarea.h>
27  #include <gtkmm/uimanager.h>  #include <gtkmm/uimanager.h>
28  #include <gdkmm/window.h>  #include <gdkmm/window.h>
# Line 31  Line 32 
32  #include "paramedit.h"  #include "paramedit.h"
33  #include "compat.h"  #include "compat.h"
34    
35  #include <gig.h>  #ifdef LIBGIG_HEADER_FILE
36    # include LIBGIG_HEADER_FILE(gig.h)
37    #else
38    # include <gig.h>
39    #endif
40    
41  enum virt_keyboard_mode_t {  enum virt_keyboard_mode_t {
42      VIRT_KEYBOARD_MODE_NORMAL,      VIRT_KEYBOARD_MODE_NORMAL,
# Line 47  public: Line 52  public:
52      void update(gig::Instrument* instrument);      void update(gig::Instrument* instrument);
53      gig::Region* first();      gig::Region* first();
54      gig::Region* next();      gig::Region* next();
55      bool operator() (gig::Region* x, gig::Region* y) {      bool operator() (gig::Region* x, gig::Region* y) const {
56          return x->KeyRange.low < y->KeyRange.low;          return x->KeyRange.low < y->KeyRange.low;
57      }      }
58  };  };
# Line 73  public: Line 78  public:
78      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
79    
80      gig::Region* get_region() { return region; }      gig::Region* get_region() { return region; }
81        void set_region(gig::Region* region);
82        void select_next_region();
83        void select_prev_region();
84    
85      void on_note_on_event(int key, int velocity);      void on_note_on_event(int key, int velocity);
86      void on_note_off_event(int key, int velocity);      void on_note_off_event(int key, int velocity);
# Line 82  public: Line 90  public:
90  protected:  protected:
91  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
92      virtual bool on_expose_event(GdkEventExpose* e);      virtual bool on_expose_event(GdkEventExpose* e);
93  #endif  #else
94      virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);      virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
95    #endif
96      virtual bool on_button_press_event(GdkEventButton* event);      virtual bool on_button_press_event(GdkEventButton* event);
97      virtual bool on_button_release_event(GdkEventButton* event);      virtual bool on_button_release_event(GdkEventButton* event);
98      virtual bool on_motion_notify_event(GdkEventMotion* event);      virtual bool on_motion_notify_event(GdkEventMotion* event);
99    
100      gig::Region* get_region(int key);      gig::Region* get_region(int key);
101    
102      Gdk::RGBA activeKeyColor, red, grey1, white, black;      Gdk::RGBA activeKeyColor, blue, grey1, white, black;
103    
104      sigc::signal<void> region_selected;      sigc::signal<void> region_selected;
105      sigc::signal<void> instrument_changed;      sigc::signal<void> instrument_changed;
# Line 109  protected: Line 118  protected:
118      SortedRegions regions;      SortedRegions regions;
119    
120      bool is_black_key(int key);      bool is_black_key(int key);
121      void draw_key(int key, const Gdk::RGBA& color);      void draw_keyboard(const Cairo::RefPtr<Cairo::Context>& cr,
122      void draw_digit(int key);                         int clip_low, int clip_high);
123        void draw_regions(const Cairo::RefPtr<Cairo::Context>& cr,
124                          int clip_low, int clip_high);
125        void draw_key(const Cairo::RefPtr<Cairo::Context>& cr, int key);
126        void draw_digit(const Cairo::RefPtr<Cairo::Context>& cr, int key);
127      void motion_resize_region(int x, int y);      void motion_resize_region(int x, int y);
128      void motion_move_region(int x, int y);      void motion_move_region(int x, int y);
129        void update_after_resize();
130        void update_after_move(int pos);
131        void invalidate_key(int key);
132    
133        // returns the leftmost pixel of a key
134        int key_to_x(double k, int w) const {
135            return int(k * w / 128.0 + 0.5);
136        }
137    
138        // returns the key given a pixel
139        int x_to_key(double x, int w) const {
140            return int(x / w * 128.0);
141        }
142    
143        // returns the key given a pixel. If the pixel is the border
144        // between two keys, the key to the ríght is always returned.
145        int x_to_key_right(double x, int w) const {
146            return int(ceil((x + 0.5) / w * 128.0)) - 1;
147        }
148    
149      // information needed during a resize      // information needed during a resize
150      struct {      struct {
# Line 132  protected: Line 164  protected:
164      // information needed during a region move      // information needed during a region move
165      struct {      struct {
166          bool active;          bool active;
167          double from_x;          int offset;
         int pos;  
         bool touch_left;  
         bool touch_right;  
168      } move;      } move;
169    
170      bool cursor_is_resize;      bool cursor_is_resize;
# Line 155  protected: Line 184  protected:
184      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<Gtk::ActionGroup> actionGroup;
185      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
186    
187      // properties of the virtaul keyboard      // properties of the virtual keyboard
188      ChoiceEntry<virt_keyboard_mode_t> m_VirtKeybModeChoice;      ChoiceEntry<virt_keyboard_mode_t> m_VirtKeybModeChoice;
189      Gtk::Label m_VirtKeybVelocityLabelDescr;      Gtk::Label m_VirtKeybVelocityLabelDescr;
190      Gtk::Label m_VirtKeybVelocityLabel;      Gtk::Label m_VirtKeybVelocityLabel;
191      Gtk::Label m_VirtKeybOffVelocityLabelDescr;      Gtk::Label m_VirtKeybOffVelocityLabelDescr;
192      Gtk::Label m_VirtKeybOffVelocityLabel;      Gtk::Label m_VirtKeybOffVelocityLabel;
193      int currentActiveKey;      int currentActiveKey;
194        bool key_pressed[128];
195    
196      DimensionManager dimensionManager;      DimensionManager dimensionManager;
197  };  };

Legend:
Removed from v.2169  
changed lines
  Added in v.3131

  ViewVC Help
Powered by ViewVC