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

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

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

revision 2392 by persson, Mon Jan 7 20:41:16 2013 UTC revision 2507 by persson, Sun Jan 12 19:37:55 2014 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2013 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 42  bool VelocityCurve::on_draw(const Cairo: Line 42  bool VelocityCurve::on_draw(const Cairo:
42          int h = get_height();          int h = get_height();
43    
44          for (int pass = 0 ; pass < 2 ; pass++) {          for (int pass = 0 ; pass < 2 ; pass++) {
45              for (int x = 0 ; x < w ; x++) {              for (double x = 0 ; x <= w ; x++) {
46                  int vel = int(x * 126.0 / w + 1.5);                  int vel = int(x * (127 - 1e-10) / w + 1);
47                  int y = int((1 - (dimreg->*getter)(vel)) * (h - 1));                  double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
48    
49                  if (x == 0) {                  if (x < 1e-10) {
50                      cr->move_to(x, y);                      cr->move_to(x, y);
51                  } else {                  } else {
52                      cr->line_to(x, y);                      cr->line_to(x, y);
53                  }                  }
54              }              }
55              if (pass == 0) {              if (pass == 0) {
56                  cr->line_to(w - 1, h - 1);                  cr->line_to(w, h);
57                  cr->line_to(0, h - 1);                  cr->line_to(0, h);
58                  cr->set_source_rgba(0.5, 0.44, 1.0, 0.2);                  cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
59                  cr->fill();                  cr->fill();
60              } else {              } else {
61                  cr->set_line_width(3);                  cr->set_line_width(3);
62                  cr->set_source_rgb(0.5, 0.44, 1.0);                  cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
63                  cr->stroke();                  cr->stroke();
64              }              }
65          }          }
# Line 82  bool CrossfadeCurve::on_expose_event(Gdk Line 82  bool CrossfadeCurve::on_expose_event(Gdk
82  #else  #else
83  bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {  bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
84  #endif  #endif
85      if (dimreg && dimreg->Crossfade.out_end) {      if (dimreg) {
86          int w = get_width();          cr->translate(1.5, 0);
87          int h = get_height();  
88                    // first, draw curves for the other layers
89            gig::Region* region = dimreg->GetParent();
90            int dimregno;
91            for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
92                if (region->pDimensionRegions[dimregno] == dimreg) {
93                    break;
94                }
95            }
96            int bitcount = 0;
97            for (int dim = 0 ; dim < region->Dimensions ; dim++) {
98                if (region->pDimensionDefinitions[dim].dimension ==
99                    gig::dimension_layer) {
100                    int mask =
101                        ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
102                          bitcount);
103                    int c = dimregno & mask; // mask away the layer dimension
104    
105                    for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
106                         i++) {
107                        gig::DimensionRegion* d =
108                            region->pDimensionRegions[c + (i << bitcount)];
109                        if (d != dimreg) {
110                            draw_one_curve(cr, d, false);
111                        }
112                    }
113                    break;
114                }
115                bitcount += region->pDimensionDefinitions[dim].bits;
116            }
117    
118            // then, draw the currently selected layer
119            draw_one_curve(cr, dimreg, is_sensitive());
120        }
121        return true;
122    }
123    
124    void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
125                                        const gig::DimensionRegion* d,
126                                        bool sensitive) {
127        int w = get_width();
128        int h = get_height();
129    
130        if (d->Crossfade.out_end) {
131          for (int pass = 0 ; pass < 2 ; pass++) {          for (int pass = 0 ; pass < 2 ; pass++) {
132              cr->move_to(dimreg->Crossfade.in_start / 127.0 * (w - 4) + 2, h);              cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
133              cr->line_to(dimreg->Crossfade.in_end / 127.0 * (w - 4) + 2, 2);              cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
134              cr->line_to(dimreg->Crossfade.out_start / 127.0 * (w - 4) + 2, 2);              cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
135              cr->line_to(dimreg->Crossfade.out_end / 127.0 * (w - 4) + 2, h);              cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
136    
137              if (pass == 0) {              if (pass == 0) {
138                  cr->line_to(dimreg->Crossfade.in_start / 127.0 * (w - 4) + 2,                  cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
                             h);  
                 cr->set_source_rgba(0.5, 0.44, 1.0, 0.2);  
139                  cr->fill();                  cr->fill();
140              } else {              } else {
141                  cr->set_line_width(3);                  cr->set_line_width(3);
142                  cr->set_source_rgb(0.5, 0.44, 1.0);                  cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
143                  cr->stroke();                  cr->stroke();
144              }              }
145          }          }
146      }      }
     return true;  
