/[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 2691 by schoenebeck, Sun Jan 4 19:46:54 2015 UTC revision 2877 by schoenebeck, Fri Apr 15 13:45:12 2016 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2015 Andreas Persson   * Copyright (C) 2006-2016 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 241  DimRegionEdit::DimRegionEdit() : Line 241  DimRegionEdit::DimRegionEdit() :
241      eSampleLoopType(_("Loop type")),      eSampleLoopType(_("Loop type")),
242      eSampleLoopInfinite(_("Infinite loop")),      eSampleLoopInfinite(_("Infinite loop")),
243      eSampleLoopPlayCount(_("Playback count"), 1),      eSampleLoopPlayCount(_("Playback count"), 1),
244      buttonSelectSample(Glib::ustring("<- ") + _("Select Sample")),      buttonSelectSample(UNICODE_LEFT_ARROW + "  " + _("Select Sample")),
245      update_model(0)      update_model(0)
246  {  {
247        // make synthesis parameter page tabs scrollable
248        // (workaround for GTK3: default theme uses huge tabs which breaks layout)
249        set_scrollable();
250    
251      connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);      connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
252      connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);      connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
253      connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);      connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
# Line 450  DimRegionEdit::DimRegionEdit() : Line 454  DimRegionEdit::DimRegionEdit() :
454      firstRowInBlock = 0;      firstRowInBlock = 0;
455    
456      addHeader(_("Mandatory Settings"));      addHeader(_("Mandatory Settings"));
457      addString(_("Sample"), lSample, wSample);      addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
458        buttonNullSampleReference->set_label("X");
459        buttonNullSampleReference->set_tooltip_text(_("Remove current sample reference (NULL reference). This can be used to define a \"silent\" case where no sample shall be played."));
460        buttonNullSampleReference->signal_clicked().connect(
461            sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
462        );
463      //TODO: the following would break drag&drop:   wSample->property_editable().set_value(false);  or this:    wSample->set_editable(false);      //TODO: the following would break drag&drop:   wSample->property_editable().set_value(false);  or this:    wSample->set_editable(false);
464  #ifdef OLD_TOOLTIPS  #ifdef OLD_TOOLTIPS
465      tooltips.set_tip(*wSample, _("Drag & drop a sample here"));      tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
# Line 835  void DimRegionEdit::addString(const char Line 844  void DimRegionEdit::addString(const char
844      rowno++;      rowno++;
845  }  }
846    
847    void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
848                                  Gtk::Entry*& widget, Gtk::Button*& button)
849    {
850        label = new Gtk::Label(Glib::ustring(labelText) + ":");
851        label->set_alignment(Gtk::ALIGN_START);
852    
853        table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
854                              Gtk::FILL, Gtk::SHRINK);
855    
856        widget = new Gtk::Entry();
857        button = new Gtk::Button();
858    
859        Gtk::HBox* hbox = new Gtk::HBox;
860        hbox->pack_start(*widget);
861        hbox->pack_start(*button, Gtk::PACK_SHRINK);
862    
863        table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
864                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
865    
866        rowno++;
867    }
868    
869  Gtk::Label* DimRegionEdit::addHeader(const char* text)  Gtk::Label* DimRegionEdit::addHeader(const char* text)
870  {  {
871      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
# Line 1469  void DimRegionEdit::set_LoopPlayCount(gi Line 1500  void DimRegionEdit::set_LoopPlayCount(gi
1500      if (d->pSample) d->pSample->LoopPlayCount = value;      if (d->pSample) d->pSample->LoopPlayCount = value;
1501  }  }
1502    
1503    void DimRegionEdit::nullOutSampleReference() {
1504        if (!dimregion) return;
1505        gig::Sample* oldref = dimregion->pSample;
1506        if (!oldref) return;
1507    
1508        dimreg_to_be_changed_signal.emit(dimregion);
1509    
1510        // in case currently assigned sample is a stereo one, then remove both
1511        // references (expected to be due to a "stereo dimension")
1512        gig::DimensionRegion* d[2] = { dimregion, NULL };
1513        if (oldref->Channels == 2) {
1514            gig::Region* region = dimregion->GetParent();
1515            {
1516                int stereo_bit = 0;
1517                int bitcount = 0;
1518                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1519                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1520                        stereo_bit = 1 << bitcount;
1521                        break;
1522                    }
1523                    bitcount += region->pDimensionDefinitions[dim].bits;
1524                }
1525    
1526                if (stereo_bit) {
1527                    int dimregno;
1528                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1529                        if (region->pDimensionRegions[dimregno] == dimregion) {
1530                            break;
1531                        }
1532                    }
1533                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1534                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1535                }
1536            }
1537        }
1538    
1539        if (d[0]) d[0]->pSample = NULL;
1540        if (d[1]) d[1]->pSample = NULL;
1541    
1542        // update UI elements
1543        set_dim_region(dimregion);
1544    
1545        sample_ref_changed_signal.emit(oldref, NULL);
1546        dimreg_changed_signal.emit(dimregion);
1547    }
1548    
1549  void DimRegionEdit::onButtonSelectSamplePressed() {  void DimRegionEdit::onButtonSelectSamplePressed() {
1550      if (!dimregion) return;      if (!dimregion) return;
1551      if (!dimregion->pSample) return;      if (!dimregion->pSample) return;

Legend:
Removed from v.2691  
changed lines
  Added in v.2877

  ViewVC Help
Powered by ViewVC