92 |
modifybothchannels = modifyalldimregs = modifybothchannels = false; |
modifybothchannels = modifyalldimregs = modifybothchannels = false; |
93 |
set_can_focus(); |
set_can_focus(); |
94 |
|
|
95 |
|
const Glib::ustring txtUseCheckBoxAllRegions = |
96 |
|
_("Use checkbox 'all regions' to control whether this should apply to all regions."); |
97 |
|
|
98 |
actionGroup = Gtk::ActionGroup::create(); |
actionGroup = Gtk::ActionGroup::create(); |
99 |
|
actionSplitDimZone = Gtk::Action::create("SplitDimZone", _("Split Dimensions Zone"), txtUseCheckBoxAllRegions); |
100 |
|
actionSplitDimZone->set_tooltip(txtUseCheckBoxAllRegions); //FIXME: doesn't work? why??? |
101 |
actionGroup->add( |
actionGroup->add( |
102 |
Gtk::Action::create("SplitDimZone", _("Split Dimensions Zone")), |
actionSplitDimZone, |
103 |
sigc::mem_fun(*this, &DimRegionChooser::split_dimension_zone) |
sigc::mem_fun(*this, &DimRegionChooser::split_dimension_zone) |
104 |
); |
); |
105 |
|
actionDeleteDimZone = Gtk::Action::create("DeleteDimZone", _("Delete Dimension Zone"), txtUseCheckBoxAllRegions); |
106 |
|
actionDeleteDimZone->set_tooltip(txtUseCheckBoxAllRegions); //FIXME: doesn't work? why??? |
107 |
actionGroup->add( |
actionGroup->add( |
108 |
Gtk::Action::create("DeleteDimZone", _("Delete Dimension Zone")), |
actionDeleteDimZone, |
109 |
sigc::mem_fun(*this, &DimRegionChooser::delete_dimension_zone) |
sigc::mem_fun(*this, &DimRegionChooser::delete_dimension_zone) |
110 |
); |
); |
111 |
|
|
160 |
|
|
161 |
void DimRegionChooser::setModifyAllRegions(bool b) { |
void DimRegionChooser::setModifyAllRegions(bool b) { |
162 |
modifyallregions = b; |
modifyallregions = b; |
163 |
|
|
164 |
|
actionDeleteDimZone->set_label(b ? _("Delete Dimension Zone [ALL REGIONS]") : _("Delete Dimension Zone")); |
165 |
|
actionSplitDimZone->set_label(b ? _("Split Dimensions Zone [ALL REGIONS]") : _("Split Dimensions Zone")); |
166 |
} |
} |
167 |
|
|
168 |
#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 |
1018 |
void DimRegionChooser::split_dimension_zone() { |
void DimRegionChooser::split_dimension_zone() { |
1019 |
printf("split_dimension_zone() type=%d, zone=%d\n", maindimtype, maindimcase[maindimtype]); |
printf("split_dimension_zone() type=%d, zone=%d\n", maindimtype, maindimcase[maindimtype]); |
1020 |
try { |
try { |
1021 |
region->SplitDimensionZone(maindimtype, maindimcase[maindimtype]); |
if (!modifyallregions) { |
1022 |
|
region->SplitDimensionZone(maindimtype, maindimcase[maindimtype]); |
1023 |
|
} else { |
1024 |
|
gig::Instrument* instr = (gig::Instrument*)region->GetParent(); |
1025 |
|
gig::dimension_def_t* pMaindimdef = region->GetDimensionDefinition(maindimtype); |
1026 |
|
assert(pMaindimdef != NULL); |
1027 |
|
// retain structure by value since the original region will be |
1028 |
|
// modified in the loop below as well |
1029 |
|
gig::dimension_def_t maindimdef = *pMaindimdef; |
1030 |
|
std::vector<gig::Region*> ignoredAll; |
1031 |
|
std::vector<gig::Region*> ignoredMinor; |
1032 |
|
std::vector<gig::Region*> ignoredCritical; |
1033 |
|
gig::Region* rgn = NULL; |
1034 |
|
for (int key = 0; key < 128; ++key) { |
1035 |
|
if (!instr->GetRegion(key) || instr->GetRegion(key) == rgn) continue; |
1036 |
|
rgn = instr->GetRegion(key); |
1037 |
|
|
1038 |
|
// ignore all regions which do not exactly match the dimension |
1039 |
|
// layout of the selected region where this operation was emitted |
1040 |
|
gig::dimension_def_t* dimdef = rgn->GetDimensionDefinition(maindimtype); |
1041 |
|
if (!dimdef) { |
1042 |
|
ignoredAll.push_back(rgn); |
1043 |
|
ignoredMinor.push_back(rgn); |
1044 |
|
continue; |
1045 |
|
} |
1046 |
|
if (dimdef->zones != maindimdef.zones) { |
1047 |
|
ignoredAll.push_back(rgn); |
1048 |
|
ignoredCritical.push_back(rgn); |
1049 |
|
continue; |
1050 |
|
} |
1051 |
|
|
1052 |
|
rgn->SplitDimensionZone(maindimtype, maindimcase[maindimtype]); |
1053 |
|
} |
1054 |
|
if (!ignoredAll.empty()) { |
1055 |
|
Glib::ustring txt; |
1056 |
|
if (ignoredCritical.empty()) |
1057 |
|
txt = ToString(ignoredMinor.size()) + _(" regions have been ignored since they don't have that dimension type."); |
1058 |
|
else if (ignoredMinor.empty()) |
1059 |
|
txt = ToString(ignoredCritical.size()) + _(" regions have been ignored due to different amount of dimension zones!"); |
1060 |
|
else |
1061 |
|
txt = ToString(ignoredCritical.size()) + _(" regions have been ignored due to different amount of dimension zones (and ") + |
1062 |
|
ToString(ignoredMinor.size()) + _(" regions have been ignored since they don't have that dimension type)!"); |
1063 |
|
Gtk::MessageType type = (ignoredCritical.empty()) ? Gtk::MESSAGE_INFO : Gtk::MESSAGE_WARNING; |
1064 |
|
Gtk::MessageDialog msg(txt, false, type); |
1065 |
|
msg.run(); |
1066 |
|
} |
1067 |
|
} |
1068 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1069 |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
1070 |
msg.run(); |
msg.run(); |
1079 |
void DimRegionChooser::delete_dimension_zone() { |
void DimRegionChooser::delete_dimension_zone() { |
1080 |
printf("delete_dimension_zone() type=%d, zone=%d\n", maindimtype, maindimcase[maindimtype]); |
printf("delete_dimension_zone() type=%d, zone=%d\n", maindimtype, maindimcase[maindimtype]); |
1081 |
try { |
try { |
1082 |
region->DeleteDimensionZone(maindimtype, maindimcase[maindimtype]); |
if (!modifyallregions) { |
1083 |
|
region->DeleteDimensionZone(maindimtype, maindimcase[maindimtype]); |
1084 |
|
} else { |
1085 |
|
gig::Instrument* instr = (gig::Instrument*)region->GetParent(); |
1086 |
|
gig::dimension_def_t* pMaindimdef = region->GetDimensionDefinition(maindimtype); |
1087 |
|
assert(pMaindimdef != NULL); |
1088 |
|
// retain structure by value since the original region will be |
1089 |
|
// modified in the loop below as well |
1090 |
|
gig::dimension_def_t maindimdef = *pMaindimdef; |
1091 |
|
std::vector<gig::Region*> ignoredAll; |
1092 |
|
std::vector<gig::Region*> ignoredMinor; |
1093 |
|
std::vector<gig::Region*> ignoredCritical; |
1094 |
|
gig::Region* rgn = NULL; |
1095 |
|
for (int key = 0; key < 128; ++key) { |
1096 |
|
if (!instr->GetRegion(key) || instr->GetRegion(key) == rgn) continue; |
1097 |
|
rgn = instr->GetRegion(key); |
1098 |
|
|
1099 |
|
// ignore all regions which do not exactly match the dimension |
1100 |
|
// layout of the selected region where this operation was emitted |
1101 |
|
gig::dimension_def_t* dimdef = rgn->GetDimensionDefinition(maindimtype); |
1102 |
|
if (!dimdef) { |
1103 |
|
ignoredAll.push_back(rgn); |
1104 |
|
ignoredMinor.push_back(rgn); |
1105 |
|
continue; |
1106 |
|
} |
1107 |
|
if (dimdef->zones != maindimdef.zones) { |
1108 |
|
ignoredAll.push_back(rgn); |
1109 |
|
ignoredCritical.push_back(rgn); |
1110 |
|
continue; |
1111 |
|
} |
1112 |
|
|
1113 |
|
rgn->DeleteDimensionZone(maindimtype, maindimcase[maindimtype]); |
1114 |
|
} |
1115 |
|
if (!ignoredAll.empty()) { |
1116 |
|
Glib::ustring txt; |
1117 |
|
if (ignoredCritical.empty()) |
1118 |
|
txt = ToString(ignoredMinor.size()) + _(" regions have been ignored since they don't have that dimension type."); |
1119 |
|
else if (ignoredMinor.empty()) |
1120 |
|
txt = ToString(ignoredCritical.size()) + _(" regions have been ignored due to different amount of dimension zones!"); |
1121 |
|
else |
1122 |
|
txt = ToString(ignoredCritical.size()) + _(" regions have been ignored due to different amount of dimension zones (and ") + |
1123 |
|
ToString(ignoredMinor.size()) + _(" regions have been ignored since they don't have that dimension type)!"); |
1124 |
|
Gtk::MessageType type = (ignoredCritical.empty()) ? Gtk::MESSAGE_INFO : Gtk::MESSAGE_WARNING; |
1125 |
|
Gtk::MessageDialog msg(txt, false, type); |
1126 |
|
msg.run(); |
1127 |
|
} |
1128 |
|
} |
1129 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
1130 |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
1131 |
msg.run(); |
msg.run(); |