/[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 1660 by schoenebeck, Sun Feb 3 00:19:55 2008 UTC revision 3409 by schoenebeck, Tue Jan 23 16:30:56 2018 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006-2008 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 "compat.h"
26    
27    #include <gtkmm/box.h>
28  #include <gtkmm/drawingarea.h>  #include <gtkmm/drawingarea.h>
 #include <gdkmm/colormap.h>  
 #include <gtkmm/uimanager.h>  
29  #include <gdkmm/window.h>  #include <gdkmm/window.h>
30  #include <gtkmm/menu.h>  #include <gtkmm/menu.h>
31    
32    #if USE_GTKMM_BUILDER
33    # include <gtkmm/builder.h>
34    #else
35    # include <gtkmm/uimanager.h> // deprecated in gtkmm >= 3.21.4
36    #endif
37    
38  #include "dimensionmanager.h"  #include "dimensionmanager.h"
39    #include "paramedit.h"
40    #include "compat.h"
41    
42  #include <gig.h>  #ifdef LIBGIG_HEADER_FILE
43    # include LIBGIG_HEADER_FILE(gig.h)
44    #else
45    # include <gig.h>
46    #endif
47    
48    enum virt_keyboard_mode_t {
49        VIRT_KEYBOARD_MODE_NORMAL,
50        VIRT_KEYBOARD_MODE_CHORD
51    };
52    
53  class SortedRegions {  class SortedRegions {
54  private:  private:
# Line 41  public: Line 59  public:
59      void update(gig::Instrument* instrument);      void update(gig::Instrument* instrument);
60      gig::Region* first();      gig::Region* first();
61      gig::Region* next();      gig::Region* next();
62      bool operator() (gig::Region* x, gig::Region* y) {      bool operator() (gig::Region* x, gig::Region* y) const {
63          return x->KeyRange.low < y->KeyRange.low;          return x->KeyRange.low < y->KeyRange.low;
64      }      }
65  };  };
# Line 54  public: Line 72  public:
72    
73      void set_instrument(gig::Instrument* instrument);      void set_instrument(gig::Instrument* instrument);
74    
75        // ATM only used for painting auto selected regions with gray hatched pattern
76        void setModifyAllRegions(bool b);
77    
78      sigc::signal<void>& signal_region_selected();      sigc::signal<void>& signal_region_selected();
79      sigc::signal<void>& signal_instrument_changed();      sigc::signal<void>& signal_instrument_changed();
80    
# Line 67  public: Line 88  public:
88      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
89    
90      gig::Region* get_region() { return region; }      gig::Region* get_region() { return region; }
91        void set_region(gig::Region* region);
92        void select_next_region();
93        void select_prev_region();
94    
95      void on_note_on_event(int key, int velocity);      void on_note_on_event(int key, int velocity);
96      void on_note_off_event(int key, int velocity);      void on_note_off_event(int key, int velocity);
97    
98        HBox m_VirtKeybPropsBox;
99    
100  protected:  protected:
101      virtual void on_realize();  #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
102      virtual bool on_expose_event(GdkEventExpose* e);      virtual bool on_expose_event(GdkEventExpose* e);
103      virtual void on_size_request(GtkRequisition* requisition);  #else
104        virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
105    #endif
106      virtual bool on_button_press_event(GdkEventButton* event);      virtual bool on_button_press_event(GdkEventButton* event);
107      virtual bool on_button_release_event(GdkEventButton* event);      virtual bool on_button_release_event(GdkEventButton* event);
108      virtual bool on_motion_notify_event(GdkEventMotion* event);      virtual bool on_motion_notify_event(GdkEventMotion* event);
109    
110      gig::Region* get_region(int key);      gig::Region* get_region(int key);
111    
112      Glib::RefPtr<Gdk::GC> gc;      Gdk::RGBA activeKeyColor, blue, grey1, white, black;
113      Gdk::Color activeKeyColor, red, grey1, white, black;      Glib::RefPtr<Gdk::Pixbuf> blueHatchedPatternARGB;
114        Cairo::RefPtr<Cairo::SurfacePattern> blueHatchedSurfacePattern;
115    
116      sigc::signal<void> region_selected;      sigc::signal<void> region_selected;
117      sigc::signal<void> instrument_changed;      sigc::signal<void> instrument_changed;
# Line 101  protected: Line 130  protected:
130      SortedRegions regions;      SortedRegions regions;
131    
132      bool is_black_key(int key);      bool is_black_key(int key);
133      void draw_region(int from, int to, const Gdk::Color& color);      void draw_keyboard(const Cairo::RefPtr<Cairo::Context>& cr,
134      void draw_digit(int key);                         int clip_low, int clip_high);
135        void draw_regions(const Cairo::RefPtr<Cairo::Context>& cr,
136                          int clip_low, int clip_high);
137        void draw_key(const Cairo::RefPtr<Cairo::Context>& cr, int key);
138        void draw_digit(const Cairo::RefPtr<Cairo::Context>& cr, int key);
139      void motion_resize_region(int x, int y);      void motion_resize_region(int x, int y);
140      void motion_move_region(int x, int y);      void motion_move_region(int x, int y);
141        void update_after_resize();
142        void update_after_move(int pos);
143        void invalidate_key(int key);
144        void on_show_tooltips_changed();
145    
146        // returns the leftmost pixel of a key
147        int key_to_x(double k, int w) const {
148            return int(k * w / 128.0 + 0.5);
149        }
150    
151        // returns the key given a pixel
152        int x_to_key(double x, int w) const {
153            return int(x / w * 128.0);
154        }
155    
156        // returns the key given a pixel. If the pixel is the border
157        // between two keys, the key to the ríght is always returned.
158        int x_to_key_right(double x, int w) const {
159            return int(ceil((x + 0.5) / w * 128.0)) - 1;
160        }
161    
162      // information needed during a resize      // information needed during a resize
163      struct {      struct {
# Line 124  protected: Line 177  protected:
177      // information needed during a region move      // information needed during a region move
178      struct {      struct {
179          bool active;          bool active;
180          double from_x;          int offset;
         int pos;  
         bool touch_left;  
         bool touch_right;  
181      } move;      } move;
182    
183      bool cursor_is_resize;      bool cursor_is_resize;
# Line 135  protected: Line 185  protected:
185    
186      int h1;      int h1;
187    
188        // ATM only used for painting auto selected regions with gray hatched pattern
189        bool modifyallregions;
190    
191      Gtk::Menu* popup_menu_inside_region;      Gtk::Menu* popup_menu_inside_region;
192      Gtk::Menu* popup_menu_outside_region;      Gtk::Menu* popup_menu_outside_region;
193      void show_region_properties();      void show_region_properties();
# Line 144  protected: Line 197  protected:
197      void on_dimension_manager_changed();      void on_dimension_manager_changed();
198      int new_region_pos;      int new_region_pos;
199    
200      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<ActionGroup> actionGroup;
201    #if USE_GTKMM_BUILDER
202        Glib::RefPtr<Gtk::Builder> uiManager;
203    #else
204      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
205    #endif
206    
207        // properties of the virtual keyboard
208        ChoiceEntry<virt_keyboard_mode_t> m_VirtKeybModeChoice;
209        Gtk::Label m_VirtKeybVelocityLabelDescr;
210        Gtk::Label m_VirtKeybVelocityLabel;
211        Gtk::Label m_VirtKeybOffVelocityLabelDescr;
212        Gtk::Label m_VirtKeybOffVelocityLabel;
213        int currentActiveKey;
214        bool key_pressed[128];
215    
216      DimensionManager dimensionManager;      DimensionManager dimensionManager;
217  };  };

Legend:
Removed from v.1660  
changed lines
  Added in v.3409

  ViewVC Help
Powered by ViewVC