/[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 2151 by persson, Sun Nov 21 12:38:41 2010 UTC revision 2397 by persson, Wed Jan 9 20:59:29 2013 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2010 Andreas Persson   * Copyright (C) 2006-2013 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 "dimregionedit.h"  #include "dimregionedit.h"
21    
22  #include "global.h"  #include "global.h"
23    #include "compat.h"
24    
25    VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) :
26        getter(getter), dimreg(0) {
27        set_size_request(80, 80);
28    }
29    
30    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
31    bool VelocityCurve::on_expose_event(GdkEventExpose* e) {
32        const Cairo::RefPtr<Cairo::Context>& cr =
33            get_window()->create_cairo_context();
34    #if 0
35    }
36    #endif
37    #else
38    bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
39    #endif
40        if (dimreg) {
41            int w = get_width();
42            int h = get_height();
43    
44            for (int pass = 0 ; pass < 2 ; pass++) {
45                for (double x = 0 ; x <= w ; x++) {
46                    int vel = int(x * (127 - 1e-10) / w + 1);
47                    double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
48    
49                    if (x < 1e-10) {
50                        cr->move_to(x, y);
51                    } else {
52                        cr->line_to(x, y);
53                    }
54                }
55                if (pass == 0) {
56                    cr->line_to(w, h);
57                    cr->line_to(0, h);
58                    cr->set_source_rgba(0.5, 0.44, 1.0, 0.2);
59                    cr->fill();
60                } else {
61                    cr->set_line_width(3);
62                    cr->set_source_rgb(0.5, 0.44, 1.0);
63                    cr->stroke();
64                }
65            }
66        }
67        return true;
68    }
69    
70    
71    CrossfadeCurve::CrossfadeCurve() : dimreg(0) {
72        set_size_request(280, 80);
73    }
74    
75    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
76    bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) {
77        const Cairo::RefPtr<Cairo::Context>& cr =
78            get_window()->create_cairo_context();
79    #if 0
80    }
81    #endif
82    #else
83    bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
84    #endif
85        if (dimreg && dimreg->Crossfade.out_end) {
86            int w = get_width();
87            int h = get_height();
88            
89            cr->translate(1.5, 0);
90            for (int pass = 0 ; pass < 2 ; pass++) {
91                cr->move_to(dimreg->Crossfade.in_start / 127.0 * (w - 3), h);
92                cr->line_to(dimreg->Crossfade.in_end / 127.0 * (w - 3), 1.5);
93                cr->line_to(dimreg->Crossfade.out_start / 127.0 * (w - 3), 1.5);
94                cr->line_to(dimreg->Crossfade.out_end / 127.0 * (w - 3), h);
95    
96                if (pass == 0) {
97                    cr->set_source_rgba(0.5, 0.44, 1.0, 0.2);
98                    cr->fill();
99                } else {
100                    cr->set_line_width(3);
101                    cr->set_source_rgb(0.5, 0.44, 1.0);
102                    cr->stroke();
103                }
104            }
105        }
106        return true;
107    }
108    
109    
110  DimRegionEdit::DimRegionEdit() :  DimRegionEdit::DimRegionEdit() :
111        velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
112        release_curve(&gig::DimensionRegion::GetVelocityRelease),
113        cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
114      eEG1PreAttack(_("Pre-attack"), 0, 100, 2),      eEG1PreAttack(_("Pre-attack"), 0, 100, 2),
115      eEG1Attack(_("Attack"), 0, 60, 3),      eEG1Attack(_("Attack"), 0, 60, 3),
116      eEG1Decay1(_("Decay 1"), 0.005, 60, 3),      eEG1Decay1(_("Decay 1"), 0.005, 60, 3),
# Line 344  DimRegionEdit::DimRegionEdit() : Line 433  DimRegionEdit::DimRegionEdit() :
433      addProp(eCrossfade_out_start);      addProp(eCrossfade_out_start);
434      addProp(eCrossfade_out_end);      addProp(eCrossfade_out_end);
435    
436        Gtk::Frame* frame = new Gtk::Frame;
437        frame->add(crossfade_curve);
438        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
439                              Gtk::SHRINK, Gtk::SHRINK);
440        rowno++;
441    
442        eCrossfade_in_start.signal_value_changed().connect(
443            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
444        eCrossfade_in_end.signal_value_changed().connect(
445            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
446        eCrossfade_out_start.signal_value_changed().connect(
447            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
448        eCrossfade_out_end.signal_value_changed().connect(
449            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
450    
451      nextPage();      nextPage();
452    
453      addHeader(_("General Filter Settings"));      addHeader(_("General Filter Settings"));
# Line 394  DimRegionEdit::DimRegionEdit() : Line 498  DimRegionEdit::DimRegionEdit() :
498      addProp(eVCFVelocityCurve);      addProp(eVCFVelocityCurve);
499      addProp(eVCFVelocityScale);      addProp(eVCFVelocityScale);
500      addProp(eVCFVelocityDynamicRange);      addProp(eVCFVelocityDynamicRange);
501    
502        eVCFCutoffController.signal_value_changed().connect(
503            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
504        eVCFVelocityCurve.signal_value_changed().connect(
505            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
506        eVCFVelocityScale.signal_value_changed().connect(
507            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
508        eVCFVelocityDynamicRange.signal_value_changed().connect(
509            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
510    
511        frame = new Gtk::Frame;
512        frame->add(cutoff_curve);
513        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
514                              Gtk::SHRINK, Gtk::SHRINK);
515        rowno++;
516    
517      addProp(eVCFResonance);      addProp(eVCFResonance);
518      addProp(eVCFResonanceDynamic);      addProp(eVCFResonanceDynamic);
519      {      {
# Line 476  DimRegionEdit::DimRegionEdit() : Line 596  DimRegionEdit::DimRegionEdit() :
596    
597      nextPage();      nextPage();
598    
599        addHeader(_("Velocity Reponse"));
600      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
601      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
602      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
603      addProp(eVelocityResponseCurveScaling);      addProp(eVelocityResponseCurveScaling);
604    
605        eVelocityResponseCurve.signal_value_changed().connect(
606            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
607        eVelocityResponseDepth.signal_value_changed().connect(
608            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
609        eVelocityResponseCurveScaling.signal_value_changed().connect(
610            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
611    
612        frame = new Gtk::Frame;
613        frame->add(velocity_curve);
614        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
615                              Gtk::SHRINK, Gtk::SHRINK);
616        rowno++;
617    
618        addHeader(_("Release Velocity Reponse"));
619      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
620                                                curve_type_values);                                                curve_type_values);
621      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
622      addProp(eReleaseVelocityResponseDepth);      addProp(eReleaseVelocityResponseDepth);
623    
624        eReleaseVelocityResponseCurve.signal_value_changed().connect(
625            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
626        eReleaseVelocityResponseDepth.signal_value_changed().connect(
627            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
628        frame = new Gtk::Frame;
629        frame->add(release_curve);
630        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
631                              Gtk::SHRINK, Gtk::SHRINK);
632        rowno++;
633    
634      addProp(eReleaseTriggerDecay);      addProp(eReleaseTriggerDecay);
635      {      {
636          const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };          const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
# Line 560  void DimRegionEdit::addString(const char Line 707  void DimRegionEdit::addString(const char
707                                Gtk::Entry*& widget)                                Gtk::Entry*& widget)
708  {  {
709      label = new Gtk::Label(Glib::ustring(labelText) + ":");      label = new Gtk::Label(Glib::ustring(labelText) + ":");
710      label->set_alignment(Gtk::ALIGN_LEFT);      label->set_alignment(Gtk::ALIGN_START);
711    
712      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
713                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
# Line 586  Gtk::Label* DimRegionEdit::addHeader(con Line 733  Gtk::Label* DimRegionEdit::addHeader(con
733      str += "</b>";      str += "</b>";
734      Gtk::Label* label = new Gtk::Label(str);      Gtk::Label* label = new Gtk::Label(str);
735      label->set_use_markup();      label->set_use_markup();
736      label->set_alignment(Gtk::ALIGN_LEFT);      label->set_alignment(Gtk::ALIGN_START);
737      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
738                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
739      rowno++;      rowno++;
# Line 634  void DimRegionEdit::addProp(LabelWidget& Line 781  void DimRegionEdit::addProp(LabelWidget&
781  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
782  {  {
783      dimregion = d;      dimregion = d;
784        velocity_curve.set_dim_region(d);
785        release_curve.set_dim_region(d);
786        cutoff_curve.set_dim_region(d);
787        crossfade_curve.set_dim_region(d);
788    
789      set_sensitive(d);      set_sensitive(d);
790      if (!d) return;      if (!d) return;

Legend:
Removed from v.2151  
changed lines
  Added in v.2397

  ViewVC Help
Powered by ViewVC