147  }  }
148    
149    
# Line 886  void DimRegionEdit::set_dim_region(gig:: Line 925  void DimRegionEdit::set_dim_region(gig::
925          d->pSample ? d->pSample->LoopPlayCount : 0);          d->pSample ? d->pSample->LoopPlayCount : 0);
926      update_model--;      update_model--;
927    
928      wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : _("NULL"));      wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
929                          _("NULL"));
930    
931      update_loop_elements();      update_loop_elements();
932      VCFEnabled_toggled();      VCFEnabled_toggled();
# Line 901  void DimRegionEdit::VCFEnabled_toggled() Line 941  void DimRegionEdit::VCFEnabled_toggled()
941      eVCFVelocityCurve.set_sensitive(sensitive);      eVCFVelocityCurve.set_sensitive(sensitive);
942      eVCFVelocityScale.set_sensitive(sensitive);      eVCFVelocityScale.set_sensitive(sensitive);
943      eVCFVelocityDynamicRange.set_sensitive(sensitive);      eVCFVelocityDynamicRange.set_sensitive(sensitive);
944        cutoff_curve.set_sensitive(sensitive);
945      eVCFResonance.set_sensitive(sensitive);      eVCFResonance.set_sensitive(sensitive);
946      eVCFResonanceController.set_sensitive(sensitive);      eVCFResonanceController.set_sensitive(sensitive);
947      eVCFKeyboardTracking.set_sensitive(sensitive);      eVCFKeyboardTracking.set_sensitive(sensitive);
# Line 993  void DimRegionEdit::AttenuationControlle Line 1034  void DimRegionEdit::AttenuationControlle
1034      eCrossfade_in_end.set_sensitive(hasController);      eCrossfade_in_end.set_sensitive(hasController);
1035      eCrossfade_out_start.set_sensitive(hasController);      eCrossfade_out_start.set_sensitive(hasController);
1036      eCrossfade_out_end.set_sensitive(hasController);      eCrossfade_out_end.set_sensitive(hasController);
1037        crossfade_curve.set_sensitive(hasController);
1038  }  }
1039    
1040  void DimRegionEdit::LFO1Controller_changed()  void DimRegionEdit::LFO1Controller_changed()
# Line 1106  void DimRegionEdit::loop_infinite_toggle Line 1148  void DimRegionEdit::loop_infinite_toggle
1148      update_model--;      update_model--;
1149  }  }
1150    
1151  bool DimRegionEdit::set_sample(gig::Sample* sample)  bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1152  {  {
1153      if (dimregion) {      if (dimregion) {
1154          //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here          //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
# Line 1150  bool DimRegionEdit::set_sample(gig::Samp Line 1192  bool DimRegionEdit::set_sample(gig::Samp
1192              d[i]->pSample = sample;              d[i]->pSample = sample;
1193    
1194              // copy sample information from Sample to DimensionRegion              // copy sample information from Sample to DimensionRegion
1195                if (copy_sample_unity)
1196              d[i]->UnityNote = sample->MIDIUnityNote;                  d[i]->UnityNote = sample->MIDIUnityNote;
1197              d[i]->FineTune = sample->FineTune;              if (copy_sample_tune)
1198                    d[i]->FineTune = sample->FineTune;
1199              int loops = sample->Loops ? 1 : 0;              if (copy_sample_loop) {
1200              while (d[i]->SampleLoops > loops) {                  int loops = sample->Loops ? 1 : 0;
1201                  d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);                  while (d[i]->SampleLoops > loops) {
1202              }                      d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1203              while (d[i]->SampleLoops < sample->Loops) {                  }
1204                  DLS::sample_loop_t loop;                  while (d[i]->SampleLoops < sample->Loops) {
1205                  d[i]->AddSampleLoop(&loop);                      DLS::sample_loop_t loop;
1206              }                      d[i]->AddSampleLoop(&loop);
1207              if (loops) {                  }
1208                  d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);                  if (loops) {
1209                  d[i]->pSampleLoops[0].LoopType = sample->LoopType;                      d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1210                  d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;                      d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1211                  d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;                      d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1212                        d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1213                    }
1214              }              }
1215          }          }
1216    
1217          // update ui          // update ui
1218          update_model++;          update_model++;
1219          wSample->set_text(dimregion->pSample->pInfo->Name);          wSample->set_text(gig_to_utf8(dimregion->pSample->pInfo->Name));
1220          eUnityNote.set_value(dimregion->UnityNote);          eUnityNote.set_value(dimregion->UnityNote);
1221          eFineTune.set_value(dimregion->FineTune);          eFineTune.set_value(dimregion->FineTune);
1222          eSampleLoopEnabled.set_value(dimregion->SampleLoops);          eSampleLoopEnabled.set_value(dimregion->SampleLoops);

Legend:
Removed from v.2392  
changed lines
  Added in v.2507

  ViewVC Help
Powered by ViewVC